<?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');

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




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

<script type="text/javascript">



function hide()



{



    document.getElementById("pr").style.display="none";



}



</script>


</head>

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



<div class="page_brack" >

<div id="pr">



      <div align="right" style=" width: 1010px; ">
<input name="button" type="button" onClick="hide();window.print();" value="Print" style="width:80px; height:40px; font-size:14px; font-weight:700;" />
      </div>



    </div>


<table width="500" 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%">

                       <!-- <img src="../../../logo/logo.png" width="100%" />-->

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

                            
                            <tr>

                              <td style="text-align:center; color:#000; font-size:18px ; letter-spacing:1px; font-weight:bold;">
<p style="font-size:26px; color:#000000; margin:0; padding: 0 0 5px 0; text-transform:uppercase;  font-weight:700; font-family: 'TradeGothicLTStd-Extended';"><?php echo $grp_data->group_name?></p>
<p style="font-size:18px
                   ; font-weight:300; color:#000000; margin:0; padding:0; line-height:24px; letter-spacing:1px;"><?php echo $grp_data->address?></p>

								<p style="font-size:18px ; line-height:24px; letter-spacing:1px; font-weight:300; color:#000000; margin:0; padding:10px;">Contact No: <?php echo $grp_data->contact_no?>
								<br />  Email:  <?php echo $grp_data->email?>
								<br />  Website:  <?php echo $grp_data->website?></p>                              </td>
                            </tr>

                            <tr>





        <!--<td bgcolor="#666666" style="text-align:center; color:#FFF; font-size:18px; font-weight:bold;">WORK ORDER </td>-->
      </tr>

                          </table>

                        <td width="15%"> 

						

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

					

					<tr>

					  

					  <td align="center"><h4 style="font-size:18px
                   ;">&nbsp;</h4></td>

					  </tr>

                      

					  

					  <tr>

					  

					  <td>&nbsp;</td>

					  </tr>

					  

					  <tr>

					  

					  <td>&nbsp;</td>

					  </tr>

					  </table>						</td>

                      </tr>

                    </table></td>

                </tr>

              </table></td>

          </tr>

          <tr>          </tr>

        </table>

      </div></td>

  </tr>

  



 

 

 

 

 

 



 

  <tr> <td><hr style="border: 2px dashed #000000;"/></td></tr>

 

  

  

  <tr> <td>

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

  

  	<tr height="30">

  	  <td width="25%" valign="top"></td>

  	  <td width="50%"  style="text-align:center; color:#FFF; font-size:22px; padding:0px 0px 10px 0px; color:#000000; font-weight:bold; font-weight:700; font-family: 'TradeGothicLTStd-Extended';"><span style="text-decoration:underline"><?php echo $page_title;?></span> </td>

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

	  </tr>

  </table>

  

  </td></tr>

  

  

  <tr> <td><hr style="border: 2px dashed #000000;"/></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:18px
                   ; letter-spacing:1px;">





		        <tr>

		          <td width="24%" style="font-size:18px
                   ; ">Username: </td>

	              <td width="38%" style="font-size:18px
                   ; "><?php echo $ms_data->entry_by;?> </td>
	              <td width="20%" style="font-size:18px
                   ; "><span role="presentation" dir="ltr">Terminal: </span></td>

	              <td width="18%" style="font-size:18px
                   ; "><?php echo $ms_data->tr_no?></td>
		        </tr>

		        <tr>

		          <td  style="font-size:18px
                   ; ">Invoice No: </td>

	              <td style="font-size:18px
                   ; "><?php echo $ms_data->view_jv_no?></td>
	              <td span style="font-size:18px
                   ;">Date: </td>

	              <td span style="font-size:18px
                   ;"><?php echo date('d-M-y',strtotime($ms_data->jv_date));?></td>
		        </tr>

		        <tr>

		          <td>Customer: </td>

	              <td><span style="font-size:18px;">
				  <?php if($ms_data->ref_no==200001) {
				  echo $ms_data->mobile_no;
				  } else{
				   echo $ref_data->display_name;
				  }?>
				  </span></td>
	              <td>&nbsp;</td>

	              <td style="text-transform: uppercase;">&nbsp;</td>
		        </tr>
		        <tr>
		          <td colspan="4"><hr style="border: 2px dashed #000000;"/></td>
		          </tr>
		        <tr >
		          <td>&nbsp;</td>
		          <td>&nbsp;</td>
		          <td>&nbsp;</td>
		          <td>&nbsp;</td>
		          </tr>
		       
		      <tr>
		          <td colspan="4"><hr style="border: 1px dashed #000000;"/></td>
		          </tr>
		        </table>		      </td>

		  </tr>





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

  

  

 

  <tr>

    <td>

      

      <table  width="100%" border="0"  cellspacing="0" cellpadding="5"  style="font-size:18px
                   ; letter-spacing:1px;">
                <thead>
                  <tr>
                    <th width="7%" >SL</th>
                    <th width="32%" >Product  </th>
                    <th width="12%" ><div align="left">Unit</div></th>
                    <th width="13%" ><div align="left">Rate</div></th>
                    <th width="13%" ><div align="left">Qty</div></th>
                    <th width="19%" ><center>Total</center></th>
                  </tr>
                  <tr>
                    <th colspan="6" scope="col"><hr style="border: 1px dashed #000000;"/></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>
                    <td><?php echo $sl++;?></td>
                    <td><?php echo $data->item_name;?></td>
                    <td><?php echo $data->unit_name;?></td>
                    <td align="left"><?php echo $data->unit_price;?></td>
                    <td align="left"><?php echo $data->total_unit;?> <?php  $data->discount_amt; $total_discount_amt +=$data->discount_amt;?></td>
                    <td align="right"><?php echo number_format($data->total_amt,2); $total_dr_amt +=$data->total_amt;?>&nbsp;&nbsp;</td>
                  </tr>
                  <tr>
                    <th colspan="6" ><hr style="border: 1px dashed #000000;"/></th>
                  </tr>
				   <?php }?>
                  <tr>
                    <th colspan="2" scope="row">&nbsp;</th>
                    <td colspan="3">Sub Total : </td>
                    <td align="right"><?php echo  number_format($total_dr_amt,2);?>&nbsp;&nbsp;</td>
                  </tr>
                  <tr>
                    <th colspan="2" scope="row">&nbsp;</th>
                    <td colspan="4"><hr style="border: 1px dashed #000000;"/></td>
                  </tr>
				  
				  
				  <tr>
                    <th colspan="2" scope="row">&nbsp;</th>
                    <td colspan="3">Discount (-) : </td>
                    <td align="right"><?php echo  number_format($total_discount_amt,2);?>&nbsp;&nbsp;</td>
                  </tr>
				  <tr>
				    <th colspan="2" scope="row">&nbsp;</th>
				    <td colspan="4"><hr style="border: 1px dashed #000000;"/></td>
			      </tr>
				  
				  <tr>
                    <th colspan="2" scope="row">&nbsp;</th>
                    <td colspan="3">Net  Payable : </td>
                    <td align="right"><?php echo  number_format($balance_due=$total_dr_amt-$total_discount_amt,2);?>&nbsp;&nbsp;</td>
                  </tr>
				  <tr>
				    <th colspan="2" scope="row">&nbsp;</th>
				    <td colspan="4"><hr style="border: 1px dashed #000000;"/></td>
			      </tr>
				  <?php 
				  $sql = 'select * from  sales_receive_data where jv_no="'.$jv_no.'" and order_no!=11 order by id';
						$query = mysqli_query($conn,$sql);
						while ($bank_data = mysqli_fetch_object($query)) {

					?>
				  <tr>
				    <th colspan="2" scope="row">&nbsp;</th>
				    <td colspan="3"><?php echo $bank_data->ledger_name ?> : </td>
			         <td align="right"><?php echo $bank_data->receive_amt ?> &nbsp;&nbsp;</td>
				  </tr>
				  <tr>
				    <th colspan="2" scope="row">&nbsp;</th>
				    <td colspan="4"><hr style="border: 1px dashed #000000;"/></td>
			      </tr>
				  <?php } ?>
                </tbody>
              </table> 
			  
			 
			  
			  
			  
        </td>

  </tr>

  

  

  

  

  <tr>

  

  	<td>&nbsp;</td>

  </tr>

  



  

  

  

	

	

	



	<tr>

		<td>

	

	

	<!-- style="border:1px solid #000; color: #000;"-->

	      <div class="footer"> 

	

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

	

	

		

		<tr>

		  <td colspan="4">&nbsp;</td>
		  </tr>

	

		<tr>

		  <td width="25%" align="center" >&nbsp;</td>

		  <td width="25%" align="center">&nbsp;</td>

		  <td width="25%" align="center">&nbsp;</td>

		  <td width="25%" align="center">&nbsp;</td>
		  </tr>

		<tr>

		  <td align="center" >&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>
		  </tr>

		<tr>

		  <td align="center" >&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>
		  </tr>
		  
		  <tr>

		  <td align="center" >&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>
		  </tr>

		<tr>

		  <td align="center" >&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>
		  </tr>

		<tr>

		  <td align="center" >&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>
		  </tr>
		  
		  <tr>

		  <td align="center" >&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>
		  </tr>

		<tr>

		  <td align="center" >&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>

		  <td align="center">&nbsp;</td>
		  </tr>

		<tr style="font-size:12px">

		  <td align="center">&nbsp;</td>

		  <td  align="center">&nbsp;</td>

		  <td  align="center">&nbsp;</td>

		  <td  align="center">&nbsp;</td>
		  </tr>

		

		

		<tr>

            <td colspan="4" style="font-size:18px; line-height:22px; letter-spacing:1px;" align="center">

                Note: For any queries, suggestionsor complaints, <br /> 
                please call <?php echo $grp_data->contact_no?> (9:00 AM - 10:00 PM).  </td>
		    </tr>

			

	

			<tr>

            <td colspan="4">&nbsp;  </td>
		</tr>

			

				<tr>

            <td colspan="4">&nbsp;  </td>
		</tr>
	</table>

	

<!--	<tr>

	  <td>&nbsp;</td>

	  </tr>

	<tr>

	  <td>&nbsp;</td>

	  </tr>

	<tr>-->

	  <td>&nbsp;</td>

	  </tr>

	<tr>

	  <td>&nbsp;</td>

	  </tr>

  </tbody>

</table>

</div>







</body>

</html>

