ok
Direktori : /proc/self/root/home2/selectio/www/tnpsctestbatch.com/admin/old/api/backups/ |
Current File : //proc/self/root/home2/selectio/www/tnpsctestbatch.com/admin/old/api/backups/emp-dash-api.php |
<?php ini_set('memory_limit', '-1'); ob_start(); session_start(); include"../config/config.php"; try{ $filter_year=date("Y"); $filter_month=date("m"); $filter_employee=$_SESSION['hrm']['id']; $monthName = date("F", mktime(0, 0, 0, $filter_month)); $total_days_inMonth=date('d ',strtotime("Last Day of $monthName $filter_year")); $conditions=' and h.status=1 '; $conditions.="and h.id='".$filter_employee."' "; $sql="SELECT h.*,(SELECT COUNT(id) FROM tbl_payslip_generation WHERE month = $filter_month and year=$filter_year and employee_id=h.id) as payslip_status,(SELECT id FROM tbl_payslip_generation WHERE month = $filter_month and year=$filter_year and employee_id=h.id) as payslip_id,(SELECT COUNT(id) FROM tbl_attendance WHERE MONTH(att_date) = $filter_month and type=1 and empid=h.id) as working_days,(select basic_salary from tbl_emp_salary WHERE tbl_emp_salary.emp_id=h.id order by id desc limit 1) as emp_salary,(select departement from tbl_departement WHERE tbl_departement.id=h.department_id) as department_id,(select desgination from tbl_desgination WHERE tbl_desgination.id=h.designation_id) as designation_id,(select type_name from tbl_pf_type WHERE tbl_pf_type.id=h.pftype) as pftype FROM tbl_user h where h.id!=1 ".$conditions; $statement = $pdo->prepare($sql); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); $content='<div >'; if($result){ $row_ids=0; foreach($result as $res){ $holidays=0;$special_holidays=0;$permission_leave=0;$avg_salary=0;$half_day_attendance_val=0; $sabari_p=0;$sabari_a=0;$sabari_h=0;$sabari_holi=0;$sabari_ch=0;$sabari_b=0;$sabari_lop=0;$sabari_week_off=0; $sabari_spl_p=0;$sabari_spl_hp=0; $sabari_p_p=0;$sabari_p_hp=0; $sabari_hd_a=0; $dsd=''; $vb=''; $use_cumulative=0;$use_casual=0; for($v=1;$v<=$total_days_inMonth;$v++){ $is_common_leave=0;$is_holiday=0;$is_leave=0;$is_attendance=0;$is_absent_attendance=0;$is_special_leave_attendance=0;$is_half_day=0; $seq_date="".$filter_year."-".$filter_month."-".str_pad($v, 2, "0", STR_PAD_LEFT); $nameOfDay = date('l', strtotime($seq_date)); $sqls="SELECT day_name FROM `tbl_comon_leave` WHERE status=1"; $statements = $pdo->prepare($sqls); $statements->execute(); $common_holiday_result = $statements->fetchAll(PDO::FETCH_ASSOC); $com_leaves=array(); foreach($common_holiday_result as $d){$com_leaves[]=$d['day_name'];} if($seq_date>=$res['joining_date']) { if(in_array($nameOfDay ,$com_leaves ) ) { $is_common_leave=1; $sabari_ch++; } } $sqls="SELECT * FROM `tbl_process_leaves` WHERE empid=".$res['id']." and att_date='".$seq_date."' "; $statements = $pdo->prepare($sqls); $statements->execute(); $common_process_result = $statements->fetchAll(PDO::FETCH_ASSOC); if($seq_date>=$res['joining_date']) { if($common_process_result) { $is_common_leave=1; $sabari_ch++; } } if($seq_date>=$res['joining_date']) { if($is_common_leave!=1){ $sqls="SELECT * FROM `tbl_holidays` WHERE holiday_date='".$seq_date."'"; $statements = $pdo->prepare($sqls); $statements->execute(); $holiday_result = $statements->fetchAll(PDO::FETCH_ASSOC); if($holiday_result){$is_holiday=1; $sabari_holi++;} } } if($seq_date>=$res['joining_date']) { if($is_common_leave==0 && $is_holiday==0){ $sqls="SELECT * FROM `tbl_leave_request` WHERE emp_id=".$res['id']." and start_date<='".$seq_date."' and end_date>='".$seq_date."' and status=1"; $statements = $pdo->prepare($sqls); $statements->execute(); $leave_result = $statements->fetchAll(PDO::FETCH_ASSOC); if($leave_result){$is_leave=1;$permission_leave++;$sabari_lop++; } } } $sqls="select * from tbl_attendance where empid=".$res['id']." and att_date='".$seq_date."' and type=1"; $statements = $pdo->prepare($sqls); $statements->execute(); $attendance_result = $statements->fetchAll(PDO::FETCH_ASSOC); if($attendance_result && $is_common_leave==0 && $is_holiday==0){$is_attendance=1; $sabari_p++;} //if($attendance_result ){$is_attendance=1; $sabari_p++;} $sqls="select * from tbl_attendance where empid=".$res['id']." and att_date='".$seq_date."' and type=3"; $statements = $pdo->prepare($sqls); $statements->execute(); $absent_attendance_result = $statements->fetchAll(PDO::FETCH_ASSOC); if($absent_attendance_result && $is_leave==0){$is_absent_attendance=1; $sabari_a++;} $sqls="select * from tbl_attendance where empid=".$res['id']." and att_date='".$seq_date."'"; $statements = $pdo->prepare($sqls); $statements->execute(); $empty_absent_attendance_result = $statements->fetchAll(PDO::FETCH_ASSOC); $empty_absent_attendance_results = $statements->rowCount(); if($empty_absent_attendance_results==0 && $is_common_leave==0 && $is_holiday==0 && $is_leave==0){$is_absent_attendance=1; $sabari_a++; $dsd.='-'.$seq_date; } $sqls="select * from tbl_attendance where empid=".$res['id']." and att_date='".$seq_date."' and type=2"; $statements = $pdo->prepare($sqls); $statements->execute(); $half_day_attendance_result = $statements->fetchAll(PDO::FETCH_ASSOC); if($half_day_attendance_result && $is_common_leave==0 && $is_holiday==0){ $half=0.5;$is_half_day=1; $half_day_attendance_val=(float)((float)$half_day_attendance_val+(float)$half); error_log('half Day:'.$half_day_attendance_val); $sabari_h++; } $sqls="select * from tbl_attendance where empid=".$res['id']." and att_date='".$seq_date."' and type=5"; $statements = $pdo->prepare($sqls); $statements->execute(); $special_leave_attendance_result = $statements->fetchAll(PDO::FETCH_ASSOC); if($special_leave_attendance_result){$is_special_leave_attendance=1;$special_holidays++; $sabari_b++;} if($is_common_leave || $is_holiday){ $holidays++; if($attendance_result){$sabari_spl_p++; } if($half_day_attendance_result){$sabari_spl_hp++; } } if($seq_date>=$res['joining_date']) { if($is_common_leave==0 && $is_holiday==0 && $is_leave==0){ //$sqls="SELECT * FROM `tbl_leave_request` WHERE emp_id=".$res['id']." and start_date<='".$seq_date."' and end_date>='".$seq_date."' and status=4"; $sqls="select * from tbl_attendance where empid=".$res['id']." and att_date='".$seq_date."' and type=4"; $statements = $pdo->prepare($sqls); $statements->execute(); $weekoff_result = $statements->fetchAll(PDO::FETCH_ASSOC); if($weekoff_result){$sabari_week_off++; } } } if($leave_result){ if($attendance_result){ $sabari_p_p++;} if($half_day_attendance_result){ $sabari_p_hp++; $vb.=' date:'.$seq_date;} }else { if($half_day_attendance_result && $is_common_leave==0 && $is_holiday==0){ $sabari_hd_a++; } } } $res['working_days']=((float)$res['working_days']+(float)$half_day_attendance_val); $d=(float)((float)$res['working_days']+(float)$half_day_attendance_val); $mul=0; $total_ctc=0;$net_pay_empoyee=0; $salary_processing_days=(((float)$res['working_days']+((float)$special_holidays+(float)$holidays))); if($res['working_days']<5){ $salary_processing_days=$res['working_days']; } if($res['working_days']>0){ $mul=1;} $avg_salary=number_format((float)($salary_processing_days)*($res['emp_salary']/$total_days_inMonth), 2, '.', ''); $basic_pay=0; $lop_days=((int)$total_days_inMonth-(int)$res['working_days']-(int)$special_holidays-(int)$holidays-(float)$half_day_attendance_val); if($lop_days<0){ $lop_days=0; } $extra_wrotking=0; $add_cumulative=0; $add_casual=0; if($total_days_inMonth<$salary_processing_days){ $add_cumulative=$salary_processing_days-$total_days_inMonth; $salary_processing_days=$salary_processing_days-$add_cumulative; } if($salary_processing_days>$total_days_inMonth){ $salary_processing_days=$total_days_inMonth; } /*Auto Casual Leave Start...*/ if($add_casual==0){$add_casual=1;} /*Auto Casual Leave End...*/ $g_lop_days=0; $salary_processing_days=$sabari_p+($sabari_h/2)+$sabari_b+$sabari_holi+$sabari_ch+$special_holidays; $add_cumulative=($salary_processing_days+$sabari_spl_p+($sabari_spl_hp/2))-$total_days_inMonth; if($add_cumulative>0){ $salary_processing_days=($salary_processing_days+$sabari_spl_p+($sabari_spl_hp/2))-$add_cumulative; }else{ $add_cumulative=0; $salary_processing_days=($salary_processing_days+$sabari_spl_p+($sabari_spl_hp/2))-$add_cumulative; } $g_spl_present_total=($sabari_spl_p+($sabari_spl_hp/2)); $g_lop=$sabari_a+($sabari_hd_a/2)+$sabari_lop+$sabari_week_off; //lop days if($g_lop>$g_spl_present_total){ $g_lop_days=$g_lop-$g_spl_present_total; }else{ $g_lop_days=0; } $content=array(); $content['days_in_month']=$total_days_inMonth; $content['working_days']=$sabari_p+($sabari_h/2); $content['holiday']=($sabari_ch+$sabari_holi); $content['permission_leaves']=($sabari_lop-($sabari_p_p+($sabari_p_hp/2))); $content['special_precent']=$sabari_spl_p+($sabari_spl_hp/2); $content['cumulative_leave']=$res['cumulative_leave']; $content['casual_leave']=$res['casual_leave']; $row_ids++; } $response['data']=$content; $response['error']=false; $response['message']="info details fetched Successfuly"; }else{ $response['error']=true; $response['message']='failed'; } echo json_encode($response); } catch(Exception $e){ $response['error']=true; $response['message']=$e.'failed'; echo json_encode($response); } /*Present-'.$sabari_p.',Absend-'.$sabari_a.',Hafl Day-'.($sabari_h/2).',Common Leave-'.$sabari_ch.',BonusL-'.$sabari_b.',Permissions-'.$sabari_lop.',Holiay-'.$sabari_holi.',WeekOff-'.$sabari_week_off.' Spl P-'.$sabari_spl_p.'.SPL hD-'.($sabari_spl_hp/2).',per P-'.$sabari_p_p.'.per hD-'.($sabari_p_hp/2).', half day absent : '.($sabari_hd_a/2).' */ ?>