<?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')");
//-------------
$b = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM novia_abc_cash_shopping where id='$_GET[id]'"));
	
	$tgl_belanja = $b["date_"];
	$dt = new DateTime($tgl_belanja);
	$currdate = $dt->format('Y-m-d');
	
	$subid = $b["subcategory_id"];
	$sql_2 = mysqli_fetch_array(mysqli_query($conn, "SELECT id, subcategory_item FROM novia_abc_cash_category_sub where id='$subid'"));
	$subname = $sql_2['subcategory_item'];

//-------------
    if(isset($_GET['item'])){
    $item = $_GET['item'];
    }
    if(isset($_GET['tanggal'])){
    $month = $_GET['tanggal'];
    }
    if(isset($_GET['file'])){
    $file = $_GET['file'];
    }

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//ID" "http://www.w3.org/TR/html4/frameset.dtd">
<html lang="id">
<head>
   <title>BELANJA</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="../css/style.css">
	<link href="../images/balance.ico" rel="icon" type="image/icon"/>
    <style>

        .box{
			max-width: 100px;
			margin: 10px;
			font-family: "Time New Roman";
			color:#ccc;
			/*display: flex; justify-content: center; align-items: center;*/
		}
		a { text-decoration: none; color:inherit;}
		a:hover {color:#FF00FF;}   /* Mouse over link */
    </style>
</head>
<body>
    <div><a href="../index.php"><img src="../images/logo_brown.png" alt="Deskripsi Gambar" width="100%" height="auto"></a></div>

<form  method="post"  action="cash-belanja-edit-update.php?id=<?php echo $b['id']; ?>&item=<?php echo $item;?>&tanggal=<?php echo $month;?>&file=<?php echo $file;?>">
	<table width="100%" max-width="600px" cellpadding="5" align="center">
    <tbody>
    <tr class="satu">
		<td colspan="3" style='text-transform:capitalize' align="center">
			<h1> Edit Belanja</h1>
		</td>
	</tr>
    <tr class="head" align="left">
		<th width="150">ID</th>
        <th><?php echo $subname; ?></th>
    </tr>

	
	<tr class="satu">
        <td>Harga</td>
        <td><input type="text" name="harga" placeholder="harga" size="6" maxlength="6" autocomplete="off" autofocus value="<?php echo $b['harga'];?>"/></td>
    </tr>
	
	<tr class="satu">
        <td>Jumlah</td>
        <td><input type="text" name="jumlah" placeholder="jumlah" size="3" maxlength="6" autocomplete="off" autofocus value="<?php echo $b['jumlah']?>"/></td>
    </tr>	
	<tr class="dua">
        <td>Keterangan</td>
        <td><input type="text" name="keterangan" placeholder="keterangan" size="20" maxlength="30" autocomplete="off" autofocus value="<?php echo $b['keterangan']?>"/></td>
    </tr>

	<tr class="satu">
        <td>Tanggal Belanja</td>
        <td><input type="text" name="tgl_belanja" placeholder="tgl_belanja" size="20" maxlength="30" autocomplete="off" autofocus value="<?php echo $b['date_']?>"/></td>
    </tr>
	
    <tr class="dua">
		<td><input type="text" name="password" placeholder="No Password" size="15" maxlength="30" value=""/></td>
        <td colspan="1"><button type="submit" name="simpan" style="padding: 10px; width: 100%">SIMPAN PERUBAHAN</button></td>
    </tr>
</tbody>
</table>
</form>
	<table width="100%" max-width="600px"" cellpadding="5" align="center">
		<tr class="dua">
		
		    <?php
		    if(!isset($_GET['item'])){
		    ?>
			<td><a href="<?php echo $file ?>" title="KEMBALI"><button style="padding : 10px; width:100%">BATALKAN EDIT BELANJA</button></a></td>
			<?php
		    }
		    ?>

		    <?php
		    if(isset($_GET['item'])){
		    ?>
			<td><a href="cash-stat-item-monthly.php?item=<?php echo $item;?>&tanggal=<?php echo $month;?>" title="KEMBALI"><button style="padding : 10px; width:100%">BATALKAN EDIT BELANJA</button></a></td>
			<?php
		    }
		    ?>
			
		</tr>
	</table>
	<div class="box">
	    <a href="cash-view-hapus.php?id=<?php echo $currdate."-1-".$b["id"];?>&item=<?php echo $item;?>&tanggal=<?php echo $month;?>" title="Hapus item belanja">
            <img src="../images/greenmap.png" alt="Deskripsi gambar" width="100" height="100">
    		<div align="center">HAPUS ITEM</div>
		</a>
    </div>

</body>
</html>