set('isPhpEnabled', 'true'); $dompdf = new Dompdf($options); function number_to_word($n){ $a=$n; $w=""; $crore=(int)($n/10000000); $n=$n%10000000; $w.=get_word($crore,"Crore "); $lakh=(int)($n/100000); $n=$n%100000; $w.=get_word($lakh,"Lakh "); $thousand=(int)($n/1000); $n=$n%1000; $w.=get_word($thousand,"Thousand "); $hundred=(int)($n/100); $w.=get_word($hundred,"Hundred "); $ten=$n%100; $w.=get_word($ten,""); $w.="Rupees "; $v=explode(".",$a); if(isset($v[1])){ if(strlen($v[1])==1) { $v[1]=$v[1]*10; } $w.=" and ".get_word($v[1]," Paisa"); } return $w." Only"; } function get_word($n,$txt){ $t=""; if($n<=19){ $t=words_array($n); }else{ $a=$n-($n%10); $b=$n%10; $t=words_array($a)." ".words_array($b); } if($n==0){ $txt=""; } return $t." ".$txt; } function words_array($num){ $n=[0=>"", 1=>"One", 2=>"Two", 3=>"Three", 4=>"Four", 5=>"Five", 6=>"Six", 7=>"Seven", 8=>"Eight", 9=>"Nine", 10=>"Ten", 11=>"Eleven", 12=>"Twelve", 13=>"Thirteen", 14=>"Fourteen", 15=>"Fifteen", 16=>"Sixteen", 17=>"Seventeen", 18=>"Eighteen", 19=>"Nineteen", 20=>"Twenty", 30=>"Thirty", 40=>"Forty", 50=>"Fifty", 60=>"Sixty", 70=>"Seventy", 80=>"Eighty", 90=>"Ninety", 100=>"Hundred",]; return $n[$num]; } $selectcom="SELECT * FROM `account` WHERE id='1'"; $run_cim=mysqli_query($conn,$selectcom); $rowcom=mysqli_fetch_array($run_cim); $com_name=$rowcom['companyname']; $address=$rowcom['address']; $district=$rowcom['district']; $pin_code=$rowcom['pincode']; $state=$rowcom['state']; $Phone=$rowcom['phoneno']; $email_id=$rowcom['emailid']; $gst_num=$rowcom['gstnumber']; $ubank_name=$rowcom['bankname']; $ua_c_no=$rowcom['bankno']; $uifc_code=$rowcom['ifsccode']; $logo=$rowcom['logo']; $sql = "SELECT * FROM `invoice` WHERE id='$invupid'"; $result = mysqli_query($conn, $sql); $row_inv = mysqli_fetch_array($result); $uin_no=$row_inv['invoicenum']; $uinv_date=$row_inv['invoicedate']; $displaytype=$row_inv['type']; $input = $uinv_date; $date = strtotime($input); $uinv_date=date('d-m-Y', $date); $customercode=$row_inv['customer']; $selectid="SELECT * FROM `customer` WHERE code='$customercode'"; $run_id=mysqli_query($conn,$selectid); $row_customerid=mysqli_fetch_array($run_id); $ucom_nam=$row_customerid['name']; $ugst_num=$row_customerid['gstno']; $upin_code=$row_customerid['pincode']; $ucus_phone=$row_customerid['phono']; $ucompany_address=$row_customerid['address']; $output=''; $allqty=0; $granttotal=0; $totalprice=''; $taxableamt=0; $overalltaxtotal=0; $partname=$row_inv['name']; $part_hsn=$row_inv['hsn']; $part_quan=$row_inv['qty']; $part_price=$row_inv['sellingprice']; $part_tax=$row_inv['gst']; $str_partname =explode("@@@@",$partname); $str_pro_hsn =explode("@@@@",$part_hsn); $str_pro_quan =explode("@@@@",$part_quan); $str_pro_tax =explode("@@@@",$part_tax); $str_pro_price =explode("@@@@",$part_price); $itemcount=count($str_partname); for($i=0;$i<$itemcount;$i++) { $allqty=$allqty+$str_pro_quan[$i]; $pricenew=$str_pro_price[$i]; $salprice=$str_pro_quan[$i]*$pricenew; $num2=$str_pro_tax[$i]*$salprice; $gstval=$num2/100; $totalprice=$salprice+$gstval; $j=$i+1; $salprice=number_format($salprice,2); $salprice=str_replace(",","",$salprice); $gstval=number_format($gstval,2); $gstval=str_replace(",","",$gstval); $totalprice=number_format($totalprice,2); $totalprice=str_replace(",","",$totalprice); $pricenew=number_format($pricenew,2); $pricenew=str_replace(",","",$pricenew); $pricenew1=$str_pro_quan[$i]*$pricenew; $taxableamt=$taxableamt+$pricenew1; $distax=$str_pro_tax[$i]/2; $distaxamt=$gstval/2; $distaxamt=number_format($distaxamt,2); $distaxamt=str_replace(",","",$distaxamt); $overalltaxtotal=$overalltaxtotal+$distaxamt; $granttotal=$granttotal+$totalprice; $output .= '

'.$j.'

  '.$str_partname[$i].'

'.$str_pro_hsn[$i].'

'.$str_pro_quan[$i].'

'.$pricenew.'

'.$distax.' %
'.$distaxamt.'

'.$distax.' %
'.$distaxamt.'

'.$totalprice.'

'; } $emptycount=15-$itemcount; $y=$itemcount; for($z=0;$z<$emptycount;$z++) { $y=$y+1; $output .= '

'.$y.'

'; } $overalltaxtotal=number_format($overalltaxtotal,2); $overalltaxtotal=str_replace(",","",$overalltaxtotal); $labourcost=$row_inv['labourcost']; $partcost=$row_inv['partcost']; $discount_amount=$row_inv['discount_amount']; if($labourcost == '') { $labourcost=0; } if($partcost == '') { $partcost=0; } if($discount_amount == '') { $discount_amount=0; } $granttotal=$granttotal+$labourcost; $granttotal=$granttotal+$partcost; $granttotal=$granttotal-$discount_amount; $granttotal=number_format($granttotal,2); $granttotal=str_replace(",","",$granttotal); $granttotalr=number_format($granttotal,0); $granttotalr=str_replace(",","",$granttotalr); $displayhtml='

'.$displaytype.'

 '.$com_name.'

'.$address.',
'.$district.'-'.$pin_code.' '.$state.',
 Phone : '.$Phone.', Email : '.$email_id.'

GSTIN : '.$gst_num.'

To :

'.$ucom_nam.' 

'.$ucompany_address.' 

'.$upin_code.' 

Phone No. : '.$ucus_phone.'
CU-GST : '.$ugst_num.'
Invoice No. : '.$uin_no.'
Date : '.$uinv_date.'
'.$output.'

S.N0.

  Description of Goods

HSN

Qty.

Price

CGST

SGST

Total

Sub Total

'.$allqty.'

'.$taxableamt.'

'.$overalltaxtotal.'

'.$overalltaxtotal.'

'.$granttotal.'

Labour Cost   

'.$labourcost.'

Part Cost   

'.$partcost.'

Discount Amount   

'.$discount_amount.'

Round Off   

'.$granttotalr.'

   (Rupees '.number_to_word($granttotalr).' only)

   BANK A/C DETAILS
   Bank : '.$ubank_name.'     A/C NO : '.$ua_c_no.' IFSC : '.$uifc_code.'  

Received the above goods in good Condition



Customer Signature with seal

for '.$com_name.'



Authorised Signatory

This is a computer generated invoice

'; $dompdf->loadHtml($displayhtml); $dompdf->setPaper('A4', ''); $dompdf->render(); $canvas = $dompdf->getCanvas(); $fontMetrics = new FontMetrics($canvas, $options); $w = $canvas->get_width(); $h = $canvas->get_height(); $font = $fontMetrics->getFont('times'); $text = ""; $txtHeight = $fontMetrics->getFontHeight($font, 150); $textWidth = $fontMetrics->getTextWidth($text, $font, 40); $canvas->set_opacity(.2); $x = (($w-$textWidth)/2); $y = (($h-$txtHeight)/2); $canvas->text($x, $y, $text, $font, 40,$color = array(255,0,0), $word_space = 0.0, $char_space = 0.0, $angle = 20.0); $dompdf->stream('document.pdf', array("Attachment" => 0)); ?>