Skip to content

Time off management. #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9674b88
Time off management.
suraj-webkul Jan 24, 2025
ecc36bc
Add accrual plan seeder and public holiday resource; enhance calendar…
suraj-webkul Jan 24, 2025
a8d0946
Add CRUD pages for MyTimeOff and MyAllocation resources; update dashb…
suraj-webkul Jan 24, 2025
6c7e96d
Add navigation sorting and new overview/dashboard pages for time off …
suraj-webkul Jan 24, 2025
581504b
Update navigation sorting and add reporting cluster with employee res…
suraj-webkul Jan 24, 2025
8749883
Enhance CalendarWidget with improved modal actions and form handling …
suraj-webkul Jan 24, 2025
d44bdb8
Refactor ByEmployeeResource to utilize TimeOffResource for form and t…
suraj-webkul Jan 24, 2025
ec6e896
Add ByType page and LeaveTypeWidget for time off analysis; update nav…
suraj-webkul Jan 24, 2025
2bce68b
Add language files and update navigation labels for time off manageme…
suraj-webkul Jan 24, 2025
fb4846c
Add language files for time off clusters and update navigation labels
suraj-webkul Jan 24, 2025
2704bad
Refactor Leave model to rename creator method to createdBy; update gl…
suraj-webkul Jan 24, 2025
a54a4da
Add language files for My Time Off resource; implement success notifi…
suraj-webkul Jan 24, 2025
02edc24
Add title methods to ByType and Overview pages for improved navigatio…
suraj-webkul Jan 24, 2025
277721c
Add language files for notifications on create, update, and delete ac…
suraj-webkul Jan 27, 2025
feac0f4
Remove unused imports in ViewTimeOff page for cleaner code
suraj-webkul Jan 27, 2025
7092ba5
Add event title localization and fix duration calculation in Calendar…
suraj-webkul Jan 27, 2025
0a75c80
Refactor CalendarLeaves model to use creator_id instead of user_id; a…
suraj-webkul Jan 27, 2025
4200af7
Add language files for Accrual Plan management and enhance notificati…
suraj-webkul Jan 27, 2025
0e0141a
Add HolidayAction and localization for holiday management in Calendar…
suraj-webkul Jan 27, 2025
55e939c
Update localization for Accrual Plan and change navigation icon in Ac…
suraj-webkul Jan 27, 2025
ac72f08
Add LeaveMandatoryDay seeder and enhance employee notifications in ca…
suraj-webkul Jan 27, 2025
57ef701
Refactor department_id assignment to use null-safe operator for emplo…
suraj-webkul Jan 27, 2025
163dce7
Enhance HolidayAction and CalendarWidget with updated icons and null-…
suraj-webkul Jan 27, 2025
d9950c0
Add multi-month view configuration to CalendarWidget and OverviewCale…
suraj-webkul Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public function up(): void

$table->unsignedBigInteger('company_id')->nullable();
$table->unsignedBigInteger('calendar_id')->nullable();
$table->unsignedBigInteger('user_id')->nullable();
$table->unsignedBigInteger('creator_id')->nullable();

$table->foreign('company_id')->references('id')->on('companies')->onDelete('set null');
$table->foreign('calendar_id')->references('id')->on('employees_calendars')->onDelete('set null');
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
$table->foreign('creator_id')->references('id')->on('users')->onDelete('set null');

