<?php
include('../config/config.php');
include('../classes/classTransaction.php');

$trxOb = new classTransaction;
$account_head_id = 1;

if(isset($_POST['search_by_date'])&&isset($_POST['search_by_date'])&&isset($_POST['to']))
{
	$to = $_POST['to'];
	$from = $_POST['from'];
}
else
{
	$to = date('Y-m-d',time());
	$from = date('Y-m-d',time());
}

$trx_detail = $trxOb->retrieveCashReport($from,$to,$account_head_id,$_SESSION['security']['location_id']);	


/*echo '<pre>';
print_r($trx_detail);
echo '</pre>';*/



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/print.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <link rel="shortcut icon" href="../images/favicon.png">
    <title>Med2TEC Hospital Management Information System</title> 
    <link href="../css/print.css" rel="stylesheet">
    <link href="../datepicker/jquery-ui.css" rel="stylesheet" >  
    <script type="text/javascript" src="../datepicker/jquery-1.9.1.js"></script>
	<script type="text/javascript" src="../datepicker/jquery-ui.js"></script> 
</head>

<body> 
<div align="right"> 
 <SCRIPT LANGUAGE="JavaScript">  
if (window.print) {
document.write('<form class="no-print"><input type=button name=print value="Print" onClick="window.print()"></form>');
}
</script></div>

<section class="wrapper">
<div style="background:#FFF; padding:0px 0px 0; height:auto;">
  <table cellspacing="0" cellpadding="0" width="100%" border="0" style="font-size:11px;">
    <tbody>
      <tr>
        <td align="left" style="background:#fff;"><img alt="" src="../images/org_print_logos/<?php echo $_SESSION['security']['org_id']?>.png" style="width:100%;"></td>
      </tr>
    </tbody>
  </table>
  
</br>

</div>

<div class="row">
          <section class="panel">
            <header class="panel-heading">
              <h2><!-- InstanceBeginEditable name="title" -->OPD CASH REPORT<!-- InstanceEndEditable --></h2>
            </header>

  <br />
  
<!-- InstanceBeginEditable name="main" -->
  <!-- page start-->
                 <table  class="bottomBorder" cellpadding="0" cellspacing="0" width="100%">
                  <thead>
                    <tr>
                      <th width="8%">ID</th>
                      <th width="38%" align="left">Account</th>
                      <th width="16%">Expense (Rs.)</th>
                      <th width="16%">Income (Rs.)</th>
                      <th width="22%" align="center" class="hidden-phone">Balance (Rs.)</th>
                    </tr>
                  </thead>
                  <tbody>
                  	<?php
					$debits_total = 0;
					$credits_total = 0;
					$balance_total = 0;
					if(isset($trx_detail[0]['account_id']))
					{
						
						
						for($t=0;$t<count($trx_detail);$t++)
						{
							if($t%2==0){$class='gradeX';}else{$class='gradeC';}
							
							$accountOb = new classTransaction;
							$accountOb->setAccountID($trx_detail[$t]['account_id']);
							$acc_detail = $accountOb->retrieveAccountByID();
							?>
							<tr class="<?php echo $class;?>">
                                <td><?php echo $trx_detail[$t]['account_id'];?></td>
                                <td align="left"><?php echo $acc_detail[0]['account_name'];?></td>
                                <td align="right">Rs. <?php echo number_format($trx_detail[$t]['debits'],2);?></td>
                                <td align="right">Rs. <?php echo number_format($trx_detail[$t]['credits'],2);?></td>
                                <td align="right">Rs. <?php echo number_format($trx_detail[$t]['balance'],2);?></td>
							</tr>
							<?php
							
							$debits_total += $trx_detail[$t]['debits'];
							$credits_total += $trx_detail[$t]['credits'];
							$balance_total += $trx_detail[$t]['balance'];
						}
					}
				 	?>
                    
                   
                  </tbody>
                  <tfoot>
                   <tr>
                        <td></td>
                        <td align="left">Total</td>
                        <td align="right">Rs. <?php echo number_format($debits_total,2);?></td>
                        <td align="right">Rs. <?php echo number_format($credits_total,2);?></td>
                        <td align="right">Rs. <?php echo number_format($balance_total,2);?></td>
                    </tr>
                  </tfoot>
                </table>
  <!-- page end-->


<!-- InstanceEndEditable -->
</section>
</div>

<!--<p align="center" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; margin-top:260px;"><strong><!--317 A-1, Nursery Stop, Township, Lahore. 
Ph: 042-35151666</strong><br />
For Appointment call at 042-35151666 (bring your Patient ID Card) </p>-->

   <div class="sidepop" style="float:right;">
    <div class="sidepopbutton stemp"><div style="color: rgb(0, 0, 0); text-align: right; font-size: 10px; margin-top: 4px; position: absolute; right: 180px;">© Software by Softusion Inc. 0322 6155 219</div>   
    </div>
</div>

<!--<div class="sidepop" style="float:right;">
    <div class="sidepopbutton stemp"><div style="color:#000; text-align:right; font-size:9px;">© Software designed by Softusion Inc. Contact us at 0322 6155 219</div>   
    </div>
</div>-->


          
</body>
<!-- InstanceEnd --></html>