<?php
 
include 'dbconfig.php';
 
$item_code=$_POST['item_code'];
$notrans= $_POST['notrans'];
$kodecab= $_POST['kodecab'];
$typetrans= $_POST['typetrans'];
$custid= $_POST['custid'];
$custname= $_POST['custname'];
$disc_val= $_POST['diskon'];
$harga_jual= $_POST['hargajual'];
$item_desc= $_POST['itemdesc'];
$noposlink= $_POST['noposlink'];
$qty= $_POST['qty'];
$harga_beli=0;

//$qty= 1;
//$disc_val= 0;

//$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 */

 

//echo 'para'.$item_desc.'--'.$harga_jual;
 
/* grab the posts from the db */
 
//if (strlen($item_code)>0 and strlen(descexec)>0)
//if (strlen($item_desc)>0)
//{
$query = "insert into Trans1sub (typetrans,kode_cabang,notrans_link,item_code, item_desc, harga_jual,qty,disc_val,harga_beli,custid,custname,noposlink) values('".$typetrans."','".$kodecab."','".$notrans."','".$item_code."','".$item_desc."','".$harga_jual."','".$qty."','".$disc_val."','".$harga_beli."','".$custid."','".$custname."','".$noposlink."')";
$response = mysqli_query($conn, $query) or die('Error query:  '.$query);
//}
 
 /*
if ($id != "0"){
 
$query = "update tbl_barang set nama='".$nama."',kode='".$kode."',harga='".$harga."',harga_beli='".$harga_beli."' where id=".$id;
 
}*/
 
//$response = mysqli_query($conn, $query) or die('Error query:  '.$query);

//$response2=mysqli_num_rows($query);
 
//$lid = mysqli_insert_id($conn);
 
//$result["errormsg"]=$notrans;
 
//$result["lid"]="$lid";
 
if ($response==1){
    
     $result["errormsg"]="okok";  
 
    echo json_encode($result);
 
}
 
else{
 
    $result["errormsg"]="failed";
 
    echo json_encode($result);
 
}
 
?>
