Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
bc6f35e
initial breakpoint commit
GoranStefanovski Jan 30, 2025
1a6d4dc
initial layouting changes commit
GoranStefanovski Jan 30, 2025
1e8749e
adding permissions and roles
GoranStefanovski Jan 30, 2025
1efaafe
add new tables for leave types and user days count, add to seeder
GoranStefanovski Jan 30, 2025
2d6517e
add leave_requests migration, add leave type php
GoranStefanovski Jan 30, 2025
137ff9c
mave view for leave types available
GoranStefanovski Jan 31, 2025
191a348
add PHP for leave requests
GoranStefanovski Jan 31, 2025
49368fa
enable listing of leave types
GoranStefanovski Jan 31, 2025
4b22c6c
fix create and update for leaveTypes
GoranStefanovski Jan 31, 2025
9ee9dde
update leave types search, create leave request page core, starting d…
GoranStefanovski Jan 31, 2025
8f36eb6
fix save on request, update migration and types
GoranStefanovski Jan 31, 2025
9cf1b27
minor update to view and change in draw search
GoranStefanovski Jan 31, 2025
8545c91
frontend work with dropdowns and design
GoranStefanovski Jan 31, 2025
ac70986
fix migration, fix typo and fix request edit
GoranStefanovski Jan 31, 2025
3dc375f
fix branding, fix my profile page
GoranStefanovski Jan 31, 2025
c5e38dc
fix issues with minimize
GoranStefanovski Jan 31, 2025
7c4c6d6
add confirmation page, add permissions, add proper save to all values…
GoranStefanovski Feb 1, 2025
58b4824
add email sending to admins and assigned manager, remove faker accounts
GoranStefanovski Feb 1, 2025
9673084
email hadndling on create/update, approve and decline request day api…
GoranStefanovski Feb 1, 2025
70d8858
show status on requests
GoranStefanovski Feb 1, 2025
ec6c97b
add status badge to requests
GoranStefanovski Feb 2, 2025
f67a8df
add colors on btns
GoranStefanovski Feb 2, 2025
b9d0b95
create Calendar user tab, tab active classes fix
GoranStefanovski Feb 2, 2025
be924e0
get approved days by user in edit, show request depending on role
GoranStefanovski Feb 2, 2025
82086a5
draw leave types for colors in the calendar
GoranStefanovski Feb 2, 2025
e843ba0
add max leave and leave felt in user
GoranStefanovski Feb 4, 2025
c792412
add if leave type paid vacation, to substract days left, add better d…
GoranStefanovski Feb 4, 2025
424f24d
disable paid if no paid days left
GoranStefanovski Feb 4, 2025
0fa2849
add singe calendar view for user
GoranStefanovski Feb 4, 2025
037ef82
add calendar view for all people
GoranStefanovski Feb 4, 2025
540b342
add national holiday db, add country dropdown for user, add command f…
GoranStefanovski Feb 4, 2025
8b20ab3
remove sensitive from .env
GoranStefanovski Feb 4, 2025
0fbd2da
add deduct vacation paid days function, removing holidays and weekend…
GoranStefanovski Feb 4, 2025
f716ccf
add national holidays in main calendar
GoranStefanovski Feb 5, 2025
4dcb644
add national holiday on user calendar
GoranStefanovski Feb 5, 2025
93a3194
change command to not save holiday if weekend
GoranStefanovski Feb 5, 2025
b4d5cc2
disable national holiday
GoranStefanovski Feb 5, 2025
8b5dd9f
show days left on user row
GoranStefanovski Feb 5, 2025
d87a3c9
add main dashboard views and tables
GoranStefanovski Feb 5, 2025
ac246cb
change command
GoranStefanovski Feb 6, 2025
bb229f1
Refactor leave days and add relation to leavedays to user and leave t…
StefanUgrenovikj Feb 6, 2025
fc4fd18
fix deleting and editing requests, fix email sendings
GoranStefanovski Feb 6, 2025
d6ef2ce
fix email templates
GoranStefanovski Feb 6, 2025
6ef7a01
add work from home
GoranStefanovski Feb 6, 2025
a4eb6b4
fix apis, improve work from home functionality
GoranStefanovski Feb 6, 2025
1648650
add is_office_based in DB and in User view
GoranStefanovski Feb 6, 2025
4d993a1
make sortabkle
GoranStefanovski Feb 6, 2025
b2298e0
fix setback routes, add filtering to headers
GoranStefanovski Feb 6, 2025
01d3530
add loading to save button
GoranStefanovski Feb 6, 2025
3351eb2
approve loading
GoranStefanovski Feb 6, 2025
f49e319
fix my profile page
GoranStefanovski Feb 7, 2025
f129dcf
fix back button on my profile
GoranStefanovski Feb 7, 2025
5678ba6
add reason to email template, fix approve/decline buttons to show to …
GoranStefanovski Feb 7, 2025
be4d84d
changes in hompeage public, request validation for leave requets, cha…
GoranStefanovski Feb 7, 2025
f197bbb
Add delete crud for users and leave request and add modal for confirm
StefanUgrenovikj Feb 7, 2025
8e8cbc6
add document table, send pdf to email, download pdf in users, fix my …
GoranStefanovski Feb 9, 2025
04be158
fix approve decline stylie
GoranStefanovski Feb 9, 2025
c84e1fd
fix pdf file with layouting data, need to update cyrilic data in DB
GoranStefanovski Feb 9, 2025
7ae04d8
fix layouting with leave types row in leave calendar tab and page
GoranStefanovski Feb 9, 2025
4e7075b
small layouting changes
GoranStefanovski Feb 9, 2025
d023067
Merge pull request #1 from GoranStefanovski/breakpoint-to-dev
GoranStefanovski Feb 9, 2025
2070a1e
add pdf mail to administration, add cancelation email
GoranStefanovski Feb 10, 2025
dec80d4
ad MK templates
GoranStefanovski Feb 11, 2025
038832b
Merge branch 'breakpoint-master' into dev
GoranStefanovski Feb 11, 2025
c14d51a
change email subjects, change approve bg color btn
GoranStefanovski Feb 11, 2025
9d5b51b
add validation for leave types and leave requests
GoranStefanovski Feb 12, 2025
d7bae06
delete leave type, refactor not needed code
GoranStefanovski Feb 12, 2025
d2be3f9
rename in leavetypes
GoranStefanovski Feb 12, 2025
c9048a5
update user id confirmed by
GoranStefanovski Feb 12, 2025
a373bd0
add error messages
GoranStefanovski Feb 12, 2025
b92e1ae
Merge branch 'breakpoint-master' into dev
GoranStefanovski Feb 12, 2025
9c1fda3
test deploy
GoranStefanovski Feb 13, 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
10 changes: 4 additions & 6 deletions app/api/app/Applications/Document/Requests/LeaveTypeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@ public function rules()
$rules = [
'name' => 'required|max:255|min:2',
'slug' => 'required|max:255|min:2',
'color' => 'required',
];

