137 lines
4.5 KiB
PHP
137 lines
4.5 KiB
PHP
|
|
<?php
|
||
|
|
include('includes/config/config.php');
|
||
|
|
include('includes/auth/auth.php');
|
||
|
|
include('includes/functions.php');
|
||
|
|
include('log_entry.php');
|
||
|
|
include('access.php');
|
||
|
|
error_reporting(E_ERROR | E_PARSE);
|
||
|
|
|
||
|
|
// Start the transaction
|
||
|
|
begin();
|
||
|
|
|
||
|
|
// Connect to mysqli database
|
||
|
|
$page = 1; // The current page
|
||
|
|
$sortname = 'ppm_id'; // Sort column
|
||
|
|
$sortorder = 'asc'; // Sort order
|
||
|
|
$qtype = ''; // Search column
|
||
|
|
$query = ''; // Search string
|
||
|
|
$searchSql = "";
|
||
|
|
|
||
|
|
// Get posted data
|
||
|
|
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']);
|
||
|
|
} else {
|
||
|
|
$rp = 10; // Default rows per page
|
||
|
|
}
|
||
|
|
|
||
|
|
// Access control checks
|
||
|
|
$hasReadAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'R');
|
||
|
|
$hasWriteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'W');
|
||
|
|
$hasExecuteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'E');
|
||
|
|
$ohc_type_id = "ohc_type_id = ".$_SESSION['current_ohcttype'];
|
||
|
|
|
||
|
|
// Searching logic
|
||
|
|
if ($qtype != '' && $query != '') {
|
||
|
|
if ($qtype == 'batch_name') {
|
||
|
|
$searchSql = "WHERE batch_name IN (SELECT batch_id FROM training_batch_master WHERE batch_name LIKE '%" . trim($query) . "%') AND $ohc_type_id";
|
||
|
|
}if ($qtype == 'teacher_name') {
|
||
|
|
$searchSql = "WHERE teacher_name IN (SELECT staff_id FROM staff_master WHERE staff_name LIKE '%" . trim($query) . "%') AND $ohc_type_id";
|
||
|
|
} else {
|
||
|
|
$searchSql = "WHERE UPPER($qtype) LIKE UPPER('%" . trim($query) . "%') AND $ohc_type_id";
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
|
||
|
|
$searchSql = "WHERE $ohc_type_id";
|
||
|
|
}
|
||
|
|
|
||
|
|
// Setup sort and search SQL using posted data
|
||
|
|
$sortSql = "ORDER BY $sortname $sortorder";
|
||
|
|
|
||
|
|
// Get total count of records
|
||
|
|
$sql = "SELECT COUNT(*) FROM primary_parents_meeting $searchSql";
|
||
|
|
|
||
|
|
error_log("SQL: " . $sql);
|
||
|
|
$result = mysqli_query($conn, $sql);
|
||
|
|
rollback();
|
||
|
|
$row = mysqli_fetch_array($result);
|
||
|
|
$total = $row[0];
|
||
|
|
|
||
|
|
// Setup paging SQL
|
||
|
|
$pageStart = ($page - 1) * $rp;
|
||
|
|
$limitSql = "LIMIT $pageStart, $rp";
|
||
|
|
|
||
|
|
// Return JSON data
|
||
|
|
$data = array();
|
||
|
|
$data['page'] = $page;
|
||
|
|
$data['total'] = $total;
|
||
|
|
$data['rows'] = array();
|
||
|
|
|
||
|
|
// Fetch data with applied search and sort
|
||
|
|
// $sql_link = "SELECT * FROM placement_examination_result $searchSql $sortSql $limitSql";
|
||
|
|
|
||
|
|
$sql_link = "SELECT * FROM primary_parents_meeting $searchSql $sortSql $limitSql";
|
||
|
|
|
||
|
|
|
||
|
|
$sql_export = $sql_link;
|
||
|
|
error_log("Select: " . $sql_link);
|
||
|
|
$results_calibration = mysqli_query($conn, $sql_link);
|
||
|
|
rollback();
|
||
|
|
$count = $pageStart + 1;
|
||
|
|
|
||
|
|
while ($row1 = mysqli_fetch_assoc($results_calibration)) {
|
||
|
|
$id = $row1['ppm_id'];
|
||
|
|
$batch_name = getFieldFromTable('batch_name', 'training_batch_master', 'batch_id', $row1['batch_name']);
|
||
|
|
// $beneficiary_name = getFieldFromTable('beneficiary_name', 'beneficiaryinfo', 'id', $row1['beneficiary_name']);
|
||
|
|
// $section_name = getFieldFromTable('examination_date', 'placement_examination', 'exm_id', $row1['exm_id']);
|
||
|
|
|
||
|
|
$links = "";
|
||
|
|
if ($hasReadAccess) {
|
||
|
|
|
||
|
|
$links .= "<a target=\"_blank\" href=\"parents_metting_pdf.php?id=" . $id . "\"class=\"green\" title=\"Result Pdf\" ><i class=\"ace-icon fa fa-file-pdf-o\" style=\"font-size: 15px;\"></i></a>";
|
||
|
|
}
|
||
|
|
if ($hasWriteAccess) {
|
||
|
|
$links .= "  <a href=\"#\" class=\"blue\" onclick=\"open_form('" . $id . "','E');\"><i class=\"ace-icon fa fa-edit bigger-130\"></i></a>";
|
||
|
|
}
|
||
|
|
if ($hasExecuteAccess) {
|
||
|
|
$links .= " <a href=\"#\" class=\"red\" onclick=\"delete_form('" . $id . "');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
||
|
|
}
|
||
|
|
$meeting_date = date_format(date_create($row1['meeting_date']), "d-m-Y");
|
||
|
|
$teacher_name = getCommaSeperatedValuesForInClause("SELECT staff_name FROM staff_master", "staff_id", $row1['teacher_name']);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$data['rows'][] = array(
|
||
|
|
'id' => $row1['id'],
|
||
|
|
'cell' => array(
|
||
|
|
$links,
|
||
|
|
$count++,
|
||
|
|
$batch_name,
|
||
|
|
$teacher_name,
|
||
|
|
$meeting_date,
|
||
|
|
|
||
|
|
)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
commit();
|
||
|
|
// $data['rows'][] = array(
|
||
|
|
// 'id' => $row['filterkey'],
|
||
|
|
// 'cell' => array('', "<input type=hidden name='filterkey' id='filterkey' value=\"" . base64_encode($sql_export) . "\">", "<input type=hidden name=paramlist id=paramlist value=\"" . ($qtype . ':' . $query) . "\">", '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')
|
||
|
|
// );
|
||
|
|
|
||
|
|
echo json_encode($data);
|