<?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')");
//-------------

$medrek = $_GET['id'];
	$tanggal_1 = substr($medrek,0,10);
	$interval=substr($medrek,11,1);
	$id = substr($medrek,13);
	
//-------------
    if(isset($_GET['item'])){
    $item = $_GET['item'];
    }
    if(isset($_GET['tanggal'])){
    $month = $_GET['tanggal'];
    }

	
if ($userini_id == '3'){
    $hapus = mysqli_query($conn, "DELETE FROM novia_abc_cash_shopping WHERE id = $id");
    if($hapus){
        if(isset($_GET['item'])){
	    echo "<script>document.location='cash-stat-item-monthly.php?item=$item&tanggal=$month'</script>";
	    }
        if ($interval==1){
            echo "<script>document.location='cash-view-daily.php?tanggal=$tanggal_1'</script>";
        }
        if ($interval==2){
            echo "<script>document.location='cash-view-monthly.php?tanggal=$tanggal_1'</script>";
        }
    } 
    else { 
        if(isset($_GET['item'])){
	    echo "<script>document.location='cash-stat-item-monthly.php?item=$item&tanggal=$month'</script>";
	    }
        if ($interval==1){
            echo "<script>alert('Proses hapus gagal, coba kembali');document.location='cash-view-daily.php?tanggal=$tanggal_1'</script>";
        }
        if ($interval==2){
            echo "<script>alert('Proses hapus gagal, coba kembali');document.location='cash-view-monthly.php?tanggal=$tanggal_1'</script>";
        }

    }
}
if ($userini_id != '3'){
	if ($interval==1){
		echo "<script>alert('Anda tidak berhak untuk menghapus');document.location='cash-view-daily.php?tanggal=$tanggal_1'</script>";
	}
	if ($interval==2){
		echo "<script>alert('Anda tidak berhak untuk menghapus');document.location='cash-view-monthly.php?tanggal=$tanggal_1'</script>";
	}
}