dev #130

Merged
joseph merged 52 commits from dev into master 2025-06-30 18:37:39 +10:00
9 changed files with 63 additions and 19 deletions
Showing only changes of commit 8ce0d957b1 - Show all commits

View File

@ -107,7 +107,7 @@ class LeaveManagementController extends Controller
'ld_user_id' => $item->ld_user_id,
'ld_day_total' => $item->ld_day_total,
'ld_year' => $item->ld_year,
'ld_date_additional' => $item->ld_date_additional,
'ld_additional_day' => $item->ld_additional_day,
'ld_note' => $item->ld_note,
'created_at' => $item->created_at,
'updated_at' => $item->updated_at,
@ -134,7 +134,7 @@ class LeaveManagementController extends Controller
$leaveDays = LeaveDays::find($validatedData['id']);
$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->save();

View File

@ -41,7 +41,7 @@ class LeaveManagementExport implements FromArray, WithHeadings, WithStyles, With
$stt = 0;
foreach ($this->data as $index => $user) {
$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
$monthlyLeaves = array_fill(1, 12, 0);

View File

@ -36,7 +36,7 @@ class DeductLeaveDays implements ShouldQueue
foreach ($users as $user) {
$existingData = LeaveDays::where('ld_user_id', $user->id)
->where('ld_year', $this->year)
->where('ld_date_additional', ">", 0)
->where('ld_additional_day', ">", 0)
->first();
if (!$existingData) {
continue;
@ -59,11 +59,11 @@ class DeductLeaveDays implements ShouldQueue
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)
if ($existingData->ld_date_additional > $totalLeaveDaysByMonth->leave_days) {
if ($existingData->ld_additional_day > $totalLeaveDaysByMonth->leave_days) {
LeaveDays::where('ld_year', $this->year)
->where('ld_user_id', $user->id)
->update([
'ld_date_additional' => $totalLeaveDaysByMonth->leave_days,
'ld_additional_day' => $totalLeaveDaysByMonth->leave_days,
]);
}
} else {
@ -71,7 +71,7 @@ class DeductLeaveDays implements ShouldQueue
LeaveDays::where('ld_year', $this->year)
->where('ld_user_id', $user->id)
->update([
'ld_date_additional' => "0",
'ld_additional_day' => "0",
]);
}
}

View File

@ -51,11 +51,11 @@ class InitializeLeaveDays implements ShouldQueue
->where('ld_year', $this->year - 1)
->first();
$ld_date_additional = 0;
$ld_additional_day = 0;
$ld_note = '';
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) {
$join->on('notes.n_time_type', '=', 'categories.c_code')
->where('categories.c_type', 'TIME_TYPE');
@ -71,9 +71,9 @@ class InitializeLeaveDays implements ShouldQueue
->groupBy(DB::raw('notes.n_year'))
->first();
if ($totalLeaveDaysByMonth) {
$ld_date_additional = $ld_date_additional - $totalLeaveDaysByMonth->leave_days;
if ($ld_date_additional < 0) {
$ld_date_additional = 0;
$ld_additional_day = $ld_additional_day - $totalLeaveDaysByMonth->leave_days;
if ($ld_additional_day < 0) {
$ld_additional_day = 0;
}
}
$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_day_total' => $ld_day_total,
'ld_year' => $this->year,
'ld_date_additional' => $ld_date_additional,
'ld_additional_day' => $ld_additional_day,
'ld_note' => $ld_note,
'created_at' => now(),
'updated_at' => now(),

View File

@ -10,7 +10,7 @@ class LeaveDays extends Model
use HasFactory;
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';

View File

@ -14,7 +14,7 @@ return new class extends Migration
Schema::create('leave_days', function (Blueprint $table) {
$table->id();
$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->float('ld_date_additional')->default(0);
$table->text('ld_note')->nullable();

View File

@ -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
});
}
}

View File

@ -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');
});
}
}

View File

@ -41,7 +41,7 @@ interface LeaveDay {
ld_user_id: number
ld_year: number
ld_day_total: number
ld_date_additional: number
ld_additional_day: number
ld_note: string
created_at: string | null
updated_at: string | null
@ -472,7 +472,7 @@ const LeaveManagement = () => {
{data.map((user, index) => {
let totalDayOff = 0
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
return (
<Table.Tr key={user.user.id} className={classes.tableTr}>
@ -589,9 +589,9 @@ const LeaveManagement = () => {
? ''
: String(user.leaveDay.ld_day_total)
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()
setCustomAddNotes({
...customAddNotes,