<?php 
$pgMod="income";
$pgAct="view";
if(isset($_GET['action']) && trim($_GET['action'])!='')
		$pgAct=strtolower($_GET['action']);


if(isset($_SESSION['msg']) && $_SESSION['msg']!="")
{
	?>
	<div class="alert alert-success">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-thumbs-up-alt"></i> <b>Notice</b><?php echo $_SESSION['msg'] ?></i>
	</div>
	<?php
	unset($_SESSION["msg"]);
}
if(is_array($alert_err) && count($alert_err)>0)
{
	?>
	<div class="alert alert-error">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-warning-sign"></i> <b>Notice</b> <?php echo $alert_err[0] ?></i>
	</div>
	<?php
}

?>

<!-- nitish code start-->

<form method="post" action="">.
    <div class="row-fluid">
        <div class="control-group">
          <div class="span3">
            	<select name="pmode">
                    <option value="all">All Bank</option>
                     <?php 
					$Expensemode=$db->getRows("select * from bank where school_id='".$_SESSION["admin"]["school_id"]."' ");
					
					?>
                      <?php foreach($Expensemode as $Expense){
					  	?><option value="<?php echo $Expense["id"] ?>"><?php echo $Expense["bank"] ?></option><?php
					  ?>
                    <?php } ?>
                    </select>
            </div>
            <div class="span3"><input required type="date" id="tfrom" name="tfrom" class="input-block-level" value="<?php if($_POST)echo $_POST["tfrom"];?>"></div>
            <div class="span3"> <input required type="date" id="tto" name="tto" class="input-block-level" value="<?php if($_POST)echo $_POST["tto"];?>"></div>
            <div class="span3"><input type="submit" class="btn" /></div>
        </div>
    </div>
</form>

<!-- nitish code end-->
 
<div class="row-fluid"><div class="span12"><div class="top-bar">
<h3><i class="icon-eye-open"></i> Bank Balance Sheet </h3>
	<div style="float:right; margin-top:5px">
        <a onclick="printDiv('printableDiv')" class="btn btn-primary" target="_blank">Print</a>
    </div>
