<?php 
error_reporting(0);

require_once '../assets/plugins/tcpdf/tcpdf.php'; 
include("../config.php");

class MyCustomPDFWithWatermark extends TCPDF{
    public function Header() {
      $bMargin = $this->getBreakMargin();
      $auto_page_break = $this->AutoPageBreak;
      $this->SetAutoPageBreak(false, 0);
      $this->Image($img_file, 35, 60, 150, 150, '', '', '', false, 300, '', false, false, 0);
      $this->SetAutoPageBreak($auto_page_break, $bMargin);
      $this->setPageMark();
    }
 public function Footer() {
        // Set the footer content to an empty string
        $this->setPrintFooter(false);
    }    
}
$pdf = new MyCustomPDFWithWatermark(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetAutoPageBreak(TRUE, 0);
$pdf->SetMargins(10,10,10);
$pdf->SetFont('helvetica', '', '7', '', true);
$bill_no  = $_GET['p1'];
// $bill_no    = $_POST['invoice_no'];

$file_type  = implode(",", $_POST['print_type']);
$arrays     = explode(',', $file_type);

$report     = "SELECT * FROM report_setting WHERE company_id = '".$_SESSION['company_id']."' AND branch_id = '".$_SESSION['branch_id']."'";
$report_res = mysqli_query($conn,$report);
$report_row = mysqli_fetch_assoc($report_res);

$bill             =  "SELECT * FROM `billing` WHERE `invoice_no` = '".$bill_no."'";
$bill_res         = mysqli_query($conn,$bill);
$bill_row         = mysqli_fetch_assoc($bill_res);
$vendor           = "SELECT * FROM `vendor_master` WHERE `id` = '".$bill_row['vendor_id']."'";
$vendor_res       = mysqli_query($conn,$vendor);
$vendor_row       = mysqli_fetch_array($vendor_res);
$state_code       = substr($vendor_row['gstin'],0,2);

$lr     = "SELECT * FROM `billing` WHERE invoice_no = '".$bill_no."'";
$lr_res = mysqli_query($conn,$lr);
$num    = mysqli_num_rows($lr_res);
$lrs    = array();
while ($lr_row = mysqli_fetch_assoc($lr_res)) { 
  $lrs[] = $lr_row;
}

//$total_count      =  count($lrs);
$gst_paid         = "SELECT * FROM lr_mst WHERE lr_no = '".$bill_row['lr_no']."'";
$gst_paid_res     = mysqli_query($conn,$gst_paid);
$gst_paid_row     = mysqli_fetch_assoc($gst_paid_res);

 $consignor_query = "SELECT * FROM `vendor_master` WHERE `id` = '".$gst_paid_row['consignor_name']."'";
 $consignor_res = mysqli_query($conn, $consignor_query);
 $consignor_row = mysqli_fetch_assoc($consignor_res);

 //consignee name
 $consignee_query = "SELECT * FROM `vendor_master` WHERE `id` = '".$gst_paid_row['consignee_name']."'";
 $consignee_res = mysqli_query($conn, $consignee_query);
 $consignee_row = mysqli_fetch_assoc($consignee_res);

$bank_det         = "SELECT * FROM company_mst WHERE id = '".$_SESSION['company_id']."'";
$bank_det_res     = mysqli_query($conn,$bank_det);
$bank_det_rows    = mysqli_fetch_assoc($bank_det_res);

$bill_add     = "SELECT * FROM `billing_details` WHERE `type` = 'add' AND `bill_no` =  '".$bill_no."' ORDER BY id DESC";
$bill_add_res = mysqli_query($conn,$bill_add);

$bill_add = array();
$total_add  = 0;
while ($bill_add_row = mysqli_fetch_assoc($bill_add_res)) {
  $bill_add[] = array('title' => $bill_add_row['tax_mst_id'], 'amount' => $bill_add_row['amount']);
  $total_add += $bill_add_row['amount'];
}
$master_tax = combine(getAllRecords('tax_mst'), 'id', 'descr');

if( isset($bill_add[0]['amount']) && !empty($bill_add[0]['amount']) ) {
  $bill_amnt_0 = customFormatMoney($bill_add[0]['amount']); 
  $countaddone = '1';
}else{
  $bill_amnt_0 = '';
}

if( isset($bill_add[1]['amount']) && !empty($bill_add[1]['amount']) ) {
 $bill_amnt_1 = customFormatMoney($bill_add[1]['amount']); 
 $countaddtwo = '1';
}else{
 $bill_amnt_1 = '';
}

if( isset($bill_add[2]['amount']) && !empty($bill_add[2]['amount']) ) {
 $bill_amnt_2 = customFormatMoney($bill_add[2]['amount']);
 $countaddthree = '1';
}else{
 $bill_amnt_2 = '';
}

if( isset($bill_add[3]['amount']) && !empty($bill_add[3]['amount']) ) {
 $bill_amnt_3 = customFormatMoney($bill_add[3]['amount']);
 $countaddfour = '1';
}else{
 $bill_amnt_3 = '';
} 

$count_add_row = $countaddone + $countaddtwo + $countaddthree + $countaddfour;
$lhc_sub     = "SELECT * FROM `billing_details` WHERE `type` = 'sub' AND `bill_no` =  '".$bill_no."' ORDER BY id DESC";
$lhc_sub_res = mysqli_query($conn,$lhc_sub);
$sub = array();
$total_sub = 0;
while ($lhc_sub_row = mysqli_fetch_assoc($lhc_sub_res)) {
 $sub[] = array('title' => $lhc_sub_row['tax_mst_id'], 'amount' => $lhc_sub_row['amount']);
 $total_sub += $lhc_sub_row['amount'];
}

if( isset($sub[0]['amount']) && !empty($sub[0]['amount']) ) {
 $sub_0 = customFormatMoney($sub[0]['amount']);
 $countsub1 = '1';
 $style = ''; 
}else{
 $sub_0 = '';
 $style = "height:17px";
}

if( isset($sub[1]['amount']) && !empty($sub[1]['amount']) ) {
 $sub_1 = customFormatMoney($sub[1]['amount']);
 $countsub2 = '1';
 $style = '';  
}else{
 $sub_1 = '';
 $style = "height:17px";
}

if( isset($sub[2]['amount']) && !empty($sub[2]['amount']) ) {
 $sub_2 = customFormatMoney($sub[2]['amount']);
 $countsub3 = '1';
 $style = '';  
}else{
 $sub_2 = '';
 $style = "height:17px";
}

if( isset($sub[3]['amount']) && !empty($sub[3]['amount']) ) {
 $sub_3 = customFormatMoney($sub[3]['amount']);
 $countsub4 = '1';
 $style = '';  
}else{
 $sub_3 = '';
 $style = "height:17px";
}

foreach ($arrays as $key => $print_types) {
    $output = ''; 
    if($print_types == 'ori_copy'){
        $bill_copy = 'ORIGNAL COPY';
        // $tag = "";
        // $img_file = '';
    }

    if($print_types == 'dup_copy'){
        $bill_copy = 'DUPLICATE COPY';
        // $tag = "C.C ATTECHED";
      // $img_file = '../assets/logo/light_green.png';

    }

    if($print_types == 't_copy'){
        $bill_copy = 'TRIPLICATE COPY';
        // $tag = "";
      // $img_file = '../assets/logo/yellow.png';

    }
$count_sub_row = $countsub1 + $countsub2 + $countsub3 + $countsub4;

$total_add_less_row = (8 - ($count_sub_row + $count_add_row));

$branch     = "SELECT * FROM branch_mst WHERE id = '".$_SESSION['branch_id']."'";
$branch_mst = mysqli_query($conn,$branch);
$branch_row = mysqli_fetch_assoc($branch_mst);

$output  = ''; 
$output .= '<!DOCTYPE html>
<html>
   <head>
      <title>BILL COPY</title>
   </head>
   <body>

    <table cellpadding="2" style="width: 100%;">
      <tr>
        <td style="border-top:1px solid black;border-left:1px solid black;width:33%;text-align:left;font-weight:bold;font-size:10px;"> Subject to Ahmedabad Jurisdiction </td>
        <td style="border-top:1px solid black;width:40%;text-align:center;"><img src="../assets/logo/sh_logo.png" alt="logo" style="width:80px; height:40px;"></td>
        <td style="border-top:1px solid black;border-right:1px solid black;width:27%;text-align:right;font-weight:bold;font-size:10px;color:red;">Mo. : 9898910259<br>8487810261</td>
      </tr>  
      <tr>
        <td style="border-left:1px solid black;border-right:1px solid black;width:100%;font-size:18px;"><img src="../assets/logo/sl_logo.png" alt="logo" style="width:500px; height:70px;"></td>
      </tr> 
      <tr>
      <td style="border-left:1px solid black;width:15%;text-align:center;font-weight:bold;font-size:9px;">  </td>
        <td style="border-right:1px solid black;width:85%;text-align:center;font-weight:bold;font-size:9px;"> Plot No. : 37,38 Office No.4, Transport Nagar, Aslali, Ahmedabad, Gujarat - 382427,<br> Email : sourbhlogistics01@gmail.com   </td>
      </tr>
      <tr>
        <td style="border-bottom:1px solid black;border-left:1px solid black;border-right:1px solid black;width:100%;text-align:center;;font-weight:bold;font-size:12px;">TAX INVOICE</td>
      </tr>  
            <tr>
              <td style="border-left:1px solid black;width:70%;text-align:left;font-weight:bold;font-size:10px;"> M/s '.$vendor_row['name'].'</td>
              <td style="border:1px solid black;border-left:1px solid black;width:30%;text-align:left;font-weight:bold;font-size:12px;"> BILL NO. : <span style="color:red;font-size:14px;">'.substr($bill_no,9).'</span></td>

            </tr>
            <tr>
              <td style="border-left:1px solid black;width:70%;text-align:left;font-size:10px;"> '.$vendor_row['address'].'</td>
              <td style="border:1px solid black;border-left:1px solid black;width:30%;text-align:left;font-weight:bold;font-size:12px;"> Date : '.risformatdate($bill_row['bill_date']).'</td>
            </tr>
             <tr>
              <td style="border-left:1px solid black;border-right:1px solid black;width:70%;font-weight:bold;text-align:left;font-size:10px;">GSTIN : '.$vendor_row['gstin'].'</td>
              <td style="border-left:1px solid black;border-right:1px solid black;width:30%;font-weight:bold;text-align:left;font-size:10px;"></td>
            </tr>

            <tr>
            <td style="border:1px solid black;text-align:center;   width:8%; font-size:9px; font-weight:bold;">C.N No.</td>
            <td style="border:1px solid black;text-align:center;   width:10%; font-size:9px; font-weight:bold;">Date</td>
            <td style="border:1px solid black;text-align:center;   width:12%; font-size:9px; font-weight:bold;">Truck No</td>
            <td style="border:1px solid black;text-align:center;   width:12%; font-size:9px; font-weight:bold;">From</td>
            <td style="border:1px solid black;text-align:center;   width:12%; font-size:9px; font-weight:bold;">To</td>
            <td style="border:1px solid black;text-align:center;   width:13%; font-size:9px; font-weight:bold;">Party Invoice</td>
            <td style="border:1px solid black;text-align:center;   width:8%; font-size:9px; font-weight:bold;">Weight</td>
            <td style="border:1px solid black;text-align:center;   width:10%; font-size:9px; font-weight:bold;">Rate</td>
            <td style="border:1px solid black;text-align:center;   width:15%; font-size:9px; font-weight:bold;">Amount</td>
          </tr>';
           $i = 1;
           $total_weight = 0;
           $total_other  = 0;
           $total_amount = 0;
           $total_pcs    = 0;
           $line_count   = 0;
           $cou = 1;
           $srno = 1;
          foreach ($lrs as $i => $lr) {
            $lr_rematks     = "SELECT * FROM `billing` WHERE invoice_no = '".$bill_no."' AND remark !=''";
            $lr_rematks_res = mysqli_query($conn,$lr_rematks);
            $remark_count   = mysqli_num_rows($lr_rematks_res);
            $lr_rematks_row = mysqli_query($conn,$lr_rematks_res);
            
            //LR NO
              $fri      = "SELECT * FROM lr_mst WHERE lr_no = '".$lr['lr_no']."'";
              $fri_res  = mysqli_query($conn,$fri);
              $fri_row  = mysqli_fetch_assoc($fri_res);

              $frio      = "SELECT * FROM lr_opening WHERE lr_no = '".$lr['lr_no']."'";
              $frio_res  = mysqli_query($conn,$frio);
              $frio_row  = mysqli_fetch_assoc($frio_res);

               if(strlen($lr['lr_no'])== "9") {
            $lrno_print = substr($lr['lr_no'],4);
            $truck_print = $fri_row['truck_no'];
            $invoice_print = $fri_row['party_invoice'];
            $nature_print = $fri_row['nature_of_goods'];
            $weight_print = $fri_row['charged_weight'];
            $date_print = $fri_row['l_date'];
         }else{
            $lrno_print = $lr['lr_no'];
            $truck_print = $frio_row['truck_no'];
            $invoice_print = $frio_row['party_invoice'];
            $nature_print = $frio_row['nature_of_goods'];
            $weight_print = $frio_row['weight'];
            $date_print = $frio_row['l_date'];
         }
            //consignor name
            $consignor_query = "SELECT * FROM `vendor_master` WHERE `id` = '".$fri_row['consignor_name']."'";
            $consignor_res = mysqli_query($conn, $consignor_query);
            $consignor_row = mysqli_fetch_assoc($consignor_res);

            //consignee name
            $consignee_query = "SELECT * FROM `vendor_master` WHERE `id` = '".$fri_row['consignee_name']."'";
            $consignee_res = mysqli_query($conn, $consignee_query);
            $consignee_row = mysqli_fetch_assoc($consignee_res);

            //type of vehicle
            $lorry_type = "SELECT * FROM `lr_mst` WHERE `lr_no` = '".$fri_row['lorry_type']."'";
            $lorry_res = mysqli_query($conn, $lorry_type);
            $lorry_row = mysqli_fetch_assoc($lorry_res);

            //freight of vehicle
            $freight_query = "SELECT * FROM `billing` WHERE `lr_no` = '".$lr['lr_amount']."'";
            $freight_res  = mysqli_query($conn, $freight_query);
            $freight_row = mysqli_fetch_assoc($freight_res);

             $afri      = "SELECT sum(pcs) as pcs FROM lr_grid WHERE master_id = '".$fri_row['id']."'";
            $afri_res  = mysqli_query($conn,$afri);
            $afri_row  = mysqli_fetch_assoc($afri_res);

          $fri_grid      = "SELECT * FROM lr_grid WHERE master_id = '".$gst_paid_row['id']."' order by id ASC";
          $fri_res_grid  = mysqli_query($conn, $fri_grid);
          $concatenated_values = "";
          $concatenated_pcs = "";
          $concatenated_packing = "";


          while ($fri_row_grid  = mysqli_fetch_assoc($fri_res_grid)) {
              $concatenated_values .= $fri_row_grid['description'] . "<br>";
              $concatenated_pcs .= $fri_row_grid['pcs'] . "<br>";
              $concatenated_packing .= $fri_row_grid['lr_packing'] . "<br>";
          }

          $concatenated_values = rtrim($concatenated_values, "<br>");
          $concatenated_pcs = rtrim($concatenated_pcs, "<br>");
          $concatenated_packing = rtrim($concatenated_packing, "<br>");
         
            // if($fri_row['packing'] || $fri_row['remark']){d
            //   $line_count += 1;
            // }

            $remark_query = "SELECT * FROM `billing` WHERE invoice_no = '".$bill_no."' AND remark !=''"; // Modify this query as needed
            $remark_res = mysqli_query($conn, $remark_query);
            $remark_row = mysqli_fetch_assoc($remark_res);
            $bill_remark  = $remark_row['remark'];
            $common_remark = $lr['remark'];


            $lr_wise_remark = $fri_row['remark'];
            // $bill_remark = $bill_row['remark'];
            $total_weight  += $fri_row['weight'];
            $total_other   += $lr['other_charges'];
            $total_amount  += $lr['lr_amount'];
            $total_pcs     += $afri_row['pcs'];
            $total_freight += $lr['other_charges'] + $lr['lr_amount'] ;
            $grand_total   = $lr['other_charges'] + $lr['lr_amount'];
            $net_amnt     =  $total_freight + $total_add + $lr['cgst_amount'] + $lr['sgst_amount'] + $lr['igst_amount'];

            $truck = mysqli_query($conn, "SELECT * FROM `truck_mst` WHERE `truck_no` = '".$fri_row['truck_no']."'");
            $truck_row = mysqli_fetch_assoc($truck);

            $total_count    =  $num + $remark_count + $line_count + count($bill_add) + count($sub);

          $output .='
          <tr>
            <td style="border-left:1px solid #000;border-right:1px solid #000;font-weight:bold;width:8%; text-align:center; font-size:9px;"> '.substr($lr['lr_no'],4).' </td>
            <td style="border-left:1px solid #000;border-right:1px solid #000;font-weight:bold;width:10%; text-align:center; font-size:9px;"> '.risformatdate($lr['lr_date']).' </td>
            <td style="border-right:1px solid #000;font-weight:bold;width:12%; text-align:center; font-size:9px;">'.$fri_row['truck_no'].'</td>
            <td style="border-right:1px solid #000;font-weight:bold;width:12%; text-align:center; font-size:9px;">'.$lr['lr_from'].'  </td>
            <td style="border-right:1px solid #000;font-weight:bold;width:12%; text-align:center; font-size:9px;">'.$lr['lr_to'].'  </td>
            <td style="border-right:1px solid #000;font-weight:bold;width:13%; text-align:center; font-size:9px;">'.$fri_row['party_invoice'].'</td>
            <td style="border-right:1px solid #000;font-weight:bold;width:8%; text-align:center; font-size:9px;">'.$lr['lr_weight'].'</td>
            <td style="border-right:1px solid #000;font-weight:bold;width:10%; text-align:center; font-size:9px;">'.$lr['lr_rate'].'</td>
            <td style="border-right:1px solid #000; text-align:center; font-weight:bold;width:15%;font-size:9px;">'.$lr['lr_amount'].'</td>
          </tr>
          
        
          ';
          $srno++;
          $i++; }
          if($total_count < 22) {
            for ($j=1; $j <= ( 22 - $total_count ); $j++) {
            $output .='
            <tr>
            <td style="border-left:1px solid #000;border-right:1px solid #000; text-align:center; font-weight:bold;width:8%;font-size:8.5px;"></td> 
            <td style="border-left:1px solid #000;border-right:1px solid #000; text-align:center; font-weight:bold;width:10%;font-size:8.5px;"></td> 
            <td style="border-right:1px solid #000;font-weight:bold;width:12%; text-align:center; font-size:8.5px;">  </td>
            <td style="border-right:1px solid #000;font-weight:bold;width:12%; text-align:center; font-size:8.5px;">  </td>
            <td style="border-right:1px solid #000;font-weight:bold;width:12%; text-align:center; font-size:8.5px;">  </td>
            <td style="border-right:1px solid #000;font-weight:bold;width:13%; text-align:center; font-size:8.5px;"></td>
            <td style="border-right:1px solid #000;font-weight:bold;width:8%; text-align:center; font-size:8.5px;"></td>
            <td style="border-right:1px solid #000;font-weight:bold;width:10%; text-align:center; font-size:8.5px;"></td>
            <td style="border-right:1px solid #000; text-align:center; font-weight:bold;width:15%;font-size:8.5px;"></td>
          </tr>
           ';
           }
         }    
          $output .='      
         <tr>
             <td  style="width:75%;font-weight:bolder;font-size:10px;border-top:1px solid black; border-bottom:1px solid black;  border-left:1px solid black;"></td>
            <td    style="width:10%;font-weight:bolder;text-align:center;border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;border-right:1px solid black;font-size:10px;">Sub Total</td>
            <td   style="width:15%;font-weight:bolder;  text-align:right;border-top:1px solid black;border-bottom:1px solid black;border-right:1px solid black;font-size:10px;"> '.customFormatMoney($total_freight).' </td>
         </tr>';

           if($bill_add[0]['title'] != ''){
          $output .='
          <tr>
            <td  style="font-weight:bolder; width:55%;border-top:1px solid black;  border-left:1px solid black;"></td>
            <td   style="font-weight:bolder;width:30%;text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.@$master_tax[$bill_add[0]['title']].'</td>
            <td style="font-weight:bolder; width:15%; text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.$bill_amnt_0.'</td>
          </tr>';
        }

        if($bill_add[1]['title'] != ''){
          $output .='
          <tr>
            <td  style="font-weight:bolder; width:55%;border-top:1px solid black;  border-left:1px solid black;"></td>
            <td   style="font-weight:bolder;width:30%;text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.@$master_tax[$bill_add[1]['title']].'</td>
            <td style="font-weight:bolder; width:15%; text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.$bill_amnt_1.'</td>
          </tr>';
        }

        if($bill_add[2]['title'] != ''){
          $output .='
          <tr>
            <td  style="font-weight:bolder; width:55%;border-top:1px solid black;  border-left:1px solid black;"></td>
            <td   style="font-weight:bolder;width:30%;text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.@$master_tax[$bill_add[2]['title']].'</td>
            <td style="font-weight:bolder; width:15%; text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.$bill_amnt_2.'</td>
          </tr>';
        }

        if($bill_add[3]['title'] != ''){
          $output .='
          <tr>
            <td  style="width::55%;font-weight:bolder; border-top:1px solid black;  border-left:1px solid black;"></td>
            <td   style="width:30%;font-weight:bolder;text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.@$master_tax[$bill_add[3]['title']].'</td>
            <td   style="font-weight:bolder; width:15%; text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.$bill_amnt_3.'</td>
          </tr>';
        }

        if($lr['cgst_amount'] != '0'){
          $output .='
          <tr>
            <td  style="width:55%;font-weight:bolder;text-align:left;border-top:1px solid black;  border-left:1px solid black;"> </td>
            <td  style="width:30%;font-weight:bolder;text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> CGST '.$lr['cgst_per'].' %</td>
            <td  style="width:15%;font-weight:bolder;  text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.$lr['cgst_amount'].'</td>
         </tr>';
         }

        if($lr['sgst_amount'] != '0'){
          $output .='
          <tr>
            <td  style="width:55%;font-weight:bolder;text-align:left;border-top:1px solid black;  border-left:1px solid black;"> </td>
            <td  style="width:30%;font-weight:bolder;text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> SGST '.$lr['sgst_per'].' %</td>
            <td  style="width:15%;font-weight:bolder;  text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.$lr['sgst_amount'].'</td>
         </tr>';
         }
        if($lr['igst_amount'] != '0'){
          $output .='
          <tr>
            <td  style="width:55%;font-weight:bolder;text-align:left;border-top:1px solid black;border-left:1px solid black;"> </td>
            <td  style="width:30%;font-weight:bolder;text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> IGST '.$lr['igst_per'].' %</td>
            <td  style="width:15%;font-weight:bolder;  text-align:right;border-top:1px solid black;border-right:1px solid black;font-size:10px;"> '.$lr['igst_amount'].'</td>
         </tr>';
       }
       
        $output .='
         <tr>
             <td  style="width:67%;font-weight:bolder;font-size:10px;border-top:1px solid black; border-bottom:1px solid black;  border-left:1px solid black;"> GST PAID BY : '.$gst_paid_row['gst_paid_by'].' </td>
            <td    style="width:18%;font-weight:bolder;text-align:center;border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;border-right:1px solid black;color:red;font-size:12px;">G TOTAL</td>
            <td   style="width:15%;font-weight:bolder;  text-align:right;border-top:1px solid black;border-bottom:1px solid black;border-right:1px solid black;font-size:12px;color:red;"> '.customFormatMoney($net_amnt).' </td>
         </tr>
         <tr>
             <td  style="width:100%;font-weight:bolder;font-size:10px;border:1px solid black; border-bottom:1px solid black;  border-left:1px solid black;"> Amount in Words : '.convertNumber2Words($net_amnt).'</td>
         </tr>
         <tr>
             <td   style="width:50%;font-weight:bolder;font-size:10px;border-left:1px solid black;"> PAN NO. : '.$bank_det_rows['panno'].'</td>
            <td    style="width:50%;font-weight:bolder;text-align:left;border-left:1px solid black;border-right:1px solid black;font-size:10px;"> BANK NAME : '.$bank_det_rows['bank_name'].'</td>
         </tr>
         <tr>
             <td   style="width:50%;font-weight:bolder;font-size:10px;border-left:1px solid black;"> GST NO. : '.$bank_det_rows['gst'].'</td>
            <td    style="width:50%;font-weight:bolder;text-align:left;border-left:1px solid black;border-right:1px solid black;font-size:10px;"> A/C NO. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: '.$bank_det_rows['account_no'].'</td>
         </tr>
         <tr>
             <td rowspan="2"  style="width:50%;font-weight:bolder;font-size:10px;border-left:1px solid black;"> NOTE : '.$bill_row['remarks'].'</td>
            <td    style="width:50%;font-weight:bolder;text-align:left;border-left:1px solid black;border-right:1px solid black;font-size:10px;"> BRANCH &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: '.$bank_det_rows['branch'].'</td>
         </tr>
         <tr>
            <td    style="width:50%;font-weight:bolder;text-align:left;border-left:1px solid black;border-right:1px solid black;font-size:10px;"> IFSC CODE &nbsp;&nbsp;: '.$bank_det_rows['ifsc_code'].'</td>
         </tr>
          <tr>
            <td rowspan="3" style="width:50%;font-weight:bolder;border-top:1px solid black;border-bottom:1px solid black;border-left:1px solid black; text-align:left;font-size:10px;"> E & O.E </td>
            <td style="width:50%;font-weight:bolder; border-top:1px solid black;color:red; border-right:1px solid black;text-align:center;font-size:11px;">For, '.$bank_det_rows['name'].' </td>
          </tr>
          <tr>
            <td style="width:50%;border-right:1px solid black;font-weight:bolder;  text-align:center;font-size:11px;"><img src="../assets/logo/sh_stamp.png" alt="logo" style="width:70px; height:60px;"></td>
          </tr>
          <tr>
            <td style="width:50%;border-bottom:1px solid black;border-right:1px solid black;font-weight:bolder;text-align:center;font-size:10px;">Authorized signatory</td>
          </tr>
         ';

        $output .='          
         
      </table>
   </body>
</html>';
$pdf->SetPrintHeader(true);
$pdf->SetPrintFooter(true);


$pdf->AddPage('P', 'A4');
$pdf->writeHTML($output, true, false, false, false, '');
}
$pdf->SetTitle('BILL COPY'.'-'.$_GET['p1']);
$pdf->Output('bill_copy'.'_'.$_GET['p1'].'.pdf', 'I');
?>