From d08ade39525c31ae80c65a78508a0e0014479f7f Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 1 Oct 2020 10:57:48 +0000 Subject: [PATCH] Redo the pdf form. #515 --- .../JobOrderHandler/CMBJobOrderHandler.php | 295 +++++++----------- translations/messages.en.yaml | 7 +- 2 files changed, 126 insertions(+), 176 deletions(-) diff --git a/src/Service/JobOrderHandler/CMBJobOrderHandler.php b/src/Service/JobOrderHandler/CMBJobOrderHandler.php index 4760d286..ece0ff70 100644 --- a/src/Service/JobOrderHandler/CMBJobOrderHandler.php +++ b/src/Service/JobOrderHandler/CMBJobOrderHandler.php @@ -2150,7 +2150,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface // translate the title and the logo for the pdf $translated_title = $translator->trans('jo_title_pdf'); - $translated_logo = $translator->trans('image_jo_pdf'); + // TODO: change the image file in messages.en.yaml to the correct logo + $translated_logo = $translator->trans('image_jo_pdf_century_logo'); $translated_delivery_instructions_label = $translator->trans('delivery_instructions_label'); // generate the pdf @@ -2182,109 +2183,138 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface // insert JO number $pdf->SetFont($font_face, 'B', $jo_font_size); $pdf->SetX($col2_x); - $pdf->Cell($label_width, $jo_line_height, 'JO Number:'); + $pdf->Cell($label_width, $jo_line_height, 'JO NO:'); $pdf->SetTextColor(9, 65, 150); $pdf->Cell(0, $jo_line_height, $obj->getID()); + $pdf->Ln(); + + // insert date + $pdf->setX($col2_x); + $str_date_create = $obj->getDateCreate()->format('d/m/y'); + $pdf->SetFont($font_face, 'B', $jo_font_size); + $pdf->SetTextColor(0, 0, 0); + $pdf->Cell($label_width, $jo_line_height, 'JO Date:'); + $pdf->SetTextColor(9, 65, 150); + $pdf->Cell(0, $jo_line_height, $str_date_create); + + // insert company name + $pdf->Ln($line_height * 4); + $pdf->SetFont($font_face, 'B', $body_font_size); + $pdf->SetTextColor(0, 0, 0); + $pdf->SetX($col1_x); + $pdf->Cell(0, $jo_line_height, $translator->trans('pdf_company_name')); + + // insert company address + $pdf->Ln($line_height); + $pdf->SetFont($font_face, '', $body_font_size); + $pdf->SetTextColor(0, 0, 0); + $pdf->SetX($col1_x); + $pdf->Cell(0, $jo_line_height, $translator->trans('pdf_company_address')); + + // insert company numbers and email + $pdf->Ln($line_height); + $pdf->SetFont($font_face, '', $body_font_size); + $pdf->SetTextColor(0, 0, 0); + $pdf->SetX($col1_x); + $pdf->Cell(0, $jo_line_height, $translator->trans('pdf_company_number_email')); + + // insert INVOICE header + $pdf->Ln($line_height * 3); + $pdf->SetFont($font_face, 'BU', $jo_font_size); + $pdf->MultiCell(0 , $jo_line_height, 'INVOICE', 0, 'C'); + + // insert customer details header + $pdf->SetFont($font_face, 'B', $body_font_size); + $pdf->SetTextColor(0, 0, 0); + $pdf->SetX($col1_x); + $pdf->Cell(0, $jo_line_height, $translator->trans('pdf_customer_details_header')); + + $pdf->Ln($line_height * 2); + // insert customer info $customer = $obj->getCustomer(); $pdf->SetFont($font_face, '', $body_font_size); $pdf->SetTextColor(0, 0, 0); - $pdf->Ln($line_height * 7); - // get current Y $y = $pdf->GetY(); $pdf->SetXY($col1_x, $y); $pdf->Cell($label_width, $line_height, 'Customer Name:'); - $pdf->MultiCell($val_width, $line_height, $customer ? $customer->getFirstName() . ' ' . $customer->getLastName() : '', 0, 'L'); + $pdf->MultiCell($val_width, $line_height, $customer ? strtoupper($customer->getFirstName()) . ' ' . strtoupper($customer->getLastName()) : '', 0, 'L'); - // get Y after left cell - $y1 = $pdf->GetY(); + // get current Y + $y = $pdf->GetY(); - $pdf->SetXY($col2_x, $y); + $pdf->SetXY($col1_x, $y); $pdf->Cell($label_width, $line_height, 'Mobile Phone:'); $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneMobile() ? $this->country_code . $customer->getPhoneMobile() : '', 0, 'L'); - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); + // get current Y + $y = $pdf->GetY(); $pdf->SetXY($col1_x, $y); - $pdf->Cell($label_width, $line_height, 'Delivery Date:'); - $pdf->MultiCell($val_width, $line_height, $obj->getDateSchedule() ? $obj->getDateSchedule()->format("m/d/Y") : '', 0, 'left'); + $pdf->Cell($label_width, $line_height, 'Second Number:'); + $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneMobile() ? $this->country_code . $customer->getPhoneLandline() : '', 0, 'L'); - // get Y after left cell - $y1 = $pdf->GetY(); - - $pdf->SetXY($col2_x, $y); - $pdf->Cell($label_width, $line_height, 'Landline:'); - $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneLandline() ? $this->country_code . $customer->getPhoneLandline() : '', 0, 'L'); - - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); - - $pdf->SetXY($col2_x, $y); - $pdf->Cell($label_width, $line_height, 'Office Phone:'); - $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneOffice() ? $this->country_code . $customer->getPhoneOffice() : '', 0, 'L'); - - $pdf->SetX($col2_x); - $pdf->Cell($label_width, $line_height, 'Fax:'); - $pdf->MultiCell($val_width, $line_height, $customer && $customer->getPhoneFax() ? $this->country_code . $customer->getPhoneFax() : '', 0, 'L'); + // get current Y + $y = $pdf->GetY(); // insert vehicle info $cv = $obj->getCustomerVehicle(); $vehicle = $cv->getVehicle(); - $pdf->Ln(); - $pdf->SetFont($font_face, 'B', $header_font_size); - $pdf->Cell($label_width, $line_height, 'Vehicle Details'); - $pdf->Ln($line_height * 2); - - // get current Y - $y = $pdf->GetY(); - - $pdf->SetFont($font_face, '', $body_font_size); + $pdf->SetXY($col1_x, $y); $pdf->Cell($label_width, $line_height, 'Plate Number:'); - $pdf->MultiCell($val_width, $line_height, $cv ? $cv->getPlateNumber() : '', 0, 'L'); + $pdf->MultiCell(0, $line_height, $cv ? $cv->getPlateNumber() : '', 0, 'L'); - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); + // get current Y + $y = $pdf->GetY(); $pdf->SetXY($col1_x, $y); $pdf->Cell($label_width, $line_height, 'Brand:'); - $pdf->MultiCell($val_width, $line_height, $vehicle && $vehicle->getManufacturer() ? $vehicle->getManufacturer()->getName() : '', 0, 'L'); + $pdf->MultiCell($val_width, $line_height, $vehicle && $vehicle->getManufacturer() ? strtoupper($vehicle->getManufacturer()->getName()) : '', 0, 'L'); - // get Y after left cell - $y1 = $pdf->GetY(); - - $pdf->SetXY($col2_x, $y); - $pdf->Cell($label_width, $line_height, 'Model / Year:'); - $pdf->MultiCell(0, $line_height, $cv ? $cv->getModelYear() : '', 0, 'L'); - - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); + // get current Y + $y = $pdf->GetY(); $pdf->SetXY($col1_x, $y); $pdf->Cell($label_width, $line_height, 'Make:'); - $pdf->MultiCell($val_width, $line_height, $vehicle ? $vehicle->getMake() : '', 0, 'L'); + $pdf->MultiCell($val_width, $line_height, $vehicle ? strtoupper($vehicle->getMake()) : '', 0, 'L'); - // insert battery info + // get current Y + $y = $pdf->GetY(); + + $pdf->SetXY($col1_x, $y); + $pdf->Cell($label_width, $line_height, 'Model / Year:'); + $pdf->MultiCell(0, $line_height, $cv ? $cv->getModelYear() : '', 0, 'L'); + + // get current Y + $y = $pdf->GetY(); + + $pdf->SetXY($col1_x, $y); + $pdf->Cell($label_width, $line_height, 'Delivery Address:'); + $pdf->MultiCell($val_width, $line_height, strtoupper($obj->getDeliveryAddress()), 0, 'L'); + + + // insert Other Details $battery = $cv->getCurrentBattery(); $pdf->Ln(); $pdf->SetFont($font_face, 'B', $header_font_size); - $pdf->Cell($label_width, $line_height, 'Battery Details'); + $pdf->Cell($label_width, $line_height, 'Other Details'); + $pdf->Ln($line_height); + $pdf->SetFont($font_face, '', $body_font_size); + + // get current Y + $y = $pdf->GetY(); + + $pdf->setXY($col1_x, $y); + $pdf->Cell($label_width, $line_height, strtoupper($obj->getDeliveryInstructions())); + + // insert invoice details + $pdf->Ln($line_height * 2); + $pdf->SetFont($font_face, 'B', $header_font_size); + $pdf->Cell($label_width, $line_height, 'Invoice Details'); $pdf->Ln($line_height * 2); $pdf->SetFont($font_face, '', $body_font_size); @@ -2292,101 +2322,29 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface // get current Y $y = $pdf->GetY(); - $pdf->Cell($label_width, $line_height, 'Current Battery:'); - $pdf->MultiCell($val_width, $line_height, $battery && $battery->getManufacturer() && $battery->getModel() && $battery->getSize() ? $battery->getManufacturer()->getName() . ' ' . $battery->getModel()->getName() . ' ' . $battery->getSize()->getName() . ' (' . $battery->getProductCode() . ')' : '', 0, 'L'); + $pdf->Cell($label_width, $line_height, 'Transaction Type:'); + $pdf->MultiCell($val_width, $line_height, CMBServiceType::getName($obj->getServiceType()), 0, 'L'); - // get Y after left cell - $y1 = $pdf->GetY(); + // get current Y + $y = $pdf->GetY(); - $pdf->SetXY($col2_x, $y); - $pdf->Cell($label_width, $line_height, 'Serial Number:'); - $pdf->MultiCell(0, $line_height, $cv ? $cv->getWarrantyCode() : '', 0, 'L'); + $pdf->Cell($label_width, $line_height, 'OR Name:'); + $pdf->MultiCell($val_width, $line_height, $obj->getORName(), 0, 'L'); - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); + // get current Y + $y = $pdf->GetY(); $pdf->SetXY($col1_x, $y); - $pdf->Cell($label_width, $line_height, 'Wty. Exp. Date:'); - $pdf->MultiCell($val_width, $line_height, $cv && $cv->getWarrantyExpiration() ? $cv->getWarrantyExpiration()->format("d/m/Y") : '', 0, 'L'); - - // insert transaction details - $pdf->Ln(); - $pdf->SetFont($font_face, 'B', $header_font_size); - $pdf->Cell($label_width, $line_height, 'Transaction Details'); - $pdf->Ln($line_height * 2); - - $pdf->SetFont($font_face, '', $body_font_size); - - // get current Y - $y = $pdf->GetY(); - - $pdf->Cell($label_width, $line_height, 'Warranty Class:'); - $pdf->MultiCell($val_width, $line_height, CMBWarrantyClass::getName($obj->getWarrantyClass()), 0, 'L'); - - // get Y after left cell - $y1 = $pdf->GetY(); - - $pdf->SetXY($col2_x, $y); $pdf->Cell($label_width, $line_height, 'Mode of Payment:'); $pdf->MultiCell(0, $line_height, CMBModeOfPayment::getName($obj->getModeOfPayment()), 0, 'L'); - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); - - $pdf->Cell($label_width, $line_height, 'Delivery Address:'); - $pdf->MultiCell($val_width, $line_height, $obj->getDeliveryAddress(), 0, 'L'); - - // get Y after left cell - $y1 = $pdf->GetY(); - - $pdf->SetXY($col2_x, $y); - $pdf->Cell($label_width, $line_height, 'Landmark:'); - $pdf->MultiCell(0, $line_height, $obj->getLandMark(), 0, 'L'); - - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); + // get current Y + $y = $pdf->GetY(); $pdf->SetXY($col1_x, $y); - $pdf->Cell($label_width, $line_height, 'Dispatch Time:'); - $pdf->MultiCell($val_width, $line_height, $obj->getDateSchedule() ? $obj->getDateSchedule()->format("g:i A") : '', 0, 'L'); - - // get Y after left cell - $y1 = $pdf->GetY(); - - $pdf->SetXY($col2_x, $y); - $pdf->Cell($label_width, $line_height, 'Dispatched By:'); - $pdf->MultiCell(0, $line_height, $obj->getProcessedBy() ? $obj->getProcessedBy()->getFullName() : '', 0, 'L'); - - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); - - // insert delivery instructions - $pdf->SetY($y); - $pdf->Ln(); - $pdf->SetFont($font_face, 'B', $header_font_size); - $pdf->Cell(0, $line_height, $translated_delivery_instructions_label); - $pdf->Ln(); - - $pdf->SetFont($font_face, '', $body_font_size); - $pdf->MultiCell(0, $line_height, $obj->getDeliveryInstructions(), 1, 'L'); - - // insert invoice details - $pdf->Ln(); - $pdf->SetFont($font_face, 'B', $header_font_size); - $pdf->Cell($label_width, $line_height, 'Invoice Details'); - $pdf->Ln(); + $pdf->Cell($label_width, $line_height, 'Credit Card No:'); + // TODO: insert boxes here + $pdf->MultiCell($val_width, $line_height, 'INSERT BOXES HERE', 0, 'L'); // invoice table headers $invoice = $obj->getInvoice(); @@ -2419,30 +2377,20 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $y = $pdf->GetY(); // insert invoice footer details - $pdf->Cell($label_width, $line_height, 'Transaction Type:'); - $pdf->MultiCell($val_width, $line_height, CMBServiceType::getName($obj->getServiceType()), 0, 'L'); + $pdf->Cell($label_width, $line_height, 'Dispatched by:'); + $pdf->MultiCell(0, $line_height, $obj->getProcessedBy() ? $obj->getProcessedBy()->getFullName() : '', 0, 'L'); - // get Y after left cell - $y1 = $pdf->GetY(); - - $pdf->SetXY($col2_x, $y); - $pdf->SetFont($font_face, 'B'); - $pdf->Cell($label_width, $line_height, 'SUBTOTAL:'); - $pdf->SetFont($font_face, ''); - $pdf->MultiCell(0, $line_height, $invoice ? number_format($invoice->getVATExclusivePrice(), 2) : '', 0, 'R'); - - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); + // get current Y + $y = $pdf->GetY(); $pdf->SetXY($col1_x, $y); - $pdf->Cell($label_width, $line_height, 'OR Name:'); - $pdf->MultiCell($val_width, $line_height, $obj->getORName(), 0, 'L'); + $pdf->Cell($label_width, $line_height, 'JO Done by:'); + $pdf->MultiCell(0, $line_height, $obj->getRider() ? $obj->getRider()->getFullName() : '', 0, 'L'); // get Y after left cell - $y1 = $pdf->GetY(); + $y = $pdf->GetY(); + + // TODO: resume here $pdf->SetXY($col2_x, $y); $pdf->SetFont($font_face, 'B'); @@ -2450,11 +2398,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $pdf->SetFont($font_face, ''); $pdf->MultiCell(0, $line_height, $invoice ? number_format($invoice->getVAT(), 2) : '', 0, 'R'); - // get Y after right cell - $y2 = $pdf->GetY(); - - // get row height - $y = max($y1, $y2); + // get current Y + $y = $pdf->GetY(); $pdf->SetXY($col1_x, $y); $pdf->Cell($label_width, $line_height, 'Emp. ID/Card No./Ref. By:'); diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index 1f269944..ce55e323 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -12,6 +12,10 @@ add_cust_vehicle_battery_info: This vehicle is using a Motolite battery jo_title_pdf: Res-Q for CMB Job Order country_code_prefix: '+60' delivery_instructions_label: 'Other Details' +pdf_company_name: ENTITY LOGISTICS SDN BHD(1045869-H) +pdf_company_address: 26/1 Lebuh Persekutuan 47301 Petaling Jaya Selangor +pdf_company_number_email: 'Tel: 03-7872 9072 E-Mail: enquiry@entitylogistic.com.my' +pdf_customer_details_header: Customers Details # images image_logo_login: /assets/images/black-text-logo-01.png @@ -19,7 +23,8 @@ icon_login: /assets/images/battery-assist-bm-logo-32x32.png icon_base_32x32: /assets/images/black-text-logo-01-32x32.png icon_base_16x16: /assets/images/black-text-logo-01-16x16.png image_dashboard: /assets/images/century_logo.png -image_jo_pdf: /public/assets/images/black-text-logo-01-115x115.png +image_jo_pdf_battery_assist_logo: /public/assets/images/battery-assist-bm-logo-edited.png +image_jo_pdf_century_logo: /public/assets/images/black-text-logo-01-115x115.png # default point for maps default_lat: 3.084216