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

$kode	= $_POST['kode'];

$text	= "SELECT * FROM jurppi_tmp WHERE nofak= '$kode'";
$sql 	= mysql_query($text);
$row	= mysql_num_rows($sql);

if ($row>0){
	while ($r=mysql_fetch_array($sql)){	
		$data['tglfak']	= $r[tgl_fak];
		$data['nopol']	= $r[nopol];
		$data['jmlpiut']= $r[jml_piut];
		$data['dibayar']= $r[dibayar];
		$data['sisa']	= $r[sisa];	
		echo json_encode($data);
	}
	$sql = mysql_query("SELECT * FROM $table WHERE batal=''");
	$row= mysql_num_rows($sql);
	$tbayar=0;
	while($r1=mysql_fetch_array($sql1)){
		$tbayar=$tbayar+$r[dibayar];
	}
	$data['tbayar']=$tbayar;
	echo json_encode($data);
}else{	
	$data['tglfak']	= '';
	$data['nopol']	= '';
	$data['jmlpiut']= '';
	$data['dibayar']= '';
	$data['sisa']	= '';
	$data['tbayar']	= '';
	echo json_encode($data);	
}
?>