<?php
//header("Content-Type: text/html; charset=iso-8859-1");
header('Content-type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename=balace_diario.xls");
set_time_limit(150);
ini_set('memory_limit', '96M');
header("Content-Type: application/xhtml+xml; charset=iso-8859-1");
use_helper('UrlFunctions');
$o_ObjectBean = new BalanceDiaBean();

if($cboSucursal   !=""){ $o_ObjectBean->setIdSucursal($cboSucursal); }
if($txtFechaInicial   !=""){ $o_ObjectBean->setFechaBalance($txtFechaInicial); }
if($txtFechaFinal   !=""){ $o_ObjectBean->setFechaBalanceFinal($txtFechaFinal); }

$o_class = new BalanceDiaBL();
$a_ObjectBean = $o_class->busquedaBalanceDiaHeader($o_ObjectBean);
    
ViewResponse::getInstance()->setMethodAjax();
?>
<table class="marco" border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
  <td>
    <table class="grid" width="100%" border="1" cellpadding="0" cellspacing="0">
      <tr height="23">
        <th width="2%" >Nro</th>
        <th width="8%" align="left"  >Sucursal</th>
        <th width="8%" align="left"  >F.Balance</th>
        <th width="8%" align="left"  >Comentario</th>
		<th width="5%" align="right"  >Total</th>
		
		<th width="8%" align="left"  >U.Registro</th>
		<th width="8%" align="left"  >F.Registro</th>
      </tr>
      <? if(count($a_ObjectBean)>0){ ?>
        <? foreach ($a_ObjectBean as $iKey => $o_objBean){ ?>
        <tr >
          <td ><?=($iKey+1)?></td>
          <td><?=$o_objBean->getNombreSucursal() ?></td>
          <td><?=$o_objBean->getFechaBalance() ?></td>
          <td><?=$o_objBean->getComentario()?></td>
          <td align="right"><?php 
          $total += $o_objBean->getSumaTotal();
          echo number_format($o_objBean->getSumaTotal(),2)?></td>
          <td><?=$o_objBean->getUsuarioCreacion()?></td>
          <td><?=$o_objBean->getFechaCreacion()?></td>
        </tr>
        <? } ?>
      <? }else{ ?>
      <tr>
        <td colspan="7" align="center">No se produjo resultado</td>
      </tr>
      <? } ?>
       <tr>
      	 <td>&nbsp;</td>
      	 <td>&nbsp;</td>
      	 <td>&nbsp;</td>
      	 <td align="right"><b>Total:</b></td>
         <td align="right"><b><?=number_format($total,2);?></b></td>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
       
	    </tr>
    </table>
  </td>
</tr>
<tr>
  <td>Total Registros: <?=count($a_ObjectBean)?></td>
</tr>
</table><?
 ini_set('memory_limit', '32M');
?>    
  