MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: /home/asjudine/www/cartera_listado_nnee.php
<?php 
require_once("mainfile.php");
include ("config.php");
global $dbi;
$espacio = ' ';
$linea = '-';

require_once("Conectarse.php");

$sql2 = mysql_query('SELECT * FROM descuentos order by unidad  ');
			if (!$sql2) {
				die('Invalid query: ' . mysql_error());
			}
$row_sql2 = mysql_fetch_assoc($sql2);
$totalRows_sql2 = mysql_num_rows($sql2);  

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Consulta Cartera por Unidad</title>
<style type="text/css">
<!--
.titulos {font: 16px; color: red; font-family:Arial; font-weight:bold}
.boton {background-color: #FFCCCC; color:#FFFFFF; width:90px; height:25; border: 3px solid #0000CC; font-family:Arial; color:#990000;}
.texto {background-color: #CCFFCC; font-size: 11px; font-family: Arial; color:#0000CC; display: block;}
.fecha {font-size: 12px; font-family: Arial; color:#990000; display: block; }
.campo {background-color:#FFFFAA; width: 100px; border:2px solid #990000;}
.lista {font-family: Arial; font-size: 11px;	color: #000066;}
.lista2 {font-family: Arial; font-size: 16px;	color: #FF6600;}
.boton2 {
	font-family: Verdana;
	font-size: 8 pt;
	color: #000080;
	background-color: #C0C0C0;
	border-style: solid;
	width:90px;
	height:22px;
}
body {
	background-image: url();
}
.Estilo50 {color: #CC3333;
	font-family: "Arial Narrow";
	font-weight: bold;
}
.boton1 {background-color: #FFCCCC; color:#FFFFFF; width:90px; height:25; border: 3px solid #0000CC; font-family:Arial; color:#990000;}
.boton11 {background-color: #FFCCCC; color:#FFFFFF; width:90px; height:25; border: 3px solid #0000CC; font-family:Arial; color:#990000;}
.Estilo54 {color: #333399; font-family: "Arial Narrow"; font-weight: bold; }
.Estilo57 {color: #006600}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>
<form action="" method="post" name="form1" class="provd" id="form1">
  <div align="center">
    <table width="655" border="3" cellpadding="3" cellspacing="3" bgcolor="#CCFFFF">
      <tr>
        <td colspan="3"><div align="center" class="Estilo50">CONSULTA CARTERA POR UNIDAD</div></td>
      </tr>
     
      </table>
  
    <p>
      <input name="menu2" type="button" class="Estilo50" id="menu2" onclick="window.location.href='menu_cartera_nomina.php'" value="IR AL MENU" />
	   <input name="consultar" id="consultar" type="submit" class="Estilo50" value="CONSULTAR">
	  
    </p>
  </div>
</form>
</body>
</html>

<?php



$mssql = mysql_query('SELECT *  FROM cartera_serviasjudinet  ');
		  if (!$mssql) {
				die('Invalid query 1: ' . mysql_error());
			}
		
   if($mssql)
   {
         $filas = mysql_num_rows($mssql);
         if ($filas > 0)
         {
	
			$control = mysql_query('SELECT cedula, codigo_militar , grado, nombre, numerocontrato, tipocontrato, fecha_ultimo_registro, unidad_descuento, codigo_descuento, numero_libranza, valorcontrato,  numerocuotas, valorcuota, fecha_inicio_contrato,   cuotasdescontadas, mes_inicio, ano_inicio, renovacion, estado FROM cartera_serviasjudinet  WHERE unidad_descuento = "NNEE" and codigo_sucursal != "20" and estado = "1" order by nombre ');
		  if (!$control) {
				die('Invalid query 2: ' . mysql_error());
			} 

                     if ((mysql_num_rows($control)!=0)) 
	                    {	 
                              echo "<TABLE width='1600' border='2' align='center' cellpadding='2' cellspacing='1'>
                              <TR>
                              <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>CEDULA</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>CODIGO</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>GRADO</span></div></TD>	
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>NOMBRE</span></div></TD>	
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>N° CONTRATO</span></div></TD>
                              <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>TIPO CONTRATO</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>CUOTAS DESC</span></div></TD>
							
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>FECHA CONTRATO</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>VALOR CONTRATO</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>VALOR CUOTA</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>VALOR CUOTA OPERO</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>N° LIBRANZA</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>A</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>N° CUOTAS</span></div></TD>
							  
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>UNIDAD</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>CODIGO</span></div></TD>
							  <TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>FECHA INICIO</span></div></TD>";		  
                           							  
                        
  while(list($cedula, $codigo, $grado, $nombres , $numcon, $tipo, $fech, $unidad, $codi, $nl, $valocon, $numcuo, $valorcuo, $fechaini,  $cuodes, $mesini, $anoini,  $renova, $estado) = mysql_fetch_row($control)) 
                              {  
							  $fecha = 0000-00-00;
							  $mese = 00;
							  $anos = 0000;
							  $valcuota = 0;
							  $iniciopag = $mesini.'-'.$anoini;
  			 	 if ($tipo > 0)
						  {
						   $cont10 = mysql_query('SELECT codigo_contrato FROM planes_contratos WHERE codigo = "' . "$tipo". '" ');
		  if (!$cont10) {
				die('Invalid query 42: ' . mysql_error());
			}
		list($tipo) = mysql_fetch_row($cont10); 
						 }	   
                              
							   if ($estado == 0)
							   {
							   $esta = "HISTORICO";
							   }   				
							   else
							   {
							   $esta = "VIGENTE";
							   }
							   
				 $cre = "NO";
						
								 $credit = mysql_query('SELECT cedula, valor_cuota, cuotas_credito, unidad_descuento, cuotas_descontadas, cuotas_pendientes, fecha_ultimo_descuento FROM creditos_serviasjudinet   WHERE cedula = "' . "$cedula". '" and estado = "1"');
		  if (!$credit) {
				die('Invalid query 42: ' . mysql_error());
			}
		list($cedcre, $valcre, $cuocredito, $unidadcre, $cuodescredi, $cuopencre, $fechacre) = mysql_fetch_row($credit); 
				  if ((mysql_num_rows($credit)!=0)) 
	                    {	
						$cre = "SI";
						}			
						else{
						$cre = "NO";
						$valcre = 0;
						$unidadcre = "NO";
					   $cuodescredi = 0;
					   $fechacre = "NO";
						}
						
						
							 $proceso = mysql_query('SELECT cedula FROM procesos  WHERE cedula = "' . "$cedula". '" and numero_contrato =  "' . "$numcon". '"');
		  if (!$proceso) {
				die('Invalid query 42: ' . mysql_error());
			}
		list($cedpro) = mysql_fetch_row($proceso); 
				  if ((mysql_num_rows($proceso)!=0)) 
	                    {	
						$pro = "SI";
						}			
						else{
						$pro = "NO";
						}
						
						 $benefici = mysql_query('SELECT cedula FROM beneficiarios  WHERE cedula_titular = "' . "$cedula". '" and numero_contrato_titular =  "' . "$numcon". '"');
		  if (!$benefici) {
				die('Invalid query benefici: ' . mysql_error());
			}
		list($cedben) = mysql_fetch_row($benefici); 
				  if ((mysql_num_rows($benefici)!=0)) 
	                    {	
						$bene = "SI";
						}			
						else{
						$bene = "NO";
						}
						
						 $proceben = mysql_query('SELECT cedula FROM procesos  WHERE cedula = "' . "$cedben". '" and numero_contrato =  "' . "$numcon". '"');
		  if (!$proceben) {
				die('Invalid query proceben: ' . mysql_error());
			}
		list($cedproben) = mysql_fetch_row($proceben); 
				  if ((mysql_num_rows($proceben)!=0)) 
	                    {	
						$proben = "SI";
						}			
						else{
						$proben = "NO";
						}
							
						
						
							   
							   
							  	$mssql4 = mysql_query("INSERT INTO  reporte_nnee (id,cedula, codigo, grado, nombre, contrato,tipo, cuota_desc, fecha_contrato, valor_contrato, valor_cuota, num_libranza, renovacion, num_cuotas, credito, valor_cuo_credito, unidad_credito, cuota_desco_cre, cuota_pen_cre, fecha_pago_cre, unidad_des, codigo_des, proceso, beneficiario, beneficiario_proceso, fecha_inicio) VALUES ('" ."$id". "','" ."$cedula". "', '" ."$codigo". "', '" ."$grado". "', '" ."$nombres". "', '" ."$numcon". "', '" ."$tipo". "', '" ."$cuodes". "', '" ."$fechaini". "', '" ."$valocon". "', '" ."$valorcuo". "', '" ."$nl". "', '" ."$renova". "', '" ."$numcuo". "','" ."$cre". "', '" ."$valcre". "', '" ."$unidadcre". "', '" ."$cuodescredi". "', '" ."$cuopencre". "', '" ."$fechacre". "', '" ."$unidad". "','" ."$codi". "', '" ."$pro". "','" ."$bene". "', '" ."$proben". "', '" ."$iniciopag". "')");
	if (!$mssql4) {
				die('Invalid query asjudinet_cartera insertar: ' . mysql_error());
			}   
	
						   
							 /*    $bene = "NO";
		 $contt = mysql_query('SELECT cedula FROM beneficiarios  WHERE cedula_titular = "' . "$cedula". '" and numero_contrato_titular =  "' . "$numcon". '"');
		  if (!$contt) {
				die('Invalid query 42: ' . mysql_error());
			}
		list($cedben) = mysql_fetch_row($contt); 
				  if ((mysql_num_rows($contt)!=0)) 
	                    {	
						$bene = "SI";
						}			
						else{
						$bene = "NO";
						}   
				
						$proceben = "NO";
 $benpro = mysql_query('SELECT cedula FROM procesos WHERE cedula = "' . "$cedben". '" and numero_contrato =  "' . "$numcon". '"');
		  if (!$benpro) {
				die('Invalid query 42: ' . mysql_error());
			}
		list($cedbenn) = mysql_fetch_row($benpro); 
				  if ((mysql_num_rows($benpro)!=0)) 
	                    {	
						$proceben = "SI";
						}			
						else{
						$proceben = "NO";
						}
				
				

						$proce = "NO";
 $procet = mysql_query('SELECT cedula FROM procesos WHERE cedula = "' . "$cedula". '" and numero_contrato =  "' . "$numcon". '"');
		  if (!$procet) {
				die('Invalid query 42: ' . mysql_error());
			}
		list($cedpro) = mysql_fetch_row($procet); 
				  if ((mysql_num_rows($procet)!=0)) 
	                    {	
						$proce = "SI";
						}			
						else{
						$proce = "NO";
						}
						
							$cre = "NO";
						
								 $credit = mysql_query('SELECT cedula, valor_cuota, cuotas_credito, unidad_descuento, cuotas_descontadas, cuotas_pendientes, fecha_ultimo_descuento FROM creditos_serviasjudinet   WHERE cedula = "' . "$cedula". '" and estado = "1"');
		  if (!$credit) {
				die('Invalid query 42: ' . mysql_error());
			}
		list($cedcre, $valcre, $cuocredito, $unidadcre, $cuodescredi, $cuopencre, $fechacre) = mysql_fetch_row($credit); 
				  if ((mysql_num_rows($credit)!=0)) 
	                    {	
						$cre = "SI";
						}			
						else{
						$cre = "NO";
						$valcre = 0;
						$unidadcre = "NO";
					   $cuodescredi = 0;
					   $fechacre = "NO";
						}	   
							   
	   
		
							   
							    $con = mysql_query('SELECT MAX(id) FROM cartera_estado_contable   WHERE cedula = "' . "$cedula". '" and contrato = "' . "$numcon". '" GROUP BY cedula, contrato ORDER BY cuota');
		  if (!$con) {
				die('Invalid query 42: ' . mysql_error());
			}
	list($id) = mysql_fetch_row($con);
	
	 $conf = mysql_query('SELECT id, mescuota, anocuota , valor_cuota, fecha_nomina FROM cartera_estado_contable   WHERE cedula = "' . "$cedula". '" and contrato = "' . "$numcon". '" and id = "' . "$id". '"  ORDER BY cuota');
		  if (!$conf) {
				die('Invalid query 42: ' . mysql_error());
			}
	list($id, $mese, $anos, $valcuota, $fecha) = mysql_fetch_row($conf);
	
*/
							   
							   $sum = $sum + 1;
							   
							   /*	   	<TD bgcolor='#ECE9D8'><div align='center' class='lista'><input type='button' value=$cedula name='cedu' class=est_cont1 onClick =window.location.href='cartera_consulta_titular_deb.php?ced2=$cedula&numcon=$numcon'></a></span></div></TD>*/

								   printf("<tr>    
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$cedula."</span></div></td>    
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$codigo."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$grado."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$nombres."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$numcon."</span></div></td>
				    <td bgcolor='#FFFFCC'><div align='center' class='lista'>".$tipo."</span></div></td>
				    <td bgcolor='#FFFFCC'><div align='center' class='lista'>".$cuodes."</span></div></td>
				    
				    <td bgcolor='#FFFFCC'><div align='center' class='lista'>".$fechaini."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$valocon."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$valorcuo."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$valcuota."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$nl."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$renova."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$numcuo."</span></div></td>
					
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$unidad."</span></div></td>
				    <td bgcolor='#FFFFCC'><div align='center' class='lista'>".$codi."</span></div></td>
					<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$iniciopag."</span></div></td>
								   ");              								   
                               }
			echo "</table>";		  
			echo "<TABLE width='200' border='0' align='center' cellpadding='0' cellspacing='1'>
           <TR>
           <TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>TOTAL REGISTROS</span></div></TD></TD>";	
				 printf("<tr>
       <td bgcolor='#C5D6FC'><div align='center' class='lista'>".$sum."</span></div></td></td>"); 
								   echo "</table>";	
                        }
						
						
		       
	      }
     }
    

echo "</form>";


?>