<?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($userini_id != 3){
    echo "<script>alert('Anda tidak berhak untuk membuka halaman ini');document.location='../administrasi.php'</script>";
}
//-------------
echo '<link href="../images/balance.ico" rel="icon" type="image/icon" />';
echo '<title>ROUTINE ITEMS EDIT</title>';
//-------------
    echo '<table width="100%" cellpadding="5">';
	echo	'<tr>';
	echo	    '<td><a href="../administrasi.php" title="Navigasi"><button style="padding : 10px; width:100%; background-color:#A6B7C1;"> NAVIGASI </button></a></td>';
	echo	    '<td><a href="../index.php" title="Halaman Awal"><button style="padding : 10px; width:100%; background-color:#A6B7C1;"> HOME </button></a></td>';
	echo	    '<td><a href="routine.php" title="Halaman Awal"><button style="padding : 10px; width:100%; background-color:#A6B7C1;"> PDA </button></a></td>';
	echo	'</tr>';
	echo '</table>';
	echo '<br>';
//-------------

	echo '<form method="post" action="routine_update.php">';
    	echo '<input type="text" name="item" placeholder="Nama Item">';
    	echo '<input type="text" name="urutan" placeholder="Urutan" size="3">';
    	echo '<input type="submit" name="submit" value="submit"><br><br>';

    	echo '<input type="text" name="eitem" placeholder="Nama Item">';
    	echo '<input type="text" name="eurutan" placeholder="Urutan" size="3">';
    	echo '<input type="text" name="id" placeholder="No ID" size="3">';
    	echo '<input type="submit" name="update" value="Update"><br><br>';
    	
    	echo '<input type="text" name="idh" placeholder="No ID" size="3">';
    	echo '<input type="submit" name="delete" value="Hapus"><br><br>';
    	
    	echo '<input type="text" name="ai" placeholder="Auto" size="5">';
    	echo '<input type="submit" name="autoincrement" value="Auto Increment"><br><br>';
    	
    	echo '<input type="submit" name="deletetable" value="Kosongkan Tabel"><br>';
	echo '</form>';
    echo '<table>';
        echo '<tr>';
            echo '<th>Nomor</th>';
            echo '<th>Group</th>';
            echo '<th>Nama Rutinitas</th>';
            echo '<th>ID</th>';
        echo '</tr>';
	$no=0;
	$hasil = mysqli_query($conn, "SELECT*FROM novia_abc_routine_item ORDER BY urutan ASC");
	if($hasil->num_rows > 0 ){
		while ($baris = $hasil->fetch_assoc()){
		$no++;
		$ID = $baris['id'];
		$Nama = $baris['item'];
		$Urutan = $baris['urutan'];
		echo '<tr>';
		echo '<td>'.$no.'.</td>';
		echo '<td>'.$Urutan.'</td>';
		echo '<td>'.$Nama.'</td>';
		echo '<td>'.$ID.'</td>';
		echo '</tr>';
		}
	}
	echo '</table>';
	$conn->close();