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/public_html/descargue_reporte.php
<!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=utf-8" />
<title>Descargue - Reporte</title>
<style type="text/css">
<!--
.Estilo50 {color: #CC3333;
	font-family: "Arial Narrow";
	font-weight: bold;
}
.fecha {font-size: 12px; font-family: Arial; color:#990000; display: block; }
.titulos {font: 16px; color: red; font-family:Arial; font-weight:bold}
.est_cont5 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-style: normal;
	font-weight: normal;
	background-color: #D6ECFE;
	margin: 2px;
	padding: 2px;
	height: auto;
	width: auto;
	border: thin groove #E9AAF0;
	color: #C72350;
}
.col_cre2 {	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-style: normal;
	font-weight: bold;
	color: #F92F0B;
	background-color: #B3D9F0;
	height: auto;
	width: auto;
	border: medium groove #FC9227;
}
.est_cont2 {	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-style: normal;
	font-weight: normal;
	color: #418BAF;
	background-color: #F0F5CF;
	height: 15px;
	width: auto;
	border: thin solid #FABF85;
}
.Estilo51 {
	color: #FF6633;
	font-weight: bold;
	font-size: 11px;
}
-->
</style>
</head>

<body>
<form id="form2" name="form2" method="post" action="" enctype="multipart/form-data">
  <label></label>
  <table border="0" align="center" cellpadding="0" cellspacing="0" widtd="671">
    <tr>
      <td><fieldset>
        <table width="373" border="0" align="center" cellpadding="2" cellspacing="2" widtd="669">
          <tr bgcolor="#FFFFCC">
            <td height="44" colspan="3" class="titulos"><div align="center">DESCARGUE REPORTE </div></td>
          </tr>
          <tr bgcolor="#ECE9D8">
            <td height="22" colspan="3" class="fecha"><div align="center">
                <script languaje="JavaScript">Mostrar_Fecha()</script>
                <input type="file" name="archivod" id="archivod" />
            </div></td>
          </tr>
          <tr bgcolor="#ECE9D8">
            <td width="82" height="22" class="fecha Estilo51">Fecha Nomina:</td>
            <td width="91" class="fecha"><div align="center">
              <input name="fecha_nom" type="text" class="est_cont2" id="fecha_nom" value="0000-00-00" size="12" maxlength="10" readonly="" />
            </div></td>
            <td width="180" class="fecha"><div align="center">
              <input name="descargar" type="submit" class="col_cre2" id="descargar" value="Descargue"  />
            </div></td>
          </tr>
          <tr bgcolor="#FFCC99">
            <td colspan="3"><div align="center">
                <input name="menu2" type="button" class="Estilo50" id="menu2" onclick="window.location.href='menu_datos_cartera_servi.php'" value="IR AL MENU" />
                <label></label>
            </div></td>
          </tr>
        </table>
      </fieldset></td>
    </tr>
  </table>
  <label></label>
  <p>&nbsp;</p>
  <p></p>
