<?php
session_start();
$ruta='../';
require_once("clases/covensol_cxc_c_cuentasxcobrar.php");
$objcxc = new covensol_cxc_cuentasxcobrar();
$objcxc->io_conexiones->decodificar_post();
$opciones = $objcxc->io_conexiones->asignar_post();
$resp = $objcxc->MonedaPorDefecto();
$objcxc->codproc='COT';					
$opciones['criterio']='por_listado';			
$filas = $objcxc->consulta_cotped($opciones);

$ancho[1] = 40;
$ancho[2] = 40;
$ancho[3] = 70;
$ancho[4] = 60;
$ancho[5] = 250;
$ancho[6] = 70;
$ancho[7] = 80;
$ancho[8] = 80;
$ancho[9] = 50;
$ancho[10] = 50;
$ancho[11] = 100;
$ancho[12] = 100;
$ancho[15] = 20;		
$ancho_total = array_sum($ancho);
			
if(!$filas['rs']->RecordCount()){
	$mensaje = 'No hay presupuestos o cotizaciones encontradas para este criterio de busqueda.<br>';
	$objcxc->io_conexiones->mensajes_ajax($mensaje);
	exit();
}

?>
<link href="../shared/css/catalogos.css" rel="stylesheet" type="text/css">
<link href="../shared/css/tablas.css" rel="stylesheet" type="text/css">
<table width="<?php echo $ancho_total; ?>" border="0" cellpadding="0" cellspacing="0"   class='fondo-tabla'>
  <tr class="titulo-celda">
    <td width="<?php echo $ancho[1] ?>" align="center">Sucursal</td>
    <td width="<?php echo $ancho[2] ?>" align="center">Caja</td>
    <td width="<?php echo $ancho[3] ?>" align="center">Número</td>
    <td width="<?php echo $ancho[4] ?>" align="center">Control</td>
    <td width="<?php echo $ancho[5] ?>" align="center">Cliente</td>
    <td width="<?php echo $ancho[6] ?>" align="center">Estatus</td>
    <td width="<?php echo $ancho[7] ?>" align="center">Cond. Pag</td>
    <td width="<?php echo $ancho[8] ?>" align="center">Fecha</td>
    <td width="<?php echo $ancho[9] ?>" align="center">Mon</td>
    <td width="<?php echo $ancho[10] ?>" align="center">Tascam</td>
    <td width="<?php echo $ancho[11] ?>" align="center">Monto (<?php echo $objcxc->DatosMonedaDef['abrmon'] ?>)</td>
    <td width="<?php echo $ancho[12] ?>" align="center">Mon Ext</td>                
    <td width="<?php echo $ancho[15] ?>" align="center"></td>                
    
  </tr>
  <?php foreach($filas['rs'] as $datos) {
    	//SEGURIDAD DE LA SUCURSAL
		
        $objcxc->codintper = $datos['codsuc'];		
        if(!$objcxc->obtSegCxc()){continue;}
       
        $aceptar = 'onClick="aceptar('.$datos['id_cotped'].",'".
                                      $objcxc->formato_numero_cotped($datos['numcotped']).
									  "','".$datos['codsuc']."',
									  '".$objcxc->io_conexiones->formatea_fecha_normal($datos['feccotped'])."',
									  '".$datos['sigsuc']."',
									  '".$datos['id_cliente']."',
									  '".$datos['estcotped']."',
									  '".$datos['codmon']."',
									  '".$datos['id_condpago']."',									  
									  '".$datos['coduniadm']."',
									  '".$datos['codfuefin']."',
									  '".$datos['estcla']."',
									  '".$datos['codestpro1']."',
									  '".$datos['codestpro2']."',
									  '".$datos['codestpro3']."',
									  '".$datos['codestpro4']."',
									  '".$datos['codestpro5']."'
									  )".'"';   
									                                      
        if($datos['abrmon']=='E'){$datos['abrmon']='&#x20AC';}
		$color_fila='style="background-color:#FFFFFF"';						
        switch($datos['estcotped']){                
                case '1': $color_fila='style="background-color:#FFFFFF"'; break;
                case '4': $color_fila='style="background-color:#FFFFFF"'; break;
                case '3': $color_fila='style="background-color:#E1ECEC"'; break;
                case '7': $color_fila='style="background-color:#FF7777"'; break;
        }
		
        /*
		$objcxc->CalcularVencimientoCxc($datos);                                                                                        
        $datos['totmonext'] = ($datos['codmon']!=$objcxc->DatosMonedaDef['codmon'])?number_format($datos['total']/$datos['tascam'],2,',','.'):"";
		if($objcxc->DiasVenCxc){$color_fila='style="background-color:'.$objcxc->ColorEstVenCxc.'"';}
		*/
		$datos['totmonext'] = $datos['total']/$datos['tascam'];
    ?>
       <tr id="consulta" <?php echo $color_fila; ?> > 
          <td width="<?php echo $ancho[1] ?>" align="right"><a href="#" <?php echo $aceptar; ?>><div style="color:#189FBC;padding-right:10px;"><?php echo $datos['sigsuc']; ?></div></a></td>
          <td width="<?php echo $ancho[2] ?>" align="right"><a href="#" <?php echo $aceptar; ?>><div style="color:#189FBC;padding-right:10px;"><?php echo $datos['codcaj']; ?></div></a></td>
          <td width="<?php echo $ancho[3] ?>" align="right"><a href="#" <?php echo $aceptar; ?>><div style="color:#189FBC;padding-right:10px;"><?php echo $datos['numcotped']; ?></div></a></td>
          <td width="<?php echo $ancho[4] ?>" align="right"><a href="#" style="color:#990000;padding-right:5px;" <?php echo $aceptar; ?>><?php echo $datos['numcont']; ?></a></td>
          <td width="<?php echo $ancho[5] ?>" align="left"><a href="#" <?php echo $aceptar; ?>><?php echo $datos['nombre_cliente']; ?></a></td>
          <td width="<?php echo $ancho[6] ?>" align="left"><a href="#" <?php echo $aceptar; ?>><?php echo $datos['denestcotped']; ?></a></td>
          <td width="<?php echo $ancho[7] ?>" align="left"><a href="#" <?php echo $aceptar; ?>><?php echo $datos['desccondpago']; ?></a></td>
          <td width="<?php echo $ancho[8] ?>" align="center"><a href="#" <?php echo $aceptar; ?>><?php echo $objcxc->io_conexiones->formatea_fecha_normal($datos['feccotped']); ?></a></td>
          <td width="<?php echo $ancho[9] ?>" align="center"><a href="#" <?php echo $aceptar; ?>><?php echo $datos['abrmon']; ?></a></td>
          <td width="<?php echo $ancho[10] ?>" align="right"><a href="#" <?php echo $aceptar; ?>><?php echo number_format($datos['tascam'],2,',','.'); ?></a></td>
          <td width="<?php echo $ancho[11] ?>" align="right"><a href="#" <?php echo $aceptar; ?>><?php echo number_format($datos['total'],2,',','.'); ?></a></td>
          <td width="<?php echo $ancho[12] ?>" align="right"><a href="#" <?php echo $aceptar; ?>><?php echo number_format($datos['totmonext'],2,',','.'); ?></a></td>
          <td width="<?php echo $ancho[15] ?>" align="left"><a href="#" onclick="imprimir_cotizacion(<?php echo $datos['id_cotped']; ?>);"><img src="../shared/imagebank/tools20/imprimir.gif" alt="Reporte de resumen de gestion de documento" width="20" height="20" border="0" /></a></td>                                        
                   
      </tr>
      <tr>
        <td height="1" bgcolor="#BBBBBB" colspan="5">
            <input name="hnombre_cliente<?php echo $datos['id_cotped'];?>" type="hidden" id="hnombre_cliente<?php echo $datos['id_cotped'];?>"  value="<?php echo $datos['nombre_cliente']; ?>"/>
            <input name="htotal<?php echo $datos['id_cotped'];?>" type="hidden" id="htotal<?php echo $datos['id_cotped'];?>"  value="<?php echo number_format($datos['total'],2,',','.'); ?>"/>
            <input name="hestcotped<?php echo $datos['id_cotped'];?>" type="hidden" id="hestcotped<?php echo $datos['id_cotped'];?>"  value="<?php echo $datos['estcotped']; ?>"/>
            <input name="hdenestcotped<?php echo $datos['id_cotped'];?>" type="hidden" id="hdenestcotped<?php echo $datos['id_cotped'];?>"  value="<?php echo $datos['denestcotped']; ?>"/>
            <input name="hdescrip<?php echo $datos['id_cotped'];?>" type="hidden" id="hdescrip<?php echo $datos['id_cotped'];?>"  value="<?php echo $datos['descrip']; ?>"/>
        </td>
      </tr>

  <?php } ?>
</table>	         