160 lines
6.7 KiB
PHP
160 lines
6.7 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 = '';
|
|
$sortname = 'id';
|
|
|
|
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%')" : '');
|
|
|
|
if ($qtype != '' && $query != '') {
|
|
if ($qtype == 'batch_id') {
|
|
$searchSql = " where batch_id IN (SELECT batch_id FROM training_batch_master WHERE batch_name LIKE '%" . trim($query) . "%')";
|
|
} elseif ($qtype == 'subject') {
|
|
$searchSql = "where subject IN (SELECT id FROM courses WHERE name LIKE '%" . trim($query) . "%')";
|
|
} else {
|
|
$searchSql = " where UPPER($qtype) LIKE UPPER('%" . trim($query) . "%')";
|
|
}
|
|
}
|
|
$ohc_id = $_SESSION['current_ohcttype'];
|
|
|
|
if ($_SESSION['RoleId'] == 20) {
|
|
|
|
$sql = "SELECT COUNT(*) FROM training_batch_enrollment WHERE (status ='VOP' ||status ='VOA' || status ='VOR' || status = 'VOH') $searchSql";
|
|
} else if ($_SESSION['RoleId'] == 33) {
|
|
$sql = "SELECT COUNT(*) FROM training_batch_enrollment WHERE (status ='VOA' || status ='VOR' || status = 'VOH') $searchSql";
|
|
} else {
|
|
|
|
$sql = "SELECT COUNT(*) FROM training_batch_enrollment WHERE (status ='VOP' || status ='SAD' ||status ='VOA' || status ='VOR' || status = 'VOH') $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' => []];
|
|
if ($_SESSION['RoleId'] == 20) {
|
|
$sql1 = "SELECT * FROM training_batch_enrollment WHERE (status ='VOP' ||status ='VOA' || status ='VOR' || status = 'VOH') $searchSql $sortSql $limitSql";
|
|
} else if ($_SESSION['RoleId'] == 33) {
|
|
|
|
$sql1 = "SELECT * FROM training_batch_enrollment WHERE (status ='VOA' || status ='VOR' || status = 'VOH') $searchSql $sortSql $limitSql";
|
|
} else {
|
|
|
|
$sql1 = "SELECT * FROM training_batch_enrollment WHERE (status ='VOP' || status ='SAD' ||status ='VOA' || status ='VOR' || status = 'VOH') $searchSql $sortSql $limitSql";
|
|
}
|
|
|
|
error_log("vimal_shukla : " . $sql1);
|
|
$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);
|
|
$record_count = 0;
|
|
while ($row_procure_items = mysqli_fetch_assoc($results_procure_items)) {
|
|
$record_count++;
|
|
$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']);
|
|
$ohc_name = getFieldFromTable('ohc_type_name', 'ohc_type', 'ohc_type_id', $row1['ohc_type_id']);
|
|
|
|
if ($row1['status'] == 'SAD') {
|
|
$status = '<span style="color: black;">Draft</span>';
|
|
} elseif ($row1['status'] == 'VOP') {
|
|
$status = '<span style="color: orange;"> Pending Approval For VTI Approver </span>';
|
|
} elseif ($row1['status'] == 'VOH') {
|
|
$status = '<span style="color: orange;"> Pending Approval For VTI HOD </span>';
|
|
} elseif ($row1['status'] == 'VOA') {
|
|
$status = '<span style="color: green;"> Approved </span>';
|
|
} elseif ($row1['status'] == 'VOR') {
|
|
$status = '<span style="color: red;"> Rejected </span>';
|
|
} else {
|
|
$status = '';
|
|
}
|
|
if($_SESSION['RoleId'] == 20 && $row1['status'] == 'VOP'){
|
|
$status = '<span style="color: orange;"> Pending For Approval </span>';
|
|
|
|
}else if($_SESSION['RoleId'] == 33 && $row1['status'] == 'VOH'){
|
|
$status = '<span style="color: orange;"> Pending For Approval </span>';
|
|
|
|
}
|
|
|
|
if ($row1['batch_started'] == '1') {
|
|
$batch_started = '<span style="color: green;">Yes</span>';
|
|
} else if ($row1['batch_started'] == '0') {
|
|
$batch_started = '<span style="color: red;"> No </span>';
|
|
} else if ($row1['batch_started'] == 'Completed') {
|
|
$batch_started = '<span style="color: green;"> Completed </span>';
|
|
}
|
|
if ($row1['batch_start_date'] && $row1['batch_start_date'] !== '1970-01-01') {
|
|
$batch_start_date = date_format(date_create($row1['batch_start_date']), "d-m-Y");
|
|
} else {
|
|
$batch_start_date = 'NA';
|
|
}
|
|
if ($row1['batch_end_date'] && $row1['batch_end_date'] !== '1970-01-01') {
|
|
$batch_end_date = date_format(date_create($row1['batch_end_date']), "d-m-Y");
|
|
} else {
|
|
$batch_end_date = 'NA';
|
|
}
|
|
|
|
// $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, $ohc_name, $batch_start_date, $batch_end_date, $subject, $status, $batch_started, $record_count]
|
|
];
|
|
}
|
|
|
|
echo json_encode($data);
|