Add consultation module assets and libraries
This commit is contained in:
68
konsultasi/API/web/getTugasAkhirMahasiswa.php
Normal file
68
konsultasi/API/web/getTugasAkhirMahasiswa.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
include '../../conf/koneksiPDO.php';
|
||||
include '../../conf/function.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$conn = new createCon();
|
||||
$dbh = $conn->connect();
|
||||
|
||||
checkKey('POST', 'token');
|
||||
checkKey('POST', 'tipe');
|
||||
|
||||
$token = trim($_POST['token']);
|
||||
$tipe = trim($_POST['tipe']);
|
||||
|
||||
$mahasiswa = false;
|
||||
$dosen = false;
|
||||
|
||||
switch ($tipe) {
|
||||
case 'mahasiswa': $tabel = 'mahasiswa'; $mahasiswa = true; break;
|
||||
case 'dosen': $tabel = 'dosen'; $dosen = true; break;
|
||||
default: echo getUnknownTypeMessage(); exit();
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM $tabel WHERE token = :token";
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->bindParam(':token', $token);
|
||||
$stmt->execute();
|
||||
|
||||
$authorized = false;
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$authorized = true;
|
||||
}
|
||||
|
||||
if ($mahasiswa) {
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$nim = $row['nim'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($dosen) {
|
||||
checkKey('POST', 'nim');
|
||||
$nim = $_POST['nim'];
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM tugas_akhir WHERE nim = :nim ORDER BY idTugasAkhir DESC';
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->bindParam(':nim', $nim);
|
||||
$stmt->execute();
|
||||
|
||||
$data = array();
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$id = $row['idTugasAkhir'];
|
||||
$judul = $row['judul'];
|
||||
$semester = $row['semester'];
|
||||
|
||||
array_push($data, array(
|
||||
'id' => $id,
|
||||
'judul' => $judul,
|
||||
'semester' => $semester,
|
||||
));
|
||||
}
|
||||
|
||||
echo json_encode(utf8ize(array(
|
||||
'status' => 1,
|
||||
'tugasAkhir' => $data,
|
||||
)));
|
||||
Reference in New Issue
Block a user