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/www/afinanciera/listado_credito_rotativo_informe1.php
<?php
require_once("../Conectarse.php");
/////////////////////////////////////
// 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);*/

/*$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);*/




$consulta_datos_cartera_credito = mysql_query("SELECT cedula FROM credito_rotativo_inter WHERE cedula = '".$_GET["ced2"]."' and libranza_credito = '".$_GET["cred"]."'' ");

$existe_en_cartera = mysql_num_rows($consulta_datos_cartera_credito);

//if($existe_en_cartera == 0){
	

	


	//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;
//}








if($rango == "POLICIA"){
	
	//$fecha_hoy = $_POST["fecha_corte"];
	$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);



	$dias_anticipo4=(strtotime($fecha_anticipo4)-strtotime($fecha_hoy))/86400;
	$dias_anticipo4=abs($dias_anticipo4); 
	$dias_anticipo4=round($dias_anticipo4);
	$valor_diario_interes4 = round(($valor_anticipo4*$interes)/30);
	$valor_diario_gastos4 = round(($valor_anticipo4*$gastos_financieros)/30);
	$total_interes_uno4 = round($valor_diario_interes4*$dias_anticipo4);
	$total_interes_dos4 = round($valor_diario_gastos4*$dias_anticipo4);
	$valor_total4 = round($total_interes_uno4 + $total_interes_dos4);



	$total_pagar_capital = round($valor_anticipo + $valor_anticipo2 + $valor_anticipo3 + $valor_anticipo4);
	$total_pagar_interes = round($valor_total1 + $valor_total2 + $valor_total3 + $valor_total4);
	//$total_mensual = ceil($total_pagar / $numero_cuotas);


	//NUEVO 2020-06-12
	//$total_pagar_con_interes = (($total_pagar_capital + $total_pagar_interes) * 0.03);
	//$total_meses = $total_pagar_con_interes * $numero_cuotas;
	//$total_mas_capital = $total_meses + $total_pagar_capital;
	//$total_pagos_mensuales = $total_mas_capital / $numero_cuotas;
	//$total_pagar_mensual = round($total_pagos_mensuales);
	//$credito_total_pagar = $total_pagar_mensual * $numero_cuotas;
	//echo $total_pagar_mensual;


	//NUEVO 2020-07-06
	$total_suma_capita_interes = round($total_pagar_capital + $total_pagar_interes);
	$total_interes_proyectado = round(($total_suma_capita_interes * 0.03)*$numero_cuotas);
	$total_proyectado = round($total_suma_capita_interes + $total_interes_proyectado);
	$total_cuota_mensual = round($total_proyectado/$numero_cuotas);
	$saldo_sin_interes = round(($total_suma_capita_interes/$numero_cuotas)*$cuotas_pendientes);

	//echo "<br> capital ".$total_pagar_capital;
	//echo "<br> interes ".$total_pagar_interes;
	//echo "<br> Nuevo a Liquidar".$total_suma_capita_interes;
	//echo "<br> interes Proyectado ".$total_interes_proyectado;
	//echo "<br> total Proyectado ".$total_proyectado;
	//echo "<br> Valor Cuota Mensual ".$total_cuota_mensual;
	//echo "<br> Cuotas Pagadas ".$cuotas_descontadas;
	//echo "<br> Cuotas Pendientes ".$cuotas_pendientes;
	//echo "<br> Saldo Sin interes ".$saldo_sin_interes;
	
	
	
	
	//REFINANCIACION
	//recorrer cantidad de cuotas pagadas
	$interes_tres_porciento = 3/100;	
	
	$busca_cuotas_pagadas = mysql_query("SELECT id FROM credito_rotativo_estado_contable WHERE cedula = '".$_GET["ced2"]."' and credito_libranza = '".$_GET["cred"] ."' ");
	if (!$busca_cuotas_pagadas) {
		die('Invalid query update 4747: ' . mysql_error());  
	}
	
	while(list($id_contable) = mysql_fetch_row($busca_cuotas_pagadas)){
		$coutas_pagadas_suma = $coutas_pagadas_suma +1;
	}
	
	
	$valores1 = (($total_interes_proyectado + $total_suma_capita_interes)/$numero_cuotas);
	$valores2 = (($total_interes_proyectado + $monto_solicitado)/$numero_cuotas);
	$valores3 = $valores1 - $valores2;
	//$valores4 = $valores3 * $coutas_pagadas_suma;
	$valores4 = $valores3 * $cuotas_antesde_refinanciacion;
	
	
	$cuotas_capital_cobradas_antesde_refinanciacion = ((($total_suma_capita_interes)/$numero_cuotas)*$cuotas_antesde_refinanciacion);
	
	
	
	$total_mas_dejado_de_cobrar = $total_suma_capita_interes - $cuotas_capital_cobradas_antesde_refinanciacion + $valores4;
	
	
	$total_interes_cuotas_pendientes = (($total_mas_dejado_de_cobrar * 0.03)*$cuotas_pendientes);
	
	$suma_capital_mas_intereses_proyectados = $total_mas_dejado_de_cobrar + $total_interes_cuotas_pendientes;

}

