<?php
include("config.php");
$id = $_GET["id"];
$concepto = "ANULACION DE PRESTAMO #: ".$id;

$str = "SELECT * FROM prestamos WHERE id_pago='$numero' AND multimo_pago>0";
$c = $sql = mysql_query($str);
$total = 0;
while($r = mysql_fetch_array($sql)){
	$total += $r["multimo_pago"];
	$cliente = $r5["nombre_cliente"];
	
}
if($total<=0){
	$a = mysql_query("UPDATE prestamos SET estado_prestamo='Anulado',balance_capital=0,balance_prestamo=0  WHERE id_prestamo='$id'");
	
	$d = mysql_query("INSERT INTO transacciones SET fecha=NOW(), monto=0, concepto='$concepto', balance=0, nom_cliente='$cliente'");

	
	
}else{
	echo "3";
	return;
}

if($a){
	echo "1";
}else{
	echo "2";
}
?>