[Ngày Phép] Bổ sung chức năng cập nhật ngày nghỉ cho ngày nghỉ đặt biệt (3 ngày nghỉ đám cưới)
This commit is contained in:
parent
308f5a3a2e
commit
af5721682b
|
|
@ -108,6 +108,7 @@ class LeaveManagementController extends Controller
|
|||
'ld_day_total' => $item->ld_day_total,
|
||||
'ld_year' => $item->ld_year,
|
||||
'ld_additional_day' => $item->ld_additional_day,
|
||||
'ld_special_leave_day' => $item->ld_special_leave_day,
|
||||
'ld_note' => $item->ld_note,
|
||||
'created_at' => $item->created_at,
|
||||
'updated_at' => $item->updated_at,
|
||||
|
|
@ -134,7 +135,8 @@ class LeaveManagementController extends Controller
|
|||
$leaveDays = LeaveDays::find($validatedData['id']);
|
||||
|
||||
$leaveDays->ld_day_total = $validatedData['totalLeave'];
|
||||
$leaveDays->ld_additional_day = $validatedData['dayAdditional']; // Assuming you have this field to store additional days
|
||||
$leaveDays->ld_additional_day = $validatedData['dayAdditional'];
|
||||
$leaveDays->ld_special_leave_day = $validatedData['specialLeave'];
|
||||
$leaveDays->ld_note = $validatedData['note'];
|
||||
|
||||
$leaveDays->save();
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ class AddMonthlyLeaveDays implements ShouldQueue
|
|||
// Nếu chưa có ghi chú, gán ghi chú mới
|
||||
$leaveDay->ld_note = $newNote;
|
||||
}
|
||||
|
||||
$leaveDay->save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class AddLdSpecialLeaveDayToLeaveDaysTable extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('leave_days', function (Blueprint $table) {
|
||||
$table->integer('ld_special_leave_day')->nullable(); // Adding the new field
|
||||
$table->float('ld_special_leave_day')->default(0); // Adding the new field
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ class RenameLdDateAdditionalToLdAdditionalDayInLeaveDaysTable extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('leave_days', function (Blueprint $table) {
|
||||
$table->renameColumn('ld_additional_day', 'ld_additional_day');
|
||||
$table->renameColumn('ld_date_additional', 'ld_additional_day');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('leave_days', function (Blueprint $table) {
|
||||
$table->renameColumn('ld_additional_day', 'ld_additional_day');
|
||||
$table->renameColumn('ld_date_additional', 'ld_additional_day');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
import { getLeaveManagement, updateNoteLeave, exportLeaveManagement } from '@/api/Admin'
|
||||
import {
|
||||
getLeaveManagement,
|
||||
updateNoteLeave,
|
||||
exportLeaveManagement,
|
||||
} from '@/api/Admin'
|
||||
import { update } from '@/rtk/helpers/CRUD'
|
||||
import { get, exportFile } from '@/rtk/helpers/apiService'
|
||||
import {
|
||||
|
|
@ -42,6 +46,7 @@ interface LeaveDay {
|
|||
ld_year: number
|
||||
ld_day_total: number
|
||||
ld_additional_day: number
|
||||
ld_special_leave_day: number
|
||||
ld_note: string
|
||||
created_at: string | null
|
||||
updated_at: string | null
|
||||
|
|
@ -75,6 +80,7 @@ const LeaveManagement = () => {
|
|||
note: string
|
||||
totalLeave: string
|
||||
dayAdditional: string
|
||||
specialLeave: string
|
||||
}>({
|
||||
id: 0,
|
||||
user: {
|
||||
|
|
@ -84,6 +90,7 @@ const LeaveManagement = () => {
|
|||
note: '',
|
||||
totalLeave: '',
|
||||
dayAdditional: '',
|
||||
specialLeave: '',
|
||||
})
|
||||
|
||||
const [data, setData] = useState<UserData[]>([])
|
||||
|
|
@ -122,6 +129,7 @@ const LeaveManagement = () => {
|
|||
},
|
||||
totalLeave: string,
|
||||
dayAdditional: string,
|
||||
specialLeave: string,
|
||||
note: string,
|
||||
) => {
|
||||
try {
|
||||
|
|
@ -132,6 +140,7 @@ const LeaveManagement = () => {
|
|||
users: users,
|
||||
totalLeave: totalLeave,
|
||||
dayAdditional: dayAdditional,
|
||||
specialLeave: specialLeave,
|
||||
note: note,
|
||||
},
|
||||
getLeaveList,
|
||||
|
|
@ -237,8 +246,8 @@ const LeaveManagement = () => {
|
|||
<div key={indexDay}>
|
||||
{isNewMonth && <p>Month {lastmonth}</p>}
|
||||
<p style={{ paddingLeft: '20px' }}>
|
||||
- {itemDay.reason_name} ({itemDay.time_type_name}) {itemDay.day}
|
||||
/{itemDay.month}
|
||||
- {itemDay.reason_name} ({itemDay.time_type_name}) {itemDay.day}/
|
||||
{itemDay.month}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
|
|
@ -249,15 +258,14 @@ const LeaveManagement = () => {
|
|||
try {
|
||||
const timestamp = moment().format('DDMMYYYY_HHmmss')
|
||||
const fileName = `LeaveManagement_${date.year}_${timestamp}.xlsx`
|
||||
|
||||
|
||||
await exportFile(
|
||||
exportLeaveManagement,
|
||||
{
|
||||
year: parseInt(date.year)
|
||||
year: parseInt(date.year),
|
||||
},
|
||||
fileName
|
||||
fileName,
|
||||
)
|
||||
|
||||
} catch (error) {
|
||||
console.error('Export error:', error)
|
||||
notifications.show({
|
||||
|
|
@ -271,9 +279,7 @@ const LeaveManagement = () => {
|
|||
return (
|
||||
<div>
|
||||
<div className={classes.title}>
|
||||
<h3>
|
||||
Leave Management
|
||||
</h3>
|
||||
<h3>Leave Management</h3>
|
||||
</div>
|
||||
<Drawer
|
||||
opened={opened1}
|
||||
|
|
@ -306,7 +312,7 @@ const LeaveManagement = () => {
|
|||
}
|
||||
}}
|
||||
label={'Total Leave'}
|
||||
placeholder="Input placeholder"
|
||||
placeholder="Input total leave days"
|
||||
/>
|
||||
<TextInput
|
||||
mb={'md'}
|
||||
|
|
@ -333,9 +339,35 @@ const LeaveManagement = () => {
|
|||
}
|
||||
}}
|
||||
label={'Day additional leave'}
|
||||
placeholder="Input placeholder"
|
||||
placeholder="Input additional leave days"
|
||||
/>
|
||||
<TextInput
|
||||
mb={'md'}
|
||||
value={customAddNotes.specialLeave}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value
|
||||
if (value) {
|
||||
const floatValue = parseFloat(value)
|
||||
if (
|
||||
/^\d*\.?\d?$/.test(value) &&
|
||||
floatValue >= 0 &&
|
||||
floatValue <= 20
|
||||
) {
|
||||
setCustomAddNotes({
|
||||
...customAddNotes,
|
||||
specialLeave: value,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
setCustomAddNotes({
|
||||
...customAddNotes,
|
||||
specialLeave: '',
|
||||
})
|
||||
}
|
||||
}}
|
||||
label={'Day special leave'}
|
||||
placeholder="Input special leave days"
|
||||
/>
|
||||
|
||||
<Textarea
|
||||
mb={'md'}
|
||||
label="Note"
|
||||
|
|
@ -368,6 +400,7 @@ const LeaveManagement = () => {
|
|||
customAddNotes.user,
|
||||
customAddNotes.totalLeave,
|
||||
customAddNotes.dayAdditional,
|
||||
customAddNotes.specialLeave,
|
||||
customAddNotes.note,
|
||||
)
|
||||
}
|
||||
|
|
@ -439,7 +472,7 @@ const LeaveManagement = () => {
|
|||
>
|
||||
<Table.Thead>
|
||||
<Table.Tr bg={'#228be66b'}>
|
||||
<Table.Th ></Table.Th>
|
||||
<Table.Th></Table.Th>
|
||||
<Table.Th>User</Table.Th>
|
||||
{monthInYear.map((d) => {
|
||||
return (
|
||||
|
|
@ -479,13 +512,22 @@ const LeaveManagement = () => {
|
|||
<Table.Td ta={'center'}>{index + 1}</Table.Td>
|
||||
<Table.Td>
|
||||
<Tooltip multiline label={user.user.name}>
|
||||
<div style={{display:'flex', alignItems:'center'}}><Avatar size={'md'} mr={'md'} src={import.meta.env.VITE_BACKEND_URL.includes('local')
|
||||
? import.meta.env.VITE_BACKEND_URL +
|
||||
'storage/' +
|
||||
user.user.avatar
|
||||
: import.meta.env.VITE_BACKEND_URL +
|
||||
'image/storage/' +
|
||||
user.user.avatar}/>{user.user.name}</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center' }}>
|
||||
<Avatar
|
||||
size={'md'}
|
||||
mr={'md'}
|
||||
src={
|
||||
import.meta.env.VITE_BACKEND_URL.includes('local')
|
||||
? import.meta.env.VITE_BACKEND_URL +
|
||||
'storage/' +
|
||||
user.user.avatar
|
||||
: import.meta.env.VITE_BACKEND_URL +
|
||||
'image/storage/' +
|
||||
user.user.avatar
|
||||
}
|
||||
/>
|
||||
{user.user.name}
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Table.Td>
|
||||
|
||||
|
|
@ -571,9 +613,12 @@ const LeaveManagement = () => {
|
|||
</Text>
|
||||
</HoverCard.Target>
|
||||
<HoverCard.Dropdown>
|
||||
<Textarea size="sm" autosize>
|
||||
{ld_note}
|
||||
</Textarea>
|
||||
<Textarea
|
||||
size="sm"
|
||||
autosize
|
||||
value={ld_note}
|
||||
readOnly
|
||||
/>
|
||||
</HoverCard.Dropdown>
|
||||
</HoverCard>
|
||||
</Box>
|
||||
|
|
@ -592,6 +637,10 @@ const LeaveManagement = () => {
|
|||
user.leaveDay.ld_additional_day == 0
|
||||
? ''
|
||||
: String(user.leaveDay.ld_additional_day)
|
||||
let specialLeave =
|
||||
user.leaveDay.ld_special_leave_day == 0
|
||||
? ''
|
||||
: String(user.leaveDay.ld_special_leave_day)
|
||||
open1()
|
||||
setCustomAddNotes({
|
||||
...customAddNotes,
|
||||
|
|
@ -599,6 +648,7 @@ const LeaveManagement = () => {
|
|||
note: ld_note,
|
||||
totalLeave: totalLeave,
|
||||
dayAdditional: dayAdditional,
|
||||
specialLeave: specialLeave,
|
||||
user: {
|
||||
id: user.user.id,
|
||||
name: user.user.name,
|
||||
|
|
|
|||
Loading…
Reference in New Issue