<?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(isset($_GET['item'])){
    $item = $_GET['item'];
    }
    if(isset($_GET['tanggal'])){
    $month = $_GET['tanggal'];
    }
    if(isset($_GET['file'])){
    $file = $_GET['file'];
    }

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

if ( $password != 000 ) { 
	echo "<script>alert('Password Anda Salah');document.location='cash-belanja-edit.php?id=$id'</script>"; 
}   else { $save=mysqli_query($conn, "UPDATE novia_abc_cash_shopping SET date_='$tgl_belanja', keterangan='$keterangan', harga='$harga', jumlah='$jumlah' where id='$id'");
	if($save){ 
	    if(empty($_GET['item'])){
	        header("Location: $file");
	    } else {
	        header("Location: " . $file . "&tanggal=" . $month);
	        exit;
	    }
	} 
    else {
        echo "<script>
            alert('Proses simpan gagal, coba kembali');
            window.location.href = '" . $file . "&tanggal=" . $month . "';
        </script>";
        exit;
    }
}
?>
