<?php
include "koneksi.php";
$response = array();
$query = mysqli_query($koneksi, "SELECT * FROM keluhan k, pengguna p WHERE k.status_admin=0 AND k.id_pengguna=p.id_pengguna
	ORDER BY k.id_keluhan DESC LIMIT 1");
if ($row = mysqli_fetch_array($query)) {
	$response["id_pengguna"] = $row['id_keluhan'];
	$response["pesan"] = "Ada keluhan baru dari " . $row['nama_pengguna'];

	$query2 = "UPDATE keluhan SET status_admin=1 WHERE id_keluhan='" . $row['id_keluhan'] . "'";
	$result2 = mysqli_query($koneksi, $query2);
} else {
	$response["id_pengguna"] = -1;
	$response["pesan"] = "";
}
echo json_encode($response);