?>




<!DOCTYPE HTML>
<html>
<head>
<title>Listado rotativo financiera</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:Geneva, Arial, Helvetica, sans-serif;}
    header {background-color: #B7271F; text-align: center;}
    .cerrarsesion{width: auto;background-color: #DBD8C9;color: #000;font-size: 13px;position:absolute;top: 15px;right:10px;z-index:0;padding: 10px;border-radius: 10px;cursor: pointer;}
    .cerrarsesion:hover{background-color: #ffffff;color: #000;}
    .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;}
    
    .fecha{background-color: #d6e08b; padding: 2px;color: #000;font-size: 15px; text-align: center;}
    td{border: #969696 solid 1px;}
    .tdizq{background-color: #EEE; padding: 1px 10px;color: #00135F;font-size: 13px;font-weight: 600; text-align: left;}
    .tdcen{background-color: #EEE; padding: 1px 10px;color: #00135F;font-size: 13px;font-weight: 600; text-align: center;}
    .tdder{background-color: #EEE; padding: 1px 10px;color: #00135F;font-size: 13px;font-weight: 600; text-align: right;}
	.exp{color:#8A0000; font-size:10px;}
    .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]{border-radius: 5px; padding: 3px;background-color: #FFFEF4;}
	
	.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; height: 25px;}
    .botonnew{width: 90px; background-color: #e3dec0;color: #b20606;padding: 1px;}
    .botonnew:hover{width: 90px; background-color: #cbbd6a;color: #000;padding: 1px;}
</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">
<header>
    <img src="../ELEMENTS/bannerInterasjudinet.png" alt="" width=" 700" height="70">
</header>
<h3 class="titulo">LISTADO GENERAL CREDITO ROTATIVO FINANCIERA</h3>

<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 bgcolor="#FFFFCC" class="titulos"><div align="center">LISTADO DEBITOS JURIDICA  </div></td>
  </tr>-->
  <tr bgcolor="#ECE9D8">
    <td height="22" bgcolor="#F9FFEA" class="fecha"><div align="center" class="fecha">
      <script languaje="JavaScript">Mostrar_Fecha()</script>
    </div></td>
  </tr>

  
  <tr>
    <td class="tdcen"><div align="center">
      <input name="menu2" type="button" class="irmenu" id="menu2" onClick="window.location.href='menu_gerencia_financiera.php'" value="IR AL MENU">
      <label></label>
    </div></td>
  </tr>
  
</table>
</fieldset></td>
  </tr>
</table>
</form>
</body>
</html>


<?php

echo "<form name='form' action='' method='post'>";
global $dbi;   
  
  

require_once("../Conectarse.php");
/*
  $valtota = 0; 
  $num = 0;
  $numto = 0; 
  $valto =  0;
//$mssql = mysql_query("select * from estado_contable where cuotas_pend = '$ncuo'",$dbi);
$mssql = mysql_query('SELECT * FROM debitos ');
if (!$mssql) {
	die('Invalid query: ' . mysql_error());
}

if($mssql)
{
  	$filas = mysql_num_rows($mssql);
    if ($filas > 0)
    {*/
$fechast = date("Y-m-d");
	
$control_int = mysql_query('SELECT cedula, nombre, credito_libranza, fecha_corte, fecha_credito, valor_credito, cuotas_credito, 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 cifin = "SI" ');

if (!$control_int) {
	die('Invalid query 188: ' . mysql_error());
}

$num=mysql_num_rows($control_int); 
$numero_row = mysql_num_rows($control_int);




	

if ((mysql_num_rows($control_int)!=0)) 
{	 
	echo "<TABLE width='900' border='0' align='center' cellpadding='0' cellspacing='1'>
    <TR>
	<TD class='tdtitulo'>CEDULA</TD>
	<TD class='tdtitulo'>CEDULA</TD>
	<TD class='tdtitulo'>NOMBRES</span></div></TD>		 
	<TD class='tdtitulo'>CREDITO LIBRANZA</span></div></TD>
	<TD class='tdtitulo'>VALOR CAPITAL + GENERADO</span></div></TD>
	<TD class='tdtitulo'>NUMERO DE CUOTAS</span></div></TD>
	<TD class='tdtitulo'>Cuota Pendientes</span></div></TD>
	<TD class='tdtitulo'>Cuota Descontadas</span></div></TD>	
	<TD class='tdtitulo'>Valor Ultima Cuota</span></div></TD>
	<TD class='tdtitulo'>Valor Cuota Mensual</span></div></TD>
	";		  
				
	
	while(list($cedula_inter, $nombre, $cred, $fecha_corte, $fechafil, $valcon, $numcuo, $valcuo, $fechaul, $mesini, $anoini,  $salant, $cupen, $cudesc, $salnue, $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))
	{
		
		
		
		$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 FROM credito_rotativo WHERE cedula =  "'.$cedula_inter.'" and libranza_credito = "'.$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) = mysql_fetch_row($control);

		$fullnombre = $apellidos ." ".$nombres; 
		
		
		
		
		$consulta_estado_contable = mysql_query('SELECT MAX(id) FROM credito_rotativo_estado_contable WHERE cedula =  "'.$cedula_inter.'" and credito_libranza = "'.$cred.'"');
		if (!$consulta_estado_contable) {
			die('Invalid query prin: ' . mysql_error());
		}
		list($id_contable) = mysql_fetch_row($consulta_estado_contable);
		$cantidad_filas = mysql_num_rows($consulta_estado_contable);
		
		if($cantidad_filas > 0){
			$consulta_estado_contable1 = mysql_query('SELECT valor_cuota FROM credito_rotativo_estado_contable WHERE cedula =  "'.$cedula_inter.'" and credito_libranza = "'.$cred.'" and id = "'.$id_contable.'" ');
			if (!$consulta_estado_contable1) {
				die('Invalid query prin: ' . mysql_error());
			}
			while(list($valor_cuota) = mysql_fetch_row($consulta_estado_contable1)){
				$valor_ultima_cuota = $valor_cuota;
			}
		}
		
		
		
		
		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");
			}
			//}
		}
		
		
		
		if($rango == "POLICIA"){

			//$fecha_hoy = $_POST["fecha_corte"];
			$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);



			$dias_anticipo4=(strtotime($fecha_anticipo4)-strtotime($fecha_hoy))/86400;
			$dias_anticipo4=abs($dias_anticipo4); 
			$dias_anticipo4=round($dias_anticipo4);
			$valor_diario_interes4 = round(($valor_anticipo4*$interes)/30);
			$valor_diario_gastos4 = round(($valor_anticipo4*$gastos_financieros)/30);
			$total_interes_uno4 = round($valor_diario_interes4*$dias_anticipo4);
			$total_interes_dos4 = round($valor_diario_gastos4*$dias_anticipo4);
			$valor_total4 = round($total_interes_uno4 + $total_interes_dos4);



			$total_pagar_capital = round($valor_anticipo + $valor_anticipo2 + $valor_anticipo3 + $valor_anticipo4);
			$total_pagar_interes = round($valor_total1 + $valor_total2 + $valor_total3 + $valor_total4);
			//$total_mensual = ceil($total_pagar / $numero_cuotas);


			//NUEVO 2020-06-12
			//$total_pagar_con_interes = (($total_pagar_capital + $total_pagar_interes) * 0.03);
			//$total_meses = $total_pagar_con_interes * $numero_cuotas;
			//$total_mas_capital = $total_meses + $total_pagar_capital;
			//$total_pagos_mensuales = $total_mas_capital / $numero_cuotas;
			//$total_pagar_mensual = round($total_pagos_mensuales);
			//$credito_total_pagar = $total_pagar_mensual * $numero_cuotas;
			//echo $total_pagar_mensual;


			//NUEVO 2020-07-06
			$total_suma_capita_interes = round($total_pagar_capital + $total_pagar_interes);
			$total_interes_proyectado = round(($total_suma_capita_interes * 0.03)*$numero_cuotas);
			$total_proyectado = round($total_suma_capita_interes + $total_interes_proyectado);
			$total_cuota_mensual = round($total_proyectado/$numero_cuotas);
			$saldo_sin_interes = round(($total_suma_capita_interes/$numero_cuotas)*$cuotas_pendientes);

			//echo "<br> capital ".$total_pagar_capital;
			//echo "<br> interes ".$total_pagar_interes;
			//echo "<br> Nuevo a Liquidar".$total_suma_capita_interes;
			//echo "<br> interes Proyectado ".$total_interes_proyectado;
			//echo "<br> total Proyectado ".$total_proyectado;
			//echo "<br> Valor Cuota Mensual ".$total_cuota_mensual;
			//echo "<br> Cuotas Pagadas ".$cuotas_descontadas;
			//echo "<br> Cuotas Pendientes ".$cuotas_pendientes;
			//echo "<br> Saldo Sin interes ".$saldo_sin_interes;




			//REFINANCIACION
			//recorrer cantidad de cuotas pagadas
			$interes_tres_porciento = 3/100;	

			$busca_cuotas_pagadas = mysql_query("SELECT id FROM credito_rotativo_estado_contable WHERE cedula = '".$_GET["ced2"]."' and credito_libranza = '".$_GET["cred"] ."' ");
			if (!$busca_cuotas_pagadas) {
				die('Invalid query update 4747: ' . mysql_error());  
			}

			while(list($id_contable) = mysql_fetch_row($busca_cuotas_pagadas)){
				$coutas_pagadas_suma = $coutas_pagadas_suma +1;
			}


			$valores1 = (($total_interes_proyectado + $total_suma_capita_interes)/$numero_cuotas);
			$valores2 = (($total_interes_proyectado + $monto_solicitado)/$numero_cuotas);
			$valores3 = $valores1 - $valores2;
			//$valores4 = $valores3 * $coutas_pagadas_suma;
			$valores4 = $valores3 * $cuotas_antesde_refinanciacion;


			$cuotas_capital_cobradas_antesde_refinanciacion = ((($total_suma_capita_interes)/$numero_cuotas)*$cuotas_antesde_refinanciacion);



			$total_mas_dejado_de_cobrar = $total_suma_capita_interes - $cuotas_capital_cobradas_antesde_refinanciacion + $valores4;


			$total_interes_cuotas_pendientes = (($total_mas_dejado_de_cobrar * 0.03)*$cuotas_pendientes);

			$suma_capital_mas_intereses_proyectados = $total_mas_dejado_de_cobrar + $total_interes_cuotas_pendientes;

		}
		
		


			if($rango == "EJERCITO"){

				$interes = 3/100;
				$gastos_financieros = 1/100;
				//$fecha_hoy = date("Y-m-d");


				//$valor_total0 = round($valor_anticipo0);
				//$valor_total0 = round($total_interes_uno0*$dias_anticipo0);

				$dias_anticipo0=(strtotime($fecha_anticipo0)-strtotime($fecha_hoy))/86400;
				$dias_anticipo0=abs($dias_anticipo0); 
				$dias_anticipo0=round($dias_anticipo0);
				$valor_diario_interes0 = round(($valor_anticipo0*$interes)/30);
				//$valor_diario_gastos0 = round(($valor_anticipo0*$gastos_financieros)/30);
				$total_interes_uno0 = round($valor_diario_interes0*$dias_anticipo0);
				//$total_interes_dos0 = round($valor_diario_gastos0*$dias_anticipo0);
				$valor_total0 = 0;



				$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);
				//$valor_total1 = round($total_interes_uno1*$total_interes_uno1);
				$valor_total1 = round($total_interes_uno1);



				$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);


				$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);




				$dias_anticipo4=(strtotime($fecha_anticipo4)-strtotime($fecha_hoy))/86400;
				$dias_anticipo4=abs($dias_anticipo4); 
				$dias_anticipo4=round($dias_anticipo4);
				$valor_diario_interes4 = round(($valor_anticipo4*$interes)/30);
				//$valor_diario_gastos4 = round(($valor_anticipo4*$gastos_financieros)/30);
				$total_interes_uno4 = round($valor_diario_interes4*$dias_anticipo4);
				//$total_interes_dos4 = round($valor_diario_gastos4*$dias_anticipo4);
				$valor_total4 = round($total_interes_uno4);



				$total_pagar_capital = round($interes_muerto + $valor_anticipo0 + $valor_anticipo + $valor_anticipo2 + $valor_anticipo3 + $valor_anticipo4);
				$total_pagar_interes = round($valor_total0 + $valor_total1 + $valor_total2 + $valor_total3 + $valor_total4);
				//$total_mensual = ceil($total_pagar / $numero_cuotas);


				//NUEVO 2020-06-12 ESTO ESTA MAL
				//$total_pagar_con_interes = ($total_pagar_capital + $total_pagar_interes) * 0.03;
				//$total_meses = $total_pagar_con_interes * $numero_cuotas;
				//$total_mas_capital = $total_meses + $total_pagar_capital;
				//$total_pagos_mensuales = $total_mas_capital / $numero_cuotas;
				//$total_pagar_mensual = round($total_pagos_mensuales);
				//$credito_total_pagar = $total_pagar_mensual * $numero_cuotas;

				//echo $total_pagar_mensual;








				//NUEVO 2020-07-06
				$total_suma_capita_interes = round($total_pagar_capital + $total_pagar_interes);
				$total_interes_proyectado = round(($total_suma_capita_interes * 0.03)*$numero_cuotas);

				//OJO
				if($valor_anticipo == 0 || $valor_anticipo == "0" || $valor_anticipo == ""){
					$total_proyectado = $monto_solicitado;
				}else{
					$total_proyectado = round($total_suma_capita_interes + $total_interes_proyectado);
				}

				$total_cuota_mensual = round($total_proyectado/$numero_cuotas);
				//$saldo_sin_interes = round(($total_suma_capita_interes/$numero_cuotas)*$cuotas_pendientes);


				//Comprobar si exite o no en la tabla credito_rotativo_inter
				if($filas_credito_rotativo_cartera){
					$saldo_sin_interes = round(($total_suma_capita_interes/$numero_cuotas)*$cuotas_pendientes);
				}
				else{
					$saldo_sin_interes = $total_suma_capita_interes;
				}

				//echo "<br> capital ".$total_pagar_capital;
				//echo "<br> interes ".$total_pagar_interes;
				//echo "<br> Nuevo a Liquidar".$total_suma_capita_interes;
				//echo "<br> interes Proyectado ".$total_interes_proyectado;
				//echo "<br> total Proyectado ".$total_proyectado;
				//echo "<br> Valor Cuota Mensual ".$total_cuota_mensual;
				//echo "<br> Cuotas Pagadas ".$cuotas_descontadas;
				//echo "<br> Cuotas Pendientes ".$cuotas_pendientes;
				//echo "<br> Saldo Sin interes ".$saldo_sin_interes;
			}


		
			$tota = $tota + 1 ;
		
		
			/*
			<TD bgcolor='#ECE9D8'><div align='center' class='lista'><input type='button' value=$cedula name='cedu' class='botonnew' onClick =window.location.href='credito_rotativo_formulario_financiera.php?ced2=$cedula&numcon=$numcon&cred=$cred'></a></span></div></TD>
			 
			*/
			printf("<tr>

			<td class='tdfull'><input type='button' value=$cedula name='cedu' class=botonnew onClick =window.open('../credito_rotativo_formulario_consulta_estado.php?ced2=$cedula&cred=$cred','','top=30,left=50,toolbar=yes,scrollbars=yes,width=900,height=630,status=yes')></a></td>
			<td class='tdfull'>".$cedula_inter."</span></div></td>
			<td class='tdfull'>".$nombre."</span></div></td>
			<td class='tdfull'>".$cred."</span></div></td>
			<td class='tdfull'>".$total_suma_capita_interes."</td>
			<td class='tdfull'>".$numcuo."</td>
			<td class='tdfull'>".$cupen."</td>
			<td class='tdfull'>".$cudesc."</td>
			<td class='tdfull'>".$valor_ultima_cuota."</td>
			<td class='tdfull'>".$total_cuota_mensual."</td>
			
			
			");
			
		
		
		
	}
	
		echo "</table>";
		
}				 	
							
echo "<TABLE width='200' border='0' align='center' cellpadding='0' cellspacing='1'>
<TR>	 
<TD class='tdtitulo'>TOTAL</TD>";	
printf("<tr>
<td class='tdfull'>".$tota."</td>");  			

echo "</form>";

?>