21 lines
731 B
PHP
21 lines
731 B
PHP
<?php
|
|
// php/update_laporan_status.php
|
|
require_once 'koneksi.php';
|
|
header('Content-Type: text/plain');
|
|
|
|
$id = intval($_POST['id'] ?? 0);
|
|
$status = trim($_POST['status_laporan'] ?? '');
|
|
$ditanganiOleh = trim($_POST['ditangani_oleh'] ?? '');
|
|
$valid = ['menunggu','diproses','selesai','ditolak'];
|
|
|
|
if (!$id || !in_array($status, $valid)) {
|
|
http_response_code(400); echo 'Data tidak valid.'; exit;
|
|
}
|
|
|
|
$esc = fn($v) => mysqli_real_escape_string($conn, (string)$v);
|
|
$sql = "UPDATE laporan_kondisi SET status_laporan='{$esc($status)}', ditangani_oleh='{$esc($ditanganiOleh)}' WHERE id={$id}";
|
|
|
|
if (mysqli_query($conn, $sql)) { echo 'success'; }
|
|
else { http_response_code(500); echo mysqli_error($conn); }
|
|
?>
|