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

$kode	= $_POST['kode'];
$text	= "SELECT kode_rj,tanggal,kode_plg,nama_plg,nomor_fk,tanggal_fk,cara_by,sum(jumlah) as total,sum(hpp) as tothpp FROM retur_pj WHERE kode_rj= '$kode' GROUP BY kode_rj";
$sql 	= mysql_query($text);
$row	= mysql_num_rows($sql);
if ($row>0){
while ($r=mysql_fetch_array($sql)){
	$data['tgl']		= $r['tanggal'];
	$data['kodeplg']	= $r['kode_plg'];
	$data['namaplg']	= $r['nama_plg'];
	$data['nomorfk']	= $r['nomor_fk'];
	$data['tanggalfk']  = $r['tanggal_fk'];
	$data['caraby']	    = $r['cara_by'];
	$data['total']		= $r['total'];
	$data['tothpp']	    = $r['tothpp'];
	echo json_encode($data);
}
}else{
	$data['tgl']		= '';
	$data['kodeplg']	= '';
	$data['namaplg']	= '';
	$data['nomorfk']	= '';
	$data['tanggalfk']  = '';
	$data['caraby']	    = '';
	$data['total']		= '';
	$data['tothpp']	    = '';
	echo json_encode($data);
}
?>