<?php
 
include 'dbconfig.php';
 
// Create connection
$date1=$_POST['date1'];
$date2=$_POST['date2'];
$kodecab=$_POST['kodecab'];



 
$conn = mysqli_connect($servername, $username, $password, $dbname);
 
// Check connection
 
if (!$conn) {
 
    die("Connection failed: " . mysqli_connect_error());
 
}
 
//$result["errorcode"]="0";
 
$sql = "SELECT date_format(tgl_rec,'%d-%m-%Y') as tglrec ,notrans_link as notrans,item_code as itemcode,item_desc as itemdesc,qty,harga_jual,harga_beli,disc_val FROM Trans1sub where date(tgl_rec)>='".$date1."'"." and date(tgl_rec)<='".$date2."' and kode_cabang='".$kodecab."' order by notrans_link";
 
$res = mysqli_query($conn, $sql);
 
$items = array();
 
if (mysqli_num_rows($res) > 0) {
 
    while($row = mysqli_fetch_object($res)){
 
        array_push($items, $row);
 
//$result["errorcode"] = "1";
 
    $result["data"] = $items;
 
}}
else
{
 
     $result["errormsg"] = "Tidak ada data";
 
}
 
echo json_encode($result);
 
mysqli_close($conn);
 
?>
