<?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')");
//-------------
    if(isset($_GET['id'])){
        $id = $_GET['id'];
    }
    $query = mysqli_query($conn, "SELECT * FROM novia_abc_todo where id='$id'");
    $userData = mysqli_fetch_array($query);
    $todo = $userData['todo'];
    $harga = $userData['harga'];
//-------------

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//ID" "http://www.w3.org/TR/html4/frameset.dtd">
<html lang="id">
<head>
	<title>CATATAN PERSONAL</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>
		body {
            background-color: #bbb;
            color : #fff;
            background-image : url('../images/bg_brown_01.jpg');
            }
		a { text-decoration: none; color:inherit;}
		a:hover {color:#FF00FF;}   /* Mouse over link */
		table, th, td {
    	border-collapse:collapse;
    	border:1px solid #999;
    	font-family:Tahoma, Geneva, sans-serif;
    	font-size:12px;
        }
        .box{
			max-width: 100px;
			margin: 10px;
			font-family: "Time New Roman";
			color:#ccc;
			/*display: flex; justify-content: center; align-items: center;*/
		}
        .head {
        	background: rgb(206,220,231); /* Old browsers */
        	background: -moz-linear-gradient(top,  rgba(206,220,231,1) 0%, rgba(89,106,114,1) 100%); /* FF3.6+ */
        	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(206,220,231,1)), color-stop(100%,rgba(89,106,114,1))); /* Chrome,Safari4+ */
        	background: -webkit-linear-gradient(top,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* Chrome10+,Safari5.1+ */
        	background: -o-linear-gradient(top,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* Opera 11.10+ */
        	background: -ms-linear-gradient(top,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* IE10+ */
        	background: linear-gradient(to bottom,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* W3C */
        	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cedce7', endColorstr='#596a72',GradientType=0 ); /* IE6-9 */
        	text-shadow:1px 1px 0px #CCC;
        	font-size:18px;
        	padding:10px;
        	color:#333;
            }        
		img {
            width: 100%;
            max-width: 500px;
            height: auto;
        }
        h1 {
            color:#B61A1A;
            text-align: center;
            font-family: "Times New Roman";
            font-size:55px;
            text-shadow:1px 1px 0px #CCC;
        }
        h2 {
            color:#B61A1A;
            text-align: center;
            font-family: "Times New Roman";
            font-size:33px;
            text-shadow:1px 1px 0px #CCC;
        }
        h3 {
            color:#B61A1A;
            text-align: center;
            font-family: "Times New Roman";
            font-size:18px;
            text-shadow:1px 1px 0px #CCC;
        }
    </style>
</head>

<body>
    <table width="100%" cellpadding="5">
		<tr class="dua">
		    <td><a href="../administrasi.php" title="Navigasi"><button style="padding : 10px; width:100%; background-color:#A6B7C1;"> PUSAT NAVIGASI </button></a></td>
		    <td><a href="../index.php" title="Halaman Awal"><button style="padding : 10px; width:100%; background-color:#A6B7C1;"> HOME </button></a></td>
		</tr>
	</table>
	
    <br>
        <h1>TO DO LIST</h1>
        <h2>HARIAN</h2>
        <h3>(EDIT-HAPUS)</h3>
    <br>
    
    <form  method="post"  action="">
    	<table width="100%" max-width="600px" cellpadding="5" align="center">
        <tr class="dua">
            <td><input type="text" name="todo" placeholder="todo" size="24" maxlength="100" autocomplete="off" autofocus value="<?php echo $todo ?>"/></td>
            <td><input type="text" name="harga" placeholder="harga" size="3" maxlength="100" autocomplete="off" autofocus value="<?php echo $harga ?>"/></td>
            <td><button type="submit" name="submit" style="padding: 10px; width: 100%; background-color:#29434E; color:#ccc;">RUBAH</button</td>
        </tr>
        </table>
    </form>
    

<?php    
    if (isset($_POST['submit'])) {
        $todo1=$_POST['todo'];
        $harga1 = $_POST['harga'];
        $save=mysqli_query($conn, "UPDATE novia_abc_todo SET todo='$todo1', harga='$harga1' where id='$id'");
        if($save){ echo "<script>document.location='todo.php'</script>";}
    }
?>

	<div class="box">
	    <a href="todo_hapus.php?id=<?php echo $id;?>" title="Hapus item catatan">
            <img src="../images/greenmap.png" alt="Deskripsi gambar" width="100" height="100">
    		<div align="center">HAPUS ITEM</div>
		</a>
    </div>
</body>