<?php
    include('../loginsession.php');
    error_reporting(E_ALL);
    $filename = __FILE__;  //---Nama file saat ini
    if (strlen(__FILE__) > 48) {$filename = substr(__FILE__, 48);}
    $save = mysqli_query($conn, "INSERT INTO novia_abc_user_logs (userid,filename) VALUES ('$userini_id','$filename')");
//-------------

$id=  $_GET['id']; 
$tgl_belanja=  $_POST['tgl_belanja']; 
$keterangan=  $_POST['keterangan']; 
$harga=  $_POST['harga'];
$jumlah=  $_POST['jumlah']; 
$password = $_POST['password'];
$tgl = substr($tgl_belanja,0,10);

if ( $userini_id != "1"){
    $password = 000;
}

if (is_numeric($harga) && $harga != 0) {
	if ( $password != 000 ) { 
		echo "<script>alert('Password Anda Salah');document.location='cash-belanja.php?id=$id'</script>"; 
	}   else { $save = mysqli_query($conn, "INSERT INTO novia_abc_cash_shopping (date_, subcategory_id, keterangan, harga, userid, jumlah) VALUES ('$tgl_belanja', '$id', '$keterangan', '$harga', '$userini_id', '$jumlah')");
		if($save){ echo "<script>document.location='cash-view-daily.php?tanggal=$tgl'</script>";} 
		else { echo "<script>alert('Proses simpan gagal, coba kembali');document.location='cash-belanja.php?id=$id'</script>"; }
	}
}
if (!is_numeric($harga) || $harga == 0) {
	echo "<script>alert('Harga masih kosong');document.location='cash-belanja.php?id=$id'</script>"; 
}
?>
