<?php
 
include 'dbconfig.php';
 
// Create connection
$cari=$_POST['cari'];
//$kodecab=$_POST['kodecab'];
 
$conn = mysqli_connect($servername, $username, $password, $dbname);
 
// Check connection
 
if (!$conn) {
 
    die("Connection failed: " . mysqli_connect_error());
 
}
 
//$result["errorcode"]="0";

//echo $cari."<br>";



 
$sql1 = "Select custid,custname from TbCustomer where nohp like '%$cari%'  order by idno desc";

$resph = mysqli_query($conn, $sql1);
$row=mysqli_fetch_row($resph);
$custid=$row[0];
//echo $custid;

 
$sql = "SELECT notrans_link,idno,item_code,item_desc,tgl_rec,qty,qtyreturn,harga_jual,disc_val FROM Trans1sub where typetrans='OT' and custid like '%$custid%' order by idno desc";
 
$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["data"] = "failed";
 
}
 
echo json_encode($result);
 
 
 
mysqli_close($conn);
 
?>
