JezK
Edit File: invoice_pdf.php
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ob_start(); //~ echo "hii";exit; require_once __DIR__ . '/vendor/autoload.php'; $mpdf = new \Mpdf\Mpdf(['tempDir' => '/tmp']); $path = '/tmp/mpdf'; // You should change this as prefered. if (!file_exists($path)) { mkdir($path, 0777, true); } $mpdf = new \Mpdf\Mpdf(['tempDir' => $path,'debug' => true]); include_once("./app/checkSession.php"); if(!isset($_REQUEST['inid'])) { header("Location: ./invoicedashboard.php"); } $invid = $_REQUEST['inid']; include("header.php"); $invoiceInfo=$customerObj->getInvoiceInfo($invid); // print_r($invoiceInfo); $company_id=isset($invoiceInfo['company_id'])?$invoiceInfo['company_id']:""; $companyInfo=$customerObj->getComapnyInfo($company_id); //~ print_r($companyInfo);exit; //~ echo $_SERVER["DOCUMENT_ROOT"];exit; $itemDetails=$customerObj->getInvoicesItemsInfo($invid); $itemDetails1=$itemDetails ? $itemDetails :[]; $warehouseNumber = isset($invoiceInfo['warehouse_number'])?$invoiceInfo['warehouse_number']:""; $invoiceValue = isset($invoiceInfo['invoice_value'])?$invoiceInfo['invoice_value']:""; $invoiceNumber = isset($invoiceInfo['invoice_number'])?$invoiceInfo['invoice_number']:""; $createdDate = isset($invoiceInfo['created_date'])?$invoiceInfo['created_date']:""; $date=date_create($createdDate); $modifiedDate=date_format($date,"d-m-Y"); $warehouseName = isset($invoiceInfo['warehouse_name'])?$invoiceInfo['warehouse_name']:""; $customerName = $invoiceInfo['first_name'].' '.$invoiceInfo['last_name']; $currencyType = isset($invoiceInfo['currency'])?$invoiceInfo['currency']:""; $descript=isset($invoiceInfo['description'])?$invoiceInfo['description']:""; if($invoiceInfo['grandtotal'] == "") { $total = 0; foreach($itemDetails1 as $item) { $total = $total + $item['total']; } } $grandtotal=isset($invoiceInfo['grandtotal'])?$invoiceInfo['grandtotal']:$total; $tableHTML =""; if($itemDetails1==0) { $tableHTML ="<tr class='text-center'> <td colspan='7' ><p class='p-2'>No data avilable</p></td> </tr>"; } foreach($itemDetails1 as $item) { $tableHTML .= '<tr> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$item['item_number'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$item['description'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$item['quotation_id'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$item['numberof_pallets'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$item['quantity'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$item['price'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$item['total'].'</td> </tr>'; } //~ $imagePath = "http://uflexit.krify.com/uploads/warehouse_docs/"; $images = "./uploads/warehouse_docs/".$companyInfo["uploaded_attachement"]; if(!file_exists($images)) { $images = "pictures/img1.png"; } //~ echo $images;exit; $template = ' <table width="100%" style="font-family: sans-serif;" cellpadding="10"> <tr> <td width="100%" style="padding: 0px; text-align: center;"> <img src="'.$images.'" class="user_Img" height="100" width="100" alt="" /> </td> </tr> <tr> <td width="100%" style="text-align: center; font-size: 20px; font-weight: bold; padding: 0px;"> INVOICE </td> </tr> <tr> <td height="10" style="font-size: 0px; line-height: 10px; height: 10px; padding: 0px;"> </td> </tr> </table> <table width="100%" style="font-family: sans-serif;" cellpadding="10"> <tr> <!-- <td width="49%" style="border: 0.1mm solid #eee;">Name<br>Company Name<br>Area<br>Area 2<br>Kent<br>0123 6NN</td> <td width="2%"> </td> --> <td width="49%" style="border: 0.1mm solid #eee; text-align: right;"> <strong>'.$companyInfo["company_name"].'</strong><br>'.$companyInfo["address"].'<br>'.$companyInfo["city_name"] .'<br> </td> </tr> </table> <br> <div> <div style="padding:0rem; vertical-align: middle;float:left;width:48%;padding-left:10px;"> '.$lang["INVOICES_NUMBER"].' : '.$invoiceNumber.' </div> <div style="padding: 0rem; vertical-align: middle;float:left;width:40%;text-align:left;padding-left:10%;"> '.$lang["WAREHOUSE_NUMBER"].' : '.$warehouseNumber.' </div> </div> <div> <div style="padding:0rem; vertical-align: middle;float:left;width:48%;padding-left:10px;"> '.$lang["WAREHOUSE_NAME"].' : '.$warehouseName.' </div> <div style="padding: 0rem; vertical-align: middle;float:left;width:40%;text-align:left;padding-left:10%;"> '.$lang["QUOTATION_VALUE"].' : '.$invoiceValue.' '.$currencyType.' </div> </div> <div> <div style="padding:0rem; vertical-align: middle;float:left;width:48%;padding-left:10px;"> '.$lang["CUSTOMER_NAME"].' : '.$customerName.' </div> <div style="padding: 0rem; vertical-align: middle;float:left;width:40%;text-align:left;padding-left:10%;"> '.$lang["DATE"].' : '.$modifiedDate.' </div> </div> <br> <table style="border-collapse: collapse; width:100%;border: 1px solid black;"> <tr> <td style="font-family:sans-serif; font-weight:600; font-size:14px; border: 1px solid black;" align="center"><strong>'.$lang["INVOICE_NUMBER"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px; border: 1px solid black;" align="center"><strong>'.$lang["DESCRIPTION"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px;border: 1px solid black;" align="center"><strong>'.$lang["QUOTATION_ID"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px;border: 1px solid black;" align="center"><strong>'.$lang["NUMBER_OF_PALLETS"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px; border: 1px solid black;" align="center"><strong>'.$lang["QUANTITY"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px; border: 1px solid black;" align="center"><strong>'.$lang["PRICE"].' ('.$currencyType.')</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px; border: 1px solid black;" align="center"><strong>'. $lang["TOTAL"].'</strong></td> </tr> <tr> '.$tableHTML.' </tr> </table> <br> <div style="align-items: baseline!important; justify-content: space-between!important;display: flex!important;box-sizing: border-box;text-align: right;" > <div> <label><strong>'.$lang["Grand_Total_value"].'</strong></label> <span><strong>'.$grandtotal.'</strong> </span> </div> </div> </div>'; //~ echo $template;exit; // Write some HTML code: $mpdf->WriteHTML($template); // $mpdf->SetDisplayMode('fullpage'); ob_end_clean(); // Output a PDF file directly to the browser // $mpdf->Output(); $res = $mpdf->Output('invoice.pdf','D'); ?>