";; if(!isset($_SESSION)){ session_start();} //session_start(); // include '../include/auth.php'; //include '../include/db_connect.php'; require "../config/dbc_accopack0.php"; require "../config/dbci_accopack0.php"; require "../config/pgparam.php"; date_default_timezone_set("Asia/Kolkata"); $tblprfx=$_SESSION['tblprfx']; //sprintf("%01.2f", $money); //$dt2=date("Y-m-d",strtotime("+1 month -1 day",strtotime($dt1))); //SELECT `item_id`, COUNT(*) AS `imei_cnt` FROM `satya_sathya20172018_scan_det` GROUP BY `item_id` HAVING `imei_cnt` > 1 $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname); if ($mysqli->connect_errno){ $err = "CONNECT FAIL: ". $mysqli->connect_errno.' '.$mysqli->connect_error; $err_cnt++; } include 'Numbers/Words.php'; //error_reporting(E_ERROR | E_PARSE); $ir=""; //$ir="(Rs)"; // echo "tbl prfx : ".$tblprfx." ($inv_no_ent pp)
"; $ht_px=25; $ht15=15; $td_l=" style='border-left:1px solid #000000;'"; $td_lb=" style='border-left:1px solid #000000; border-bottom: 1px solid #000000; '"; $td_r=" style=' border-right:1px solid #000000; '"; $td_lr= " style=' border-left:1px solid #000000; border-right:1px solid #000000; '"; $td_rb=" style=' border-right:1px solid #000000; border-bottom: 1px solid #000000; '"; $td_lrb= " style=' border-left:1px solid #000000; border-right:1px solid #000000; border-bottom: 1px solid #000000; '"; $td_lrtb= " style=' border-left:1px solid #000000; border-right:1px solid #000000; border-bottom: 1px solid #000000; border-top: 1px solid #000000; '"; $td_lt= " style=' border-left:1px solid #000000; border-top: 1px solid #000000; '"; $td_rtb= " style=' border-right:1px solid #000000; border-bottom: 1px solid #000000; border-top: 1px solid #000000; '"; $td_rt= " style=' border-right:1px solid #000000; border-top: 1px solid #000000; '"; $td_tb= " style=' border-bottom: 1px solid #000000; border-top: 1px solid #000000; '"; $td_b=" style=' border-bottom: 1px solid #000000; '"; $td_t=" style=' border-top: 1px solid #000000; '"; $td_ltb= " style=' border-left:1px solid #000000; border-bottom: 1px solid #000000; border-top: 1px solid #000000; '"; /* if(!$inv_no_ent){ $inv_no=$_REQUEST['inv_no']; $top_copy=$_REQUEST['top_copy']; }else{ $inv_no=$inv_no_ent; } */ $inv_id=$_REQUEST['inv_id']; $top_copy=$_REQUEST['top_copy']; $co_name=$_SESSION['co_name']; $co_add1=$_SESSION['co_add']; $co_add2=$_SESSION['co_address2']; $co_add3=$_SESSION['co_address3']; $co_gstin=$_SESSION['co_gstin']; $co_tin=$_SESSION['co_tin']; $co_cst=$_SESSION['co_cst']; $co_cst_dt=$_SESSION['co_cst_dt']; $co_ph=$_SESSION['co_phone']; $co_em=$_SESSION['co_email']; $co_web=$_SESSION['co_web']; #$inv_no=125; include "../include/convert_date2display.php"; $gst_imple_date="2017-07-01"; $scm_op=""; //============================================================+ // File name : example_048.php // Begin : 2009-03-20 // Last Update : 2010-08-08 // // Description : Example 048 for TCPDF class // HTML tables and table headers // // Author: Nicola Asuni // // (c) Copyright: // Nicola Asuni // Tecnick.com LTD // Manor Coach House, Church Hill // Aldershot, Hants, GU12 4RQ // UK // www.tecnick.com // info@tecnick.com //============================================================+ /** * Creates an example PDF TEST document using TCPDF * @package com.tecnick.tcpdf * @abstract TCPDF - Example: HTML tables and table headers * @author Nicola Asuni * @since 2009-03-20 */ $old_limit = ini_set("memory_limit", "512M"); require_once('../include/tcpdf/config/lang/eng.php'); require_once('../include/tcpdf/tcpdf.php'); // 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('Accopack'); $pdf->SetTitle("Invoice No $inv_no"); $pdf->SetSubject('Invoice Generated by Accopack'); $pdf->SetKeywords('Invoice, Accopack'); // set default header data //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.'048', PDF_HEADER_STRING); // remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // 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->SetTopMargin(15); $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 $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font //$pdf->SetFont('helvetica', 'B', 20); // add a page //$pdf->AddPage(); //$pdf->Write(0, 'Example of HTML tables', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFont('helvetica', '', 10); // ----------------------------------------------------------------------------- $pg_open=""; $msg.= " "; $msg.=""; $vr100="
"; $ginvmast=$mysqli->query("SELECT * FROM `".$tblprfx."inv_mast` WHERE `inv_id`='$inv_id'"); if(!$ginvmast){echo "$bodystr Invoice details not found for $inv_no. Possible reasons : ".$mysqli->error; exit;} //else{ echo "here ".mysql_num_rows($ginvmast);} //if(mysql_num_rows($ginvmast)==0){echo "$bodystr Invoice no $inv_no not found."; exit; } #echo ""; // echo "$bodystr"; while($ginvmastr=$ginvmast->fetch_array()){ $inv_id =$ginvmastr["inv_id"]; $inv_no =$ginvmastr["inv_no"]; $loc_prefix =$ginvmastr["loc_prefix"]; $inv_date =$ginvmastr["inv_date"]; $inv_date_disp=dt_input2display($inv_date); $sale_amt =$ginvmastr["sale_amt"]; $tax_amt =$ginvmastr["tax_amt"]; //$tax_id =$ginvmastr["tax_id"]; $discount =$ginvmastr["discount"]; $fwd =$ginvmastr["fwd"]; //$roundoff =$ginvmastr["roundoff"]; $inv_amt =$ginvmastr["inv_amt"]; $account_id =$ginvmastr["account_id"]; $tranidhd =$ginvmastr["tranid"]; $bndl =$ginvmastr["bndl"]; $ship_to_id=$ginvmastr["ship_to_id"]; $inv_status=$ginvmastr["inv_status"]; } //echo "Invoice details of $inv_id
";exit; if(($loc_prefix=='*')||($loc_prefix==NULL)){$loc_prefix_disp="";}else{$loc_prefix_disp=$loc_prefix."-";} $invLen=strlen($inv_no); $inv_prfx=$loc_prefix_disp; if($invLen==1){$inv_prfx.="000";} if($invLen==2){$inv_prfx.="00";} if($invLen==3){$inv_prfx.="0";} if($inv_date>=$gst_imple_date){ if($co_gstin!=""){ $co_tin_disp=" "; $inv_tx_disp="TAX Invoice"; $inv_tx_disp2="TAX  "; }else{ $co_tin_disp=" "; $inv_tx_disp="Invoice"; $inv_tx_disp2=" "; } }else{ if($co_tin!=""){ $co_tin_disp=" "; $inv_tx_disp="TAX Invoice"; $inv_tx_disp2="TAX  "; }else{ $co_tin_disp=" "; $inv_tx_disp="Invoice"; $inv_tx_disp2=" "; } if($co_cst!=""){ $co_cst_disp=" "; }else{ } } if($co_ph!=""){ $co_ph_disp= " PHONE:$co_ph"; }else{ $co_ph_disp=""; } $co_dets="
$co_dets
  GSTIN : $co_gstin
