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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//ID" "http://www.w3.org/TR/html4/frameset.dtd">
<html lang="id">
<head>
	<title>TO DO LIST</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;
        }
        .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:36px;
            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;
        }
    </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>
    <br>

    <form method="post" action="">
        
        <table width="100%" cellpadding="5">
            <tr>
                <td><textarea name="todo" placeholder="What to do?" rows="1" cols="25"/></textarea></td>
                <td><textarea name="harga" placeholder="Harga" rows="1" cols="5"/></textarea></td>
                <td><input type="submit" name="submit" value="Submit"></td>
            </tr>
        </table>
        
    </form>
    <br>
    <table width="100%" cellpadding="5">
        <tr class="head">
            <td width="10">No</td>
            <td width="75"  align="center">Tanggal</td>
            <td>ToDo</td>
            <td width="10">Nilai</td>
            <td width="10">By</td>
        </tr>
        
<?php
    $mark = "";
    
    if (isset($_POST['todo'])) {
        $todo = $_POST['todo'];
    } else {
        $todo = ''; 
    }
    if (isset($_POST['harga'])) {
        $harga = $_POST['harga'];
    } else {
        $harga = 0; 
    }
    
    //$todo=$_POST['todo'];
    //$harga=$_POST['harga'];
    
    if (isset($_POST['submit'])) {
        $save = mysqli_query($conn, "INSERT INTO novia_abc_todo (userid, todo, harga) VALUES ('$userini_id', '$todo', '$harga')");
        if($save){ echo "<script>document.location='todo.php'</script>";}         
    }
    
    $no = "0";
    $sql = "SELECT * FROM novia_abc_todo ORDER BY tanggal DESC";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
            $id = $row['id'];
            $Mark = $row['mark'];
            $User = $row['userid'];
            $user = $USERNAME[$User];
            //if ( $userini_id == "3" || ( $userini_id != "3" && $Mark == "" )){
                $no ++;
                
                $Tanggal = new Datetime($row['tanggal']);
                $tanggal = $Tanggal->format('Y-m-d');
                ?>

                    <tr>
                        <td><?php echo $no; ?></td>
                        <td align="center"><a href="todo_edit.php?id=<?php echo $id; ?>"><?php echo $tanggal; ?></a></td>
                        <td><a href="todo_edit.php?id=<?php echo $id; ?>"><?php echo $row['todo']; ?></a></td>
                        <td align="right"><a href="todo_edit.php?id=<?php echo $id; ?>"><?php echo $row['harga']; ?></a></td>
                        <td><?php echo $user; ?></td>
                    </tr>
                
                
                <?php
            //}
            
        }
    }
?>
    </table>
</body>