File: /home/asjudine/www/ingresar_creditos_ventas.php
<?php
require_once("mainfile.php");
include ("config.php");
global $dbi;
$espacio = ' ';
$linea = '-';
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();
$resul = mysql_query('SELECT cedula, apellidos_noms, direccion, celular, telefono, ciudad, email FROM datos_basicos_rc WHERE cedula = "' . $HTTP_GET_VARS["ced2"] . '" ');
if (!$resul) {
die('Invalid query: ' . mysql_error());
}
$num3=mysql_num_rows($resul);
list($cedula, $apes, $direccion, $celular, $telefono, $ciudad, $email) = mysql_fetch_row($resul);
$resul5 = mysql_query('SELECT cedula, grado, nombre, devengado, descuento, neto, unidad FROM datos_credito WHERE cedula = "' . $HTTP_GET_VARS["ced2"] . '" ');
if (!$resul5) {
die('Invalid query: ' . mysql_error());
}
list($codm, $grado, $nombredt, $devengado, $descuentos, $neto, $unidad) = mysql_fetch_row($resul5);
if($num3==0)
{
$apes = $nombredt;
$cedula = $codm;
}
if(isset($_POST["guardar"]))
{
//$mssql = mysql_query("select * from solicitud_credito where cedula = '$ced'",$dbi);
$resul9 = mysql_query('SELECT * FROM solicitud_credito WHERE cedula = "' . $_POST["ced"] . '" ');
if (!$resul9) {
die('Invalid query: ' . mysql_error());
}
$num=mysql_num_rows($resul9);
//$mssql2 = mysql_query("select * from creditos where cedula = '$ced'",$dbi);
$resul2 = mysql_query('SELECT * FROM creditos WHERE cedula = "' . $_POST["ced"] . '" ');
if (!$resul2) {
die('Invalid query: ' . mysql_error());
}
$num2=mysql_num_rows($resul2);
if($num2==0)
{
if($num==0)
{
$tieser = $tie.$espacio.$ma;
$interes=0.04;
$temp1=0;
$val_mensual=0;
$temp1 = ($mon * $interes) * $num_cuotas;
$val_mensual = ($mon + $temp1) / $num_cuotas;
$control3 = mysql_query('SELECT cedula, numero_desembolso FROM solicitud_credito WHERE cedula = "' . $_POST[ced] . '"');
if (!$control3) {
die('Invalid query: ' . mysql_error());
}
list($ceduli, $numdem) = mysql_fetch_row($control3);
$num4=mysql_num_rows($control3);
if ($num4 != "")
{
$mssql = mysql_query("UPDATE solicitud_credito set ced_ciudad= '" . $_POST[ciuced] . "', nombre= '" . $_POST[ape] . "', fecha = '" . $_POST[fechas] . "', direccion='" . $_POST[dir] . "', ciudad= '" . $_POST[ciu] . "', telefono= '" . $_POST[tel] . "', celular= '" . $_POST[cel] . "', email= '" . $_POST[email] . "', unidad= '" . $_POST[uni] . "', codigo_plan= '" . $_POST[plan] . "', numero_cuenta= '" . $_POST[cue] . "', banco= '" . $_POST[ban] . "', grado= '" . $_POST[gra] . "', codigo_sucursal= '" . $_POST[codigo_sucursal] . "', numero_libranza= '" . $_POST[num_lib] . "', cuotas_credito= '" . $_POST[num_cuotas] . "', valor_mensual_cre = '" .$val_mensual. "', con_valor_total = '" . $_POST[vmt] . "', tipo_solicitud_cre= '2', estado_cre = '0' WHERE cedula= '" . $_POST[ced] . "'");
if (!$mssql) {
die('Invalid query udate: ' . mysql_error());
}
echo "<script>alert('Los datos fueron Modificados ');</script>";
}
else
{
mysql_query("INSERT INTO solicitud_credito(cedula, ced_ciudad, nombre, fecha, direccion, ciudad, telefono, celular, email, devengado, descuentos, neto, unidad, monto_solicitado, numero_cuenta, banco, codigo_asesor, codigo_militar, grado, codigo_sucursal, numero_libranza, cuotas_credito, valor_mensual_cre , con_valor_total, tipo_solicitud_cre, estado_cre) VALUES ('" . $_POST["ced"] . "', '" . $_POST["ciuced"] . "', '" . $_POST["ape"] . "', '" . $_POST["fechas"] . "', '" . $_POST["dir"] . "', '" . $_POST["ciu"] . "', '" . $_POST["tel"] . "', '" . $_POST["cel"] . "', '" . $_POST["email"] . "', '" . $_POST["dev"] . "', '" . $_POST["desc"] . "', '" . $_POST["net"] . "', '" . $_POST["uni"] . "', '" . $_POST["mon"] . "' , '" . $_POST["cue"] . "', '" . $_POST["ban"] . "', '" . $_POST["ase"] . "', '" . $_POST["codigom"] . "', '" . $_POST["gra"] . "', '" . $_POST["codigo_sucursal"] . "', '" . $_POST["num_lib"] . "', '" . $_POST["num_cuotas"] . "', '" . "$val_mensual". "', '" . $_POST["vmt"] . "', '2', '0')");
echo "<script>alert('Los datos fueron grabados correctamente');</script>";
}
$resu = mysql_query('SELECT cedula, ced_ciudad, nombre, direccion, ciudad, telefono, celular, email, devengado, descuentos, neto, unidad, monto_solicitado, numero_cuenta, banco, codigo_militar, grado, numero_libranza, con_valor_mensual, con_valor_total FROM solicitud_credito WHERE cedula = "' . $_POST["ced"] . '" ');
if (!$resu) {
die('Invalid query: ' . mysql_error());
}
list($cedula, $ced_ciudad, $apes, $direccion, $ciudad, $telefono, $celular, $email, $devengado, $descuentos, $neto, $unidad, $monto_solicitado, $numero_cuenta, $banco, $codm, $grado, $numero_libranza, $val_menj, $val_ment) = mysql_fetch_row($resu);
}else{
echo "<script>alert('Tiene una Solicitud pendiente');</script>";
}
}else{
echo "<script>alert('Tiene un Credito pendiente');</script>";
}
}
$sql = mysql_query('SELECT * FROM entidad_laboral order by nombre ');
if (!$sql) {
die('Invalid query: ' . mysql_error());
}
$row_sql = mysql_fetch_assoc($sql);
$totalRows_sql = mysql_num_rows($sql);
/*$query_sql2 = "SELECT * FROM descuentos order by codigo";
$sql2 = mysql_query($query_sql2, $dbi) or die(mysql_error());*/
$sql2 = mysql_query('SELECT * FROM descuentos order by codigo ');
if (!$sql2) {
die('Invalid query: ' . mysql_error());
}
$row_sql2 = mysql_fetch_assoc($sql2);
$totalRows_sql2 = mysql_num_rows($sql2);
/*$query_sql3 = "SELECT * FROM descuentos order by codigo";
$sql3 = mysql_query($query_sql3, $dbi) or die(mysql_error());*/
$sql3 = mysql_query('SELECT * FROM descuentos order by codigo ');
if (!$sql3) {
die('Invalid query: ' . mysql_error());
}
$row_sql3 = mysql_fetch_assoc($sql3);
$totalRows_sql3 = mysql_num_rows($sql3);
/*$query_sql4 = "SELECT * FROM vendedores where estado = '1' order by vendedor";
$sql4 = mysql_query($query_sql4, $dbi) or die(mysql_error());*/
$sql4 = mysql_query('SELECT * FROM vendedores WHERE estado = "1" order by vendedor ');
if (!$sql4) {
die('Invalid query: ' . mysql_error());
}
$row_sql4 = mysql_fetch_assoc($sql4);
$totalRows_sql4 = mysql_num_rows($sql4);
/*$query_sql5 = "SELECT * FROM sucursal order by nombre";
$sql5 = mysql_query($query_sql5, $dbi) or die(mysql_error());*/
$sql5 = mysql_query('SELECT * FROM sucursal order by nombre ');
if (!$sql5) {
die('Invalid query: ' . mysql_error());
}
$row_sql5 = mysql_fetch_assoc($sql5);
$totalRows_sql5 = mysql_num_rows($sql5);
/*$query_sql8 = "SELECT * FROM sucursal order by nombre";
$sql8 = mysql_query($query_sql8, $dbi) or die(mysql_error());*/
$sql8 = mysql_query('SELECT * FROM sucursal order by nombre ');
if (!$sql8) {
die('Invalid query: ' . mysql_error());
}
$row_sql8 = mysql_fetch_assoc($sql8);
$totalRows_sql8 = mysql_num_rows($sql8);
?>
<!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>INGRESAR SOLICITUD DE CREDITO</title>
<style type="text/css">
<!--
.est_cont5 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
font-style: normal;
font-weight: normal;
background-color: #EDFAF4;
margin: 2px;
padding: 2px;
height: auto;
width: auto;
border: thin groove #E9AAF0;
color: #C72350;
}
.color_fondo_sc {
background-color: #DCE0E4;
}
.Estilo1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
font-style: normal;
font-weight: bold;
background-color: #D6ECFE;
margin: 2px;
padding: 2px;
height: auto;
width: auto;
border: thin groove #E9AAF0;
color: #C72350;
}
.Estilo2 {
font-size: 14px;
font-weight: bold;
}
.est_cont2 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
color: #2B39EC;
background-color: #F0F5CF;
height: 18px;
width: auto;
border: thin solid #FABF85;
}
.est_cont6 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 11px;
font-style: normal;
font-weight: normal;
color: #006262;
background-color: #EDFED3;
margin: 1px;
padding: 1px;
height: auto;
width: auto;
border: thin solid #D9B6F8;
}
.Estilo3 {
color: #C72350;
font-weight: bold;
}
.sol_cre1 {
font-family: "Times New Roman", Times, serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
color: #0B3495;
background-color: #E6FAFF;
margin: 1px;
padding: 1px;
height: 18px;
width: auto;
border: thin outset #56AD95;
}
.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;
}
.Estilo50 {color: #CC3333;
font-family: "Arial Narrow";
font-weight: bold;
}
.Estilo52 {color: #FF6633;
font-size: 16px;
}
.Estilo53 {color: #2492FF;
font-weight: bold;
}
.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;
}
.Estilo54 {
color: #7DD096;
font-weight: bold;
}
.campo1 {background-color: #B7FFFF;
border: thin dashed #B6B6B6;
}
.campo1 {font-family: "Courier New", Courier, monospace;
font-size: 16px;
font-style: normal;
font-weight: bold;
background-color: #E1EFFD;
border: thin doble #009999;
}
.campo1 { font-family: "Courier New", Courier, monospace;
font-size: 11px;
color: #5151FF;
background-color: #C4E4FD;
border: thin solid #009999;
height: 18px;
width: auto;
}
.datos1 {font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 16px;
font-style: normal;
text-decoration: blink;
background-color: #CCFFCC;
margin: 5px;
padding: 7px;
height: auto;
width: auto;
border: thin solid #0099FF;
}
.datos1 {font-family: Georgia, "Times New Roman", Times, serif;
font-size: 16px;
background-color: #FDE0C1;
margin: 2px;
padding: 3px;
border: medium doble #DBAED7;
}
.datos1 { font-family: Georgia, "Times New Roman", Times, serif;
font-size: 11px;
font-weight: normal;
background-color: #B8F5E8;
margin: 4px;
padding: 5px;
border: thin outset #009999;
}
.datos2 { font-family: "Courier New", Courier, monospace;
font-size: 10px;
font-style: normal;
font-weight: normal;
color: #0033FF;
background-color: #FFE2C6;
margin: 2px;
padding: 3px;
border: medium doble #EEBFEB;
}
.datos3 { font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-style: normal;
font-weight: normal;
color: #FF3300;
background-color: #A6ECD7;
margin: 4px;
padding: 4px;
border: medium groove #CCCCFF;
}
.go { font-family: "Times New Roman", Times, serif;
font-size: 9px;
font-style: normal;
color: #FF6633;
background-color: #FBDCBD;
padding: 1px;
height: auto;
width: auto;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
}
.Estilo64 {
font-size: 8px;
font-weight: bold;
color: #000000;
}
.Estilo65 {color: #C72350}
.Estilo66 {
font-size: 12px;
font-weight: bold;
}
.label {background-color: #FFFFCC; font-size: 16px; font-family: Arial; color:#0000CC; display: block;}
-->
</style>
<script Language="JavaScript">
function validarEntero(valor){
//intento convertir a entero.
//si era un entero no le afecta, si no lo era lo intenta convertir
valor = parseInt(valor)
//Compruebo si es un valor numérico
if (isNaN(valor)) {
//entonces (no es numero) devuelvo el valor cadena vacia
return ""
}else{
//En caso contrario (Si era un número) devuelvo el valor
return valor
}
}
function valida_envia(){
//valido LOS APELLIDOS
if (document.form1.ape.value.length==0){
alert("Tiene que escribir sus apellidos")
document.form1.ape.focus()
return (false);
}
//valido el nombre
if (document.form1.noms.value.length==0){
alert("Tiene que escribir sus nombres")
document.form1.noms.focus()
return (false);
}
//valido la cedula
if (document.form1.ced.value.length==0){
alert("Tiene que escribir el numero de cedula")
document.form1.ced.focus()
return (false);
}
return (true);
}
</script>
</head>
<body >
<form action="" method="post" name="consult" id="consult">
<div align="center">
<table width="253" border="3" cellpadding="3" cellspacing="3" class="recaudo">
<caption>
</caption>
<tr>
<th colspan="2" scope="col"><label>Digite el Numero de Cedula </label></th>
</tr>
<tr>
<td width="162"><div align="center"><span class="Estilo52">CEDULA : </span></div></td>
<td width="131"><div align="center">
<input name="ced2" type="text" id="ced2" size="20" maxlength="20" />
</div></td>
</tr>
<tr>
<td height="32" colspan="2"><div align="center">
<input name="consultar" type="submit" class="Estilo53" id="consultar" value="Consultar" />
</div></td>
</tr>
</table>
</div>
</form>
<form action="" method="post" onsubmit="return valida_envia()" enctype="multipart/form-data" name="form1" class="color_fondo_sc" id="form1">
<div align="center">
<div class="Estilo1">SOLICITUD CREDITO</div>
<table width="760" border="2" cellpadding="1" cellspacing="1" class="est_cont5">
<caption>
<div align="center"><br />
<span class="Estilo2">DATOS BASICOS - DEUDOR </span><br />
</div>
</caption>
<tr>
<th scope="col"> </th>
<th scope="col"><div align="right">
<div align="right"><strong>Fecha Solicitud :</strong></div>
</div></th>
<th width="94" scope="col"><div align="left">
<input name="fechas" type="text" class="est_cont2" id="fechas" value="<?php echo date("Y-m-d"); ?>" size="10" maxlength="10" />
</div></th>
<th scope="col"><div align="right"><strong>Sucursal :</strong></div></th>
<th colspan="3" scope="col"><div align="left">
<select name="codigo_sucursal" class="est_cont2">
<option value="">--SELECCIONE SUCURSAL--</option>
<?php
do {
?>
<option value="<?php echo $row_sql8['codigo'];?>"><?php echo $row_sql8['nombre']?></option>
<?php
} while ($row_sql8 = mysql_fetch_assoc($sql8));
$rows = mysql_num_rows($sql8);
if($rows8 > 0) {
mysql_data_seek($sql8, 0);
$row_sql8 = mysql_fetch_assoc($sql8);
}
?>
</select>
</div></th>
</tr>
<tr>
<td width="95"><div align="right"><strong>Apellidos y Nombres:</strong></div></td>
<td colspan="3"><div align="left">
<input name="ape" type="text" class="est_cont2" id="ape" value="<?php echo $apes ?>" size="66" maxlength="65" />
</div></td>
<td><div align="right"><strong>Cogido Militar :</strong></div></td>
<td colspan="2"><div align="left">
<input name="codigom" type="text" class="est_cont2" id="codigom" value="<?php echo $codm ?>" size="20" maxlength="20" />
</div></td>
</tr>
<tr>
<td height="21"><div align="right"><strong>Cedula No:</strong></div></td>
<td width="105"><div align="left">
<input name="ced" type="text" class="est_cont2" id="ced" value="<?php echo $cedula ?>" size="20" maxlength="20" />
</div></td>
<td><div align="right"><strong>De:</strong></div></td>
<td><div align="left">
<input name="ciuced" type="text" class="est_cont2" id="ciuced" value="<?php echo $ced_ciudad ?>" size="20" maxlength="20" />
</div></td>
<td><div align="right"><strong>Unidad :</strong></div></td>
<td colspan="2"><div align="left">
<input name="uni" type="text" class="est_cont2" id="uni" value="<?php echo $unidad ?>" size="35" maxlength="35" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Cuidad :</strong></div></td>
<td><div align="left">
<input name="ciu" type="text" class="est_cont2" id="ciu" value="<?php echo $ciudad ?>" size="20" maxlength="20" />
</div></td>
<td><div align="right"><strong>Direccion :</strong></div></td>
<td colspan="2"><div align="left">
<input name="dir" type="text" class="est_cont2" id="dir" value="<?php echo $direccion ?>" size="50" maxlength="50" />
</div></td>
<td width="111"><div align="right"><strong>Grado :</strong></div></td>
<td width="66"><div align="left">
<input name="gra" type="text" class="est_cont2" id="gra" value="<?php echo $grado ?>" size="12" maxlength="10" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Telefono :</strong></div></td>
<td><div align="left">
<input name="tel" type="text" class="est_cont2" id="tel" value="<?php echo $telefono ?>" size="20" maxlength="20" />
</div></td>
<td><div align="right"><strong>Celular :</strong></div></td>
<td>
<div align="left">
<input name="cel" type="text" class="est_cont2" id="cel" value="<?php echo $celular ?>" size="20" maxlength="20" />
</div></td>
<td><div align="right"><strong>E-mail :</strong></div></td>
<td colspan="2"><div align="left">
<input name="email" type="text" class="est_cont2" id="email" value="<?php echo $email ?>" size="35" maxlength="35" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Total Devengado $:</strong></div></td>
<td><div align="left">
<input name="dev" type="text" class="est_cont2" id="dev" value="<?php echo $devengado ?>" size="12" maxlength="10" />
</div></td>
<td><div align="right"><strong>Descuentos $:</strong></div></td>
<td width="139"><div align="left">
<input name="desc" type="text" class="est_cont2" id="desc" value="<?php echo $descuentos ?>" size="12" maxlength="10" />
</div></td>
<td width="110"><div align="right"><strong>Neto a Recibir $:</strong></div></td>
<td colspan="2"><div align="left">
<input name="net" type="text" class="est_cont2" id="net" value="<?php echo $neto ?>" size="12" maxlength="10" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Monto Solicitado $ :</strong></div></td>
<td><div align="left">
<input name="mon" type="text" class="est_cont2" id="mon" value="<?php echo $monto_solicitado ?>" size="12" maxlength="10"/>
</div></td>
<td><div align="right"><strong>Cuotas credito :</strong></div></td>
<td><div align="left">
<select name="num_cuotas" class="est_cont2" id="num_cuotas">
<option value="6" selected="selected">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
</select>
</div></td>
<td><div align="right"><strong>Numero libranza:</strong></div></td>
<td colspan="2"><div align="left">
<input name="num_lib" type="text" class="est_cont2" id="num_lib" value="<?php echo $numero_libranza ?>" size="12" maxlength="12" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Cuenta No :</strong></div></td>
<td><div align="left">
<input name="cue" type="text" class="est_cont2" id="cue" value="<?php echo $numero_cuenta ?>" size="20" maxlength="20" />
</div></td>
<td><div align="right"><strong>Banco :</strong></div></td>
<td><div align="left">
<input name="ban" type="text" class="est_cont2" id="ban" value="<?php echo $banco ?>" size="20" maxlength="20" />
</div></td>
<td><div align="right"><strong>Vendedor :</strong></div></td>
<td colspan="2"><select name="ase" id="ase">
<option value="">-SELECCIONE VENDEDOR-</option>
<?php
do {
?>
<option value="<?php echo $row_sql4['codigo'];?>"><?php echo $row_sql4['vendedor']?></option>
<?php
} while ($row_sql4 = mysql_fetch_assoc($sql4));
$rows4 = mysql_num_rows($sql4);
if($rows4 > 0) {
mysql_data_seek($sql4, 0);
$row_sql4 = mysql_fetch_assoc($sql4);
}
?>
</select></td>
</tr>
</table>
<p> </p>
<p><span class="label"><?php printf("<TR>
<TD bgcolor='#ECE9D8'><div align='center' class='lista'><input type='button' value='Ingresar Codeudor' name='cedu' class=est_cont1 onClick =window.open('ingresar_codeudor_sol.php?cedul=$ced2','','top=50,left=100,toolbar=yes,scrollbars=yes,width=730,height=250,status=yes')></a></span></div></TD> </TR>"); ?></span></p>
<p>
<label>
<input name="guardar" type="submit" class="col_cre2" id="guardar" value="Guardar" />
</label>
</p>
<p>
<input name="menu2" type="button" class="Estilo50" id="menu2" onclick="window.location.href='menu_solicitud_credito.php'" value="IR AL MENU" />
</p>
</div>
</form>
</body>
</html>