<div class="container-title"><?php echo $_translator->_getTranslation('Ventas')?></div>
<div class="clear"></div>
<div id="flashmessenger"><?php $flashmessenger->showMessage();?></div>
<div id="container-main">
    <?php
    if ($ventaPag) {
        $varsQuery = $venta->getQueryVarsFromGET(array('action','pag','send'));?>
        <div class="links-options">            
            <?php if(isset($_fromCobro)){?> 
                <a href="/Controller/Cobro.php?action=buscarv" class="btn btn-sm btn-default"><span class="fa fa-plus fa-lg"></span> <?php echo $_translator->_getTranslation('Nueva busqueda');?></a>
              <?php }else{?>
                <a href="/Controller/Venta.php?action=buscarv" class="btn btn-sm btn-default"><span class="fa fa-plus fa-lg"></span> <?php echo $_translator->_getTranslation('Nueva busqueda');?></a>
              <?php }?>                
                <a href="/Controller/Venta.php" class="btn btn-sm btn-default"><span class="fa fa-plus fa-lg"></span> <?php echo $_translator->_getTranslation('Agregar nueva venta');?></a>
                <a href="/Controller/Venta.php?action=excel&flag=search&<?php echo$varsQuery?>" class="btn btn-sm btn-default"><span class="fa fa-file-excel-o fa-lg"></span> <?php echo $_translator->_getTranslation('Excel');?></a>
            <hr>
        </div>

        <table class="table table-condensed table-hover table-striped">
        <thead class="table-header">
            <th style="width:60px"><?php echo $_translator->_getTranslation('Editar')?></th>
            <th style="width:40px"><?php echo $_translator->_getTranslation('#Venta')?></th>
            <th><?php echo $_translator->_getTranslation('#OCC')?></th>
            <th><?php echo $_translator->_getTranslation('#FacProv')?></th>
            <th><?php echo $_translator->_getTranslation('Fecha')?></th>
            <th><?php echo $_translator->_getTranslation('Cliente')?></th>
            <th><?php echo $_translator->_getTranslation('Total')?></th>
            <th><?php echo $_translator->_getTranslation('Balance')?></th>
            <th><?php echo $_translator->_getTranslation('Status')?></th>
            <th><?php echo $_translator->_getTranslation('Imprimir')?></th>
        </thead>
        <tbody><?php
        while ($ventaData = $ventaPag->fetch_object()) {?>
            <tr>
                <td><?php 
                    if($controller == 'Venta'){?>
                        <a class="btn btn-sm btn-default" href="Venta.php?action=edit&id=<?php echo $ventaData->factura?>"><i class="fa fa-pencil"></i></a><?php 
                     }elseif($controller == 'Cobro'){?>
                        <a class="btn btn-sm btn-default" href="Cobro.php?action=insert&id=<?php echo $ventaData->factura?>"><i class="fa fa-pencil"></i></a><?php 
                     }?>
                     <a class="btn btn-sm btn-danger" 
                        onclick="return cancelSale(<?php echo $ventaData->factura?>,this);" 
                        href="Venta.php?action=delete&id=<?php echo $ventaData->factura?>" target="iframe" ><i class="fa fa-trash"></i></a>
                </td>
                <td style="text-align: right"><?php echo $ventaData->factura;?></td>            
                <td style="text-align: center"><?php echo $ventaData->po;?></td>
                <td style="text-align: center"><?php echo $ventaData->ref_fac;?></td>
                <td><?php echo $ventaData->fecha;?></td>
                <td><?php echo $ventaData->cliente;?></td>
                <td style="text-align: right">$ <?php echo number_format($ventaData->total,2);?></td>
                <td style="text-align: right">$ <?php echo number_format($ventaData->saldoPendiente,2);?></td>
                <td><?php echo $_translator->_getTranslation($ventaData->status);?></td>
                <td><a class="a-cursor-pointer" onclick="javascript: void window.open('/Controller/Venta.php?action=pdf&flag=shipventa&id=<?php echo $ventaData->factura;?>','','width=700,height=500,status=1,scrollbars=1,resizable=1')">Bill</a>
                |
                <a class="a-cursor-pointer" onclick="javascript: void window.open('/Controller/Venta.php?action=pdf&flag=invoice&id=<?php echo $ventaData->factura;?>','','width=700,height=500,status=1,scrollbars=1,resizable=1')"><?php echo $_translator->_getTranslation('Factura')?></a></div>
                </td>
            </tr><?php
        }?>
        </table>
        <div class="pagination">
            <?php echo $pagObj->showLinks(); ?>
        </div>
    <?php
    }else {?>
        <p><?php echo $_translator->_getTranslation('No se encontraron resultados.')?></p>
    <?php
    }?>
</div>