111 lines
3.0 KiB
PHP
111 lines
3.0 KiB
PHP
<?php
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
include __DIR__.'/../../konsultasi/conf/koneksiPDO.php';
|
|
|
|
$validSecrets = [
|
|
getenv('SPOTA_LEGACY_API_SECRET') ?: '',
|
|
'in14d4lahP4ssWordSP0TA!12!',
|
|
];
|
|
|
|
$secret = isset($_GET['secret']) ? trim((string) $_GET['secret']) : '';
|
|
if ($secret === '' || !in_array($secret, $validSecrets, true)) {
|
|
http_response_code(401);
|
|
echo json_encode([
|
|
'status' => 0,
|
|
'msg' => 'Unauthorized',
|
|
]);
|
|
exit();
|
|
}
|
|
|
|
$mulaiTahun = isset($_GET['mulaiTahun']) ? (int) $_GET['mulaiTahun'] : 0;
|
|
$withoutKep = array_key_exists('withoutKep', $_GET);
|
|
|
|
try {
|
|
$conn = new createCon();
|
|
$dbhSpota = $conn->connectSpota();
|
|
|
|
$where = [];
|
|
$params = [];
|
|
|
|
if ($mulaiTahun > 0) {
|
|
$where[] = 'tbmhs.thnmasuk >= :mulaiTahun';
|
|
$params[':mulaiTahun'] = $mulaiTahun;
|
|
}
|
|
|
|
if (!$withoutKep) {
|
|
$where[] = "tbrekaphasil.kep_akhir = '1'";
|
|
}
|
|
|
|
$whereSql = '';
|
|
if (!empty($where)) {
|
|
$whereSql = ' WHERE '.implode(' AND ', $where);
|
|
}
|
|
|
|
$sql = 'SELECT '
|
|
.'tbrekaphasil.id, '
|
|
.'tbrekaphasil.nim, '
|
|
.'tbrekaphasil.judul_final, '
|
|
.'tbrekaphasil.pemb1, '
|
|
.'tbrekaphasil.pemb2, '
|
|
.'tbrekaphasil.peng1, '
|
|
.'tbrekaphasil.peng2, '
|
|
.'tbrekaphasil.semester, '
|
|
.'tbrekaphasil.tahun_ajaran, '
|
|
.'tbrekaphasil.tgl_kep, '
|
|
.'tbrekaphasil.wkt_kep, '
|
|
.'tbrekaphasil.idpraoutline, '
|
|
.'tbrekaphasil.kep_akhir, '
|
|
.'tbmhs.idmhs, '
|
|
.'tbmhs.thnmasuk, '
|
|
.'tbmhs.nmLengkap, '
|
|
.'tbjadwal.id AS sidang '
|
|
.'FROM tbrekaphasil '
|
|
.'LEFT JOIN tbmhs ON tbrekaphasil.nim = tbmhs.nim '
|
|
."LEFT JOIN tbjadwal ON tbmhs.idmhs = tbjadwal.idMhs AND tbjadwal.jenis = 'Sidang' AND tbjadwal.publish = 'Y'"
|
|
.$whereSql
|
|
.' ORDER BY tbrekaphasil.tgl_kep DESC, tbrekaphasil.wkt_kep DESC, tbrekaphasil.id DESC';
|
|
|
|
$stmt = $dbhSpota->prepare($sql);
|
|
$stmt->execute($params);
|
|
|
|
$data = [];
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
$sidang = empty($row['sidang']) ? 0 : 1;
|
|
if ((int) $row['thnmasuk'] < 2015) {
|
|
$sidang = 1;
|
|
}
|
|
|
|
$data[] = [
|
|
'id' => $row['id'],
|
|
'judul' => $row['judul_final'],
|
|
'nim' => $row['nim'],
|
|
'nama' => $row['nmLengkap'],
|
|
'pemb1' => $row['pemb1'],
|
|
'pemb2' => $row['pemb2'],
|
|
'peng1' => $row['peng1'],
|
|
'peng2' => $row['peng2'],
|
|
'semester' => $row['semester'],
|
|
'tahun' => $row['tahun_ajaran'],
|
|
'tanggalKeputusan' => $row['tgl_kep'],
|
|
'waktuKeputusan' => $row['wkt_kep'],
|
|
'idPraoutline' => $row['idpraoutline'],
|
|
'keputusan' => $row['kep_akhir'],
|
|
'sidang' => $sidang,
|
|
];
|
|
}
|
|
|
|
echo json_encode([
|
|
'status' => 1,
|
|
'data' => $data,
|
|
'msg' => 'ok',
|
|
]);
|
|
} catch (Exception $e) {
|
|
http_response_code(500);
|
|
echo json_encode([
|
|
'status' => 0,
|
|
'msg' => 'Server error',
|
|
]);
|
|
}
|