File: /home/asjudine/public_html/generar_num_des_especial.php
.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php
require_once("mainfile.php");
include ("config.php");
global $dbi;
$num_des=0;
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();
//$sqlnom5 = "select numero_desembolso from creditos ";
//$control5 = mysql_query($result, $dbi) or die(mysql_error());
$result = mysql_query('SELECT numero_desembolso FROM creditos');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while(list($numd2) = mysql_fetch_row($result))
{
if($numd2>$num_des)
{
$num_des = $numd2;
}
}
$num_des++;
?>
<html>
<head>
<title>Generar Desembolso - CREDITOS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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: #990000;}
.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:70px; height:22px;}
body {
background-image: url();
}
.Estilo50 {color: #CC3333;
font-family: "Arial Narrow";
font-weight: bold;
}
.Estilo51 {
color: #3366FF;
font-weight: bold;
}
-->
</style>
<script languaje="JavaScript">
function Mostrar_Fecha()
{
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado")
var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre")
document.write("<b><font face='Arial, Helvetica, sans-serif'>"+dayarray[day]+" "+daym+" de "+montharray[month]+" de "+year+"</font></b>")
}
</script>
<script language="javascript">
function AbreGral()
{
var menu;
menu=window.open("mostrar_ingreso.php","","toolbar=no,scrollbars=no,width=800,height=500,status=yes");
menu.focus();
var ventana = window.self;
ventana.opener = window.self;
ventana.close();
}
</script>
</head>
<body onLoad="document.formulario.cedula.focus()" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="formulario" action="" method="post">
<table width="671" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><fieldset><table width="669" border="0" align="center" cellpadding="2" cellspacing="2">
<tr bgcolor="#FFFFCC">
<td class="titulos"><div align="center">GENERAR DESEMBOLSO </div></td>
</tr>
<tr bgcolor="#ECE9D8">
<td height="22" class="fecha"><div align="center">
<script languaje="JavaScript">Mostrar_Fecha()</script>
</div></td>
</tr>
<tr bgcolor="#FFCC99">
<td><div align="center">
<input name="menu2" type="button" class="Estilo50" id="menu2" onClick="window.location.href='menu_credito.php'" value="IR AL MENU">
<label></label>
</div></td>
</tr>
<tr bgcolor="#FFCC99">
<td><div align="center" class="Estilo51">
<input name="generar" type="submit" class="boton" id="generar" value="Generar">
Numero Desembolso:
<input name="textfield" type="text" value="<?php echo $num_des ?>" size="15" maxlength="15" readonly = "">
</div></td>
</tr>
</table>
</fieldset></td>
</tr>
</table>
</form>
</body>
</html>
<?php
echo "<form name='form' action='' method='post'>";
require_once("mainfile.php");
include ("config.php");
global $dbi;
$total_desembolso = 0;
$total_int_ded = 0;
if(isset($_POST["generar"]))
{
$num_des = 0;
$fecha_des = date ( "Y-n-j" );
$hora_des = getdate();
$hora = $hora_des["hours"];
$minutos = $hora_des["minutes"];
$segundos = $hora_des["seconds"];
$res_hora = $hora .":". $minutos.":". $segundos;
//$sqlnom3 = "select numero_desembolso from creditos ";
//$control3 = mysql_query($sqlnom3, $dbi) or die(mysql_error());
$resu = mysql_query('SELECT numero_desembolso FROM creditos ');
if (!$resu) {
die('Invalid query: ' . mysql_error());
}
while(list($numd) = mysql_fetch_row($resu))
{
if($numd>$num_des)
{
$num_des = $numd;
}
}
$num_des++;
//$sqlnom4 = "select cedula from creditos where estado = ' ' and tipo_credito = 'E'";
//$control4 = mysql_query($sqlnom4, $dbi) or die(mysql_error());
$resulte = mysql_query('SELECT cedula FROM creditos WHERE estado = "" and tipo_credito = "E" ');
if (!$resulte) {
die('Invalid query: ' . mysql_error());
}
while(list($ced) = mysql_fetch_row($resulte))
{
/*$mssql2 = "update creditos set
numero_desembolso='$num_des',
fecha_desembolso='$fecha_des',
hora_desembolso='$res_hora',
estado='1'
where cedula = $ced";
mysql_query($mssql2, $dbi) or die(mysql_error());*/
$mssql2 = mysql_query('UPDATE creditos set numero_desembolso = "' . $_POST[num_des] . '", fecha_desembolso= "' . $_POST[fecha_des] . '" , hora_desembolso= "' . $_POST[res_hora] . '" , estado = "1" WHERE cedula = "' . $_POST[ced] . '"');
if (!$mssql2) {
die('No se actualizó la BD : ' . mysql_error());
}
}
}
//$mssql = mysql_query("select * from creditos where estado = ' ' and tipo_credito = 'E'",$dbi);
$resul2 = mysql_query('SELECT * FROM creditos WHERE estado = "" and tipo_credito = "E" ');
if (!$resul2) {
die('Invalid query: ' . mysql_error());
}
if($resul2)
{
$filas = mysql_num_rows($resul2);
if ($filas > 0)
{
// $sql = "select ciudad, cedula, nombres, grado, cuenta_ahorros, banco_cuenta, neto_consignar, interes_deducible, numero_libranza from creditos where estado = ' ' and tipo_credito = 'E'";
// $control = mysql_query($sql, $dbi) or die(mysql_error());
$resulto = mysql_query('SELECT ciudad, cedula, nombres, grado, cuenta_ahorros, banco_cuenta, neto_consignar, interes_deducible, numero_libranza FROM creditos WHERE estado = "" and tipo_credito = "E" ');
if (!$resulto) {
die('Invalid query: ' . mysql_error());
}
if ((mysql_num_rows($resulto)!=0))
{
echo "<TABLE width='1000' border='0' align='center' cellpadding='0' cellspacing='1'>
<TR>
<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>CEDULA</span></div></TD>
<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>NOMBRE</span></div></TD>
<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>GRADO</span></div></TD>
<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'># CUENTA</span></div></TD>
<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>BANCO</span></div></TD>
<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>VALOR CONSIGNAR</span></div></TD>
<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>INTERES DEDUCIBLE</span></div></TD>
<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>No. LIBRANZA</span></div></TD>
<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>SUCURSAL</span></div></TD>";
while(list($ciudad, $cedula, $nombres, $grad, $cuenta_ahorros, $banco_cuenta, $neto_consignar, $interes, $numlib) = mysql_fetch_row($resulto))
{
$valor_desembolso = $valor_desembolso + $neto_consignar;
$total_int_ded = $total_int_ded + $interes;
printf("<tr>
<td bgcolor='#C5D6FC'><div align='center' class='lista'>".$cedula."</span></div></td>
<td bgcolor='#C5D6FC'><div align='center' class='lista'>".$nombres."</span></div></td>
<td bgcolor='#C5D6FC'><div align='center' class='lista'>".$grad."</span></div></td>
<td bgcolor='#C5D6FC'><div align='center' class='lista'>".$cuenta_ahorros."</span></div></td>
<td bgcolor='#C5D6FC'><div align='center' class='lista'>".$banco_cuenta."</span></div></td>
<td bgcolor='#C5D6FC'><div align='center' class='lista'>".$neto_consignar."</span></div></td>
<td bgcolor='#C5D6FC'><div align='center' class='lista'>".$interes."</span></div></td>
<td bgcolor='#C5D6FC'><div align='center' class='lista'>".$numlib."</span></div></td>
<td bgcolor='#C5D6FC'><div align='center' class='lista'>".$ciudad."</span></div></td>");
}
echo "</table>";
}
echo "<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>TOTAL DESEMBOLSO</span></div></TD>";
echo "<td bgcolor='#C5D6FC'><div align='center' class='lista2'>".$valor_desembolso."</span></div></td>";
echo "<TD bgcolor='#FFFFCC'><div align='center'><span class='texto'>TOTAL INTERES DEDUCIBLE</span></div></TD>";
echo "<td bgcolor='#C5D6FC'><div align='center' class='lista2'>".$total_int_ded."</span></div></td>";
}
}
echo "</form>";
?>