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

$kode	    = $_POST['kode'];
$tgljualaw  = $_POST['tgljualaw'];
$tgljualak  = $_POST['tgljualak'];

$sql= mysql_query("SELECT nama_st,satuan,hb_akhir,sum(jml_stok) as jstok,sum(jml_stokb) as jstokb FROM stock WHERE kode_st='$kode' GROUP BY kode_st");
$r	= mysql_fetch_assoc($sql);
$data['namast']	= $r['nama_st'];
$data['satuan']	= $r['satuan'];
$data['harga']	= $r['hb_akhir'];
$data['jmlstok']= $r['jstok']+$r['jstokb'];

$sql1= mysql_query("SELECT kode_st,sum(jml_unit) as jjual FROM faktur_pj WHERE tanggal BETWEEN '$tgljualaw' AND '$tgljualak' AND kode_st='$kode' AND batal='' AND posting='P'");
$r1	 = mysql_fetch_assoc($sql1);
$data['jmljual']= $r1['jjual'];
echo json_encode($data);
?>