TIN : $co_tin
CST No: $co_cst
CST Date : $co_cst_dt
$inv_tx_disp
$co_name
$co_add1
$co_tin_disp $co_cst_disp
$co_ph_disp
$co_web
$co_em
"; // $fk="";$fk_key_disp=""; // $fk_src_id=$_SESSION['lid']."_".$_SESSION['co_id']; // $fk=$mysqli->query("SELECT `fk_key` AS `fast_key` FROM `fast_key_mast` WHERE `fk_location`='_inv_mast' AND `fk_location_value`='$inv_id' AND `fk_src_id`='$fk_src_id' AND `fk_status`='generated'")->fetch_object()->fast_key; // if($fk!=""){$fk_key_disp="Fast Key : tsmma#$fk
";} // $scm_op.="Annexure for Invoice No : $loc_prefix_disp $inv_no dated $inv_date_disp
// $fk_key_disp
"; //$scm_op.="Annexure for Invoice No : $loc_prefix_disp $inv_no dated $inv_date_disp

"; $gam=$mysqli->query("SELECT * FROM `".$tblprfx."account_mast` WHERE `id`='$account_id' OR `id`='$tax_id'"); //echo "SELECT `fk_key` AS `fast_key` FROM `fast_key_mast` WHERE `fk_location`='$inv_id' AND `fk_src_id`='$fk_src_id' AND `fk_status`='generated'"; $z=0; while($gamr=$gam->fetch_array()) { $temp_id=$gamr["id"]; $temp_name= $gamr["account"]; if($temp_id==$tax_id){$tax_name=$temp_name;} if($temp_id==$account_id){ $account_name=$temp_name; $salut=$gamr["salut"]; $address1=$gamr["address1"]; $address2=$gamr["address2"]; $address3=$gamr["address3"]; $city=$gamr["city"]; $pin=$gamr["pin"]; $phone1=$gamr["phone1"]; $phone2=$gamr["phone2"]; $mob1=$gamr["mob1"]; $mob2=$gamr["mob2"]; $gstin=$gamr["gstin"]; $tin=$gamr["tin"]; $state=$gamr["state"]; $cst=$gamr["cst"]; $cst_dt=$gamr["cst_dt"]; if($cst_dt){$cst_dt_disp="dt.".$cst_dt;}else{$cst_dt_disp="";} $logistic=$gamr["logistic"]; $doc_thru=$gamr["doc_thru"]; $remarks=$gamr["remarks"]; } } $gst_type="interstate"; if((substr($gstin,0,2))==(substr(($_SESSION['co_gstin']),0,2))){ $gst_type="intrastate"; } $ht="height='$ht15 px'"; if($pin){$pin=" - ".$pin.".";}//else{$pin=".";} $sp1_o=""; $sp_c=""; $msg.=""; $bgcolor="silver"; if($salut==""){$salut="M/s / Mr / Ms .";} if($ship_to_id>0){ $rs221=$mysqli->query("SELECT * FROM `".$tblprfx."shipto_mast` WHERE `stm_id`='$ship_to_id'"); while($r327=$rs221->fetch_array()){ $stm_account=$r327['account_name']; $stm_l1=$r327['address_line1']; $stm_l2=$r327['address_line2']; $stm_l3=$r327['address_line3']; $stm_city=$r327['city']; $stm_pin=$r327['pin']; $stm_gstin=$r327['stm_gstin']; $stm_state=$r327['stm_state']; $stm_state_code=$r327['stm_state_code']; $shipto_details=" "; if($stm_l2!=""){ $shipto_details.=""; } if($stm_l3!=""){ $shipto_details.=""; } $shipto_details.="
$sp1_o| Ship to
|M/s. $stm_account $sp_c
$sp1_o|   $stm_l1 $sp_c
$sp1_o|   $stm_l2 $sp_c
$sp1_o|   $stm_l3 $sp_c
$sp1_o|   $stm_city-$stm_pin $sp_c
$sp1_o|   GSTIN : $stm_gstin $sp_c
$sp1_o|   State Code-State: $stm_state_code-$stm_state $sp_c
"; } $shipto_w=225; $shipto_tbl=" $shipto_details "; }else{ $shipto_tbl=""; $shipto_w=460; } $ac_det="$shipto_tbl "; $ph_disp=""; if($phone1) {$ph_disp="";} elseif(($phone1)&&($phone2)){ $ph_disp=""; } $ac_det.="$ph_disp
$sp1_o Billed To
  $salut $account_name $sp_c
