FPDF xCRUD 1.7.25 Default theme
FPDF Integrated with xCRUD
HIDE CODE
<?php require_once(dirname(__file__) . '/../../xcrud/plugins_php/TCPDF-main/tcpdf.php'); //$app_name = "xCrud_1.7.25.1"; //$app_name = $_SERVER["DOCUMENT_ROOT"]; // Get the full path of the current PHP file $currentFile = $_SERVER["SCRIPT_FILENAME"]; // Get the document root directory $documentRoot = $_SERVER["DOCUMENT_ROOT"]; // Calculate the directory path relative to the document root $relativePath = substr($currentFile, strlen($documentRoot)); // Remove leading and trailing slashes (if any) $relativePath = trim($relativePath, '/\\'); // Split the path into an array $pathParts = explode('/', $relativePath); // The immediate parent directory (which is 'app' in your case) $parentDir = $pathParts[0]; // Output the parent directory //echo $parentDir; $app_name = $parentDir; //die(); //============================================================+ // File name : example_001.php // Begin : 2008-03-04 // Last Update : 2013-05-14 // // Description : Example 001 for TCPDF class // Default Header and Footer // // Author: xcrud.net //USD // (c) Copyright: // xCRUD //============================================================+ /** * Creates an example PDF TEST document using TCPDF * @package com.tecnick.tcpdf * @abstract TCPDF - Example: Default Header and Footer * @author Nicola Asuni * @since 2008-03-04 */ // Include the main TCPDF library (search for installation path). $db = Xcrud_db::get_instance(); // $qry = "SELECT c.client_name,atr.ref_id,atr.due_date, atr.description AS header_description,atr.transaction_date,atl.price,p.description,atl.product_description,atl.quantity,atl.sub_total_amount,atl.total_amount,atl.vat FROM acc_transactions atr // JOIN acc_transactions_line atl ON atr.acc_transactions_id = atl.acc_transactions_id // JOIN clients c ON c.clients_id = atr.bill_to // JOIN product p ON p.product_id = atl.product_id WHERE atr.acc_transactions_id = " . $acc_transactions_id; // error_log($qry); // $db->query($qry); // $bill_list = $db->result(); // Dummy data for testing purposes $dummy_data = array( array( "header_description" => "Header description 1", "client_name" => "Client 1", "due_date" => "2024-02-22", "ref_id" => "REF001", "transaction_date" => "2024-02-22", // Add other fields as needed ), array( "header_description" => "Header description 2", "client_name" => "Client 2", "due_date" => "2024-02-23", "ref_id" => "REF002", "transaction_date" => "2024-02-23", // Add other fields as needed ) ); // You can uncomment the above section and comment out the dummy data section above when using real data // ... // Construct the dynamic file path based on the current URL $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; $host = $_SERVER['HTTP_HOST']; $http_file_access = $protocol . "://" . $host . "/xCrud_1.7.24/pdf/proforma_invoice.pdf"; echo "<br><br>"; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Techbase Solutions'); $pdf->SetTitle('Invoice'); $pdf->SetSubject('Proforma Invoice'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, '', '', array(0,64,255), array(0,64,128)); $pdf->setFooterData(array(0,64,0), array(0,64,128)); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('dejavusans', '', 14, '', true); // Add a page $pdf->AddPage(); $db = Xcrud_db::get_instance(); $query = 'SELECT * from orderdetails limit 10'; $db->query($query); $result = $db->result(); $count = count($result); $sort = array(); $rows = ""; foreach ($result as $key => $item) { $productCode = $item['productCode']; $orderNumber = $item['orderNumber']; $quantityOrdered = $item['quantityOrdered']; $priceEach = $item['priceEach']; $orderLineNumber = $item['orderLineNumber']; $total = $item['total']; $rows .= '<tr style="background-color:#e1e1e1;"> <td style="width:5%">#</td> <td style="width:15%">' . $orderLineNumber . '</td> <td style="width:27%">' . $productCode . '</td> <td style="width:7%">' . $quantityOrdered . '</td> <td style="width:13%">' . $priceEach .'</td> <td style="width:17%">' . $total . '</td> <td style="width:16%">' . $total . '</td> </tr>'; } $html = <<<EOD <h1 style="text-align:center;">Invoice</h1> <table style="font-size:11px;padding:5px;border:1px solid #e5e5e5;width:100%"> <tr> <td style="width:10%;">Bill to</td> <td style="width:30%;">John Doe</td> <td style="width:15%;"></td> <td style="width:20%;">Invoice Number</td> <td style="width:25%;">INV123456</td> </tr> <tr> <td style="width:10%;"></td> <td style="width:30%;"></td> <td style="width:15%;"></td> <td style="width:20%;">Invoice Date</td> <td style="width:25%;">2024-02-22</td> </tr> <tr> <td style="width:10%;"></td> <td style="width:30%;"></td> <td style="width:15%;"></td> <td style="width:20%;">Due Date</td> <td style="width:25%;">2024-02-28</td> </tr> </table> <br> <br> <table style="font-size:11px;padding:5px;border:1px solid #e5e5e5;width:100%;"> <tr style="background-color:#e1e1e1;"> <td style="width:5%">#</td> <td style="width:15%">Order Line Number</td> <td style="width:27%">Description</td> <td style="width:7%">Qty</td> <td style="width:13%">Price (KES)</td> <td style="width:17%">Amount (KES)</td> <td style="width:16%">Total Amount</td> </tr> $rows </table> <br> <br> <br> <table style="font-size:11px;padding:5px;border:1px solid #e5e5e5;width:100%"> <tr> <td style="width:50%;">Notes</td> <td style="width:20%;"></td> </tr> <tr> <td style="width:50%;">This is a sample invoice.</td> <td style="width:20%;"></td> </tr> </table> EOD; // Print text using writeHTMLCell() $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // --------------------------------------------------------- // Close and output PDF document $file_name = $_SERVER['DOCUMENT_ROOT'] . "/$app_name/pdf/" . "proforma_invoice.pdf"; $pdf->Output($file_name, 'F'); // --------------------------------------------------------- $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; // Get the current domain $host = $_SERVER['HTTP_HOST']; // Construct the dynamic file path $http_file_access = $protocol . "://" . $host . "/$app_name/pdf/proforma_invoice.pdf"; // Output the PDF file in the browser echo '<embed src="' . $http_file_access . '" width="800px" height="2100px" />'; //============================================================+ // END OF FILE //============================================================ ?>
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159
Warning: Undefined array key "total" in /var/www/html/xcrud/demo/xcrud_1_7/demos/pages/REPORT_invoice.php on line 159