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

$kode		= $_POST['kode'];
$tglawal	= $_POST['tglawal'];
$tglakhir	= $_POST['tglakhir'];
$tjumlah 	= $_POST['tjumlah'];

mysql_query("UPDATE faktur_pj SET import='' WHERE kode_pj= '$kode' ");

$sql1 	= mysql_query("SELECT sum(jumlah) as timport,sum(potongan) as tpotongan  FROM faktur_pj WHERE tanggal BETWEEN '$tglawal' AND '$tglakhir' AND import='v' ");
$row1	= mysql_num_rows($sql1);

if($row1>0){
	$r1=mysql_fetch_assoc($sql1);
	$timport=$r1['timport']-$r1['tpotongan'];
	$prosen=($timport/$tjumlah)*100;
	$data['timport']	= $timport;
	$data['prosen'] 	= $prosen;
}else{
	$data['timport'] = '';
	$data['prosen'] = '';
}
echo json_encode($data);
?>