prepare("INSERT INTO surat_masuk (nomor_surat, tanggal_surat, pengirim, perihal, departemen_tujuan, status, file_path) VALUES (?, ?, ?, ?, ?, ?, ?)"); $stmt->execute([ $nomor !== '' ? $nomor : null, $tanggal, $pengirim, $perihal, $departemen, $status, $filePath ]); header('Location: /surat_masuk.php?success=1'); exit; } } $search = trim($_GET['q'] ?? ''); $where = ''; $params = []; if ($search !== '') { $where = "WHERE nomor_surat LIKE ? OR pengirim LIKE ? OR perihal LIKE ? OR departemen_tujuan LIKE ?"; $like = '%' . $search . '%'; $params = [$like, $like, $like, $like]; } $stmt = $pdo->prepare("SELECT id, nomor_surat, tanggal_surat, pengirim, perihal, departemen_tujuan, status FROM surat_masuk $where ORDER BY tanggal_surat DESC, id DESC LIMIT 50"); $stmt->execute($params); $rows = $stmt->fetchAll(); render_header('Surat Masuk', 'masuk'); ?>
| Tanggal | Nomor | Pengirim | Perihal | Departemen | Status |
|---|---|---|---|---|---|
| = h($row['tanggal_surat']) ?> | = h($row['nomor_surat'] ?? '-') ?> | = h($row['pengirim']) ?> | = h($row['perihal']) ?> | = h($row['departemen_tujuan']) ?> | = h($row['status']) ?> |