[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_day_total' => $item->ld_day_total,
|
||||||
'ld_year' => $item->ld_year,
|
'ld_year' => $item->ld_year,
|
||||||
'ld_additional_day' => $item->ld_additional_day,
|
'ld_additional_day' => $item->ld_additional_day,
|
||||||
|
'ld_special_leave_day' => $item->ld_special_leave_day,
|
||||||
'ld_note' => $item->ld_note,
|
'ld_note' => $item->ld_note,
|
||||||
'created_at' => $item->created_at,
|
'created_at' => $item->created_at,
|
||||||
'updated_at' => $item->updated_at,
|
'updated_at' => $item->updated_at,
|
||||||
|
|
@ -134,7 +135,8 @@ class LeaveManagementController extends Controller
|
||||||
$leaveDays = LeaveDays::find($validatedData['id']);
|
$leaveDays = LeaveDays::find($validatedData['id']);
|
||||||
|
|
||||||
$leaveDays->ld_day_total = $validatedData['totalLeave'];
|
$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->ld_note = $validatedData['note'];
|
||||||
|
|
||||||
$leaveDays->save();
|
$leaveDays->save();
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,6 @@ class AddMonthlyLeaveDays implements ShouldQueue
|
||||||
// Nếu chưa có ghi chú, gán ghi chú mới
|
// Nếu chưa có ghi chú, gán ghi chú mới
|
||||||
$leaveDay->ld_note = $newNote;
|
$leaveDay->ld_note = $newNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
$leaveDay->save();
|
$leaveDay->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class AddLdSpecialLeaveDayToLeaveDaysTable extends Migration
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::table('leave_days', function (Blueprint $table) {
|
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()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::table('leave_days', function (Blueprint $table) {
|
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()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::table('leave_days', function (Blueprint $table) {
|
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 { update } from '@/rtk/helpers/CRUD'
|
||||||
import { get, exportFile } from '@/rtk/helpers/apiService'
|
import { get, exportFile } from '@/rtk/helpers/apiService'
|
||||||
import {
|
import {
|
||||||
|
|
@ -42,6 +46,7 @@ interface LeaveDay {
|
||||||
ld_year: number
|
ld_year: number
|
||||||
ld_day_total: number
|
ld_day_total: number
|
||||||
ld_additional_day: number
|
ld_additional_day: number
|
||||||
|
ld_special_leave_day: number
|
||||||
ld_note: string
|
ld_note: string
|
||||||
created_at: string | null
|
created_at: string | null
|
||||||
updated_at: string | null
|
updated_at: string | null
|
||||||
|
|
@ -75,6 +80,7 @@ const LeaveManagement = () => {
|
||||||
note: string
|
note: string
|
||||||
totalLeave: string
|
totalLeave: string
|
||||||
dayAdditional: string
|
dayAdditional: string
|
||||||
|
specialLeave: string
|
||||||
}>({
|
}>({
|
||||||
id: 0,
|
id: 0,
|
||||||
user: {
|
user: {
|
||||||
|
|
@ -84,6 +90,7 @@ const LeaveManagement = () => {
|
||||||
note: '',
|
note: '',
|
||||||
totalLeave: '',
|
totalLeave: '',
|
||||||
dayAdditional: '',
|
dayAdditional: '',
|
||||||
|
specialLeave: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const [data, setData] = useState<UserData[]>([])
|
const [data, setData] = useState<UserData[]>([])
|
||||||
|
|
@ -122,6 +129,7 @@ const LeaveManagement = () => {
|
||||||
},
|
},
|
||||||
totalLeave: string,
|
totalLeave: string,
|
||||||
dayAdditional: string,
|
dayAdditional: string,
|
||||||
|
specialLeave: string,
|
||||||
note: string,
|
note: string,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -132,6 +140,7 @@ const LeaveManagement = () => {
|
||||||
users: users,
|
users: users,
|
||||||
totalLeave: totalLeave,
|
totalLeave: totalLeave,
|
||||||
dayAdditional: dayAdditional,
|
dayAdditional: dayAdditional,
|
||||||
|
specialLeave: specialLeave,
|
||||||
note: note,
|
note: note,
|
||||||
},
|
},
|
||||||
getLeaveList,
|
getLeaveList,
|
||||||
|
|
@ -237,8 +246,8 @@ const LeaveManagement = () => {
|
||||||
<div key={indexDay}>
|
<div key={indexDay}>
|
||||||
{isNewMonth && <p>Month {lastmonth}</p>}
|
{isNewMonth && <p>Month {lastmonth}</p>}
|
||||||
<p style={{ paddingLeft: '20px' }}>
|
<p style={{ paddingLeft: '20px' }}>
|
||||||
- {itemDay.reason_name} ({itemDay.time_type_name}) {itemDay.day}
|
- {itemDay.reason_name} ({itemDay.time_type_name}) {itemDay.day}/
|
||||||
/{itemDay.month}
|
{itemDay.month}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
@ -249,15 +258,14 @@ const LeaveManagement = () => {
|
||||||
try {
|
try {
|
||||||
const timestamp = moment().format('DDMMYYYY_HHmmss')
|
const timestamp = moment().format('DDMMYYYY_HHmmss')
|
||||||
const fileName = `LeaveManagement_${date.year}_${timestamp}.xlsx`
|
const fileName = `LeaveManagement_${date.year}_${timestamp}.xlsx`
|
||||||
|
|
||||||
await exportFile(
|
await exportFile(
|
||||||
exportLeaveManagement,
|
exportLeaveManagement,
|
||||||
{
|
{
|
||||||
year: parseInt(date.year)
|
year: parseInt(date.year),
|
||||||
},
|
},
|
||||||
fileName
|
fileName,
|
||||||
)
|
)
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Export error:', error)
|
console.error('Export error:', error)
|
||||||
notifications.show({
|
notifications.show({
|
||||||
|
|
@ -271,9 +279,7 @@ const LeaveManagement = () => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className={classes.title}>
|
<div className={classes.title}>
|
||||||
<h3>
|
<h3>Leave Management</h3>
|
||||||
Leave Management
|
|
||||||
</h3>
|
|
||||||
</div>
|
</div>
|
||||||
<Drawer
|
<Drawer
|
||||||
opened={opened1}
|
opened={opened1}
|
||||||
|
|
@ -306,7 +312,7 @@ const LeaveManagement = () => {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
label={'Total Leave'}
|
label={'Total Leave'}
|
||||||
placeholder="Input placeholder"
|
placeholder="Input total leave days"
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
mb={'md'}
|
mb={'md'}
|
||||||
|
|
@ -333,9 +339,35 @@ const LeaveManagement = () => {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
label={'Day additional leave'}
|
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
|
<Textarea
|
||||||
mb={'md'}
|
mb={'md'}
|
||||||
label="Note"
|
label="Note"
|
||||||
|
|
@ -368,6 +400,7 @@ const LeaveManagement = () => {
|
||||||
customAddNotes.user,
|
customAddNotes.user,
|
||||||
customAddNotes.totalLeave,
|
customAddNotes.totalLeave,
|
||||||
customAddNotes.dayAdditional,
|
customAddNotes.dayAdditional,
|
||||||
|
customAddNotes.specialLeave,
|
||||||
customAddNotes.note,
|
customAddNotes.note,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -439,7 +472,7 @@ const LeaveManagement = () => {
|
||||||
>
|
>
|
||||||
<Table.Thead>
|
<Table.Thead>
|
||||||
<Table.Tr bg={'#228be66b'}>
|
<Table.Tr bg={'#228be66b'}>
|
||||||
<Table.Th ></Table.Th>
|
<Table.Th></Table.Th>
|
||||||
<Table.Th>User</Table.Th>
|
<Table.Th>User</Table.Th>
|
||||||
{monthInYear.map((d) => {
|
{monthInYear.map((d) => {
|
||||||
return (
|
return (
|
||||||
|
|
@ -479,13 +512,22 @@ const LeaveManagement = () => {
|
||||||
<Table.Td ta={'center'}>{index + 1}</Table.Td>
|
<Table.Td ta={'center'}>{index + 1}</Table.Td>
|
||||||
<Table.Td>
|
<Table.Td>
|
||||||
<Tooltip multiline label={user.user.name}>
|
<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')
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
||||||
? import.meta.env.VITE_BACKEND_URL +
|
<Avatar
|
||||||
'storage/' +
|
size={'md'}
|
||||||
user.user.avatar
|
mr={'md'}
|
||||||
: import.meta.env.VITE_BACKEND_URL +
|
src={
|
||||||
'image/storage/' +
|
import.meta.env.VITE_BACKEND_URL.includes('local')
|
||||||
user.user.avatar}/>{user.user.name}</div>
|
? 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>
|
</Tooltip>
|
||||||
</Table.Td>
|
</Table.Td>
|
||||||
|
|
||||||
|
|
@ -571,9 +613,12 @@ const LeaveManagement = () => {
|
||||||
</Text>
|
</Text>
|
||||||
</HoverCard.Target>
|
</HoverCard.Target>
|
||||||
<HoverCard.Dropdown>
|
<HoverCard.Dropdown>
|
||||||
<Textarea size="sm" autosize>
|
<Textarea
|
||||||
{ld_note}
|
size="sm"
|
||||||
</Textarea>
|
autosize
|
||||||
|
value={ld_note}
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
</HoverCard.Dropdown>
|
</HoverCard.Dropdown>
|
||||||
</HoverCard>
|
</HoverCard>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
@ -592,6 +637,10 @@ const LeaveManagement = () => {
|
||||||
user.leaveDay.ld_additional_day == 0
|
user.leaveDay.ld_additional_day == 0
|
||||||
? ''
|
? ''
|
||||||
: String(user.leaveDay.ld_additional_day)
|
: String(user.leaveDay.ld_additional_day)
|
||||||
|
let specialLeave =
|
||||||
|
user.leaveDay.ld_special_leave_day == 0
|
||||||
|
? ''
|
||||||
|
: String(user.leaveDay.ld_special_leave_day)
|
||||||
open1()
|
open1()
|
||||||
setCustomAddNotes({
|
setCustomAddNotes({
|
||||||
...customAddNotes,
|
...customAddNotes,
|
||||||
|
|
@ -599,6 +648,7 @@ const LeaveManagement = () => {
|
||||||
note: ld_note,
|
note: ld_note,
|
||||||
totalLeave: totalLeave,
|
totalLeave: totalLeave,
|
||||||
dayAdditional: dayAdditional,
|
dayAdditional: dayAdditional,
|
||||||
|
specialLeave: specialLeave,
|
||||||
user: {
|
user: {
|
||||||
id: user.user.id,
|
id: user.user.id,
|
||||||
name: user.user.name,
|
name: user.user.name,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue