first change
This commit is contained in:
0
Modules/Leave/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Leave/app/Http/Controllers/.gitkeep
Normal file
275
Modules/Leave/app/Http/Controllers/LeaveController.php
Normal file
275
Modules/Leave/app/Http/Controllers/LeaveController.php
Normal file
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Employee\Interfaces\EmployeeInterface;
|
||||
use Modules\Leave\Models\Leave;
|
||||
use Modules\Leave\Repositories\LeaveBalanceInterface;
|
||||
use Modules\Leave\Repositories\LeaveInterface;
|
||||
use Modules\Leave\Repositories\LeaveTypeInterface;
|
||||
|
||||
class LeaveController extends Controller
|
||||
{
|
||||
private $leave;
|
||||
private $employee;
|
||||
private $leaveType;
|
||||
private $leaveBalance;
|
||||
|
||||
public function __construct(
|
||||
LeaveInterface $leaveRepository,
|
||||
EmployeeInterface $employeeRepository,
|
||||
LeaveTypeInterface $leaveTypeRepository,
|
||||
LeaveBalanceInterface $leaveBalance,
|
||||
|
||||
) {
|
||||
$this->leave = $leaveRepository;
|
||||
$this->employee = $employeeRepository;
|
||||
$this->leaveType = $leaveTypeRepository;
|
||||
$this->leaveBalance = $leaveBalance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$filters = $request->all();
|
||||
$data['title'] = "Leave List";
|
||||
$data['leaves'] = $this->leave->findAll($filters);
|
||||
// dd($data['leaves']->toArray());
|
||||
$data['employeeList'] = $this->employee->pluck();
|
||||
$data['status'] = Leave::PROGRESS_STATUS;
|
||||
|
||||
return view('leave::leave.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Leave';
|
||||
$data['editable'] = false;
|
||||
$data['employeeList'] = $this->employee->pluck();
|
||||
$data['leaveTypeList'] = $this->leaveType->pluck();
|
||||
$data['status'] = Leave::PROGRESS_STATUS;
|
||||
$data['duration'] = Leave::DURATION;
|
||||
|
||||
return view('leave::leave.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$inputData = $request->all();
|
||||
try {
|
||||
$dates = array_map('trim', explode(",", $request->start_date));
|
||||
$inputData['total_days'] = $request->duration == '2' ? count($dates) / 2 : count($dates);
|
||||
$inputData['start_date'] = ['dates' => $dates];
|
||||
$leave = $this->leave->create($inputData);
|
||||
|
||||
if ($request->status == 2) {
|
||||
$leaveBalance = $this->leaveBalance->where([
|
||||
'employee_id' => $request->employee_id,
|
||||
'leave_type_id' => $leave->leave_type_id,
|
||||
])->first();
|
||||
|
||||
$leaveBalance->remain -= $leave->total_days;
|
||||
$leaveBalance->save();
|
||||
|
||||
$leave->leave_approved_by = Auth::id();
|
||||
$leave->save();
|
||||
}
|
||||
|
||||
// $employeemodel = $this->employee->getEmployeeById($inputData['employee_id']);
|
||||
// sendNotification($employeemodel->user, [
|
||||
// 'msg' => 'Leave Created']);
|
||||
|
||||
flash()->success('Leave Created Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
flash()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('leave.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'View Leave';
|
||||
$data['leave'] = $this->leave->getLeaveById($id);
|
||||
return view('leave::leave.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Leave';
|
||||
$data['editable'] = true;
|
||||
$data['leave'] = $this->leave->getLeaveById($id);
|
||||
$data['employeeList'] = $this->employee->pluck();
|
||||
$data['leaveTypeList'] = $this->leaveType->pluck();
|
||||
$data['status'] = Leave::PROGRESS_STATUS;
|
||||
$data['duration'] = Leave::DURATION;
|
||||
return view('leave::leave.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$inputData = $request->except(['_method', "_token"]);
|
||||
try {
|
||||
$this->leave->update($id, $inputData);
|
||||
flash()->success('Leave Updated Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
flash()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('leave.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->leave->delete($id);
|
||||
return response()->json(['status' => 200, 'message' => 'Leave has been deleted!'], 200);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json(['status' => 500, 'message' => 'Leave to delete!', 'error' => $th->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the status of the specified resource in storage.
|
||||
*/
|
||||
public function updateStatus(Request $request)
|
||||
{
|
||||
try {
|
||||
$leave = $this->leave->getLeaveById($request->leave_id);
|
||||
$request->merge([
|
||||
'leave_approved_by' => Auth::id(),
|
||||
]);
|
||||
if ($request->status == 2) {
|
||||
$leaveBalance = $this->leaveBalance->where([
|
||||
'employee_id' => $request->employee_id,
|
||||
'leave_type_id' => $leave->leave_type_id,
|
||||
])->first();
|
||||
|
||||
$leaveBalance->remain -= $leave->total_days;
|
||||
$leaveBalance->save();
|
||||
}
|
||||
$this->leave->update($request->leave_id, $request->except(['_method', "_token"]));
|
||||
// $employeemodel = $this->employee->getEmployeeById($request->employee_id);
|
||||
// sendNotification($employeemodel->user, [
|
||||
// 'msg' => 'Leave Status Changed']);
|
||||
|
||||
flash()->success('Leave Status Updated Successfully');
|
||||
} catch (\Throwable $th) {
|
||||
flash()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('leave.index');
|
||||
}
|
||||
|
||||
public function getRemainingEmpLeave(Request $request)
|
||||
{
|
||||
try {
|
||||
$leaveBalance = $this->leaveBalance->where([
|
||||
'employee_id' => $request->employee_id,
|
||||
])->with(['leaveType:leave_type_id,name'])->get()
|
||||
->transform(function ($leaveBalance) {
|
||||
return [
|
||||
'leave_type_id' => $leaveBalance->leave_type_id,
|
||||
'leave_type' => $leaveBalance->leaveType?->name,
|
||||
'total' => $leaveBalance->total,
|
||||
'remain' => $leaveBalance->remain,
|
||||
];
|
||||
});
|
||||
return response()->json([
|
||||
'view' => view('leave::leave.partials.remaining-leave', compact('leaveBalance'))->render(),
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json([
|
||||
'msg' => $th->getMessage(),
|
||||
]);
|
||||
}
|
||||
// return redirect()->route('leave.index');
|
||||
}
|
||||
|
||||
public function checkEmpLeaveDates(Request $request)
|
||||
{
|
||||
$validator = \Validator::make($request->all(), [
|
||||
'employee_id' => 'required',
|
||||
'leave_type_id' => 'required',
|
||||
'duration' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'errors' => $validator->errors(),
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
$dates = array_map('trim', explode(",", $request->dates));
|
||||
$leaves = $this->leave->where([
|
||||
'employee_id' => $request->employee_id,
|
||||
])
|
||||
->when(true, function ($q) use ($dates) {
|
||||
$q->where(function ($query) use ($dates) {
|
||||
foreach ($dates as $date) {
|
||||
$query->orWhereJsonContains("start_date", ['dates' => $date]);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
->select('leave_id', 'employee_id', 'start_date', 'status')
|
||||
->get()
|
||||
->toArray();
|
||||
$mergeLeaveDates = array_map(function ($leave) {
|
||||
return $leave['start_date']['dates'];
|
||||
}, $leaves);
|
||||
|
||||
$previousLeaveDates = array_intersect($dates, array_merge(...$mergeLeaveDates));
|
||||
$html = '';
|
||||
$btnFlag = $request->filled('dates') ? true : false;
|
||||
if (!empty($previousLeaveDates)) {
|
||||
$btnFlag = false;
|
||||
$html .= '<li class="list-group-item text-danger"><i class="ri-close-fill"></i> Previous Leave Found on ' . implode(', ', $previousLeaveDates);
|
||||
}
|
||||
|
||||
$leaveBalance = $this->leaveBalance->where([
|
||||
'employee_id' => $request->employee_id,
|
||||
'leave_type_id' => $request->leave_type_id,
|
||||
])->where('remain', '<=', count($dates))
|
||||
->first();
|
||||
if ($leaveBalance) {
|
||||
$btnFlag = false;
|
||||
$html .= '<li class="list-group-item text-danger"><i class="ri-close-fill"></i> Remaining Leave Balance: ' . $leaveBalance->remain;
|
||||
}
|
||||
|
||||
if ($btnFlag == true) {
|
||||
$html .= '<li class="list-group-item text-success"><i class="ri-check-fill"></i> Leave Apply Dates: ' . $request->dates;
|
||||
}
|
||||
return response()->json(['html' => $html, 'btnFlag' => $btnFlag]);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json([
|
||||
'msg' => $th->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
125
Modules/Leave/app/Http/Controllers/LeaveTypeController.php
Normal file
125
Modules/Leave/app/Http/Controllers/LeaveTypeController.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Employee\Interfaces\EmployeeInterface;
|
||||
use Modules\Leave\Repositories\LeaveBalanceInterface;
|
||||
use Modules\Leave\Repositories\LeaveTypeInterface;
|
||||
|
||||
class LeaveTypeController extends Controller
|
||||
{
|
||||
private $leaveType;
|
||||
private $employee;
|
||||
private $leaveBalance;
|
||||
|
||||
public function __construct(
|
||||
LeaveTypeInterface $leaveType,
|
||||
LeaveBalanceInterface $leaveBalance,
|
||||
EmployeeInterface $employee) {
|
||||
$this->leaveType = $leaveType;
|
||||
$this->leaveBalance = $leaveBalance;
|
||||
$this->employee = $employee;
|
||||
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'LeaveType List';
|
||||
$data['leaveTypeLists'] = $this->leaveType->findAll();
|
||||
return view('leave::leave-type.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create LeaveType';
|
||||
$data['editable'] = false;
|
||||
return view('leave::leave-type.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$leaveType = $this->leaveType->create($request->all());
|
||||
$employees = $this->employee->pluck();
|
||||
|
||||
foreach ($employees as $empKey => $emp) {
|
||||
$leaveBalance = [
|
||||
'employee_id' => $empKey,
|
||||
'leave_type_id' => $leaveType->leave_type_id,
|
||||
'total' => $request->total_days,
|
||||
'remain' => $request->total_days,
|
||||
];
|
||||
|
||||
$this->leaveBalance->create($leaveBalance);
|
||||
}
|
||||
DB::commit();
|
||||
flash()->success('LeaveType created successfully');
|
||||
} catch (\Throwable $th) {
|
||||
flash()->error($th->getMessage());
|
||||
DB::rollBack();
|
||||
}
|
||||
|
||||
return redirect()->route('leaveType.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'View Leave';
|
||||
$data['leave'] = $this->leaveType->getLeaveTypeById($id);
|
||||
|
||||
return view('leave::leave-type.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['editable'] = true;
|
||||
$data['title'] = 'Edit LeaveType';
|
||||
$data['leaveType'] = $this->leaveType->getLeaveTypeById($id);
|
||||
|
||||
return view('leave::leave-type.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->leaveType->update($id, $request->except(['_token', '_method']));
|
||||
flash()->success('LeaveType updated successfully');
|
||||
} catch (\Throwable $th) {
|
||||
flash()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('leaveType.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->leaveType->delete($id);
|
||||
flash()->success('LeaveType deleted successfully');
|
||||
return redirect()->route('leaveType.index');
|
||||
|
||||
}
|
||||
}
|
0
Modules/Leave/app/Http/Requests/.gitkeep
Normal file
0
Modules/Leave/app/Http/Requests/.gitkeep
Normal file
26
Modules/Leave/app/Http/Requests/LeaveTypeRequest.php
Normal file
26
Modules/Leave/app/Http/Requests/LeaveTypeRequest.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LeaveTypeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
0
Modules/Leave/app/Models/.gitkeep
Normal file
0
Modules/Leave/app/Models/.gitkeep
Normal file
83
Modules/Leave/app/Models/Leave.php
Normal file
83
Modules/Leave/app/Models/Leave.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Models;
|
||||
|
||||
use App\Models\Scopes\CreatedByScope;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Attributes\ScopedBy;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
#[ScopedBy([CreatedByScope::class])]
|
||||
class Leave extends Model
|
||||
{
|
||||
protected $table = 'tbl_leaves';
|
||||
protected $primaryKey = 'leave_id';
|
||||
protected $guarded = [];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
const PROGRESS_STATUS = [
|
||||
1 => 'Pending',
|
||||
2 => 'Approved',
|
||||
3 => 'Rejected',
|
||||
];
|
||||
|
||||
const DURATION = [
|
||||
1 => 'Full Day',
|
||||
2 => 'Half Day',
|
||||
3 => 'Multiple',
|
||||
];
|
||||
protected $casts = [
|
||||
'start_date' => 'json',
|
||||
];
|
||||
|
||||
protected function statusName(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function (mixed $value, array $attributes) {
|
||||
switch ($attributes['status']) {
|
||||
case '1':
|
||||
$color = 'dark';
|
||||
break;
|
||||
case '2':
|
||||
$color = 'success';
|
||||
break;
|
||||
case '3':
|
||||
$color = 'danger';
|
||||
break;
|
||||
default:
|
||||
$color = 'light';
|
||||
break;
|
||||
}
|
||||
|
||||
return collect([
|
||||
'status' => self::PROGRESS_STATUS[$attributes['status']],
|
||||
'color' => $color]);
|
||||
},
|
||||
set: fn($value) => $value,
|
||||
);
|
||||
}
|
||||
|
||||
public function getDuration()
|
||||
{
|
||||
return self::DURATION[$this->duration] ?? null;
|
||||
}
|
||||
|
||||
public function employee()
|
||||
{
|
||||
return $this->belongsTo(Employee::class, 'employee_id');
|
||||
}
|
||||
|
||||
public function approveBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'leave_approved_by');
|
||||
}
|
||||
|
||||
public function leaveType()
|
||||
{
|
||||
return $this->belongsTo(LeaveType::class, 'leave_type_id');
|
||||
}
|
||||
|
||||
}
|
25
Modules/Leave/app/Models/LeaveBalance.php
Normal file
25
Modules/Leave/app/Models/LeaveBalance.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
class LeaveBalance extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_leave_balances';
|
||||
protected $fillable = ['employee_id', 'leave_type_id', 'total', 'remain'];
|
||||
public $timestamps = false;
|
||||
|
||||
public function employee()
|
||||
{
|
||||
return $this->belongsTo(Employee::class, 'employee_id');
|
||||
}
|
||||
|
||||
public function leaveType()
|
||||
{
|
||||
return $this->belongsTo(LeaveType::class, 'leave_type_id');
|
||||
}
|
||||
}
|
32
Modules/Leave/app/Models/LeaveType.php
Normal file
32
Modules/Leave/app/Models/LeaveType.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Models;
|
||||
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LeaveType extends Model
|
||||
{
|
||||
use HasFactory, StatusTrait;
|
||||
|
||||
protected $table = 'tbl_leave_types';
|
||||
protected $primaryKey = 'leave_type_id';
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'total_days',
|
||||
'max_accumulated_days',
|
||||
'is_accumulated',
|
||||
'is_proportionate',
|
||||
'status',
|
||||
'description',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_accumulated' => 'boolean',
|
||||
'is_proportionate' => 'boolean',
|
||||
];
|
||||
}
|
0
Modules/Leave/app/Providers/.gitkeep
Normal file
0
Modules/Leave/app/Providers/.gitkeep
Normal file
123
Modules/Leave/app/Providers/LeaveServiceProvider.php
Normal file
123
Modules/Leave/app/Providers/LeaveServiceProvider.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Leave\Repositories\LeaveBalanceInterface;
|
||||
use Modules\Leave\Repositories\LeaveBalanceRepository;
|
||||
use Modules\Leave\Repositories\LeaveInterface;
|
||||
use Modules\Leave\Repositories\LeaveRepository;
|
||||
use Modules\Leave\Repositories\LeaveTypeInterface;
|
||||
use Modules\Leave\Repositories\LeaveTypeRepository;
|
||||
|
||||
class LeaveServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Leave';
|
||||
|
||||
protected string $moduleNameLower = 'leave';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->bind(LeaveInterface::class, LeaveRepository::class);
|
||||
$this->app->bind(LeaveTypeInterface::class, LeaveTypeRepository::class);
|
||||
$this->app->bind(LeaveBalanceInterface::class, LeaveBalanceRepository::class);
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower . '.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower . '-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace') . '\\' . $this->moduleName . '\\' . ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', '')));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
49
Modules/Leave/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/Leave/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')->group(module_path('Leave', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Leave', '/routes/api.php'));
|
||||
}
|
||||
}
|
0
Modules/Leave/app/Repositories/.gitkeep
Normal file
0
Modules/Leave/app/Repositories/.gitkeep
Normal file
14
Modules/Leave/app/Repositories/LeaveBalanceInterface.php
Normal file
14
Modules/Leave/app/Repositories/LeaveBalanceInterface.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Repositories;
|
||||
|
||||
interface LeaveBalanceInterface
|
||||
{
|
||||
public function pluck();
|
||||
public function findAll();
|
||||
public function delete($leaveTypeId);
|
||||
public function create(array $LeaveTypeDetails);
|
||||
|
||||
public function where(array $filter);
|
||||
public function update($leaveTypeId, array $newDetails);
|
||||
}
|
38
Modules/Leave/app/Repositories/LeaveBalanceRepository.php
Normal file
38
Modules/Leave/app/Repositories/LeaveBalanceRepository.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Repositories;
|
||||
|
||||
use Modules\Leave\Models\LeaveBalance;
|
||||
|
||||
class LeaveBalanceRepository implements LeaveBalanceInterface
|
||||
{
|
||||
public function pluck()
|
||||
{
|
||||
return LeaveBalance::pluck('name', 'id');
|
||||
}
|
||||
public function findAll()
|
||||
{
|
||||
return LeaveBalance::get();
|
||||
}
|
||||
|
||||
public function create(array $LeaveBalanceDetails)
|
||||
{
|
||||
return LeaveBalance::create($LeaveBalanceDetails);
|
||||
}
|
||||
|
||||
public function update($LeaveBalanceId, array $newDetails)
|
||||
{
|
||||
return LeaveBalance::where('id', $LeaveBalanceId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function where(array $filter)
|
||||
{
|
||||
return LeaveBalance::where($filter);
|
||||
}
|
||||
|
||||
public function delete($LeaveBalanceId)
|
||||
{
|
||||
LeaveBalance::destroy($LeaveBalanceId);
|
||||
}
|
||||
|
||||
}
|
14
Modules/Leave/app/Repositories/LeaveInterface.php
Normal file
14
Modules/Leave/app/Repositories/LeaveInterface.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Repositories;
|
||||
|
||||
interface LeaveInterface
|
||||
{
|
||||
public function findAll($filters = [], $limit = null, $offset = null);
|
||||
public function getLeaveById($leaveId);
|
||||
public function where(array $filter);
|
||||
public function delete($leaveId);
|
||||
public function create(array $LeaveDetails);
|
||||
public function update($leaveId, array $newDetails);
|
||||
public function getLeaveByEmployeeId(int $id);
|
||||
}
|
80
Modules/Leave/app/Repositories/LeaveRepository.php
Normal file
80
Modules/Leave/app/Repositories/LeaveRepository.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Repositories;
|
||||
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
use Modules\Leave\Models\Leave;
|
||||
|
||||
class LeaveRepository implements LeaveInterface
|
||||
{
|
||||
public function findAll($filters = [], $limit = null, $offset = null)
|
||||
{
|
||||
return Leave::with(['leaveType', 'employee'])->when($filters, function ($query) use ($filters) {
|
||||
|
||||
if (isset($filters["employee_id"])) {
|
||||
$query->whereHas('employee', function (Builder $query) use ($filters) {
|
||||
$query->where('id', '=', $filters["employee_id"]);
|
||||
});
|
||||
}
|
||||
|
||||
if (isset($filters["status"])) {
|
||||
$query->where("status", $filters["status"]);
|
||||
}
|
||||
|
||||
if (!empty($filters['date'])) {
|
||||
$dateFilter = explode("to", $filters['date']);
|
||||
$startDate = trim($dateFilter[0]);
|
||||
$endDate = trim($dateFilter[1]);
|
||||
if ($startDate === $endDate) {
|
||||
$query->where("created_at", '=', $startDate);
|
||||
} else {
|
||||
$query->where("created_at", '>=', $startDate);
|
||||
$query->where("created_at", '<=', $endDate);
|
||||
}
|
||||
}
|
||||
|
||||
// if (isset($filters["date"])) {
|
||||
// $explodeDate = explode("to", $filters['date']);
|
||||
// dd($explodeDate);
|
||||
// $query->whereBetween("start_date", [$explodeDate[0], preg_replace('/\s+/', '', $explodeDate[1])]);
|
||||
// }
|
||||
|
||||
})->latest()
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getLeaveById($leaveId)
|
||||
{
|
||||
return Leave::findOrFail($leaveId);
|
||||
}
|
||||
|
||||
public function where(array $filter)
|
||||
{
|
||||
return Leave::where($filter);
|
||||
}
|
||||
|
||||
public function delete($leaveId)
|
||||
{
|
||||
Leave::destroy($leaveId);
|
||||
}
|
||||
|
||||
public function create(array $leaveDetails)
|
||||
{
|
||||
return Leave::create($leaveDetails);
|
||||
}
|
||||
|
||||
public function update($leaveId, array $newDetails)
|
||||
{
|
||||
return Leave::where('leave_id', $leaveId)->update($newDetails);
|
||||
}
|
||||
|
||||
|
||||
public function getLeaveByEmployeeId(int $id)
|
||||
{
|
||||
return Leave::where([
|
||||
['employee_id', $id],
|
||||
])
|
||||
->latest()
|
||||
->get();
|
||||
}
|
||||
}
|
13
Modules/Leave/app/Repositories/LeaveTypeInterface.php
Normal file
13
Modules/Leave/app/Repositories/LeaveTypeInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Repositories;
|
||||
|
||||
interface LeaveTypeInterface
|
||||
{
|
||||
public function pluck();
|
||||
public function findAll();
|
||||
public function getLeaveTypeById($leaveTypeId);
|
||||
public function delete($leaveTypeId);
|
||||
public function create(array $LeaveTypeDetails);
|
||||
public function update($leaveTypeId, array $newDetails);
|
||||
}
|
38
Modules/Leave/app/Repositories/LeaveTypeRepository.php
Normal file
38
Modules/Leave/app/Repositories/LeaveTypeRepository.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\Repositories;
|
||||
|
||||
use Modules\Leave\Models\LeaveType;
|
||||
|
||||
class LeaveTypeRepository implements LeaveTypeInterface
|
||||
{
|
||||
public function pluck()
|
||||
{
|
||||
return LeaveType::pluck('name', 'leave_type_id');
|
||||
}
|
||||
public function findAll()
|
||||
{
|
||||
return LeaveType::get();
|
||||
}
|
||||
|
||||
public function getLeaveTypeById($leaveTypeId)
|
||||
{
|
||||
return LeaveType::findOrFail($leaveTypeId);
|
||||
}
|
||||
|
||||
public function create(array $leaveTypeDetails)
|
||||
{
|
||||
return LeaveType::create($leaveTypeDetails);
|
||||
}
|
||||
|
||||
public function update($leaveTypeId, array $newDetails)
|
||||
{
|
||||
return LeaveType::where('leave_type_id', $leaveTypeId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function delete($leaveTypeId)
|
||||
{
|
||||
LeaveType::destroy($leaveTypeId);
|
||||
}
|
||||
|
||||
}
|
30
Modules/Leave/composer.json
Normal file
30
Modules/Leave/composer.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "nwidart/leave",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Leave\\": "app/",
|
||||
"Modules\\Leave\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\Leave\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\Leave\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Leave/config/.gitkeep
Normal file
0
Modules/Leave/config/.gitkeep
Normal file
5
Modules/Leave/config/config.php
Normal file
5
Modules/Leave/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Leave',
|
||||
];
|
0
Modules/Leave/database/factories/.gitkeep
Normal file
0
Modules/Leave/database/factories/.gitkeep
Normal file
0
Modules/Leave/database/migrations/.gitkeep
Normal file
0
Modules/Leave/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tbl_leaves', function (Blueprint $table) {
|
||||
$table->tinyInteger('leave_id')->unsigned()->autoIncrement();
|
||||
$table->unsignedBigInteger('employee_id');
|
||||
$table->unsignedBigInteger('leave_type_id');
|
||||
$table->longText('start_date')->nullable();
|
||||
// $table->date('end_date')->nullable();
|
||||
$table->date('leave_approved_date')->nullable();
|
||||
$table->float('total_days', 2)->nullable();
|
||||
$table->unsignedBigInteger('leave_approved_by')->nullable();
|
||||
$table->integer('duration')->nullable();
|
||||
$table->integer('status')->default(11);
|
||||
$table->longtext('description')->nullable();
|
||||
$table->text('remarks')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tbl_leaves');
|
||||
}
|
||||
};
|
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tbl_leave_types', function (Blueprint $table) {
|
||||
$table->tinyInteger('leave_type_id')->unsigned()->autoIncrement();
|
||||
$table->string('name');
|
||||
$table->integer('total_days');
|
||||
$table->integer('max_accumulated_days')->nullable();
|
||||
$table->boolean('is_accumulated')->default(false);
|
||||
$table->boolean('is_proportionate')->default(false);
|
||||
$table->integer('status')->default(11);
|
||||
$table->mediumText('description')->nullable();
|
||||
$table->mediumText('remarks')->nullable();
|
||||
$table->integer('createdBy')->nullable();
|
||||
$table->integer('updatedBy')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tbl_leave_types');
|
||||
}
|
||||
};
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tbl_leave_balances', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('employee_id');
|
||||
$table->unsignedBigInteger('leave_type_id');
|
||||
$table->decimal('total', 8, 2);
|
||||
$table->decimal('remain', 8, 2);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tbl_leave_balances');
|
||||
}
|
||||
};
|
0
Modules/Leave/database/seeders/.gitkeep
Normal file
0
Modules/Leave/database/seeders/.gitkeep
Normal file
16
Modules/Leave/database/seeders/LeaveDatabaseSeeder.php
Normal file
16
Modules/Leave/database/seeders/LeaveDatabaseSeeder.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Leave\database\seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class LeaveDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// $this->call([]);
|
||||
}
|
||||
}
|
11
Modules/Leave/module.json
Normal file
11
Modules/Leave/module.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Leave",
|
||||
"alias": "leave",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Leave\\Providers\\LeaveServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/Leave/package.json
Normal file
15
Modules/Leave/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^1.1.2",
|
||||
"laravel-vite-plugin": "^0.7.5",
|
||||
"sass": "^1.69.5",
|
||||
"postcss": "^8.3.7",
|
||||
"vite": "^4.0.0"
|
||||
}
|
||||
}
|
0
Modules/Leave/resources/assets/.gitkeep
Normal file
0
Modules/Leave/resources/assets/.gitkeep
Normal file
0
Modules/Leave/resources/assets/js/app.js
Normal file
0
Modules/Leave/resources/assets/js/app.js
Normal file
0
Modules/Leave/resources/assets/sass/app.scss
Normal file
0
Modules/Leave/resources/assets/sass/app.scss
Normal file
0
Modules/Leave/resources/views/.gitkeep
Normal file
0
Modules/Leave/resources/views/.gitkeep
Normal file
29
Modules/Leave/resources/views/layouts/master.blade.php
Normal file
29
Modules/Leave/resources/views/layouts/master.blade.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<title>Leave Module - {{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<meta name="description" content="{{ $description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
||||
<meta name="author" content="{{ $author ?? '' }}">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
{{-- Vite CSS --}}
|
||||
{{-- {{ module_vite('build-leave', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-leave', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
25
Modules/Leave/resources/views/leave-type/create.blade.php
Normal file
25
Modules/Leave/resources/views/leave-type/create.blade.php
Normal file
@@ -0,0 +1,25 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<x-dashboard.breadcumb :title="$title" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('leaveType.store') }}" class="needs-validation" novalidate method="post">
|
||||
@csrf
|
||||
@include('leave::leave-type.partials.action')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
49
Modules/Leave/resources/views/leave-type/edit.blade.php
Normal file
49
Modules/Leave/resources/views/leave-type/edit.blade.php
Normal file
@@ -0,0 +1,49 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
|
||||
<h4 class="mb-sm-0">{{ $title }}</h4>
|
||||
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
|
||||
<li class="breadcrumb-item active">{{ $title }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
{{-- @dd($leaveType) --}}
|
||||
|
||||
{{ html()->modelForm($leaveType, 'PUT')->route('leaveType.update', $leaveType->leave_type_id)->class(['needs-validation'])->attributes(['novalidate'])->open() }}
|
||||
|
||||
@include('leave::leave-type.partials.action')
|
||||
|
||||
{{ html()->closeModelForm() }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--end row-->
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
78
Modules/Leave/resources/views/leave-type/index.blade.php
Normal file
78
Modules/Leave/resources/views/leave-type/index.blade.php
Normal file
@@ -0,0 +1,78 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<x-dashboard.breadcumb :title="$title" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header align-items-center d-flex">
|
||||
<h5 class="card-title flex-grow-1 mb-0">LeaveType Lists</h5>
|
||||
|
||||
<div class="flex-shrink-0">
|
||||
{{-- @role('admin')
|
||||
<button type="button" class="btn btn-primary waves-effect waves-light"><i class="ri-user-shared-line me-1
|
||||
align-bottom"></i> Assign</button>
|
||||
@endrole --}}
|
||||
<a href="{{ route('leaveType.create') }}" class="btn btn-success waves-effect waves-light"><i
|
||||
class="ri-add-fill me-1 align-bottom"></i> Add LeaveType</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="buttons-datatables" class="display table-sm table-bordered table" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>S.N</th>
|
||||
<th>Name</th>
|
||||
<th>Total Days</th>
|
||||
<th>Accumulated</th>
|
||||
<th>Proportionate</th>
|
||||
{{-- <th>Created By</th> --}}
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($leaveTypeLists as $key => $leaveType)
|
||||
<tr>
|
||||
<td>{{ $key + 1 }}</td>
|
||||
<td>{{ $leaveType->name }}</td>
|
||||
<td>{{ $leaveType->total_days }}</td>
|
||||
<td>{{ $leaveType->is_accumulated ? 'Checked' : 'Not Checked' }}</td>
|
||||
<td>{{ $leaveType->is_proportionate ? 'Checked' : 'Not Checked' }}</td>
|
||||
{{-- <td>{{ $leaveType->createdBy }}</td> --}}
|
||||
<td>{!! $leaveType->status_name !!}</td>
|
||||
<td>
|
||||
<div class="hstack flex-wrap gap-3">
|
||||
@can('leaveType.show')
|
||||
<a href="{{ route('leaveType.show', $leaveType->leave_type_id) }}" class="link-info fs-15">
|
||||
<i class="ri-eye-fill"></i>
|
||||
</a>
|
||||
@endcan
|
||||
</a>
|
||||
<a href="{{ route('leaveType.edit', $leaveType->leave_type_id) }}"
|
||||
class="link-success fs-15 edit-item-btn"><i class="ri-edit-2-fill"></i></a>
|
||||
|
||||
<a href="javascript:void(0);"
|
||||
data-link="{{ route('leaveType.destroy', $leaveType->leave_type_id) }}"
|
||||
data-id="{{ $leaveType->leave_type_id }}" class="link-danger fs-15 remove-item-btn"><i
|
||||
class="ri-delete-bin-fill"></i></a>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--end row-->
|
||||
</div>
|
||||
@endsection
|
@@ -0,0 +1,49 @@
|
||||
<div class="row gy-3">
|
||||
<div class="col-md-6">
|
||||
{{ html()->label('Name')->class('form-label') }}
|
||||
{{ html()->text('name')->class('form-control')->placeholder('LeaveType Name')->required() }}
|
||||
{{ html()->div('Please Fill the Name')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{{ html()->label('Total Days')->class('form-label') }}
|
||||
{{ html()->number('total_days')->class('form-control')->placeholder('Total Leave Days')->required() }}
|
||||
{{ html()->div('Please Fill the total Leave Days')->class('invalid-feedback') }}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{{ html()->label('Maximum Accumulated Days')->class('form-label') }}
|
||||
{{ html()->number('max_accumulated_days')->class('form-control')->placeholder('Maximum Acummulated Days')->required() }}
|
||||
{{ html()->div('Please Fill this field')->class('invalid-feedback') }}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Description')->class('form-label') }}
|
||||
{{ html()->textarea('description')->class('form-control')->placeholder('LeaveType Description')->attributes(['rows' => 3])->required() }}
|
||||
{{ html()->div('Please Fill the Description')->class('invalid-feedback') }}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
{{ html()->label('Accumulated')->class('form-check-label me-1') }}
|
||||
{{ html()->checkbox('is_accumulated',false,'1')->class('form-check-input')->checked($editable && $leaveType->is_accumulated == 1)}}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
{{ html()->label('Proportionate')->class('form-check-label me-1') }}
|
||||
{{ html()->checkbox('is_proportionate',false,'1')->class('form-check-input')->checked($editable && $leaveType->is_proportionate == 1) }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="text-end">
|
||||
<a href="{{route('leaveType.index')}}" class="btn btn-light btn-md">Cancel</a>
|
||||
<button type="submit" class="btn btn-primary btn-md">{{ $editable ? 'Update' : 'Add LeaveType' }}</button>
|
||||
</div>
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
@@ -0,0 +1,16 @@
|
||||
<div class="modal fade" id="viewModal" tabindex="-1" aria-labelledby="viewModalLabel" aria-modal="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalgridLabel">View Leave</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ route('leave-t.store') }}" class="needs-validation" novalidate method="post">
|
||||
@csrf
|
||||
@include('leave::leave.partials.action')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
49
Modules/Leave/resources/views/leave-type/show.blade.php
Normal file
49
Modules/Leave/resources/views/leave-type/show.blade.php
Normal file
@@ -0,0 +1,49 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<x-dashboard.breadcumb :title="$title" />
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card card-body p-4">
|
||||
<div>
|
||||
<div class="table-responsive">
|
||||
<table class="table-borderless mb-0 table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Leave Name</span></th>
|
||||
<td>{{ $leave->name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Total Days</span></th>
|
||||
<td>{{ $leave->total_days}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Accumulated</span></th>
|
||||
<td>{{ $leave->max_accumulated_days}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Status</span></th>
|
||||
<td>{{ $leave->status}}</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 text-end">
|
||||
<a href="{{ route('leaveType.index') }}" class="btn btn-secondary w-sm">Back</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
16
Modules/Leave/resources/views/leave/create.blade.php
Normal file
16
Modules/Leave/resources/views/leave/create.blade.php
Normal file
@@ -0,0 +1,16 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<x-dashboard.breadcumb :title="$title" />
|
||||
|
||||
|
||||
{{ html()->form('POST')->route('leave.store')->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }}
|
||||
@include('leave::leave.partials.action')
|
||||
{{ html()->form()->close() }}
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
35
Modules/Leave/resources/views/leave/edit.blade.php
Normal file
35
Modules/Leave/resources/views/leave/edit.blade.php
Normal file
@@ -0,0 +1,35 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
|
||||
<h4 class="mb-sm-0">{{ $title }}</h4>
|
||||
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
|
||||
<li class="breadcrumb-item active">{{ $title }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
{{ html()->modelForm($leave, 'PUT')->route('leave.update', $leave->leave_id)->class(['needs-validation'])->attributes(['novalidate'])->open() }}
|
||||
@include('leave::leave.partials.action')
|
||||
{{ html()->closeModelForm() }}
|
||||
|
||||
<!--end row-->
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
235
Modules/Leave/resources/views/leave/index.blade.php
Normal file
235
Modules/Leave/resources/views/leave/index.blade.php
Normal file
@@ -0,0 +1,235 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<x-dashboard.breadcumb :title="$title" />
|
||||
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body text-align-center">
|
||||
<form action="{{ route('leave.index') }}" method="GET">
|
||||
<div class="row g-2">
|
||||
<div class="col-xl-3">
|
||||
<div class="search-box">
|
||||
{{ html()->select('employee_id', $employeeList)->class('form-control select2')->value(request('employee_id'))->placeholder('By Employee') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<div class="">
|
||||
{{ html()->text('date')->class('form-control daterange-custom-picker')->value(request('date'))->placeholder('Date Range')}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-3">
|
||||
<div class="search-box">
|
||||
{{ html()->select('status', $status)->class('form-control select2')->value(request('status'))->placeholder('By Status') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="g-2 text-end">
|
||||
<div>
|
||||
<button type="submit" class="btn btn-success">Filter</button>
|
||||
<a href="{{ route('leave.index') }}" class="btn btn-danger">Reset</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header align-items-center d-flex">
|
||||
<h5 class="card-title flex-grow-1 mb-0">Leave Lists</h5>
|
||||
<div class="flex-shrink-0">
|
||||
@can('leave.create')
|
||||
<a href="{{ route('leave.create') }}" class="btn btn-primary waves-effect waves-light"><i
|
||||
class="ri-add-fill me-1 align-bottom"></i> Apply Leave</a>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="datatable" class="display table-sm table-bordered align-center table" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>S.N</th>
|
||||
<th width="20%">Employee Name</th>
|
||||
<th>Leave Type</th>
|
||||
<th>Dates</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($leaves as $key => $leave)
|
||||
{{-- @dd($leave->start_date['dates'][0]) --}}
|
||||
<tr>
|
||||
<td>{{ $key + 1 }}</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-start text-muted mb-2">
|
||||
<div class="me-3 flex-shrink-0">
|
||||
<img src="{{ optional($leave->employee)->profile_pic }}" class="avatar-sm rounded"
|
||||
alt="...">
|
||||
</div>
|
||||
|
||||
<div class="flex-grow-1">
|
||||
<h5 class="fs-12"> {{ optional($leave->employee)->full_name }}</h5>
|
||||
{{ optional($leave->employee)->email }}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="">
|
||||
<h5 class="fs-12 fw-medium my-1">
|
||||
{{ optional($leave->leaveType)->name }} <span
|
||||
class="text-danger">({{ $leave->total_days }} days)</span>
|
||||
</h5>
|
||||
<span class="fs-10 text-danger text-bold">{{ $leave->getDuration() }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@foreach ($leave->start_date as $dates)
|
||||
@foreach ($dates as $date)
|
||||
<li class="fs-12">{{ $date }}</li>
|
||||
@endforeach
|
||||
@endforeach
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-{{ $leave->status_name['color'] }}">
|
||||
{!! $leave->status_name['status'] !!} </span>
|
||||
<p class="text-info fs-10 mb-0">{{ optional($leave->approveBy)->name }}</p>
|
||||
<p class="text-muted fs-10">{!! $leave->description !!}</p>
|
||||
</td>
|
||||
<td>
|
||||
<div class="hstack flex-wrap gap-3">
|
||||
{{-- <a href="javascript:void(0);" class="link-info fs-15 view-item-btn" data-bs-toggle="modal"
|
||||
data-bs-target="#viewModal">
|
||||
<i class="ri-eye-fill"></i>
|
||||
</a> --}}
|
||||
@can('leave.show')
|
||||
<a href="{{ route('leave.show', $leave->leave_id) }}" class="link-info fs-15">
|
||||
<i class="ri-eye-fill"></i>
|
||||
</a>
|
||||
@endcan
|
||||
{{-- @can('leave.edit')
|
||||
<a href="{{ route('leave.edit', $leave->leave_id) }}"
|
||||
class="link-success fs-15 edit-item-btn"><i class="ri-edit-2-fill"></i></a>
|
||||
@endcan --}}
|
||||
@can('leave.updateStatus')
|
||||
@if (in_array($leave->status, ['1', '3']))
|
||||
<a href="javascript:void(0);" class="link-dark fs-15 approve-item-btn"
|
||||
data-bs-toggle="modal" data-bs-target="#statusModal"
|
||||
data-leave-id="{{ $leave->leave_id }}" data-employee-id="{{ $leave->employee_id }}">
|
||||
<i class="ri-check-double-line"></i>
|
||||
</a>
|
||||
@endif
|
||||
@endcan
|
||||
@can('leave.destroy')
|
||||
@if (in_array($leave->status, ['1', '3']))
|
||||
<a href="javascript:void(0);" data-link="{{ route('leave.destroy', $leave->leave_id) }}"
|
||||
data-id="{{ $leave->leave_id }}" class="link-danger fs-15 remove-item-btn"><i
|
||||
class="ri-delete-bin-fill"></i></a>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="text-center"> No Leave Found</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--end row-->
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
@can('leave.updateStatus')
|
||||
<div class="modal fade" id="statusModal" tabindex="-1" aria-labelledby="statusModalLabel" aria-modal="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalgridLabel">Update Status</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ route('leave.updateStatus') }}" id="statusForm" class="needs-validation" novalidate
|
||||
method="post">
|
||||
@csrf
|
||||
<input type="hidden" id="leave_id" name="leave_id" value="">
|
||||
<input type="hidden" id="employeeId" name="employee_id" value="">
|
||||
<div class="row g-2">
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Status')->class('form-label') }}
|
||||
{{ html()->select('status', $status)->class('form-select select2')->placeholder('Select Status')->required() }}
|
||||
{{ html()->div('Please Select Status')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Remark')->class('form-label') }}
|
||||
{{ html()->textarea('remarks')->class('form-control')->placeholder('Write remarks...') }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="mt-3 text-end">
|
||||
{{ html()->button('Save')->class('btn btn-info') }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
|
||||
<script>
|
||||
// $(document).ready(function(){
|
||||
// $('#statusForm').on('submit',function(e){
|
||||
// e.preventDefault();
|
||||
// var formData = $(this).serialize();
|
||||
|
||||
// $.ajax({
|
||||
// url:'{{ route('leave.updateStatus') }}',
|
||||
// type: 'POST',
|
||||
// // headers: {
|
||||
// // 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
// // }
|
||||
// data: formData,
|
||||
// success: function(response){
|
||||
// console.log(response);
|
||||
// location.reload();
|
||||
// },
|
||||
// error: function(xhr, status, error){
|
||||
// console.error(error)
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
$(document).ready(function() {
|
||||
$('.approve-item-btn').on('click', function() {
|
||||
let leaveId = $(this).data('leave-id');
|
||||
$('#leave_id').val(leaveId);
|
||||
let employeeId = $(this).data('employee-id');
|
||||
$('#employeeId').val(employeeId);
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
220
Modules/Leave/resources/views/leave/partials/action.blade.php
Normal file
220
Modules/Leave/resources/views/leave/partials/action.blade.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row g-2">
|
||||
<div class="col-md-6">
|
||||
{{ html()->label('Employee')->class('form-label') }}
|
||||
{{ html()->select('employee_id', $employeeList)->class('form-select select2')->placeholder('Select Employee')->required() }}
|
||||
{{ html()->div('Please Select Employee')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{{ html()->label('Leave Type')->class('form-label') }}
|
||||
{{ html()->select('leave_type_id', $leaveTypeList)->class('form-select select2')->attributes(['id' => 'leave_type_id'])->placeholder('Select Leave Type')->required() }}
|
||||
{{ html()->div('Please Select Leave Type')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Selet Duration')->class('form-label') }}
|
||||
<div>
|
||||
@foreach ($duration as $durationKey => $durationItem)
|
||||
<div class="form-check form-check-inline">
|
||||
{{ html()->radio('duration')->class('form-check-input duration')->checked(old('duration', isset($leave) && $leave->duration === $durationKey))->attributes(['id' => $durationKey])->value($durationKey)->required() }}
|
||||
{{ html()->label($durationItem)->class('form-check-label')->for($durationKey) }}
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Choose Date')->class('form-label') }}
|
||||
{{ html()->text('start_date')->class('form-control start-date')->placeholder('Select Start Date')->attributes([
|
||||
// 'data-provider' => 'flatpickr',
|
||||
// 'data-date-format' => 'd M, Y',
|
||||
// 'data-multiple-date' => 'true',
|
||||
])->required() }}
|
||||
{{ html()->div('Please Select Start Date')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-8 leave-note">
|
||||
<ul class="list-group">
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{{-- <div class="col-md-6 end-date d-none">
|
||||
{{ html()->label('End Date')->class('form-label') }}
|
||||
{{ html()->date('end_date')->class('form-control')->placeholder('Select End Date') }}
|
||||
{{ html()->div('Please Select End Date')->class('invalid-feedback') }}
|
||||
</div> --}}
|
||||
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Description')->class('form-label') }}
|
||||
{{ html()->textarea('description')->class('form-control')->placeholder('Write Reason for Leave') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 text-end">
|
||||
{{-- <a href="{{ route('leave.index') }}" class="btn btn-danger w-sm">Cancel</a> --}}
|
||||
{{ html()->button($editable ? 'Update' : 'Save', 'submit')->class('btn btn-success btn-save d-none') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Leave Remaining</h5>
|
||||
</div>
|
||||
<div class="card-body p-2">
|
||||
<div class="table-responsive">
|
||||
<table class="table-nowrap table-sm mb-0 table align-middle">
|
||||
<thead class="table-dark text-white">
|
||||
<tr>
|
||||
<th scope="col" style="width: 62;">Leave Type</th>
|
||||
<th scope="col">Total</th>
|
||||
<th scope="col">Remain</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="leaveRemainTable">
|
||||
</tbody><!-- end tbody -->
|
||||
</table><!-- end table -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- end card body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
@can('leave.updateStatus')
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Leave Status</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{{ html()->label('Status')->class('form-label') }}
|
||||
{{ html()->select('status', $status)->class('form-control select2')->required() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end card body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
<script>
|
||||
let startDatePicker = initializeFlatpickr('single');
|
||||
let appendError = $('.leave-note').find('.list-group');
|
||||
|
||||
$('input[name=duration]').on('click', function() {
|
||||
if ($(this).is(":checked")) {
|
||||
var checked = $(this).prop("checked", true).val();
|
||||
startDatePicker.destroy();
|
||||
appendError.html('')
|
||||
if (checked == 3) {
|
||||
startDatePicker = initializeFlatpickr('multiple');
|
||||
} else {
|
||||
startDatePicker = initializeFlatpickr('single');
|
||||
}
|
||||
$(".start-date").val('');
|
||||
}
|
||||
})
|
||||
|
||||
$('select[name=employee_id]').on('change', function() {
|
||||
leave_type_id = $(this).val();
|
||||
fetchLeaveRemain()
|
||||
})
|
||||
|
||||
function initializeFlatpickr(mode) {
|
||||
return $(".start-date").flatpickr({
|
||||
enableTime: false,
|
||||
dateFormat: "Y-m-d",
|
||||
altInput: true,
|
||||
altFormat: "Y-m-d",
|
||||
defaultDate: "",
|
||||
mode: mode,
|
||||
onChange: function(selectedDates, dateStr, instance) {
|
||||
checkEmpLeaveDates(dateStr)
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const checkEmpLeaveDates = async (dates) => {
|
||||
appendError.html('')
|
||||
|
||||
$('.btn-save').addClass('d-none')
|
||||
try {
|
||||
const request = new Request("{{ route('leave.checkEmpLeaveDates') }}", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
|
||||
},
|
||||
body: JSON.stringify({
|
||||
employee_id: $('select[name=employee_id]').val(),
|
||||
leave_type_id: $('select[name=leave_type_id]').val(),
|
||||
duration: $('input[name=duration]:checked').val(),
|
||||
dates: dates
|
||||
}),
|
||||
});
|
||||
|
||||
const response = await fetch(request);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok ' + response);
|
||||
}
|
||||
const data = await response.json();
|
||||
|
||||
if (data.status == false) {
|
||||
if (data.errors) {
|
||||
Object.keys(data.errors).forEach(key => {
|
||||
const errorMessage = data.errors[key];
|
||||
appendError.append(
|
||||
`<li class="list-group-item text-danger"><i class="ri-close-line"></i> ${errorMessage}</li>`);
|
||||
})
|
||||
}
|
||||
} else {
|
||||
appendError.html(data.html)
|
||||
if (data.btnFlag == true) {
|
||||
$('.btn-save').removeClass('d-none')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
console.error('Fetch Error:', error);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const fetchLeaveRemain = () => {
|
||||
const params = {
|
||||
employee_id: $('select[name=employee_id]').val(),
|
||||
};
|
||||
const urlParams = new URLSearchParams(params);
|
||||
appendError.html('')
|
||||
|
||||
fetch(`{{ route('leave.getRemainingEmpLeave') }}?${urlParams.toString()}`, {
|
||||
method: 'GET',
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
$('#leaveRemainTable').html(data.view)
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Fetch Error:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@isset($editable)
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("input[name=duration]:checked").trigger("click");
|
||||
})
|
||||
</script>
|
||||
@endisset
|
||||
@endpush
|
@@ -0,0 +1,7 @@
|
||||
@foreach ($leaveBalance as $item)
|
||||
<tr>
|
||||
<td>{{ $item['leave_type'] }}</td>
|
||||
<td class="text-primary">{{ $item['total'] }}</td>
|
||||
<td class="text-danger">{{ $item['remain'] }}</td>
|
||||
</tr>
|
||||
@endforeach
|
16
Modules/Leave/resources/views/leave/partials/view.blade.php
Normal file
16
Modules/Leave/resources/views/leave/partials/view.blade.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<div class="modal fade" id="viewModal" tabindex="-1" aria-labelledby="viewModalLabel" aria-modal="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalgridLabel">View Leave</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ route('leave.store') }}" class="needs-validation" novalidate method="post">
|
||||
@csrf
|
||||
@include('leave::leave.partials.action')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
82
Modules/Leave/resources/views/leave/show.blade.php
Normal file
82
Modules/Leave/resources/views/leave/show.blade.php
Normal file
@@ -0,0 +1,82 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<x-dashboard.breadcumb :title="$title" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card card-body p-4">
|
||||
<div>
|
||||
<div class="table-responsive">
|
||||
<table class="table-borderless mb-0 table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Employee Name</span></th>
|
||||
<td>{{ $leave->employee->first_name }} {{ $leave->employee->middle_name }}
|
||||
{{ $leave->employee->last_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Leave Type</span></th>
|
||||
<td> {{ optional($leave->leaveType)->name }} </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Date</span></th>
|
||||
<td>
|
||||
@foreach ($leave->start_date as $dates)
|
||||
@foreach ($dates as $date)
|
||||
<li>{{ $date }}</li>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Leave Approved Date</span></th>
|
||||
<td>{{ $leave->leave_approved_date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Total Days</span></th>
|
||||
<td>{{ $leave->total_days }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Leave Approved By</span></th>
|
||||
<td>{{ $leave->leave_approved_by }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Duration</span></th>
|
||||
<td>{{ $leave->getDuration() }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Leave Approved Date</span></th>
|
||||
<td>{{ $leave->employee_id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Status</span></th>
|
||||
<td>{{ $leave->status_name['status'] }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Description</span></th>
|
||||
<td>{{ $leave->description }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="fw-medium">Remark</span></th>
|
||||
<td>{{ $leave->remarks }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 text-end">
|
||||
<a href="{{ route('leave.index') }}" class="btn btn-secondary w-sm">Back</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
0
Modules/Leave/routes/.gitkeep
Normal file
0
Modules/Leave/routes/.gitkeep
Normal file
19
Modules/Leave/routes/api.php
Normal file
19
Modules/Leave/routes/api.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Leave\Http\Controllers\LeaveController;
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------
|
||||
* API Routes
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* Here is where you can register API routes for your application. These
|
||||
* routes are loaded by the RouteServiceProvider within a group which
|
||||
* is assigned the "api" middleware group. Enjoy building your API!
|
||||
*
|
||||
*/
|
||||
|
||||
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
|
||||
Route::apiResource('leave', LeaveController::class)->names('leave');
|
||||
});
|
25
Modules/Leave/routes/web.php
Normal file
25
Modules/Leave/routes/web.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Leave\Http\Controllers\LeaveController;
|
||||
use Modules\Leave\Http\Controllers\LeaveTypeController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group(['middleware' => ['web', 'auth', 'permission'], 'prefix' => 'admin/'], function () {
|
||||
Route::post('status-update', [LeaveController::class, 'updateStatus'])->name('leave.updateStatus');
|
||||
Route::get('getRemainingEmpLeave', [LeaveController::class, 'getRemainingEmpLeave'])->name('leave.getRemainingEmpLeave');
|
||||
Route::post('checkEmpLeaveDates', [LeaveController::class, 'checkEmpLeaveDates'])->name('leave.checkEmpLeaveDates');
|
||||
|
||||
Route::resource('leave', LeaveController::class)->names('leave');
|
||||
Route::resource('leave-type', LeaveTypeController::class)->names('leaveType');
|
||||
});
|
26
Modules/Leave/vite.config.js
Normal file
26
Modules/Leave/vite.config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: '../../public/build-leave',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-leave',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/Leave/resources/assets/sass/app.scss',
|
||||
// 'Modules/Leave/resources/assets/js/app.js',
|
||||
//];
|
Reference in New Issue
Block a user