<?php 
error_reporting(0);

  require_once '../assets/plugins/tcpdf/tcpdf.php'; 
  $pdf = new PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  error_reporting('0');
  include("../config.php");
  $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);
  $id = $_GET['eid'];

  $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);

  $payment          = "SELECT * FROM payment WHERE voucher_no = '".$id."' AND company_id = '".$_SESSION['company_id']."' AND branch_id = '".$_SESSION['branch_id']."'";
  $payment_res      = mysqli_query($conn,$payment);
  $payment_row      = mysqli_fetch_assoc($payment_res);

  $num              = mysqli_num_rows($payment_res);
  $master_accounts  = combine(getAllRecords('act_master'), 'act_code', 'ac_name');

  $act              = "SELECT * FROM act_master WHERE act_code = '".$payment_row['account_name']."'";
  $act_res          = mysqli_query($conn,$act);
  $act_row          = mysqli_fetch_assoc($act_res);

  $lhc = mysqli_query($conn, "SELECT * FROM `lhc_payment_status` WHERE `voucher_no` = '".$payment_row['voucher_no']."'");
  $lhc_row = mysqli_fetch_assoc($lhc);

$output  = ''; 
$output .= '<!DOCTYPE html>
<html>
   <head>
      <title>LR COPY</title>
   </head>
  
   <body>
      <div>';
      $output .='<img src="../assets/logo/lhc_logo.png"><hr/><span style="font-size: 10px;text-align:center;font-size:12px;"><b>CASH PAYMENT VOUCHER</b></span>';
      $output .='</div>
      <table cellpadding="5" style="width: 100%">
         <tr>
            <td style="width:13%;text-align:left;"><b>Voucher No. </b></td>
            <td style="width:87%;text-align:left;"><b> : '.$payment_row['voucher_no'].'</b></td>
         </tr>
         <tr>
            <td style="width:13%;text-align:left;"><b>Date </b></td>
            <td style="width:87%;text-align:left;"><b> : '.risFormatDate($payment_row['b_date']).'</b></td>
         </tr>
         <tr>
            <td style="width:80%;text-align:left;border-right:1px solid black;border-left:1px solid black;border-top:1px solid black;"><b>Particulars </b></td>
            <td style="width:20%;text-align:right;border-right:1px solid black;border-top:1px solid black;"><b>Amount</b></td>
         </tr>
         <tr>
            <td style="width:12%;text-align:left;border-left:1px solid black;border-top:1px solid black;"><b>Account : </b></td>
            <td style="width:68%;text-align:left;border-right:1px solid black;border-top:1px solid black;"><b>'.$act_row['ac_name'].' ('.$lhc_row['lhc_no'].') <br/> <span style="font-size:8px;">'.$payment_row['narration'].' </span></b></td>
            <td style="width:20%;text-align:right;border-right:1px solid black;border-top:1px solid black;"><b> '.customFormatMoney($payment_row['amount']).'</b></td>
         </tr>';
         if( $num < 9 ) {
          for ($j=1; $j <= ( 9 - $num ); $j++) {
         $output .='
         <tr>
            <td style="width:10%;text-align:left;border-left:1px solid black;"><b></b></td>
            <td style="width:70%;text-align:left;border-right:1px solid black;"><b></b></td>
            <td style="width:20%;text-align:right;border-right:1px solid black;"><b></b></td>
         </tr>';
       }
     }
         $output .='
         <tr>
            <td style="width:20%;text-align:left;border-left:1px solid black;border-top:1px solid black;"><b>Amount (In Words) :  </b></td>
            <td style="width:60%;text-align:left;border-right:1px solid black;border-top:1px solid black;"><b>'.convertNumber2Words($payment_row['amount']).'</b></td>
            <td style="width:20%;text-align:right;border-right:1px solid black;border-top:1px solid black;"><b>'.customFormatMoney($payment_row['amount']).'</b></td>
         </tr>
         <tr>
            <td style="width:100%;text-align:left;border-left:1px solid black;border-top:1px solid black;border-right:1px solid black;"><b></b></td>
         </tr>
         <tr>
            <td style="width:80%;text-align:left;border-left:1px solid black;border-bottom:1px solid black;"><b>Receiver Signature</b></td>
            <td style="width:20%;text-align:right;border-right:1px solid black;border-bottom:1px solid black;"><b>Authorise Signature</b></td>
         </tr>
      </table>
   </body>
</html>';
/*echo'<pre>';
print_r($output);
echo'</pre>';
die();*/

$pdf->SetPrintHeader(true);
$pdf->SetPrintFooter(true);


//$pdf->SetAutoPageBreak(TRUE, 43);
$pdf->SetFont('helvetica', '', 9, '', true);

$pdf->AddPage('P', 'A4');
$pdf->writeHTML($output, true, false, false, false, '');

$pdf->SetTitle($title);
$pdf->IncludeJS("print();");
$pdf->Output($fname);

?>