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

$kode	= $_POST[kode];
$text	= "SELECT tanggal,kode_plg,nama_plg,jt_tempo,tanggal_jt,kode_sl,nama_sl,unit,sum(jumlah) as tjumlah FROM faktur_pj WHERE kode_pj= '$kode' GROUP BY kode_pj";
$sql 	= mysql_query($text);
$row	= mysql_num_rows($sql);
if ($row>0){
	$total=0;
	while ($r=mysql_fetch_array($sql)){
		$tgl	= $r[tanggal];
		$kodeplg= $r[kode_plg];
		$namaplg= $r[nama_plg];
		$kodesl = $r[kode_sl];
		$namasl = $r[nama_sl];
		$unit   = $r[unit];
		$jttempo= $r[jt_tempo];
		$tanggaljt= $r[tanggal_jt];
		$total	= $r[tjumlah];
	}
	$data['tgl']  = $tgl;
	$data['kodeplg']= $kodeplg;
	$data['namaplg']= $namaplg;
	$data['kodesl'] = $kodesl;
	$data['namasl'] = $namasl;
	$data['unit'] 	= $unit;
	$data['jttempo']= $jttempo;
	$data['tanggaljt']= $tanggaljt;
	$data['total']= $total;
	echo json_encode($data);
}else{
	$data['tgl']  = '';
	$data['kodeplg']= '';
	$data['namaplg']= '';
	$data['kodesl'] = '';
	$data['namasl'] = '';
	$data['unit'] 	= '';
	$data['jttempo']= '';
	$data['tanggaljt']= '';
	$data['total']  = '';
	echo json_encode($data);
}
?>