112 lines
3.9 KiB
PHP
112 lines
3.9 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/auth/auth.php');
|
|
include('includes/functions.php');
|
|
include('access.php');
|
|
//include('log_entry.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
?>
|
|
<?php
|
|
//begin();
|
|
// Connect to mysqli database
|
|
$page = 1; // The current page
|
|
$sortname = 'section_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']);
|
|
}
|
|
|
|
$hasReadAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'R');
|
|
$hasWriteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'W');
|
|
$hasExecuteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'E');
|
|
if ($qtype == 'section_name') {
|
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim($query) . "%')" : '';
|
|
} else if ($qtype == 'section_desc') {
|
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim($query) . "%')" : '';
|
|
}
|
|
|
|
|
|
//echo $searchSql;
|
|
//echo $qtype." ".$query;
|
|
//echo ($qtype != '' && $query != '');
|
|
|
|
// Setup sort and search SQL using posted data
|
|
$sortSql = "order by $sortname $sortorder";
|
|
|
|
|
|
//echo "h".$searchSql;
|
|
//$searchSql = preg_replace ( '/and/', 'where', $searchSql, 1 );
|
|
// Get total count of records
|
|
$sql = "select count(*) from checkup_form_section $searchSql";
|
|
//error_log("nnnnnnnnnnn".$sql);
|
|
//echo $sql;
|
|
$result = mysqli_query($conn, $sql);
|
|
//rollback();
|
|
$row = mysqli_fetch_array($result);
|
|
$total = $row[0];
|
|
if (!isset($rp)) {
|
|
$rp = 10;
|
|
}
|
|
// Setup paging SQL
|
|
// $rp=1;
|
|
$pageStart = ($page - 1) * $rp;
|
|
$limitSql = "limit $pageStart, $rp";
|
|
// Return JSON data
|
|
$data = array();
|
|
$data['page'] = $page;
|
|
$data['total'] = $total;
|
|
$data['rows'] = array();
|
|
// $sql = "select checkup_section_id , checkup_section_name, description from checkup_section_master $searchSql $sortSql $limitSql";
|
|
//echo $sql;
|
|
$sql = "select * from checkup_form_section $searchSql $sortSql $limitSql";
|
|
error_log("Section :" . $sql);
|
|
$results = mysqli_query($conn, $sql);
|
|
$count = 1;
|
|
while ($row = mysqli_fetch_assoc($results)) {
|
|
|
|
$section_id = $row['section_id'];
|
|
$rule_ids = getCommaSeperatedValuesForInClause('select rule_equation from rule_equation', 'rule_eq_id', $row['rule_ids']);
|
|
$access_level = "E";
|
|
if ($access_level == 'R' || $access_level == 'W' || $access_level == 'E') {
|
|
$view_link = "<a href=\"#\"class=\"green\" onclick=\"open_checkup_section_form('" . $section_id . "','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
|
}
|
|
if ($access_level == 'W' || $access_level == 'E') {
|
|
$edit_link = "<a href=\"#\" class=\"blue\" onclick=\"open_checkup_section_form('" . $section_id . "','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
}
|
|
if ($access_level == 'E') {
|
|
$delete_link = "<a href=\"#\" class=\"blue\" onclick=\"delete_checkup_section_form('" . $section_id . "','E');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
|
}
|
|
|
|
$space = " ";
|
|
$links = $assign_link . $space . $view_link . $space . $edit_link . $space . $delete_link;
|
|
|
|
|
|
$interpretation = getFieldFromTable('interpretation_header', 'interpretation_master', 'id', $row['interpretation']);
|
|
|
|
|
|
|
|
$data['rows'][] = array(
|
|
'section_id' => $row['section_id'],
|
|
'cell' => array($count++, $links, $row['section_name'], $row['section_desc'], $row['Status'], $row['notes'], $row['comments'], $rule_ids, $row['display_order'], $interpretation)
|
|
);
|
|
}
|
|
echo json_encode($data);
|
|
?>
|