JezK
Edit File: customer_invoice_pdf.php
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ob_start(); 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['id'])) { header("Location: ./invoicedashboard.php"); } $id = $_REQUEST['id']; $adminid = $_SESSION['admin_id']; include("header.php"); // print_r($_SESSION);exit; $profile = $_SESSION['admin_profile_pic']; $invoiceInfo=$adminObj->getInvoiceInfo($id); // print_r($invoiceInfo);exit; $warehouseInfo=$adminObj->getAdmindata($adminid); // print_r($warehouseInfo);exit; // $itemDetails=$customerObj->getInvoicesItemsInfo($id); // $itemDetails=$invoiceInfo ? $invoiceInfo :[]; // $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(empty($invoiceInfo)) { $tableHTML ="<tr class='text-center'> <td colspan='7' ><p class='p-2'>No data avilable</p></td> </tr>"; } // print_r($invoiceInfo);exit; // foreach($invoiceInfo as $item) // { // print_r($item['quotation_id']);exit; $tableHTML .= '<tr> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$invoiceInfo['quotation_id'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$invoiceInfo['warehouse_id'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$invoiceInfo['warehouse_name'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$invoiceInfo['warehouse_email'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$invoiceInfo['grandtotal'].'</td> <td style="font-family:sans-serif; font-weight:300; font-size:13px; border: 1px solid black;" height="32" align="center">'.$invoiceInfo['currency'].'</td> </tr>'; // } $imagePath = "http://uflexit.krify.com/master_admin/uploads/superadmin_photos/"; $template = ' <table width="100%" style="font-family: sans-serif;" cellpadding="10"> <tr> <td width="100%" style="padding: 0px; text-align: center;"> <img src="'.$imagePath.''.$profile.'" 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;"> CUSTOMER 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>'.$warehouseInfo["name"].'</strong><br>'.$warehouseInfo["email"].'<br> </td> </tr> </table> <br> <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["QUOTATION_ID"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px; border: 1px solid black;" align="center"><strong>'.$lang["WAREHOUSE_ID"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px;border: 1px solid black;" align="center"><strong>'.$lang["WAREHOUSE_NAME"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px;border: 1px solid black;" align="center"><strong>'.$lang["EMAIL"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px; border: 1px solid black;" align="center"><strong>'.$lang["INVOICE_VALUE"].'</strong></td> <td style="font-family:sans-serif; font-weight:600; font-size:14px; border: 1px solid black;" align="center"><strong>'.$lang["CURRENCY"].'</strong></td> </tr> <tr> '.$tableHTML.' </tr> </table> <br>'; // 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'); ?>