109 lines
4.3 KiB
PHP
109 lines
4.3 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/auth/auth.php');
|
|
include('includes/functions.php');
|
|
include('access.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
|
|
// Connect to mysqli database
|
|
$page = 1;
|
|
$qtype = '';
|
|
$query = '';
|
|
|
|
if (isset($_POST['page'])) {
|
|
$page = mysqli_real_escape_string($conn, $_POST['page']);
|
|
}
|
|
if (isset($_POST['sortname'])) {
|
|
$sortname = mysqli_real_escape_string($conn, $_POST['sortname']);
|
|
}
|
|
if (isset($_POST['sortorder'])) {
|
|
$sortorder = mysqli_real_escape_string($conn, $_POST['sortorder']);
|
|
}
|
|
if (isset($_POST['qtype'])) {
|
|
$qtype = mysqli_real_escape_string($conn, $_POST['qtype']);
|
|
}
|
|
if (isset($_POST['query'])) {
|
|
$query = mysqli_real_escape_string($conn, $_POST['query']);
|
|
}
|
|
if (isset($_POST['rp'])) {
|
|
$rp = mysqli_real_escape_string($conn, $_POST['rp']);
|
|
}
|
|
|
|
$hasReadAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'R');
|
|
$hasWriteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'W');
|
|
$hasExecuteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'E');
|
|
|
|
$sortSql = "ORDER BY $sortname $sortorder";
|
|
$searchSql = ($qtype == 'procurement_date') ? " AND DATE_FORMAT(DATE(procurement_date), '%Y-%m-%d') = STR_TO_DATE('$query', '%d-%m-%Y')" :
|
|
(($qtype != '' && $query != '') ? " AND UPPER($qtype) LIKE UPPER('%$query%')" : '');
|
|
|
|
$ohc_id = $_SESSION['current_ohcttype'];
|
|
$sql = "SELECT COUNT(*) FROM training_batch_enrollment WHERE ohc_type_id = '$ohc_id' and (status ='VOP' || status ='SAD' ||status ='VOA' || status ='VOR') $searchSql";
|
|
$result = mysqli_query($conn, $sql);
|
|
$row = mysqli_fetch_array($result);
|
|
$total = $row[0];
|
|
$rp = $rp ?? 10;
|
|
|
|
$pageStart = ($page - 1) * $rp;
|
|
$limitSql = "LIMIT $pageStart, $rp";
|
|
|
|
$data = ['page' => $page, 'total' => $total, 'rows' => []];
|
|
|
|
$sql1 = "SELECT * FROM training_batch_enrollment WHERE ohc_type_id = '$ohc_id' and (status ='VOP' || status ='SAD' ||status ='VOA'|| status ='VOR') $searchSql $sortSql $limitSql";
|
|
$results = mysqli_query($conn, $sql1);
|
|
$count = ($page - 1) * $rp + 1;
|
|
|
|
while ($row1 = mysqli_fetch_assoc($results)) {
|
|
$id = $row1['id'];
|
|
|
|
$view_link = "<a href=\"#\" class=\"grey\" onclick=\"open_enrol('$id', 'V');\"><i class=\"ace-icon fa fa-eye bigger-130\"></i></a>" ;
|
|
$edit_link = "<a href=\"#\" class=\"red\" onclick=\"open_enrol('$id', 'E');\"><i class=\"ace-icon fa fa-edit bigger-130\"></i></a>" ;
|
|
$delete_link = "<a href=\"#\" class=\"grey\" onclick=\"delete_enrol('$id');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>" ;
|
|
|
|
$links = $view_link . " " . $edit_link . " " . $delete_link;
|
|
|
|
$item_desc = '';
|
|
$sql_procure_items = "SELECT * FROM training_batch_enrollment_beneficiary WHERE batch_pri_tbl_id='$id'";
|
|
error_log("dipak mali".$sql_procure_items);
|
|
$results_procure_items = mysqli_query($conn, $sql_procure_items);
|
|
while ($row_procure_items = mysqli_fetch_assoc($results_procure_items)) {
|
|
$patient_name = getFieldFromTable('patient_name', 'patient_master', 'id', $row_procure_items['beneficiary_id']);
|
|
error_log($row_procure_items['beneficiary_id']."bene ".$patient_name);
|
|
$item_desc .= '<p>' . $patient_name . '</p>';
|
|
}
|
|
|
|
$subject = getFieldFromTable('name','courses','id',$row1['subject']);
|
|
$batch_name = getFieldFromTable('batch_name','training_batch_master','batch_id',$row1['batch_id']);
|
|
|
|
if($row1['status']=='SAD'){
|
|
$status = '<span style="color: black;">Draft</span>';
|
|
}elseif($row1['status']=='VOP'){
|
|
$status = '<span style="color: orange;"> Approval Pending </span>';
|
|
}elseif($row1['status']=='VOA'){
|
|
$status = '<span style="color: green;"> Approved </span>';
|
|
}elseif($row1['status']=='VOR'){
|
|
$status = '<span style="color: red;"> Reject </span>';
|
|
}
|
|
|
|
else{
|
|
$status = '';
|
|
}
|
|
|
|
if($row1['batch_started']=='1'){
|
|
$batch_started = '<span style="color: green;">Yes</span>';
|
|
}elseif($row1['batch_started']=='0'){
|
|
$batch_started = '<span style="color: red;"> No </span>';
|
|
}
|
|
$batch_start_date = date_format(date_create($row1['batch_start_date']),"d-m-Y");
|
|
$batch_end_date = date_format(date_create($row1['batch_end_date']),"d-m-Y");
|
|
|
|
|
|
$data['rows'][] = [
|
|
'id' => $id,
|
|
'cell' => [$links,$count++,$batch_name,$batch_start_date,$batch_end_date,$subject,$status,$batch_started, $item_desc]
|
|
];
|
|
}
|
|
|
|
echo json_encode($data);
|
|
?>
|