query("SELECT * FROM system_user WHERE user_id = '".$_SESSION['system_id']."' "); if ($mysqli_page->num_rows > 0){ while($row_page=$mysqli_page->fetch_array(MYSQLI_ASSOC)){ if($row_page['user_date_format'] == NULL){ $dateformat = "Y-m-d"; } else{ $dateformat = $row_page['user_date_format']; } $date01 = str_replace("d","01",$dateformat); $date31 = str_replace("d","t",$dateformat); // get all branch $branch = [] ; $get_branch = $mysqli->query("SELECT * FROM branch WHERE deleted_at IS NULL".$user_branch_permission_sql) ; if ( $get_branch->num_rows > 0 ){ while ( $row_branch = $get_branch->fetch_assoc() ){ $branch[$row_branch['branch_id']] = $row_branch['branch_name'] ; } } $array_typelist = [ 'PT' => 'Partime Day', 'WD' => 'Working Day', 'AL' => 'Annual Leave', 'MC' => 'Sick Leave', 'UL' => 'Unpaid Leave', 'AS' => 'Absent', 'HL' => 'Holiday', 'OD' => 'Off Day' ] ; // mode type | all list | new | edit switch( $page_mode ){ case 'record-all': include 'includes/Record/record-all.php'; break; case 'record-edit': include 'includes/Record/record-edit.php'; break; case 'admend-format-1' : /* $result = 'failed' ; $data = [] ; $staff_id = escapeString($_GET['staff_id']) ; $check_group = escapeString($_GET['check_group']) ; if ( $staff_id != '' && $check_group != '' ){ $attendances_q = $mysqli->query("SELECT * FROM staff_attendance WHERE staff_id = '".$staff_id."'AND check_group = '".$check_group."' AND deleted_at IS NULL ORDER BY created_at ASC") ; if ( $attendances_q->num_rows > 0 ){ $result = 'success' ; while ( $attendance = $attendances_q->fetch_assoc() ){ $data[] = [ 'id' => $attendance['attendance_id'], 'type' => ucwords($attendance['type']), 'date' => date('Y-m-d', strtotime($attendance['created_at'])), 'time' => date('H:i:s', strtotime($attendance['created_at'])) ] ; } $last_inout = '' ; $last_date = '' ; for ( $a = 0 ; $a < 8 ; $a++ ){ if ( !empty($data[$a]) ){ $last_inout = $data[$a]['type'] ; $last_date = $data[$a]['date'] ; }else{ if ( $last_inout == 'In' ){ $last_inout = 'Out' ; }else{ $last_inout = 'In' ; } $data[$a] = [ 'id' => 0, 'type' => $last_inout, 'date' => $last_date, 'time' => '' ] ; } } }else{ $result = 'success' ; $last_inout = '' ; for ( $a = 0 ; $a < 8 ; $a++ ){ if ( $last_inout == 'In' && $last_inout != '' ){ $last_inout = 'Out' ; }else{ $last_inout = 'In' ; } $data[$a] = [ 'id' => 0, 'type' => $last_inout, 'date' => $check_group, 'time' => '' ] ; } } } echo json_encode([ 'result' => $result, 'data' => $data ]) ; exit ; */ break ; case 'admend-format-2' : $result = 'failed' ; $data = [] ; $staff_id = escapeString($_GET['staff_id']) ; $check_group = escapeString($_GET['check_group']) ; if ( $staff_id != '' && $check_group != '' ){ $attendances_q = $mysqli->query("SELECT * FROM staff_attendance WHERE staff_id = '".$staff_id."'AND created_at LIKE '".$check_group."%' AND deleted_at IS NULL ORDER BY created_at ASC") ; if ( $attendances_q->num_rows > 0 ){ $result = 'success' ; while ( $attendance = $attendances_q->fetch_assoc() ){ $data[] = [ 'id' => $attendance['attendance_id'], 'date' => date('Y-m-d', strtotime($attendance['created_at'])), 'time' => date('H:i:s', strtotime($attendance['created_at'])), 'remark' => dataFilter($attendance['remark']) ] ; } for ( $a = 0 ; $a < 8 ; $a++ ){ if ( !empty($data[$a]) ){ $last_date = $data[$a]['date'] ; }else{ $data[$a] = [ 'id' => 0, 'date' => $last_date, 'time' => '', 'remark' => '' ] ; } } }else{ $result = 'success' ; $last_inout = '' ; for ( $a = 0 ; $a < 8 ; $a++ ){ $data[$a] = [ 'id' => 0, 'date' => $check_group, 'time' => '', 'remark' => '' ] ; } } } echo json_encode([ 'result' => $result, 'data' => $data ]) ; exit ; break ; case 'list-limit' : $path = 'attendances/check' ; $platform = 'web' ; $lang = 'en' ; $branch_id = $row_branch['branch_id'] ; $staff_id = '' ; $token = '' ; $time = time() ; $sign = hash('sha256', $path.$platform.$lang.$branch_id.$staff_id.$token.$time.APIKEY) ; $call = call( 'curl', PATH.'api/'.$path.'.php', 'POST', [], [ 'input_type' => 'selfpunch', 'qrcode' => $staff_idno, 'latitude' => '', 'longitude' => '', 'platform' => $platform, 'lang' => $lang, 'branch_id' => $branch_id, 'staff_id' => $staff_id, 'token' => $token, 'time' => $time, 'sign' => $sign ] ) ; echo json_encode( $call ) ; exit ; break ; case 'selfpunch' : $status = '300' ; $message = 'Staff not found.' ; $alert = '' ; $data = [] ; $list = [] ; // staff_idno $staff_idno = escapeString( $_GET['staff_idno'] ) ; if ( $staff_idno != '' ){ $path = 'attendances/punch' ; $platform = 'web' ; $lang = 'en' ; $branch_id = $row_branch['branch_id'] ; $staff_id = '' ; $token = '' ; $time = time() ; $sign = hash('sha256', $path.$platform.$lang.$branch_id.$staff_id.$token.$time.APIKEY) ; $call = call( 'curl', PATH.'api/'.$path.'.php', 'POST', [], [ 'input_type' => 'selfpunch', 'qrcode' => $staff_idno, 'latitude' => '', 'longitude' => '', 'platform' => $platform, 'lang' => $lang, 'branch_id' => $branch_id, 'staff_id' => $staff_id, 'token' => $token, 'time' => $time, 'sign' => $sign ] ) ; $status = $call['status'] ; $message = $call['message'] ; if ( $call['status'] == '200' ){ $alert = 'Scan success ( '.$staff_idno.' ).' ; } } echo json_encode([ 'status' => $status, 'message' => $message, 'alert' => $alert ]) ; exit ; break ; case 'qrcode-check' : $status = '300' ; $message = 'Code not found.' ; $data = [] ; $new_code = '' ; $alert = '' ; $boolean = false ; $type = $_POST['type'] ; $qrcode = $_POST['qrcode'] ; // if code not found, generate one if ( $qrcode != '' ){ $get_code = $mysqli->query("SELECT staff_id, code, status, created_at FROM qrcodes WHERE type = '".$type."' AND code = '".$qrcode."' LIMIT 1") ; if ( $get_code->num_rows > 0 ){ $status = '220' ; $message = 'Code expired.' ; $get = $get_code->fetch_assoc() ; $date_code = $get['created_at'] ; $date_time = TODAYDATE ; $date_time = date('Y-m-d H:i:s', strtotime($date_time . ' -5 minutes')) ; if ( $date_code > $date_time ){ $status = '210' ; $message = 'Code used' ; // check code status if ( $get['status'] == '0' ){ $status = '201' ; // Code used before $message = 'Code can used back.' ; $generate = $get['code'] ; $boolean = true ; }elseif ( $get['status'] == '1' ){ // 1 mean scan success // get staff info if ( $get['staff_id'] > 0 ){ $get_staff = $mysqli->query("SELECT * FROM staff WHERE deleted_at IS NULL AND staff_id = '".$get['staff_id']."' LIMIT 1") ; if ( $get_staff->num_rows > 0 ){ $staff = $get_staff->fetch_assoc() ; $alert = 'Scan success ( '.$staff['staff_idno'].' )' ; } } }elseif ( $get['status'] == '2' ){ // 2 mean scan success, but scan too fast $alert = 'Accept rescan only after 15 minutes.' ; } } } } if ( !$boolean ){ $mysqli->query("INSERT INTO qrcodes (type, status, created_at, updated_at) VALUES ('checkin', '0', '".TODAYDATE."', '".TODAYDATE."')") ; // set new code $last_id = $mysqli->insert_id ; $new_code = 'PC|'.str_pad($last_id, 6, '0', STR_PAD_LEFT) ; $mysqli->query("UPDATE qrcodes SET code = '".$new_code."' WHERE qrcode_id = '".$last_id."'") ; $status = '200' ; $message = 'New code generated' ; } $generatecode = generateQrcode( '', $new_code, $new_code ) ; $new_code = $generatecode['url'] ; echo json_encode([ 'status' => $status, 'message' => $message, 'data' => [ 'alert' => $alert, 'code' => $generatecode['url'], ] ]) ; exit ; break ; case 'qrcode' : // check permission if ( !permissionCheck($row_user, 'attendance-list-qrcode') ){ header('Location: index.php') ; exit ; } // active page $active_main_menu = 'hr' ; $active_sub_menu = 'hr-attendance' ; $active_menu = 'hr-attendance-qrcode' ; // start header here include 'requires/page_header.php' ; include 'requires/page_top.php' ; ?>
 
$v ){ $search_department_url .= '&search_department%5B'.$k.'%5D='.$v; } } } if ( $search_name != '' ){ $search_query .= " AND ( b.staff_name LIKE '%".$search_name."%' )" ; } if ( $search_idno != '' ){ $search_query .= " AND ( b.staff_idno LIKE '%".$search_idno."%' )" ; } if ( $search_country != '' ){ if ( $search_country == 'local' ){ $search_query .= " AND b.country_id = '1'" ; }else{ $search_query .= " AND b.country_id != '1'" ; } } if ( $search_branch != '' ){ $search_query .= " AND b.branch_id = '".$search_branch."'" ; } if ( $date_to != '' || $date_from != '' ){ if ($date_from != '' && $date_to != ''){ $search_query .= " AND a.list_date BETWEEN '".$date_from."' and '".$date_to."'" ; }else if ( $date_from != '' ){ $search_query .= " AND a.list_date >= '".$date_from."'" ; }else{ $search_query .= " AND a.list_date <= '".$date_to."'" ; } } if ( $search_job_type_id != '' ){ $search_query .= " AND b.job_type_id = '".$search_job_type_id."'" ; } $mysqli_page = $mysqli->query("SELECT b.staff_id, b.staff_idno, b.staff_name, b.staff_salary, b.ot_rate_type, b.work_type_id FROM staff_attendance_list a LEFT JOIN staff b ON ( a.staff_id = b.staff_id ) ".$search_join." WHERE b.deleted_at IS NULL AND ( b.staff_date_resigned IS NULL OR b.staff_date_resigned = '0000-00-00' OR b.staff_date_resigned >= '".$date_time."' ) AND a.deleted_at IS NULL AND a.list_date LIKE '%".$date_time."%' ".$search_query.$user_branch_permission_sql_b." GROUP BY a.staff_id ORDER BY b.staff_idno") ; if ( $export == 'report-month' ){ include 'hr-attendance-export-by-month.php' ; } if ( $export == 'report-template1' ){ include 'hr-attendance-export-by-template1.php' ; } if ( $export == 'absence' ){ include 'hr-attendance-absence-report1.php' ; } // if ( $export == 'report-daily' ){ // include 'hr-attendance-export-by-daily.php' ; // } // active page $active_main_menu = 'hr' ; $active_sub_menu = 'hr-attendance' ; $active_menu = 'hr-attendance-report' ; // required component // get all job type $job_type = [] ; $get_job_type = $mysqli->query("SELECT * FROM master_job_type WHERE deleted_at IS NULL") ; if ( $get_job_type->num_rows > 0 ){ while ( $row_job_type = $get_job_type->fetch_assoc() ){ $job_type[$row_job_type['job_type_id']] = $row_job_type['job_type_desc'] ; } } // start header here include 'requires/page_header.php' ; include 'requires/page_top.php' ; ?>
search
" max=""/>
" max=""/>
listing
'.$date_time.'' ; if ( $date_time >= date('Y-m', time()) ){}else{ ?>
$vtypelist ){ $default_typelist[$ktypelist] = 0 ; ?> num_rows > 0 ){ $get_result = 'success' ; $new_attendance = array() ; $staff_ids = array() ; while ( $attendance = $mysqli_page->fetch_assoc() ){ $temp_attendance = [ 'staff_id' => $attendance['staff_id'], 'idno' => $attendance['staff_idno'], 'name' => $attendance['staff_name'], 'staff_salary' => $attendance['staff_salary'], 'ot_rate_type' => $attendance['ot_rate_type'], 'work_type_id' => $attendance['work_type_id'] ] ; $new_attendance[$attendance['staff_id']] = $temp_attendance ; $staff_ids[] = $attendance['staff_id'] ; } // get working day $list_workday = [] ; $select_attendancelist = $mysqli->query("SELECT staff_id, list_type_remark, COUNT( list_type_remark ) as count_list_type_remark, SUM( list_work_day ) as sum_list_work_day, SUM( list_leave_day ) as sum_list_leave_day FROM staff_attendance_list WHERE deleted_at IS NULL AND list_date LIKE '".$date_time."%' AND staff_id IN ( ".implode(',', $staff_ids)." ) GROUP BY staff_id, list_type_remark") ; if ( $select_attendancelist->num_rows > 0 ){ while ( $row_attendancelist = $select_attendancelist->fetch_assoc() ){ $list_workday[$row_attendancelist['staff_id']][$row_attendancelist['list_type_remark']] = $row_attendancelist ; } } $list_time_off = [] ; $select_attendancelist = $mysqli->query("SELECT staff_id, list_type_remark, list_time_off, list_time_off2 FROM staff_attendance_list WHERE deleted_at IS NULL AND list_date LIKE '".$date_time."%' AND staff_id IN ( ".implode(',', $staff_ids)." ) AND ( list_time_off != '00:00:00' OR list_time_off2 != '00:00:00' )") ; if ( $select_attendancelist->num_rows > 0 ){ while ( $row_attendancelist = $select_attendancelist->fetch_assoc() ){ $get_sum_timeoff = $list_time_off[$row_attendancelist['staff_id']]['sum'] ; $check_sum_timeoff = ( $get_sum_timeoff != '' ? $get_sum_timeoff : '00:00:00' ) ; if ( $row_attendancelist['list_time_off'] != '00:00:00' ){ $list_time_off[$row_attendancelist['staff_id']]['count'] = ( $list_time_off[$row_attendancelist['staff_id']]['count'] + 1 ); $list_time_off[$row_attendancelist['staff_id']]['sum'] = addTime( $check_sum_timeoff, $row_attendancelist['list_time_off'] ) ; } if ( $row_attendancelist['list_time_off2'] != '00:00:00' ){ $list_time_off[$row_attendancelist['staff_id']]['count'] = ( $list_time_off[$row_attendancelist['staff_id']]['count'] + 1 ); $list_time_off[$row_attendancelist['staff_id']]['sum'] = addTime( $check_sum_timeoff, $row_attendancelist['list_time_off2'] ) ; } } } // get staff leave $list_leave = [] ; $select_leavelist = $mysqli->query("SELECT staff_id, leave_type, leave_record_days FROM staff_leave_year WHERE deleted_at IS NULL AND leave_year LIKE '".date( 'Y', strtotime( $date_time.'-01' ) )."%' AND staff_id IN ( ".implode(',', $staff_ids)." )") ; if ( $select_leavelist->num_rows > 0 ){ while ( $row_leavelist = $select_leavelist->fetch_assoc() ){ $list_leave[$row_leavelist['staff_id']][$row_leavelist['leave_type']] = $row_leavelist ; } } // get staff given leave $list_leave_given = [] ; $select_leavegivenlist = $mysqli->query("SELECT staff_id, SUM(given_day) as total_given_day FROM staff_leave_month WHERE deleted_at IS NULL AND given_date BETWEEN '".$year_of_day."' AND '".$month_of_day."' AND staff_id IN ( ".implode(',', $staff_ids)." ) GROUP BY staff_id ") ; if ( $select_leavegivenlist->num_rows > 0 ){ while ( $row_leavegivenlist = $select_leavegivenlist->fetch_assoc() ){ $list_leave_given[$row_leavegivenlist['staff_id']] = $row_leavegivenlist['total_given_day'] ; } } // get staff total use leave $list_leave_used = [] ; $select_leave_usedlist = $mysqli->query("SELECT staff_id, list_type_remark, SUM( list_leave_day ) as sum_list_leave_day FROM staff_attendance_list WHERE deleted_at IS NULL AND list_date BETWEEN '".$year_of_day."' AND '".$month_of_last."' AND list_type_remark IN ( 'AL', 'MC' ) AND staff_id IN ( ".implode(',', $staff_ids)." ) GROUP BY staff_id, list_type_remark") ; if ( $select_leave_usedlist->num_rows > 0 ){ while ( $row_leave_usedlist = $select_leave_usedlist->fetch_assoc() ){ $list_leave_used[$row_leave_usedlist['staff_id']][$row_leave_usedlist['list_type_remark']] = $row_leave_usedlist['sum_list_leave_day'] ; } } // get late $list_late = [] ; $select_latelist = $mysqli->query("SELECT staff_id, count( list_late ) as count_list_late, SEC_TO_TIME(SUM(TIME_TO_SEC(TIME_FORMAT(list_late, '%H:%i')))) as sum_list_late FROM staff_attendance_list WHERE deleted_at IS NULL AND list_date LIKE '".$date_time."%' AND staff_id IN ( ".implode(',', $staff_ids)." ) AND list_late != '00:00:00' GROUP BY staff_id") ; if ( $select_latelist->num_rows > 0 ){ while ( $row_late = $select_latelist->fetch_assoc() ){ $list_late[$row_late['staff_id']] = [ 'count' => $row_late['count_list_late'], 'sum' => $row_late['sum_list_late'] ] ; } } // get early out $list_earlyout = [] ; $select_earlyoutlist = $mysqli->query("SELECT staff_id, count( list_early_out ) as count_list_early_out, SEC_TO_TIME(SUM(TIME_TO_SEC(TIME_FORMAT(list_early_out, '%H:%i')))) as sum_list_early_out FROM staff_attendance_list WHERE deleted_at IS NULL AND list_date LIKE '".$date_time."%' AND staff_id IN ( ".implode(',', $staff_ids)." ) AND list_early_out != '00:00:00' GROUP BY staff_id") ; if ( $select_earlyoutlist->num_rows > 0 ){ while ( $row_earlyoutlist = $select_earlyoutlist->fetch_assoc() ){ $list_earlyout[$row_earlyoutlist['staff_id']] = [ 'count' => $row_earlyoutlist['count_list_early_out'], 'sum' => $row_earlyoutlist['sum_list_early_out'] ] ; } } // get rest more $list_rest_more = [] ; $select_rest_morelist = $mysqli->query("SELECT staff_id, count( list_rest_more ) as count_list_rest_more, SEC_TO_TIME(SUM(TIME_TO_SEC(TIME_FORMAT(list_rest_more, '%H:%i')))) as sum_list_rest_more FROM staff_attendance_list WHERE deleted_at IS NULL AND list_date LIKE '".$date_time."%' AND staff_id IN ( ".implode(',', $staff_ids)." ) AND list_rest_more != '00:00:00' GROUP BY staff_id") ; if ( $select_rest_morelist->num_rows > 0 ){ while ( $row_rest_more = $select_rest_morelist->fetch_assoc() ){ $list_rest_more[$row_rest_more['staff_id']] = [ 'count' => $row_rest_more['count_list_rest_more'], 'sum' => $row_rest_more['sum_list_rest_more'] ] ; } } // get rest more 2 $list_rest_more2 = [] ; $select_rest_more2list = $mysqli->query("SELECT staff_id, count( list_rest_more2 ) as count_list_rest_more2, SEC_TO_TIME(SUM(TIME_TO_SEC(TIME_FORMAT(list_rest_more2, '%H:%i')))) as sum_list_rest_more2 FROM staff_attendance_list WHERE deleted_at IS NULL AND list_date LIKE '".$date_time."%' AND staff_id IN ( ".implode(',', $staff_ids)." ) AND list_rest_more2 != '00:00:00' GROUP BY staff_id") ; if ( $select_rest_more2list->num_rows > 0 ){ while ( $row_rest_more2 = $select_rest_more2list->fetch_assoc() ){ $list_rest_more2[$row_rest_more2['staff_id']] = [ 'count' => $row_rest_more2['count_list_rest_more2'], 'sum' => $row_rest_more2['sum_list_rest_more'] ] ; } } // get ot $list_ot = [] ; $select_otlist = $mysqli->query("SELECT staff_id, count( list_ot_normal ) as count_list_ot_normal, SEC_TO_TIME(SUM(TIME_TO_SEC(TIME_FORMAT(list_ot_normal, '%H:%i')))) as sum_list_ot_normal FROM staff_attendance_list WHERE deleted_at IS NULL AND list_date LIKE '".$date_time."%' AND staff_id IN ( ".implode(',', $staff_ids)." ) AND list_ot_normal != '00:00:00' GROUP BY staff_id") ; if ( $select_otlist->num_rows > 0 ){ while ( $row_otlist = $select_otlist->fetch_assoc() ){ $list_ot[$row_otlist['staff_id']] = [ 'count' => $row_otlist['count_list_ot_normal'], 'sum' => $row_otlist['sum_list_ot_normal'] ] ; } } // render table foreach ( $new_attendance as $key => $value ){ echo ' ' ; $array_tablelist = [] ; $total_workday = 0 ; $total_realwork = 0 ; $get_late = checkExists( $list_late[$value['staff_id']]['count'] ) ; $get_sum_late = checkExists( $list_late[$value['staff_id']]['sum'] ) ; $get_earlyout = checkExists( $list_earlyout[$value['staff_id']]['count'] ) ; $get_sum_earlyout = checkExists( $list_earlyout[$value['staff_id']]['sum'] ) ; $get_ot = checkExists( $list_ot[$value['staff_id']]['count'] ) ; $get_sum_ot = checkExists( $list_ot[$value['staff_id']]['sum'] ) ; $get_timeoff = checkExists( $list_time_off[$value['staff_id']]['count'] ) ; $get_sum_timeoff = checkExists( $list_time_off[$value['staff_id']]['sum'] ) ; $get_restmore = checkExists( $list_rest_more[$value['staff_id']]['count'] ) ; $get_sum_restmore = checkExists( $list_rest_more[$value['staff_id']]['sum'] ) ; $get_restmore2 = checkExists( $list_rest_more2[$value['staff_id']]['count'] ) ; $get_sum_restmore2 = checkExists( $list_rest_more2[$value['staff_id']]['sum'] ) ; $total_restmore_list = [] ; if ( $get_sum_restmore != '' ){ $total_restmore_list[] = $get_sum_restmore ; } if ( $get_sum_restmore2 != '' ){ $total_restmore_list[] = $get_sum_restmore2 ; } $total_restmore = 0 ; foreach ( $total_restmore_list as $krestmore => $vrestmore ){ $total_restmore += convertMinutes( $vrestmore ) ; } $get_leave = $list_leave[$value['staff_id']] ; $get_leave_annual = $get_leave['annual'] ; $get_leave_sick = $get_leave['sick'] ; $get_leave_used = $list_leave_used[$value['staff_id']] ; $get_leave_annual_used = $get_leave_used['AL'] ; $get_leave_sick_used = $get_leave_used['MC'] ; $get_leave_annual_given = $list_leave_given[$value['staff_id']] ; foreach ( $array_typelist as $ktypelist => $vtypelist ){ $get_workday = checkExists( $list_workday[$value['staff_id']][$ktypelist] ) ; $days = 0 ; $total_realwork += $get_workday['sum_list_work_day'] ; switch ( $ktypelist ){ case 'WD' : case 'PT' : case 'AL' : case 'MC' : case 'UL' : case 'AS' : $total_workday += $get_workday['count_list_type_remark'] ; break ; } switch ( $ktypelist ){ case 'WD' : case 'PT' : $days = $get_workday['sum_list_work_day'] ; break ; case 'AL' : case 'MC' : case 'UL' : $days = $get_workday['sum_list_leave_day'] ; break ; case 'AS' : case 'HL' : case 'OD' : $days = $get_workday['count_list_type_remark'] ; break ; } if ( $ktypelist != 'WD' && $ktypelist != 'PT' && $ktypelist != 'HL' && $ktypelist != 'OD' ){ $temp_typelist = '' ; $days = ( $days + 0 ) ; switch ( $ktypelist ){ case 'AL' : $temp_typelist = '' ; break ; case 'MC' : $temp_typelist = '' ; break ; case 'UL' : $temp_typelist = '' ; break ; default : $temp_typelist = '' ; } $array_tablelist[] = $temp_typelist ; } } echo '' ; echo implode( '', $array_tablelist ) ; echo '' ; echo '' ; echo '' ; echo '' ; echo ' ' ; } } ?>
ID Late Early Out Over Rest OT
'.$value['idno'].' '.ucwords($value['name']).'' ; if ( $get_leave_annual['leave_record_days'] > 0 ){ $temp_typelist .= ( $days > 0 ? ''.$days.'' : '-' ) .' / '.( $get_leave_annual_given - $get_leave_annual_used + 0 ) .' / '.( $get_leave_annual['leave_record_days'] + 0 ) . ' ( '.( $get_leave_annual_given + 0 ).' )' ; } $temp_typelist .= ''. ( $days > 0 ? ''.$days.'' : '-' ) .' / '.( $get_leave_sick['leave_record_days'] - $get_leave_sick_used + 0 ) .' / '.( $get_leave_sick['leave_record_days'] + 0 ).''. ( $days > 0 ? ''.$days.'' : '' ) .''. ( $days > 0 ? $days : 0 ) .'' . $total_realwork . ' / ' . $total_workday . ''.( $get_late > 0 ? $get_late . ' ( ' . $get_sum_late . ' )' : '' ).''.( $get_earlyout > 0 ? $get_earlyout . ' ( ' . $get_sum_earlyout . ' )' : '' ).''.( $total_restmore > 0 ? convertToTimes( $total_restmore ) : '' ).''.( $get_ot > 0 ? $get_ot . ' ( ' . $get_sum_ot . ' )' : '' ).'
query("SELECT * FROM staff_attendance_list a WHERE a.staff_id = '".$staff_id."' AND a.list_date LIKE '%".$date_time."%' AND a.deleted_at IS NULL ORDER BY a.list_date ASC") ; // get staff information $staff = $mysqli->query("SELECT staff_idno, staff_name FROM staff WHERE staff_id = '".$staff_id."' LIMIT 1") ; $staff_name = '' ; $staff_idno = '' ; if ( $staff->num_rows > 0 ){ $row_staff = $staff->fetch_assoc() ; $staff_name = $row_staff['staff_name'] ; $staff_idno = $row_staff['staff_idno'] ; } // get all attendance time $attendances = $mysqli->query("SELECT list_id, created_at FROM staff_attendance WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' AND check_group LIKE '%".$date_time."%' ORDER BY created_at ASC") ; $attendances_list = [] ; if ( $attendances->num_rows > 0 ){ while ( $row = $attendances->fetch_assoc() ){ $attendances_list[$row['list_id']][] = $row ; } } // active page $active_main_menu = 'hr' ; $active_sub_menu = 'hr-attendance' ; $active_menu = 'hr-attendance-report' ; // start header here include 'requires/page_header.php' ; include 'requires/page_top.php' ; ?>
ID :
:
num_rows > 0 ){ while ( $value = $mysqli_page->fetch_assoc() ){ $date = date('w', strtotime($value['list_date'])) ; $date = $date_array[$date] ; $attendances_date = $attendances_list[$value['list_id']] ; $bg_color = '' ; switch ( $value['list_type_remark'] ){ case 'WD' : $bg_color = '' ; break ; case 'AL' : $bg_color = '#ffccf0' ; break ; case 'UL' : $bg_color = '#fff6cc' ; break ; case 'MC' : $bg_color = '#ffd9cc' ; break ; case 'AS' : $bg_color = '#ffcccc' ; break ; case 'HL' : $bg_color = '#ccfffd' ; break ; case 'OD' : $bg_color = '#daccff' ; break ; case 'PT' : $bg_color = '#ffd5d1' ; break ; } if ( $value['list_work'] != '00:00:00' ){ $list_total_work[] = $value['list_work'] ; } echo ' ' ; for ( $a = 0 ; $a < 8 ; $a++ ){ $current_time = $attendances_date[$a]['created_at'] ; $current_time = ( $current_time != '' ? date('H:i:s', strtotime($current_time)) : '' ) ; echo ' ' ; } if ( EXCELDETAIL == "YES" ){ echo ' '; } echo ' ' ; } } ?>
Date Day Work day Work Day T Day Work Rest 1 Rest Timeout 1 Rest 2 Rest Timeout 2 Early Late Early Out OT Remark
'. $value['list_date'] .' '. $lang[$date] .' '.( $value['list_work_day'] > 0 ? ''.$value['list_work_day'].'' : $value['list_work_day'] ).'
'. $current_time .'
'. ( $value['list_work_day'] != '0.00' ? $value['list_work_day'] : '' ) .' '. ( $value['list_ot_day'] != '0.00' ? $value['list_ot_day'] : '' ) .''. ( $value['list_work'] != '00:00:00' ? $value['list_work'] : '' ) .' '. ( $value['list_rest'] != '00:00:00' ? $value['list_rest'] : '' ) .' '. ( $value['list_time_off'] != '00:00:00' ? '( '.$value['list_time_off'].' )' : '' ) .' '. ( $value['list_rest_more'] != '00:00:00' ? $value['list_rest_more'] : '' ) .' '. ( $value['list_rest2'] != '00:00:00' ? $value['list_rest2'] : '' ) .' '. ( $value['list_time_off2'] != '00:00:00' ? '( '.$value['list_time_off2'].' )' : '' ) .' '. ( $value['list_rest_more2'] != '00:00:00' ? $value['list_rest_more2'] : '' ) .' '. ( $value['list_early'] != '00:00:00' ? $value['list_early'] : '' ) .' '. ( $value['list_late'] != '00:00:00' ? $value['list_late'] : '' ) .' '. ( $value['list_early_out'] != '00:00:00' ? $value['list_early_out'] : '' ) .' '. ( $value['list_ot_normal'] != '00:00:00' ? $value['list_ot_normal'] : '' ) .' '. $value['list_remark'] .'
Total  
$value) { if ( $value != '' ){ $required_reprocess[$key] = $value ; } } if(arrayCheck($required_reprocess)){ foreach ($required_reprocess as $key => $value) { $u_saw = "UPDATE staff_attendance_working SET deleted_at = '".TODAYDATE."' WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' AND working_date = '".$key."' " ; $mysqli->query($u_saw) ; // get staff working hours $working_q2 = $mysqli->query("SELECT group_id, working_on, working_next_day, working_if_flexi, working_if_include_rest, working_if_ot, working_direct_day, working_if_fixed_work, working_day_calculation, working_morning_start as working_period_from, working_morning_end as working_period_to, working_period_before, working_break_start as working_from, working_break_end as working_to, working_total_hours, working_total_rest_hours, working_rest_range_from, working_rest_range_to, working_rounding_ot, working_if_ot_morning, working_if_offduty, working_count_offduty, working_if_deduct_offduty, working_max_ot,working_total_rest_hours2,working_rest_range_from2,working_rest_range_to2 FROM setting_working WHERE deleted_at IS NULL AND group_id = '".$value."' AND working_day = '".date('N', strtotime($key))."' LIMIT 1") ; // check if working setting got set if ( $working_q2->num_rows > 0 ){ $working = $working_q2->fetch_assoc() ; $mysqli->query("INSERT INTO staff_attendance_working (staff_id, working_group_id, working_date, working_on, working_next_day, working_if_flexi, working_if_include_rest, working_if_ot, working_direct_day, working_if_fixed_work, working_day_calculation, working_period_from, working_period_to, working_period_before, working_from, working_to, working_total_hours, working_total_rest_hours, working_rest_range_from, working_rest_range_to, working_rounding_ot, working_if_ot_morning, working_if_offduty, working_count_offduty, working_if_deduct_offduty, working_max_ot, created_at, updated_at, working_total_rest_hours2, working_rest_range_from2, working_rest_range_to2) VALUES ('".$staff_id."', '".$working['group_id']."', '".$key."', '".$working['working_on']."', '".$working['working_next_day']."', '".$working['working_if_flexi']."', '".$working['working_if_include_rest']."', '".$working['working_if_ot']."', '".$working['working_direct_day']."', '".$working['working_if_fixed_work']."', '".$working['working_day_calculation']."', '".$working['working_period_from']."', '".$working['working_period_to']."', '".$working['working_period_before']."', '".$working['working_from']."', '".$working['working_to']."', '".$working['working_total_hours']."', '".$working['working_total_rest_hours']."', ".( $working['working_rest_range_from'] != '' ? "'".$working['working_rest_range_from']."'" : "NULL" ).", ".( $working['working_rest_range_to'] != '' ? "'".$working['working_rest_range_to']."'" : "NULL" ).", '".$working['working_rounding_ot']."', '".$working['working_if_ot_morning']."', '".$working['working_if_offduty']."', '".$working['working_count_offduty']."', '".$working['working_if_deduct_offduty']."', '".$working['working_max_ot']."', '".TODAYDATE."', '".TODAYDATE."','".$working['working_total_rest_hours2']."','".$working['working_rest_range_from2']."','".$working['working_rest_range_to2']."')") ; } } } } header('Location: hr-attendance.php?page_mode=reprocessing-list&date_time='.$date_time.'&staff_id='.$staff_id.'&a=1') ; exit ; } $mysqli_page = $mysqli->query("SELECT * FROM staff_attendance_list a WHERE a.staff_id = '".$staff_id."' AND a.list_date LIKE '%".$date_time."%' AND a.deleted_at IS NULL ORDER BY a.list_date ASC") ; // get staff information $staff = $mysqli->query("SELECT staff_idno, staff_name FROM staff WHERE staff_id = '".$staff_id."' LIMIT 1") ; $staff_name = '' ; $staff_idno = '' ; if ( $staff->num_rows > 0 ){ $row_staff = $staff->fetch_assoc() ; $staff_name = $row_staff['staff_name'] ; $staff_idno = $row_staff['staff_idno'] ; } // get all attendance time $attendances = $mysqli->query("SELECT staff_id, list_id, created_at FROM staff_attendance WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' AND check_group LIKE '%".$date_time."%' ORDER BY created_at ASC") ; $attendances_list = [] ; if ( $attendances->num_rows > 0 ){ while ( $row = $attendances->fetch_assoc() ){ $attendances_list[$row['list_id']][] = $row ; } } // active page $active_main_menu = 'hr' ; $active_sub_menu = 'hr-attendance' ; $active_menu = 'hr-attendance-list' ; // start header here include 'requires/page_header.php' ; include 'requires/page_top.php' ; ?>
'.$_SESSION['system_result'].'
' ; }else{ echo '
'.$_SESSION['system_result'].'
' ; } unset($_SESSION['system_result']) ; } ?>
ID :
:
query($mysqli_work); if ($mwk->num_rows > 0){ while ($rmwk = $mwk->fetch_array(MYSQLI_ASSOC)){ $arr_work[] = $rmwk; } } $attendances = [] ; if ( $mysqli_page->num_rows > 0 ){ while ( $value = $mysqli_page->fetch_assoc() ){ $attendances[$value['list_date']] = $value ; } } for ( $loop = 1 ; $loop <= $last_day ; $loop++ ){ $select_date = $date_time.'-'.strPad(2, $loop) ; $select_day_w = date('w', strtotime($select_date)) ; $select_day_w = $date_array[$select_day_w] ; $value = $attendances[$select_date] ; $attendances_date = $attendances_list[$value['list_id']] ; echo ' ' ; } ?>
'. $select_date .' '. $lang[$select_day_w] .' ' ; for ( $a = 0 ; $a < 8 ; $a++ ){ $current_time = $attendances_date[$a]['created_at'] ; $current_time = ( $current_time != '' ? date('H:i:s', strtotime($current_time)) : '' ) ; echo '
'. $current_time .'
' ; } echo '