$inv_tx_disp2 INVOICE
 $sp1_o $address1 $sp_c Invoice No: $inv_prfx$inv_no
 $sp1_o $address2 $address3 $sp_c  
 $sp1_o $city $pin $sp_c Date : $inv_date_disp
 $sp1_o State Code-State : $state $sp_c 
  
Phone: $phone1  
Phone: $phone1 $phone2 

"; // if($inv_date>=$gst_imple_date){ if((strtoupper(substr($gstin,2,3)))=='ZZZ'){$gstin_disp="Unregistered";}else{$gstin_disp=$gstin;} // $desp_det=" // // // // // // // // // //
 GSTIN: $gstin_dispGoods despatched ThroughDocuments through
".ucwords($logistic)."$doc_thru
"; $ac_det.="
 GSTIN : $gstin_disp
"; // }else{ // $desp_det=" // // // // // // // // // // //
TIN: $tinGoods despatched ThroughDocuments through
CST No: $cst $cst_dt_disp ".ucwords($logistic)."$doc_thru
"; // } $msg.=$ac_det." "; $msg.=""; $fnt="\"font-size:8pt;\""; $bill_bodyp=" SNo Particulars Quantity Rate
($ir) Amount
($ir)
Discount
($ir)
Nett Sales
(after Discount) ($ir)
Tax ($ir)
%
"; $sub_total=0; $scm_cnt=0; //$git=$mysqli->query("SELECT * FROM `".$tblprfx."sale_bk` WHERE `inv_no`=$inv_no"); $git=$mysqli->query("SELECT * FROM `".$tblprfx."sale_bk` WHERE `inv_id`='$inv_id'"); while($gitr=$git->fetch_array()){ $sale_bk_id=$gitr["id"]; $temp_item_id=$gitr["item_id"]; $temp_qty=($gitr["item_qty"])+0; $temp_rate=$gitr["item_rate"]; $temp_item_name1=$gitr["item_name"]; $tax_amt=$gitr["tax_amt"]; $tax_id=$gitr["tax_id"]; $tax_per=$gitr["tax_per"]; $discount_amt=$gitr["discount_amt"]; $gitdet=$mysqli->query("SELECT `item`,`unit`,`vat_code` FROM `".$tblprfx."item_mast` WHERE `item_id`=$temp_item_id"); while($gitdetr=$gitdet->fetch_array()){ if($temp_item_name1==""){ $temp_item_name=$gitdetr["item"]; }else{ $temp_item_name=$temp_item_name1; } $temp_item_unit=$gitdetr["unit"]; $vat_code=$gitdetr["vat_code"]; } if($inv_date>=$gst_imple_date){$vat_code_disp="
  HSN / SAC Code: $vat_code";}else{$vat_code_disp="";} $tt++; //$scm_op_line0="
