Skip to content
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

Contractor appraisal letter #3687

4 changes: 2 additions & 2 deletions Modules/Salary/Http/Controllers/SalaryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function storeOrUpdateContractorSalary(Request $request, Employee $employ
return redirect()->back()->with('success', $message);
}


public function generateAppraisalLetter(Request $request, Employee $employee)
{
$salaryService = new SalaryCalculationService($request->grossSalary);
Expand All @@ -72,8 +73,7 @@ public function generateAppraisalLetter(Request $request, Employee $employee)

return $pdf->inline($employee->user->name . '_Increment Letter_' . Carbon::parse($request->commencementDate)->format('jS F Y') . '.pdf');
} elseif ($employee->payroll_type === 'contractor') {
$pdf = $salaryService->getContractorOnboardingLetterPdf($request->all());

$pdf = $salaryService->getContractorOnboardingLetterPdf($request->all(), $employee);
return $pdf->inline($employee->user->name . '_Onboarding Letter_' . Carbon::parse($request->commencementDate)->format('jS F Y') . '.pdf');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
}
.address{
font-weight: bold;

}
.address span {
font-size: 14px !important

}
.pay-details{
font-size: 14px;
Expand Down

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions Modules/Salary/Resources/views/render/footer.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.footer {
width: 100%;
text-align: center;
}
</style>
</head>
<body>
<div class="footer">
ColoredCow Consulting Pvt. Ltd. | +91 9818571035 | [email protected] | F-61 Suncity,
Sector 54, Gurgaon, India | CIN No. U72900HR2019PTC081234 | https://coloredcow.com/
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions Modules/Salary/Resources/views/render/header.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.header {
width: 100%;
text-align: center;
}
</style>
</head>
<body>
<div class="header">
<img src="{{ public_path('images/coloredcow.png') }}" alt="">
<hr>
</div>
</body>
</html>
29 changes: 28 additions & 1 deletion Modules/Salary/Services/SalaryCalculationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,40 @@ public function getIncrementLetterPdf($data)
return $pdf;
}

public function getContractorOnboardingLetterPdf($data)
public function getEmployeeAddressDetail($employee)
{
$user = $employee->user;
$userProfile = $user->profile;
$address = $userProfile->address;
return $address;
}

public function getEmployeeAge($employee)
{
$user = $employee->user;
$userProfile = $user->profile;
$dateOfBirth = $userProfile->date_of_birth;
$dob = Carbon::parse($dateOfBirth);
$age = $dob->age;
return $age;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this an accessor in user Model. So that we can get the age attribute everywhere by using $user->age

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure


public function getContractorOnboardingLetterPdf($data, $employee)
{
$commencementDate = Carbon::parse($data['commencementDate'])->format('jS F Y');
$data['formattedCommencementDate'] = $commencementDate;
$data['employeeAddress'] = $this->getEmployeeAddressDetail($employee);
$data['employeeAge'] = $this->getEmployeeAge($employee);
$data['employee'] = $employee;
$pdf = App::make('snappy.pdf.wrapper');
$template = 'contractor-onboarding-template';

$html = view('salary::render.' . $template, compact('data'));
$pdf->loadHTML($html);

$pdf->setOption('header-html', view('salary::render.header')->render());
$pdf->setOption('footer-html', view('salary::render.footer')->render());

return $pdf;
}
}
2 changes: 1 addition & 1 deletion Modules/Salary/Services/SalaryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function storeOrUpdateSalary($request, $employee)

$appraisalData = $salaryService->appraisalLetterData($request, $employee);
if ($employee->staff_type === 'Contractor') {
$pdf = $salaryService->getContractorOnboardingLetterPdf($appraisalData);
$pdf = $salaryService->getContractorOnboardingLetterPdf($appraisalData, $employee);
Mail::to($data['employeeEmail'])->send(new SendContractorOnboardingLetterMail($data, $pdf->inline($data['employeeName'] . '_Onboarding Letter_' . $formattedCommencementDate . '.pdf'), $formattedCommencementDate));
} else {
$pdf = $salaryService->getAppraisalLetterPdf($appraisalData);
Expand Down
Loading