D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
print_invoice.php
back
Copy
<?php require ('config.php'); $companyName = ""; $companyLogo = ""; $companySign = ""; $companyPhone = ""; $companyEmail = ""; $companyAddress = ""; $companyCity = ""; $companyState = ""; $companyCountry = ""; $companygstin = ""; $companyPin = ""; $accountHolderName = ""; $accountNumber = ""; $bankName = ""; $ifsc = ""; $shift= ""; $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 = ""; $shift= ""; $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 proforma 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)){ $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"]; $shift= $rowGetInvoice["shift"]; $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 = date("d/m/Y", strtotime($rowGetInvoice["date"])); $terms = $rowGetInvoice["terms"]; $dueDate = date("d/m/Y", strtotime($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>GSTIN :".$companygstin."</span>"; } if($terms == "Paid"){ $paidImage = "<img src='images/paid.png' height='75px' style='margin-left:100px;'>"; } else{ $dueDateAccToPaid = "<tr><th style='text-align:right; width:50%; float:right;font-weight:normal;'>Due Date : ".$dueDate."</th></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 = ""; $totalitem = ""; $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:normal'>CGST @</strong></th> <td></td><td style='text-align:right'> ".$currency." ".$halfTax."</td></tr><tr><th><strong style='font-weight:normal'>SGST @</strong></th> <td></td><td style='text-align:right'> ".$currency." ".$halfTax."</td></tr>"; } else{ $taxList = "<tr><th><strong style='font-weight:normal'>IGST @</strong></th><td></td> <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><th style='font-weight:normal;'>".$rowGetTaxName["tax_name"]."</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]; $sum =""; $qty =""; $sqlGetItemName = "SELECT * FROM invoice_items WHERE invoice_id = '$invoice_id1'"; $resultGetItemName = mysqli_query($conn, $sqlGetItemName); while($rowGetItemName = mysqli_fetch_array($resultGetItemName)){ $number1= $number++; $qty += $rowGetItemName["quantity"] ; $sum += $rowGetItemName["price"] ; $itemList .= "<tr data-iterate='item'> <td style='vertical-align:top;border-bottom:none;'>".$number1."</td> <td style='vertical-align:top;border-bottom:none;'>".$rowGetItemName['item_name']."</td> <td style='vertical-align:top;border-bottom:none;'>".$rowGetItemName['hsn_sac_code']."</td> <td style='vertical-align:top;border-bottom:none;'>".$rowGetItemName['quantity']."</td> <td style='vertical-align:top;border-bottom:none;'></td> <td style='vertical-align:top;border-bottom:none;'>".$rowGetItemName['discount_applied']."</td> <td style='vertical-align:top;border-bottom:none;'>".$rowGetItemName['tax']."</td> <td style='vertical-align:top;border-bottom:none;'>".$rowGetItemName['price']."</td> </tr>"; } } $totalitem .= " <tr><td style='border-bottom:none;'></td></tr> <tr><td style='border-bottom:none;'></td></tr> <tr data-iterate='item' style='border-top:1px solid #dee2e6;'> <td style='vertical-align:top;border-top:1px solid #dee2e6;'></td> <td style='border-top:1px solid #dee2e6;'><b>TOTALS</b></td> <td style='vertical-align:top;border-top:1px solid #dee2e6;'></td> <td style='vertical-align:top;border-top:1px solid #dee2e6;'>".$qty."</td> <td style='vertical-align:top;border-top:1px solid #dee2e6;'></td> <td style='vertical-align:top;border-top:1px solid #dee2e6;'>".$totalDiscount."</td> <td style='vertical-align:top;border-top:1px solid #dee2e6;'>".$totalTax."</td> <td style='vertical-align:top;border-top:1px solid #dee2e6;'>".$sum."</td> </tr>"; if(empty($color) && $color == "#ffffff"){ $color = "#ff962d"; } $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'><h4 style='font-weight:normal;'>".$companyName."</h4></div> <span>".$companyAddress.",".$companyCity."</span> <br> <span>Phone : ".$companyPhone.",</span> <br> ".$companygstin." <br> <span> State : ".$companyState." </span> </div> <div class='logo' style='margin-top:10px;text-align:right; float:right;'> ".$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:normal'>Bill To:</strong></span> <div style='text-transform:capitalize; font-weight:normal; '> <span>".$billingCompanyName."</span> </div> <div style='width:99%;'> <div style='width:49%; float:left'> <div><span style='text-transform:capitalize;'>".$billingCompanyAddress."</span></div> <div> <span>Phone : ".$billingCompanyPhone."</span></div> <div> <span>Email : ".$billingCompanyEMail."</span></div> </div> </div> </div> <div id='invoice-title-number'> <table width='100%'> <tr> <th style='text-align:right; width:45%; float:right;font-weight:normal;'>Invoice Number : ".$invoice." </th> </tr> <tr> <th style='text-align:right; width:45%; float:right;font-weight:normal;'> Date : ".$date." </th> </tr> ".$dueDateAccToPaid." </table> ".$paidImage." </div> </section> </div> <section id='items' style='width:100%;margin-left:0px; margin-right:0px;'> <table cellpadding='0' cellspacing='0' style='width:100%;margin-left:0px; margin-right:0px;'> <thead> <tr style='background:".$color.";color:#fff;'> <th>#</th> <th>ITEM NAME</th> <th>HSN/SAC</th> <th>QTY</th> <th>RATE</th> <th>DISCOUNT</th> <th>GST</th> <th>AMOUNT</th> </tr> </thead> ".$itemList." ".$totalitem." </table> </section> <div id='container' style='margin-top:0px; padding-top:0px'> <section id='sums' style='width:100%; margin-top:20px'> <div style='float:left; width:60%'> <div style='float:left; width:60%'><p style='margin-bottom:0px;'> DESCRIPTION </p></div> <div style='float:left; background-color:#dee2e673; margin-bottom:10px; width:60%;'><p > Sample Description <br><br></p></div> <div style='float:left; width:60%'><p style='margin-bottom:0px;'> Terms & Conditions </p></div> <div style='float:left; background-color:#dee2e673;width:60%;'><p> Sample terms & conditions <br><br></p></div> </div> <div style='float:left; width:40%'> <table> <tr> <th style='font-weight:normal;'>SUBTOTAL</th> <td></td> <td style='text-align:right'> ".$currency." ".$subTotal."</td> </tr> <tr> <th style='font-weight:normal;'>Discount</th> <td></td> <td style='text-align:right'> ".$currency." ".$totalDiscount."</td> </tr> ".$taxList." <tr style='background-color:".$color.";color:#fff;margin-top:8px;margin-bottom:8px;'> <th style='font-weight:normal;'>TOTAL</th> <td></td> <td style='text-align:right'> ".$currency." ".$amountPaid."</td> </tr> <tr> <th style='font-weight:normal;'>BALANCE DUE</th> <td></td> <td style='text-align:right'></td> </tr> <tr> <th style='font-weight:normal;'>Payment mode</th> <td></td> <td style='text-align:right'>Cash</td> </tr> </table> </div> </section> <div class='payment-info' style='margin-top:20px'> <table width='100%'> <tr> <td width='78%'> <table> <tr> <th style='font-weight:normal;'>Pay to - ".$bankName."</th> </tr> <tr> <th style='font-weight:normal;'>Account Name : ".$accountHolderName."</th> </tr> <tr> <th style='font-weight:normal;'>Account No : ".$accountNumber."</th> </tr> <tr> <th style='font-weight:normal;'>IFSC Code : ".$ifsc."</th> </tr> </table> </td> <td width='20%' style='text-align:right'> <div> <div> <strong style='color:".$color."; font-size:14px;'>For , ".$companyName."</strong> </div> <div style='margin-top:10px;'><span style='text-transform:uppercase;'> Authorised Signatory</span></div> </div> </td> </tr> </table> </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); $pdf = new mPDF('','Letter', 0, '', 15, 15, 16, 16, 9, 9, ''); $pdf->debug = true; $pdf->showImageErrors = true; $pdf->WriteHTML($html_utf8); // this is identical on both pages $pdf->WriteFixedPosHTML($img, 17, 17, 50, 50); $pdf->Output(); // $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"); } ?>