whoami7 - Manager
:
/
home
/
gracious
/
hris.graciousphils.com
/
backup hris employee
/
Upload File:
files >> /home/gracious/hris.graciousphils.com/backup hris employee/convert-pdf.php
<?php // Enable error reporting for debugging ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); include('includes/config.php'); // Includes the FPDF main library require_once("vendor/fpdf/fpdf.php"); try { // Start output buffering ob_start(); // Receiving the form data $imgfile = $_POST['imgfile']; $extension = substr($imgfile, strlen($imgfile) - 4, strlen($imgfile)); $imgnewfile = md5($imgfile) . $extension; $idid = $_POST['idid']; $ofcrs = $_POST['officernames']; $posss = $_POST['positions']; $depts = $_POST['departments']; $today = date("F j, Y", strtotime($_POST['tdate'])); $empss = $_POST['empcodes']; $ldays = date("F j, Y ", strtotime($_POST['ldays'])); // Prepare and execute the SQL query $sql = "SELECT * FROM tblemployees WHERE EmpId = :empss"; $query = $dbh->prepare($sql); $query->bindParam(':empss', $empss, PDO::PARAM_STR); $query->execute(); $results = $query->fetchAll(PDO::FETCH_OBJ); if ($query->rowCount() > 0) { foreach ($results as $result) { $pdf = new FPDF(); $pdf->AddPage(); // Set document title $pdf->SetFont('Arial', '', 17); $pdf->Cell(0, 15, 'Letter of Acceptance', 0, 0, 'C'); // Date and recipient information $pdf->Ln(); $pdf->Ln(16); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, $today); $pdf->Ln(); $pdf->Ln(10); $pdf->SetFont('Arial', 'B', 12); if ($result->MiddleName == 'N/A' || $result->MiddleName == 'n/a' || $result->MiddleName == 'N/a') { $pdf->Write(6, $result->FirstName . " " . $result->LastName); } else { $pdf->Write(6, $result->FirstName . " " . $result->MiddleName . " " . $result->LastName); } $pdf->Ln(); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, $result->Address); $pdf->Ln(); $pdf->Ln(10); $pdf->SetFont('Arial', '', 12); if ($result->Gender == 'Male') { $pdf->Write(6, "Dear Mr. " . $result->LastName . ","); } else { $pdf->Write(6, "Dear Ms. " . $result->LastName . ","); } $pdf->Ln(); $pdf->Ln(10); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, "Your Letter of Resignation has been accepted by Management. However, we still expect you to perform your duties and responsibilities with utmost dedication and professionalism until the close of business hours of $ldays which is the effectivity date of your separation with the Company."); $pdf->Ln(); $pdf->Ln(5); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, "You shall be responsible for the processing and monitoring of your clearance which can be undertaken during your last week in the Company."); $pdf->Ln(); $pdf->Ln(5); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, "Once your clearance is completed, it shall be forwarded to Finance Department for the processing of the last salary, 13th month pay and other monetary claims less appropriate deductions like cash advances, unpaid loans and other accountabilities."); $pdf->Ln(); $pdf->Ln(5); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, "Your last pay and other claims shall be released within 2-3 weeks from the time your clearance is completed."); $pdf->Ln(); $pdf->Ln(5); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, "In event of your failure to process the required clearance within six (6) months from your separation with the Company, any financial entitlement shall be forfeited in favor of the Company."); $pdf->Ln(); $pdf->Ln(10); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, "We thank you for all the accomplishment and contributions which you've provided to the Company. Good Luck!"); // Add images and signature $imageX = $pdf->GetPageWidth() - 60; // Adjust the value based on your layout requirements $imageY = $pdf->GetPageHeight() - 80; // Adjust the value based on your layout requirements $pdf->Image('hradmin/letterofacceptance/received logo.png', $imageX, $imageY, 40, 40); $overlapX = $imageX; $overlapY = $imageY; $textX = $overlapX; $textY = $overlapY + 20; // Adjust the value based on your layout requirements $pdf->SetXY($overlapX, $overlapY); $pdf->Image('signatureupload/' . $result->My_Signature, $overlapX, $overlapY, 30, 30); $pdf->SetXY($textX, $textY); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, $result->FirstName . " " . $result->LastName); $pdf->Ln(); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, "Respectfully yours,"); $pdf->Ln(); $pdf->Image('signatureupload/' . $imgfile, 10, 240, 30, 30); $pdf->Ln(); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, $ofcrs); $pdf->Ln(); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, $posss); $pdf->Ln(); $pdf->SetFont('Arial', '', 12); $pdf->Write(6, $depts); // Save PDF to file $directory = 'hradmin/letterofacceptance/'; if (!is_dir($directory)) { throw new Exception("Directory does not exist: $directory"); } $filess = 'LOA' . $result->LastName . $result->FirstName . '.pdf'; $fullPath = $directory . $filess; $pdf->Output($fullPath, 'F'); // Save the file on the server $pdf->Output($filess, 'D'); // Force download // Update the database $sql = "UPDATE tbl_releasing_file SET Letter_Of_Acceptance = :filess, isReceived_LOA = 3 WHERE id = :idid"; $query = $dbh->prepare($sql); $query->bindParam(':filess', $filess, PDO::PARAM_STR); $query->bindParam(':idid', $idid, PDO::PARAM_STR); $query->execute(); } } else { throw new Exception("No records found for EmpId: $empss"); } // End output buffering and flush ob_end_flush(); } catch (Exception $e) { // Log the error and show a generic error message error_log($e->getMessage()); ob_end_clean(); // Clean the buffer if there is an error echo "An error occurred while processing your request. Please try again later."; } ?>
Copyright ©2021 || Defacer Indonesia