<?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')");
//-------------
    $today = date("Y-m-d");
//-------------
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//ID" "http://www.w3.org/TR/html4/frameset.dtd">
<html lang="id">
<head>
	<title>DAFTAR 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>

		input[type=text],input[type=password]
		{
		width:60%;
		padding:8px;
		margin-top:8px;
		margin-bottom:8px;
		border:1px solid #ccc;
		padding-left:5px;
		font-size:18px;
		}

		input[type=submit]
		{
		width:35%;
		background-color:#8baca4;
		color:#FFFFFF;
		border:2px solid #8baca4;
		padding:6px;
		font-size:18px;
		cursor:pointer;
		border-radius:5px;
		}
		img {
            width: 100%;
            max-width: 500px;
            height: auto;
        }
    </style>	
</head>

<body>

    <div><img src="../images/page/keuangan_entry.png" alt="Keuangan Harian"></div>

    <table width="100%" cellpadding="5">

		<tr class="dua">
    		<td><a href="cash-stat.php?tanggal=<?php echo $today;?>" title="Lihat Statistik Keuangan"><button style="padding : 10px; width:100%; background-color:#546E7A;">STATISTIK</button></a></td>
    		<td width="5%"><a href="../administrasi.php" title="NAVIGASI"><button style="padding : 10px; width:100%; background-color:#8baca4;">NAVIGASI</button></a></td>
		    <td><a href="../index.php" title="HOME"><button style="padding : 10px; width:100%; background-color:#A6B7C1;"> HOME </button></a></td>
		</tr>
	</table>
	<table width="100%" cellpadding="5">
		<tr class="dua">
		<td><a href="cash-view-monthly.php?tanggal=<?php echo date("Y-m-d");?>" title="Lihat Pengeluaran Bulan ini"><button style="padding : 10px; width:100%; background-color:#8baca4;">BELANJA BULANAN</button></a></td>
		<td><a href="cash-view-daily.php?tanggal=<?php echo date("Y-m-d");?>" title="Lihat Pengeluaran Hari ini"><button style="padding : 10px; width:100%; background-color:#8baca4;"> BELANJA HARIAN </button></a></td>
		</tr>
	</table>



<table width="100%" cellpadding="5">
	<tr class="head">
		<th width="20">No</th>
		<th width="150">Sub Kategori</th>
		<th align="left">Kategori</th>
	</tr>

<?php 

$sty = 1;
$sql = "SELECT * FROM novia_abc_cash_category_sub";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
	while($row = $result->fetch_assoc()) {
		
		$si = $row['maincategory'] + 1;
		$y = 2;
		$result1 = fmod($si,$y);
		if ( $result1 == 0 ) $sty = "dua";
		if ( $result1 == 1 ) $sty = "satu";
		
		$imr = $row["maincategory"];
		$sql_1 = mysqli_fetch_array(mysqli_query($conn, "SELECT id, name FROM novia_abc_cash_category_main where id='$imr'"));
		$namo = $sql_1['name'];
		
?>
	<tr class=<?php echo $sty; ?>>
		<td width="20" align="center"><?php echo $row["id"]; ?></td>
		<td width="150" align="left"><a href="cash-belanja.php?id=<?php echo $row["id"];?>" title="Dartar untuk belanja hari ini"><?php echo $row["subcategory_item"]; ?></a></td>			
		<td><?php echo $namo; ?></td>
	</tr>
<?php
	}
} else {
    echo "0 results";
}
?>
</body>
</html>
