<?php use_helper('UrlFunctions');

$o_BalanceDiaBean = new BalanceDiaBean();

$o_BalanceDiaBean->setIdSucursal($id);	
$o_BalanceDiaBean->setFechaBalance($Fecha);
$o_BalanceDiaBean->setFechaBalanceFinal($Fecha);

$o_BalanceDiaDP = new BalanceDiaDP($o_BalanceDiaBean);
$a_o_resumenDiario = $o_BalanceDiaDP->select();
$a_Header = $o_BalanceDiaDP->selectHeader();
?>
<img src="/images/common/spacer.gif" width="10">
 <?php
if(is_array($a_Header)){
	foreach ($a_Header as $key => $o_resumenHeader) {
		?>
<table class="cuerpo" width="98%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="0">
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td class="titleBody">
            <span class="subtitle"><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:::&nbsp;Ficha de Balance Diario</I></span></td>
          <td align="right" valign="baseline">&nbsp;<img src="/images/common/buttons/btnPdf.gif" title="Balance del Día - Detalle " onClick="parent.objMainTab.reqBody('<?=buildUrl('bdi/pdf_det/idSucursal/'.$o_resumenHeader->getIdSucursal().'/fecha/'.$o_resumenHeader->getFechaBalance());?>','001');";" style="cursor:pointer" /></td>
        </tr>
      </table>
    </td>
  </tr>
      <script type="text/javascript">
        validatePass = function(){
          
            valid.onSubmit = false;
          
        }
      </script>
  <tr>
    <td valign="top">
      <form id="form1" name="form1" method="POST">
      <input type="hidden" name="control" value="1">
        <table hspace="20px" class="marco" width="99%">
          <tr>
            <td valign="top">
               <table width="100%" border="0" cellpadding="5" cellspacing="0" style="background: #E3E9E2">
          		<tr>
    				  <td height="0">
    				 
    					<table width="100%" border="1" cellpadding="5" cellspacing="0">
      					
									<tr>
		          						<td width="20%"><label class="label">Sucursal</label></td>		
		      							<td><label class="label1"><?php echo $o_resumenHeader->getNombreSucursal();?></label></td>		
		          					</tr>
									<tr>
		          						<td><label class="label">Administrador</label></td>		
		      							<td><label class="label1"><?php echo $o_resumenHeader->getNombreAdministrador();?></label></td>		
		          					</tr>
		          					<tr>
		          						<td><label class="label">Fecha</label></td>		
		      							<td><label class="label1"><?php echo $o_resumenHeader->getFechaBalance();?></label></td>		
		          					</tr>
		          					<tr>
		          						<td><label class="label">Comentario</label></td>		
		      							<td><label class="label1"><?php echo $o_resumenHeader->getDescripcion();?>&nbsp;</label></td>		
		          					</tr>
									
	    					
	    				</table>   							
    				</td>
                </tr>
              </table>   	
              <table width="100%" border="0" cellpadding="5" cellspacing="0" style="background: #E3E9E2">
          		<tr>
    				  <td height="0">
    				 
    					<table width="100%" border="1" cellpadding="5" cellspacing="0" class="grid2">
      					 <tr>
      						<th align="left">Nombre</th>		
      						<th align="center">T.Caja</th>		
      						<th align="center">T.Prestamos</th>		
      						<th align="center">T.Pagos</th>	
      						<td align="center">T.Pagos Mora</td>
      						<th align="center">Sobrantes</th>
          					<th align="center">Faltante</th>			
      						<th align="center">T.G.Admin.</th>		
      						<th align="center">Total</th>
      					 </tr>
      					 
      					 <?
	    					if(is_array($a_o_resumenDiario)){
	    						foreach ($a_o_resumenDiario as $key => $o_resumenDiario) {
									?>
									<tr>
		          						<td><label class="label1"><?php echo mb_strtoupper($o_resumenDiario->getNombreColaborador())?></label></td>		
		          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#009933"><?php $TotalCaja += $o_resumenDiario->getTotalCaja();echo number_format(round((float)$o_resumenDiario->getTotalCaja(),2),2)?></label></td>		
		          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#FF9900"><?php $TotalPrestamo += $o_resumenDiario->getTotalPrestamos();echo number_format(round((float)$o_resumenDiario->getTotalPrestamos(),2),2)?></label></td>		
		          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#3300FF"><?php $TotalPago += $o_resumenDiario->getTotalPagos();echo number_format(round((float)$o_resumenDiario->getTotalPagos(),2),2)?></label></td>		
		          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#3300FF"><?php $TotalPagoMora += $o_resumenDiario->getTotalPagosMora();echo number_format(round((float)$o_resumenDiario->getTotalPagosMora(),2),2)?></label></td>		
		          						<td align="right"><label class="label"><?php $TotalSobrantes += $o_resumenDiario->getTotalSobrantes();echo "S/.&nbsp;".number_format(round($o_resumenDiario->getTotalSobrantes(),2),2)?></label></td>
		          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#FF0000"><?php $TotalFaltantes += $o_resumenDiario->getTotalFaltantes();echo "S/.&nbsp;".number_format(round($o_resumenDiario->getTotalFaltantes(),2),2)?></label></td>				
		          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#3300FF"><?php $TotalGastoAdmin += $o_resumenDiario->getTotalGastoAdministrativo(); echo number_format(round($o_resumenDiario->getTotalGastoAdministrativo(),2),2)?></label></td>		
		          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#000000"><?php $Total += round($o_resumenDiario->getTotalCaja(),2) + round($o_resumenDiario->getTotalPagos(),2) +$o_resumenDiario->getTotalPagosMora() - round($o_resumenDiario->getTotalPrestamos(),2) + round($o_resumenDiario->getTotalGastoAdministrativo(),2)+round($o_resumenDiario->getTotalSobrantes(),2)-round($o_resumenDiario->getTotalFaltantes(),2);
		          														echo number_format(round((round($o_resumenDiario->getTotalCaja(),2) + round($o_resumenDiario->getTotalPagos(),2) + $o_resumenDiario->getTotalPagosMora() - round($o_resumenDiario->getTotalPrestamos(),2) + $o_resumenDiario->getTotalGastoAdministrativo()),2) +round($o_resumenDiario->getTotalSobrantes(),2)-round($o_resumenDiario->getTotalFaltantes(),2),2)?></label></td>		
		          					</tr>
									<?php    							
	    						}
	    					}
	    				?>  
	    					<tr>
          						<td align="right"><label class="label">&nbsp;Totales:</label></td>		
          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#009933"><b><?=number_format(round($TotalCaja,2),2)?></b></label></td>		
          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#FF9900"><b><?=number_format(round($TotalPrestamo,2),2)?></b></label></td>		
          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#3300FF"><b><?=number_format(round($TotalPago,2),2)?></b></label></td>	
          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#3300FF"><b><?=number_format(round($TotalPagoMora,2),2)?></b></label></td>
          						<td align="right"><label class="label" style="font:12px; font-weight:bold;"><b><?="S/.&nbsp;".number_format(round($TotalSobrantes,2),2)?></b></label></td>
          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#FF0000"><b><?="S/.&nbsp;".number_format(round($TotalFaltantes,2),2)?></b></label></td>	
          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#3300FF"><b><?=number_format(round($TotalGastoAdmin,2),2)?></b></label></td>		
          						<td align="right"><label class="label" style="font:12px; font-weight:bold; color:#000000"><b><?=number_format(round($Total,2),2)?></b></label></td>		
          					</tr>
	    				</table>
						 <table width="100%" border="0" cellspacing="0" cellpadding="0">
							  <tr>
								 <td><img src="/images/common/spacer.gif" width="10"></td>
							  </tr>
							  <tr>
								<td align="center">
								  <input type="hidden" name="typeSubmit" id="typeSubmit">
								  <input class="button" type="button" value="Volver" onclick="parent.objMainTab.reqBody('<?=buildUrl('bdi/list')?>','001')"/>
								</td>
							  </tr>
							  <tr>
								<td height="10">&nbsp;</td>
							  </tr>
							</table>
    							
    				</td>
                </tr>
      </table>
      </form>
			<script type="text/javascript">
				var valid = new Validation('form1', {immediate : true});
			</script>
    </td>
  </tr>
</table>
<?php    							
		}
	}
?>