File: /home/asjudine/public_html/pages/formulario_liquidacion_policia_creditos.php
<?php
global $dbi;
$espacio = ' ';
$linea = '-';
require_once("../Conectarse.php");
/////////////////////////////////////
///// INFORMACION DE JURIDICO ///////
/////////////////////////////////////
/*
$busca_cartera_juridica = mysql_query('SELECT cedula, estado FROM cartera_serviasjudinet WHERE cedula = "'.$_GET["ced2"].'" ');
if (!$busca_cartera_juridica) {
die('Invalid query error Search Cartera: ' . mysql_error());
}
$registros = mysql_num_rows($busca_cartera_juridica);
list($cedula_juridica, $estado_juridica) = mysql_query($busca_cartera_juridica);
if($registros != 0){
$esta_juridica = "Esta en Cartera de Juridicos - Revisar ";
}
else{
$esta_juridica = "";
}
$procesos_vigentes = 0;
$procesos_historicos = 0;
$busca_proceso = mysql_query('SELECT cedula, estado_proceso FROM procesos WHERE cedula = "'.$_GET["ced2"].'" ');
if (!$busca_proceso) {
die('Invalid query error Search procesos: ' . mysql_error());
}
$registros_procesos = mysql_num_rows($busca_proceso);
if($registros_procesos != 0){
while(list($cedula_proceso, $estado_proceso) = mysql_query($busca_proceso)){
if($estado_proceso == "V"){
$procesos_vigentes = $procesos_vigentes + 1;
}
elseif($estado_juridica == "H"){
$procesos_historicos = $procesos_historicos + 1;
}
}
$cantidad_procesos_vigentes = $procesos_vigentes;
$cantidad_procesos_historios = $procesos_historicos;
$mensaje_procesos = "Tiene " .$cantidad_procesos_vigentes. " procesos vigentes y ".$cantidad_procesos_historios. " procesos historicos ";
}
else{
$mensaje_procesos = "No tiene procesos juridicos";
}
*/
/////////////////////////////////////
// INFORMACION DE CREDITO ROTATIVO //
/////////////////////////////////////
/*$consultaconsultorio = mysql_query('SELECT unidad, promocion FROM consultorio_creditos_policia WHERE cedula = "' . $_GET["ced2"] . '"');
list($unidad, $promocion) = mysql_fetch_row($consultaconsultorio);*/
//comento desde aqui
/*
$consultacredito = mysql_query('SELECT unidad, promocion FROM credito_rotativo WHERE cedula = "' . $_GET["ced2"] . '" and libranza_credito = "'.$_GET["cred"].'" ');
list($unidad, $promocion) = mysql_fetch_row($consultacredito);
$control = mysql_query('SELECT cedula, apellidos, nombres, grado, rango, libranza_credito, direccion , telefono, celular, ciudad , email, cuenta, banco, entidad, escuela, numerosolicitud, fecha_solicitud, nombre_padre, nombre_madre, direccion_padres, ciudad_padres, telefono_padres, celular_padres, referencia_compa, celular_compa, fecha_anticipo, valor_anticipo, fecha_anticipo2, valor_anticipo2, fecha_anticipo3, valor_anticipo3, saldo_pendiente, monto_solicitado, permanencia, cedula_codeudor, nombre_codeudor, celular_codeudor, telefono_codeudor, direccion_codeudor, ciudad_codeudor, email_codeudor, planilla, proveedor, planilla2, proveedor2, planilla3, proveedor3 FROM credito_rotativo WHERE cedula = "' . $_GET["ced2"] . '" and libranza_credito = "'.$_GET["cred"].'" ');
if (!$control) {
die('Invalid query prin: ' . mysql_error());
}
$num=mysql_num_rows($control);
list($cedula, $apellidos, $nombres, $grado, $rango, $cred, $direccion, $telefono, $celular, $ciudad, $email, $cuenta, $banco, $entidad, $escuela, $numerosolicitud, $fecha_solicitud, $nompadre, $nommadre, $direcpadres, $ciudadpadres, $telpadres, $celpadres, $refcompa, $celcompa, $fecha_anticipo, $valor_anticipo, $fecha_anticipo2, $valor_anticipo2, $fecha_anticipo3, $valor_anticipo3, $saldo_pendiente, $montosolicitado, $numero_cuotas, $cedula_codeudor, $nombre_codeudor, $celular_codeudor, $telefono_codeudor, $direccion_codeudor, $ciudad_codeudor, $email_codeudor, $planilla, $proveedor, $planilla2, $proveedor2, $planilla3, $proveedor3 ) = mysql_fetch_row($control);
$fullnombre = $apellidos ." ".$nombres;
$control_int = mysql_query('SELECT cedula, fecha_credito, valor_credito, cuotas_credito, valor_cuota, fecha_ultimo_descuento, mes_inicio, ano_inicio, saldo_anterior , cuotas_pendientes, cuotas_descontadas, saldo_nuevo, cifin, estado, causal, fecha_terminacion FROM credito_rotativo_inter WHERE cedula = "' . $_GET["ced2"] . '" and credito_libranza = "' . $_GET["cred"] . '"');
if (!$control_int) {
die('Invalid query 188: ' . mysql_error());
}
$filas_credito_rotativo_cartera=mysql_num_rows($control_int);
list($cedula_inter, $fecha_credito_inicio, $valcon, $numcuo, $valcuo, $fechaul, $mesini, $anoini, $salant, $cupen, $cudesc, $salnue, $cifin, $estado, $causal, $fecha_terminacion) = mysql_fetch_row($control_int);
*/
//hasta aqui
$consulta_datos_cartera_credito = mysql_query("SELECT cedula FROM credito_rotativo_inter WHERE cedula = '".$_GET["ced2"]."' and credito_libranza = '".$_GET["cred"]."' ");
if (!$consulta_datos_cartera_credito) {
die('Invalid query 188: ' . mysql_error());
}
$existe_en_cartera = mysql_num_rows($consulta_datos_cartera_credito);
//if($existe_en_cartera == 0){
$control = mysql_query('SELECT cedula, apellidos, nombres, grado, rango, libranza_credito, direccion , telefono, celular, ciudad , email, cuenta, banco, entidad, escuela, numerosolicitud, fecha_solicitud, nombre_padre, nombre_madre, direccion_padres, ciudad_padres, telefono_padres, celular_padres, referencia_compa, celular_compa, fecha_anticipo0, valor_anticipo0, fecha_anticipo, valor_anticipo, fecha_anticipo2, valor_anticipo2, fecha_anticipo3, valor_anticipo3, fecha_anticipo4, valor_anticipo4, saldo_pendiente, monto_solicitado, permanencia, valor_cuotas, cedula_codeudor, nombre_codeudor, celular_codeudor, telefono_codeudor, direccion_codeudor, ciudad_codeudor, email_codeudor, unidad, promocion, planilla, proveedor, planilla2, proveedor2, planilla3, proveedor3, planilla4, proveedor4, fecha_corte_temporal, interes_muerto, asesor_comercial FROM credito_rotativo WHERE cedula = "' . $_GET["ced2"] . '" and libranza_credito = "'.$_GET["cred"].'" ');
if (!$control) {
die('Invalid query prin: ' . mysql_error());
}
$num=mysql_num_rows($control);
list($cedula, $apellidos, $nombres, $grado, $rango, $cred, $direccion, $telefono, $celular, $ciudad, $email, $cuenta, $banco, $entidad, $escuela, $numerosolicitud, $fecha_solicitud, $nompadre, $nommadre, $direcpadres, $ciudadpadres, $telpadres, $celpadres, $refcompa, $celcompa, $fecha_anticipo0, $valor_anticipo0, $fecha_anticipo, $valor_anticipo, $fecha_anticipo2, $valor_anticipo2, $fecha_anticipo3, $valor_anticipo3, $fecha_anticipo4, $valor_anticipo4, $saldo_pendiente, $monto_solicitado, $numero_cuotas, $valor_cuota, $cedula_codeudor, $nombre_codeudor, $celular_codeudor, $telefono_codeudor, $direccion_codeudor, $ciudad_codeudor, $email_codeudor, $unidad, $promocion, $planilla, $proveedor, $planilla2, $proveedor2, $planilla3, $proveedor3, $planilla4, $proveedor4, $fecha_corte_temporal, $interes_muerto, $asesor_comercial) = mysql_fetch_row($control);
$fullnombre = $apellidos ." ".$nombres;
//ojo con el numero de cuotas
//}
//else{
$control_int = mysql_query('SELECT cedula, credito_libranza, fecha_corte, fecha_credito, valor_credito, cuotas_credito, fecha_refinanciacion, cuotas_refinanciacion, cuotas_antesde_refinanciacion, valor_cuota, fecha_ultimo_descuento, mes_inicio, ano_inicio, saldo_anterior , cuotas_pendientes, cuotas_descontadas, saldo_nuevo, dia_inicio, mes_inicio, ano_inicio, dia_termino, mes_termino, ano_termino, cifin, estado, causal, fecha_terminacion, liquidacion_credito_reporte, fecha_liquidacion_reporte FROM credito_rotativo_inter WHERE cedula = "' . $_GET["ced2"] . '" and credito_libranza = "' . $_GET["cred"] . '"');
if (!$control_int) {
die('Invalid query 188: ' . mysql_error());
}
$num=mysql_num_rows($control_int);
$numero_row = mysql_num_rows($control_int);
list($cedula, $cred, $fecha_corte, $fecha_ingreso_credito, $monto_solicitado, $numero_cuotas, $fecha_refinanciacion, $cuotas_refinanciacion, $cuotas_antesde_refinanciacion, $valor_cuota, $fecha_ultimo_descuento, $mes_inicio, $ano_inicio, $saldo_anterior, $cuotas_pendientes, $cuotas_descontadas, $saldo_nuevo, $dia_inicio, $mes_inicio, $ano_inicio, $dia_termino, $mes_termino, $ano_termino, $cifin, $estado, $causal, $fecha_terminacion, $liquidacion_credito_reporte, $fecha_liquidacion_reporte) = mysql_fetch_row($control_int);
$fecha_inicio_credito = $ano_inicio."-".$mes_inicio."-".$dia_inicio;
$fecha_termino_credito = $ano_termino."-".$mes_termino."-".$dia_termino;
//}
//$permanencia = 24;
if($existe_en_cartera == 0){
$consulta_num_cedula = mysql_query("SELECT cedula, rango, libranza_credito, saldo_pendiente, monto_solicitado, permanencia FROM credito_rotativo WHERE cedula = '".$_GET["ced2"]."' and libranza_credito = '".$_GET["cred"]."' ");
if (!$consulta_num_cedula) {
die('Invalid query 188: ' . mysql_error());
}
list($cedula, $rango, $cred, $saldo_pendiente, $monto_solicitado, $numero_cuotas) = mysql_fetch_row($consulta_num_cedula);
}else{
$consulta_num_cedula = mysql_query("SELECT cedula, cuotas_credito FROM credito_rotativo_inter WHERE cedula = '".$_GET["ced2"]."' and credito_libranza = '".$_GET["cred"]."' ");
if (!$consulta_num_cedula) {
die('Invalid query 188: ' . mysql_error());
}
list($cedula, $numero_cuotas) = mysql_fetch_row($consulta_num_cedula);
}
/*
if($_GET["fecha_corte"] != ""){
$fecha_hoy = $_GET["fecha_corte"];
}else{
$fecha_hoy = $fecha_corte;
if(empty($fecha_corte)){
$fecha_hoy = $fecha_corte_temporal;
}
}
*/
if($_GET["fecha_corte"] != ""){
$fecha_hoy = $_GET["fecha_corte"];
}else{
if($fecha_corte){
$fecha_hoy = $fecha_corte;
}
//else{ $fecha_hoy = $fecha_corte_temporal; }
if(($fecha_corte_temporal!="0000-00-00") && ($numero_row == 0)){
$fecha_hoy = $fecha_corte_temporal;
}
if(($fecha_corte_temporal=="0000-00-00") && ($numero_row == 0)){
$fecha_hoy = date("Y-m-d");
}
//}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>CARTERA CREDITO ROTATIVO</title>
<meta http-equiv="X-UA-Compatible" content="IE=8; IE=9; IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
*{margin: 0;padding: 0;}
body{background-color:#EAEAEA;font-family:Verdana, Geneva, sans-serif;}
header {background-color: #B7271F; text-align: center;}
.titulo{width: 100%;text-align: center;background-color: #dbd8c9;color: #b20606;padding: 6px 0;font-size: 18px;}
table{margin: 0 auto;border: 8px solid #bebebe; text-align: center;}
.divirmenu{text-align: center;}
.irmenu{width: 200px;background-color: #1c4fa0;color: #fff; padding: 4px;border-radius: 6px;}
.irmenu:hover{background-color: #67a0d9; color: #000;}
.direcciona{width: 200px;background-color: #D4090C;color: #fff; padding: 4px;border-radius: 3px;}
.direcciona:hover{background-color: #67a0d9; color: #000;}
.fecha{background-color: #d6e08b; padding: 2px;color: #000;font-size: 15px; text-align: center;}
td{padding: 1px; border: 1px solid #a0a0a0;}
.td{background-color: #e5e5e5; padding: 1px 30px;color: #00135F;font-size: 14px;font-weight: 600; text-align: center;}
.boton1{width:30%;background-color: #ffffff;color: #000;padding: 2px;border:2px solid #580000;border-radius:10px;}
.boton1:hover{background-color: #6f0000;color: #fff;cursor: pointer;}
input[type=text],select{border-radius: 5px; padding: 3px;background-color: #FFF;}
.tdtitulo{background-color: #e3dec0; color: #b20606; padding: 2px; text-align: center; font-size: 12px; font-weight: 900}
.tdfull{background-color: #fff; color: #000; padding: 1px; text-align: center; font-size: 12px;}
.botonnew{width: 90px; background-color: #e3dec0;color: #b20606;padding: 1px;border-radius:5px;}
.botonnew:hover{width: 90px; background-color: #cbbd6a;color: #000;padding: 1px;border-radius:5px;}
.tdizq{background-color: #e5e5e5; padding: 1px 10px;color: #00135F;font-size: 12px;font-weight: 600; text-align: left;}
.tdcen{background-color: #e5e5e5; padding: 1px 10px;color: #00135F;font-size: 12px;font-weight: 600; text-align: center;}
.tdder{background-color: #e5e5e5; padding: 1px 2px;color: #00135F;font-size: 12px;font-weight: 600; text-align: right;}
.tddered{background-color: #e5e5e5; padding: 1px 2px;color: #D40609;font-size: 12px;font-weight: 600; text-align: right;}
.tdbono{background-color: #FFFFCC; padding: 1px 2px;color: #00135F;font-size: 12px;font-weight: 600; text-align: right;}
/*Estilo Complementario*/
.tdi{background-color: #F9FBC8; padding: 1px 10px;color: #00135F;font-size: 12px;font-weight: 600; text-align: left;}
.tdc{background-color: #F9FBC8; padding: 1px 10px;color: #00135F;font-size: 12px;font-weight: 600; text-align: center;}
.tdd{background-color: #F9FBC8; padding: 1px 2px;color: #00135F;font-size: 12px;font-weight: 600; text-align: right;}
.tdrojad{background-color: #EEE; color: #8A0002; padding: 1px 4px;font-size: 12px;font-weight: 600; text-align: right;}
.tdrojai{background-color: #EEE; color: #8A0002; padding: 1px 4px;font-size: 12px;font-weight: 600; text-align: left;}
.rojo{color:#C60000;}
.aprobado{background-color:#2CA316; color:#FFF; padding:4px; cursor:pointer;}
.aprobado:hover{background-color:#296411; color:#FFF; padding:4px;}
.denegado{background-color:#BE161B; color:#FFF; padding:4px; cursor:pointer;}
.denegado:hover{background-color:#A42023; color:#FFF; padding:4px;}
.pendiente{background-color:#5170EC; color:#FFF; padding:4px;}
.pendiente:hover{background-color:#1B3A8D; color:#FFF; padding:4px;}
.valida{background-color:#A41518; color:#FFF;}
.hit{background-color: #47547C; color: #fff; padding: 2px; text-align: center; font-size: 12px; font-weight: 900;}
.tdtitulo{background-color: #e3dec0; color: #b20606; padding: 2px; text-align: center; font-size: 12px; font-weight: 900}
.tdfull{background-color: #fff; color: #000; padding: 1px; text-align: center; font-size: 12px;}
</style>
<script>
function Verificar() {
if (document.form1.entidad.value == ""){
alert("Seleccione Entidad")
document.form1.entidad.focus()
return (false);
}
if (document.form1.escuela.value == ""){
alert("Seleccione Escuela")
document.form1.escuela.focus()
return (false);
}
/*if (document.form1.fechareporte.value == "0000-00-00")
{
alert("Verifique FECHA A REPORTAR");
document.form1.fechareporte.focus()
return (false);
}
if (document.form1.fechareporte.value == "")
{
alert("Verifique FECHA A REPORTAR");
document.form1.fechareporte.focus()
return (false);
}
*/
if (document.form1.creditolibranza.value == "")
{
alert("Digite El Credito Libranza");
document.form1.creditolibranza.focus()
return (false);
}
if (document.form1.estadoanticipo.value == "")
{
alert("¿ TIENE ANTICIPO ?");
document.form1.estadoanticipo.focus()
return (false);
}
/*var dt = new Date();
if (document.form1.fechareporte.value < dt)
{
alert("Verifique Fecha De Reporte");
document.form1.fechareporte.focus()
return (false);
}
if (document.form1.actuacion.value == "")
{
alert("Escriba Una Gestion");
document.form1.actuacion.focus()
return (false);
}*/
return(true);
}
</script>
</head>
<body>
<header>
<img src="../ELEMENTS/bannerInterasjudinet.png" alt="" width=" 700" height="70">
</header>
<h3 class="titulo">CONSULTA CREDITO ROTATIVO</h3>
<p align="center"><input name="menu2" type="button" class="irmenu" id="menu2" onclick="window.location.href='credito_rotativo_consulta_liquidacion_policia.php'" value="VOLVER" /></p>
<?php echo $esta_juridica; ?>
<?php echo $mensaje_procesos; ?>
<form action="" method="post" name="form1" onSubmit="return Verificar()">
<!--NUEVVO-->
<table width="900" border="2" cellpadding="1" cellspacing="1" class="sol_cre1">
<tr>
<td class="fecha" colspan="9">DATOS LIQUIDACION</td>
</tr>
<tr>
<td class="tdtitulo">N°</td>
<td class="tdtitulo">ANTICIPOS</td>
<td class="tdtitulo">FECHA INICIO</td>
<td class="tdtitulo">N° DIAS</td>
<td class="tdtitulo">INTERES</td>
<td class="tdtitulo">GASTOS FINANCIEROS</td>
<td class="tdtitulo">VALOR TOTAL</td>
</tr>
<?php
//$fecha_mod = "2020-06-30";
//$fecha_hoy = $fecha_mod;
//2020-02-22 - se adelanta proceso para si existe en cartera del credito rotativo la fecha final sea igual al dia que se validad
/*if($filas_credito_rotativo_cartera>0){
$fecha_hoy = $fecha_credito_inicio;
//$fecha_hoy = $fecha_mod;
echo "<center>".$fecha_hoy."</center>";
}
else{
$fecha_hoy = date("Y-m-d");
}*/
$numcred = $numcred++;
$interes = 2/100;
$gastos_financieros = 1/100;
//$fecha_hoy = date("Y-m-d");
$dias_anticipo1=(strtotime($fecha_anticipo)-strtotime($fecha_hoy))/86400;
$dias_anticipo1=abs($dias_anticipo1);
$dias_anticipo1=round($dias_anticipo1);
$valor_diario_interes1 = round(($valor_anticipo*$interes)/30);
$valor_diario_gastos1 = round(($valor_anticipo*$gastos_financieros)/30);
$total_interes_uno1 = round($valor_diario_interes1*$dias_anticipo1);
$total_interes_dos1 = round($valor_diario_gastos1*$dias_anticipo1);
//$gastos_financieros1 = $valor_anticipo * $gastos_financieros;
//$valor_total1 = ceil((($total_interes_anticipo1+$gastos_financieros)+$valor_anticipo));
$valor_total1 = round($total_interes_uno1 + $total_interes_dos1);
$dias_anticipo2=(strtotime($fecha_anticipo2)-strtotime($fecha_hoy))/86400;
$dias_anticipo2=abs($dias_anticipo2);
$dias_anticipo2=round($dias_anticipo2);
$valor_diario_interes2 = round(($valor_anticipo2*$interes)/30);
$valor_diario_gastos2 = round(($valor_anticipo2*$gastos_financieros)/30);
$total_interes_uno2 = round($valor_diario_interes2*$dias_anticipo2);
$total_interes_dos2 = round($valor_diario_gastos2*$dias_anticipo2);
$valor_total2 = round($total_interes_uno2 + $total_interes_dos2);
$dias_anticipo3=(strtotime($fecha_anticipo3)-strtotime($fecha_hoy))/86400;
$dias_anticipo3=abs($dias_anticipo3);
$dias_anticipo3=round($dias_anticipo3);
$valor_diario_interes3 = round(($valor_anticipo3*$interes)/30);
$valor_diario_gastos3 = round(($valor_anticipo3*$gastos_financieros)/30);
$total_interes_uno3 = round($valor_diario_interes3*$dias_anticipo3);
$total_interes_dos3 = round($valor_diario_gastos3*$dias_anticipo3);
$valor_total3 = round($total_interes_uno3 + $total_interes_dos3);
$total_pagar_capital = round($valor_anticipo + $valor_anticipo2 + $valor_anticipo3);
$total_pagar_interes = round($valor_total1 + $valor_total2 + $valor_total3);
//$total_mensual = ceil($total_pagar / $numero_cuotas);
if($fecha_anticipo != ""){ ?>
<tr>
<td class="tdfull"><?php echo "1"; ?></td>
<td class="tdfull"><?php echo $valor_anticipo; ?></td>
<td class="tdfull"><?php echo $fecha_anticipo; ?></td>
<td class="tdfull"><?php echo $dias_anticipo1; ?></td>
<td class="tdfull"><?php echo $total_interes_uno1; ?></td>
<td class="tdfull"><?php echo $total_interes_dos1; ?></td>
<td class="tdfull"><?php echo $valor_total1; ?></td>
</tr>
<?php } ?>
<?php
if($fecha_anticipo2 != ""){ ?>
<tr>
<td class="tdfull"><?php echo "2"; ?></td>
<td class="tdfull"><?php echo $valor_anticipo2; ?></td>
<td class="tdfull"><?php echo $fecha_anticipo2; ?></td>
<td class="tdfull"><?php echo $dias_anticipo2; ?></td>
<td class="tdfull"><?php echo $total_interes_uno2; ?></td>
<td class="tdfull"><?php echo $total_interes_dos2; ?></td>
<td class="tdfull"><?php echo $valor_total2; ?></td>
</tr>
<?php } ?>
<?php
if($fecha_anticipo3 != ""){ ?>
<tr>
<td class="tdfull"><?php echo "3"; ?></td>
<td class="tdfull"><?php echo $valor_anticipo3; ?></td>
<td class="tdfull"><?php echo $fecha_anticipo3; ?></td>
<td class="tdfull"><?php echo $dias_anticipo3; ?></td>
<td class="tdfull"><?php echo $total_interes_uno3; ?></td>
<td class="tdfull"><?php echo $total_interes_dos3; ?></td>
<td class="tdfull"><?php echo $valor_total3; ?></td>
</tr>
<?php } ?>
<tr>
<td class="tdtitulo" colspan=""></td>
<td class="tdtitulo" colspan=""><?php echo $total_pagar_capital ?></td>
<td class="tdtitulo" colspan="4"></td>
<td class="tdtitulo"><?php echo $total_pagar_interes; ?></td>
</tr>
<!--
<tr>
<td class="tdtitulo" colspan="2">NUMERO CUOTAS</td>
<td class="tdfull" colspan="2"><?php echo $numero_cuotas; ?></td>
<td class="tdtitulo" colspan="2">VALOR MENSUAL</td>
<td class="tdfull"><?php echo $total_mensual; ?></td>
</tr>
-->
</table>
</form>
</body>
</html>