From f1c1f42a4ce24f383ab3ad8d44f8b7327d2ecf0d Mon Sep 17 00:00:00 2001 From: Power BI Dev Date: Wed, 6 May 2026 23:16:17 +0700 Subject: [PATCH] Add legacy mahasiswa list endpoint --- steven/API/getListMahasiswa.php | 73 +++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 steven/API/getListMahasiswa.php diff --git a/steven/API/getListMahasiswa.php b/steven/API/getListMahasiswa.php new file mode 100644 index 0000000..3710864 --- /dev/null +++ b/steven/API/getListMahasiswa.php @@ -0,0 +1,73 @@ + 0, + 'msg' => 'Unauthorized', + ]); + exit(); +} + +$mulaiTahun = isset($_GET['mulaiTahun']) ? (int) $_GET['mulaiTahun'] : 0; +$withHP = array_key_exists('withHP', $_GET); + +try { + $conn = new createCon(); + $dbhSpota = $conn->connectSpota(); + + $sql = 'SELECT idmhs, nim, nmLengkap, email, foto, thnmasuk, noHP, noHPOrtu FROM tbmhs'; + $params = []; + + if ($mulaiTahun > 0) { + $sql .= ' WHERE thnmasuk >= :mulaiTahun'; + $params[':mulaiTahun'] = $mulaiTahun; + } + + $sql .= ' ORDER BY thnmasuk DESC, nim ASC'; + + $stmt = $dbhSpota->prepare($sql); + $stmt->execute($params); + + $data = []; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $foto = (string) $row['foto']; + $item = [ + 'id' => $row['idmhs'], + 'nim' => $row['nim'], + 'nama' => $row['nmLengkap'], + 'email' => $row['email'], + 'urlFoto' => 'http://spota.untan.ac.id/img/'.$foto, + 'angkatan' => $row['thnmasuk'], + ]; + + if ($withHP) { + $item['hp'] = $row['noHP']; + $item['hpOrtu'] = $row['noHPOrtu']; + } + + $data[] = $item; + } + + echo json_encode([ + 'status' => 1, + 'data' => $data, + 'msg' => 'ok', + ]); +} catch (Exception $e) { + http_response_code(500); + echo json_encode([ + 'status' => 0, + 'msg' => 'Server error', + ]); +}