235 lines
7.3 KiB
PHP
235 lines
7.3 KiB
PHP
|
<?php
|
||
|
include('includes/config/config.php');
|
||
|
include('includes/auth/auth.php');
|
||
|
include('includes/functions.php');
|
||
|
// error_reporting(E_ERROR | E_PARSE);
|
||
|
include('access.php');
|
||
|
include('log_entry.php');
|
||
|
// error_reporting(E_ERROR | E_PARSE);
|
||
|
?>
|
||
|
<?php
|
||
|
|
||
|
// Connect to mysqli database
|
||
|
$page = 1; // The current page
|
||
|
$sortname = 'date_assigned'; // 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');
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$sortSql = "order by $sortname $sortorder";
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%".trim($query)."%')" : '';
|
||
|
|
||
|
if($searchSql!=''){
|
||
|
if($qtype!=''){
|
||
|
if($qtype=='date_assigned'){
|
||
|
$searchSql =" where date_format(date(date_assigned),'%Y-%m-%d')=str_to_date('$query','%d-%m-%Y') ";
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
else if($qtype =='credit_to'){
|
||
|
|
||
|
if($query=="All Employees"){
|
||
|
//echo "dgt";
|
||
|
$searchSql =" where upper(credit_to) like upper(trim('%1%')) ";
|
||
|
|
||
|
}else if($query=="Employee Categories"){
|
||
|
//$qtype == "2";
|
||
|
$searchSql =" where upper(credit_to) like upper(trim('%2%')) ";
|
||
|
}else if($query=="Specific Employee"){
|
||
|
// $qtype == "3";
|
||
|
$searchSql =" where upper(credit_to) like upper(trim('%3%')) ";
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
else if($qtype=='emp_cat_name'){
|
||
|
$searchSql =" where emp_cat_id=(select emp_cat_id from employee_category where upper(emp_cat_name) like upper(trim('%$query%'))) ";
|
||
|
}
|
||
|
}}
|
||
|
// Get total count of records
|
||
|
$searchSql=preg_replace('/and/', 'where', $searchSql, 1);
|
||
|
$sql = "select count(*) from assign_checkup $searchSql $sortSql $limitSql ";
|
||
|
//echo $sql;
|
||
|
error_log("count: ".$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_checkup $searchSql $sortSql $limitSql ";
|
||
|
|
||
|
//echo $sql1;
|
||
|
error_log("query: ".$sql1);
|
||
|
$results = mysqli_query($conn,$sql1);
|
||
|
//echo $results;
|
||
|
//echo mysqli_error($results);
|
||
|
$count=($page-1)*$rp+1;
|
||
|
//echo $sql_ailment;
|
||
|
//echo $access_level;
|
||
|
|
||
|
while ($row1= mysqli_fetch_assoc($results)) {
|
||
|
|
||
|
$id=$row1['assign_checkup_id'];
|
||
|
//echo $id;
|
||
|
$view_link="";
|
||
|
$edit_link="";
|
||
|
$delete_link="";
|
||
|
$links="";
|
||
|
//if($hasReadAccess)
|
||
|
//{
|
||
|
//echo "shubham";
|
||
|
$view_link="<a href=\"#\"class=\"green\" onclick=\"open_assign_checkup_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_checkup_schedule('".$id."','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
||
|
//}
|
||
|
//if($hasExecuteAccess)
|
||
|
//{
|
||
|
$delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_assign_checkup_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('employee_category','emp_cat_name','emp_cat_id',$emp_cat_ids[$i]);
|
||
|
else
|
||
|
$employee_categories.=getTableFieldValue('employee_category','emp_cat_name','emp_cat_id',$emp_cat_ids[$i]).",";
|
||
|
}
|
||
|
}
|
||
|
$checkup_schedule="";
|
||
|
$query_schedule = "select * from checkup_list_mgmt where checkup_mgmt_id='".$row1['checkup_schedule']."' ";
|
||
|
// echo $query_schedule;
|
||
|
$result_schedule = @mysqli_query($conn,$query_schedule);
|
||
|
while($rows_schedule = mysqli_fetch_assoc($result_schedule)){
|
||
|
// echo fjdfdgfh;
|
||
|
$checkup_name=getTableFieldValue('checkup_master','checkup_name','checkup_master_id',$rows_schedule['checkup_mgmt_name'],'');
|
||
|
$checkup_schedule= $checkup_name.'('.$rows_schedule['checkup_by'].','.date_format(date_create($row_training['from_date']),"d-M-Y").' '.date_format(date_create($row_training['to_date']),"d-M-Y").')';
|
||
|
// echo $checkup_schedule;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
$space=" ";
|
||
|
$links = $assign_link.$space.$view_link.$space.$edit_link.$space.$delete_link;
|
||
|
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
/*
|
||
|
if(isset($_GET['forgot_pass'])){
|
||
|
echo"
|
||
|
<div align='center'>
|
||
|
<b>ENTER your email below we'll send your password to your email</b><br>
|
||
|
<form action='' method='post'>
|
||
|
<input type='text' name='c_email' placeholder='enter your email'/></br>
|
||
|
<input type ='submit' name='forgot_pass' value='send me password'/>
|
||
|
</form>
|
||
|
</div>
|
||
|
";
|
||
|
if(isset($_POST['forgot_pass'])){
|
||
|
$c_email=$_POST['c_email'];
|
||
|
$sel_c="select * from users where email='$c_email'";
|
||
|
|
||
|
$run_c=mysqli_query($conn,$sel_c);
|
||
|
$r = mysqli_fetch_assoc($run_c);
|
||
|
echo $r['email'];
|
||
|
$check_c=mysqli_num_rows($run_c);
|
||
|
|
||
|
if($check_c==0){
|
||
|
echo"<script>alert('this mail does not exist in our database,soory')</script>";
|
||
|
exit();
|
||
|
}
|
||
|
|
||
|
else{
|
||
|
$from='py27091998@gmail.com';
|
||
|
$subject="your password";
|
||
|
$message="
|
||
|
<html>
|
||
|
<h3>dear $c_email</h3>
|
||
|
<p> your requested password</p>
|
||
|
<b>your password is</b><span style='color:red;'></span>
|
||
|
<h3> thank you for using our website </h3>
|
||
|
|
||
|
</html>";
|
||
|
mail($c_email,$subject,$message,$from);
|
||
|
echo"<script>alert('password was sent to your email,please check your inbox !')</script>";
|
||
|
echo"<script>window.open('login.php','self')</script>";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
$data['rows'][] = array(
|
||
|
'id' => $row1['assign_checkup_id'],
|
||
|
'cell' => array($count++,$credit_to_name, $employee_categories,$checkup_schedule,date_format(date_create($row1['date_assigned']),"d-M-Y "),$links)
|
||
|
);
|
||
|
}
|
||
|
// error_log("data: ".print_r($data, true));
|
||
|
echo json_encode($data);
|
||
|
?>
|