<?php
include '../config.php';

$id = $_GET['id'];

/* ambil kode tiket */
$q = mysqli_query($conn,"
SELECT kode_tiket
FROM pengajuan
WHERE id='$id'
");

$d = mysqli_fetch_assoc($q);
$kode_tiket = $d['kode_tiket'];

/* update status */
mysqli_query($conn,"
UPDATE pengajuan
SET status='Diterima'
WHERE id='$id'
");

/* simpan histori */
mysqli_query($conn,"
INSERT INTO log_status
(kode_tiket,status,tanggal)
VALUES
('$kode_tiket','Diterima',NOW())
");

header("location:surat_diterima.php");
exit;
?>