D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
proc
/
self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
print_invoice_old.php
back
Copy
<?php require ('config.php'); $companyName = ""; $companyLogo = ""; $companySign = ""; $companyPhone = ""; $companyEmail = ""; $companyAddress = ""; $companyCity = ""; $companyState = ""; $companyCountry = ""; $companygstin = ""; $companyPin = ""; $accountHolderName = ""; $accountNumber = ""; $bankName = ""; $ifsc = ""; $swift= ""; $color = ""; $currency = ""; $branch = ""; $billingCompanyName = ""; $billingCompanyAddress = ""; $billingCompanyCity = ""; $billingCompanyState = ""; $billingCompanyPhone = ""; $billingCompanyEMail = ""; $billingCompanyPin = ""; $billingCompanyCountry = ""; $billingGSTIN = ""; $shippingCompanyAddress = ""; $shippingCompanyCity = ""; $shippingCompanyState = ""; $shippingCompanyPhone = ""; $shippingCompanyEMail = ""; $shippingCompanyPin = ""; $shippingCompanyCountry = ""; $shippingGSTIN = ""; $invoice = ""; $date = ""; $terms = ""; $dueDate = ""; $itemName = ""; $price = ""; $quantity = ""; $discountValueQty = ""; $tax = ""; $totalAmount = ""; $discountApplied = ""; $discountCategory = ""; $taxValue = ""; $totalDiscount = ""; $totalTax = ""; $subTotal = ""; $amountPaid = ""; $dateCreation = ""; $companyName = ""; $address = ""; $city = ""; $state = ""; $pin = ""; $gstin = ""; $invoice = ""; $date = ""; $dueDate = ""; $itemName = ""; $price = ""; $quantity = ""; $discountValueQty = ""; $tax = ""; $totalAmount = ""; $discountApplied = ""; $discountCategory = ""; $taxValue = ""; $totalDiscount = ""; $totalTax = ""; $subTotal = ""; $amountPaid = ""; $dateCreation = ""; $billingCompanyName = ""; $billingCompanyLogo = ""; $billingCompanyPhone = ""; $billingCompanyEMail = ""; $billingCompanyAddress = ""; $billingCompanyCity = ""; $billingCompanyState = ""; $billingCompanyCountry = ""; $billingGSTIN = ""; $accountHolderName = ""; $accountNumber = ""; $bankName = ""; $ifsc = ""; $swift= ""; $color = ""; $currency = ""; $branch = ""; $logo = ""; $sign = ""; $country = ""; $gstTax = ""; $gstTax1 = ""; $billingAddress = ""; $shipingAddress = ""; $checkPaidUnpaid = ""; $paidImage = ""; $dueDateAccToPaid = ""; if(isset($_GET["id"]) && $_GET["id"] != ""){ $id = $_GET["id"]; $sqlGetInvoice = "SELECT * FROM invoice WHERE id = '$id'"; $result = mysqli_query($conn, $sqlGetInvoice) or die(mysqli_error()); if($result){ if(mysqli_num_rows($result) > 0){ while($rowGetInvoice = mysqli_fetch_assoc($result)){ $companyName = $rowGetInvoice["company_name"]; $companyLogo = $rowGetInvoice["company_logo"]; $companySign = $rowGetInvoice["signature"]; $companyPhone = $rowGetInvoice["company_phone"]; $companyEmail = $rowGetInvoice["company_email"]; $companyAddress = $rowGetInvoice["company_address"]; $companyCity = $rowGetInvoice["company_city"]; $companyState = $rowGetInvoice["company_state"]; $companyCountry = $rowGetInvoice["company_country"]; $companygstin = $rowGetInvoice["company_gstin"]; $accountHolderName = $rowGetInvoice["company_account_name"]; $accountNumber = $rowGetInvoice["company_account_no"]; $bankName = $rowGetInvoice["company_bank_name"]; $ifsc = $rowGetInvoice["company_ifsc"]; $swift= $rowGetInvoice["company_swift"]; $color = $rowGetInvoice["company_color"]; $currency = $rowGetInvoice["company_currency"]; $branch = $rowGetInvoice["company_branch"]; $billingCompanyName = $rowGetInvoice["billing_company_name"]; $billingCompanyAddress = $rowGetInvoice["billing_company_address"]; $billingCompanyCity = $rowGetInvoice["billing_company_city"]; $billingCompanyState = $rowGetInvoice["billing_company_state"]; $billingCompanyPhone = $rowGetInvoice["billing_company_phone"]; $billingCompanyEMail = $rowGetInvoice["billing_company_email"]; $billingCompanyPin = $rowGetInvoice["billing_company_pin"]; $billingCompanyCountry = $rowGetInvoice["billing_comapny_country"]; $billingGSTIN = $rowGetInvoice["billing_company_gstin"]; $shippingCompanyAddress = $rowGetInvoice["shipping_company_address"]; $shippingCompanyCity = $rowGetInvoice["shipping_company_city"]; $shippingCompanyState = $rowGetInvoice["shipping_company_state"]; $shippingCompanyPhone = $rowGetInvoice["shipping_comapny_phone"]; $shippingCompanyEMail = $rowGetInvoice["shipping_comapny_email"]; $shippingCompanyPin = $rowGetInvoice["shipping_company_pin"]; $shippingCompanyCountry = $rowGetInvoice["shipping_comapny_country"]; $shippingGSTIN = $rowGetInvoice["shipping_company_gstin"]; $invoice = $rowGetInvoice["invoice"]; $date = $rowGetInvoice["date"]; $terms = $rowGetInvoice["terms"]; $dueDate = $rowGetInvoice["due_date"]; $itemName = $rowGetInvoice["item_name"]; $price = $rowGetInvoice["price"]; $quantity = $rowGetInvoice["quantity"]; $discountValueQty = $rowGetInvoice["discount_value_qty"]; $tax = $rowGetInvoice["tax"]; $totalAmount = $rowGetInvoice["total_amount"]; $discountApplied = $rowGetInvoice["discount_applied"]; $discountCategory = $rowGetInvoice["discount_category"]; $taxValue = $rowGetInvoice["tax_value"]; $totalDiscount = $rowGetInvoice["total_discount"]; $totalTax = $rowGetInvoice["total_tax"]; $subTotal = $rowGetInvoice["sub_total"]; $amountPaid = $rowGetInvoice["amount_paid"]; $dateCreation = $rowGetInvoice["date_creation"]; } if(!empty($companygstin)){ $companygstin = "<span><strong>GSTIN : </strong>".$companygstin."</span>"; } if($terms == "Paid"){ $paidImage = "<img src='images/paid.png' height='75px' style='margin-left:100px;'>"; } else{ $dueDateAccToPaid = "<tr><th style='text-align:left; width:50%; float:left'><strong>Due Date</strong></th><th>:</th><td style='text-align:right;width:50%; float:left'>".$dueDate."</td></tr>"; } if($companyLogo != ""){ $logo = "<img src='images/".$companyLogo."' style='max-height:100px;' />"; } if($companySign != ""){ $sign = "<img src='signature/".$companySign."' style='max-height:100px;max-width:150px;' />"; } if($billingCompanyCountry == "India"){ if(!empty($billingGSTIN)){ $gstTax = "<div><b>GSTIN : </b><span>".$billingGSTIN."</span></div>"; } } else{ if(!empty($billingGSTIN)){ $gstTax = " <div><b>Tax Number : </b><span>".$billingGSTIN."</span></div>"; } } if($shippingCompanyCountry == "India"){ if(!empty($shippingGSTIN)){ $gstTax1 = "<div><b>GSTIN : </b><span>".$shippingGSTIN."</span></div>"; } } else{ if(!empty($shippingGSTIN)){ $gstTax1 = " <div><b>Tax Number : </b><span>".$shippingGSTIN."</span></div>"; } } $item = explode(",", $itemName); $price1 = explode(",", $price); $quantity1 = explode(",", $quantity); $discountValueQty1 = explode(",", $discountValueQty); $tax1 = explode(",", $tax); $totalAmount1 = explode(",", $totalAmount); $discountApplied1 = explode(",", $discountApplied); $discountCategory1 = explode(",", $discountCategory); $taxValue1 = explode(",", $taxValue); $count = sizeof($item); $itemList = ""; $taxList = ""; $halfTax = number_format((float)$totalTax/2, 2, '.', ''); if(strtoupper($companyCountry) == strtoupper("India")){ if(strtoupper($billingCompanyState) == strtoupper($companyState)){ $taxList = "<tr data-iterate='tax'><th><strong>CGST </strong></th><td> : </td><td>".$halfTax."</td></tr><tr data-iterate='tax'><th><strong>SGST </strong></th><td> : </td><td>".$halfTax."</td></tr>"; } else{ $taxList = "<tr data-iterate='tax'><th><strong>IGST </strong></th><td> : </td><td>".$totalTax."</td></tr>"; } } else{ $sqlGetTaxName = "SELECT tax_name FROM tax_manager WHERE UPPER(country) = UPPER('$companyCountry')"; $resultGetTaxName = mysqli_query($conn, $sqlGetTaxName); if($resultGetTaxName){ if(mysqli_num_rows($resultGetTaxName) > 0){ while($rowGetTaxName = mysqli_fetch_assoc($resultGetTaxName)){ $taxList = "<tr data-iterate='tax'><th><strong>".$rowGetTaxName["tax_name"]." </strong></th><td> : </td><td>".$totalTax."</td></tr>"; } } } } for($i = 0; $i < $count; $i++){ $number = $i+1; $iid = $item[$i]; $iitemName = ""; $sqlGetItemName = "SELECT item_name FROM inventory_manager WHERE id = '$iid'"; $resultGetItemName = mysqli_query($conn, $sqlGetItemName); if($resultGetItemName){ while($rowGetItemName = mysqli_fetch_assoc($resultGetItemName)){ $iitemName = $rowGetItemName["item_name"]; } } $ttax = "-"; if($taxValue1[$i] != ""){ $ttax = $taxValue1[$i]."%"; } $itemList .= "<tr data-iterate='item'> <td >".$number."</td> <td>".$iitemName."</td> <td>".$quantity1[$i]."</td> <td>".$price1[$i]."</td> <td>".$discountValueQty1[$i]."</td> <td>".$ttax."</td> <td>".$totalAmount1[$i]."</td> </tr>"; } if(empty($color) && $color == "#ffffff"){ $color = "#415472"; } $html = "<html lang='en'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> </head> <body> <div id='container'> <div class='right-invoice' style='float:left'> <section id='memo' style='width:100%'> <div class='company-info' style='float:left; width:70%'> <div style='margin-top:10px'>".$companyName."</div> <span>".$companyAddress."</span> <br> <span>".$companyCity.", ".$companyState.", ".$companyCountry."</span> <br> <span><strong>Phone : </strong>".$companyPhone.", <strong> Email : </strong>".$companyEmail."</span> <br> ".$companygstin." </div> <div class='logo' style='margin-top:10px;'> ".$logo." </div> </section> <section id='invoice-title-number' style='width:40%; margin-top:15px'> <div id='title' style='background-color:".$color."'>INVOICE</div> </section> <section id='client-info' style='margin-top:-2px'> <span><b>Bill To:</b></span> <div class='client-name' style='text-transform:uppercase'> <span>".$billingCompanyName."</span> </div> <div style='width:99%;'> <div style='width:49%; float:left'> <span><b>Billing Address </b></span> <div><span> ".$billingCompanyAddress."</span></div> <div> <span>".$billingCompanyCity.", ".$billingCompanyState.", ".$billingCompanyCountry."</span></div> <div> <span>PIN - ".$billingCompanyPin." </span></div> <span><strong>Phone : </strong>".$billingCompanyPhone."</span> ".$gstTax." </div> <div style='width:50%; float:left'> <span><b>Shipping Address</b></span> <div><span> ".$shippingCompanyAddress."</span></div> <div> <span>".$shippingCompanyCity.", ".$shippingCompanyState.", ".$shippingCompanyCountry."</span></div> <div> <span>PIN - ".$shippingCompanyPin." </span></div> <span><strong>Phone : </strong>".$shippingCompanyPhone."</span> ".$gstTax1." </div> </div> </section> <section id='invoice-info' style='margin-top:60px'> <div style='width:100%;'> <table cellpadding='0' cellspacing='0'> <tr> <th style='text-align:left; width:45%; float:left'><strong>Invoice Number</strong></th> <th>:</th> <td style='text-align:right;width:54%; float:left'>".$invoice."</td> </tr> <tr> <th style='text-align:left; width:45%; float:left'><strong>Invoice Date</strong></th> <th>:</th> <td style='text-align:right;width:54%; float:left'>".$date."</td> </tr> ".$dueDateAccToPaid." </table> ".$paidImage." </div> </section> <div class='clearfix'></div> <div class='currency' style='margin-top:-10px'> <span>* All prices are in </span> <span>".$currency."</span> </div> <section id='items'> <table cellpadding='0' cellspacing='0'> <tr> <th><strong>SL</strong></th> <th><strong>ITEM</strong></th> <th><strong>QTY</strong></th> <th><strong>PRICE</strong></th> <th><strong>DISCOUNT</strong></th> <th><strong>TAX</strong></th> <th><strong>TOTAL</strong></th> </tr> ".$itemList." </table> </section> <section id='sums'> <table cellpadding='0' cellspacing='0'> <tr> <th><strong>SUBTOTAL</strong></th> <td> : </td> <td>".$subTotal."</td> </tr> ".$taxList." </table> <div style='height:30px; padding-top: 10px; font-size:20px; text-align:center; color:#ffffff; background-color:".$color."'>".$currency." ".$amountPaid."</div> </section> <div class='clearfix'></div> <div class='payment-info'> <table width='100%'> <tr> <td width='78%'> <div><b>Account Details</b></div> <table> <tr> <th>Bank Name</th> <th> : </th> <td>".$bankName."</td> </tr> <tr> <th>A/C Name</th> <th> : </th> <td>".$accountHolderName."</td> </tr> <tr> <th>A/C Number</th> <th> : </th> <td>".$accountNumber."</td> </tr> <tr> <th>IFSC</th> <th> : </th> <td>".$ifsc."</td> </tr> <tr> <th>Branch</th> <th> : </th> <td>".$branch."</td> </tr> <tr> <th>SWIFT</th> <th> : </th> <td>".$swift."</td> </tr> </table> </td> <td width='20%' style=''> <div> <div> ".$sign." </div> <div><b> Authorised Signatory</b></div> </div> </td> </tr> </table> </div> </div> <div style='text-align:center'>Thank you for doing business with us!</div> </div> </body> </html> "; require ("mpdf/mpdf.php"); $name = str_replace("#","",$invoice); //$mpdf = new mPDF('c', 'A4', '', '', 0, 0, 0, 0, 0, 0); $mpdf = new mPDF('A4'); $mpdf->allow_charset_conversion = true; $stylesheet = file_get_contents('assets/css/template.css'); $mpdf->WriteHTML($stylesheet,1); $mpdf->showImageErrors = true; $mpdf->SetDisplayMode('fullpage'); $mpdf->WriteHTML($html); // error_reporting(E_ALL); ob_clean(); ob_end_clean(); $mpdf->Output($name."_".date("YmdHms").".pdf","D"); // $mpdf->Output(); exit; } } else{ die("Sorry! Invoice not found"); } } else{ die("Sorry! Invoice id not found"); }