ESH/pending_checklist_script.php

259 lines
7.1 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<?php
include ('includes/config/config.php');
include ('includes/auth/auth.php');
include ('includes/functions.php');
include ('access.php');
error_reporting ( E_ERROR | E_PARSE );
?>
<?php
$emp_id = $_REQUEST ['emp_id'];
// echo $emp_id;
// Connect to mysqli database
$page = 1; // The current page
$sortname = 'approve_date'; // 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
$sortSql = "order by $sortname $sortorder";
$searchSql = ($qtype != '' && $query != '') ? " and upper($qtype) like upper('%$query%')" : '';
if ($searchSql != '') {
if ($qtype == 'approve_date') {
$searchSql = " and date_format(date(approve_date),'%Y-%m-%d')=str_to_date('$query','%d/%m/%Y') ";
}
}
// Get total count of records
// echo 'shu'.$p;
$sql = "select count(*) FROM inventory_checklist_status where ohc_type_id='" . $_SESSION ['current_ohcttype'] . "' $searchSql";
// echo $sql;
$result = mysqli_query($conn,$sql );
$row = mysqli_fetch_array ( $result );
$total = $row [0];
// Setup paging
if (! isSet ( $rp )) {
$rp = 10;
}
$pageStart = ($page - 1) * $rp;
$limitSql = "limit $pageStart, $rp";
// Return JSON data
$data = array ();
$data ['page'] = $page;
$data ['total'] = $total;
$data ['rows'] = array ();
$sql_employee_appointment = "select a.* FROM inventory_checklist_status a left join ambulance_details_new b on a.amb_id=b.id where a.ohc_type_id='" . $_SESSION ['current_ohcttype'] ."' ";
// echo $sql_employee_appointment;
$sql_export = $sql_employee_appointment;
$sql_employee_appointment .= " $searchSql $sortSql $limitSql ";
$sql_export .= " $searchSql $sortSql ";
$results_employee_appointment = mysqli_query($conn,$sql_employee_appointment );
// echo $sql_employee_appointment;
$count = ($page - 1) * $rp + 1;
// echo $sql_ailment;
error_log($sql_employee_appointment);
while ( $row_employee_appointment = mysqli_fetch_assoc ( $results_employee_appointment ) ) {
extract ( $row_employee_appointment );
$param_year= $row_employee_appointment ['param_year'];
$param_month= $row_employee_appointment ['param_month'];
$amb_id= $row_employee_appointment ['amb_id'];
$item_cat= $row_employee_appointment ['item_cat'];
$status_id= $row_employee_appointment ['status_id'];
$status= $row_employee_appointment ['status'];
$issue_type= $row_employee_appointment ['issue_type'];
$shift= $row_employee_appointment ['shift'];
// echo $ailment_id;
$view_link = "";
$print_link= "";
$edit_link = "";
$links = "";
// $delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_employee_appointment_history('".$appointment_id."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
$space = "&nbsp;&nbsp;&nbsp;";
$edit_link = $space . "<a href=\"#\" class=\"blue\" onclick=\"open_employee_appointment('" . $param_year."','" . $param_month."','" . $amb_id."','" . $item_cat."','" . $status_id."','" . $status."','" . $issue_type."','" . $shift."','E');\"><i class=\"ace-icon fa fa-edit\" style=\"font-size: 15px;\"></i></a>";
// if($row_employee_appointment['status']=='APPROVE'){
// $print_link = $space . "<a href=\"#\" class=\"green\" onclick=\"open_employee_appointment('" . $param_year."','" . $param_month."','" . $amb_id."','" . $item_cat."','v');\" ><i class=\"ace-icon fa fa-file-pdf-o bigger-130\"></i></a>";
// }
// if ($appointment_type == 'I') {
// $isInjury = "<span class='red'>Yes</i></span>";
// $edit_link = "<a href=\"edit_injury.php?appointmentId=" . $appointment_id . "&flex_opd_id=" . $emp_id . "&returnPage=pending_patient_list.php?view=edit\" class=\"blue\" ><i class=\"menu-icon fa fa-pencil-square-o\"></i></a>";
// $view_link = "<a href=\"view_injury.php?appointmentId=" . $appointment_id . "&flex_opd_id=" . $emp_id . "&returnPage=pending_patient_list.php?view=view\" class=\"green\" ><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
// } else {
// $isInjury = "<span class='green'>No</i></span>";
// $edit_link = "<a href=\"edit_opd.php?appointmentId=" . $appointment_id . "&flex_opd_id=" . $emp_id . "&returnPage=pending_patient_list.php?view=edit\" class=\"blue\" ><i class=\"menu-icon fa fa-pencil-square-o\"></i></a>";
// $view_link = "<a href=\"view_opd.php?appointmentId=" . $appointment_id . "&flex_opd_id=" . $emp_id . "&returnPage=pending_patient_list.php?view=view\" class=\"green\" ><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
// }
if ($row_employee_appointment ['status'] != 'APPROVED' && $row_employee_appointment ['status'] != 'APPROVE' ) {
$status = "<span class=' lighter red'>".$row_employee_appointment ['status']."</i></span>";
} else {
$status = "<span class='green'>APPROVED</i></span>";
}
if (! isAccessible ( $_SESSION ['RoleId'], $menu_key, 'W' )) {
$edit_link = "";
}
$amb_name='';
if($row_employee_appointment ['issue_type']=='AMB'){
$amb_name = getTableFieldValue("ambulance_details_new","CONCAT( ambulance_name , ' ( ' , ambulance_number , ' ) ')","id",$row_employee_appointment['amb_id']) ;
}else{
$amb_name = getTableFieldValue('ohc_type', "CONCAT(ohc_type_name)", 'ohc_type_id',$row_employee_appointment['amb_id']) ;
}
$monthNum = $row_employee_appointment ['param_month'];
$dateObj = DateTime::createFromFormat('!m', $monthNum);
$monthName = $dateObj->format('F');
$links = $view_link . $space . $edit_link. $space . $print_link ;
// echo $row_employee_appointment['bp_sbp'];
$data ['rows'] [] = array (
'id' => $row_employee_appointment ['status_id'],
'cell' => array (
$count ++,
$links,
$amb_name,
$monthName,
$row_employee_appointment ['param_year'],
getTableFieldValue('shift_status','status_name','shift_status_id',$row_employee_appointment ['shift']) ,
getTableFieldValue('patient_master','patient_name','id',getTableFieldValue('tbl_users','emp_id','user_id',$row_employee_appointment ['checker_user_id'])) ,
$status,
)
)
;
}
$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 );
?>