Add consultation module assets and libraries
This commit is contained in:
96
konsultasi/API/web/verifKonsultasiKP.php
Normal file
96
konsultasi/API/web/verifKonsultasiKP.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
include '../../conf/koneksiPDO.php';
|
||||
include '../../conf/function.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$conn = new createCon();
|
||||
$dbh = $conn->connect();
|
||||
|
||||
$connBio = new createCon();
|
||||
$dbhBio = $connBio->connectDbBio();
|
||||
|
||||
checkKey('POST', 'token');
|
||||
checkKey('POST', 'id');
|
||||
checkKey('POST', 'catatan');
|
||||
checkKey('POST', 'tanggal');
|
||||
|
||||
$token = trim($_POST['token']);
|
||||
$id = trim($_POST['id']);
|
||||
$catatan = trim($_POST['catatan']);
|
||||
$tanggal = trim($_POST['tanggal']);
|
||||
|
||||
$authorized = false;
|
||||
|
||||
$sql = 'SELECT * FROM dosen WHERE token = :token';
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->bindParam(':token', $token);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$authorized = true;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
echo getUnauthorizedMessage();
|
||||
exit();
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM konsultasi_kp WHERE idKonsul = :idKonsul';
|
||||
$stmt = $dbhBio->prepare($sql);
|
||||
$stmt->bindParam(':idKonsul', $id);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() == 0) {
|
||||
echo getUnauthorizedMessage();
|
||||
exit();
|
||||
}
|
||||
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$timestampDosen = $row['timestampVerif'];
|
||||
}
|
||||
|
||||
if ($timestampDosen > 0) {
|
||||
echo json_encode(
|
||||
array(
|
||||
'status' => 1,
|
||||
'msg' => 'Berhasil melakukan verifikasi konsultasi ini!!!',
|
||||
)
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
$now = time();
|
||||
$sql = 'UPDATE konsultasi_kp SET tanggal = :tanggal, timestampVerif = :timestamp, catatanDosen = :catatan WHERE idKonsul = :idKonsul';
|
||||
$stmt = $dbhBio->prepare($sql);
|
||||
$stmt->bindParam(':tanggal', $tanggal);
|
||||
$stmt->bindParam(':timestamp', $now);
|
||||
$stmt->bindParam(':catatan', $catatan);
|
||||
$stmt->bindParam(':idKonsul', $id);
|
||||
$stmt->execute();
|
||||
|
||||
$error = $stmt->errorInfo();
|
||||
|
||||
$isError = true;
|
||||
|
||||
if ($error[0] == '00000') {
|
||||
$isError = false;
|
||||
}
|
||||
|
||||
if ($isError) {
|
||||
echo json_encode(
|
||||
array(
|
||||
'status' => 0,
|
||||
'msg' => 'Terjadi kesalahan teknis!!!',
|
||||
)
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'status' => 1,
|
||||
'msg' => 'Berhasil melakukan verifikasi konsultasi ini!!!',
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user