<?php 
include_once("../connect.php");
include_once("../session.php");


$isAdmin = $_SESSION['isAdmin'];
if (!$isAdmin) {
	header("Location: logout.php");
}


 ?>
 <!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title><?= $config['CompanyName'] ?></title>
  
      <!-- Bootstrap -->
      <link href="<?= $root ?>css/bootstrap.min.css" rel="stylesheet">
      <link rel="stylesheet" href="<?= $root ?>css/bootstrap-combobox.css" />
  
      <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
      <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
      <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
            <!-- Include all compiled plugins (below), or include individual files as needed -->
            <script src="<?= $root ?>js/bootstrap.min.js"></script>
        	 <script src="<?= $root ?>js/bootstrap-combobox.js"></script>
            <script type="text/javascript">
              $(document).ready(function(){
        //        $('.grpline').css("width", "100px");
              });
            </script>
 
      <![endif]-->
 	<link rel="stylesheet" href="<?= $root ?>css/styles.css"/>
	<style>
		.paymentSummaryHeader{
			font-weight: bold;
		}
		
	</style>
    </head>
    <body>
    
        <?php 
        		include("navbar.php"); 
        		
 
        ?>     
 
    
    <!-- Stack the columns on mobile by making one full-width and the other half-width -->
 <?php
 $depositID = $_REQUEST['id'];
 $deposit = new PaymentDeposit($depositID);
 
 
 ?>
 <div class="container-fluid" style="padding-top: 5px;">
 	<div class="row">
 	  <div class="col-xs-5">
 	  	<img class="img-responsive" style="width: 200px;" src="<?= $root ?>img/<?= $config['Logo'] ?>" alt="" />
 	  	
 	  </div>
  	  <div class="col-xs-2"></div>
 	  <div class="col-xs-5">
 		  <h3>Deposit</h3>
 		  <p>
 		  	<h1><span style="padding-left: 20px;"><b><?= $deposit->DepositID ?></b></span></h1>
			
 		  <b>Date: </b><?= date("m/d/Y",strtotime($deposit->DepositDate)) ?><br>
		  <b>Creation Date: </b><?= date("m/d/Y h:i a",strtotime($deposit->CreationDate)) ?><br>
		  <b>Created By: </b><?php
		  echo $deposit->Username;
		  //$createdBy = new Administrator($deposit->Username);
		  //echo $createdBy;
		  
		  ?><br>
		  
 		  
 		  
          </p>
          
 	  </div>
	</div> 
	<div class="row">
		
			<div class="col-xs-8 col-md-6">
				<h4>Checks</h4>
				<table class="table table-condensed" style="font-size: small;">
				  <thead>
					<tr>
					  <th style="width: 50%">Customer</th>
					  <th style="width: 25%">Check No.</th>
					  <th style="width: 25%">Check Amount</th>
					</tr>
				  </thead>
				  <tbody>
				  <?php
						
						
						$checksCount = 0;
						$totalChecks = 0;
						foreach($deposit->Checks as $check){
							
						
						$checksCount++;
						$totalChecks += $check->Amount;
				  ?>
					  <tr>
							  <td>
								  <span class="itemInfo"><?= $check->CustomerName ?></span>
							  </td>						
							  <td>
								  <span class="itemInfo"><?= $check->Number ?></span>
							  </td>
							  <td>
								  <span class="itemInfo"><?= moneyFormat($check->Amount) ?></span>
							  </td>
							  
					  </tr>
					  <?php 
					  
					  }?>
					  <tr>
							<td></td>
						  <td><b><?= $checksCount ?></b> <?= $checksCount==1?"check":"checks" ?></td>
						  <td><b><?= moneyFormat($totalChecks) ?></b></td>
						 
					  </tr>
					
				  </tbody>
				</table>
			</div>
		
	</div>
	<div class="row">
		<div class="col-xs-4 col-md-6">
				<h4>Cash</h4>
				<span>Total Cash: <b><?= moneyFormat($deposit->TotalCash) ?></b></span>
			</div>
	</div>
	<div class="row">
		<div class="col-xs-4 col-md-6">
				<h4>Grand Total</h4>
				<span>Grand Total: <b><?= moneyFormat($deposit->TotalCash+$totalChecks) ?></b></span>
			</div>
	</div>
	<br>
	<br>
     <div>
        <span><b><big>Notes: </big></b><?= $deposit->Notes ?></span>
     </div>
</div>
 
        <div class="panel panel-default">
          <div class="panel-body">
           
		   
          </div>
        </div>
        
    </body>
  </html>