208 lines
6.7 KiB
PHP
208 lines
6.7 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 = 'assign_training_id'; // Sort column
|
||
|
$sortorder = 'asc'; // 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');
|
||
|
|
||
|
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%".trim($query)."%')" : '';
|
||
|
if($qtype!=''){
|
||
|
if($qtype=='emp_cat_name'){
|
||
|
$searchSql =" inner join employee_category on employee_category.emp_cat_id=assign_training.emp_cat_id where upper(emp_cat_name) like upper(trim('%$query%')) ";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if($qtype!=''){
|
||
|
if($qtype=='training_name'){
|
||
|
$searchSql =" inner join training_master on training_master.training_master_id=assign_training.training_schedule_id where upper(training_name) like upper(trim('%$query%')) ";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if ($searchSql != '') {
|
||
|
|
||
|
if ($qtype == 'date_assigned') {
|
||
|
|
||
|
$searchSql = " and date_format(date(date_assigned),'%Y-%m-%d')=str_to_date('$query','%d/%m/%Y') ";
|
||
|
//echo $searchSql;
|
||
|
|
||
|
}
|
||
|
else if ($qtype == 'date_assigned_between') {
|
||
|
$dates = explode("-", $query);
|
||
|
// $qtype=" due_date between ";
|
||
|
$searchSql = " and date_assigned between str_to_date('" . trim($dates[0]) . "','%d/%m/%Y') and str_to_date('" . trim($dates[1]) . "','%d/%m/%Y') ";
|
||
|
}
|
||
|
}
|
||
|
// Get total count of records
|
||
|
error_log("assigned date:".$searchSql);
|
||
|
$sortSql = "order by $sortname $sortorder";
|
||
|
$searchSql=preg_replace('/and/', 'where', $searchSql, 1);
|
||
|
$sql = "select count(*) from assign_training $searchSql ";
|
||
|
//echo $sql;
|
||
|
$result = mysqli_query($conn,$sql);
|
||
|
//echo $result;
|
||
|
$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();
|
||
|
$sql1 = "select * from assign_training ";
|
||
|
$sql_export=$sql1;
|
||
|
$sql1 .="$searchSql $sortSql $limitSql";
|
||
|
$sql_export .="$searchSql $sortSql ";
|
||
|
//echo $sql1;
|
||
|
$results = mysqli_query($conn,$sql1);
|
||
|
//echo $results;
|
||
|
//echo mysqli_error($conn$results);
|
||
|
$count=($page-1)*$rp+1;
|
||
|
//echo $sql_ailment;
|
||
|
//echo $access_level;
|
||
|
|
||
|
while ($row1= mysqli_fetch_assoc($results)) {
|
||
|
|
||
|
$id=$row1['assign_training_id'];
|
||
|
//echo $Department_id;
|
||
|
$view_link="";
|
||
|
$edit_link="";
|
||
|
$delete_link="";
|
||
|
$links="";
|
||
|
if($hasReadAccess)
|
||
|
{
|
||
|
//echo "shubham";
|
||
|
$view_link="<a href=\"#\"class=\"green\" onclick=\"open_assign_training_schedule('".$id."','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
||
|
}
|
||
|
|
||
|
if($hasWriteAccess)
|
||
|
{
|
||
|
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_assign_training_schedule('".$id."','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
||
|
}
|
||
|
if($hasExecuteAccess)
|
||
|
{
|
||
|
$delete_link="<a href=\"#\" class=\"red\" onclick=\"delete_assign_training_schedule('".$id."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
||
|
}
|
||
|
|
||
|
$credit_to=$row1['credit_to'];
|
||
|
$credit_to_name="";
|
||
|
if($credit_to=="1"){
|
||
|
$credit_to_name="All Employees";
|
||
|
|
||
|
}else if($credit_to=="2"){
|
||
|
$credit_to_name="Employee Categories";
|
||
|
}else if($credit_to=="3"){
|
||
|
$credit_to_name="Specific Employee";
|
||
|
}
|
||
|
|
||
|
$employee_categories="";
|
||
|
$emp_cat_ids=array();
|
||
|
if($row1['emp_cat_id']!=null && $row1['emp_cat_id']!=""){
|
||
|
$emp_cat_ids= explode(",",$row1['emp_cat_id']);
|
||
|
|
||
|
for($i=0;$i<count($emp_cat_ids);$i++){
|
||
|
if($i==count($emp_cat_ids)-1)
|
||
|
$employee_categories.=getTableFieldValue('patient_category','patient_cat_name','patient_cat_id',$emp_cat_ids[$i]);
|
||
|
else
|
||
|
$employee_categories.=getTableFieldValue('patient_category','patient_cat_name','patient_cat_id',$emp_cat_ids[$i]).",";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$employee_name="";
|
||
|
$emp_name_ids=array();
|
||
|
if($row1['employee_id']!=null && $row1['employee_id']!=""){
|
||
|
$emp_name_ids= explode(",",$row1['employee_id']);
|
||
|
|
||
|
for($i=0;$i<count($emp_name_ids);$i++){
|
||
|
if($i==count($emp_name_ids)-1)
|
||
|
$employee_name.=getTableFieldValue('patient_master','patient_name','id',$emp_name_ids[$i]);
|
||
|
else
|
||
|
$employee_name.=getTableFieldValue('patient_master','patient_name','id',$emp_name_ids[$i]).",";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$training_schedule="";
|
||
|
$query_schedule = "select * from training_schedule where schedule_id='".$row1['training_schedule_id']."' ";
|
||
|
//echo $query_schedule;
|
||
|
$result_schedule = @mysqli_query($conn,$query_schedule);
|
||
|
while($rows_schedule = mysqli_fetch_assoc($result_schedule)){
|
||
|
$training_name=getTableFieldValue('training_master','training_name','training_master_id',$rows_schedule['training_id']);
|
||
|
$training_schedule= $training_name.'('.$rows_schedule['trainer_name'].','.date_format(date_create($rows_schedule['from_date']),"d-M-Y").' '.date_format(date_create($rows_schedule['to_date']),"d-M-Y").')';
|
||
|
}
|
||
|
|
||
|
|
||
|
$space=" ";
|
||
|
$links = $assign_link.$space.$view_link.$space.$edit_link.$space.$delete_link;
|
||
|
|
||
|
|
||
|
$data['rows'][] = array(
|
||
|
'id' => $row1['assign_training_id'],
|
||
|
'cell' => array($count++,$credit_to_name, $employee_categories,$employee_name,$training_schedule,date_format(date_create($row1['date_assigned']),"d-M-Y "),$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);
|
||
|
?>
|