<?php
include("procesos/creditos_formulas.php");
include "verifica.php";
include "conexion.php";

$xper_codi = $_REQUEST['xper_codi'];

$r_credito = mysqli_query($conexion, "SELECT * FROM personas p WHERE per_codi=$xper_codi;");
while($row_credito = mysqli_fetch_array($r_credito)){

	if($row_credito['per_credito']==1){		
		$arr_credito = $creform->calcular_credito_saldo($conexion,$row_credito['per_codi'],$row_credito['per_importe_credito'],$row_credito['per_importe_sobregiro']);			
	}else{
	
		$arr_credito = array(	
			"xper_credito" => 0,				
			"xmonto_credito" => 0,
			"xutilizado" => 0,
			"xdisponible" => 0,
			"xdias_vencidos" => 0,
		);			
	}
	

?>	
	<script language="javascript">
	
	parent.agregar_credito_plazo2('<?php echo $arr_credito['xper_credito'];?>',
						  '<?php echo number_format($arr_credito['xmonto_credito'],2,'.',',');?>',
						  '<?php echo number_format($arr_credito['xutilizado'],2,'.',',');?>',
						  '<?php echo number_format($arr_credito['xdisponible'],2,'.',',');?>',
						  '<?php echo $arr_credito['xdias_vencidos'];?>',
						  '<?php echo number_format($arr_credito['xdisponible'],2,'.','');?>');
	
	</script>	

<?php
}

?>