</form>
</body>
</html>
<?php
if(isset($_POST["descargar"]))
{

function Conectarse()
	{
	   if (!($link=@mysql_connect("localhost","asjudine","as2006")))
	   {
		  echo "Error conectando con el servidor.";
		  exit();
	   }
	   $dbname = "asjudinet";
	   if (!@mysql_select_db($dbname,$link))
	   {
		  echo "Error seleccionando la base de datos.";
		  exit();
	   }
	   return $link;
	}
	Conectarse();


require_once("mainfile.php");
include ("config.php");
global $dbi;
$cont=0;

 $archivo = $_FILES['archivod']['tmp_name']; 
 $tamanio = $_FILES['archivod']['size'];
 $tipo    = $_FILES['archivod']['type'];
 $nombre  = $_FILES['archivod']['name'];

$fp = fopen ($archivo,"r");

echo "<form id='form2' name='form2' method='post' action=''>";
				echo "<label>
  <div align='center'><span class='Estilo1'>INCONSISTENCIAS</span></div>";
				echo "<table width='750' border='2' align='center' cellpadding='1' cellspacing='1' class='est_cont5'>
                        <tr>
        					<td width='150'><div align='center'><strong>CODIGO</strong></div></td>
        					<td width='400'><div align='center'><strong>NOMBRE</strong></div></td>
        					<td width='100'><div align='center'><strong>VALOR DESCUENTO</strong></div></td>
							<td width='100'><div align='center'><strong>INCONSITENCIA</strong></div></td>
      					</tr>";

while ($data = fgetcsv ($fp, 6500, ";"))
{
$num = count($data);

$fechar = date ( "Y-n-j" );
/*$sqlnom = "select codigo, cod_desc, valor_descuento, mes_inicio, ano_inicio from reporte_mindefensa where codigo = '$data[0]' and valor_descuento = '$data[2]' and estado = '1'";
$control = mysql_query($sqlnom, $dbi) or die(mysql_error());	 
$num2 = mysql_num_rows($control);
list($codigo, $cod_desc, $valor_descuento, $mes_inicio, $ano_inicio) = mysql_fetch_array($control);
*/
$sqlnom = mysql_query('select cedula, nombre, numerocontrato,  tipocontrato , unidad_descuento, codigo_descuento, valorcuota, fecha_ultimo_registro, mes_inicio, ano_inicio, saldoanteior, cuotaspendientes, cuotasdescontadas, saldonuevo FROM cartera_serviasjudinet  WHERE cedula = "' . "$data[0]". '" and valorcuota =  "' . "$data[2]". '" ');
  if (!$sqlnom) {
				die('Invalid query cartera_serviasjudinet 11: ' . mysql_error());
			}	 
$num2 = mysql_num_rows($sqlnom);
			list($codigo, $nombre, $numcont, $tipo, $uni_desc,  $cod_desc, $valor_descuento, $fud, $mes_inicio, $ano_inicio, $saldo_ant, $cuopend, $cuodesc, $sal_nuevo) = mysql_fetch_row($sqlnom);

if($num2>0)
{
	
/*	$sqlnom2 = "select cuotas_pend, cuotas_desc, fecha_udesc from estado_contable where codigo = '$codigo'";
	$control2 = mysql_query($sqlnom2, $dbi) or die(mysql_error());	 
	list($cuopend, $cuodesc, $fud) = mysql_fetch_array($control2);*/
	$fechar = date ( "Y-n-j" );

	if($fud!=$fechar)
	{
	
/*	$sqlnom3 = mysql_query('SELECT mes_inicio, ano_inicio FROM relacion_pagos WHERE codigo =  "' . "$codigo". '"  ');
	$control3 = mysql_query($sqlnom3, $dbi) or die(mysql_error());	
	$num3 = mysql_num_rows($control3);*/
	
	$sqlnom3 = mysql_query('SELECT max(id), mescuota, anocuota FROM cartera_estado_contable  WHERE cedula =  "' . "$codigo". '" and contrato  "' . "$numcont". '" ');
  				if (!$sqlnom3) {
				die('Invalid query cartera_estado_contable: ' . mysql_error());
								} 
	$num3 = mysql_num_rows($sqlnom3);

	if($num3>0)
	{ 
	list($id, $mes_inicio, $ano_inicio) = mysql_fetch_row($sqlnom3);
		if($mes_inicio==12)
		{
			$mes_inicio=1;
			$ano_inicio++;
		}else{
		$mes_inicio++;
		}
	}
	
	/*$insertar="INSERT INTO relacion_pagos (codigo, valor, cuota, mes_inicio, ano_inicio, cod_descuento, fecha_registro) VALUES ('$codigo','$valor_descuento','$cuodesc','$mes_inicio','$ano_inicio','$cod_desc', '$fechar')";
	$conn = mysql_query($insertar, $dbi) or die(mysql_error($dbi));*/
	$subir = $subir +1 ;
	
	$guardar =  mysql_query("INSERT INTO cartera_estado_contable (cedula, nombre, contrato, contratotipo, cuota,  mescuota, anocuota, valor_cuota, fecha_registro, fecha_nomina, codigo_descuento, unidad_descuento) VALUES ('" ."$codigo". "', '" ."$nombre". "', '" ."$numcont". "', '" ."$tipo". "', '" ."$cuono". "', '" ."$mes_inicio". "', '" ."$ano_inicio". "','" ."$valor_descuento". "', '" ."$fechar". "','" ."$data[3]". "', '" ."$codcd". "', '" ."$unidt". "')");
  if (!$guardar) {
				die('Invalid query 1  cartera_estado_contable guardar: ' . mysql_error());
			}

	/*$mssql2 = "update estado_contable set cuotas_pend='$cuopend', cuotas_desc='$cuodesc', fecha_udesc='$fechar'  where codigo = '$codigo' ";
	mysql_query($mssql2, $dbi) or die(mysql_error());
	*/
		
	$cuopend--;
	$cuodesc++;

			$sal_ant = $sal_nue;
			$sal_nue = $sal_nue - $valor_descuento ;
			
			$mssql3 = mysql_query("UPDATE  cartera_serviasjudinet set  fecha_ultimo_registro = '" .$fechar. "', saldoanteior = '" .$sal_ant. "' , cuotaspendientes = '" .$cuopend. "' , cuotasdescontadas = '" .$cuodesc. "' , saldonuevo = '" .$sal_nue. "' WHERE cedula = '" .$codigo. "'");
            if (!$mssql3) {
				die('Invalid query cartera_serviasjudinet MODIFICAR: ' . mysql_error());
						}  
	
	
	}
	
}else{

$incon = $incon + 1;
	//mostrar inconsistencias
	
 						
/*  $sql = "select codigo, nombre from reporte_mindefensa where codigo = '$data[0]'";
                      $con = mysql_query($sql, $dbi) or die(mysql_error());
					  list($codigorm, $nombrerm) = mysql_fetch_array($con);*/
					  
					  $con = mysql_query('select cedula, nombre, numerocontrato,   tipocontrato , unidad_descuento,  codigo_descuento, valorcuota, fecha_ultimo_registro,  mes_inicio, ano_inicio, saldoanteior, cuotaspendientes, cuotasdescontadas, saldonuevo FROM cartera_serviasjudinet  WHERE cedula = "' . "$data[0]". '" and valorcuota !=  "' . "$data[2]". '" ');
  if (!$con) {
				die('Invalid query cartera_estado_contable: ' . mysql_error());
			}	 
			list($codigo, $nombre, $numcont, $tipo, $uni_desc,  $cod_desc, $valor_descuento, $fud, $mes_inicio, $ano_inicio, $saldo_ant, $cuopend, $cuodesc, $sal_nuevo) = mysql_fetch_row($con);
					  
 
                      if ((mysql_num_rows($con)!=0)) 
	                    {	
										  								   	
								   printf("<TR>
                                   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$codigorm."</span></div></TD>
                                   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$nombrerm."</span></div></TD>
								   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$data[2]."</span></div></TD>
								   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>Valor Descuento</span></div></TD> </TR>");              								
		   	  
    					}else{
								if ($fud == $fechar)
								{
								printf("<TR>
                                   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$data[0]."</span></div></TD>
                                   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$data[1]."</span></div></TD>
								   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$data[2]."</span></div></TD>
								   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>Cuota ya fue cargada el Dia de Hoy</span></div></TD> </TR>");  
								}
								else
								{
						//mostrar los datos del archivo de descargue
						printf("<TR>
                                   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$data[0]."</span></div></TD>
                                   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$data[1]."</span></div></TD>
								   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$data[2]."</span></div></TD>
								   <TD bgcolor='#C5D6FC'><div align='center' class='lista'>Cedula Incorrecta</span></div></TD> </TR>");     
								   }
						}
						

	$cont++;
	} //fin else

}//fin while
						echo "</table>";	
						echo "Numero de Registros subidos = $subir <br>";
						echo "Numero de Inconsistencias = $incon";
echo "</form>";

fclose ($fp);
}
?>