$tt) $temp_item_name :- $temp_qty $temp_item_unit @ Rs. ".round($temp_rate+($temp_rate*$tax_per/100))." each"; $scm_op_line0="
$tt) $temp_item_name $temp_qty $temp_item_unit Rs. ".round($temp_rate+($temp_rate*$tax_per/100))."each
"; $scm_op_line1=""; $temp_line=sprintf('%01.2f',($temp_qty*$temp_rate)); $sub_total=$sub_total+$temp_line; if($tt==1){ $fwd_tax_amt= sprintf('%01.2f',($fwd_tax_amt=$fwd*$tax_per/100)); $tax_str=$mysqli->query("SELECT `tax_str` FROM `".$tblprfx."tax_link` WHERE `tax_ac`='$temp_tax_id'")->fetch_object()->tax_str; } $ald=sprintf('%01.2f',($temp_line-$discount_amt)); $tot_ald=$tot_ald+$ald; $tot_tax_amt=$tot_tax_amt+$tax_amt; $tot_discount=$tot_discount+$discount_amt; $fnt=""; $bill_bodyp.= " $tt $fnt  ".ucwords(strtolower($temp_item_name))."$vat_code_disp $fnt $temp_qty 
$fnt ".strtoupper($temp_item_unit)." $fnt $temp_rate   $fnt $temp_line   $fnt $discount_amt   $fnt $ald   $fnt $tax_amt  
($tax_per %)   "; // $scmd=$mysqli->query("SELECT `scm1` FROM `".$tblprfx."scan_mast` WHERE `sale_bk_id`='$sale_bk_id'"); // while($scmdr=$scmd->fetch_array()){ // $scm1=$scmdr["scm1"]; // $scm_op_line1.="   ".$scm1.","; // $scm_cnt++; // } // //$scm_op.=$scm_op_line0."
".$scm_op_line1."