</div>
<div class="well no-padding" id="printableDiv">
<?php
    $aryPgAct=array("src"=>"Account", "page_id"=>$pgMod,"action"=>"add");
    
    $between="";
    if(isset($_POST["tfrom"]) && isset($_POST["tto"])){
    $between=" and udate between '".$_POST["tfrom"]."' and '".$_POST["tto"]."' ";
    
    if($_POST["pmode"]=='all')
    {
        $aryList=$db->getRows("SELECT * FROM banktransaction where school_id='".$_SESSION["admin"]["school_id"]."' and type='deposit' and status=1 and amount!=0 and session='".$_SESSION["admin"]["session"]."' $between ");
        $aryList_ex=$db->getRows("SELECT * FROM banktransaction where school_id='".$_SESSION["admin"]["school_id"]."' and type='withdraw' and status=1 and amount!=0 and session='".$_SESSION["admin"]["session"]."' $between ");
    }
    else
    {
        $aryList=$db->getRows("SELECT * FROM banktransaction where school_id='".$_SESSION["admin"]["school_id"]."' and type='deposit' and status=1 and amount!=0 AND bankname='".$_POST["pmode"]."' and session='".$_SESSION["admin"]["session"]."'  $between ");
        $aryList_ex=$db->getRows("SELECT * FROM banktransaction where school_id='".$_SESSION["admin"]["school_id"]."' and type='withdraw' and status=1 and amount!=0 AND bankname='".$_POST["pmode"]."' and session='".$_SESSION["admin"]["session"]."' $between "); 
    }

?>

	<center>
	    <h5>
	        <p style="float:right"> Date: 
    			<?php if(strtotime($tndate)==strtotime($_POST["tfrom"])){echo date("d-M-Y",strtotime($tndate));?> - <?php echo date("l",strtotime($tndate));}
    			else echo date("d-M-Y",strtotime($_POST["tfrom"])) ." to ".date("d-M-Y",strtotime($tndate)); ?>
			</p>
			<p>Bank Balance Sheet</p>
		</h5>
	</center>

	<div style="font-size: 16px;clear: both;background-color: #D5DA13;font-weight: bold;padding: 5px;color: #000;text-align: center;  border-top: 1px solid #000;border-bottom: 2px solid #FA0606;border-left: 1px solid #000;border-right: 1px solid #000;"> Profit & Loss Detail</div>  
	<table style="width:100%; font-size:13px;margin:0;border-top:1px solid #FA0606 ;border-bottom:1px solid #000;text-align: center;color: #1224A5;font-weight: 800;" cellpadding="5" cellspacing="0">
		<tr style="background-color: #FFEA15;font-weight: 800;padding: 0px;color: #000;">
			<td colspan="3" style="border-right:2px solid #FA0606;border-left:2px solid #FA0606;border-bottom: 2px solid #FA0606; text-align:center">Deposit</td>
			<td colspan="3" style="border-right:2px solid #FA0606;border-bottom: 2px solid #FA0606; text-align:center">Withdrawal</td>
		</tr>

		<tr style="background-color: #FFEA15;font-weight: 800;padding: 0px;color: #000;">
			<td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;border-left:2px solid #FA0606;">S. No.</td> 
			<td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">Deposit Detail</td>
			<td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">Amount</td>
            <td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">S. No.</td> 
			<td width="12%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">Withdrawal Detail</td>
			<td width="5%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;">Amount</td>
		</tr>

        <tr style="background-color: #FFEA15;font-weight: 800;padding: 0px;color: #000;">

            <td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;border-left:2px solid #FA0606;">
                <?php foreach($aryList as $clist){ $i++; 
                    echo "$i<br>";
                }?>
            </td>

            <td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;border-left:2px solid #FA0606;text-align:left;">
                <?php foreach($aryList as $clist){ $i++; 
                    echo "$clist[detail]<br>";
                }?>
            </td>

            <td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;border-left:2px solid #FA0606;text-align:right;">
                <?php foreach($aryList as $clist){ $i++; 
                    echo number_format($clist['amount'],2)."<br>";
                    $total+=$clist["amount"];
                }?>
            </td>

            <td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;border-left:2px solid #FA0606;">
                <?php foreach($aryList_ex as $clist){ $j++; 
                    echo "$j<br>";
                }?>
            </td>

            <td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;border-left:2px solid #FA0606;text-align:left;">
                <?php foreach($aryList_ex as $clist){ $j++; 
                    echo "$clist[detail]<br>";
                }?>
            </td>

            <td style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;border-left:2px solid #FA0606;text-align:right;">
                <?php foreach($aryList_ex as $clist){ $j++; 
                    echo number_format($clist['amount'],2)."<br>";
                    $total1+=$clist["amount"];
                }?>
            </td>
            
        </tr>

        <tr style="background-color: #FFEA15;font-weight: 800;padding: 0px;color: #000;">
			<td width="7%" style="border-bottom: 1px solid #000;border-left:2px solid #FA0606;"></td> 
			<td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;" align="left">Total</td>
			<td width="7%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;" align="right"><?php echo number_format($total,2); ?></td>
            <td width="7%" style="border-bottom: 1px solid #000;"></td> 
			<td width="12%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;" align="left">Total</td>
			<td width="5%" style="border-right:2px solid #FA0606;border-bottom: 1px solid #000;" align="right"><?php echo  number_format($total1,2); ?></td>
		</tr>

	</table>

	<?php
        }
    ?>
    <br>
        <center><span  style="font-size: 21px !important;  color:#F00;">Net Profit: <?php echo number_format(($total-$total1),2); ?></span></center>
    <br>
</div>


</div>

</div>
<?php

?>
<!-- / Forms -->
<style>
<!-- CSS goes in the document HEAD or added to your external stylesheet -->
<style type="text/css">
table.gridtable {
	font-family: verdana,arial,sans-serif;
	font-size:11px;
	color:#333333;
	border-width: 1px;
	border-color: #666666;
	border-collapse: collapse;
}
table.gridtable th {
	border-width: 1px;
	padding: 3px;
	border-style: solid;
	border-color: #666666;
	background-color: #dedede;
}
table.gridtable td {
	border-width: 1px;
	padding: 3px;
	border-style: solid;
	border-color: #666666;
	background-color: #ffffff;
}
</style>
<!-- Table goes in the document BODY -->


</style>