<?
header('Content-type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename=balace_general.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 BalanceGeneralBean();

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

$o_class = new BalanceGeneralBL();
$a_ObjectBean = $o_class->busquedaBalanceGeneral($o_ObjectBean);

if(!is_array($a_ObjectBean) && isset($a_ObjectBean)){
  $obj = $a_ObjectBean;
  $a_ObjectBean = null;
  $a_ObjectBean[] = $obj;  
}
ViewResponse::getInstance()->setMethodAjax();
?>
<table class="marco" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
  <td>
    <table class="grid" width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr height="23">
        <th width="2%" >Nro</th>
        <th width="8%" align="left"  >Sucursal</th>
        <th width="3%" align="left"  >F.Balance</th>
        <th width="8%" align="left"  >Comentario</th>
		<th width="6%"  align="right"  >Total</th>
		<th width="6%" align="left"  >U.Registro</th>
		<th width="6%" align="left"  >F.Registro</th>
        
      </tr>
      <? if(count($a_ObjectBean)>0){ ?>
        <? foreach ($a_ObjectBean as $iKey => $o_objBean){ ?>
        <tr onClick="TR_click(this);">
          <td class="chk"><?=($tamanioPag)*($page-1)+($iKey+1)?></td>
          <td><?=$o_objBean->getNombreSucursal() ?></td>
          <td><?=$o_objBean->getFecha() ?></td>
          <td><?=$o_objBean->getDescripcion()?>&nbsp;</td>
          <td align="right"><?php 
          			$total += $o_objBean->getTotal();
          			echo number_format($o_objBean->getTotal(),2);?></td>
          <td align="left"><?=$o_objBean->getUsuarioCreacion()?></td>
          <td align="left"><?=$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>
         <td>&nbsp;</td>
	    </tr>
    </table>
  </td>
</tr>

<tr>
  <td>Total Registros: <?=count($a_ObjectBean)?></td>
</tr>
</table>