
<?php
ini_set('display_errors', 0);
//error_reporting(E_ALL);
//ini_set('display_errors', 1);

session_start();
ob_start();

require_once('../../server_assets/server_connect.php');
require_once('../../server_assets/all_function.php');
require_once('number_to_inword.php');

 $jv_no 		= $_REQUEST['jv_no'];
 
$ms_sql="SELECT * FROM journal_master  WHERE jv_no='".$jv_no."'";
$ms_data = find_all_field_sql($conn,$ms_sql);
 
$grp_sql="SELECT * FROM user_group  WHERE id='".$ms_data->group_for."'";
$grp_data = find_all_field_sql($conn,$grp_sql);

$ref_sql="SELECT * FROM accounts_reference  WHERE ref_no='".$ms_data->ref_no."'";
$ref_data = find_all_field_sql($conn,$ref_sql);

$trm_sql="SELECT * FROM acc_terms  WHERE id='".$ms_data->acc_terms."'";
$trm_data = find_all_field_sql($conn,$trm_sql);


		 $sql = "select j.tr_no, sum(j.cr_amt) as rec_amt from journal_receive_payment j
		where  j.tr_no='".$jv_no."' group by j.tr_no";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $rec_amt[$info->tr_no]=$info->rec_amt;
		 }



		  $barcode_content = $jv_no;
		  $barcodeText = $barcode_content;
          $barcodeType='code128';
		  $barcodeDisplay='horizontal';
          $barcodeSize=40;
          $printText='';


$page_title="INVOICE";



?>



<!DOCTYPE html>
<html lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title><?php echo $ms_data->view_jv_no?></title>


<link href="../../logo/favicon.png" rel="icon">

 <link href="https://fonts.gstatic.com" rel="preconnect">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
 

  <!-- Vendor CSS Files -->

  <!-- Template Main CSS File -->
 
  
   
<style type="text/css">

<!--

.header table tr td table tr td table tr td table tr td {

	color: #000;

}

@font-face {

  font-family: 'MYRIADPRO-REGULAR';

  src: url('MYRIADPRO-REGULAR.OTF'); /* IE9 Compat Modes */



}



@font-face {

  font-family: 'TradeGothicLTStd-Extended';

  src: url('TradeGothicLTStd-Extended.otf'); /* IE9 Compat Modes */



}





@font-face {

  font-family: 'Humaira demo';

  src: url('Humaira demo.otf'); /* IE9 Compat Modes */



}



@media print {

  .brack {page-break-after: always;}

}





</style>

</head>

<body style="font-family:Tahoma, Geneva, sans-serif; font-size: 10px;">



<div class="page_brack" >



<table width="800" border="0" cellspacing="0" cellpadding="0" align="center">

  <tbody>

  <tr>

    <td><div class="header">

        <table width="100%" border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">

                <tr>

                  <td><table width="100%" border="0" cellspacing="0" cellpadding="0">

                      <tr>

                        <td width="15%">&nbsp;</td>

                        <td width="60%"><table  width="100%" border="0" align="center" cellpadding="3" cellspacing="0">

                            <tr>

                              <td style="text-align:center; color:#000; font-size:14px; font-weight:bold;">
