Add consultation module assets and libraries
This commit is contained in:
110
konsultasi/API/web/verifProposalKP.php
Normal file
110
konsultasi/API/web/verifProposalKP.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
include '../../conf/koneksiPDO.php';
|
||||
include '../../conf/function.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
checkKey('POST', 'token');
|
||||
checkKey('POST', 'id');
|
||||
checkKey('POST', 'verif');
|
||||
checkKey('POST', 'catatan');
|
||||
|
||||
$token = $_POST['token'];
|
||||
$id = $_POST['id'];
|
||||
$verif = $_POST['verif'];
|
||||
$catatan = $_POST['catatan'];
|
||||
|
||||
$conn = new createCon();
|
||||
$dbh = $conn->connect();
|
||||
|
||||
$connBio = new createCon();
|
||||
$dbhBio = $connBio->connectDbBio();
|
||||
|
||||
$connDosen = new createCon();
|
||||
$dbhDosen = $connDosen->connectDbDosen();
|
||||
|
||||
$sql = 'SELECT * FROM dosen WHERE token = :token';
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->bindParam(':token', $token);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() === 0) {
|
||||
echo getUnauthorizedMessage();
|
||||
exit();
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$sql = 'UPDATE kerja_praktek SET proposalApproved = :setuju, timestampApproved = :timestamp, catatanRevisiProposal = :catatan WHERE idKerjaPraktek = :id';
|
||||
$stmt = $dbhBio->prepare($sql);
|
||||
$stmt->bindParam(':setuju', $verif);
|
||||
$stmt->bindParam(':timestamp', $time);
|
||||
$stmt->bindParam(':catatan', $catatan);
|
||||
$stmt->bindParam(':id', $id);
|
||||
$stmt->execute();
|
||||
|
||||
$error = $stmt->errorInfo();
|
||||
|
||||
$isError = true;
|
||||
|
||||
if ($error[0] == '00000') {
|
||||
$isError = false;
|
||||
}
|
||||
|
||||
if ($isError) {
|
||||
echo json_encode(
|
||||
[
|
||||
'status' => 0,
|
||||
'msg' => 'Terjadi kesalahan teknis!!!',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$sql = 'SELECT kerja_praktek.nim, nama_lengkap, topik, instansi FROM kerja_praktek LEFT JOIN bio_mahasiswa ON kerja_praktek.nim = bio_mahasiswa.nim WHERE idKerjaPraktek = :id';
|
||||
$stmt = $dbhBio->prepare($sql);
|
||||
$stmt->bindParam(':id', $id);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$nimMahasiswa = $row['nim'];
|
||||
$namaMahasiswa = $row['nama_lengkap'];
|
||||
$topik = $row['topik'];
|
||||
$namaInstansi = $row['instansi'];
|
||||
}
|
||||
|
||||
$emailTo = [];
|
||||
array_push($emailTo, 'tu@informatika.untan.ac.id');
|
||||
//array_push($emailTo, 'apriefekon92@gmail.com');
|
||||
array_push($emailTo, 'sholvariza@untan.ac.id');
|
||||
$judulEmail = 'Verifikasi Proposal oleh dosen pembimbing KP';
|
||||
|
||||
$isiEmail = "Proposal kerja praktek mahasiswa $namaMahasiswa / $nimMahasiswa telah di verifikasi oleh dosen KP masing-masing.";
|
||||
|
||||
$ch = curl_init();
|
||||
$emailParams = [];
|
||||
$emailParams['to'] = json_encode($emailTo);
|
||||
$emailParams['judul'] = $judulEmail;
|
||||
$emailParams['content'] = $isiEmail;
|
||||
$emailParams['from'] = 'system@informatika.untan.ac.id';
|
||||
|
||||
$postdata = $emailParams;
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://informatika.untan.ac.id/API/sendMail.php');
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_exec($ch);
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'status' => 1,
|
||||
'msg' => 'Berhasil melakukan verifikasi kerja praktek ini!!!',
|
||||
]
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user