", "\n", $set_ord['cust_address']); echo $contentWithNewlines.'
'; } $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('Payment Receipt'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(4, 3, PDF_MARGIN_RIGHT); // 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 (optional) if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font // add a page $pdf->SetFont('times', 'A4', 12); $pdf->AddPage(); $html='

INVOICE

'; $html.='
'; $html.= ''.$set_deal['name'].'
'; if($set_deal['address']!=''){ $contentWithNewlines = str_replace("
", "\n", $set_deal['address']); $html.= $contentWithNewlines.'
'; } $html.= $set_deal['city'].'
'; $html.=$set_deal['state'].' '.$set_deal['postcode'].'
'; if($set_deal['gst_no']!='' || $set_deal['gst_no']!=NULL){ $html.= 'GST NO: '.$set_deal['gst_no'].'
'; } $html.='MOBILE: '.$set_deal['phone'].'
'; $html.= ''.$set_ord['cust_name'] .'
'; if($set_ord['cust_address']!='' || $set_ord['gst_no']!=NULL){ $contentWithNewlines = str_replace("
", "\n", $set_ord['cust_address']); $html.= $contentWithNewlines.'
'; } $html.= $set_sate['state'].' '.$set_ord['cust_pin'].'
'; if($set_ord['gst_no']!='' || $set_ord['gst_no']!=NULL){ $html.= 'GST NO: '.$set_ord['gst_no'].'
'; }else $html.='MOBILE: '.$set_ord['cust_phone'].''; $html.='
INVOICE NO.: '.$ref_id.'

DATE :'.date('d-m-Y', strtotime($set_ord['created_at'])).'

'; if($set_deal['gst']!='GST'){ $html.=' GST NO: '.$set_deal['gst'].'
'; } $html.='


'; $html.=''; if($set_ord['cust_state']==30){ $html.= ''; }else{ $html.=''; } $html.= ''; $get_sales = mysqli_query($conn, "select * from tbl_dealer_sales where bill_id='".$set_ord['bill_id']."' and dealer_id='".$set_ord['dealer_id']."'"); while($set_sales = mysqli_fetch_array($get_sales, MYSQLI_ASSOC)){ $get_prod = mysqli_query($conn, "select * from shop_product where product_id = '".$set_sales['prod_id']."'"); $set_prod = mysqli_fetch_array($get_prod, MYSQLI_ASSOC); $ob=json_decode(calc_rate_gst($conn, $set_sales['prod_id'],$set_prod['vstatus'], $set_sales['price'], $set_sales['qty'], $set_ord['cust_state'], $set_ord['bill_id'], $set_ord['dealer_id'])); $total_qty+=$set_sales['qty']; $total_taxable_value+=$ob->taxable_value; if($set_ord['cust_state']==30){ $cgst+=$ob->cgst; $sgst+=$ob->sgst; }else{ $igst+=$ob->igst; } $total+=$ob->total; $html.=' '; if($set_ord['cust_state']==30){ $html.=' '; }else{ $html.=' '; } $html.=' '; } $html.=''; if($set_ord['cust_state']==30){ $html.=' '; }else{ $html.=' '; } $html.='
NO PRODUCT NAME HSN RATE QTY TAX VALUE GST%CGST SGSTIGSTTOTAL
'.($i=$i + 1).' '.$set_prod['name'].' '.$set_prod['product_url'].' '.$ob->hsn.' '.$ob->rate.' '.$set_sales['qty'].' '.$ob->taxable_value.' '.$ob->gst_percent.'%'.''. $ob->cgst.' '.$ob->sgst.''.$ob->igst.''.$ob->total.'
Total '.$total_qty.' '.$total_taxable_value.' '.$cgst.' '.$sgst.''.$igst.''.$total.'
'; // set some text to print $pdf->writeHTML($html, true, false, true, false, ''); // --------------------------------------------------------- //Close and output PDF document ob_end_clean(); // $pdf->Output('/var/www/html/billing/bills_pdf/Invoice-'.$set_ord['bill_id'].'-'.$set_ord['dealer_id'].'.pdf', 'F'); $pdf->Output('/var/www/html/billing/bills_pdf/Invoice-'.$set_ord['bill_id'].'-'.$set_ord['dealer_id'].'.pdf', 'I'); ?>