<?php
include "../koneksi.php";

$material = $_POST['material'];
$item_desc = $_POST['item_desc'];
$sloc = $_POST['sloc'];
$qty_unit = $_POST['qty_unit'];
$folder = $_POST['folder'];

if ($material == '') {
    $data['error']['material'] = 'Material tidak boleh kosong';
}
if ($item_desc == '') {
    $data['error']['item_desc'] = 'Item Description Tidak Boleh Kosong';
}
if ($sloc == '') {
    $data['error']['sloc'] = 'SLoc Tidak Boleh Kosong';
}
if ($qty_unit == '') {
    $data['error']['qty_unit'] = 'Quantity Unit tidak boleh kosong';
}
if ($folder == '') {
    $data['error']['folder'] = 'Folder tidak boleh kosong';
}

if (empty($data['error'])) {
    
		$query = "insert INTO product SET
										Material = '$material',
										ItemDescription = '$item_desc',
										SLoc = '$sloc',
										QtyUnit = '$qty_unit',
										Folder = '$folder'
										";

		mysqli_query($koneksi, $query)
		or die ("Gagal Perintah SQL".mysql_error());
		
    $data['hasil'] = 'sukses';
    
} else {
    
    $data['hasil'] = 'gagal';
}

echo json_encode($data);

?>

