ok
Direktori : /proc/thread-self/root/home2/selectio/www/obnovit-tracking/api/ |
Current File : //proc/thread-self/root/home2/selectio/www/obnovit-tracking/api/daily-attendance-api.php |
<?php include"../config/config.php"; if($_POST['type']=="daily_attendance"){ $emp_id = $_POST['emp_id']; $date = $_POST['date']; $where=""; if(isset($_POST['emp_id']) && $_POST['emp_id']!='all'){ $where.=" and id=".$_POST['emp_id']; } /*if(isset($_POST['department_id']) && $_POST['department_id']!='all'){ $where.=" and department_id=".$_POST['department_id']; }*/ $statement = $pdo->prepare("SELECT * FROM `tbl_user` WHERE id!=1 ".$where.""); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); $totalrow = $statement->rowCount(); $n=0; foreach($result as $row){ $user_id=$row['id']; $result[$n]['user_id']=$row['id']; /*$result[$n]['id']=$row['id']; $result[$n]['date']=$date; $n++;*/ $statement = $pdo->prepare("SELECT * FROM `tbl_attendence` WHERE resource_name=".$user_id." and attendence_date='".$date."'"); $statement->execute(); $query="SELECT * FROM `tbl_attendence` WHERE resource_name=".$user_id." and attendence_date='".$date."'"; error_log($query); $att_result = $statement->fetchAll(PDO::FETCH_ASSOC); if($att_result){ foreach($att_result as $rows){ $result[$n]['id']=$rows['id']; $result[$n]['user_id']=$row['id']; $result[$n]['emp_id']=$rows['resource_name']; $result[$n]['date']=$rows['attendence_date']; $result[$n]['att_department']=$rows['department']; $result[$n]['att_project']=$rows['project_name']; $result[$n]['att_type']=$rows['attendence_type']; $result[$n]['department']=$rows['department']; $result[$n]['project']=$rows['project_name']; $result[$n]['salary']=$rows['salary_per_day']; $result[$n]['notes']=$rows['notes']; } }else{ $result[$n]['id']=""; $result[$n]['date']=""; $result[$n]['att_department']=""; $result[$n]['att_project']=""; $result[$n]['att_type']=""; $result[$n]['salary']=""; } $n++; } if($result){ $response['data']=$result; $response['error']=false; $response['message']="Attendance details fetched Successfuly"; }else{ $response['error']=true; $response['message']='failed'; } echo json_encode($response); } ?>