File: /home/asjudine/www/cartera_cargar_automatica_nnee.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>Cargue Liquidacion Cobranzas</title>
<style type="text/css">
<!--
.Estilo2 {color: #0000CC;
font-size: 16px;
}
.Estilo3 {color: #2492FF;
font-weight: bold;
}
.Estilo4 {
color: #003300;
font-size: 18px;
font-family: Georgia, "Times New Roman", Times, serif;
}
.recaudo {font-family: "Courier New", Courier, monospace;
font-size: 12px;
font-style: normal;
font-weight: bold;
font-variant: normal;
color: #000000;
background-color: #B6CBDC;
margin: 4px;
padding: 8px;
width: auto;
border: medium outset #339966;
}
.Estilo50 {color: #CC3333;
font-family: "Arial Narrow";
font-weight: bold;
}
.Estilo53 {font-family: "Courier New", Courier, monospace}
-->
</style>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<label> </label>
<div align="center">
<table width="448" border="3" cellpadding="3" cellspacing="3" class="recaudo">
<caption>
<div align="center" class="Estilo4 ">CARGUE LIQUIDACION </div>
</caption>
<tr>
<th colspan="2" bgcolor="#E0FEF3" scope="col"><label><span class="Estilo53">Seleccione el Archivo a Cargar</span></label></th>
</tr>
<tr>
<td width="150" bgcolor="#E0FEF3"><div align="center"><span class="Estilo2">ARHIVO(Excel): </span></div></td>
<td width="265" bgcolor="#E0FEF3"><div align="center">
<input type="file" name="archivo_carga" id="archivo_carga" />
</div></td>
</tr>
<tr>
<td bgcolor="#E0FEF3" align="center"> </td>
<td colspan="2" bgcolor="#E0FEF3"><div align="center">
<input name="cargar" type="submit" class="Estilo3" id="cargar" value="Enviar" />
</div></td>
</tr>
<tr>
<td colspan="2" bgcolor="#E0FEF3"><div align="center">
<input name="menu2" type="button" class="Estilo50" id="menu2" onclick="window.location.href='menu_cartera_nomina.php'" value="IR AL MENU" />
</div></td>
</tr>
</table>
</div>
<label><br />
</label>
<p>
<label></label>
</p>
</form>
<p> </p>
</body>
</html>
<?php
require_once("mainfile.php");
include ("config.php");
global $dbi;
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();
$tota = 0 ;
$regi = 0;
$total = 0 ;
$tere = 0;
if(isset($_POST["cargar"]))
{
// Test CVS
require_once 'Excel/reader.php';
// ExcelFile($filename, $encoding);
$data = new Spreadsheet_Excel_Reader();
// Set output Encoding.
$data->setOutputEncoding('CP1251');
$data->read($archivo_carga);
error_reporting(E_ALL ^ E_NOTICE);
$fecha_act=date ( "Y-n-j" );
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'>NOMBRE</span></div></TD>
<TD bgcolor='#CCFFCC'><div align='center'><span class='texto'>VALOR</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'>UNIDAD</span></div></TD>
";
$dis = date("d");
$mes = date("m");
$anos = date("Y");
$fechar = $anos.'-'.$mes.'-'.$dis;
for ($i = 1; $i <= $data->sheets[0]['numRows'] ; $i++)
{
for ($j = 1; $j <=5; $j++)
{
//echo "\"".$data->sheets[0]['cells'][$i][$j]."\",";
$data2[$j]=$data->sheets[0]['cells'][$i][$j];
$tere = 0;
}
$total = $total + 1;
$control = mysql_query('SELECT cedula , nombre FROM cartera_estado_contable WHERE cedula = "' . "$data2[1]". '" and fecha_nomina = "2011-06-30" order by nombre ');
if (!$control) {
die('Invalid query 2: ' . mysql_error());
}
list($cedula, $nombre) = mysql_fetch_row($control);
if ((mysql_num_rows($credit)!=0))
{
printf("<tr>
<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$data2[1]."</span></div></td>
<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$data2[2]."</span></div></td>
<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$data2[3]."</span></div></td>
<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$data2[4]."</span></div></td>
<td bgcolor='#FFFFCC'><div align='center' class='lista'>".$data2[5]."</span></div></td> ");
}
}
echo "</table>";
echo'<table width="300" border="0" cellspacing="2" cellpadding="2" align = "center">
<tr align="center">
<td colspan="4"><font face="Georgia, Times New Roman, Times, serif" color="#FF0000"><b align = "center">INFORME DE REGISTROS</b></font></td>
</tr>
<tr align="center" bgcolor="#DDDDDD">
<td bgcolor="#DDDDDD" width="300" ><font face="Geneva, Arial, Helvetica, san-serif" size="2" color="#000099">TOTAL</font></td>
</tr>';
printf ("<tr align='center' bgcolor='#f4f4f4'>
<td width='300'><font face='Geneva, Arial, Helvetica, san-serif' size='2' color=#993300'>$total</td></tr>");
echo "</table>";
}
?>