D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
print_invoice_2.php
back
Copy
<?php require ('config.php'); $companyName=""; $companyLogo=""; $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=""; $country=""; $gstTax=""; $gstTax1=""; $billingAddress=""; $shipingAddress=""; $checkPaidUnpaid = ""; $dueDatePaidUnpaid = ""; $companyId = ''; if(isset($_GET["id"]) && $_GET["id"] !="") { $id=$_GET["id"]; $sqlGetInvoice=" SELECT * FROM invoice_new a LEFT JOIN invoice_items b ON b.invoice_id = a.id LEFT JOIN company_details c ON c.id = a.company_id WHERE a.company_id = '$source_id' AND (a.id = '$id' OR b.invoice_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)) { $companyId = $rowGetInvoice["company_id"]; $companyName=$rowGetInvoice["company_name"]; $companyLogo=$rowGetInvoice["company_logo"]; $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($terms == "Paid"){ $checkPaidUnpaid = "<tr class='clr-bdr'><td>Paid Amount</td><td>:</td><td style='text-align:right'><b>".$currency." ".$amountPaid."</b></td></tr>"; $dueDatePaidUnpaid = "<img src='images/paid.png' height='75px'>"; } else{ $checkPaidUnpaid = "<tr class='sm-bdr t-head'> <td><b>Amount Due</b></td><td>:</td> <td style='text-align:right'><b>".$currency." ".$amountPaid."</b></td> </tr>"; $dueDatePaidUnpaid = $dueDate; } if($companyLogo !="") { $logo="<img src='images/".$companyLogo."' style='max-height:100px;' />"; } if($billingCompanyCountry=="India") { $gstTax="GSTIN : ".$billingGSTIN; } else { $gstTax="Tax Number : ".$billingGSTIN; } if($billingCompanyCountry=="India") { $gstTax1="GSTIN : ".$shippingGSTIN; } else { $gstTax1="Tax Number : ".$shippingGSTIN; } $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><th>:</th><td style='text-align:right'>".$currency." ".$halfTax."</td></tr><tr data-iterate='tax'><th><strong>SGST</strong></th><th>:</th><td style='text-align:right'>".$currency." ".$halfTax."</td></tr>"; } else { $taxList="<tr data-iterate='tax'><th><strong>IGST</strong></th><th>:</th><td style='text-align:right'>".$currency." ".$totalTax."</td></tr>"; } } else { $sqlGetTaxName="SELECT tax_name FROM tax_manager WHERE UPPER(country) = UPPER('$companyCountry') AND source_id = '$companyId'"; $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><th>:</th><td style='text-align:right'>".$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 style='text-align:left'>".$number."</td> <td style='text-align:left'>".$iitemName."</td> <td>".$quantity1[$i]."</td> <td>".$price1[$i]."</td> <td>".$discountValueQty1[$i]."</td> <td>".$ttax."</td> <td style='text-align:right;padding-right:25px'>".$totalAmount1[$i]."</td> </tr>"; } if(empty($color) && $color=="#ffffff") { $color="#415472"; } $html="<!DOCTYPE html> <html lang='en'> <body> <section class='invoice-page'> <div class='container-fluid'> <div class='row'> <div class='col-md-7 bdr-rt'> <div class='left-bar'> <h1 class='main-head'>Invoice</h1> <div class='t-head gray'> <div class='float-left col-md-5'>".$invoice."</div> <div class='float-right'>".$date."</div> </div> <table class='table text-center top-table'> <thead> <tr class='text-center gray'> <th class='text-center'>Total:</th> <th class='text-center'>Net:</th> <th class='text-center'>Due Date:</th> <th class='text-center no-bordr'>P.O.#</th> </tr> </thead> <tbody> <tr> <td>".$currency." ".$amountPaid."</td> <td>25</td> <td>".$dueDatePaidUnpaid."</td> <td class='no-bordr'>1/3-147</td> </tr> </tbody> </table> </div> </div> <div class='col-md-5'> <div class='right-bar' > <h4 class='dark'>".$companyName."</h4> <ul class='list-unstyled'> <li>".$companyAddress."</li> <li>".$companyCity.", ".$companyState.", ".$companyCountry."</li> <li>Phone: ".$companyPhone."</li> <li>".$companyEmail."</li> <li>GSTIN:".$companygstin."</li> </ul> </div> </div> </div> <div class='bdr-btm'></div> <div class='row'> <div class='col-md-12'> <div style='width:100%;'> <b class='gray pad-tp30'>Bill To:</b><br> <b style='text-transform:uppercase; font-size:20px'>".$billingCompanyName."</b><br> <div style='width:50%; float:left'> <b class='gray pad-tp30'>Billing Address :</b> <div style='padding-right:15px;'><span>".$billingCompanyAddress."</span></div> <div style='padding-right:15px;'><span>".$billingCompanyCity.", ".$billingCompanyState.", ".$billingCompanyCountry."</span></div> <div style='padding-right:15px;'><span>PIN - ".$billingCompanyPin." </span></div> <div style='padding-right:15px;'><span><strong>Phone: </strong>".$billingCompanyPhone."</span></div> </div> <div style='width:50%; float:left'> <b class='gray pad-tp30'>Shipping Address :</b> <div style='padding-right:15px;'><span>".$shippingCompanyAddress."</span></div> <div style='padding-right:15px;'><span>".$shippingCompanyCity.", ".$shippingCompanyState.", ".$shippingCompanyCountry."</span></div> <div style='padding-right:15px;'><span>PIN - ".$shippingCompanyPin." </span></div> <div style='padding-right:15px;'><span><strong>Phone: </strong>".$shippingCompanyPhone."</span></div> </div> </div> </div> </div> <table class='table l-table mr-btm10 w790' style='margin-top:20px'> <thead> <tr class='bgdark'> <th>SN</th> <th style='text-align:left'>ITEM</th> <th>QTY</th> <th>PRICE</th> <th>DISCOUNT</th> <th>TAX</th> <th>TOTAL</th> </tr> </thead> <tbody class=''> ".$itemList." </tbody> </table> <div class='col-md-6 float-right'> <table class='table r-table w400'> <tr> <td class='bdr0'>Subtotal </td> <td class='bdr0'>:</td> <td class='bdr0' style='text-align:right'>".$currency." ".$subTotal."</td> </tr> ".$taxList." <tr> <td><b>Total</b> </td> <td> :</td> <td style='text-align:right'><b>".$currency." ".$amountPaid."</b></td> </tr> ".$checkPaidUnpaid." </table> </div> </div><br> <div class='clearfix'></div> <footer> <div class='container-fluid gray'> <p>Payment Details:</p> <div class='row'> <div class='col-md-7'> <ul class='list-unstyled list-inline float-left'> <li>Name: ".$accountHolderName.", Bank: ".$bankName.", Branch: ".$branch."</li> <li>ACC: ".$accountNumber.", IFSC: ".$ifsc.", Swift: ".$swift."</li> </ul> </div> <div class=' text-right col-md-5'> Currency: ".$currency." </div> </div> <div class='terms pad-tp30 pad-btm80'> <h4>Terms and Notes</h4> <p>John, Thank you very much. we really appreciate your business. Please send payments before due date. </p> </div> </div> </footer> </div> </section> </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('bootstrap.min.css'); $mpdf->WriteHTML($stylesheet, 1); $stylesheet1=file_get_contents('style.css'); $mpdf->WriteHTML($stylesheet1, 1); $mpdf->showImageErrors=true; $mpdf->SetDisplayMode('fullpage'); $mpdf->WriteHTML($html); // error_reporting(E_ALL); // ob_end_clean(); 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"); } ?>