[Ngày Phép] Cập nhật lại tên cột cho bảng ngày nghỉ phép năm
This commit is contained in:
parent
86f2bb12fc
commit
8ce0d957b1
|
|
@ -107,7 +107,7 @@ class LeaveManagementController extends Controller
|
||||||
'ld_user_id' => $item->ld_user_id,
|
'ld_user_id' => $item->ld_user_id,
|
||||||
'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_date_additional' => $item->ld_date_additional,
|
'ld_additional_day' => $item->ld_additional_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 +134,7 @@ 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_date_additional = $validatedData['dayAdditional']; // Assuming you have this field to store additional days
|
$leaveDays->ld_additional_day = $validatedData['dayAdditional']; // Assuming you have this field to store additional days
|
||||||
$leaveDays->ld_note = $validatedData['note'];
|
$leaveDays->ld_note = $validatedData['note'];
|
||||||
|
|
||||||
$leaveDays->save();
|
$leaveDays->save();
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class LeaveManagementExport implements FromArray, WithHeadings, WithStyles, With
|
||||||
$stt = 0;
|
$stt = 0;
|
||||||
foreach ($this->data as $index => $user) {
|
foreach ($this->data as $index => $user) {
|
||||||
$totalDayOff = 0;
|
$totalDayOff = 0;
|
||||||
$totalDayLeave = $user['leaveDay']['ld_day_total'] + $user['leaveDay']['ld_date_additional'];
|
$totalDayLeave = $user['leaveDay']['ld_day_total'] + $user['leaveDay']['ld_additional_day'];
|
||||||
|
|
||||||
// Tính tổng ngày nghỉ theo tháng
|
// Tính tổng ngày nghỉ theo tháng
|
||||||
$monthlyLeaves = array_fill(1, 12, 0);
|
$monthlyLeaves = array_fill(1, 12, 0);
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class DeductLeaveDays implements ShouldQueue
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$existingData = LeaveDays::where('ld_user_id', $user->id)
|
$existingData = LeaveDays::where('ld_user_id', $user->id)
|
||||||
->where('ld_year', $this->year)
|
->where('ld_year', $this->year)
|
||||||
->where('ld_date_additional', ">", 0)
|
->where('ld_additional_day', ">", 0)
|
||||||
->first();
|
->first();
|
||||||
if (!$existingData) {
|
if (!$existingData) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -59,11 +59,11 @@ class DeductLeaveDays implements ShouldQueue
|
||||||
|
|
||||||
if ($totalLeaveDaysByMonth) {
|
if ($totalLeaveDaysByMonth) {
|
||||||
//Nếu ngày phép thừa năm trước chưa sử dụng hết => cập nhật lại ngày đó (Ngày tồn đọng - ngày sử dụng)
|
//Nếu ngày phép thừa năm trước chưa sử dụng hết => cập nhật lại ngày đó (Ngày tồn đọng - ngày sử dụng)
|
||||||
if ($existingData->ld_date_additional > $totalLeaveDaysByMonth->leave_days) {
|
if ($existingData->ld_additional_day > $totalLeaveDaysByMonth->leave_days) {
|
||||||
LeaveDays::where('ld_year', $this->year)
|
LeaveDays::where('ld_year', $this->year)
|
||||||
->where('ld_user_id', $user->id)
|
->where('ld_user_id', $user->id)
|
||||||
->update([
|
->update([
|
||||||
'ld_date_additional' => $totalLeaveDaysByMonth->leave_days,
|
'ld_additional_day' => $totalLeaveDaysByMonth->leave_days,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -71,7 +71,7 @@ class DeductLeaveDays implements ShouldQueue
|
||||||
LeaveDays::where('ld_year', $this->year)
|
LeaveDays::where('ld_year', $this->year)
|
||||||
->where('ld_user_id', $user->id)
|
->where('ld_user_id', $user->id)
|
||||||
->update([
|
->update([
|
||||||
'ld_date_additional' => "0",
|
'ld_additional_day' => "0",
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,11 @@ class InitializeLeaveDays implements ShouldQueue
|
||||||
->where('ld_year', $this->year - 1)
|
->where('ld_year', $this->year - 1)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
$ld_date_additional = 0;
|
$ld_additional_day = 0;
|
||||||
$ld_note = '';
|
$ld_note = '';
|
||||||
|
|
||||||
if ($previousYearData) {
|
if ($previousYearData) {
|
||||||
$ld_date_additional = $previousYearData->ld_day_total + $previousYearData->ld_date_additional;
|
$ld_additional_day = $previousYearData->ld_day_total + $previousYearData->ld_additional_day;
|
||||||
$totalLeaveDaysByMonth = Notes::join('categories', function ($join) {
|
$totalLeaveDaysByMonth = Notes::join('categories', function ($join) {
|
||||||
$join->on('notes.n_time_type', '=', 'categories.c_code')
|
$join->on('notes.n_time_type', '=', 'categories.c_code')
|
||||||
->where('categories.c_type', 'TIME_TYPE');
|
->where('categories.c_type', 'TIME_TYPE');
|
||||||
|
|
@ -71,9 +71,9 @@ class InitializeLeaveDays implements ShouldQueue
|
||||||
->groupBy(DB::raw('notes.n_year'))
|
->groupBy(DB::raw('notes.n_year'))
|
||||||
->first();
|
->first();
|
||||||
if ($totalLeaveDaysByMonth) {
|
if ($totalLeaveDaysByMonth) {
|
||||||
$ld_date_additional = $ld_date_additional - $totalLeaveDaysByMonth->leave_days;
|
$ld_additional_day = $ld_additional_day - $totalLeaveDaysByMonth->leave_days;
|
||||||
if ($ld_date_additional < 0) {
|
if ($ld_additional_day < 0) {
|
||||||
$ld_date_additional = 0;
|
$ld_additional_day = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ld_note = 'Cộng dồn ngày phép năm cũ';
|
$ld_note = 'Cộng dồn ngày phép năm cũ';
|
||||||
|
|
@ -84,7 +84,7 @@ class InitializeLeaveDays implements ShouldQueue
|
||||||
'ld_user_id' => $user->id,
|
'ld_user_id' => $user->id,
|
||||||
'ld_day_total' => $ld_day_total,
|
'ld_day_total' => $ld_day_total,
|
||||||
'ld_year' => $this->year,
|
'ld_year' => $this->year,
|
||||||
'ld_date_additional' => $ld_date_additional,
|
'ld_additional_day' => $ld_additional_day,
|
||||||
'ld_note' => $ld_note,
|
'ld_note' => $ld_note,
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class LeaveDays extends Model
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id', 'ld_user_id', 'ld_day_total', 'ld_year', 'ld_date_additional', 'ld_note'
|
'id', 'ld_user_id', 'ld_day_total', 'ld_year', 'ld_additional_day', 'ld_note'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $table = 'leave_days';
|
protected $table = 'leave_days';
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ return new class extends Migration
|
||||||
Schema::create('leave_days', function (Blueprint $table) {
|
Schema::create('leave_days', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->integer('ld_user_id'); // Giả định user_id là khóa ngoại
|
$table->integer('ld_user_id'); // Giả định user_id là khóa ngoại
|
||||||
$table->float('ld_day_total');
|
$table->float('ld_day');
|
||||||
$table->integer('ld_year');
|
$table->integer('ld_year');
|
||||||
$table->float('ld_date_additional')->default(0);
|
$table->float('ld_date_additional')->default(0);
|
||||||
$table->text('ld_note')->nullable();
|
$table->text('ld_note')->nullable();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('leave_days', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('ld_special_leave_day'); // Dropping the field if needed
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class RenameLdDateAdditionalToLdAdditionalDayInLeaveDaysTable extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('leave_days', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('ld_additional_day', 'ld_additional_day');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('leave_days', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('ld_additional_day', 'ld_additional_day');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -41,7 +41,7 @@ interface LeaveDay {
|
||||||
ld_user_id: number
|
ld_user_id: number
|
||||||
ld_year: number
|
ld_year: number
|
||||||
ld_day_total: number
|
ld_day_total: number
|
||||||
ld_date_additional: number
|
ld_additional_day: number
|
||||||
ld_note: string
|
ld_note: string
|
||||||
created_at: string | null
|
created_at: string | null
|
||||||
updated_at: string | null
|
updated_at: string | null
|
||||||
|
|
@ -472,7 +472,7 @@ const LeaveManagement = () => {
|
||||||
{data.map((user, index) => {
|
{data.map((user, index) => {
|
||||||
let totalDayOff = 0
|
let totalDayOff = 0
|
||||||
let totalDayLeave =
|
let totalDayLeave =
|
||||||
user.leaveDay.ld_day_total + user.leaveDay.ld_date_additional
|
user.leaveDay.ld_day_total + user.leaveDay.ld_additional_day
|
||||||
let ld_note = user.leaveDay.ld_note
|
let ld_note = user.leaveDay.ld_note
|
||||||
return (
|
return (
|
||||||
<Table.Tr key={user.user.id} className={classes.tableTr}>
|
<Table.Tr key={user.user.id} className={classes.tableTr}>
|
||||||
|
|
@ -589,9 +589,9 @@ const LeaveManagement = () => {
|
||||||
? ''
|
? ''
|
||||||
: String(user.leaveDay.ld_day_total)
|
: String(user.leaveDay.ld_day_total)
|
||||||
let dayAdditional =
|
let dayAdditional =
|
||||||
user.leaveDay.ld_date_additional == 0
|
user.leaveDay.ld_additional_day == 0
|
||||||
? ''
|
? ''
|
||||||
: String(user.leaveDay.ld_date_additional)
|
: String(user.leaveDay.ld_additional_day)
|
||||||
open1()
|
open1()
|
||||||
setCustomAddNotes({
|
setCustomAddNotes({
|
||||||
...customAddNotes,
|
...customAddNotes,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue