Add SPOTA core PHP application
Add the main admin, dosen, mahasiswa, API, and service code needed to run the core legacy application with configurable upload storage.
This commit is contained in:
56
admin/API/list-data-kk.php
Normal file
56
admin/API/list-data-kk.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
include '../../steven/conf/koneksiPDO.php';
|
||||
include '../../steven/conf/function.php';
|
||||
|
||||
$conn = new createCon();
|
||||
$dbh = $conn->connect();
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if (!isset($_SESSION['login-admin'])) {
|
||||
echo json_encode(['status' => 403, 'msg' => 'Forbidden']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM tbdosen";
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
$listDosen = [];
|
||||
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
$listDosen[$row['iddosen']] = $row['nmLengkap'];
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM tb_kelompok_keahlian LEFT JOIN tbdosen ON tb_kelompok_keahlian.ketuaKK = tbdosen.iddosen';
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
$listData = [];
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$idKetua = $row['ketuaKK'];
|
||||
$idSekretaris = $row['sekretarisKK'];
|
||||
|
||||
$namaKetua = "-";
|
||||
$namaSekretaris = "-";
|
||||
|
||||
if(isset($listDosen[$idKetua])){
|
||||
$namaKetua = $listDosen[$idKetua];
|
||||
}
|
||||
|
||||
if(isset($listDosen[$idSekretaris])){
|
||||
$namaSekretaris = $listDosen[$idSekretaris];
|
||||
}
|
||||
array_push($listData, [
|
||||
'id' => $row['idKK'],
|
||||
'nama' => $row['namaKK'],
|
||||
'ketua' => $idKetua,
|
||||
'namaKetua' => $namaKetua,
|
||||
'sekretaris' => $idSekretaris,
|
||||
'namaSekretaris' => $namaSekretaris,
|
||||
]);
|
||||
}
|
||||
|
||||
echo json_encode(utf8ize($listData));
|
||||
Reference in New Issue
Block a user