<?php use_helper('Javascript','Number')?>
<div id="comisionados_">
<?php if(count($comisionados_planta) > 0 || count($comisionados_contrato) > 0):?>
  <table class="show">
    <tr><th colspan="3">Comisionados programados</th></tr>
    <tr>
      <th>Nombre</th>    
      <th>Tipo comisionado</th>
      <th>Total comision</th>
    </tr>
    <?php $total = 0?>
    <?php $i = 0?>
    <?php foreach($comisionados_planta as $planta):?>
    <?php $suma = ComisionadosObjsPeer::getSumaObjetosComisionado($planta->getIdComision(),$planta->getNitocc())?>
      <tr>
        <td><?php echo $planta->getTerceros()->getRazsoc()?></td>
        <td align="center">PLANTA</td>
        <td align="right"><?php echo format_number($suma)?></td>
      </tr>
      <?php $i++?>
      <?php $total += $suma?>
    <?php endforeach?>
    <?php foreach($comisionados_contrato as $contrato):?>
    <?php $suma1 = ComisionadosObjsPeer::getSumaObjetosComisionado($contrato->getIdComision(),$contrato->getNitocc())?>
      <tr>
        <td><?php echo $contrato->getTerceros()->getRazsoc()?></td>
        <td align="center">CONTRATO</td>
        <td align="right"><?php echo format_number($suma1)?></td>
      </tr>
      <?php $i++?>
      <?php $total += $suma1?>
    <?php endforeach?>
    <tr>
      <th colspan="2">Total por <?php echo $i?> comisionados</th>
      <td align="right"><b><?php echo format_number($total)?></b></td>
    </tr>
  </table>
<?php else:?>
  <div class="warning">No existen comisionados programados</div>
<?php endif?>
</div>