$table->timestamps();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function form(Form $form): Form
Forms\Components\Select::make('company_id')
->label(__('employees::filament/resources/department.form.sections.general.fields.company'))
->relationship('company', 'name')
->options(fn () => Company::pluck('name', 'id'))
->options(fn() => Company::pluck('name', 'id'))
->searchable()
->placeholder(__('employees::filament/resources/department.form.sections.general.fields.company-placeholder'))
->nullable(),
Expand Down Expand Up @@ -127,15 +127,15 @@ public static function table(Table $table): Table
->sortable()
->searchable(),
])
->visible(fn ($record) => filled($record?->manager?->name)),
->visible(fn($record) => filled($record?->manager?->name)),
Tables\Columns\Layout\Stack::make([
Tables\Columns\TextColumn::make('company.name')
->searchable()
->label(__('employees::filament/resources/department.table.columns.company-name'))
->icon('heroicon-m-building-office-2')
->searchable(),
])
->visible(fn ($record) => filled($record?->company?->name)),
->visible(fn($record) => filled($record?->company?->name)),
])->space(1),
])->space(4),
])
Expand Down Expand Up @@ -283,7 +283,7 @@ public static function infolist(Infolist $infolist): Infolist
Infolists\Components\TextEntry::make('hierarchy')
->label('')
->html()
->state(fn (Department $record): string => static::buildHierarchyTree($record)),
->state(fn(Department $record): string => static::buildHierarchyTree($record)),
])->columnSpan('full'),
])
->columns(2),
Expand Down Expand Up @@ -368,7 +368,7 @@ protected static function formatDepartmentLine(
$managerName = $department->manager?->name ? " · {$department->manager->name}" : '';

$style = $isActive
? 'color: '.($department->color ?? '#1D4ED8').'; font-weight: bold;'
? 'color: ' . ($department->color ?? '#1D4ED8') . '; font-weight: bold;'
: '';

return sprintf(
Expand Down
29 changes: 28 additions & 1 deletion plugins/webkul/employees/src/Models/CalendarLeaves.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
<?php

namespace App\Models;
namespace Webkul\Employee\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Webkul\Security\Models\User;
use Webkul\Support\Models\Company;

class CalendarLeaves extends Model
{
use HasFactory;

protected $table = 'employees_calendar_leaves';

protected $fillable = [
'name',
'time_type',
'date_from',
'date_to',
'company_id',
'calendar_id',
'creator_id',
];

public function createdBy()
{
return $this->belongsTo(User::class, 'creator_id');
}

public function calendar()
{
return $this->belongsTo(Calendar::class);
}

public function company()
{
return $this->belongsTo(Company::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Support\Facades\Auth;
use Webkul\Recruitment\Filament\Clusters\Applications\Resources\CandidateResource;
use Webkul\Recruitment\Filament\Clusters\Applications\Resources\CandidateResource;

class CreateCandidate extends CreateRecord
{
Expand Down
36 changes: 36 additions & 0 deletions plugins/webkul/time-off/database/seeders/AccrualPlanSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Webkul\TimeOff\Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class AccrualPlanSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('time_off_leave_accrual_plans')->delete();

$leaveAccrualPlans = [
[
'company_id' => 1,
'creator_id' => 1,
'name' => 'Seniority Plan',
'transition_mode' => 'immediately',
'accrued_gain_time' => 'end',
'carryover_date' => 'year_start',
'carryover_month' => 'jan',
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
],
];

DB::table('time_off_leave_accrual_plans')->insert($leaveAccrualPlans);
}
}
2 changes: 2 additions & 0 deletions plugins/webkul/time-off/database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class DatabaseSeeder extends Seeder
public function run($parameters = [])
{
$this->call([
AccrualPlanSeeder::class,
LeaveTypeSeeder::class,
LeaveMandatoryDay::class,
]);
}
}
45 changes: 45 additions & 0 deletions plugins/webkul/time-off/database/seeders/LeaveMandatoryDay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Webkul\TimeOff\Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class LeaveMandatoryDay extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('time_off_leave_mandatory_days')->delete();

$leaveMandatoryDays = [
[
'company_id' => 1,
'creator_id' => 1,
'color' => '#FF0000',
'name' => 'New Year',
'start_date' => '2022-01-01',
'end_date' => '2022-01-01',
'created_at' => now(),
'updated_at' => now(),
],

[
'company_id' => 1,
'creator_id' => 1,
'color' => '#FF0000',
'name' => 'Christmas',
'start_date' => '2022-12-25',
'end_date' => '2022-12-25',
'created_at' => now(),
'updated_at' => now(),
]
];

DB::table('time_off_leave_mandatory_days')->insert($leaveMandatoryDays);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'morning' => 'Morning',
'afternoon' => 'Afternoon',
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
'title' => 'Holidays',
'form' => [
'placeholders' => [
'public-holiday' => 'Public Holidays',
'mandatory-holiday' => 'Mandatory Holidays'
]
]
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'navigation' => [
'title' => 'Configuration',
'group' => 'Time Off',
]
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

return [
'title' => 'Accrual Plan',
'navigation' => [
'title' => 'Accrual Plan',
],

'global-search' => [
'name' => 'Name',
'time-off-type' => 'Time Off Type',
'created-by' => 'Created By',
],

'form' => [
'fields' => [
'name' => 'Title',
'is-based-on-worked-time' => 'Is Based on Worked Time',
'accrued-gain-time' => 'Accrued Gain Time',
'carry-over-time' => 'Carry Over Time',
'carry-over-date' => 'Carry Over Date',
'status' => 'Status',
],
],

'table' => [
'columns' => [
'name' => 'Name',
'levels' => 'Levels',
],

'actions' => [
'delete' => [
'notification' => [
'title' => 'Accrual Plan deleted',
'body' => 'The Accrual Plan has been deleted successfully.',
],
],
],

'bulk-actions' => [
'delete' => [
'notification' => [
'title' => 'Accrual Plan deleted',
'body' => 'The Accrual Plan has been deleted successfully.',
],
],
],
],

'infolist' => [
'entries' => [
'name' => 'Name',
'is-based-on-worked-time' => 'Is Based on Worked Time',
'accrued-gain-time' => 'Accrued Gain Time',
'carry-over-time' => 'Carry Over Time',
'carry-over-day' => 'Carry Over Day',
'carry-over-month' => 'Carry Over Month',
]
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'notification' => [
'title' => 'Accrual Plan Created',
'body' => 'The accrual plan has been created successfully.',
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

return [
'notification' => [
'title' => 'Accrual Type updated',
'body' => 'The accrual Type has been updated successfully.',
],

'header-actions' => [
'delete' => [
'notification' => [
'title' => 'Accrual Type deleted',
'body' => 'The accrual type has been deleted successfully.',
],
],
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'header-actions' => [
'new-accrual-plan' => 'New Accrual',
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'navigation' => [
'label' => 'Manage Milestone',
]
];
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
return [
'title' => 'Mandatory Days',

'model-label' => 'Mandatory Day',

'navigation' => [
'title' => 'Mandatory Holidays',
],

'global-search' => [
'name' => 'Name',
'start-date' => 'Start Date',
'end-date' => 'End Date',
],

'form' => [
'fields' => [
'name' => 'Name',
Expand Down
Loading