"; // $scm_op.="$scm_op_line0
".rtrim($scm_op_line1,",")."




"; } $bal_row=10-$tt; $bal_height=$bal_row*($ht_px+2); $bill_bodyp.="             "; $tot_tax_amt=$tot_tax_amt+$fwd_tax_amt; $sub_total4=$sub_total-$tot_discount+$fwd+$tot_tax_amt; $roundoff=$inv_amt-$sub_total4; $inv_total_word=$ret=Numbers_Words::toWords($inv_amt,"en_GB"); $inv_total_word=strtoupper($inv_total_word); $inv_total_word='  RUPEES '.$inv_total_word.' ONLY'; // // $qr_code_img="
CANCELLED
"; $watermark=" position: absolute; color: red; opacity: 0.25; font-size: 2.5em; width: 100%; -- top: 8%; text-align: center; z-index: 0; -ms-transform: rotate(-20deg); /* IE 9 */ transform: rotate(-40deg); "; $qr_code_img="
CANCELLED
"; $inv_cancelled="
CANCELLED
"; if($inv_status!='cancelled'){ $inv_cancelled=""; $get_ir=$mysqli->query("SELECT * FROM `irn_data` WHERE `inv_id`='$inv_id' AND `co_id`='".$_SESSION["co_id"]."'"); while($gir=$get_ir->fetch_array()){ $irn=$gir["irn"]; $SignedQRCode=$gir["irn_qr_data"]; $ack_no=$gir["irn_ack_no"]; $ack_dtt=$gir["irn_ack_dtt"]; include('php_qr_code/library/php_qr_code/qrlib.php'); // Include a library for PHP QR code //its a location where generated QR code can be stored. $qr_code_file_path = dirname(__FILE__).DIRECTORY_SEPARATOR.'qr_assets'.DIRECTORY_SEPARATOR; $set_qr_code_path = 'qr_assets/'; // If directory is not created, the create a new directory if(!file_exists($qr_code_file_path)){ mkdir($qr_code_file_path); } //Set a file name of each generated QR code $filename = $qr_code_file_path.time().'.png'; $errorCorrectionLevel = "L"; $matrixPointSize = 2; $frm_link = $SignedQRCode; QRcode::png($frm_link, $filename, $errorCorrectionLevel, $matrixPointSize, 2); // echo " // // // // // // $qr_code_img=""; } } if($inv_date>=$gst_imple_date){ if($gst_type=="intrastate"){ $cgst_amt=$tot_tax_amt/2; $dec=substr((($cgst_amt-floor($cgst_amt))*100),0,2); $tax_amt_disp=strtoupper("Rupees ".Numbers_Words::toWords(($cgst_amt),"en_GB")." & Paise ".Numbers_Words::toWords($dec,"en_GB")." Only"); $remarks_disp="
IRN$Irn
Ack No$AckNo
Ack Date$AckDt
QRCode
QRCode Data$SignedQRCode
Signed Inv$SignedInvoice
GST Summary$qr_code_img
CGST:$cgst_amt
SGST:$cgst_amt
IRN
$irn
Ack no/Date :$ack_no / $ack_dtt
$remarks "; }elseif($gst_type=="interstate"){ $dec=substr((($tot_tax_amt-floor($tot_tax_amt))*100),0,2); //echo "$dec :"; $tax_amt_disp=strtoupper(" IGST: Rupees ".Numbers_Words::toWords($tot_tax_amt,"en_GB")." & Paise ".Numbers_Words::toWords($dec,"en_GB")." Only"); $remarks_disp="
GST Summary
IGST:$tot_tax_amt$qr_code_img
IRN :$irn
Ack no/Date :$ack_no / $ack_dtt
$remarks "; } }else{ $remarks_disp=$remarks ; } #$inv_total_rupees="Rupees".$inv_total; #mysql_close(); $sub_total=sprintf('%01.2f',$sub_total); $sub_total4=sprintf('%01.2f',$sub_total4); $roundoff=sprintf('%01.2f',$roundoff); if($inv_date>="2017-07-01"){$tax_str_disp="GST";}else{$tax_str_disp="Tax";} $tax_str=$sale_group; if($fwd==0){ $bill_bodyp.= " $remarks_disp       ";}else{ $bill_bodyp.= " $remarks_disp Packing & Forwarding Charges   $fwd   ".sprintf('%01.2f',$fwd_tax_amt)."  "; } $bill_bodyp.=" $tax_str $tax_str_disp   ".sprintf('%01.2f', $tot_tax_amt)."   $bndl_disp Subtotal   $sub_total4   $inv_total_wordRoundoff   $roundoff   Total ($ir)   $inv_amt  "; if(!isset($top_copy)){$top_copy=4;} $pg_type=array('(ORIGINAL)','(Duplicate)','(Triplicate)','(Copy)','(Copy)','(Copy)','(Copy)'); $sign_str="

