D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
proc
/
thread-self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
print_invoice2.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 = ""; $invoice = ""; $date = ""; $terms = ""; $dueDate = ""; $itemName = ""; $price = ""; $quantity = ""; $tax = ""; $totalAmount = ""; $discountApplied = ""; $totalDiscount = ""; $totalTax = ""; $subTotal = ""; $amountPaid = ""; $dateCreation = ""; $companyName = ""; $address = ""; $city = ""; $state = ""; $pin = ""; $gstin = ""; $invoice = ""; $date = ""; $dueDate = ""; $itemName = ""; $price = ""; $quantity = ""; $tax = ""; $totalAmount = ""; $discountApplied = ""; $totalDiscount = ""; $totalTax = ""; $subTotal = ""; $amountPaid = ""; $dateCreation = ""; $billingCompanyName = ""; $billingCompanyLogo = ""; $billingCompanyPhone = ""; $billingCompanyEMail = ""; $billingCompanyAddress = ""; $billingCompanyCity = ""; $billingCompanyState = ""; $billingCompanyCountry = ""; $billingGSTIN = ""; $accountHolderName = ""; $accountNumber = ""; $bankName = ""; $ifsc = ""; $swift= ""; $invoice_note = ""; $color = ""; $currency = ""; $branch = ""; $logo = ""; $sign = ""; $country = ""; $gstTax = ""; $gstTax1 = ""; $billingAddress = ""; $checkPaidUnpaid = ""; $paidImage = ""; $dueDateAccToPaid = ""; $companyId = ''; $invoice_type = ""; $header = ""; if(isset($_GET["id"]) && $_GET["id"] != ""){ $id = $_GET["id"]; $sqlGetInvoice = " SELECT * FROM invoice_new a left join company_details b on a.company_id = b.id where a.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"]; $invoice_type = $rowGetInvoice["invoice_type"]; $companyName = $rowGetInvoice["company_name"]; $companyLogo = $rowGetInvoice["company_logo"]; $companySign = $rowGetInvoice["signature"]; $companyPhone = $rowGetInvoice["phone"]; $companyEmail = $rowGetInvoice["email"]; $companyAddress = $rowGetInvoice["address"]; $companyCity = $rowGetInvoice["city"]; $companyState = $rowGetInvoice["state"]; $companyCountry = $rowGetInvoice["country"]; $companygstin = $rowGetInvoice["GSTIN"]; $accountHolderName = $rowGetInvoice["account_name"]; $accountNumber = $rowGetInvoice["account_no"]; $bankName = $rowGetInvoice["bank_name"]; $ifsc = $rowGetInvoice["ifsc"]; $swift= $rowGetInvoice["swift"]; $color = $rowGetInvoice["company_color"]; $currency = $rowGetInvoice["currency"]; $branch = $rowGetInvoice["branch"]; $invoice_note = $rowGetInvoice["invoice_note"]; $billingCompanyName = $rowGetInvoice["billing_company_name"]; $billingCompanyAddress = $rowGetInvoice["billing_company_address"]; $billingCompanyPhone = $rowGetInvoice["billing_company_phone"]; $billingCompanyEMail = $rowGetInvoice["billing_company_email"]; $billingGSTIN = $rowGetInvoice["billing_company_gstin"]; $invoice = $rowGetInvoice["invoice"]; $date = $rowGetInvoice["date"]; $terms = $rowGetInvoice["terms"]; $dueDate = $rowGetInvoice["due_date"]; $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 style='font-weight:bold'>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 style='font-weight:bold'>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><strong style='font-weight:bold'>GSTIN : </strong><span>".$billingGSTIN."</span></div>"; } } else{ if(!empty($billingGSTIN)){ $gstTax = " <div><strong style='font-weight:bold'>Tax Number : </strong><span>".$billingGSTIN."</span></div>"; } } $company_gstin = substr($rowGetInvoice["GSTIN"], 0, 2); $client_gstin = substr($rowGetInvoice["billing_company_gstin"], 0, 2); $itemList = ""; $taxList = ""; $halfTax = number_format((float)$totalTax/2, 2, '.', ''); if(strtoupper($companyCountry) == strtoupper("India")){ if($company_gstin == $client_gstin){ $taxList = "<tr><th><strong style='font-weight:bold'>CGST</strong></th><td> : </td> <td style='text-align:right'> ".$halfTax."</td></tr><tr><th><strong style='font-weight:bold'>SGST</strong></th><td> : </td> <td style='text-align:right'> ".$halfTax."</td></tr>"; } else{ $taxList = "<tr><th><strong style='font-weight:bold'>IGST</strong></th><td> : </td> <td style='text-align:right'> ".$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><th><strong style='font-weight:bold'>".$rowGetTaxName["tax_name"]."</strong></th><td> : </td> <td style='text-align:right'> ".$totalTax."</td></tr>"; } } } } $invoiceId = explode(',', $id); $count = sizeof($invoiceId); for($i = 0; $i < $count; $i++){ $number = $i+1; $itemName = ""; $sac_hsn = ""; $price = ""; $itemquantity = ""; $itemtax = ""; $itemtotalamount= ""; $itemdis_app = ""; $invoice_id1 = $invoiceId[$i]; $sqlGetItemName = "SELECT * FROM invoice_items WHERE invoice_id = '$invoice_id1'"; $resultGetItemName = mysqli_query($conn, $sqlGetItemName); while($rowGetItemName = mysqli_fetch_array($resultGetItemName)){ $number1= $number++; $itemList .= "<tr data-iterate='item'> <td style='vertical-align:top'>".$number1."</td> <td>".$rowGetItemName['item_name']."</td> <td style='vertical-align:top'>".$rowGetItemName['hsn_sac_code']."</td> <td style='vertical-align:top'>".$rowGetItemName['quantity']."</td> <td style='vertical-align:top'>".$rowGetItemName['price']."</td> <td style='vertical-align:top'>".$rowGetItemName['discount_applied']."</td> <td style='vertical-align:top'>".$rowGetItemName['tax']."</td> <td style='vertical-align:top'>".$rowGetItemName['total_amount']."</td> </tr>"; } } if(empty($color) && $color == "#ffffff"){ $color = "#415472"; } $header = "TAX INVOICE"; $invoiceNumber = "Invoice Number"; $html = "<html lang='en'> <body> <div id='container'> <div 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 style='font-weight:bold'>Phone : </strong>".$companyPhone.",</span> <br> <span> <strong style='font-weight:bold'> Email : </strong>".$companyEmail." </span> <br> ".$companygstin." </div> <div class='logo' style='margin-top:10px;'> ".$logo." </div> </div> <section style='width:100%; margin-top:25px' > <div id='title' style='color:".$color."; text-align:center; width:100%;margin-bottom:25px; font-size:25px; font-weight:bold'>".$header."</div> <div style='float:left; width:60%'> <span><strong style='font-weight:bold'>Bill To:</strong></span> <div style='text-transform:uppercase; font-weight:bold; font-size:16px'> <span>".$billingCompanyName."</span> </div> <div style='width:99%;'> <div style='width:49%; float:left'> <div><span>".$billingCompanyAddress."</span></div> <span><strong style='font-weight:bold'>Phone : </strong>".$billingCompanyPhone."</span> ".$gstTax." </div> </div> </div> <div id='invoice-title-number'> <table width='100%'> <tr> <th style='text-align:left; width:45%; float:left'> <strong style='font-weight:bold'>".$invoiceNumber."</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 style='font-weight:bold'>Date</strong> </th> <th>:</th> <td style='text-align:right;width:54%; float:left'>".$date."</td> </tr> ".$dueDateAccToPaid." </table> ".$paidImage." </div> </section> <div style='width:100%; text-align:right'> <span>* All prices are in </span> <span>".$currency."</span> </div> <section id='items'> <table cellpadding='0' cellspacing='0'> <thead style='background-color:".$color.";color:#fff'> <tr> <th><strong>SL</strong></th> <th><strong>ITEM</strong></th> <th><strong>HSN/SAC</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> </thead> ".$itemList." </table> </section> <section id='sums' style='width:100%; margin-top:20px'> <div style='float:left; width:60%'> </div> <div style='float:left; width:40%'> <table> <tr> <th><strong style='font-weight:bold'>SUBTOTAL</strong></th> <td> : </td> <td style='text-align:right'>".$subTotal."</td> </tr> ".$taxList." </table> <div style='height:30px; padding: 10px; font-size:20px; text-align:center; color:#ffffff; background-color:".$color."; font-weight:bold'>".$currency." ".$amountPaid."</div> </div> </section> <div class='payment-info' style='margin-top:20px'> <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='text-align:right'> <div> <div> ".$sign." </div> <div> Authorised Signatory</div> </div> </td> </tr> </table> </div> <div style='text-align:center; margin-top:10px'>".$invoice_note."</div> </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('bootstrap.min.css'); $mpdf->WriteHTML($stylesheet, 1); $stylesheet1=file_get_contents('style1212.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"); } ?>