<p style="font-size:18px; color:#000000; margin:0; padding: 0 0 5px 0; text-transform:uppercase;  font-weight:700; font-family: 'TradeGothicLTStd-Extended';">&nbsp;</p></td>
                            </tr>
                            <tr>
                              <td style="text-align:center; color:#000; font-size:14px; font-weight:bold;">&nbsp;</td>
                            </tr>
                            <tr>
                              <td style="text-align:center; color:#000; font-size:14px; font-weight:bold;">&nbsp;</td>
                            </tr>
                            <tr>
                              <td style="text-align:center; color:#000; font-size:14px; font-weight:bold;">&nbsp;</td>
                            </tr>
                            <tr>
                              <td style="text-align:center; color:#000; font-size:14px; font-weight:bold;">&nbsp;</td>
                            </tr>
                            <tr>
                              <td style="text-align:center; color:#000; font-size:14px; font-weight:bold;">&nbsp;</td>
                            </tr>
                          </table>
                        <td width="20%">&nbsp; </td>
                      </tr>

                    </table></td>
                </tr>

              </table></td>
          </tr>

          <tr>          </tr>
        </table>

      </div></td>
  </tr>

  



 

 

 

 

 

 



 

  <tr> <td><hr /></td></tr>

 

  

  

  <tr> <td>

  <table width="100%" border="0" cellspacing="0" cellpadding="0"  style="font-size:12px">

  

  	<tr height="30"  style=" color:#FFF;font-size:16px; color:#000000; font-weight:bold; font-weight:700; ">

  	  <td width="25%" valign="top">Date: <?php echo date('d/m/Y',strtotime($ms_data->jv_date));?></td>

  	  <td width="43%">&nbsp;</td>

  	  <td width="32%" align="left" valign="right">Work Ref: <?php echo $ms_data->work_ref_no;?></td>
	  </tr>
	  <tr height="30"  style=" color:#FFF;font-size:16px; color:#000000; font-weight:bold; font-weight:700;">

  	  <td width="25%" valign="top">&nbsp;</td>

  	  <td width="43%">&nbsp;</td>

  	  <td width="32%" align="left" valign="right">Bill Ref: <?php echo $ms_data->bill_ref_no;?></td>
	  </tr>
	  <tr height="30"  style=" color:#FFF;font-size:16px; color:#000000; font-weight:bold; font-weight:700;">
	    <td valign="top">&nbsp;</td>
	    <td>&nbsp;</td>
	    <td align="left" valign="right">Invoice No: <?php echo $ms_data->view_jv_no;?></td>
	    </tr>
  </table>

  

  </td></tr>

  

  

  <tr> <td>&nbsp;</td></tr>

  

  

  

 <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0">





		  <tr>





		    <td width="100%" valign="top">





		      <table width="100%" border="0" cellspacing="0" cellpadding="3"  style="font-size:12px">





		        <tr>

		          <td width="50%" style="font-size:16px; font-weight:700;">The Managing Director</td>

	              <td width="50%">&nbsp;</td>
	              </tr>

		        <tr>

		          <td  style="font-size:16px;"><?php echo $ref_data->display_name?></td>

	              <td>&nbsp;</td>
	              </tr>


		        <tr>

		          <td style="font-size:16px;"><?php echo $ms_data->address?></td>

	              <td>&nbsp;</td>
	              </tr>
		        <tr>
		          <td>&nbsp;</td>
		          <td>&nbsp;</td>
		          </tr>
		        <tr>
		          <td colspan="2">&nbsp;</td>
		          </tr>
		        <tr>
		          <td colspan="2" style="font-size:16px; font-weight:700;">Subject: <?php echo $ms_data->inv_subject?> </td>
		          </tr>
		        <tr>
		          <td colspan="2">&nbsp;</td>
		          </tr>
		        <tr>
		          <td colspan="2">&nbsp;</td>
		          </tr>
		        <tr>
		          <td colspan="2" style="font-size:16px;">Dear Sir,</td>
		          </tr>
		        
		        <tr>
		          <td colspan="2"><span style="font-size:16px; "><?php echo $ms_data->inv_details?></span></td>
		          </tr>
		        <tr>
		          <td colspan="2">&nbsp;</td>
		          </tr>
		        <tr>
		          <td colspan="2">&nbsp;</td>
		          </tr>
		        </table>		      </td>
		  </tr>





		</table>		</td></tr>

  

  

 

  <tr>

    <td>

      

      <table  width="100%" border="1" bordercolor="#CCCCCC" cellspacing="0" cellpadding="5"  style="font-size:14px">
                <thead>
                  <tr>
                    <th width="8%" scope="col">SL</th>
                    <th width="61%" scope="col">Particulars</th>
                    <th width="31%" scope="col"><center>
                      AMOUNT
                    </center></th>
                  </tr>
                </thead>
                <tbody>
					<?php
					
					$sl=1;
					
		
					
						 $sql = 'select s.*, i.item_name from item_info i, sales_invoice s
						where i.item_id=s.item_id and s.jv_no="'.$jv_no.'"  order by i.item_category, i.item_id ';
						$query = mysqli_query($conn,$sql);
						while ($data = mysqli_fetch_object($query)) {

					?>
				
                  <tr>
                    <th scope="row"><?php echo $sl++;?></th>
                    <td><?php echo $data->narration;?></td>
                    <td align="right"><?php echo number_format($data->total_amt,2); $total_dr_amt +=$data->total_amt;?>&nbsp;&nbsp;</td>
                  </tr>
				   <?php }?>
                  <tr>
                    <th colspan="2" scope="row"><div align="right">Total</div></th>
                    <td align="right"><strong><?php echo  number_format($total_dr_amt,2);?></strong>&nbsp;&nbsp;</td>
                  </tr>
				  
				  <?php if($ms_data->vat_amt>0) {?>
				  <tr>
                    <th colspan="2" scope="row"><div align="right">VAT</div></th>
                    <td align="right"><strong><?php echo  number_format($ms_data->vat_amt,2);?></strong>&nbsp;&nbsp;</td>
                  </tr>
				  <?php }?>
				   <?php if($ms_data->advance_amt>0) {?>
				  <tr>
                    <th colspan="2" scope="row"><div align="right">Advance Adjustment</div></th>
                    <td align="right"><strong><?php echo  number_format($ms_data->advance_amt,2);?></strong>&nbsp;&nbsp;</td>
                  </tr>
				  <?php }?>
				  <?php if(($ms_data->vat_amt+$ms_data->advance_amt)>0) {?>
				  <tr>
				    <th colspan="2" scope="row"><div align="right">Due Amount </div></th>
				    <td align="right"><strong><?php echo  number_format($invoice_amt=($total_dr_amt+$ms_data->vat_amt)-$ms_data->advance_amt,2);?></strong>&nbsp;&nbsp;</td>
			      </tr>
				  <?php }?>
                </tbody>
              </table>        </td>
  </tr>

	

	<tr>

	  <td>&nbsp;</td>
	  </tr>
	<tr>
	  <td style="font-size:16px; font-weight:700;">In Word: 
	  
	<?php
		number_format($net_invoice_amt=($total_dr_amt+$ms_data->vat_amt)-$ms_data->advance_amt,2);
 
	   echo convertToInwordBDT($net_invoice_amt);

	?>


	  
	 	  </td>
	  </tr>
	
  </tbody>
</table>

</div>







</body>

</html>