"; $savp=$_REQUEST['savp']; if($savp=='pdf'){ $top_copy=1; $pg_type[0]=''; $sign_str="Computer Generated.
Signature not required.
"; } $bill_bodyp.="  Goods once sold cannot be taken back.
 Subject to Jurisdiction of ".$_SESSION['co_city']."

 E. & O.E.
For ".$_SESSION['co_name']."


$sign_str
Authorised Signatory.
"; $msg.="$bill_body"; $html=""; $i=0; while($i<$top_copy){ $pdf->Addpage(); //
 $pg_type[$i]
$tbl=<< $co_dets $inv_cancelled
$ac_det $desp_det $bill_bodyp
EOD; //$html=utf8_encode($html); $pdf->writeHTML($tbl, true, false, false, false, ''); $i++; } //$scm_op_tbl="$scm_op
"; $scm_op_tbl=<<$scm_op EOD; $mysqli->close; if($scm_cnt>0){ $pdf->Addpage(); $pdf->writeHTML($scm_op_tbl, true, false, false, false, ''); } $pdf->lastPage(); $pdf->IncludeJS("print();"); // ----------------------------------------------------------------------------- //Close and output PDF document $pdf->Output("Invoice No $inv_no.pdf", 'I'); //exit("hi".date("dmY His")); /* //============================================================+ // END OF FILE //============================================================+ */ //$html.=""; //$pdfcontent.=$html."
"; //$pdfcontent=$html; //$pdfpassword='123'; //exit("$html"); ?>