ok
Direktori : /home2/selectio/www/subamangala/admin/api/waste-files/ |
Current File : /home2/selectio/www/subamangala/admin/api/waste-files/own-attendance-checkin-checkout.php |
<?php include"../config/config.php"; if($_POST['type']=="own_info"){ $emp_id = $_POST['emp_id']; date_default_timezone_set("Asia/Kolkata"); //India time (GMT+5:30) $checkin_time= date('H:i:s'); $date = date('Y-m-d'); $response=array(); $statement = $pdo->prepare("SELECT * FROM `tbl_attendance` where empid=".$emp_id." and att_date='".$date."'"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); $statement = $pdo->prepare("SELECT DATE_FORMAT(date, '%d-%m-%Y') as date,TIME_FORMAT(check_in, '%H:%i:%s %p') check_in,TIME_FORMAT(check_out, '%H:%i:%s %p') as check_out,check_out as c,TIMEDIFF(check_out,check_in) as over_all_time,check_out_type FROM `tbl_day_log_monitor` where emp_id=".$emp_id." and date='".$date."'"); $statement->execute(); $log_result = $statement->fetchAll(PDO::FETCH_ASSOC); $total_rows = $statement->rowCount(); if($result[0]['check_out']!='00:00:00'){ $total_rows=0; } $n=0; foreach($log_result as $log){ if($log['c']=='00:00:00'){$log_result[$n]['over_all_time']="00:00:00";} $n++; } $response['count']=$total_rows; $response['data']=$result; $response['log_data']=$log_result; echo json_encode($response); } if($_POST['type']=="update_checkin"){ $emp_id = $_POST['emp_id']; date_default_timezone_set("Asia/Kolkata"); //India time (GMT+5:30) $checkin_time= date('H:i:s'); $date = date('Y-m-d'); $statement = $pdo->prepare("SELECT * FROM `tbl_attendance` where empid=".$emp_id." and att_date='".$date."'"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); if(!$result){ $statement = $pdo->prepare("INSERT INTO `tbl_attendance`(`empid`,`check_in`,`att_date`, `added_by`) VALUES (?,?,?,?)"); $result=$statement->execute(array($_POST['emp_id'],$checkin_time,$date,$_POST['created_by'])); }else{ $s="UPDATE tbl_attendance SET check_out='00:00:00', WHERE empid=$emp_id and att_date='".$date."'"; error_log($s); $statement = $pdo->prepare("UPDATE tbl_attendance SET check_out=? WHERE empid=? and att_date='".$date."'"); $result=$statement->execute(array('00:00:00',$emp_id)); } if($result){ $statement = $pdo->prepare("INSERT INTO `tbl_day_log_monitor`(`emp_id`,`check_in`,`date`) VALUES (?,?,?)"); $result=$statement->execute(array($_POST['emp_id'],$checkin_time,$date)); $response['error']=false; $response['message']="Own Attendance Details Successfuly"; }else{ $response['error']=true; $response['message']='failed'; } echo json_encode($response); } if($_POST['type']=="update_checkout"){ $emp_id = $_POST['emp_id']; date_default_timezone_set("Asia/Kolkata"); //India time (GMT+5:30) $checkout_time= date('H:i:s'); $date = date('Y-m-d'); $statement = $pdo->prepare("UPDATE tbl_attendance SET check_out=?,updated_by=? WHERE empid=? and att_date=?"); $result=$statement->execute(array($checkout_time,$_POST['updated_by'],$emp_id,$date)); if($result){ $statement = $pdo->prepare("UPDATE tbl_day_log_monitor SET check_out=?,check_out_type=? WHERE emp_id=? and date=? and check_out='00:00:00'"); $result=$statement->execute(array($checkout_time,$_POST['break_type'],$emp_id,$date)); $response['error']=false; $response['message']="Own Attendance Check out Successfuly"; }else{ $response['error']=true; $response['message']='failed'; } echo json_encode($response); } ?>