<?php
session_start();
require_once($ruta."clases/covensol_cxc_c_cuentasxcobrar.php");
$objcxc = new covensol_cxc_cuentasxcobrar();
$objcxc->io_conexiones->decodificar_post();
$prop = $objcxc->io_conexiones->asignar_post();

if($prop['numcancelados']){
	$prop['numcancelados'] = explode(',',$prop['numcancelados']);
	$prop['feccancelados'] = explode(',',$prop['feccancelados']);
	$resp = $objcxc->cancelacion_giros($prop);
}
if($prop['numrevcancel']){
	$prop['numrevcancel'] = explode(',',$prop['numrevcancel']);
	$resp2 = $objcxc->revcancelacion_giros($prop);
}
if($prop['numsuspendidos']){
	$prop['numsuspendidos'] = explode(',',$prop['numsuspendidos']);
	$resp3 = $objcxc->suspencion_giros($prop);
}


$resultado = $objcxc->consulta_cuotasgiros($prop);
?>

<?php 
$ancho[1] = 80;
$ancho[2] = 100;
$ancho[3] = 100;
$ancho[4] = 100;
$ancho[5] = 200;
$ancho[6] = 80;

$ancho_total = array_sum($ancho);
$color_fila='#C5E0FC';
$saldo = 0;
$cancelado = 0;
?><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]; ?>"><div align="center">Giro</div></td>    
    <td width="<?php echo $ancho[2]; ?>"><div align="center">Fec. venc.</div></td> 
     <td width="<?php echo $ancho[3]; ?>"><div align="center">Monto</div></td>
     <td width="<?php echo $ancho[4]; ?>"><div align="center">Estatus</div></td> 
     <td width="<?php echo $ancho[5]; ?>"><div align="center">Cancelar</div></td>
     <td width="<?php echo $ancho[6]; ?>"><div align="center">Suspender</div></td>            
  </tr>
  <?php do { ?>
          <?php
		  	$seguridad = true;	
			if($seguridad or $_SESSION['autent_administrador']){
			switch($color_fila){case'#C5E0FC': $color_fila='#FFFFFF'; break; case'#FFFFFF': $color_fila='#C5E0FC'; break;}			
			if($resultado['fila']['estgiro']){$cancelado += $resultado['fila']['mongiro'];}
			else{$saldo += $resultado['fila']['mongiro'];}	 
			?>
           
				  <tr  bgcolor="<?php echo $color_fila; ?>">
                    <td width="<?php echo $ancho[1]; ?>"><div align="center"><?php echo $resultado['fila']['numgiro'];?></div></td>
                  	<td width="<?php echo $ancho[2]; ?>"><div align="center"><?php echo $objcxc->io_conexiones->formatea_fecha_normal($resultado['fila']['fecvengiro']);?></div></td>
                    <td width="<?php echo $ancho[3]; ?>"><div align="right"><?php echo number_format($resultado['fila']['mongiro'],2,',','.');?></div></td>
					<td width="<?php echo $ancho[4]; ?>" align="center">
                    <?php if($resultado['fila']['estgiro']){ ?>
                    <img src="../shared/imagenes/checkeado.gif" alt="Eliminar" width="15" height="15" border="0" title="Eliminar">
                    <?php }?>
                    </td> 
                    <td width="<?php echo $ancho[5]; ?>">
                        <div align="center">
                        <?php if(!$resultado['fila']['estgiro']){ ?>
                                    <input name="chkcancelar" id="chkcancelar" type="checkbox" onclick="validar_campo_fec(this,<?php echo $resultado['fila']['numgiro'];?>)" value="<?php echo $resultado['fila']['numgiro'];?>" /> 
                              &nbsp;<input name="txt_fec_cancel<?php echo $resultado['fila']['numgiro'];?>" type="text" id="txt_fec_cancel<?php echo $resultado['fila']['numgiro'];?>"  style="text-align:center;" size="15" onblur="tildar_cancelacion(<?php echo $resultado['fila']['numgiro'];?>)" maxlength="10" datepicker="true" />
                        <?php }else{?>
                                   <input name="chkrevcancel" id="chkrevcancel" type="checkbox"  value="<?php echo $resultado['fila']['numgiro'];?>" checked/>
                        		   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								   <?php echo $objcxc->io_conexiones->formatea_fecha_normal($resultado['fila']['feccancel']);?>
                        <?php }?>
                        </div>
                    </td>
                    <td width="<?php echo $ancho[6]; ?>"><div align="center"><?php if(!$resultado['fila']['estgiro']){ ?><input name="chksuspender" id="chksuspender" type="radio" value="<?php echo $resultado['fila']['numgiro'];?>" /><?php }?></div></td> 
                  </tr>
                  <tr>
                    <td height="1" bgcolor="#BBBBBB" colspan="4"></td>
                  </tr>
          <?php } ?>
  <?php } while ($resultado['fila'] = $obj_sql->fetch_row($resultado['rs'])); ?> 
  <tr bgcolor="#FFFFFF">
     <td width="<?php echo $ancho[1]; ?>"><div align="right"></div></td> 
     <td width="<?php echo $ancho[2]; ?>"><div align="right" class="texto-azulato">Cancelado:</div></td>    
     <td width="<?php echo $ancho[3]; ?>"><div align="right" class="texto-azul"><?php echo number_format($cancelado,2,',','.'); ?></div></td>  
     <td width="<?php echo $ancho[4]; ?>"><div align="right"></div></td>
     <td width="<?php echo $ancho[5]; ?>"><div align="right"></div></td>
     <td width="<?php echo $ancho[6]; ?>"><div align="right"></div></td>              
  </tr> 
  <tr bgcolor="#FFFFFF">
     <td width="<?php echo $ancho[1]; ?>"><div align="right"></div></td> 
     <td width="<?php echo $ancho[2]; ?>"><div align="right" class="texto-azulato">Saldo:</div></td>    
     <td width="<?php echo $ancho[3]; ?>"><div align="right" class="texto-rojo"><?php echo number_format($saldo,2,',','.'); ?></div></td>
     <td width="<?php echo $ancho[4]; ?>"><div align="right"></div></td> 
     <td width="<?php echo $ancho[5]; ?>"><div align="right"></div></td>
     <td width="<?php echo $ancho[6]; ?>"><div align="right"></div></td>          
  </tr> 
</table>
<?php 
	if($resp or $resp2 or $resp3){echo '<input type="hidden" name="txt_ejecutar_funcion" id="txt_ejecutar_funcion" value="mostrar_mensajes">';}
?>
<input type="hidden" name="txt_ejecutar_funcion" id="txt_ejecutar_funcion" value="cargar_calendarios">
<input type="hidden" name="txt_mensajes" id="txt_mensajes" value="<?php echo $resp.'<br>'.$resp2.'<br>'.$resp3; ?>">   
