Files
spota-dev/dosen/page/praoutline/list.statistikdraft.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

152 lines
4.5 KiB
PHP

<?php
session_start();
$idprodi = $_SESSION['login-dosen']['prodi'];
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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.semester'];
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = 'tp.id';
/* DB table to use */
$sTable = 'tbpraoutline tp';
/* 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.semester";
$sOrder = 'ORDER BY tp.semester';
/*
* 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]."%' ";
}
}
$where2 = '';
if ($sWhere != '') {
$where2 = " AND tp.idProdi='$idprodi' ";
} else {
$where2 = " WHERE tp.idProdi='$idprodi' ";
}
/*
* SQL queries
* Get data to display
*/
$sQuery0 = "
SELECT
tp.semester,
COUNT(if(tp.status_usulan='1',1,null)) as terima,
COUNT(if(tp.status_usulan='2',1,null)) as tolak,
COUNT(if(tp.status_usulan='3',1,null)) as gugur,
COUNT(if(tp.status_usulan='0',1,null)) as proses,
COUNT(tp.semester) as totaldraft
FROM $sTable
$sWhere
$where2
GROUP BY tp.semester
$sOrder
";
$sQuery0 = "SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(semester, '-', 2), '-', -1) as tahunSplit, SUBSTRING_INDEX(SUBSTRING_INDEX(semester, '-', 1), '-', -1) as semesterSplit, semester, terima, tolak, gugur,proses, totaldraft FROM ($sQuery0) t ORDER BY tahunSplit DESC, semesterSplit DESC ";
//echo $sQuery0;
$db->runQuery($sQuery0);
$iFilteredTotal = $db->dbRows();
$result = $db->runQuery($sQuery0.$sLimit);
/* Total data set length */
$sQuery2 = "
SELECT COUNT(DISTINCT(tp.semester)) 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)) {
//print_r($aRow);
$row = [];
$tahunSplit = intval($aRow['tahunSplit']);
$tahunSplitNext = $tahunSplit + 1;
$semsterSplit = $aRow['semesterSplit'];
switch ($semsterSplit) {
case 'GAS': $semesterText = 'GAZAL'; break;
case 'GEN': $semesterText = 'GENAP'; break;
default: $semesterText = '-';
}
$periodeFinalText = "$tahunSplit/$tahunSplitNext - $semesterText";
$row[0] = $periodeFinalText;
$row[1] = $aRow['proses'];
$row[2] = $aRow['terima'];
$row[3] = $aRow['tolak'];
$row[4] = $aRow['gugur'];
$row[5] = $aRow['totaldraft'];
$output['aaData'][] = $row;
// print_r($row);
}
echo json_encode($output);