151 lines
5.6 KiB
PHP
151 lines
5.6 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
|
|
|
|
// Connect to mysqli database
|
|
$page = 1; // The current page
|
|
$sortname = 'a.last_modified'; // Sort column
|
|
$sortorder = 'desc'; // Sort order
|
|
$qtype = ''; // Search column
|
|
$query = ''; // Search string
|
|
// 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']);
|
|
}
|
|
// Setup sort and search SQL using posted data
|
|
$hasReadAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'R');
|
|
$hasWriteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'W');
|
|
$hasExecuteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'E');
|
|
$sortSql = "group by a.response_id order by $sortname $sortorder";
|
|
|
|
if ($qtype == 'dept_name') {
|
|
$searchSql = " and dept_id in (select dept_id from department where dept_name like '%$query%') ";
|
|
}elseif ($qtype == 'medical_entry_date_between') {
|
|
$dates = explode("-", $query);
|
|
|
|
$searchSql = " and date_format(date(screen_date),'%Y-%m-%d') between str_to_date('" . trim($dates[0]) . "','%d/%m/%Y') and str_to_date('" . trim($dates[1]) . "','%d/%m/%Y') ";
|
|
} else {
|
|
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%$query%')" : '';
|
|
}
|
|
|
|
$ohc_type = $_SESSION['current_ohcttype'];
|
|
// Get total count of records
|
|
$sql = "select count(distinct(a.response_id)) from questionaire_master_response a left join questionaire_master_response_details b on a.response_id = b.response_id left join patient_master c on a.patient_id = c.id where form_type='dlf' and f_status='CLS' and approval_status='Y'";
|
|
|
|
//echo $sql;
|
|
$result = mysqli_query($conn, $sql);
|
|
$row = mysqli_fetch_array($result);
|
|
$total = $row[0];
|
|
// Setup paging
|
|
if (!isset($rp)) {
|
|
$rp = 10;
|
|
}
|
|
//echo $_REQUEST[emp_id];
|
|
$pageStart = ($page - 1) * $rp;
|
|
$limitSql = "limit $pageStart, $rp";
|
|
// Return JSON data
|
|
$data = array();
|
|
$data['page'] = $page;
|
|
$data['total'] = $total;
|
|
$data['rows'] = array();
|
|
$sql_medical_examination = "select *,c.employer_contractor_id,c.dept_id from questionaire_master_response a left join questionaire_master_response_details b on a.response_id = b.response_id left join patient_master c on a.patient_id = c.id where form_type = 'dlf' and f_status='CLS' and approval_status='Y' ";
|
|
|
|
$sql_export = $sql_medical_examination ;
|
|
$sql_medical_examination .="$searchSql $sortSql $limitSql";
|
|
$sql_export .= " $searchSql $sortSql ";
|
|
|
|
|
|
error_log("ffi grid " . $sql_medical_examination);
|
|
$results_medical_examination = mysqli_query($conn, $sql_medical_examination);
|
|
$count = ($page - 1) * $rp + 1;
|
|
|
|
//echo $sql_checkup;
|
|
//echo $access_level;
|
|
|
|
while ($row_medical_examination = mysqli_fetch_assoc($results_medical_examination)) {
|
|
|
|
$patient_id = $row_medical_examination['patient_id'];
|
|
$department = getTableFieldValue('department', 'dept_name', 'dept_id', $row_medical_examination['dept_id']);
|
|
$emp_cont = getTableFieldValue('employer_contractor', 'employer_contractor_name', 'id', $row_medical_examination['employer_contractor_id']);
|
|
$dlf_no = $row_medical_examination['medical_examination_no'];
|
|
$response_id = $row_medical_examination['response_id'];
|
|
error_log($emp_cont);
|
|
error_log('---------');
|
|
$view_link = "";
|
|
$edit_link = "";
|
|
$delete_link = "";
|
|
$pdf_link = "";
|
|
$links = "";
|
|
|
|
|
|
if ($hasWriteAccess) {
|
|
$edit_link = "<a href=\"#\" class=\"blue\" onclick=\"open_dlf_form('" . $row_medical_examination['patient_id'] . "','" . $dlf_no . "','" . $response_id . "');\"><span style=\"font-size:12px\" class=\"glyphicon glyphicon-edit\"></span></a>";
|
|
|
|
$pdf_link = "<a href=\"#\" class=\"red\" onclick=\"open_form_pdf('" . $row_medical_examination['patient_id'] . "','" . $response_id . "','" . $dlf_no . "');\"><i class=\"fa fa-file-pdf-o\" style=\"font-size: 12px;\"></i></a>";
|
|
}
|
|
if ($hasExecuteAccess) {
|
|
$delete_link = "<a href=\"#\" class=\"blue\" onclick=\"delete_ffi_form('" . $row_medical_examination['patient_id'] . "','" . $response_id . "','" . $dlf_no . "');\"><span style=\"font-size:20px\" class=\"ace-icon fa fa-trash bigger-130\"></span></a>";
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$space = " ";
|
|
$links = $assign_link . $space . $view_link . $space . $edit_link . $space . $delete_link . $space . $pdf_link;
|
|
|
|
$data['rows'][] = array(
|
|
'id' => $row_medical_examination['patient_id'],
|
|
|
|
'cell' => array($count++, $row_medical_examination['patient_name'], $row_medical_examination['screen_date'], $row_medical_examination['emp_code'], $department, $emp_cont, $links)
|
|
);
|
|
}
|
|
|
|
$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=\"" . base64_encode($paramlist) . "\">",
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
''
|
|
)
|
|
);
|
|
echo json_encode($data);
|
|
?>
|