<STYLE TYPE='text/css'>
	a {text-decoration:none}
	a { color: black; }
P.pagebreakhere {page-break-after: always}
</STYLE>


<?php include("../../include/dbconnect.php");

$result= mysqli_query($conn," select name,account_year from branches where code='$branch' order by name")or die( mysqli_error() );
$row = mysqli_fetch_row($result);
$branchname = $row[0];


$account_year = $row[1];

$result=mysqli_query($conn,"select distinct name,address1,address2,city,state from company where compcode = '$compcode' ") or die(mysqli_error());
$row = mysqli_fetch_row($result);
$compname = $row[0];
$address = $row[1].'&nbsp;'.$row[2].'&nbsp;'.$row[3].'&nbsp;'.$row[4];


?>


<form name='myform2'  >
<?
	for($ind=0;$ind<count($trans_id);$ind++)
	{
?>
<table  width="780" border="0" align="center" cellpadding="0" cellspacing="0"    style="padding:5px; border:1px solid #666666">

<tr>
      <td height="80" colspan="4"  align="center" bgcolor="#095F92">
      <div style="padding:10px;"><img src="../../images/hapbco_logo.png" alt="logo" width="82" height="87" style="float:left"/></div>
      <span style="font-family:Arial, Helvetica, sans-serif; font-size:16px;  font-weight:bold;" > <?=$compname?> </span><br />
          <span style="font-family:Arial, Helvetica, sans-serif; font-size:12px;  font-weight:bold;" >
             <br /><?=$address?></span></td>
    </tr>



</table>







<?
$vtype ='';
$result = mysqli_query($conn,"select  distinct acctcode from ledger where account_year = '$account_year' and compcode = '$compcode' and branch_code = '$branch' and amttype !='J' and trans_id = '$trans_id[$ind]' and date = '$date' order by date desc ") or die(mysqli_error());	
while($row = mysqli_fetch_row($result))
{
	$hresult = mysqli_query($conn,"select acctgroup from acctmast where acctcode = '$row[0]' ") or die(mysqli_error());
	$hrow = mysqli_fetch_row($hresult);
	if($hrow[0] == '111201')
	{
		$vtype = 'BANK';
	}
	elseif($hrow[0] == '111204')
	{
		$vtype = 'CASH';
	}
}

$netdb = 0;
$netcr=0;
$result = mysqli_query($conn,"select  invno,voucher_no from ledger where account_year = '$account_year' and compcode = '$compcode' and branch_code = '$branch' and amttype != 'J' and trans_id = '$trans_id[$ind]' and date = '$date' order by date desc ") or die(mysqli_error());	
$row = mysqli_fetch_row($result);
if($row[0] !=0)
{
	$bill_no = $row[0];
}

$voucher_no = $row[1];

?>
<TABLE  width="780" BORDER=1 CELLPADDING=4    align="center">

  <tr >
<td height="31" align="center"   colspan="100%"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?=$vtype?>&nbsp;&nbsp; Voucher</b></font></td>


</tr>

  <tr >
  <td width="483" height="31" align="left"  ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b></b></font></td>
<td width="137" height="31" align="left" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Vr No:<?=$voucher_no?></b></font></td>
<td width="120" height="31"    align="right"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Date:<?=british($date)?></b></font></td>
</tr>
</table>
<TABLE  width="780" BORDER=1 CELLPADDING=4 RULES=COLS   align="center">



<COLGROUP></COLGROUP>
<COLGROUP></COLGROUP>
<COLGROUP></COLGROUP>
<COLGROUP></COLGROUP>
<COLGROUP></COLGROUP>

  <tr  bgcolor="#A4A4FF">



<td height="31" align="center"  colspan="2"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Particulars</b></font></td>
<td width="86" height="31" align="left" ><div align="center"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Ref. No</b></font></div></td>
<td width="106" height="31" align="right" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Debit</b></font></td>
<td width="127" height="31" align="right" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Credit</b></font></td>
</tr>
<tr>

<td colspan="2"><hr></td>
<td><hr align="center"></td>
<td><hr></td>
<td><hr></td>
</tr>
<?

$result = mysqli_query($conn,"select acctcode,date,narration,dbamt,cramt,type,trans_id,record,cheqno from ledger where account_year = '$account_year' and compcode = '$compcode' and branch_code = '$branch' and amttype != 'J' and trans_id = '$trans_id[$ind]' and date = '$date' order by date desc ") or die(mysqli_error());	
while($row = mysqli_fetch_row($result))
{
	$acctcode = trim($row[0]);
	$date = $row[1];
	$narration = $row[2];
	$chequeno = $row[8];
	$dbamt = $row[3];
	$cramt = $row[4];
	$type = $row[5];
	//$trans_id = $row[6];
	$record = $row[7];
	
	$netdb = $netdb+$dbamt;
	$netcr = $netcr + $cramt;
	if($dbamt>0)
	{
		$tp = 'Dr';
	}
	else
	{
		$tp = 'Cr';
	}
	$prodname = mysqli_fetch_array(mysqli_query($conn,"select description from acctmast where acctcode = '$acctcode'")) or die(mysqli_error());
	
	?>
	<tr  >

	<td width="375" height="31" align="left" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?=$prodname['description']?></b></font></td>
	<td width="22" height="31" align="center" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?=$tp?></b></font></td>    
	<td width="86" height="31" align="left" ><div align="center"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>
	  <?=$bill_no?>
	  </b></font></div></td>
	<td width="106" height="31" align="right" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><? if($dbamt > 0) echo $dbamt; ?></b></font></td>
	<td width="127" height="31" align="right" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><? if($cramt>0) echo  $cramt; ?></b></font></td>
	</tr>
	
<?	
}










?>
<tr>

<td colspan="2"><hr></td>
<td><hr></td>
<td><hr></td>
<td><hr></td>
</tr>
<?
if($chequeno !='')
{
?>
    <tr  bgcolor="#D7D7FF">
    
    <td   height="31" align="left"   colspan="100%" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Cheque /RTGS No.</b></font>
<font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?=$chequeno?></b></font></td>
    
    </tr>
<?
}
?>

<tr  bgcolor="#D7D7FF">


<td   height="31" align="left"  colspan="2" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?=$narration?></b></font></td>
<td   height="31" align="right" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Total</b></font></td>
<td width="106" height="31" align="right" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?=number_format($netdb,2)?></b></font></td>
<td width="127" height="31" align="right" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?=number_format($netcr,2)?></b></font></td>
</tr>
</table>
<TABLE  width="780" BORDER=1 CELLPADDING=4  align="center" rules="cols">
<tr  >
<td width="253"   height="31" align="left"  ><div align="center"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Prepared By</b></font></div></td>
<td width="253"   height="31" align="left"  ><div align="center"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Received By</b></font></div></td>

<td width="244"   height="31" align="left"  ><div align="center"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Verified By</b></font></div></td>
<td width="243"   height="31" align="right" ><div align="center"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Approved By</b></font></div></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

</table>
<table>
<tr><td colspan="100%">&nbsp;</td></tr>
<tr><td colspan="100%">&nbsp;</td></tr>
</table>
<?
}
?>





 

  
 
    
</table>
</form>
 

