<div class="container-title"><?php echo $_translator->_getTranslation('Venta'); if($form->getId()!= '')echo ' # '.$form->getId();?></div>
<div class="clear"></div>
<div id="flashmessenger"><?php $flashmessenger->showMessage();?></div>
<div id="container-main"><?php
    if($action == 'edit'){ 
        echo $venta->getBackButton();?>
       <div class="links-options">
           <a href="/Controller/Venta.php" class="btn btn-sm btn-default"><span class="fa fa-plus fa-lg"></span> <?php echo $_translator->_getTranslation('Agregar nuevo');?></a>
           <a id="linkSendMail" href="#sendMail" role="button" data-toggle="modal" class="btn btn-sm btn-default"><i class="fa fa-envelope fa-lg"></i> Mail</a>
           <a href="" class="btn btn-sm btn-default" onclick="javascript: void window.open('/Controller/Venta.php?action=pdf&flag=shipventa&id=<?php echo $form->getId();?>','','width=700,height=500,status=1,scrollbars=1,resizable=1')"><i class="fa fa-file fa-lg" ></i> <?php echo $_translator->_getTranslation('Bill');?></a>
           <a href="" class="btn btn-sm btn-default" onclick="javascript: void window.open('/Controller/Venta.php?action=pdf&flag=invoice&id=<?php echo $form->getId();?>','','width=700,height=500,status=1,scrollbars=1,resizable=1')"><i class="fa fa-file fa-lg" ></i> <?php echo $_translator->_getTranslation('Factura');?></a>
           <a href="" class="btn btn-sm btn-default" onclick="javascript: void window.open('/Controller/Venta.php?action=pdf&flag=pickticket&id=<?php echo $form->getId();?>','','width=700,height=500,status=1,scrollbars=1,resizable=1')"><i class="fa fa-file fa-lg" ></i> <?php echo $_translator->_getTranslation('Pick Ticket');?></a>        
           <!-- Split button -->
                <div class="btn-group" style="text-align: left">
                  <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo $_translator->_getTranslation('Mas opciones')?> <span class="caret"></span></button>                                
                  <ul class="dropdown-menu pull-right">
                      <li><a href="/Controller/Cobro.php?action=insert&id=<?echo $form->getId()?>"><i class="fa fa-file" ></i> <?php echo $_translator->_getTranslation('Recibir pago');?></a></li>
                      <li><a href="Reportes-finanzas.php?reporte=saldo_pendiente_ventas_detalles&output=pantalla&idCliente=<?php echo $form->getValueElement('cliente')?>&fi&ff"><i class="fa fa-file" ></i> <?php echo $_translator->_getTranslation('CxC de cliente');?></a></li>
                      <li><a onclick="return cancelSale(<?php echo $form->getId()?>,this);" href="Venta.php?action=delete&id=<?php echo $form->getId()?>" target="iframe" ><i class="fa fa-trash"></i> <?php echo $_translator->_getTranslation('Eliminar venta')?></a></li>
                  </ul>
                </div>
           <hr/>
       </div>
   <?php }?>    
       <form name="<?php echo $form->getName() ?>" action="<?php echo $form->getAction() ?>" method="<?php echo $form->getMethod() ?>" class="<?php echo $form->getClass(); ?>">
       <input type="hidden" name="action" value="<?php echo $form->getActionController(); ?>"/>
       <input type="hidden" name="id" value="<?php echo $form->getId() ?>"/>
       <?php $form->showElement('idDetalleTemp');?>
       <?php $form->showElement('cantidadOrigen');?>
       <div class="div-left">
           <div class="panel panel-default">
               <div class="panel-heading"><?php echo $_translator->_getTranslation('Informacion de venta');?></div>
               <div class="panel-body">
                   <div class="div-left">
                       <div><?php $form->showElement('fecha');?></div>  
                       <div><?php $form->showElement('po');?></div>              
                   </div>
                   <div class="div-left">        
                       <div class="div-left">
                           <?php $form->showElement('truck_trailer');?>
                       </div>
                       <button type="button" class="btn btn-sm btn-primary" style="margin-left:-10px" data-toggle="modal" data-target="#modalAgregarTransportista">
                           <span class="fa fa-external-link" aria-hidden="true"></span>
                       </button>
                       <div class="clear"></div>
                       <div class='div-left'>
                           <?php $form->showElement('chofer');?>
                       </div>
                       <button type="button" class="btn btn-sm btn-primary" style="margin-left:-10px" data-toggle="modal" data-target="#modalAgregarChofer">
                           <span class="fa fa-external-link" aria-hidden="true"></span>
                       </button>
                   </div>
                   <div class="clear"></div>
                   <div class="div-left">
                       <div class="div-left">
                               <?php $form->showElement('cliente');?>                
                       </div>
                       <button type="button" class="btn btn-sm btn-primary" style="margin-left:-10px" data-toggle="modal" data-target="#modalAgregarCliente">
                            <i class="fa fa-external-link"></i>
                        </button>
                   </div>
                    <div class="clear"></div>
                   <div class='div-left'>
                       <?php $form->showElement('vendedor');?>   
                   </div>
                   <div class='div-left'>
                       <?php $form->showElement('comprador');?>   
                   </div>
                   <div class="clear"></div>
                   <div>
                       <?php $form->showElement('comentariosTemp');?>
                       <?php $form->showElement('comentarios');?>
                   </div>
               </div>
           </div>
       </div>    
       <div class="div-left">
               <div class="panel panel-default">
                   <div class="panel-heading"><?php echo $_translator->_getTranslation('Informacion de pago');?></div>
                   <div class="panel-body">
                       <div class="div-left"><?php $form->showElement('metodo_pago');?></div>
                       <div class="div-left"><?php $form->showElement('diasCredito');?></div>
                       <div class="div-left"><?php $form->showElement('fecha_pago');?></div>  
                   </div>
               </div>
               <div class="clear"></div>
               <div class="panel panel-default">
                   <div class="panel-heading"><?php echo $_translator->_getTranslation('Gastos de venta');?></div>
                   <div class="panel-body">
                       <div class="div-left"><?php $form->showElement('fletes_mex');?></div>
                       <div class="div-left"><?php $form->showElement('fletes_ame');?></div>
                       <div class="div-left"><?php $form->showElement('cruce_mex');?></div>                 
                       <div class="div-left"><?php $form->showElement('cruce_ame');?></div>
                       <div class="clear"></div>                             
                       <div class="div-left"><?php $form->showElement('in_out');?></div>
                       <div class="div-left"><?php $form->showElement('otros');?></div>
                       <div class="div-left"><?php $form->showElement('comision');?></div>
                       <div class="clear"></div>
                   </div>
              </div>
       </div>
        <div class="clear"></div>
       <hr style="margin-top:10px"/>
       <div style="width: 100%">
           <table class="table-header venta">
               <thead>
                   <th class="accion-tbl-salidas"><?php echo $_translator->_getTranslation('Editar');?></th>
                   <th class="descripcion-tbl-salidas"><?php echo $_translator->_getTranslation('Descripcion');?></th>
                   <th class="tipoEntrada-tbl-salidas"><?php echo $_translator->_getTranslation('TipoEntrada');?></th>
                   <th class="referencia-tbl-salidas"><?php echo $_translator->_getTranslation('#Referencia');?></th>
                   <th class="refFac-tbl-salidas"><?php echo $_translator->_getTranslation('#Fac prov');?></th>
                   <th class="lote-tbl-salidas"><?php echo $_translator->_getTranslation('#Lote');?></th>
                   <th class="cantidad-tbl-salidas"><?php echo $_translator->_getTranslation('Cant.');?></th>
                   <th class="punit-tbl-salidas"><?php echo $_translator->_getTranslation('P.Unit');?></th>
                   <th class="total-tbl-salidas"><?php echo $_translator->_getTranslation('Total');?></th>
               </thead>
           </table>
           <div id="scroll-items" class="jp-container">
               <div id="ventaDetalles">
                      <?php $ventaAjax = new VentaAjax();
                            $edit = null;
                            if($action=='edit'){$edit = true;}
                            $listVentaDetalles = $ventaAjax->getListVentaDetalles(array('edit'=>$edit));
                            echo $listVentaDetalles['ventaDetalles'];?>
               </div>
           </div>
           <div class="clear"></div>
           <div style="margin-top:5px;">
               <div id='montoTotal' class="div-right"><?php echo $listVentaDetalles['montoTotal'];?></div>
               <div class="div-right totales"><?php echo $_translator->_getTranslation('Total');?>: $</div>
               <div id="cajasTotal"class="div-right totales"><?php echo $listVentaDetalles['cajasTotal'];?></div>
               <div class="div-right totales"><?php echo $_translator->_getTranslation('Cajas');?>:</div>
           </div>
       </div>
       <div  class="clear"></div>
       <div style="margin-top:10px">
           <div class="div-left">
               <!--<div class="div-left" style="margin-right: 25px"><?php $form->showElement('cuentaContable');?></div>-->
               <div class="div-left" style="margin-right: 25px"><?php $form->showElement('producto');?></div>
               <div class="div-left" style="margin-right: 0px"><?php $form->showElement('etiqueta');?></div>
               <div class="div-left" style="margin-right: 0px"><?php $form->showElement('cantidad');?></div>
               <div class="div-left" style="margin-right: 0px"><?php $form->showElement('precio');?></div>
               <div class="div-left" style="margin-right: 0px"><?php $form->showElement('tipo_entrada');?></div>
               <div class="div-left" style="margin-right: 0px"><?php $form->showElement('referencia');?></div>
               <div class="div-left" style="margin-right: 0px"><?php $form->showElement('ref_fac');?></div>
               <?php $form->showElement('punitariocompra');?>
               <div class="div-left" style="margin-right: 0px; margin-left: 5px"><?php $form->showElement('lote');?></div>
               <div class="div-right" style="margin-right: 0px">
                   <div class="div-left" style="margin-top: 23px;margin-right: 0px"><?php $form->showElement('buscar');?></div>
                   <div class="div-left" style="margin-top: 23px;"><?php $form->showElement('terminar');?></div>
               </div>
               <div class="clear"></div>
           </div>
       </div>
       </form>
       <?php
           $_gastosVenta = true;
           include ROOT."/View/Popup/AgregarGastoCompra.php";
       ?>
       <!-- Button to trigger modal -->
       <?php include ROOT."/View/Popup/MailEnviarFactura.php";?>
       <?php include ROOT."/View/Popup/AgregarTransportista.php";?>
       <?php include ROOT."/View/Popup/AgregarChofer.php";?>
        <?php include ROOT."/View/Popup/AgregarCliente.php";?>
        <?php include ROOT."/View/Popup/AgregarProveedor.php";?>
       <?php include ROOT."/View/Popup/StockPorReferencia.php";?>
       <div class="clear"></div>
        <?php  $venta->mostrarComentarios();?>
</div>