<LINK href="images/index.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
    function refreshAndClose() {
        window.opener.location.reload(true);
        window.close();
    }
</script>
<body onbeforeunload="refreshAndClose();">
<?php
include("index.db.php");
mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$mytable = "$tahun_now";
$id1 = $_POST['id'];
$do1 = $_POST['do'];
$nama1 = $_POST['nama'];
$alamat1 = $_POST['alamat'];
$notelp1 = $_POST['notelp'];
$day1 = date("d");
$month1 = date("m");
$year1 = date("Y");
$tanggalexec = "$day1/$month1/$year1";
//----------STEP
if ($do1 == "kembali"){
$query = "UPDATE $mytable Set TGLEKSEKUSI  = '$tanggalexec' where ID = '$id1'";  
$result = mysql_query($query); 
$query = "UPDATE $mytable SET STATUS = '1' WHERE ID = '$id1'";
$result = mysql_query($query); 
$query = "UPDATE $mytable SET NAMAPEMILIK = '$nama1' WHERE ID = '$id1'";
$result = mysql_query($query); 
$query = "UPDATE $mytable SET ALAMATPEMILIK = '$alamat1' WHERE ID = '$id1'";
$result = mysql_query($query); 
$query = "UPDATE $mytable SET NOHPPEMILIK = '$notelp1' WHERE ID = '$id1'";
$result = mysql_query($query); 
echo "<b>POSTING PENGEMBALIAN BARANG BUKTI TELAH DISIMPAN SILAHKAN TUTUP JENDELA INI</b>";
}
//----------ENDSTEP
//----------STEP
if ($do1 == "lelang"){
$query = "UPDATE $mytable Set TGLEKSEKUSI  = '$tanggalexec' where ID = '$id1'";  
$result = mysql_query($query); 
$query = "UPDATE $mytable SET STATUS = '2' WHERE ID = '$id1'";
$result = mysql_query($query); 
echo "<b>POSTING LELANG/EKSEKUSI KE PEMBINAAN TELAH DISIMPAN SILAHKAN TUTUP JENDELA INI</b>";

}
//----------ENDSTEP
//----------STEP
if ($do1 == "musnah"){
$query = "UPDATE $mytable Set TGLEKSEKUSI  = '$tanggalexec' where ID = '$id1'";  
$result = mysql_query($query); 
$query = "UPDATE $mytable SET STATUS = '3' WHERE ID = '$id1'";
$result = mysql_query($query); 
echo "<b>POSTING PEMUSNAHAN TELAH DISIMPAN SILAHKAN TUTUP JENDELA INI</b>";
}
//----------ENDSTEP
//----------STEP
if ($do1 == "rampas"){
$query = "UPDATE $mytable Set TGLEKSEKUSI  = '$tanggalexec' where ID = '$id1'";  
$result = mysql_query($query); 
$query = "UPDATE $mytable SET STATUS = '4' WHERE ID = '$id1'";
$result = mysql_query($query); 
echo "<b>POSTING BARANG BUKTI DIRAMPAS UNTUK NEGARA TELAH DISIMPAN SILAHKAN TUTUP JENDELA INI</b>";
}
//----------ENDSTEP
//----------STEP
if ($do1 == "delete"){
include("index.db.php");
$conn = new mysqli("$server", "$username", "$password", "$database");
$mytable = "$tahun_now";
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sql = "DELETE FROM $mytable WHERE ID = '$id1'";
if ($conn->query($sql) === TRUE) {
    echo "BERHASIL MENGHAPUS SILAHKAN TUTUP JENDELA INI";
} else {
    echo "Error deleting record: " . $conn->error;
}

$conn->close();
}
//----------ENDSTEP
?>
