Files
spota-dev/dosen/page/praoutline/list.judul.php
Power BI Dev efdb11db3f 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.
2026-05-02 10:08:52 +07:00

225 lines
7.5 KiB
PHP

<?php
session_start();
$idprodi = $_SESSION['login-dosen']['prodi'];
$iddosen = $_SESSION['login-dosen']['id'];
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = ['tp.judul', 'tp.nim', 'tm.nmLengkap'];
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = 'tp.id';
/* DB table to use */
$sTable = 'tbpraoutline tp';
$sTable .= ' LEFT JOIN tbmhs tm ON (tp.nim=tm.nim) ';
/* Database connection information */
include '../../../inc/helper.php';
include '../../../inc/konfigurasi.php';
include '../../../inc/db.pdo.class.php';
$db = new dB($dbsetting);
/*
* Paging
*/
$sLimit = '';
if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') {
$sLimit = 'LIMIT '.intval($_GET['iDisplayStart']).', '.
intval($_GET['iDisplayLength']);
}
/*
* Ordering
*/
$sOrder = 'ORDER BY tp.tgl_upload DESC, tp.judul ASC';
/*
* Filtering
*/
$sWhere = '';
if (isset($_GET['sSearch']) && $_GET['sSearch'] != '') {
$sWhere = 'WHERE (';
for ($i = 0; $i < count($aColumns); ++$i) {
if (isset($_GET['bSearchable_'.$i]) && $_GET['bSearchable_'.$i] == 'true') {
$sWhere .= ''.$aColumns[$i]." LIKE '%".$_GET['sSearch']."%' OR ";
}
}
$sWhere = substr_replace($sWhere, '', -3);
$sWhere .= ')';
}
/* Individual column filtering */
for ($i = 0; $i < count($aColumns); ++$i) {
if (isset($_GET['bSearchable_'.$i]) && $_GET['bSearchable_'.$i] == 'true' && $_GET['sSearch_'.$i] != '') {
if ($sWhere == '') {
$sWhere = 'WHERE ';
} else {
$sWhere .= ' AND ';
}
$sWhere .= ''.$aColumns[$i]." LIKE '%".$_GET['sSearch_'.$i]."%' ";
}
}
$whereKK = '';
if (isset($_GET['kk'])) {
$kkDosen = intval($_GET['kk']);
$whereKK = " AND kelompokKeahlian = '$kkDosen' ";
}
$where2 = '';
if ($sWhere != '') {
$where2 = " AND tp.idProdi='$idprodi' AND tp.status_usulan='0' $whereKK ";
} else {
$where2 = " WHERE tp.idProdi='$idprodi' AND tp.status_usulan='0' $whereKK ";
}
/*
* SQL queries
* Get data to display
*/
$sqlDosen = "SELECT * FROM tbdosen WHERE iddosen = '$iddosen'";
$db->runQuery($sqlDosen);
$currentIdKK = '-';
$currentKetua = false;
while ($rowDosen = $db->dbFetch()) {
$currentIdKK = $rowDosen['kelompokKeahlian'];
if($rowDosen['jenis'] == "K"){
$currentKetua = true;
}
}
$sqlKK = 'SELECT * FROM tb_kelompok_keahlian';
$db->runQuery($sqlKK);
$dataKK = [];
while ($kk = $db->dbFetch()) {
$idKK = $kk['idKK'];
$namaKK = $kk['namaKK'];
$warnaLabel = $kk['warnaLabel'];
$dataKK[$idKK] = ['nama' => $namaKK, 'label' => $warnaLabel];
}
$sQuery0 = "
SELECT tp.*,
((SELECT count(id) FROM tmp_notif WHERE iduser='".$iddosen."' AND typeuser='D' AND jenis='J' AND idProdi='".$idprodi."' AND idkonten=tp.id)) as new,
(SELECT nmLengkap FROM tbmhs WHERE nim=tp.nim LIMIT 1) as nm_mhs
FROM $sTable
$sWhere
$where2
$sOrder
";
//echo $sQuery0;
$db->runQuery($sQuery0);
$iFilteredTotal = $db->dbRows();
$result = $db->runQuery($sQuery0.$sLimit);
/* Total data set length */
$sQuery2 = "
SELECT COUNT(tp.id) as total FROM $sTable $sWhere $where2
";
//echo $sQuery2;
$db->runQuery($sQuery2);
$aResultTotal = $db->dbFetch();
$iTotal = $aResultTotal['total'];
/*$rResultTotal = mysql_query( $sQuery, $gaSql['link'] ) or fatal_error( 'MySQL Error: ' . mysql_errno() );
$aResultTotal = mysql_fetch_array($rResultTotal);
$iTotal = $aResultTotal[0];*/
/*
* Output
*/
$output = [
'sEcho' => intval($_GET['sEcho']),
'iTotalRecords' => $iTotal,
'iTotalDisplayRecords' => $iFilteredTotal,
'aaData' => [],
];
while ($aRow = $db->dbFetch($result)) {
$kelompokKeahlian = ' - <span class="label label-default" style="background-color:#A9A9A9">Tidak Ada Kelompok Keahlian</span>';
$idKelompokKeahlian = $aRow['kelompokKeahlian'];
if (isset($dataKK[$idKelompokKeahlian])) {
$kelompokKeahlian = ' - <span class="label label-'.$dataKK[$idKelompokKeahlian]['label'].'">'.$dataKK[$idKelompokKeahlian]['nama'].'</span>';
}
//print_r($aRow);
$row = [];
if ($aRow['new'] == 0) {
$badge = ' - <span class="label label-warning"> Baru</span>';
} else {
$badge = '';
}
$sQueryCount = "SELECT * FROM tbreview WHERE idpraoutline = '".$aRow['id']."'";
$resCount = $db->runQuery($sQueryCount);
$kkTerkait = $aRow['kkTerkait'];
$listKKTerkait = json_decode($kkTerkait, true);
$labelKKTerkait = '';
if ($listKKTerkait != null) {
foreach ($listKKTerkait as $key => $val) {
if (isset($dataKK[$val])) {
$labelKKTerkait = '<span class="label label-'.$dataKK[$val]['label'].'" style="margin-right:1rem">'.$dataKK[$val]['nama'].'</span>';
}
}
}
if ($labelKKTerkait == '') {
$labelKKTerkait = '-';
}
if($currentIdKK == $idKelompokKeahlian || $currentKetua){
$labelKKTerkait .= '<br><a href="?page=praoutline&menu=kk-terkait&prid='.$aRow['id'].'">Tambahkan KK Terkait</a>';
}
$jumlahReview = 0;
$jumlahSetuju = 0;
$jumlahTidakSetuju = 0;
while ($aResRow = $db->dbFetch($resCount)) {
if ($aResRow['putusan'] == '0') {
++$jumlahTidakSetuju;
}
if ($aResRow['putusan'] == '1') {
++$jumlahSetuju;
}
++$jumlahReview;
}
$statusPraoutline = '';
if ($aRow['status_usulan'] == 0) {
$statusPraoutline = '| <span class="label label-default" style="background-color:grey !important">Belum diclose</span>';
} elseif ($aRow['status_usulan'] == 1) {
$statusPraoutline = '| <span class="label label-success">Judul Diterima</span>';
} elseif ($aRow['status_usulan'] == 2) {
$statusPraoutline = '| <span class="label label-danger">Judul Ditolak</span>';
} elseif ($aRow['status_usulan'] == 3) {
$statusPraoutline = '| <span class="label label-danger">Judul Gugur</span>';
}
$row[0] = $aRow['nm_mhs'].'<br/>NIM: '.$aRow['nim'];
$row[1] = '<a href="?page=praoutline&menu=review&prid='.$aRow['id'].'">'.$aRow['judul'].'</a>'.$badge.$kelompokKeahlian.$statusPraoutline;
$row[1] .= '<p style="margin-top:1rem">Jumlah Review : <span class="badge badge-info">'.$jumlahReview.'</span> | Setuju : <span class="badge badge-success"> '.$jumlahSetuju.'</span> | Tidak Setuju : <span class="badge badge-danger">'.$jumlahTidakSetuju.'</span> '.$statusPraoutline.'</p>';
$row[2] = $aRow['thn_ajaran'].' - '.$aRow['semester'];
$row[3] = tanggalIndo($aRow['tgl_upload'].' '.$aRow['wkt_upload'], 'j F Y, H:i');
$row[4] = $labelKKTerkait;
$output['aaData'][] = $row;
// print_r($row);
}
echo json_encode($output);