return $rules;
}
public function messages(){
return [
'name.required' => 'users.name.required',
'name.max' => 'users.name.max',
'name.min' => 'users.name.min',
'slug.required' => 'users.slug.required',
'slug.max' => 'users.slug.max',
'slug.min' => 'users.slug.min',
'name.required' => 'The name field is required',
'slug.required' => 'The slug field is required',
'color.required' => 'The color field is required',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace App\Applications\LeaveRequest\Mail;

use App\Applications\LeaveRequest\Model\LeaveRequest;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class LeaveRequestCancelation extends Mailable
{
use Queueable, SerializesModels;

public LeaveRequest $leaveRequest;
public ?string $pdfPath;

/**
* Create a new message instance.
*/
public function __construct(LeaveRequest $leaveRequest, ?string $pdfPath = null)
{
$this->leaveRequest = $leaveRequest;
$this->pdfPath = $pdfPath;
}

/**
* Build the message.
*/
public function build(): self
{
$formattedStartDate = \Carbon\Carbon::parse($this->leaveRequest->start_date)->format('d M Y');
$formattedEndDate = $this->leaveRequest->end_date
? \Carbon\Carbon::parse($this->leaveRequest->end_date)->format('d M Y')
: null;
$subject = $this->leaveRequest->user->first_name . ' ' . $this->leaveRequest->user->last_name . ': ' . $this->leaveRequest->leaveType->name . ': ' . $formattedStartDate . ($this->leaveRequest->end_date ? ' to ' . $formattedEndDate : '');
$email = $this->subject($subject .' (Canceled)')
->view('emails.leave_request_cancelation')
->with([
'leaveRequest' => $this->leaveRequest,
]);

return $email;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,33 @@ class LeaveRequestConfirmation extends Mailable
use Queueable, SerializesModels;

public LeaveRequest $leaveRequest;
public ?string $pdfPath;

/**
* Create a new message instance.
*/
public function __construct(LeaveRequest $leaveRequest, ?string $pdfPath = null)
public function __construct(LeaveRequest $leaveRequest)
{
$this->leaveRequest = $leaveRequest;
$this->pdfPath = $pdfPath;
}

/**
* Build the message.
*/
public function build(): self
{
$email = $this->subject($this->leaveRequest->user->first_name . ' ' . $this->leaveRequest->user->last_name .' Leave Request was Approved')
$formattedStartDate = \Carbon\Carbon::parse($this->leaveRequest->start_date)->format('d M Y');
$formattedEndDate = $this->leaveRequest->end_date
? \Carbon\Carbon::parse($this->leaveRequest->end_date)->format('d M Y')
: null;

$subject =$this->leaveRequest->user->first_name . ' ' . $this->leaveRequest->user->last_name . ': ' . $this->leaveRequest->leaveType->name . ': ' . $formattedStartDate . ($this->leaveRequest->end_date ? ' to ' . $formattedEndDate : '');
$email = $this->subject($subject .' (Approved)')
->view('emails.leave_request_confirmation')
->with([
'leaveRequest' => $this->leaveRequest,
]);


if ($this->pdfPath && file_exists($this->pdfPath)) {
$email->attach($this->pdfPath, [
'as' => basename($this->pdfPath),
'mime' => 'application/pdf',
]);
}

return $email;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace App\Applications\LeaveRequest\Mail;

use App\Applications\LeaveRequest\Model\LeaveRequest;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class LeaveRequestConfirmationPDF extends Mailable
{
use Queueable, SerializesModels;

public LeaveRequest $leaveRequest;
public ?string $pdfPath;

/**
* Create a new message instance.
*/
public function __construct(LeaveRequest $leaveRequest, ?string $pdfPath = null)
{
$this->leaveRequest = $leaveRequest;
$this->pdfPath = $pdfPath;
}

/**
* Build the message.
*/
public function build(): self
{
$subject = $this->leaveRequest->user->country == 1 ? 'ESOF Starter' : 'ESOF BG';
$email = $this->subject( $subject . ' PDF')
->view('emails.leave_request_confirmation_pdf')
->with([
'leaveRequest' => $this->leaveRequest,
]);


if ($this->pdfPath && file_exists($this->pdfPath)) {
$email->attach($this->pdfPath, [
'as' => basename($this->pdfPath),
'mime' => 'application/pdf',
]);
}

return $email;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ public function __construct(LeaveRequest $leaveRequest)
*/
public function build(): self
{
return $this->subject('Leave Request was Declined')
$formattedStartDate = \Carbon\Carbon::parse($this->leaveRequest->start_date)->format('d M Y');
$formattedEndDate = $this->leaveRequest->end_date
? \Carbon\Carbon::parse($this->leaveRequest->end_date)->format('d M Y')
: null;

$subject = $this->leaveRequest->leaveType->name . ': ' . $formattedStartDate . ($this->leaveRequest->end_date ? ' to ' . $formattedEndDate : '');
return $this->subject($subject . ' (Declined)')
->view('emails.leave_request_decline')
->with([
'leaveRequest' => $this->leaveRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ public function __construct(LeaveRequest $leaveRequest)
*/
public function build(): self
{
return $this->subject('New Leave Request Assigned to You')
$formattedStartDate = \Carbon\Carbon::parse($this->leaveRequest->start_date)->format('d M Y');
$formattedEndDate = $this->leaveRequest->end_date
? \Carbon\Carbon::parse($this->leaveRequest->end_date)->format('d M Y')
: null;
$subject =$this->leaveRequest->user->first_name . ' ' . $this->leaveRequest->user->last_name . ': ' . $this->leaveRequest->leaveType->name . ': ' . $formattedStartDate . ($this->leaveRequest->end_date ? ' to ' . $formattedEndDate : '');
return $this->subject('Requested: ' . $subject)
->view('emails.leave_request_notification')
->with([
'leaveRequest' => $this->leaveRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ public function __construct(LeaveRequest $leaveRequest)
*/
public function build(): self
{
return $this->subject('A Leave Request Is Updated')
$formattedStartDate = \Carbon\Carbon::parse($this->leaveRequest->start_date)->format('d M Y');
$formattedEndDate = $this->leaveRequest->end_date
? \Carbon\Carbon::parse($this->leaveRequest->end_date)->format('d M Y')
: null;

$subject =$this->leaveRequest->user->first_name . ' ' . $this->leaveRequest->user->last_name . ': ' . $this->leaveRequest->leaveType->name . ': ' . $formattedStartDate . ($this->leaveRequest->end_date ? ' to ' . $formattedEndDate : '');
return $this->subject($subject . ' (Update)')
->view('emails.leave_request_notification')
->with([
'leaveRequest' => $this->leaveRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
LeaveRequestNotification,
LeaveRequestNotificationUpdate,
LeaveRequestConfirmation,
LeaveRequestDeclining
LeaveRequestDeclining,
LeaveRequestCancelation,
LeaveRequestConfirmationPDF,
};
use App\Applications\Pagination\StarterPaginator;
use App\Applications\LeaveRequest\Model\LeaveRequest;
Expand Down Expand Up @@ -103,11 +105,14 @@ public function confirm(int $leaveRequestId, LeaveRequestDTO $leaveRequestData,
$leaveRequest->update([
...$leaveRequestData->toArray(),
'is_confirmed' => $isConfirmed,
'confirmed_by' => ($isConfirmed == 2 ? $user->id : $leaveRequest['confirmed_by'])
'confirmed_by' => $user->id
]);

if ($isConfirmed == 2) {
$this->createLeaveRequestPDF($leaveRequest->user, $leaveRequest);
if ($leaveRequest->leave_type_id == 3 || $leaveRequest->leave_type_id == 4) {
$this->createLeaveRequestPDF($leaveRequest->user, $leaveRequest);
$this->sendConfirmationAccountentsEmail($leaveRequest);
}

if ($leaveRequest->user && $leaveRequestData->leave_type_id == 3) {
$this->deductPaidLeaves($leaveRequest->user, $leaveRequestData);
Expand All @@ -120,7 +125,10 @@ public function confirm(int $leaveRequestId, LeaveRequestDTO $leaveRequestData,

public function delete(int $id)
{
return $this->leaveRequest::findOrFail($id)->delete();
$leaveRequest = $this->leaveRequest::findOrFail($id);
$this->sendRequestCancelationEmail($leaveRequest);

return $leaveRequest->delete();
}

public function draw($data): StarterPaginator
Expand Down Expand Up @@ -177,15 +185,30 @@ private function sendRequestConfirmationEmail(LeaveRequest $leaveRequest)
};

if ($mailClass) {
if ($leaveRequest->is_confirmed == 2) {
$document = Document::where('leave_request_id', $leaveRequest->id)->first();
Mail::to($recipients)->send(new $mailClass($leaveRequest, $document ? Storage::disk('public')->path($document->file_path) : null));
} else {
Mail::to($recipients)->send(new $mailClass($leaveRequest));
}
Mail::to($recipients)->send(new $mailClass($leaveRequest));
}
}

private function sendRequestCancelationEmail(LeaveRequest $leaveRequest)
{
$recipients = $this->getRecipients($leaveRequest);

Mail::to($recipients)->send(new LeaveRequestCancelation($leaveRequest));
}


private function sendConfirmationAccountentsEmail(LeaveRequest $leaveRequest) {
$administrationEmails = User::role(User::COLLABORATOR)
->where('country', '=', $leaveRequest->user->country)
->pluck('email')
->toArray();

if ($leaveRequest->is_confirmed == 2) {
$document = Document::where('leave_request_id', $leaveRequest->id)->first();
Mail::to($administrationEmails)->send(new LeaveRequestConfirmationPDF($leaveRequest, $document ? Storage::disk('public')->path($document->file_path) : null));
}
}

private function getRecipients(LeaveRequest $leaveRequest)
{
$manager = $this->user->find($leaveRequest->request_to);
Expand Down Expand Up @@ -235,12 +258,12 @@ private function createLeaveRequestPDF(User $user, LeaveRequest $leaveRequest):
// Cannot print in PDF
// Create a Cyrilyc Data for each user on create in a separate table, with foreign user_id
$fullNameCyrilic = transliterator_transliterate('Latin-Cyrillic', $user->first_name) . ' ' . transliterator_transliterate('Latin-Cyrillic', $user->last_name);
$start_date = $this->formatDate($leaveRequest->start_date);

if ($isSingleDay) {
$dates = $this->formatDate($leaveRequest->start_date);
$leaveDays = 1;
} else {
$dates = $this->formatDate($leaveRequest->start_date) . "g. to " . $this->formatDate($leaveRequest->end_date) . 'g.';
$end_date = $this->formatDate($leaveRequest->end_date);
// Calculate valid leave days excluding weekends and national holidays
$startDate = new DateTime($leaveRequest->start_date);
$endDate = $leaveRequest->end_date ? new DateTime($leaveRequest->end_date) : $startDate;
Expand All @@ -259,26 +282,50 @@ private function createLeaveRequestPDF(User $user, LeaveRequest $leaveRequest):
fn($date) => in_array($date->format('N'), [6, 7]) || in_array($date->format('Y-m-d'), $nationalHolidays)
));
}

$userCountry = $leaveRequest->user->country;

$pdf = new Fpdi();
$pdf->AddPage();
$pdf->setSourceFile(public_path('BG_template.pdf'));
if ($userCountry == 1) {
if ($leaveRequest->leave_type_id == 3) {
$pdf->setSourceFile(public_path('MK_template_paid.pdf'));
} else {
$pdf->setSourceFile(public_path('MK_template_unpaid.pdf'));
}
} else {
if ($leaveRequest->leave_type_id == 3) {
$pdf->setSourceFile(public_path('BG_template_paid.pdf'));
} else {
$pdf->setSourceFile(public_path('BG_template_unpaid.pdf'));
}
}

$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 0, 0, 210);

$pdf->SetFont('Arial', '', 11);
$pdf->SetXY(111, 77);
$pdf->Write(0, $user->first_name . " " . $user->last_name);
$pdf->SetXY(112, 110);
$pdf->Write(0, $leaveRequest->leaveType->name ?? 'N/A');
$pdf->SetXY(121, 114);
$pdf->Write(0, $leaveDays ?? 'N/A');
$pdf->SetXY(44, 118);
$pdf->Write(0, $dates ?? 'N/A');
$pdf->SetXY(24, 159);
$pdf->Write(0, $nowDate ?? 'N/A');
$pdf->SetXY(24, 227);
$pdf->Write(0, $nowDate ?? 'N/A');
if ($userCountry !== 1) {
$pdf->SetXY(111, 79);
$pdf->Write(0, $user->first_name . " " . $user->last_name);
$pdf->SetXY($leaveRequest->leave_type_id == 3 ? 92 : 80, 135);
$pdf->Write(0, $leaveDays ?? 'N/A');
$pdf->SetXY(44, 141);
$pdf->Write(0, $start_date ?? 'N/A');
$pdf->SetXY(44, 147);
$pdf->Write(0, $end_date ?? '');
$pdf->SetXY(24,215);
$pdf->Write(0, $nowDate ?? 'N/A');
} else {
$pdf->SetXY(111, 77);
$pdf->Write(0, $user->first_name . " " . $user->last_name);
$pdf->SetXY(65, 118);
$pdf->Write(0, $leaveDays ?? 'N/A');
$pdf->SetXY(124, 118);
$pdf->Write(0, $start_date ?? 'N/A');
$pdf->SetXY(150, 118);
$pdf->Write(0, $end_date ?? '');
$pdf->SetXY(24,193);
$pdf->Write(0, $nowDate ?? 'N/A');
}

$pdfDirectory = storage_path("app/public/");
if (!file_exists($pdfDirectory)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function rules()
$rules = [
'request_to' => 'required',
'leave_type_id' => 'required',
'start_date' => 'required|date',
'start_date' => 'required|date|after_or_equal:today',
'end_date' => 'sometimes|date|after_or_equal:start_date',
];

Expand Down
Loading