<?php
include "../../inc/inc.koneksi.php";

$kode       = $_POST['kode'];
$kodeppi    = $_POST['kodeppi'];

$sql  = mysql_query("SELECT * FROM piutang WHERE nofak='$kode'");
$row  = mysql_num_rows($sql);
if ($row>0){
	$r=mysql_fetch_assoc($sql);
	
	$sql1= mysql_query("SELECT sum(tunai) as jtunai FROM jurppi WHERE nofak= '$kode' AND kode_ppi='$kodeppi'");
	$row1= mysql_num_rows($sql1);
	if($row1>0){
		$r1= mysql_fetch_assoc($sql1);
		$jtunai=$r1['jtunai'];
	}else{
		$jtunai=0;		
	}
	$data['jumlah']=$r['jumlah']-$r1['jtunai'];
	$data['tglfak']=$r['tanggal'];
	echo json_encode($data);
}else{
	$data['jumlah']='';
	$data['tglfak']='';
	echo json_encode($data);
}
?>