<?php
 
include 'dbconfig.php';
 
// Create connection

$nopos=$_POST['nopos'];
$kodecab=$_POST['kodecab'];

//echo $notrans;
 
$conn = mysqli_connect($servername, $username, $password, $dbname);
 
// Check connection
 
if (!$conn) {
 
    die("Connection failed: " . mysqli_connect_error());
 
}
 
//$result["errorcode"]="0";

 
//$sql = "SELECT count(item_code) as jumlah,sum($val) as total FROM Trans1sub where notrans_link='".$nopos."'";

$sql = "SELECT count(item_code) as hitpos,IFNULL(sum((harga_jual*qty)-(disc_val)),0)  as total  FROM Trans1ret where return_no='".$nopos."' and kode_cabang='".$kodecab."' ";

$res = mysqli_query($conn, $sql);
 
$items = array();
 
 
 
    while($row = mysqli_fetch_object($res)){
 
        array_push($items, $row);
    }
 
     $result["errorcode"] = $nopos;
 
    $result["data"] = $items;
 
 
echo json_encode($result);
 
mysqli_close($conn);
 
?>
