<?php
include("../../pidbco/pidbjoin.php");

$company = base64_decode($_GET['company']);
$branch = base64_decode($_GET['branch']);
$start = base64_decode($_GET['start']);
$end = base64_decode($_GET['end']);

$sq1 = mysqli_query($con,"SELECT c_comp FROM `p_company` WHERE `cid`='$company' ");
$rs1 = mysqli_fetch_array($sq1);
?>
<html>
<title>Daily Income Branch Wise</title>
<head>
    <link type="text/css" href="css/pdfstyle.css" rel="stylesheet">
    <link type="text/css" href="css/reset.css" rel="stylesheet">
</head>
<body onLoad="window.print();">
<div class="container" >
    <br>
    <div  style="width: 100%;text-align: center;"><img src="invoice/images/bank_book.jpg" /><br>
    </div>
    <br><br>
    <?php
    if(!empty($start))
    {
        list($year,$month,$day) = explode('/', $start);
        ?>
        <p style="font-size: 16px;font-weight: bold;text-transform: uppercase;">FROM &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;<?php echo $day.'-'.$month.'-'.$year; ?>
		<span style=" float:right; margin-right:50px;">Company : <?php echo $rs1['c_comp']; ?></span>
		</p>
		
    <?php
    }
    if(!empty($end))
    {
        list($year,$month,$day) = explode('/', $end);
        ?>
        <p style="font-size: 16px;font-weight: bold;text-transform: uppercase;">TO  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;<?php echo $day.'-'.$month.'-'.$year; ?>
		<?php if($branch != ''){ ?>
		<span style=" float:right; margin-right:50px;">Branch : <?php echo $branch; ?></span>
		<?php } ?>
		</p>
    <?php
    }
    
    ?>
    <br>
    <!-- Heads -->

   
   </div>
    
 <div style="height: 25px;border: 2px solid #000000;width: 120px;float: left;border-right: 0px solid #000000;"><p style="text-align: center;font-weight: bolder; margin-top:0px;">Receipt No. </p></div>
     <div style="height: 25px;border: 2px solid #000000;width: 100px;float: left;border-right: 0px solid #000000;"><p style="text-align: center;font-weight: bolder;margin-top:0px;">Date</p></div>
    <div style="height: 25px;border: 2px solid #000000;width: 175px;float: left;border-right: 0px solid #000000;"><p style="text-align: center;font-weight: bolder;font-size: 14px;margin-top:0px;">Customer</p></div>
    <div style="height: 25px;border: 2px solid #000000;width: 120px;float: left;border-right: 0px solid #000000;"><p style="text-align: center;font-weight: bolder; margin-top:0px;">Order Type</p></div>
    
    <div style="height: 25px;border: 2px solid #000000;width: 100px;float: left;border-right: 0px solid #000000;"><p style="text-align: center;font-weight: bolder; margin-top:0px;">
	Amount</p></div>
	<div style="height: 25px;border: 2px solid #000000;width: 120px;float: left;border-right: 0px solid #000000;"><p style="text-align: center;font-weight: bolder; margin-top:0px;">Cheque No.</p></div>
	<div style="height: 25px;border: 2px solid #000000;width: 120px;float: left;border-right: 2px solid #000000;"><p style="text-align: center;font-weight: bolder; margin-top:0px;">Bank </p></div>
	
	
<div>	
 <?php
if($company != ''){ 
$s1 = " AND `rcomp`='$company'";
} else {
$s1 = "";
}
if($branch !=''){
 $s2 = " AND `rbran`='$branch'";
} else {
$s2 = "";
}
if($start != '' && $end != ''){
 $s3 = " AND `rdate` BETWEEN '$start' AND '$end' ";
} else {
$s3 = "";
}
 $sqq = mysqli_query($con, "SELECT * FROM `p_receipts` WHERE `ramnt_type`='Cheque' ".$s1.$s2.$s3);
 while($res = mysqli_fetch_array($sqq)){

  $cusid = $res['rcust'];
   $sq2 = mysqli_query($con,"SELECT cname FROM `p_customers` WHERE `cid`='$cusid' ");
 $rs2 = mysqli_fetch_array($sq2);
 $rorder = $res['rorder'];
 $sq1 = mysqli_query($con,"SELECT ordr_type FROM `p_orders` WHERE `oid`='$rorder' ");
 $rs1 = mysqli_fetch_array($sq1);
	  
	  
	  $arrEventSeatArrangement[] = array(	"recno"	    => $res['ridentity'],
									"recdate" 	=> $res['rdate'],
									"cust" 	=> $rs2['cname'],
									"ordrtype" 	=> $rs1['ordr_type'],
									"amnytype" 	=> $res['ramnt_type'],
									"amount" 	    => $res['ramount']
								   );	

	   }

	
 $lastChar = '';
sort($arrEventSeatArrangement, SORT_NATURAL | SORT_NUMERIC); 													
if(is_array($arrEventSeatArrangement) && count($arrEventSeatArrangement)>0){
foreach($arrEventSeatArrangement as $seatArrangement){
?>
	
	<div style="height: 18px;width: 120px;float: left;border-bottom: 2px solid #000000;border-left: 2px solid #000000;overflow: hidden;"><p style="margin-left: 5px;font-size: 11px;font-weight: bold;text-align: center;margin-top:0px;"><?php echo $seatArrangement['recno']; ?></p></div>             
    <div style="height: 18px;width: 100px;float: left;border-left: 2px solid #000000;border-bottom: 2px solid #000000;border-right: 2px solid #000000;overflow: hidden;"><p style="margin-left: 5px;font-size: 11px;font-weight: bold;text-align: center;margin-top:0px;"><?php echo $seatArrangement['recdate']; ?></p></div>
    <div style="height: 18px;width: 175px;float: left;border-bottom: 2px solid #000000;border-right: 2px solid #000000;overflow: hidden;"><p style="margin-left: 5px;font-size: 11px;font-weight: bold;text-align: center;margin-top:0px;"><?php echo $seatArrangement['cust']; ?></p></div>
    <div style="height: 18px;width: 120px;float: left;border-bottom: 2px solid #000000;border-right: 2px solid #000000;overflow: hidden;"><p style="margin-left: 5px;font-size: 11px;font-weight: bold;text-align: center;margin-top:0px;"><?php echo $seatArrangement['ordrtype']; ?></p></div>
    
    <div style="height: 18px;width: 100px;float: left;border-bottom: 2px solid #000000;border-right: 2px solid #000000;overflow: hidden;"><p style="margin-left: 5px;font-size: 11px;font-weight: bold;text-align: center;margin-top:0px;"><?php echo $seatArrangement['amount']; ?></p></div>
   
   <div style="height: 18px;width: 120px;float: left;border-bottom: 2px solid #000000;border-right: 2px solid #000000;overflow: hidden;"><p style="margin-left: 5px;font-size: 11px;font-weight: bold;text-align: center;margin-top:0px;"><?php echo $seatArrangement['rcheque']; ?></p></div>
   <div style="height: 18px;width: 120px;float: left;border-bottom: 2px solid #000000;border-right: 2px solid #000000;overflow: hidden;"><p style="margin-left: 5px;font-size: 11px;font-weight: bold;text-align: center;margin-top:0px;"><?php echo $seatArrangement['rbank']; ?></p></div>
 <?php } } ?> 
  </div> 


<!-- END -->
</div>
</div>
</body>
</html>
