<?php
 
include 'dbconfig.php';

$idno= $_POST['idno']; 
$qty= $_POST['qty'];
$discount= $_POST['discount'];

 

//$qty=1;
 
 
// Create connection
 
$conn = mysqli_connect($servername, $username, $password, $dbname);
 
// Check connection
 
if (!$conn) {
 
    die("Connection failed: " . mysqli_connect_error());
 
}

//echo $item_code;

/*GET ITEM_DESC */
$querydesc="select nama,harga,disc_val from tbl_barang where kode='".$item_code."'";
$descexec = mysqli_query($conn, $querydesc);
$row=mysqli_fetch_row($descexec);
$item_desc=$row[0];
$harga_jual=$row[1];
//echo 'para'.$item_desc.'--'.$harga_jual;
 
/* grab the posts from the db */
 
$query = "insert into Trans1sub (notrans_link,item_code, item_desc, harga_jual,qty,disc_val) values('".$notrans."','".$item_code."','".$item_desc."','".$harga_jual."','".$qty."','".$disc_val."')";
 
  
if ($idno != "0"){
 
$query = "update Trans1sub set qty='".$qty."',disc_val='".$discount."' where idno=".$idno;
 
}
 
$response = mysqli_query($conn, $query) or die('Error query:  '.$query);
 
$lid = mysqli_insert_id($conn);
 
$result["errormsg"]=$notrans;
 
$result["lid"]="$lid";
 
if ($response == 1){
 
    echo json_encode($result);
 
}
 
else{
 
    $result["errormsg"]="Fail";
 
    echo json_encode($result);
 
}
 
?>
