first commit

This commit is contained in:
LAPTOP-V9RRD1TL\Michelle's Computer
2025-07-21 21:38:17 +08:00
commit f8f8fcaf96
2529 changed files with 227800 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND documentation_subject LIKE '%".$array['search']."%'" ;
}
$query = "SELECT documentation_id, documentation_format, documentation_subject, documentation_message, documentation_video, documentation_file_type, documentation_file, created_at FROM documentation
WHERE deleted_at IS NULL AND staff_id LIKE '%(".$staff_info['staff_id'].")%' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '1' ;
$message = 'Success.' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['documentation_message'] = html_entity_decode( stripslashes( $row['documentation_message'] ) ) ;
$list[] = $row ;
}
$data = [
'list' => [
"current_page" => $current,
"data" => $list,
"from" => '',
"last_page" => $pagination['last_page'],
"next_page_url" => '',
"path" => '',
"per_page" => $limit,
"prev_page_url" => '',
"to" => '',
"total" => $pagination['total']
],
'file_path' => PATH.'uploads/Documentation/'
] ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+71
View File
@@ -0,0 +1,71 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
$today = TODAYDAY ;
$today_month = date( 'Y-m', strtotime( TODAYDATE ) ) ;
$last_day = date( 'j', strtotime( TODAYDATE ) ) ;
$attendances_q = $mysqli->query("SELECT * FROM staff_attendance
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' AND created_at LIKE '".$today_month."%' ORDER BY created_at ASC") ;
$list = [] ;
if ( $attendances_q->num_rows > 0 ){
while ( $attendance = $attendances_q->fetch_assoc() ){
$created_at = $attendance['created_at'] ;
$created_date = date('Y-m-d', strtotime($created_at)) ;
$list[$created_date][] = date('H:i', strtotime($attendance['created_at'])) ;
}
}
$all = [] ;
for ( $a = $last_day ; $a >= 1 ; $a-- ){
$lead = $today_month.'-'.str_pad( $a, '2', '0', STR_PAD_LEFT ) ;
$temp = [] ;
for ( $b = 1 ; $b <= 6 ; $b++ ){
$temp[] = '' ;
}
if ( !empty($list[$lead]) ){
$count = 0 ;
foreach ( $list[$lead] as $k => $v ){
if ( $count < 6 ){
$temp[$count] = $v ;
}
$count++ ;
}
}
// get attendance list
$attendance_list_q = $mysqli->query("SELECT list_work_day, list_type_remark FROM staff_attendance_list
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' AND list_date = '".$lead."' LIMIT 1") ;
$work_day = '0' ;
$work_type = '' ;
if ( $attendance_list_q->num_rows > 0 ){
$attendance_list = $attendance_list_q->fetch_assoc() ;
$work_day = $attendance_list['list_work_day'] ;
$work_type = $attendance_list['list_type_remark'] ;
}
$all[] = [
'date' => $lead,
'date_name' => date('d M Y', strtotime($lead)),
'work_day' => $work_day,
'type' => $work_type,
'time' => $temp
] ;
}
$data = [
'attendance' => $all
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+454
View File
@@ -0,0 +1,454 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
// if ( $boolean_login ){
$status = '300' ;
$branch_name = '' ;
// Hr = All staff without branch
// HrBranch = All staff with branch
// HrManual = For M&R only
$is_show = 'no' ;
$is_filterbranch = 'no' ;
$services = $mysqli->query( "SELECT a.module FROM app_service a
WHERE a.deleted_at IS NULL AND a.type = 'service' AND a.module IN ( 'Hr', 'HrBranch', 'HrManual' ) AND on_off = 'on'
LIMIT 2" ) ;
if ( $services->num_rows > 0 ){
while ( $row_service = $services->fetch_assoc() ){
if ( $row_service['module'] == 'Hr' ){
$is_show = 'yes' ;
}
if ( $row_service['module'] == 'HrBranch' ){
$is_show = 'yes' ;
$is_filterbranch = 'yes' ;
}
if ( $row_service['module'] == 'HrManual' ){
$is_show = 'manual' ;
$is_filterbranch = 'yes' ;
}
}
}
if ( $array['module'] == 'branch' ){
$is_show = 'yes' ;
$is_filterbranch = 'yes' ;
if ( $array['branch_id'] != '' ){
$get_branch = $mysqli->query("SELECT branch_name FROM branch
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' LIMIT 1") ;
if ( $get_branch->num_rows > 0 ){
$branch = $get_branch->fetch_assoc() ;
$branch_name = $branch['branch_name'] ;
}
}
}
$list = [] ;
$total_staffs = 0 ;
$present = 0 ;
$late = 0 ;
$rest_late = 0 ;
$absent = 0 ;
$merit = 0 ;
$passionate = 0 ;
$in_off = 0 ;
$in_mc = 0 ;
$in_leave = 0 ;
$in_off_working = 0 ;
$error = 0 ;
$present_list = [] ;
$late_list = [] ;
$rest_late_list = [] ;
$absent_list = [] ;
$off_list = [] ;
$mc_list = [] ;
$leave_list = [] ;
$off_working_list = [] ;
$merit_list = [] ;
$passionate_list = [] ;
$yesterday_day = date('N', strtotime('-1 days')) ;
$today_day = date('N', time()) ;
$date_yesterday = date('Y-m-d', strtotime('-1 days')) ;
$date_today = date('Y-m-d', time()) ;
$date_next = date('Y-m-d', strtotime('+1 days')) ;
if ( $is_show == 'yes' ){
// filter department
$check_department = false;
if( $department_id > 0 ){
$check_department = true ;
$search_query1 .= " AND a.department_id = '".$department_id."'" ;
}
// loop all group
$working_q = $mysqli->query("SELECT group_id, working_day, working_next_day, working_on, working_morning_start as working_period_from, working_morning_end as working_period_to, working_break_start as working_from, working_break_end as working_to, working_break_end_include_ot as working_to_include_ot, working_max_ot, working_period_before, working_total_rest_hours FROM setting_working
WHERE deleted_at IS NULL AND group_id > '0' AND ( working_day = '".$yesterday_day."' OR working_day = '".$today_day."' )") ;
$row_working = [] ;
if ( $working_q->num_rows > 0 ){
while ( $working = $working_q->fetch_assoc() ){
$row_working[$working['group_id']][$working['working_day']] = $working ;
}
}
// get all last checkin attendace
$attendance_q = $mysqli->query( "SELECT staff_id, MAX(created_at) AS created_at FROM staff_attendance
WHERE deleted_at IS NULL
GROUP BY staff_id" ) ;
$row_attendance = [] ;
if ( $attendance_q->num_rows > 0 ){
while ( $attendance = $attendance_q->fetch_assoc() ){
$row_attendance[$attendance['staff_id']] = $attendance['created_at'] ;
}
}
// get all last 4 checkin attendace
$attendance_2days_q = $mysqli->query( "SELECT staff_id, created_at FROM staff_attendance
WHERE deleted_at IS NULL AND list_id = '0' AND '".date( 'Y-m-d', time() )." 23:59:59'" ) ;
$row_attendance_2days = [] ;
if ( $attendance_2days_q->num_rows > 0 ){
while ( $attendance_2days = $attendance_2days_q->fetch_assoc() ){
$row_attendance_2days[$attendance_2days['staff_id']][] = $attendance_2days['created_at'] ;
}
}
// get all mc / unpaid / annual today
$leave_q = $mysqli->query("SELECT staff_id, leave_type FROM staff_leave_date
WHERE deleted_at IS NULL AND leave_type_mode = 'working' AND leave_date = '".$date_today."'") ;
$row_leave = [] ;
if ( $leave_q->num_rows > 0 ){
while ( $leave = $leave_q->fetch_assoc() ){
$row_leave[$leave['staff_id']] = $leave['leave_type'] ;
}
}
// get all staff
$staffs_q = $mysqli->query( "SELECT staff_id, staff_idno, staff_name, staff_image, group_id FROM staff
WHERE ( staff_date_resigned IS NULL || staff_date_resigned = '0000-00-00' || staff_date_resigned >= '".$date_today."' ) AND deleted_at IS NULL ".( $is_filterbranch == 'yes' ? " AND branch_id = '".$array['branch_id']."'" : '' )."
ORDER BY (staff_idno+0)" ) ;
if ( $staffs_q->num_rows > 0 ){
$status = '200' ;
$row_staff = [] ;
while ( $staff = $staffs_q->fetch_assoc() ){
if( $check_department ){
$mysqli_department = $mysqli->query( "SELECT a.department_id, b.department_desc FROM staff_department a
LEFT JOIN setting_department_translation b ON ( b.department_id = a.department_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.staff_id = '".$staff['staff_id']."'".$search_query1 ) ;
$count = 0 ;
$department_name = '' ;
if( $mysqli_department->num_rows > 0 ){
while( $row_department = $mysqli_department->fetch_assoc() ){
$count++ ;
$break = '' ;
if( $count == 3 ){
$break = "\n" ;
$count = 0 ;
}
$department_name .= $row_department['department_desc'].', '.$break ;
}
$department_name = substr( $department_name, 0, -2 ) ;
if( $department_name != '' ){
$row_staff[] = $staff ;
}
}
}else{
$row_staff[] = $staff ;
}
}
foreach ( $row_staff as $staff ){
$total_staffs++ ;
$this_working = $row_working[$staff['group_id']] ;
$this_type = '' ;
$attendance = '' ;
$last_late = '' ;
if ( arrayCheck( $this_working ) ){
// get staff attendance
$attendance = $row_attendance[$staff['staff_id']] ;
$attendance_all = $row_attendance_2days[$staff['staff_id']] ;
$attendance_first = ( isset($attendance_all[0]) ? $attendance_all[0] : '' ) ;
// check if mc / unpaid / annual leave today
$get_leave = $row_leave[$staff['staff_id']] ;
if ( $get_leave != '' ){
if ( $get_leave == 'sick' ){
$in_mc++ ;
$this_type = 'mc' ;
}
if ( $get_leave == 'unpaid' ){
$in_leave++ ;
$this_type = 'leave' ;
}
if ( $get_leave == 'annual' ){
$in_leave++ ;
$this_type = 'leave' ;
}
}else{
// check today day working
$working = $this_working[$today_day] ;
$check_current_datetime = $date_today.' '.$working['working_period_from'] ;
$check_next_datetime = $date_next.' '.$working['working_period_to'] ;
$working_from = $date_today.' '.$working['working_from'] ;
if ( $working['working_period_before'] > 0 ){
$working_from = $date_today.' '.addTime( $working['working_from'], convertToTimes($working['working_period_before']) ) ;
}
$working_to = $date_today.' '.$working['working_to'] ;
$working_to_include_ot = $date_today.' '.$working['working_to_include_ot'] ;
$working_max_ot = $working['working_max_ot'] ;
if ( $working_from > $working_to ){
$working_to = $date_next.' '.$working['working_to'] ;
}
if ( $working['working_to_include_ot'] != '' && $working['working_to_include_ot'] != '00:00:00' ){
$working_to = $date_next.' '.$working['working_to_include_ot'] ;
}
if ( $working_max_ot != '' && $working_max_ot != '00:00:00' ){
$convertMinutes = convertMinutes($working_max_ot) ;
$working_to = date("Y-m-d H:i:s", strtotime($working_to . ' + '.$convertMinutes.' minutes')) ;
}
// check if allow to insert attendances
if ( TODAYDATE >= $check_current_datetime ){
// this guys is working within this day
}else{
if ( $attendance >= $working_to ){
// this guys is working within this day
}else{
if ( date('Y-m-d', strtotime($attendance)) == $yesterday_day ){
// check yesterday day working
$working = $this_working[$yesterday_day] ;
$check_current_datetime = $date_yesterday.' '.$working['working_period_from'] ;
$check_next_datetime = $date_today.' '.$working['working_period_to'] ;
$working_from = $date_yesterday.' '.$working['working_from'] ;
$working_to = $date_yesterday.' '.$working['working_to'] ;
$working_max_ot = $working['working_max_ot'] ;
if ( $working_from > $working_to ){
$working_to = $date_today.' '.$working['working_to'] ;
}
if ( $working['working_to_include_ot'] != '' && $working['working_to_include_ot'] != '00:00:00' ){
$working_to = $date_today.' '.$working['working_to_include_ot'] ;
}
}
}
}
$working_to_10 = date("Y-m-d H:i:s", strtotime($working_to . ' + 10 hours')) ;
if ( $working['working_if_flexi'] == 'yes' ){
$working_from = $check_current_datetime ;
$working_to = $check_next_datetime ;
}
if ( $working["working_on"] == "yes" ){
// check if within working period
if ( TODAYDATE >= $check_current_datetime && TODAYDATE <= $working_to ){
if ( $attendance_first >= $check_current_datetime && $attendance_first <= $working_to ){
if ( $attendance_first >= $working_from ){
$late++ ;
$this_type = 'late' ;
$last_late = subtractTime( $attendance_first, $working_from ) ;
}else{
$present++ ;
$this_type = 'working' ;
if ( count( $attendance_all ) == 2 || count( $attendance_all ) == 3 ){
$rest_out = $attendance_all[1] ;
$rest_in = ( count( $attendance_all ) == 3 ? $attendance_all[2] : TODAYDATE ) ;
$total_rest = subtractTime( $rest_in, $rest_out ) ;
if ( $total_rest > $working['working_total_rest_hours'] ){
$rest_late++ ;
$this_type = 'rest_late' ;
$last_late = subtractTime( $rest_in, $rest_out ) ;
}
$attendance_first = $attendance ;
}
}
}else{
if ( TODAYDATE >= $working_from ){
$absent++ ;
$this_type = 'absent' ;
$attendance_first = $attendance ;
}
}
}else{
// check absent
if ( $attendance >= $check_current_datetime && $attendance <= $check_next_datetime ){
// check error
if ( $attendance >= $check_current_datetime && $attendance <= $working_to_10 ){
// do nothing
}else{
$error++ ;
$this_type = 'error' ;
}
}else{
if ( TODAYDATE >= $check_current_datetime && TODAYDATE <= $check_next_datetime ){
$absent++ ;
$this_type = 'absent' ;
$attendance_first = $attendance ;
}
}
}
}else{
if ( $attendance >= $working_from && $attendance <= $check_next_datetime ){
$in_off_working++ ;
$this_type = 'off_working' ;
}else{
$in_off++ ;
$this_type = 'off' ;
}
}
}
$temp = [
'staff_id' => $staff['staff_id'],
'staff_image' => PATH . ( $staff['staff_image'] != '' ? 'uploads/Staff/'.$staff['staff_image'] : 'images/NoProduct.jpg' ),
'staff_idno' => $staff['staff_idno'],
'staff_name' => $staff['staff_name'],
'last_late' => ( $last_late != '' ? date( 'H:i', strtotime($last_late) ) : '' ),
'last_attendance' => ( $attendance_first != '' ? $attendance_first : '-' )
] ;
switch ( $this_type ){
case 'working' : $present_list[] = $temp ; break ;
case 'late' : $late_list[] = $temp ; break ;
case 'rest_late' : $rest_late_list[] = $temp ; break ;
case 'absent' : $absent_list[] = $temp ; break ;
case 'off' : $off_list[] = $temp ; break ;
case 'off_working' : $off_working_list[] = $temp ; break ;
case 'mc' : $mc_list[] = $temp ; break ;
case 'leave' : $leave_list[] = $temp ; break ;
case 'error' : $error_list[] = $temp ; break ;
}
}
}
}
}
if ( $is_show == 'manual' ){
$staffs = $mysqli->query( "SELECT a.type, a.times, b.staff_id, b.staff_image, b.staff_idno, b.staff_name FROM staff_attendance_summary a
LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
WHERE a.deleted_at IS NULL AND b.branch_id = '".$array['branch_id']."'" ) ;
if ( $staffs->num_rows > 0 ){
$status = '200' ;
while ( $staff = $staffs->fetch_assoc() ){
$temp = [
'staff_id' => $staff['staff_id'],
'staff_image' => PATH . ( $staff['staff_image'] != '' ? 'uploads/Staff/'.$staff['staff_image'] : 'images/NoProduct.jpg' ),
'staff_idno' => $staff['staff_idno'],
'staff_name' => $staff['staff_name'],
'last_attendance' => $staff['times']
] ;
if ( $staff['type'] == 'late' ){
$late++ ;
$late_list[] = $temp ;
}
if ( $staff['type'] == 'absent' ){
$absent++ ;
$absent_list[] = $temp ;
}
if ( $staff['type'] == 'merit' ){
$merit++ ;
$merit_list[] = $temp ;
}
if ( $staff['type'] == 'passionate' ){
$passionate++ ;
$passionate_list[] = $temp ;
}
}
}
}
$data = [
'staff' => $total_staffs,
'branch_name' => dataFilter( $branch_name ),
'present' => $present,
'present_list' => $present_list,
'late' => ( $late + $rest_late ),
'late_list' => array_merge( $late_list, $rest_late_list ),
'absent' => $absent,
'absent_list' => $absent_list,
'in_off' => $in_off,
'off_list' => $off_list,
'in_mc' => $in_mc,
'mc_list' => $mc_list,
'in_leave' => $in_leave,
'in_off_working' => $in_off_working,
'leave_list' => $leave_list,
'off_working_list' => $off_working_list,
'merit' => $merit,
'merit_list' => $merit_list,
'passionate' => $passionate,
'passionate_list' => $passionate_list
] ;
// }
require( $require_sub.'footer.php' ) ;
?>
+183
View File
@@ -0,0 +1,183 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_path.'plugins/geoPHP/geoPHP.inc' ) ;
require( $require_sub.'header.php' ) ;
$boolean_access = false ;
$input_type = $array['input_type'] ;
$qrcode = $array['qrcode'] ;
$latitude = $array['latitude'] ;
$longitude = $array['longitude'] ;
$mac_address = '' ;
$ip_address = '' ;
$staff_settings = [] ;
$staff_id = '' ;
$branch_id = '' ;
if ( $input_type == 'selfpunch' ){
$status = '290' ;
$select_qrcode = $mysqli->query( "SELECT staff_id, branch_id, staff_settings FROM staff
WHERE staff_idno = '".$qrcode."' AND ( staff_date_resigned IS NULL || staff_date_resigned = '0000-00-00' || staff_date_resigned >= '".TODAYDATE."' ) AND deleted_at IS NULL " ) ;
if ( $select_qrcode->num_rows > 0 ){
$boolean_access = true ;
$data_qrcode = $select_qrcode->fetch_assoc() ;
$staff_id = $data_qrcode['staff_id'] ;
$branch_id = $data_qrcode['branch_id'] ;
$staff_settings = $data_qrcode['staff_settings'] ;
}
}else{
if ( $boolean_login ){
$boolean_access = true ;
$staff_id = $staff_info['staff_id'] ;
$branch_id = $staff_info['branch_id'] ;
$staff_settings = $staff_info['staff_settings'] ;
}
}
if ( $boolean_access ){
$status = '300' ;
if ( ( $input_type == 'qrcode' && $qrcode != '' ) || $input_type == 'button' || $input_type == 'selfpunch' ){
$status = '272' ;
$first_string = substr( $qrcode, 0, 1 ) ;
$boolean_qr = false ;
if ( $input_type == 'button' || $input_type == 'selfpunch' ){
$boolean_qr = true ;
$date_code = TODAYDATE ;
$code_status = '0' ;
}else{
$check = $mysqli->query( "SELECT qrcode_id, status, created_at FROM qrcodes
WHERE deleted_at IS NULL AND type = 'checkin' AND code = '".$qrcode."' LIMIT 1" ) ;
if ( $check->num_rows > 0 ){
$get = $check->fetch_assoc() ;
$boolean_qr = true ;
$date_code = $get['created_at'] ;
$code_status = $get['status'] ;
}
}
if ( $boolean_qr ){
$status = '277' ;
$date_current = TODAYDATE ;
$date_time = date('Y-m-d H:i:s', strtotime($date_current . ' -5 minutes')) ;
$date_time_res = date('Y-m-d H:i:s', strtotime($date_current . ' -15 minutes')) ;
$date_group = date('Y-m-d', strtotime($date_current)) ;
// check if code not yet expired.
if ( $date_code > $date_time ){
$status = '276' ;
// check code status
if ( $code_status == '0' ){
$status = '275' ;
// check last check in out time
// get previous check in & out type
$last_attendance_q = $mysqli->query("SELECT type, check_group, created_at FROM staff_attendance
WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' ORDER BY created_at DESC LIMIT 1") ;
$boolean_last = false ;
$boolean_last_att = false ;
if ( $last_attendance_q->num_rows > 0 ){
$last_attendance = $last_attendance_q->fetch_assoc() ;
if ( $date_time_res > $last_attendance['created_at'] ){
$boolean_last = true ;
$boolean_last_att = true ;
}
}else{
$boolean_last = true ;
}
if ( $boolean_last ){
$status = '270' ;
$check_area = 'out' ;
if ( $latitude != '' && $longitude != '' ){
// get this staff branch
$get_branch = $mysqli->query("SELECT branch_geometry FROM branch
WHERE deleted_at IS NULL AND branch_id = '".$branch_id."' LIMIT 1") ;
if ( $get_branch->num_rows > 0 ){
$branch = $get_branch->fetch_assoc() ;
$branch_geometry = $branch['branch_geometry'] ;
if ( $branch_geometry != '' ){
$pointLatLng = geoPHP::load("POINT(".$longitude." ".$latitude.")","wkt") ;
$polygon = geoPHP::load($branch_geometry,'wkt') ;
$inpolygon = $polygon->pointInPolygon($pointLatLng) ;
if ( $inpolygon ){
$check_area = 'in' ;
}
}
}
}
if ( $check_area == 'in' || $staff_settings['without_geometry'] == 'yes' || $input_type == 'selfpunch' ){
// start commit
$error = 0 ;
$mysqli->autocommit( false ) ;
if ( $input_type == 'qrcode' ){
// update qrcode
if ( $mysqli->query("UPDATE qrcodes SET
staff_id = '".$staff_id."',
status = '1',
updated_at = '".TODAYDATE."'
WHERE qrcode_id = '".$get['qrcode_id']."'") ){ }else{
$error++ ;
}
}
$check_type = 'in' ;
if ( $boolean_last_att ){
// check if last attendance is in
if ( $last_attendance['type'] == 'in' ){
$date_group = $last_attendance['check_group'] ;
$check_type = 'out' ;
}
}
// insert new attendance record
if ( $mysqli->query("INSERT INTO staff_attendance
( staff_id, check_group, type, code, record_from, mac_address, ip_address, latitude, longitude, check_area, created_at, updated_at ) VALUES
( '".$staff_id."', '".$date_group."', '".$check_type."', '".$qrcode."', '".$input_type."', '".$mac_address."', '".$ip_address."', '".$latitude."', '".$longitude."', '".$check_area."', '".TODAYDATE."', '".TODAYDATE."' )") ){ }else{
$error++ ;
}
if ( $error == 0 ) {
$mysqli->commit() ;
$status = '200' ;
}else{
$mysqli->rollback() ;
$status = '304' ;
}
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_path.'extensions/sms.php' ) ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
if ( $array['password'] != '' ){
$status = '205' ;
$password = $staff_info['staff_id'].strPad( 6, rand(000000, 999999) ) ;
$enc_password = passwordEncrypt( $array['password'] ) ;
if ( $mysqli->query( "UPDATE staff SET
staff_password = '".$enc_password."'
WHERE staff_id = '".$staff_info['staff_id']."'" ) ){
$status = '208' ;
$mailer = new Mailer() ;
$mailer->from = EMAILNOREPLY ;
$mailer->to = [ $staff_info['staff_email'] ] ;
$mailer->subject = 'Change password' ;
$mailer->body = 'Your new password was success change to ' . $array['password'] ;
if ( $mailer->send() ){
$status = '200' ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+47
View File
@@ -0,0 +1,47 @@
<?php
$must_login = false ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_path.'extensions/sms.php' ) ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
$status = '300' ;
if ( $array['staff_idno'] != '' && $array['username'] != '' ){
$status = '290' ;
$mysqli_staff = $mysqli->query("SELECT staff_id, staff_idno, staff_username, staff_email, staff_mobileno FROM staff
WHERE deleted_at IS NULL AND ( staff_date_resigned IS NULL OR staff_date_resigned = '0000-00-00' ) AND staff_idno = '".$array['staff_idno']."' AND staff_username = '".$array['username']."' LIMIT 1") ;
if ( $mysqli_staff->num_rows > 0 ){
$status = '204' ;
$row_staff = $mysqli_staff->fetch_assoc() ;
$password = $row_staff['staff_id'].strPad( 6, rand(000000, 999999) ) ;
$enc_password = passwordEncrypt( $password ) ;
if ( $mysqli->query( "UPDATE staff SET
staff_password = '".$enc_password."'
WHERE staff_id = '".$row_staff['staff_id']."'" ) ){
$status = '208' ;
$mailer = new Mailer() ;
$mailer->from = EMAILNOREPLY ;
$mailer->to = [ $row_staff['staff_email'] ] ;
$mailer->subject = 'Reset password' ;
$mailer->body = 'Your temporary password is ' . $password ;
if ( $mailer->send() ){
$status = '200' ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+74
View File
@@ -0,0 +1,74 @@
<?php
$must_login = false ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
$username = $array['username'] ;
$password = $array['password'] ;
$token = $array['token'] ;
$status = '300' ;
if ( $username != '' && $password != '' ){
$status = '284' ;
$password = passwordEncrypt( $password ) ;
$mysqli_staff = $mysqli->query("SELECT staff_id, staff_idno, staff_name, staff_shortname, staff_username, staff_email, staff_mobileno, staff_image, job_position_id, job_section_id, branch_id, staff_point_achievement, staff_point, staff_wallet, staff_tier, staff_achievement, staff_star, staff_settings, country_id FROM staff
WHERE deleted_at IS NULL AND ( staff_date_resigned IS NULL OR staff_date_resigned = '0000-00-00' || staff_date_resigned >= '".TODAYDATE."' ) AND staff_username = '".$username."' AND staff_password = '".$password."' LIMIT 1") ;
if ( $mysqli_staff->num_rows > 0 ){
$status = '200' ;
$row_staff = $mysqli_staff->fetch_array(MYSQLI_ASSOC) ;
$code = time().strPad( 6, rand(000000, 999999) ) ;
$tokencode = $row_staff['staff_id'] . '_' . $code . md5($code) ;
$mysqli->query( "INSERT INTO staff_token
( staff_id, platform, token ) VALUES
( '".$row_staff['staff_id']."', '".$array['platform']."', '".$tokencode."' )" ) ;
if ( $array['notification'] != '' ){
$select_notification = $mysqli->query( "SELECT * FROM staff_notification
WHERE notification = '".$array['notification']."' LIMIT 1" ) ;
if ( $select_notification->num_rows == 0 ){
$mysqli->query( "INSERT INTO staff_notification
( notification, staff_id ) VALUES
( '".$array['notification']."', '".$row_staff['staff_id']."' )" ) ;
}else{
$mysqli->query( "UPDATE staff_notification SET
staff_id = '".$row_staff['staff_id']."'
WHERE notification = '".$array['notification']."'" ) ;
}
}
$row_staff['staff_image'] = ( $row_staff['staff_image'] != '' ? PATH.'uploads/Staff/'.dataFilter($row_staff['staff_image']) : '' ) ;
$row_staff['token'] = $tokencode ;
$row_staff['staff_settings'] = ( $row_staff['staff_settings'] != '' ? json_decode($row_staff['staff_settings'], true) : [] ) ;
$get_tier = getTier( $row_staff['staff_tier'], $array['lang'] ) ;
$row_staff['staff_tier_level'] = $get_tier['level'] ;
$row_staff['staff_tier_title'] = $get_tier['title'] ;
$row_staff['staff_tier_is_task'] = $get_tier['is_task'] ;
$row_staff['staff_tier_is_task_assigned'] = $get_tier['is_task_assigned'] ;
$row_staff['staff_tier_is_task_incentive'] = $get_tier['is_task_incentive'] ;
$row_staff['staff_tier_is_task_incentive2'] = $get_tier['is_task_incentive2'] ;
$row_staff['staff_tier_is_task_extra'] = $get_tier['is_task_extra'] ;
$row_staff['staff_tier_is_adjustment'] = $get_tier['is_adjustment'] ;
$row_staff['staff_star'] = ( $row_staff['staff_star'] + 0 ) ;
$data = $row_staff ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
$must_login = false ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
$username = $array['username'] ;
$name = $array['name'] ;
$mobile = $array['mobile'] ;
$email = $array['email'] ;
$password = $array['password'] ;
$token = $array['token'] ;
$status = '300' ;
if ( $username != '' && $name != '' && $mobile != '' && $email != '' && $password != '' ){
$status = '289' ;
$mysqli_staff = $mysqli->query( "SELECT staff_id, staff_idno, staff_name, staff_shortname, staff_username, staff_email, staff_mobileno, staff_image, job_position_id, job_section_id, staff_point_achievement, staff_point, staff_wallet, staff_tier, staff_achievement, staff_star FROM staff
WHERE deleted_at IS NULL AND staff_username = '".$username."' LIMIT 1" ) ;
if ( $mysqli_staff->num_rows == 0 ){
$status = '200' ;
$password = passwordEncrypt( $password ) ;
$mysqli->query( "INSERT INTO staff
( staff_name, staff_username, staff_email, staff_mobileno, staff_password, staff_date_resigned, staff_run_away ) VALUES
( '".$name."', '".$username."', '".$email."', '".$mobile."', '".$password."', '".TODAYDAY."', 'yes' )" ) ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_path.'extensions/sms.php' ) ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
if ( $array['password'] != '' ){
$status = '205' ;
$password = $staff_info['staff_id'].strPad( 6, rand(000000, 999999) ) ;
$enc_password = passwordEncrypt( $array['password'] ) ;
if ( $mysqli->query( "UPDATE staff SET
staff_password = '".$enc_password."'
WHERE staff_id = '".$staff_info['staff_id']."'" ) ){
$status = '208' ;
$mailer = new Mailer() ;
$mailer->from = EMAILNOREPLY ;
$mailer->to = [ $staff_info['staff_email'] ] ;
$mailer->subject = 'Change password' ;
$mailer->body = 'Your new password was success change to ' . $array['password'] ;
if ( $mailer->send() ){
$status = '200' ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+50
View File
@@ -0,0 +1,50 @@
<?php
$must_login = false ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
$status = '300' ;
$test_file = $array['test_file'] ;
// if ( $array['name'] != '' && $array['mobile'] != '' && $array['temperature'] != '' ){
if ( $array['name'] != '' && $array['mobile'] != '' ){
$status = '203' ;
/*
$test_filename = '' ;
$test_filetype = '' ;
foreach ( $test_file as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'Visitor', md5( $array['name'] ), $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$test_filename = $upload['data']['file_name'] ;
$test_filetype = $upload['data']['file_type'] ;
}
}
}
if ( $test_file != '' ){
if ( $mysqli->query( "INSERT INTO visitor
( name, mobile, temperature, test_file, test_filetype ) VALUES
( '".$array['name']."', '".$array['mobile']."', '".$array['temperature']."', '".$test_filename."', '".$test_filetype."' )" ) ){
$status = '200' ;
}
}
*/
if ( $mysqli->query( "INSERT INTO visitor
( name, mobile ) VALUES
( '".$array['name']."', '".$array['mobile']."' )" ) ){
$status = '200' ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+16
View File
@@ -0,0 +1,16 @@
<?php
$data['staff_info'] = $staff_info ;
$result = [
'status' => $status,
'message' => $message[$status],
'data' => $data
] ;
saveLog( 'api', 'API', $array, $result ) ;
header('Content-Type: application/json') ;
echo json_encode($result) ;
?>
+61
View File
@@ -0,0 +1,61 @@
<?php
require( $require_path.'connect/status.php' ) ;
require( $require_path.'connect/main-config.php' ) ;
require( $require_path.'requires/function.php' ) ;
// check if post exsists
$array = resetRequest( $_REQUEST ) ;
// $array = resetRequest( $_POST ) ;
$status = '500' ;
$data = [] ;
// get original path
$explode1 = explode( '/api', $_SERVER['PHP_SELF'] ) ;
$explode2 = explode( '/', $explode1['1'], 2 ) ;
$path = str_replace( '.php', '', $explode2['1'] ) ;
$current = ( checkExists($array['current']) ? $array['current'] : '1' ) ;
// check access
if ( ALLOWSIGN == '1' ){
$access = false ;
if ( $array['time'] > strtotime('-1 minutes') ){
if ( hash('sha256', $path.$array['platform'].$array['lang'].$array['branch_id'].$array['staff_id'].$array['token'].$array['time'].APIKEY) == $array['sign'] ){
$access = true ;
}
}
if ( !$access ){ header("HTTP/1.0 404 Not Found") ; exit ; }
}
$boolean_login = false ;
$staff_info = [] ;
if ( $must_login == true ){
$status = '400' ;
$select = $mysqli->query( "SELECT a.staff_id, b.staff_idno, b.staff_name, b.staff_shortname, b.staff_username, b.staff_email, b.staff_mobileno, b.staff_image, b.job_position_id, b.job_section_id, b.branch_id, b.staff_point_achievement, b.staff_point, b.staff_wallet, b.staff_tier, b.staff_achievement, b.staff_star, b.staff_settings, b.country_id FROM staff_token a
LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
WHERE a.staff_id = '".$array['staff_id']."' AND a.token = '".$array['token']."' AND ( b.staff_date_resigned IS NULL OR b.staff_date_resigned = '0000-00-00' ) AND b.deleted_at IS NULL" ) ;
if ( $select->num_rows > 0 ){
$boolean_login = true ;
$staff_info = $select->fetch_assoc() ;
$staff_info['staff_image'] = ( $staff_info['staff_image'] != '' ? PATH.'uploads/Staff/'.dataFilter($staff_info['staff_image']) : '' ) ;
$staff_info['token'] = $array['token'] ;
$staff_info['staff_settings'] = ( $staff_info['staff_settings'] != '' ? json_decode($staff_info['staff_settings'], true) : [] ) ;
$get_tier = getTier( $staff_info['staff_tier'], $array['lang'] ) ;
$staff_info['staff_tier_level'] = $get_tier['level'] ;
$staff_info['staff_tier_title'] = $get_tier['title'] ;
$staff_info['staff_tier_is_task'] = $get_tier['is_task'] ;
$staff_info['staff_tier_is_task_assigned'] = $get_tier['is_task_assigned'] ;
$staff_info['staff_tier_is_task_incentive'] = $get_tier['is_task_incentive'] ;
$staff_info['staff_tier_is_task_incentive2'] = $get_tier['is_task_incentive2'] ;
$staff_info['staff_tier_is_task_extra'] = $get_tier['is_task_extra'] ;
$staff_info['staff_tier_is_adjustment'] = $get_tier['is_adjustment'] ;
$staff_info['staff_star'] = ( $staff_info['staff_star'] + 0 ) ;
}
}
?>
+27
View File
@@ -0,0 +1,27 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND advance_id = '".$array['id']."'" ;
$query = "SELECT * FROM staff_advance
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND advance_reason LIKE '%".$array['search']."%'" ;
}
$query = "SELECT * FROM staff_advance
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+83
View File
@@ -0,0 +1,83 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/sms.php' ) ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
$custom_message = '' ;
if ( $boolean_login ){
$status = '300' ;
$advance_amount = $array['advance_amount'] ;
$advance_reason = $array['advance_reason'] ;
$advance_paidby = $array['advance_paidby'] ;
if ( $advance_amount != '' && $advance_reason != '' && $advance_paidby != '' ){
$status = '305' ;
$day = date('j', strtotime(TODAYDATE)) ;
// check query exsits
$setting_query = $mysqli->query("SELECT post_id, post_title as advance_from, post_link as advance_to, post_content as advance_remark FROM system_post
WHERE post_type = 'page-advance' AND post_categories = 'page-advance' AND post_trash = '0' LIMIT 1") ;
if ( $setting_query->num_rows > 0 ){
$setting = $setting_query->fetch_assoc() ;
}
$boolean_advance = false ;
if ( $setting['advance_from'] != '' ){
if ( $setting['advance_from'] <= $day && $setting['advance_to'] >= $day ){
$boolean_advance = true ;
}else{
$status = '399' ;
$custom_message = $setting['advance_remark'] ;
}
}else{
$boolean_advance = true ;
}
if ( $boolean_advance ){
$error = 0 ;
$mysqli->autocommit( false ) ;
try {
$advance_amount = is_numeric($advance_amount) ? number_format($advance_amount, 2, '.', '') : 0 ;
$advance_reason = ( $advance_reason != '' ? $advance_reason : 'ADVANCE' ) ;
// insert into advance
$mysqli->query("INSERT INTO staff_advance
( staff_id, advance_paidby, advance_amount, advance_reason, advance_status ) VALUES
( '".$staff_info['staff_id']."', '".$advance_paidby."', '".$advance_amount."', '".$advance_reason."', 'pending' )" ) ;
$staff_advance_id = $mysqli->insert_id ;
pushToUserCron( 'staff_advance', $staff_advance_id, $staff_info['staff_id'], 'Apply Advance', 'Advance has been created.' ) ;
}catch( Exception $e ){
$error++;
}
if( $error == 0 ) {
$status = '200' ;
// commit query
$mysqli->commit() ;
}else{
$mysqli->rollback() ;
}
}
}
}
$data['custom_message'] = $custom_message ;
require( $require_sub.'footer.php' ) ;
?>
+27
View File
@@ -0,0 +1,27 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND health_id = '".$array['id']."'" ;
$query = "SELECT * FROM staff_health
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND temperature LIKE '%".$array['search']."%'" ;
}
$query = "SELECT * FROM staff_health
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+52
View File
@@ -0,0 +1,52 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/sms.php' ) ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$temperature = $array['temperature'] ;
$health_reason = $array['health_reason'] ;
if ( $temperature != '' ){
$status = '305' ;
$error = 0 ;
$mysqli->autocommit( false ) ;
try {
$health_reason = ( $health_reason != '' ? $health_reason : '' ) ;
// insert into health
$mysqli->query("INSERT INTO staff_health
( staff_id, temperature, health_reason ) VALUES
( '".$staff_info['staff_id']."', '".$temperature."', '".$health_reason."' )" ) ;
$staff_health_id = $mysqli->insert_id ;
pushToUserCron( 'staff_health', $staff_health_id, $staff_info['staff_id'], 'Apply Health', 'Health has been created.' ) ;
}catch( Exception $e ){
$error++;
}
if( $error == 0 ) {
$status = '200' ;
// commit query
$mysqli->commit() ;
}else{
$mysqli->rollback() ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+45
View File
@@ -0,0 +1,45 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
$list = [] ;
if ( $boolean_login ){
$status = '201' ;
$searchyear = ( $array['searchyear'] != '' ? $array['searchyear'] : date("Y", time()) ) ;
$search_query = " AND holiday_year = '".$searchyear."'" ;
if ( $array['search'] != '' ){
$search_query .= " AND holiday_name LIKE '%".$array['search']."%'" ;
}
$query = "SELECT * FROM setting_holiday
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY holiday_date ASC" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
while ( $row = $mysqli_query->fetch_assoc() ){
$set_status = 'current' ;
if ( $row['holiday_date'] > date( "Y-m-d", time() ) ){
$set_status = 'future' ;
}elseif ( $row['holiday_date'] < date( "Y-m-d", time() ) ){
$set_status = 'passed' ;
}
$row['status'] = $set_status ;
$list[] = $row ;
}
}
}
$data['list'] = $list ;
require( $require_sub.'footer.php' ) ;
?>
+187
View File
@@ -0,0 +1,187 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
$qrcode = $array['qrcode'] ;
if ( $boolean_login ){
$status = '303' ;
$search_query = '' ;
if ( $qrcode != '' ){
$staff_tier = [] ;
$staff_tier = getRelatedTierID( 'yes', $staff_info['staff_tier_level'] ) ;
$search_query .= " AND staff_idno = '".$qrcode."' AND staff_tier IN ( '".implode("', '", $staff_tier)."' )" ;
}else{
$search_query .= " AND staff_id = '".$staff_info['staff_id']."'" ;
}
$select_staff = $mysqli->query( "SELECT a.staff_id, a.branch_id, a.staff_idno, a.staff_name, a.staff_shortname, a.staff_username, a.staff_email, a.staff_mobileno, a.staff_birthdate, a.job_position_id, a.job_section_id, a.staff_image, a.staff_point_achievement, a.staff_point, a.staff_tier, a.staff_achievement, a.staff_star, a.gender_id, a.country_id, a.staff_date_joined, a.job_section_id, a.job_position_id, a.staff_icno, a.staff_passportno, a.staff_passportexpired, a.staff_permitno, a.staff_permit_start, a.staff_permit_end, a.staff_permit_effective_date, a.staff_settings FROM staff a
WHERE a.deleted_at IS NULL AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL ) ".$search_query."
LIMIT 1" ) ;
if ( $select_staff->num_rows > 0 ){
$status = '200' ;
$row_staff = $select_staff->fetch_assoc() ;
$row_staff['staff_name'] = ucwords( strtolower( $row_staff['staff_name'] ) ) ;
$row_staff['staff_image'] = ( $row_staff['staff_image'] != '' ? PATH.'uploads/Staff/'.dataFilter($row_staff['staff_image']) : '' ) ;
$row_staff['staff_mobileno'] = ( $row_staff['staff_mobileno'] != '' ? '+'.$row_staff['staff_mobileno'] : '' ) ;
$row_staff['staff_birthdate'] = resetDateFormat( $row_staff['staff_birthdate'] ) ;
$staff_settings = json_decode($row_staff['staff_settings'], true) ;
$row_staff['mailing_address'] = checkExists( $staff_settings['mailing_address'] ) ;
$row_staff['staff_date_joined'] = ( $row_staff['staff_date_joined'] != '0000-00-00' && $row_staff['staff_date_joined'] != '' ? resetDateFormat( $row_staff['staff_date_joined'] ) : '' ) ;
// get branch
$branch = '' ;
$get_branch = $mysqli->query( "SELECT * FROM branch WHERE deleted_at IS NULL AND branch_id = '".$row_staff['branch_id']."' LIMIT 1" ) ;
if ( $get_gender->num_rows > 0 ){
$row_gender = $get_gender->fetch_assoc() ;
$gender = $row_gender['gender_desc'] ;
}
$row_staff['staff_gender'] = ucwords( strtolower( $gender ) ) ;
// get gender
$gender = '' ;
$get_gender = $mysqli->query( "SELECT * FROM master_gender WHERE deleted_at IS NULL AND gender_id = '".$row_staff['gender_id']."' LIMIT 1" ) ;
if ( $get_gender->num_rows > 0 ){
$row_gender = $get_gender->fetch_assoc() ;
$gender = $row_gender['gender_desc'] ;
}
$row_staff['staff_gender'] = ucwords( strtolower( $gender ) ) ;
// get country
$country = '' ;
$get_country = $mysqli->query( "SELECT * FROM master_country WHERE deleted_at IS NULL AND country_id = '".$row_staff['country_id']."' LIMIT 1" ) ;
if ( $get_country->num_rows > 0 ){
$row_country = $get_country->fetch_assoc() ;
$country = $row_country['country_desc'] ;
}
$row_staff['staff_country'] = ucwords( strtolower( $country ) ) ;
// get department
$department = '' ;
$department_list = [] ;
$get_department = $mysqli->query( "SELECT a.department_id, b.department_desc FROM staff_department a
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.staff_id = '".$row_staff['staff_id']."'" ) ;
if ( $get_department->num_rows > 0 ){
while ( $row_department = $get_department->fetch_assoc() ){
$department_list[$row_department['department_id']] = dataFilter( $row_department['department_desc'] ) ;
}
$department = implode( ', ', $department_list ) ;
}
$row_staff['staff_department'] = ucwords( strtolower( $department ) ) ;
// get section
$section = '' ;
$get_section = $mysqli->query( "SELECT b.job_section_desc FROM setting_job_section a
LEFT JOIN setting_job_section_translation b ON ( a.job_section_id = b.job_section_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.job_section_id = '".$row_staff['job_section_id']."' LIMIT 1" ) ;
if ( $get_section->num_rows > 0 ){
$row_section = $get_section->fetch_assoc() ;
$section = $row_section['job_section_desc'] ;
}
$row_staff['staff_section'] = ucwords( strtolower( $section ) ) ;
$position = '' ;
$get_position = $mysqli->query( "SELECT b.job_position_desc FROM setting_job_position a
LEFT JOIN setting_job_position_translation b ON ( a.job_position_id = b.job_position_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.job_position_id = '".$row_staff['job_position_id']."' LIMIT 1" ) ;
if ( $get_position->num_rows > 0 ){
$row_position = $get_position->fetch_assoc() ;
$position = $row_position['job_position_desc'] ;
}
$row_staff['staff_position'] = ucwords( strtolower( $position ) ) ;
// get passport / permit
$passportimages = [] ;
$permitimages = [] ;
$get_staff_image = $mysqli->query("SELECT * FROM staff_image WHERE deleted_at IS NULL AND staff_id = '".$row_staff['staff_id']."'") ;
if ( $get_staff_image->num_rows > 0 ){
while ( $row_staff_image = $get_staff_image->fetch_assoc() ){
if ( $row_staff_image['type'] == 'passport' ){
$passportimages[] = PATH.'uploads/StaffImage/b/'.$row_staff_image['file_name'] ;
}
if ( $row_staff_image['type'] == 'permit' ){
$permitimages[] = PATH.'uploads/StaffImage/b/'.$row_staff_image['file_name'] ;
}
}
}
$row_staff['passportimages'] = $passportimages ;
$row_staff['permitimages'] = $permitimages ;
// get tier
$get_tier = getTier( $row_staff['staff_tier'], $array['lang'] ) ;
$row_staff['staff_tier_level'] = $get_tier['level'] ;
$row_staff['staff_tier_title'] = $get_tier['title'] ;
$row_staff['staff_tier_is_task'] = $get_tier['is_task'] ;
$row_staff['staff_tier_is_task_assigned'] = $get_tier['is_task_assigned'] ;
$row_staff['staff_tier_is_task_incentive'] = $get_tier['is_task_incentive'] ;
$row_staff['staff_tier_is_task_incentive2'] = $get_tier['is_task_incentive2'] ;
$row_staff['staff_tier_is_task_extra'] = $get_tier['is_task_extra'] ;
$row_staff['staff_tier_is_adjustment'] = $get_tier['is_adjustment'] ;
$row_staff['staff_star'] = ( $row_staff['staff_star'] + 0 ) ;
// get join training
$trainings = [] ;
$get_training = $mysqli->query( "SELECT a.created_at, b.title FROM staff_training a
LEFT JOIN training_translation b ON ( a.training_id = b.training_id )
WHERE b.lang = '".$array['lang']."' AND a.staff_id = '".$row_staff['staff_id']."' AND a.status IN ( 'confirmed', 'rated' )
GROUP BY a.training_id
ORDER BY a.updated_at DESC
LIMIT 15" ) ;
if ( $get_training->num_rows > 0 ){
while ( $row_training = $get_training->fetch_assoc() ){
$trainings[] = [
'title' => dataFilter( $row_training['title'] ),
'created_at' => resetDateFormat( $row_training['created_at'] )
] ;
}
}
$row_staff['trainings'] = $trainings ;
// get join association
$associations = [] ;
$get_association = $mysqli->query( "SELECT a.created_at, b.title FROM staff_association a
LEFT JOIN association_translation b ON ( a.association_id = b.association_id )
WHERE b.lang = '".$array['lang']."' AND a.staff_id = '".$row_staff['staff_id']."' AND a.status IN ( 'confirmed', 'rated' )
GROUP BY a.association_id
ORDER BY a.updated_at DESC
LIMIT 15" ) ;
if ( $get_association->num_rows > 0 ){
while ( $row_association = $get_association->fetch_assoc() ){
$associations[] = [
'title' => dataFilter( $row_association['title'] ),
'created_at' => resetDateFormat( $row_association['created_at'] )
] ;
}
}
$row_staff['associations'] = $associations ;
// get outstanding
$outstanding = '' ;
$get_outstanding = $mysqli->query( "SELECT type FROM staff_attendance_summary
WHERE deleted_at IS NULL AND staff_id = '".$row_staff['staff_id']."' AND type IN ( 'merit', 'passionate' ) " ) ;
if ( $get_outstanding->num_rows > 0 ){
$row_outstanding = $get_outstanding->fetch_assoc() ;
$outstanding = $row_outstanding['type'] ;
}
$row_staff['outstanding'] = $outstanding ;
unset( $row_staff['staff_settings'] ) ;
$data = $row_staff ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+29
View File
@@ -0,0 +1,29 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND leave_id = '".$array['id']."'" ;
$query = "SELECT leave_id, leave_type, leave_from, leave_to, leave_day, leave_reason, leave_file, leave_status, created_at, updated_at FROM staff_leave
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['leave_reason'] = dataFilter( $row['leave_reason'] ) ;
$row['leave_file'] = ( $row['leave_file'] != '' ? PATH.'uploads/Leave/b/'.$row['leave_file'] : '' ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+60
View File
@@ -0,0 +1,60 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$list = [] ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND leave_reason LIKE '%".$array['search']."%'" ;
}
$query = "SELECT leave_id, leave_type, leave_from, leave_to, leave_day, leave_reason, leave_file, leave_status, created_at, updated_at FROM staff_leave
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['leave_reason'] = dataFilter( $row['leave_reason'] ) ;
$list[] = $row ;
}
}
$data['list'] = $list ;
// get left leave
$annual_leave = 0 ;
$sick_leave = 0 ;
$select_leave_year = $mysqli->query( "SELECT leave_type, leave_days FROM staff_leave_year
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' AND leave_year = '".date('Y', time())."'" ) ;
if ( $select_leave_year->num_rows > 0 ){
while ( $row_leave_year = $select_leave_year->fetch_assoc() ){
if ( $row_leave_year['leave_type'] == 'annual' ){
$annual_leave = $row_leave_year['leave_days'] ;
}
if ( $row_leave_year['leave_type'] == 'sick' ){
$sick_leave = $row_leave_year['leave_days'] ;
}
}
}
$data['annual_leave'] = $annual_leave ;
$data['sick_leave'] = $sick_leave ;
}
require( $require_sub.'footer.php' ) ;
?>
+108
View File
@@ -0,0 +1,108 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$searchyearmonth = $array['searchyearmonth'] ;
$searchday = $array['searchday'] ;
$searchyearmonthday = '' ;
$list = [] ;
$selected = [] ;
$marked = [] ;
$services = $mysqli->query( "SELECT a.module FROM app_service a
WHERE a.deleted_at IS NULL AND a.type = 'service' AND a.module IN ( 'HrBranch' ) AND on_off = 'on'
LIMIT 1" ) ;
$is_filterbranch = 'no' ;
if ( $services->num_rows > 0 ){
$is_filterbranch = 'yes' ;
}
$search_query = ( $is_filterbranch == 'yes' ? " AND branch_id = '".$array['branch_id']."'" : '' ) ;
$search_query2 = '' ;
$search_query .= " AND ( a.leave_from LIKE '%".$searchyearmonth."%' OR a.leave_to LIKE '%".$searchyearmonth."%' )" ;
$search_query2 .= " AND holiday_date LIKE '%".$searchyearmonth."%'" ;
if ( $searchday != '' ){
$searchyearmonthday = $searchyearmonth . '-' . $searchday ;
$search_query .= " AND a.leave_from <= '".$searchyearmonthday."' AND a.leave_to >= '".$searchyearmonthday."'" ;
$search_query2 .= " AND holiday_date = '".$searchyearmonthday."'" ;
}
$query = "SELECT a.leave_type, a.leave_from, a.leave_to, a.leave_day, a.leave_reason, a.leave_status, b.staff_idno, b.staff_name, b.staff_shortname FROM staff_leave a
LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
WHERE b.deleted_at IS NULL AND ( b.staff_date_resigned >= '".date("Y-m-d",time())."' OR b.staff_date_resigned = '0000-00-00' OR b.staff_date_resigned IS NULL ) AND a.deleted_at IS NULL AND a.leave_status IN ( 'pending', 'confirmed' ) " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY leave_from" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
while ( $row = $mysqli_query->fetch_assoc() ){
$boolean_loop = true ;
$leave_from = $row['leave_from'] ;
$leave_to = $row['leave_to'] ;
$row['leave_reason'] = dataFilter( $row['leave_reason'] ) ;
while ( $boolean_loop ){
if ( $leave_from <= $leave_to ){
$selected[$leave_from] = $leave_from ;
}else{
$boolean_loop = false ;
}
$leave_from = date('Y-m-d', strtotime("+1 day", strtotime($leave_from))) ;
}
$row['type'] = 'leave' ;
$list[] = $row ;
}
}
$query_holiday = "SELECT * FROM setting_holiday
WHERE deleted_at IS NULL " . $search_query2 ;
$mysqli_holiday = $mysqli->query( $query_holiday . " ORDER BY holiday_date ASC" ) ;
if ( $mysqli_holiday->num_rows > 0 ){
while ( $row_holiday = $mysqli_holiday->fetch_assoc() ){
$row_holiday['type'] = 'holiday' ;
$list[] = $row_holiday ;
}
}
$first_day_of_month = $searchyearmonth . '-01' ;
$last_day_of_month = $searchyearmonth . '-' . date( 't', strtotime( $first_day_of_month ) ) ;
for ( $a = $first_day_of_month ; $a <= $last_day_of_month ; $a++ ){
if ( $selected[$a] != null ){
$marked[$a] = [ 'marked' => true, 'dotColor' => '#ff9500' ] ;
}
}
// get holiday list
$select_holiday = $mysqli->query( "SELECT holiday_date FROM setting_holiday WHERE deleted_at IS NULL AND holiday_date LIKE '%".$searchyearmonth."%'" ) ;
if ( $select_holiday->num_rows > 0 ){
while ( $row_holiday = $select_holiday->fetch_assoc() ){
$marked[$row_holiday['holiday_date']] = [ 'marked' => true, 'dotColor' => '#5188ff' ] ;
}
}
$data['list'] = $list ;
$data['marked'] = $marked ;
}
require( $require_sub.'footer.php' ) ;
?>
+304
View File
@@ -0,0 +1,304 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/sms.php' ) ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$leave_type = $array['leave_type'] ;
$leave_fullhalf = $array['leave_fullhalf'] ;
$leave_from = $array['leave_from'] ;
$leave_to = $array['leave_to'] ;
$leave_reason = $array['leave_reason'] ;
$datetime1 = new DateTime($leave_from) ;
$datetime2 = new DateTime($leave_to) ;
$interval = $datetime1->diff($datetime2) ;
$days = $interval->format('%a')+1 ;
$photos = $array['photos'] ;
if ( $leave_fullhalf == 'half' ){
$leave_to = $leave_from ;
}
if ( $leave_type != '' && $leave_from != '' && $leave_to != '' && $leave_reason != '' ){
$status = '274' ;
$from = $leave_from ;
$to = $leave_to ;
if ( date('Y', strtotime($from)) == date('Y', strtotime($to)) ){
$status = '273' ;
// get again staff
$department = '' ;
$get_department = $mysqli->query("SELECT department_id FROM staff_department
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."'") ;
if ( $get_department->num_rows > 0 ){
while ( $row_department = $get_department->fetch_assoc() ){
$department .= ',('.$row_department['department_id'].')' ;
}
$department = substr($department, 1) ;
}
// get days
$datetime1 = new DateTime($from) ;
$datetime2 = new DateTime($to) ;
$interval = $datetime1->diff($datetime2) ;
$days = $interval->format('%a')+1 ;
if ( $leave_fullhalf == 'half' ){
$days = '0.5' ;
}
$boolean_apply = false ;
// check left leave
if ( $type == 'unpaid' ){
$boolean_apply = true ;
}else{
$leave_days = 0 ;
$boolean_ded = false ;
// return leave to the staff
$get_leave_year = $mysqli->query("SELECT leave_days FROM staff_leave_year
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' AND leave_type = '".$leave_type."' AND leave_year_from >= '".TODAYDAY."' AND leave_year_to <= '".TODAYDAY."' LIMIT 1") ;
if ( $get_leave_year->num_rows > 0 ){
$row_leave_year = $get_leave_year->fetch_assoc() ;
$leave_days = $row_leave_year['leave_days'] ;
$boolean_ded = true ;
}
if ( $leave_days > 0 ){
// get currently apply pending leave
$get_leave_pending = $mysqli->query("SELECT leave_from, leave_to, leave_day FROM staff_leave
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' AND leave_type = '".$leave_type."' AND leave_status = 'pending' AND leave_from LIKE '".date('Y', time())."-%'") ;
if ( $get_leave_pending->num_rows > 0 ){
$array_leave_pending[] = [
'from' => $leave_from,
'to' => $leave_to,
'days' => $days
] ;
while ( $row_leave_pending = $get_leave_pending->fetch_assoc() ){
$array_leave_pending[] = [
'from' => $row_leave_pending['leave_from'],
'to' => $row_leave_pending['leave_to'],
'days' => $row_leave_pending['leave_day']
] ;
}
foreach ( $array_leave_pending as $kk => $vv ){
$new_date = date('Y-m-d', strtotime($vv['leave_from'])) ;
// check if full day or half day
$day_fullhalf = 'full' ;
$leave_day = $vv['days'] ; // should change to $days
$cut_day = '1' ;
if ( $leave_day == '0.5' ){
$day_fullhalf = 'half' ;
$leave_day = '1' ;
$cut_day = '0.5' ;
}
// save to leave more
for ( $a = 1 ; $a <= $leave_day ; $a++ ){
$leave_type_mode = 'working' ;
$leave_work_direct = 'no' ;
$leave_work_day = '0' ;
$boolean_holiday = false ;
$boolean_off = false ;
// check if today is holiday
$get_holiday = $mysqli->query("SELECT * FROM $prefixSettingHoliday
WHERE deleted_at IS NULL AND holiday_date = '".$new_date."' LIMIT 1") ;
if ( $get_holiday->num_rows > 0 ){
$leave_type_mode = 'holiday' ;
$boolean_holiday = true ;
$leave_work_day = '1' ;
}
// check working days if today off
if ( !$boolean_holiday ){
$new_week_day = date('N', strtotime($new_date)) ;
$get_working = $mysqli->query("SELECT * FROM setting_working
WHERE deleted_at IS NULL AND group_id = '".$row_staff['group_id']."' AND working_day = '".$new_week_day."' LIMIT 1") ;
if ( $get_working->num_rows > 0 ){
$row_working = $get_working->fetch_assoc() ;
if ( $row_working['working_on'] == 'no' ){
$leave_type_mode = 'off' ;
$boolean_off = true ;
$leave_work_day = '1' ;
}
$leave_work_direct = $row_working['working_direct_day'] ;
if ( $leave_work_direct == 'yes' ){
$leave_work_day = '0.5' ;
}
}
if ( !$boolean_off ){
$leave_work_day = $cut_day ;
}
}
$new_date = date('Y-m-d', strtotime($new_date . '+1 days')) ;
if ( !$boolean_holiday && !$boolean_off ){
$leave_days = ( $leave_days - $leave_work_day ) ;
}
}
}
}
}
if ( $leave_days >= 0 ){
$boolean_apply = true ;
}
}
if ( $boolean_apply ){
$status = '203' ;
$error = 0 ;
$mysqli->autocommit( false ) ;
try {
$incharge_status = 'confirmed' ;
// insert into leave
$mysqli->query( "INSERT INTO staff_leave
( staff_id, leave_department, leave_type, leave_from, leave_to, leave_day, leave_reason, leave_file, leave_incharge_status, leave_status ) VALUES
( '".$staff_info['staff_id']."', '".$department."', '".$leave_type."', '".$leave_from."', '".$leave_to."', '".$days."', '".$leave_reason."', '".$leave_file."', '".$incharge_status."', 'pending' )" ) ;
$last_id = $mysqli->insert_id ;
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'Leave', $last_id.'-'.$last_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "UPDATE staff_leave SET
leave_file = '".$upload['data']['file_name']."'
WHERE leave_id = '".$last_id."'" ) ;
}
}
}
}
// get team leave
$l_content = '' ;
$leave_q = $mysqli->query("SELECT a.leave_day, a.leave_from, a.leave_to, a.leave_status, b.staff_name FROM staff_leave a
LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
WHERE a.deleted_at IS NULL AND a.leave_id != '".$last_id."' AND a.leave_incharge_status = 'confirmed' AND a.leave_status != 'rejected' AND a.leave_from >= '".TODAYDAY."'
ORDER BY a.leave_from ASC") ;
if ( $leave_q->num_rows > 0 ){
while ( $leave = $leave_q->fetch_assoc() ){
$l_content .= '
<tr>
<td>'.$leave['staff_name'].'</td>
<td style="text-align:center;">'.$leave['leave_day'].'</td>
<td style="text-align:center;">'.$leave['leave_from'].' ~ '.$leave['leave_to'].'</td>
<td style="text-align:center;">'.ucwords($leave['leave_status']).'</td>
</tr>' ;
}
}else{
$l_content .= '<tr><td colspan="4">No leave found.</td></tr>' ;
}
// set date
$array_date = [
1 => 'Monday',
2 => 'Tuesday',
3 => 'Wednesday',
4 => 'Thursday',
5 => 'Friday',
6 => 'Saturday',
7 => 'Sunday',
] ;
$leave_from_date = $array_date[ date('N', strtotime($leave_from)) ] ;
$leave_to_date = $array_date[ date('N', strtotime($leave_to)) ] ;
// get current annual leave or sick leave
$leave_year_days = 0 ;
if ( $leave_type != 'unpaid' ){
$leave_year_q = $mysqli->query("SELECT leave_days FROM staff_leave_year
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' AND leave_type = '".$leave_type."' ORDER BY leave_year_id DESC LIMIT 1") ;
if ( $leave_year_q->num_rows > 0 ){
$leave_year = $leave_year_q->fetch_assoc() ;
$leave_year_days = $leave_year['leave_days'] ;
}
}
pushToUserCron( 'staff_leave', $last_id, $staff_info['staff_id'], 'Apply Leave', 'Leave has been created.' ) ;
// send email when apply leave
$content = '
Hello Team, <br /><br />
Please approve <b>'.$staff_info['staff_name'].'</b> leave.<br /><br />
<b>'.$staff_info
['staff_name'].'</b> has applied for <b>'.ucwords($leave_type).'</b> leave from <b>'.date('d/m/Y', strtotime($leave_from)).' ('.$leave_from_date.')</b> to <b>'.date('d/m/Y', strtotime($leave_to)).' ('.$leave_to_date.')</b> with the reason <b>('.$leave_reason.')</b>. Please review the application and appove or reject it.<br /><br />
'.( $leave_type != 'unpaid' ? 'If this application is approved, it will utilize <b>'.$days.' day(s)</b> and there is <b>'.($leave_year_days-$days).' day(s)</b> remaining <b>'.ucwords($leave_type).'</b> leave days.<br /><br />' : '' ).'
Currently, your team\'s leave schedule (nearby the date range) is illustrated as below:
<table width="600px">
<tr>
<th style="text-align:left;">Name</th>
<th>Day(s)</th>
<th>Date Range</th>
<th>Status</th>
</tr>
'.$l_content.'
</table><br /><br />
The approval for this application belongs to you, so do keep this e-mail safe.' ;
$mailer = new Mailer() ;
$mailer->from = EMAILNOREPLY ;
$mailer->to = $EMAILCC ;
$mailer->cc = [ $staff_info['staff_email'] ] ;
$mailer->subject = ucwords($leave_type).' leave request from '.$staff_info['staff_name'] ;
$mailer->body = $content ;
$mailer->send() ;
}catch( Exception $e ){
$message = $e ;
$error++;
}
if( $error == 0 ) {
$status = '200' ;
// commit query
$mysqli->commit() ;
}else{
$mysqli->rollback() ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+29
View File
@@ -0,0 +1,29 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND payment_slip_id = '".$array['id']."'" ;
$query = "SELECT * FROM staff_payment_slip
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['payment_file'] = ( $row['payment_file'] != '' ? PATH.'uploads/PaymentSlip/b/'.$row['payment_file'] : '' ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+35
View File
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND payment_subject LIKE '%".$array['search']."%'" ;
}
$query = "SELECT * FROM staff_payment_slip
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['payment_file'] = ( $row['payment_file'] != '' ? PATH.'uploads/PaymentSlip/b/'.$row['payment_file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+33
View File
@@ -0,0 +1,33 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
$status = '300' ;
$commission_array = $array['commission_array'];
if ( count($commission_array) > 0 ){
$status = '203';
foreach($commission_array as $key => $value){
$staff_id = $value['staff_id'];
$commission_num = $value['commision_student_count'];
$commission = $value['commission'];
$month = $value['month'];
$query_commission_temp = $mysqli->query("SELECT temp_id FROM staff_commission_temp WHERE staff_id='$staff_id' AND month='$month'");
if(mysqli_num_rows($query_commission_temp)==0){
$insert = $mysqli->query("INSERT INTO staff_commission_temp (staff_id, commission_num, commission, month) VALUES ('$staff_id', '$commission_num', '$commission', '$month') ");
}
}
if($insert){
$status = '200';
}
}
require( $require_sub.'footer.php' ) ;
?>
+76
View File
@@ -0,0 +1,76 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
$status = '300' ;
$branch_id = $array['branch_id'] ;
$branch_name = $array['branch_name'] ;
$staff_idno = $array['idno'] ;
$staff_name = $array['name'] ;
$staff_email = $array['email'] ;
$staff_mobileno = $array['mobile'] ;
$department_id = '5' ;
if ( $branch_id != '' && $staff_idno != '' && $staff_name != '' ){
$status = '244' ;
// check branch id exists or not first
$select_branch = $mysqli->query( "SELECT * FROM branch WHERE branch_id = '".$branch_id."' LIMIT 1" ) ;
if ( $select_branch->num_rows == 0 ){
if ( $branch_name != '' ){
$mysqli->query( "INSERT INTO branch
( branch_id, branch_name, created_at, updated_at ) VALUES
( '".$branch_id."', '".$branch_name."', '".TODAYDATE."', '".TODAYDATE."' )" ) ;
}
}
// check staffidno exists
$staff_id = '' ;
$select_staff = $mysqli->query( "SELECT staff_id FROM staff
WHERE deleted_at IS NULL AND staff_idno = '".$staff_idno."' LIMIT 1" ) ;
if ( $select_staff->num_rows == 0 ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO staff
( branch_id, staff_idno, staff_name, staff_email, staff_mobileno, staff_tier ) VALUES
( '".$branch_id."', '".$staff_idno."', '".$staff_name."', '".$staff_email."', '".$staff_mobileno."', '9' )" ) ){
$staff_id = $mysqli->insert_id ;
$status = '200' ;
}
}else{
$status = '202' ;
$row_staff = $select_staff->fetch_assoc() ;
if ( $mysqli->query( "UPDATE staff SET
branch_id = '".$branch_id."',
staff_name = '".$staff_name."',
staff_email = '".$staff_email."',
staff_mobileno = '".$staff_mobileno."'
WHERE staff_id = '".$row_staff['staff_id']."'" ) ){
$staff_id = $row_staff['staff_id'] ;
$status = '200' ;
}
}
if ( $staff_id != '' ){
$select_department = $mysqli->query( "SELECT staff_department_id FROM staff_department
WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' LIMIT 1" ) ;
if ( $select_department->num_rows == 0 ){
$mysqli->query("INSERT INTO staff_department
( staff_id, department_id, created_at, updated_at ) VALUES
( '".$staff_id."', '".$department_id."', '".TODAYDATE."', '".TODAYDATE."')" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+348
View File
@@ -0,0 +1,348 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
$is_show = 'no' ;
$popup = '' ;
$department_list = [] ;
$departments = [] ;
$position = '' ;
$section = '' ;
$announcements = [] ;
$services = [ 'hr' => [], 'service' => [] ] ;
$count_inbox = 0 ;
$staff_settings = $staff_info['staff_settings'] ;
// get branch name
$branch = '' ;
$select_branch = $mysqli->query( "SELECT branch_name FROM branch
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' LIMIT 1" ) ;
if ( $select_branch->num_rows > 0 ){
$row_branch = $select_branch->fetch_assoc() ;
$branch = dataFilter( $row_branch['branch_name'] ) ;
}
// get popup
$select = $mysqli->query( "SELECT * FROM setting_popup
WHERE branch LIKE '%/".$array['branch_id']."/%' AND setting_popup_id = '1' AND file != '' AND status = 'active' LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$row = $select->fetch_assoc() ;
$popup = PATH.'uploads/Pop-up/b/'.dataFilter($row['file']) ;
}
// select all department
$select = $mysqli->query( "SELECT a.department_id, a.department_code, b.department_desc FROM setting_department a
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$department_list[$row['department_id']] = dataFilter( $row['department_desc'] ) ;
}
}
// select staff department
$select = $mysqli->query( "SELECT a.department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$departments[] = $department_list[ $row['department_id'] ] ;
}
}
$departments = implode( ', ', $departments ) ;
// select staff position
$select = $mysqli->query( "SELECT a.job_position_code, b.job_position_desc FROM setting_job_position a
LEFT JOIN setting_job_position_translation b ON ( a.job_position_id = b.job_position_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.job_position_id = '".$staff_info['job_position_id']."'" ) ;
if ( $select->num_rows > 0 ){
$row = $select->fetch_assoc() ;
$position = dataFilter( $row['job_position_desc'] ) ;
}
// select staff section
$select = $mysqli->query( "SELECT a.job_section_code, b.job_section_desc FROM setting_job_section a
LEFT JOIN setting_job_section_translation b ON ( a.job_section_id = b.job_section_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.job_section_id = '".$staff_info['job_section_id']."'" ) ;
if ( $select->num_rows > 0 ){
$row = $select->fetch_assoc() ;
$section = dataFilter( $row['job_section_desc'] ) ;
$section = ( $section != 'NONE' ? $section : '' ) ;
}
// select announcement
$select = $mysqli->query( "SELECT a.announcement_id, a.is_hide, a.file, b.title FROM announcement a
LEFT JOIN announcement_translation b ON ( a.announcement_id = b.announcement_id )
WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' AND a.branch LIKE '%".$array['branch_id']."%' AND a.file != ''
ORDER BY a.announcement_id DESC
LIMIT 8" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$row['id'] = dataFilter( $row['announcement_id'] ) ;
$row['title'] = ( $row['is_hide'] == 'no' ? dataFilter( $row['title'] ) : '' ) ;
$row['uri'] = ( $row['file'] != '' ? PATH.'uploads/Announcement/b/'.$row['file'] : '' ) ;
$row['url'] = ( $row['file'] != '' ? PATH.'uploads/Announcement/b/'.$row['file'] : '' ) ;
$announcements[] = $row ;
}
}
// count
// count adjustment
$count_adjustment = 0 ;
$query = "SELECT COUNT( adjustment_id ) as total FROM staff_adjustment
WHERE deleted_at IS NULL AND ( created_branch_id = '".$array['branch_id']."' AND created_by = '".$staff_info['staff_id']."' ) " ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_adjustment = $row['total'] ;
}
// count task
$count_task = 0 ;
$query = "SELECT COUNT( a.task_id ) as total FROM task a
WHERE a.deleted_at IS NULL AND ( a.created_branch_id = '".$array['branch_id']."' AND a.created_by = '".$staff_info['staff_id']."' OR a.assigned_by = '".$staff_info['staff_id']."' OR EXISTS ( SELECT b.staff_id FROM task_joinstaff b WHERE a.task_id = b.task_id AND b.staff_id = '".$staff_info['staff_id']."' LIMIT 1 ) ) AND status IN ( 'pending', 'assigned', 'resubmit', 'progress' ) " ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_task = $row['total'] ;
}
// count redeem
$count_redeem = 0 ;
$query = "SELECT COUNT( redeem_id ) as total FROM staff_redeem
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' AND status = 'pending'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_redeem = $row['total'] ;
}
// count catalog
$count_catalog = 0 ;
$query = "SELECT COUNT( catalog_id ) as total FROM catalog
WHERE deleted_at IS NULL" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_catalog = $row['total'] ;
}
// count handbook
$count_handbook = 0 ;
$query = "SELECT COUNT( handbook_id ) as total FROM handbook
WHERE deleted_at IS NULL AND ( ( receiver_type IN ( '0' ) ) OR ( receiver_type IN ( '1', '2' ) AND staff_id LIKE '%/".$staff_info['staff_id']."/%' ) )" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_handbook = $row['total'] ;
}
// count suggestion, grievance, request
// count suggestion
$count_suggestion = 0 ;
$query = "SELECT COUNT( suggestion_id ) as total FROM suggestion
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' AND status = 'pending'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_suggestion = $row['total'] ;
}
// count request
$count_request = 0 ;
$query = "SELECT COUNT( request_id ) as total FROM request
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' AND status = 'pending'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_request += $row['total'] ;
}
// count grievance
$count_grievance = 0 ;
$query = "SELECT COUNT( grievance_id ) as total FROM grievance
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' AND status = 'pending'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_grievance += $row['total'] ;
}
// count training
$count_training = 0 ;
$query = "SELECT COUNT( training_id ) as total FROM staff_training
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' AND status = 'pending'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_training = $row['total'] ;
}
// count association
$count_association = 0 ;
$query = "SELECT COUNT( association_id ) as total FROM staff_association
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' AND status = 'pending'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_association = $row['total'] ;
}
// count form
$count_form = 0 ;
$query = "SELECT COUNT( form_id ) as total FROM form
WHERE deleted_at IS NULL AND branch LIKE '%/".$array['branch_id']."/%' AND ( ( receiver_type IN ( '0' ) ) OR ( receiver_type IN ( '1', '2' ) AND staff_id LIKE '%/".$staff_info['staff_id']."/%' ) )" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_form = $row['total'] ;
}
// count recruitment
$count_recruitment = 0 ;
$query = "SELECT COUNT( employment_id ) as total FROM staff_employment
WHERE employment_trash = '0' AND employment_status = 'Processing' AND employment_branch = '".$array['branch_id']."' AND employment_incharge_staff_id = '".$staff_info['staff_id']."'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_recruitment = $row['total'] ;
}
// select service
$select = $mysqli->query( "SELECT a.type, a.module, a.colour, a.file, b.title FROM app_service a
LEFT JOIN app_service_translation b ON ( a.service_id = b.service_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.on_off = 'on'
ORDER BY a.sortable" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$boolean_show = true ;
$count = 0 ;
switch ( $row['module'] ){
case 'Punch' :
if ( $staff_settings['punch'] != 'yes' ){
$boolean_show = false ;
}
break ;
case 'Adjustment' :
switch ( $staff_info['staff_tier_is_adjustment'] ){
case 'yes' :
case 'fixed' :
$count = $count_adjustment ;
break ;
default :
$boolean_show = false ;
}
break ;
case 'Task' : $count = $count_task ; break ;
case 'Redeem' : $count = $count_redeem ; break ;
case 'Catalog' : $count = $count_catalog ; break ;
case 'Handbook' :
case 'HandbookMainCategory' :
$count = $count_handbook ;
break ;
case 'LocalInbox' : $count = ( $count_suggestion + $count_grievance + $count_request ) ; break ;
case 'Training' : $count = $count_training ; break ;
case 'Association' : $count = $count_association ; break ;
case 'Hr' : $is_show = 'yes' ; break ;
case 'HrBranch' : $is_show = 'yes' ; break ;
case 'HrManual' : $is_show = 'manual' ; break ;
case 'Recruitment' :
if ( $staff_info['staff_settings']['checkrecruitment'] != 'yes' ){
$boolean_show = false ;
}else{
$count = $count_recruitment ;
}
break ;
case 'Visitor' :
if ( $staff_info['staff_settings']['approvevisitation'] != 'yes' ){
$boolean_show = false ;
}
break ;
case 'Form' : $count = $count_form ; break ;
}
$row['title'] = dataFilter( $row['title'] ) ;
$row['count'] = ( $count > 999 ? '999+' : $count ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/AppService/'.$row['file'] : '' ) ;
$service_type = $row['type'] ;
unset( $row['type'] ) ;
if ( $boolean_show ){
$services[$service_type][] = $row ;
}
}
}
// select attendance
$attendances = [ 'presents' => 0, 'late' => 0, 'absent' => 0 ] ;
$mysqli_query = $mysqli->query( "SELECT COUNT( a.view_id ) as total FROM staff_inbox_view a
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.is_read = '0'" ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_inbox = $row['total'] ;
}
$data = [
'is_show' => $is_show,
'branch' => $branch,
'position' => $position,
'section' => $section,
'popup' => $popup,
'departments' => $departments,
'announcements' => $announcements,
'services' => $services,
'attendances' => $attendances,
'count_inbox' => $count_inbox
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+33
View File
@@ -0,0 +1,33 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.menu_id = '".$array['id']."'" ;
$query = "SELECT * FROM app_menu a
LEFT JOIN app_menu_translation b ON ( a.menu_id = b.menu_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/AppMenu/b/'.$row['file'] : '' ) ;
$row['created_at'] = resetDateTimeFormat( $row['created_at'] ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+30
View File
@@ -0,0 +1,30 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
$menus = [] ;
$select = $mysqli->query( "SELECT a.menu_id, b.title FROM app_menu a
LEFT JOIN app_menu_translation b ON ( a.menu_id = b.menu_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' ORDER BY a.sortable" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$row['id'] = dataFilter( $row['menu_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$menus[] = $row ;
}
}
$data = [
'menus' => $menus
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+33
View File
@@ -0,0 +1,33 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.page_id = '".$array['id']."'" ;
$query = "SELECT * FROM app_page a
LEFT JOIN app_page_translation b ON ( a.page_id = b.page_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/AppPage/b/'.$row['file'] : '' ) ;
$row['created_at'] = resetDateTimeFormat( $row['created_at'] ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+39
View File
@@ -0,0 +1,39 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
$is_delete = 'no' ;
if ( $staff_info['staff_username'] == 'jimmy' ){
$is_delete = 'yes' ;
}
$pages = [] ;
$select = $mysqli->query( "SELECT a.page_id, b.title FROM app_page a
LEFT JOIN app_page_translation b ON ( a.page_id = b.page_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' ORDER BY a.sortable" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$row['id'] = dataFilter( $row['page_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$pages[] = $row ;
}
}
$generatecode = generateQrcode( $require_path, $staff_info['staff_idno'], PATH.'hr-staff-vcard.php?staff_idno='.$staff_info['staff_idno'] ) ;
$data = [
'is_delete' => $is_delete,
'pages' => $pages,
'namecard' => $generatecode['url']
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+35
View File
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.name LIKE '%".$array['search']."%'" ;
}
$supports = [] ;
$select = $mysqli->query( "SELECT a.mobile, b.name FROM app_support a
LEFT JOIN app_support_translation b ON ( a.support_id = b.support_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ) ;
if ( $select->num_rows > 0 ){
$status = '200' ;
while ( $row = $select->fetch_assoc() ){
$supports[] = $row ;
}
}
$data = [
'list' => $supports
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+31
View File
@@ -0,0 +1,31 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$query = "SELECT branch_id, branch_name, branch_hq FROM branch
WHERE deleted_at IS NULL " ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['branch_name'] = dataFilter( $row['branch_name'] ) ;
$row['branch_hq'] = ( $row['branch_hq'] != '' ? $row['branch_hq'] : '0' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+207
View File
@@ -0,0 +1,207 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.view_id = '".$array['id']."'" ;
$query = "SELECT a.view_id, a.inbox_id, a.is_read, b.from_table, b.from_id, b.title, b.description, b.content, b.view_format, b.file, b.file_type, b.video_url, b.created_at FROM staff_inbox_view a
LEFT JOIN inbox b ON ( a.inbox_id = b.inbox_id )
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$file = '' ;
if ( $row['file'] != '' ){
if ( $row['file_type'] == 'pdf' ){
$file = PATH.'uploads/Inbox/'.$row['file'] ;
}else{
$file = PATH.'uploads/Inbox/b/'.$row['file'] ;
}
}
$row['title'] = dataFilter( $row['title'] ) ;
$row['description'] = dataFilter( $row['description'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = $file ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$go_page = '' ;
$go_param = '' ;
$is_updateread = true ;
switch ( $row['from_table'] ){
case 'task' :
$go_page = 'TaskView' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'redeem' :
$go_page = 'RedeemDetails' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'], 'view_id' => '' ] ;
break ;
case 'staff_redeem' :
$select_view = $mysqli->query( "SELECT redeem_id FROM staff_redeem WHERE view_id = '".$row['from_id']."' LIMIT 1" ) ;
$main_id = '' ;
if ( $select_view->num_rows > 0 ){
$row_view = $select_view->fetch_assoc() ;
$main_id = $row_view['redeem_id'] ;
$go_page = 'RedeemView' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $main_id, 'view_id' => $row['from_id'] ] ;
}
break ;
case 'association' :
$go_page = 'AssociationDetails' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'], 'view_id' => '' ] ;
break ;
case 'staff_association' :
$select_view = $mysqli->query( "SELECT association_id FROM staff_association WHERE view_id = '".$row['from_id']."' LIMIT 1" ) ;
$main_id = '' ;
if ( $select_view->num_rows > 0 ){
$row_view = $select_view->fetch_assoc() ;
$main_id = $row_view['association_id'] ;
$go_page = 'AssociationView' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $main_id, 'view_id' => $row['from_id'] ] ;
}
break ;
case 'training' :
$go_page = 'TrainingDetails' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'], 'view_id' => '' ] ;
break ;
case 'staff_training' :
$select_view = $mysqli->query( "SELECT training_id FROM staff_training WHERE view_id = '".$row['from_id']."' LIMIT 1" ) ;
$main_id = '' ;
if ( $select_view->num_rows > 0 ){
$row_view = $select_view->fetch_assoc() ;
$main_id = $row_view['training_id'] ;
$go_page = 'TrainingView' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $main_id, 'view_id' => $row['from_id'] ] ;
}
break ;
case 'suggestion' :
$go_page = 'SuggestionUpdate' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'grievance' :
$go_page = 'GrievanceUpdate' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'request' :
$go_page = 'RequestUpdate' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'staff_adjustment' :
$go_page = 'AdjustmentDetails' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'handbook' :
$go_page = 'HandbookDetails' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'staff_leave' :
$go_page = 'LeaveDetails' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'staff_payment_slip':
$go_page = 'PaymentSlipUpdate' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'staff_advance' :
$go_page = 'AdvanceUpdate' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'staff_health' :
$go_page = 'HealthUpdate' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'holiday' :
$go_page = 'Holiday' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => '' ] ;
break ;
case 'announcement' :
$select_announcement = $mysqli->query( "SELECT is_showagree FROM announcement
WHERE deleted_at IS NULL AND status = 'active' AND announcement_id = '".$row['from_id']."' LIMIT 1" ) ;
if ( $select_announcement->num_rows > 0 ){
$row_announcement = $select_announcement->fetch_assoc() ;
if ( $row_announcement['is_showagree'] == 'yes' ){
$select_agree = $mysqli->query( "SELECT * FROM staff_announcement
WHERE deleted_at IS NULL AND announcement_id = '".$row['from_id']."' AND staff_id = '".$staff_info['staff_id']."' LIMIT 1" ) ;
if ( $select_agree->num_rows == 0 ){
$is_updateread = false ;
}
}
}
$go_page = 'AnnouncementDetails' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'outstanding-employee' :
case 'lateness-board' :
$go_page = 'Home' ;
$go_param = [ 'refresh' => '', 'type' => '', 'id' => '' ] ;
break ;
case 'association_gallery' :
case 'training_gallery' :
case 'request_gallery' :
$select_view = $mysqli->query( "SELECT file FROM ".$row['from_table']." WHERE gallery_id = '".$row['from_id']."' LIMIT 1" ) ;
$main_id = '' ;
if ( $select_view->num_rows > 0 ){
$row_view = $select_view->fetch_assoc() ;
$path = '' ;
switch ( $row['from_table'] ){
case 'association_gallery' :
$path = 'AssociationGallery' ;
break ;
case 'training_gallery' :
$path = 'TrainingGallery' ;
break ;
case 'request_gallery' :
$path = 'RequestGallery' ;
break ;
}
$files = ( $row_view['file'] != '' ? [ PATH.'uploads/'.$path.'/b/'.$row_view['file'] ] : [] ) ;
$go_page = 'ImageZoom' ;
$go_param = [ 'refresh' => '', 'files' => $files ] ;
}
break ;
case 'form' :
$go_page = 'FormDetails' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
case 'formresignation' :
$go_page = 'FormResignationUpdate' ;
$go_param = [ 'refresh' => '', 'type' => 'update', 'id' => $row['from_id'] ] ;
break ;
}
$row['go_page'] = $go_page ;
$row['go_param'] = $go_param ;
$data['list'] = $row ;
// update is read
if ( $row['is_read'] == '0' && $is_updateread ) {
$mysqli->query( "UPDATE staff_inbox_view SET
is_read = '1'
WHERE view_id = '".$row['view_id']."'" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+65
View File
@@ -0,0 +1,65 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search']!= '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
if ( $array['searchstatus'] != '' ){
$get_status = '' ;
switch ( $array['searchstatus'] ){
case 'unread' :
$get_status = '0' ;
break ;
case 'read' :
$get_status = '1' ;
break ;
}
$search_query .= " AND a.is_read = '".$get_status."'" ;
}
$query = "SELECT a.view_id, a.inbox_id, a.is_read, b.title, b.description, b.created_at FROM staff_inbox_view a
LEFT JOIN inbox b ON ( a.inbox_id = b.inbox_id )
WHERE a.deleted_at IS NULL AND b.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY b.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['title'] = dataFilter( $row['title'] ) ;
$row['description'] = dataFilter( $row['description'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
// total inbox
$mysqli_query = $mysqli->query( "SELECT COUNT( a.view_id ) as total FROM staff_inbox_view a
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.is_read = '0'" ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$count_inbox = $row['total'] ;
}
$data['count_inbox'] = $count_inbox ;
// mark notification as 0
$mysqli->query( "UPDATE staff_notification SET badge = '0' WHERE staff_id = '".$staff_info['staff_id']."'" ) ;
}
require( $require_sub.'footer.php' ) ;
?>
+18
View File
@@ -0,0 +1,18 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '202' ;
if ( $mysqli->query( "UPDATE staff_inbox_view SET
is_read = '1'
WHERE deleted_at IS NULL AND staff_id = '".$staff_info['staff_id']."'" ) ){
$status = '200' ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$list = [] ;
$query = "SELECT a.code, a.file, a.created_at, b.title, b.content FROM profile_achievement a
LEFT JOIN profile_achievement_translation b ON ( a.achievement_id = b.achievement_id )
WHERE deleted_at IS NULL AND b.lang = '".$array['lang']."'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
while ( $row = $mysqli_query->fetch_assoc() ){
$temp = [] ;
$temp['code'] = dataFilter( $row['code'] ) ;
$temp['title'] = dataFilter( $row['title'] ) ;
$temp['content'] = dataFilter( $row['content'] ) ;
$temp['file'] = ( $row['file'] != '' ? PATH.'uploads/ProfileAchievement/b/'.$row['file'] : '' ) ;
$temp['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $temp ;
}
}
$data['list'] = $list ;
}
require( $require_sub.'footer.php' ) ;
?>
+36
View File
@@ -0,0 +1,36 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$list = [] ;
$query = "SELECT * FROM profile_tier
WHERE deleted_at IS NULL " ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
while ( $row = $mysqli_query->fetch_assoc() ){
$temp = [] ;
$temp['title'] = dataFilter( $row['title'] ) ;
$temp['sub'] = dataFilter( $row['sub'] ) ;
$temp['content'] = dataFilter( $row['content'] ) ;
$temp['file'] = ( $row['file'] != '' ? PATH.'uploads/ProfileTier/b/'.$row['file'] : '' ) ;
$temp['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $temp ;
}
}
$data['list'] = $list ;
}
require( $require_sub.'footer.php' ) ;
?>
+35
View File
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND ( a.remark LIKE '%".$array['search']."%' )" ;
}
$query = "SELECT a.movement_id, a.from_table, a.before_amount, a.amount, a.balance, a.remark, a.created_at FROM staff_point_movement a
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.movement_id DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+188
View File
@@ -0,0 +1,188 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
$html = '' ;
$list = [] ;
$total_accumulated = 0 ;
$total_redeem = 0 ;
if ( $boolean_login ){
$status = '201' ;
if ( $array['iswebview'] == 'no' ){
// get point list
$query = "SELECT a.point_id, a.file, a.created_at, b.title, b.content FROM profile_point a
LEFT JOIN profile_point_translation b ON ( a.point_id = b.point_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$temp = [] ;
$temp['title'] = dataFilter( $row['title'] ) ;
$temp['content'] = dataFilter( $row['content'] ) ;
$temp['file'] = ( $row['file'] != '' ? PATH.'uploads/ProfilePoint/b/'.$row['file'] : '' ) ;
$temp['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list = $temp ;
}
// get total accumulated point
// 'system','staff_point_movement_cutoff','task','redeem','adjustment','training'
$select_movement = $mysqli->query( "SELECT SUM( amount ) as total FROM staff_point_movement
WHERE staff_id = '".$staff_info['staff_id']."' AND from_table IN ( 'system','task','adjustment','training' ) AND created_at LIKE '%".date('Y', time())."-%'" ) ;
if ( $select_movement->num_rows > 0 ){
$data_movement = $select_movement->fetch_assoc() ;
$total_accumulated = $data_movement['total'] ;
}
// get total redeem
$select_movement = $mysqli->query( "SELECT SUM( amount ) as total FROM staff_point_movement
WHERE staff_id = '".$staff_info['staff_id']."' AND from_table IN ( 'redeem' ) AND created_at LIKE '%".date('Y', time())."-%'" ) ;
if ( $select_movement->num_rows > 0 ){
$data_movement = $select_movement->fetch_assoc() ;
$total_redeem = $data_movement['total'] ;
$total_redeem = numberFormat( $total_redeem < 0 ? -( $total_redeem ) : 0 ) ;
}
$data['list'] = $list ;
$data['total_accumulated'] = $total_accumulated ;
$data['total_redeem'] = $total_redeem ;
}
// direct echo
if ( $array['iswebview'] == 'yes' ){
require( $require_path.'languages/'.$array['lang'].'.php' ) ;
$search_year = ( $array['search_year'] != '' ? $array['search_year'] : date('Y') ) ;
$search_type = ( $array['search_type'] != '' ? $array['search_type'] : 'personal' ) ;
$staff_settings = $staff_info['staff_settings'] ;
$months = [] ;
$months_name = [ $lang['Jan'], $lang['Feb'], $lang['Mar'], $lang['Apr'], $lang['May'], $lang['Jun'], $lang['Jul'], $lang['Aug'], $lang['Sep'], $lang['Oct'], $lang['Nov'], $lang['Dec'] ] ;
for ( $a = 1 ; $a <= 12 ; $a++ ){ $months[$a] = 0 ; }
// monthly report = by personal or whole branch
$array_report = [
'personal' => [
'yes' => $months
],
] ;
$filtertype = [] ;
foreach ( $array_report as $k => $v ){
if ( $k == $search_type ){
$filtertype[] = $k ;
}
}
foreach ( $filtertype as $k => $v ){
$search_query = " AND ( a.staff_id = '".$staff_info['staff_id']."' )" ;
$select_task = $mysqli->query( "SELECT SUM(a.staff_point_achievement) as total, MONTH(a.reported_at) as month FROM staff_monthly_achievement a
WHERE a.deleted_at IS NULL AND a.reported_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY MONTH(a.reported_at)" ) ;
if ( $select_task->num_rows > 0 ){
while ( $row_report = $select_task->fetch_assoc() ){
$array_report[$v]['yes'][$row_report['month']] = $row_report['total'] ;
}
}
}
$html .= '
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="'.PATH.'css/bootstrap.css?v='.filemtime($require_path.'css/bootstrap.css').'" />
<script src="'.PATH.'scripts/chart.js"></script>
</head>
<body>
<div class="report_chart_main">
<div class="report_chart_filter_year">
<a href="?search_year='.( $search_year - 1 ).resetGetParams($array, [ 'search_year' ]).'" class="report_chart_filter_year_button">
<i class="fa fa-chevron-left" aria-hidden="true"></i>
</a>
<span class="report_chart_filter_year_span">'. $search_year .'</span>
<a href="?search_year='.( $search_year + 1 ).resetGetParams($array, [ 'search_year' ]).'" class="report_chart_filter_year_button">
<i class="fa fa-chevron-right" aria-hidden="true"></i>
</a>
</div>' ;
foreach ( $array_report as $kreport => $vreport ){
if ( $kreport == $search_type ){
$title = $lang['By '.ucwords($kreport).' Report'] ;
$titlename = $title.' ( '.$lang['Year'].' '.$search_year.' )' ;
$html .= '
<div class="report_chart_line">
<canvas id="myChart'.$kreport.'"></canvas>
</div>
<script>
const ctx'.$kreport.' = document.getElementById("myChart'.$kreport.'") ;
const config'.$kreport.' = {
type : "line",
data : {
datasets : [
{
label : "'.$lang['Completed Task'].'",
data : [ "'.implode( '", "', $vreport['yes'] ).'" ]
}
],
labels : [ "'.implode( '", "', $months_name ).'" ]
},
options: {
responsive : true,
maintainAspectRatio : false,
plugins : {
legend : {
position : "top",
},
title : {
display : true,
text : "'.$titlename.'"
}
}
}
} ;
new Chart( ctx'.$kreport.', config'.$kreport.' ) ;
</script>' ;
}
}
$html .= '
</div>
</body>
</html>' ;
}
}
if ( $array['iswebview'] == 'yes' ){
echo $html ;
exit ;
}
require( $require_sub.'footer.php' ) ;
?>
+88
View File
@@ -0,0 +1,88 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
$html = '' ;
if ( $boolean_login ){
$status = '201' ;
$list = [] ;
if ( $array['iswebview'] == 'no' ){
$query = "SELECT a.file, a.created_at, b.title, b.content FROM profile_star a
LEFT JOIN profile_star_translation b ON ( a.star_id = b.star_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$temp = [] ;
$temp['title'] = dataFilter( $row['title'] ) ;
$temp['content'] = dataFilter( $row['content'] ) ;
$temp['file'] = ( $row['file'] != '' ? PATH.'uploads/ProfileStar/b/'.$row['file'] : '' ) ;
$temp['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list = $temp ;
}
$data['list'] = $list ;
}
// direct echo
if ( $array['iswebview'] == 'yes' ){
$get_monthly = getMonthlyAchievement( date('Y', time()), $staff_info['staff_id'] ) ;
$get_star[] = [ 'Month', 'Star' ] ;
foreach ( $get_monthly as $k => $v ){
$get_star[] = [ date('m', strtotime($v['reported_at'])), $v['staff_star'] ] ;
}
$html .= '
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<style> td{ padding: 5px; } </style>
</head>
<body>
<script type="text/javascript">
google.charts.load(\'current\', {\'packages\':[\'bar\']});
google.charts.setOnLoadCallback(drawStuff);
function drawStuff() {
var data = new google.visualization.arrayToDataTable( '.json_encode( $get_star ).' ) ;
var options = {
chart: { title: \'Yearly Star Report\' },
bars: \'vertical\'
} ;
var chart = new google.charts.Bar(document.getElementById(\'barchart\')) ;
chart.draw(data, options);
};
</script>
<div style="padding: 0 20px;">
<div id="barchart" style="width: 100%; height: 500px;"></div>
</div>
</body>
</html>' ;
}
}
if ( $array['iswebview'] == 'yes' ){
echo $html ;
exit ;
}
require( $require_sub.'footer.php' ) ;
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$list = [] ;
$query = "SELECT a.tier_id, a.file, a.created_at, b.title, b.sub, b.content FROM profile_tier a
LEFT JOIN profile_tier_translation b ON ( a.tier_id = b.tier_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' ORDER BY a.sortable ASC" ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
while ( $row = $mysqli_query->fetch_assoc() ){
$temp = [] ;
$temp['tier_id'] = dataFilter( $row['tier_id'] ) ;
$temp['title'] = dataFilter( $row['title'] ) ;
$temp['sub'] = dataFilter( $row['sub'] ) ;
$temp['content'] = dataFilter( $row['content'] ) ;
$temp['file'] = ( $row['file'] != '' ? PATH.'uploads/ProfileTier/b/'.$row['file'] : '' ) ;
$temp['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $temp ;
}
}
$data['list'] = $list ;
}
require( $require_sub.'footer.php' ) ;
?>
+18
View File
@@ -0,0 +1,18 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '206' ;
if ( $mysqli->query( "UPDATE staff SET
deleted_at = '".TODAYDATE."'
WHERE staff_id = '".$staff_info['staff_id']."'" ) ){
$status = '200' ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+56
View File
@@ -0,0 +1,56 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/sms.php' ) ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
if ( $array['current'] != '' && $array['password'] != '' && $array['confirm'] != '' ){
$status = '284' ;
$password = passwordEncrypt( $array['current'] ) ;
$mysqli_staff = $mysqli->query("SELECT staff_id, staff_idno, staff_name, staff_shortname, staff_username, staff_email, staff_mobileno, staff_image, job_position_id, job_section_id, staff_point_achievement, staff_point, staff_wallet, staff_tier, staff_achievement, staff_star FROM staff
WHERE deleted_at IS NULL AND ( staff_date_resigned IS NULL OR staff_date_resigned = '0000-00-00' ) AND staff_id = '".$staff_info['staff_id']."' AND staff_password = '".$password."' LIMIT 1") ;
if ( $mysqli_staff->num_rows > 0 ){
$status = '286' ;
if ( $array['password'] == $array['confirm'] ){
$status = '285' ;
if ( strlen( $array['password'] ) >= 6 ){
$status = '205' ;
$password = $staff_info['staff_id'].strPad( 6, rand(000000, 999999) ) ;
$enc_password = passwordEncrypt( $array['password'] ) ;
if ( $mysqli->query( "UPDATE staff SET
staff_password = '".$enc_password."'
WHERE staff_id = '".$staff_info['staff_id']."'" ) ){
$status = '208' ;
$mailer = new Mailer() ;
$mailer->from = EMAILNOREPLY ;
$mailer->to = [ $staff_info['staff_email'] ] ;
$mailer->subject = 'Change password' ;
$mailer->body = 'Your new password was success change to ' . $array['password'] ;
if ( $mailer->send() ){
$status = '200' ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+78
View File
@@ -0,0 +1,78 @@
<?php
$must_login = false ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
$employment_id = $array['employment_id'] ;
$date_time = $array['date_time'] ;
$date_group_yest = date('Y-m-d', strtotime($date_time.'-1 days')) ;
$date_group = date('Y-m-d', strtotime($date_time)) ;
$temperature = $array['temperature'] ;
$sn = $array['sn'] ;
if ( $employment_id != '' && $date_time != '' ){
$status = '201' ;
// get staff
$staffs_q = $mysqli->query("SELECT staff_id FROM staff
WHERE deleted_at IS NULL AND staff_idno = '".$employment_id."' LIMIT 1") ;
if ( $staffs_q->num_rows == 0 ){
$mysqli->query("INSERT INTO staff
(staff_idno, staff_name, staff_email, gender_id, staff_icno, staff_passportno, religion_id, ethnic_id, created_at, updated_at) VALUES
('".$employment_id."', '', '', '0', '', '', '0', '0', '".TODAYDATE."', '".TODAYDATE."')") ;
$staff_id = $mysqli->insert_id ;
}else{
$staff = $staffs_q->fetch_assoc() ;
$staff_id = $staff['staff_id'] ;
}
$last_attendance_q = $mysqli->query("SELECT type FROM staff_attendance
WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' AND check_group = '".$date_group_yest."' ORDER BY attendance_id DESC LIMIT 1") ;
$check_type = 'in' ;
if ( $last_attendance_q->num_rows > 0 ){
// check if last attendance is in
$last_attendance = $last_attendance_q->fetch_assoc() ;
if ( $last_attendance['type'] == 'in' ){
$date_group = $date_group_yest ;
$check_type = 'out' ;
}
}
if ( $check_type != 'out' ){
$current_attendance_q = $mysqli->query("SELECT type FROM staff_attendance
WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' AND check_group = '".$date_group."' ORDER BY attendance_id DESC LIMIT 1") ;
if ( $current_attendance_q->num_rows > 0 ){
// check if last attendance is in
$current_attendance = $current_attendance_q->fetch_assoc() ;
if ( $current_attendance['type'] == 'in' ){
$check_type = 'out' ;
}
}
}
// check if staff and time exists
$check = $mysqli->query("SELECT * FROM staff_attendance
WHERE record_from = 'machine' AND staff_id = '".$staff_id."' AND created_at = '".$date_time."' LIMIT 1") ;
if ( $check->num_rows == 0 ){
// set information into staff_attendance
if ( $mysqli->query("INSERT INTO staff_attendance
(staff_id, check_group, type, code, record_from, mac_address, ip_address, latitude, longitude, check_area, temperature, created_at, updated_at) VALUES
('".$staff_id."', '".$date_group."', '".$check_type."', '".$sn."', 'machine', '', '', '', '', 'in', '".$temperature."', '".$date_time."', '".$date_time."')") ){
$status = '200' ;
}
}else{
$status = '200' ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+50
View File
@@ -0,0 +1,50 @@
<?php
$must_login = false ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
$status = '201' ;
$select_staff = $mysqli->query( "SELECT staff_id, staff_idno, staff_name, staff_shortname, staff_image, branch_id FROM staff
WHERE deleted_at IS NULL AND ( staff_date_resigned >= '".date( "Y-m-d", time() )."' OR staff_date_resigned = '0000-00-00' OR staff_date_resigned IS NULL ) AND updated_at >= '".date( "Y-m-d H:i:s", strtotime("-1 minutes") )."'" ) ;
if ( $select_staff->num_rows > 0 ){
$status = '200' ;
$array_branch = [] ;
$select_branch = $mysqli->query( "SELECT * FROM branch
WHERE deleted_at IS NULL" ) ;
if ( $select_branch->num_rows > 0 ){
while ( $row_branch = $select_branch->fetch_assoc() ){
$array_branch[$row_branch['branch_id']] = $row_branch ;
}
}
while ( $row_staff = $select_staff->fetch_assoc() ){
$staff_image = ( $row_staff['staff_image'] != '' ? PATH.'uploads/Staff/'.dataFilter($row_staff['staff_image']) : '' ) ;
$punch_companyid = PUNCHCOMPANYID ;
if ( $row_staff['branch_id'] > 0 ){
if ( arrayCheck( $array_branch[$row_staff['branch_id']] ) ){
if ( $array_branch[$row_staff['branch_id']]['branch_binding_id'] > 0 ){
$punch_companyid = $array_branch[$row_staff['branch_id']]['branch_binding_id'] ;
}
}
}
call( 'curl', PUNCHURL.'/api/user.php', 'POST', [], [
'company_id' => $punch_companyid,
'staff_idno' => $row_staff['staff_idno'],
'staff_name' => $row_staff['staff_name'],
'staff_shortname' => $row_staff['staff_shortname'],
'staff_image' => $staff_image
] ) ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+46
View File
@@ -0,0 +1,46 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$list = [] ;
$query = '' ;
$mysqli_category = $mysqli->query( "SELECT a.category_id, b.title FROM rms_bill_category a
LEFT JOIN rms_bill_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' ORDER BY a.sortable ASC" ) ;
if ( $mysqli_category->num_rows > 0 ){
$status = '200' ;
$items = [] ;
$mysqli_item = $mysqli->query( "SELECT a.item_id, a.category_id, a.min_amount, a.max_amount, a.is_reference1, a.is_reference2, a.is_reference3, a.is_reference4, a.file, b.title, b.content, b.reference1, b.reference2, b.reference3, b.reference4 FROM rms_bill_item a
LEFT JOIN rms_bill_item_translation b ON ( a.item_id = b.item_id )
WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' ORDER BY a.sortable ASC" ) ;
if ( $mysqli_item->num_rows > 0 ){
while ( $row_item = $mysqli_item->fetch_assoc() ){
$row_item['title'] = dataFilter( $row_item['title'] ) ;
$row_item['content'] = dataFilter( $row_item['content'] ) ;
$row_item['file'] = ( $row_item['file'] != '' ? PATH.'uploads/RmsBillItem/b/'.$row_item['file'] : '' ) ;
$items[$row_item['category_id']][] = $row_item ;
}
}
while ( $row_category = $mysqli_category->fetch_assoc() ){
$row_category['id'] = dataFilter( $row_category['category_id'] ) ;
$row_category['title'] = dataFilter( $row_category['title'] ) ;
$row_category['items'] = ( $items[$row_category['category_id']] != null ? $items[$row_category['category_id']] : [] ) ;
$list[] = $row_category ;
}
}
$data['list'] = $list ;
}
require( $require_sub.'footer.php' ) ;
?>
+86
View File
@@ -0,0 +1,86 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$bill_id = $array['bill_id'] ;
$amount = $array['amount'] ;
if ( $bill_id != '' && $amount > 0 ){
$status = '250' ;
$amount = numberFormat( $amount, 2 ) ;
if ( $staff_info['staff_wallet'] >= $amount ){
$status = '201' ;
$select_bill = $mysqli->query( "SELECT a.bill_id, a.reference1, a.reference2, a.reference3, a.reference4, b.biller_code, b.min_amount, b.max_amount FROM staff_rms_bill a
LEFT JOIN rms_bill_item b ON ( a.item_id = b.item_id )
WHERE a.deleted_at IS NULL AND b.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.bill_id = '".$bill_id."' LIMIT 1" ) ;
if ( $select_bill->num_rows > 0 ){
$status = 'rms-39' ;
$row_bill = $select_bill->fetch_assoc() ;
if ( $amount >= $row_bill['min_amount'] && $amount <= $row_bill['max_amount'] ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO staff_rms_bill_order
( `branch_id`, `staff_id`, `bill_id`, `biller_code`, `cashier_id`, `reference1`, `reference2`, `reference3`, `reference4`, `amount` ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$bill_id."', '".$row_bill['biller_code']."', '".RMSLOCATION."', '".$row_bill['reference1']."', '".$row_bill['reference2']."', '".$row_bill['reference3']."', '".$row_bill['reference4']."', '".$amount."' )" ) ){
// update sonumber
$order_id = $mysqli->insert_id ;
$sonumber = 'BO'.strPad( 6, $order_id ) ;
$mysqli->query( "UPDATE staff_rms_bill_order SET sonumber = '".$sonumber."' WHERE order_id = '".$order_id."'" ) ;
$rms_content = [
'referenceId' => $sonumber,
'billerCode' => $row_bill['biller_code'],
'billReferenceNo1' => $row_bill['reference1'],
'billReferenceNo2' => $row_bill['reference2'],
'billReferenceNo3' => $row_bill['reference3'],
'billReferenceNo4' => $row_bill['reference4'],
'amount' => $amount
] ;
$rms_call = rmsCall( 'bill/initiate', $rms_content ) ;
saveLog( 'rms-api', 'Intiate Bill Order', $rms_content, $rms_call ) ;
if ( $rms_call['respCode'] == '00' ){
$status = '298' ;
// deduct the wallet first
$remark = 'You have been deducted the wallet from bill order '.$row_bill['reference1'].' (' . $sonumber . ')' ;
$walletdeduct = walletMovement( 'staff_rms_bill_order', $order_id, 'minus', 'normal', $staff_info['staff_id'], -($amount), $remark ) ;
if ( $walletdeduct ){
$status = '200' ;
// update status
$mysqli->query( "UPDATE staff_rms_bill_order SET
rms_accountname = '".$rms_call['billAccountName']."',
rms_instruction = '".$rms_call['instruction']."',
rms_authorizationtoken = '".$rms_call['authorizationToken']."',
status = 'pending'
WHERE order_id = '".$order_id."'" ) ;
}
}else{
$status = 'rms-'.$rms_call['respCode'] ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+25
View File
@@ -0,0 +1,25 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$mysqli_bill = $mysqli->query( "SELECT a.bill_id FROM staff_rms_bill a
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.bill_id = '".$array['bill_id']."'" ) ;
if ( $mysqli_bill->num_rows > 0 ){
$status = '200' ;
$mysqli->query( "UPDATE staff_rms_bill SET
deleted_at = '".TODAYDATE."'
WHERE bill_id = '".$array['bill_id']."'" ) ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+28
View File
@@ -0,0 +1,28 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$query = "SELECT a.sonumber, a.biller_code, a.reference1, a.reference2, a.reference3, a.reference4, a.amount, a.status, a.created_at, b.title, c.file FROM staff_rms_bill_order a
LEFT JOIN staff_rms_bill b ON ( a.bill_id = b.bill_id )
LEFT JOIN rms_bill_item c ON ( b.item_id = c.item_id )
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.order_id = '".$array['id']."'" ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/RmsBillItem/b/'.$row['file'] : '' ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+52
View File
@@ -0,0 +1,52 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$searchfilter = $array['searchfilter'] ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND ( a.sonumber LIKE '%".$array['search']."%' OR a.reference1 LIKE '%".$array['search']."%' OR b.title LIKE '%".$array['search']."%' )" ;
}
switch ( $searchfilter ){
case 'pending' :
$search_query .= " AND a.status IN ( 'new', 'pending', 'progress' )" ;
break ;
case 'confirmed' :
$search_query .= " AND a.status IN ( 'confirmed' )" ;
break ;
case 'cancelled' :
$search_query .= " AND a.status IN ( 'cancelled', 'failed' )" ;
break ;
}
$query = "SELECT a.order_id, a.sonumber, a.biller_code, a.reference1, a.reference2, a.reference3, a.reference4, a.amount, a.status, a.created_at, b.title, c.file FROM staff_rms_bill_order a
LEFT JOIN staff_rms_bill b ON ( a.bill_id = b.bill_id )
LEFT JOIN rms_bill_item c ON ( b.item_id = c.item_id )
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.order_id DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['order_status'] = ( checkExists( $row['status'] ) != '' ? $row['status'] : '' ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/RmsBillItem/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+29
View File
@@ -0,0 +1,29 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$list = [] ;
$mysqli_bill = $mysqli->query( "SELECT a.bill_id, a.item_id, a.title, a.reference1, a.reference2, a.reference3, a.reference4, a.created_at, b.is_reference1, b.is_reference2, b.is_reference3, b.is_reference4, c.reference1 as reference1_title, c.reference2 as reference2_title, c.reference3 as reference3_title, c.reference4 as reference4_title FROM staff_rms_bill a
LEFT JOIN rms_bill_item b ON ( a.item_id = b.item_id )
LEFT JOIN rms_bill_item_translation c ON ( b.item_id = c.item_id )
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.item_id = '".$array['item_id']."' AND b.deleted_at IS NULL AND b.status = 'active' AND c.lang = '".$array['lang']."'" ) ;
if ( $mysqli_bill->num_rows > 0 ){
$status = '200' ;
while ( $row_bill = $mysqli_bill->fetch_assoc() ){
$list[] = $row_bill ;
}
}
$data['list'] = $list ;
}
require( $require_sub.'footer.php' ) ;
?>
+58
View File
@@ -0,0 +1,58 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$item_id = $array['item_id'] ;
$title = $array['title'] ;
$reference1 = $array['reference1'] ;
$reference2 = $array['reference2'] ;
$reference3 = $array['reference3'] ;
$reference4 = $array['reference4'] ;
if ( $array['item_id'] != '' && $array['title'] != '' ){
$status = '201' ;
$select_item = $mysqli->query( "SELECT is_reference1, is_reference2, is_reference3, is_reference4 FROM rms_bill_item
WHERE deleted_at IS NULL AND status = 'active' AND item_id = '".$item_id."' LIMIT 1" ) ;
if ( $select_item->num_rows > 0 ){
$status = '300' ;
$row_item = $select_item->fetch_assoc() ;
$is_error = 0 ;
if ( $row_item['is_reference1'] == 'yes' && $reference1 == '' ){
$is_error++ ;
}
if ( $row_item['is_reference2'] == 'yes' && $reference2 == '' ){
$is_error++ ;
}
if ( $row_item['is_reference3'] == 'yes' && $reference3 == '' ){
$is_error++ ;
}
if ( $row_item['is_reference4'] == 'yes' && $reference4 == '' ){
$is_error++ ;
}
if ( $is_error == 0 ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO staff_rms_bill
( `branch_id`, `staff_id`, `item_id`, `title`, `reference1`, `reference2`, `reference3`, `reference4` ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['item_id']."', '".$array['title']."', '".$array['reference1']."', '".$array['reference2']."', '".$array['reference3']."', '".$array['reference4']."' )" ) ){
$status = '200' ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+65
View File
@@ -0,0 +1,65 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$item_id = $array['item_id'] ;
$lists = $array['lists'] ;
if ( $item_id != '' && count( $array['lists'] ) > 0 ){
$status = '201' ;
$select_item = $mysqli->query( "SELECT is_reference1, is_reference2, is_reference3, is_reference4 FROM rms_bill_item
WHERE deleted_at IS NULL AND status = 'active' AND item_id = '".$item_id."' LIMIT 1" ) ;
if ( $select_item->num_rows > 0 ){
$status = '300' ;
$row_item = $select_item->fetch_assoc() ;
$is_error = 0 ;
foreach ( $lists as $k => $v ){
if ( $row_item['is_reference1'] == 'yes' && $v['reference1'] == '' ){
$is_error++ ;
}
if ( $row_item['is_reference2'] == 'yes' && $v['reference2'] == '' ){
$is_error++ ;
}
if ( $row_item['is_reference3'] == 'yes' && $v['reference3'] == '' ){
$is_error++ ;
}
if ( $row_item['is_reference4'] == 'yes' && $v['reference4'] == '' ){
$is_error++ ;
}
}
if ( $is_error == 0 ){
$status = '203' ;
$is_update = false ;
foreach ( $lists as $k => $v ){
if ( $mysqli->query( "UPDATE staff_rms_bill SET
title = '".$v['title']."',
reference1 = '".$v['reference1']."',
reference2 = '".$v['reference2']."',
reference3 = '".$v['reference3']."',
reference4 = '".$v['reference4']."'
WHERE bill_id = '".$v['bill_id']."'" ) ){
$is_update = true ;
}
}
if ( $is_update ){
$status = '200' ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+68
View File
@@ -0,0 +1,68 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = 'rms-47' ;
$item_id = $array['item_id'] ;
$dialcode = $array['dialcode'] ;
$mobile = $array['mobile'] ;
if ( $item_id != '' && $dialcode != '' && $mobile != '' ){
$status = '203' ;
$dialcode = str_replace( '+', '', $dialcode ) ;
$referenceid = strPad( '5', $staff_info['staff_id'] ) . time() . strPad( '5', rand( 0, 99999 ) ) ;
if ( $mysqli->query( "INSERT INTO staff_rms_prepaid_pretemp
( `referenceid`, `item_id`, `dialcode`, `mobile` ) VALUES
( '".$referenceid."', '".$item_id."', '".$dialcode."', '".$mobile."' )" ) ){
$temp_id = $mysqli->insert_id ;
// $rms_content = [
// 'referenceId' => $referenceid,
// 'countryCode' => $dialcode,
// 'mobileNumber' => $mobile
// ] ;
// $rms_call = rmsCall( 'pinless/getproductidlistbymobilenumber', $rms_content ) ;
// saveLog( 'rms-api', 'Check Prepaid Mobile Number', $rms_content, $rms_call ) ;
// if ( $rms_call['respCode'] == '00' ){
// $status = '202' ;
// if ( $mysqli->query( "UPDATE staff_rms_prepaid_pretemp SET
// rms_authorizationtoken = '".$rms_call['authorizationToken']."',
// status = 'progress'
// WHERE temp_id = '".$temp_id."'" ) ){
// $status = '200' ;
// $data = [
// 'temp_id' => $temp_id
// ] ;
// }
// }else{
// $status = 'rms-'.$rms_call['respCode'] ;
// }
$status = '202' ;
if ( $mysqli->query( "UPDATE staff_rms_prepaid_pretemp SET
status = 'progress'
WHERE temp_id = '".$temp_id."'" ) ){
$status = '200' ;
$data = [
'temp_id' => $temp_id
] ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+88
View File
@@ -0,0 +1,88 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$temp_id = $array['temp_id'] ;
$item_id = $array['item_id'] ;
$deno_id = $array['deno_id'] ;
$dialcode = $array['dialcode'] ;
$mobile = $array['mobile'] ;
if ( $temp_id != '' && $item_id != '' && $deno_id != '' ){
$dialcode = str_replace( '+', '', $dialcode ) ;
$select_deno = $mysqli->query( "SELECT deno_code, amount FROM rms_prepaid_deno
WHERE deleted_at IS NULL AND item_id = '".$item_id."' AND deno_id = '".$deno_id."' AND status = 'active' LIMIT 1" ) ;
if ( $select_deno->num_rows > 0 ){
$row_deno = $select_deno->fetch_assoc() ;
$amount = numberFormat( $row_deno['amount'], 2 ) ;
$select_temp = $mysqli->query( "SELECT rms_authorizationtoken FROM staff_rms_prepaid_pretemp
WHERE deleted_at IS NULL AND temp_id = '".$temp_id."' AND item_id = '".$item_id."' AND dialcode = '".$dialcode."' AND mobile = '".$mobile."' LIMIT 1" ) ;
if ( $select_temp->num_rows > 0 ){
$status = '250' ;
$row_temp = $select_temp->fetch_assoc() ;
if ( $amount > 0 && $staff_info['staff_wallet'] >= $amount ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO staff_rms_prepaid_order
( `branch_id`, `staff_id`, `temp_id`, `item_id`, `deno_id`, `deno_code`, `cashier_id`, `dialcode`, `mobile`, `amount` ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$temp_id."', '".$item_id."', '".$deno_id."', '".$row_deno['deno_code']."', '".RMSLOCATION."', '".$dialcode."', '".$mobile."', '".$amount."' )" ) ){
// update sonumber
$order_id = $mysqli->insert_id ;
$sonumber = 'TO'.strPad( 6, $order_id ) ;
$mysqli->query( "UPDATE staff_rms_prepaid_order SET sonumber = '".$sonumber."' WHERE order_id = '".$order_id."'" ) ;
$status = '298' ;
// deduct the wallet first
$remark = 'You have been deducted the wallet from prepaid order '.$dialcode.'-'.$mobile.' (' . $sonumber . ')' ;
$walletdeduct = walletMovement( 'staff_rms_prepaid_order', $order_id, 'minus', 'normal', $staff_info['staff_id'], -($amount), $remark ) ;
if ( $walletdeduct ){
$status = '200' ;
$rms_content = [
'referenceId' => $sonumber,
'cashierId' => RMSLOCATION,
'productCode' => $row_deno['deno_code'],
'transactionDateTime' => date( "Y-m-d\TH:i:s", time() ),
'businessDate' => date( "Y-m-d", time() ),
'countryCode' => $dialcode,
'mobileNumber' => $mobile,
'partnerReferenceId' => $sonumber
] ;
$rms_call = rmsCall( 'pinless/requesttopup', $rms_content ) ;
saveLog( 'rms-api', 'Request Prepaid Order', $rms_content, $rms_call ) ;
// update status
$mysqli->query( "UPDATE staff_rms_prepaid_order SET
rms_instruction = '".$rms_call['instructions']."',
rms_order_id = '".$rms_call['orderId']."',
status = 'pending'
WHERE order_id = '".$order_id."'" ) ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+28
View File
@@ -0,0 +1,28 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$query = "SELECT a.order_id, a.sonumber, a.deno_code, a.dialcode, a.mobile, a.amount, a.status, a.created_at, b.file , c.title FROM staff_rms_prepaid_order a
LEFT JOIN rms_prepaid_item b ON ( a.item_id = b.item_id )
LEFT JOIN rms_prepaid_deno_translation c ON ( a.deno_id = c.deno_id )
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND c.lang = '".$array['lang']."' AND a.order_id = '".$array['id']."'" ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/RmsPrepaidItem/b/'.$row['file'] : '' ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+52
View File
@@ -0,0 +1,52 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$searchfilter = $array['searchfilter'] ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND ( a.sonumber LIKE '%".$array['search']."%' OR a.dialcode LIKE '%".$array['search']."%' OR a.mobile LIKE '%".$array['search']."%' OR c.title LIKE '%".$array['search']."%' )" ;
}
switch ( $searchfilter ){
case 'pending' :
$search_query .= " AND a.status IN ( 'new', 'pending', 'progress' )" ;
break ;
case 'confirmed' :
$search_query .= " AND a.status IN ( 'confirmed' )" ;
break ;
case 'cancelled' :
$search_query .= " AND a.status IN ( 'cancelled', 'failed' )" ;
break ;
}
$query = "SELECT a.order_id, a.sonumber, a.deno_code, a.dialcode, a.mobile, a.amount, a.status, a.created_at, b.file , c.title FROM staff_rms_prepaid_order a
LEFT JOIN rms_prepaid_item b ON ( a.item_id = b.item_id )
LEFT JOIN rms_prepaid_deno_translation c ON ( a.deno_id = c.deno_id )
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND c.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.order_id DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['order_status'] = ( checkExists( $row['status'] ) != '' ? $row['status'] : '' ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/RmsPrepaidItem/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+45
View File
@@ -0,0 +1,45 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$list = [] ;
$query = '' ;
$mysqli_item = $mysqli->query( "SELECT a.item_id, a.file, b.title FROM rms_prepaid_item a
LEFT JOIN rms_prepaid_item_translation b ON ( a.item_id = b.item_id )
WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' ORDER BY a.sortable ASC" ) ;
if ( $mysqli_item->num_rows > 0 ){
$status = '200' ;
$denos = [] ;
$mysqli_deno = $mysqli->query( "SELECT a.deno_id, a.item_id, b.title FROM rms_prepaid_deno a
LEFT JOIN rms_prepaid_deno_translation b ON ( a.deno_id = b.deno_id )
WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' ORDER BY a.sortable ASC" ) ;
if ( $mysqli_deno->num_rows > 0 ){
while ( $row_deno = $mysqli_deno->fetch_assoc() ){
$row_deno['title'] = dataFilter( $row_deno['title'] ) ;
$denos[$row_deno['item_id']][] = $row_deno ;
}
}
while ( $row_item = $mysqli_item->fetch_assoc() ){
$row_item['id'] = dataFilter( $row_item['item_id'] ) ;
$row_item['title'] = dataFilter( $row_item['title'] ) ;
$row_item['file'] = ( $row_item['file'] != '' ? PATH.'uploads/RmsPrepaidItem/b/'.$row_item['file'] : '' ) ;
$row_item['denos'] = ( $denos[$row_item['item_id']] != null ? $denos[$row_item['item_id']] : [] ) ;
$list[] = $row_item ;
}
}
$data['list'] = $list ;
}
require( $require_sub.'footer.php' ) ;
?>
+71
View File
@@ -0,0 +1,71 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
$status = '300' ;
$qrocde = $array['qrcode'] ;
if ( $qrocde != '' ){
$status = '307' ;
if ( strpos($qrocde, 'AS') !== false ) {
$status = '303' ;
if ( $staff_info['staff_settings']['checkassociation'] == 'yes' ){
$status = '201' ;
$select = $mysqli->query( "SELECT view_id, status FROM staff_association
WHERE deleted_at IS NULL AND association_so = '".$qrocde."' LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '299' ;
$row = $select->fetch_assoc() ;
if ( $row['status'] == 'approved' ){
$status = '200' ;
$mysqli->query( "UPDATE staff_association SET
status = 'confirmed'
WHERE view_id = '".$row['view_id']."'" ) ;
}
}
}
}
if ( strpos($qrocde, 'TN') !== false ) {
$status = '303' ;
if ( $staff_info['staff_settings']['checktraining'] == 'yes' ){
$status = '201' ;
$select = $mysqli->query( "SELECT view_id, status FROM staff_training
WHERE deleted_at IS NULL AND training_so = '".$qrocde."' LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '299' ;
$row = $select->fetch_assoc() ;
if ( $row['status'] == 'approved' ){
$status = '200' ;
$mysqli->query( "UPDATE staff_training SET
status = 'confirmed'
WHERE view_id = '".$row['view_id']."'" ) ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+109
View File
@@ -0,0 +1,109 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_path.'extensions/sms.php' ) ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
$status = '300' ;
$visitor_id = $array['visitor_id'] ;
$photos = $array['photos'] ;
if ( $visitor_id != '' ){
$status = '245' ;
if ( checkExists($photos) ){
$status = '303' ;
if ( $staff_info['staff_settings']['checkvisitation'] == 'yes' ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM visitor
WHERE deleted_at IS NULL AND visitor_id = '".$visitor_id."' LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '306' ;
$row_visitor = $select->fetch_assoc() ;
$branch_hr_contact = '' ;
$branch_hr_email = '' ;
$branch_hr_cc = [] ;
$branch_email_footer = '' ;
$mysqli_query = "SELECT branch_hr_email, branch_hr_cc, branch_hr_contact, branch_email_footer FROM branch WHERE
deleted_at IS NULL AND branch_id = '".$row_visitor['branch']."' LIMIT 1" ;
$mysqli_branch = $mysqli->query($mysqli_query) ;
if ( $mysqli_branch->num_rows > 0 ){
$row_branch = $mysqli_branch->fetch_assoc() ;
$branch_hr_contact = dataFilter( $row_branch['branch_hr_contact'] ) ;
$branch_hr_email = dataFilter( $row_branch['branch_hr_email'] ) ;
$branch_hr_cc = explodeToArray( $row_branch['branch_hr_cc'] ) ;
$branch_email_footer = entityDecode( dataFilter( $row_branch['branch_email_footer'] ) ) ;
}
$file_name = '' ;
// upload file
$count_upload = 0 ;
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'Visitor', 'visiter-'.$visitor_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$file_name = $upload['data']['file_name'] ;
}
}
}
if ( $count_upload == 0 ){
$status = '308' ;
if ( $row_visitor['status'] == 'tested-approved' || $row_visitor['status'] == 'visited' ){
$status = '257' ;
$visited_at = date( 'Y-m-d', strtotime( $row_visitor['visited_at'] ) ) ;
$visited_at_to = date( 'Y-m-d', strtotime( $row_visitor['visited_at_to'] ) ) ;
if ( $visited_at <= TODAYDAY && $visited_at_to >= TODAYDAY ){
$status = '200' ;
$mysqli->query( "INSERT INTO visitor_checkin ( visitor_id, checkin_file ) VALUES ( '".$visitor_id."', '".$file_name."' )" ) ;
$mysqli->query( "UPDATE visitor SET status = 'visited' WHERE visitor_id = '".$visitor_id."'" ) ;
$body = 'Dear valued visitor,<br /><br />Thank you for your submission. Welcome to '.COMPANYSHORT.'! <br /><br />by ' . COMPANY . '!' . $branch_email_footer ;
$body_sms = 'Dear valued visitor, thank you for your submission. Welcome to '.COMPANYSHORT.'!' ;
$mailer = new Mailer() ;
$mailer->from = $branch_hr_email ;
$mailer->fromname = COMPANY ;
$mailer->to = [ $row_visitor['email'] ] ;
if ( count($branch_hr_cc) > 0 ){
$mailer->cc = $branch_hr_cc ;
}
$mailer->subject = 'Visitor Checked In' ;
$mailer->body = $body ;
$mailer->send() ;
if ( substr( $row_visitor['mobile'], 0, 2 ) == '60' || substr( $row_visitor['mobile'], 0, 3 ) == '+60' ||
substr( $row_visitor['mobile'], 0, 2 ) == '65' || substr( $row_visitor['mobile'], 0, 3 ) == '+65' ){
$sms = new Sms() ;
$sms->to = $row_visitor['mobile'] ;
$sms->message = $body_sms ;
$sms->send() ;
}
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+67
View File
@@ -0,0 +1,67 @@
<?php
$must_login = true ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
$status = '300' ;
$qrocde = $array['qrcode'] ;
if ( $qrocde != '' ){
$status = '303' ;
if ( $staff_info['staff_settings']['checkvisitation'] == 'yes' ){
$status = '201' ;
$select = $mysqli->query( "SELECT * FROM visitor
WHERE deleted_at IS NULL AND visitor_id = '".$qrocde."' LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
$status = '200' ;
$row_visitor = $select->fetch_assoc() ;
// get branch name
$branch_name = '' ;
$mysqli_query = "SELECT branch_id, branch_name FROM branch
WHERE branch_id = '".$row_visitor['branch']."' LIMIT 1" ;
$mysqli_branch = $mysqli->query($mysqli_query) ;
if ( $mysqli_branch->num_rows > 0 ){
$row_branch = $mysqli_branch->fetch_assoc() ;
$branch_name = $row_branch['branch_name'] ;
}
$is_showbutton = 'no' ;
$visited_at = date( 'Y-m-d', strtotime( $row_visitor['visited_at'] ) ) ;
$visited_at_to = date( 'Y-m-d', strtotime( $row_visitor['visited_at_to'] ) ) ;
if ( $visited_at <= TODAYDAY && $visited_at_to >= TODAYDAY ){
$is_showbutton = 'yes' ;
}
$data = [
'visitor_id' => dataFilter( $row_visitor['visitor_id'] ),
'appointment_date' => date( 'Y-m-d H:iA', strtotime( $row_visitor['visited_at'] ) ) . ' ~ ' . date( 'Y-m-d H:iA', strtotime( $row_visitor['visited_at_to'] ) ),
'branch_name' => dataFilter( $branch_name ),
'visitor_category' => ucwords( dataFilter( $row_visitor['category'] ) ),
'visitor_name' => dataFilter( $row_visitor['name'] ),
'contact_number' => dataFilter( $row_visitor['mobile'] ),
'email' => dataFilter( $row_visitor['email'] ),
'nric_passport' => dataFilter( $row_visitor['identity'] ),
'nationality' => dataFilter( $row_visitor['nationality'] ),
'visitor_company' => ucwords( dataFilter( $row_visitor['visitor_company'] ) ),
'car_plate' => dataFilter( $row_visitor['car_plate'] ),
'reason_to_visit' => dataFilter( $row_visitor['reason'] ),
'contact_person' => dataFilter( $row_visitor['contact_person'] ),
'status' => dataFilter( $row_visitor['status'] ),
'is_showbutton' => $is_showbutton
] ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+150
View File
@@ -0,0 +1,150 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
$adjustments = [ 'plus' => [], 'minus' => [] ] ;
$staffs = [] ;
$departments = [] ;
$staff_departments = [] ;
$all_tier = getAllTier( $array['lang'] ) ;
// select all adjustment
$query_setting = " AND set_tier LIKE '%|".$staff_info['staff_tier']."|%'" ;
switch ( $staff_info['staff_tier_is_adjustment'] ){
case 'yes' :
// do nothing
break ;
default :
$query_setting = " AND a.adjustment_mode = 'fixed'" ;
}
$select = $mysqli->query( "SELECT a.adjustment_id, a.adjustment_type, a.adjustment_mode, a.point, b.title FROM setting_adjustment a
LEFT JOIN setting_adjustment_translation b ON ( a.adjustment_id = b.adjustment_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.adjustment_site = 'frontend' ".$query_setting." ORDER BY a.sortable" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$adjustments[$row['adjustment_type']][] = [
'id' => $row['adjustment_id'],
'mode' => $row['adjustment_mode'],
'title' => dataFilter( $row['title'] ),
'point' => $row['point']
] ;
}
}
// select all staff
$staff_tier = [] ;
$staff_tier = getRelatedTierID( 'no', $staff_info['staff_tier_level'] ) ;
$where_staff = '' ;
$where_branch = '' ;
if ( $staff_info['staff_settings']['adjustmentbranch'] != 'yes' ){
$where_staff .= " AND a.branch_id = '".$array['branch_id']."'" ;
$where_branch .= " AND a.branch_id = '".$array['branch_id']."'" ;
}
// select all staff
$select = $mysqli->query( "SELECT a.staff_id, a.branch_id, a.staff_idno, a.staff_name, a.staff_shortname, a.staff_tier FROM staff a
WHERE a.deleted_at IS NULL AND a.staff_id != '".$staff_info['staff_id']."' AND a.staff_tier IN ( '".implode("', '", $staff_tier)."' ) AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL ) " . $where_staff ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$get_staff_tier = $all_tier[$row['staff_tier']] ;
$staffs[$row['staff_id']] = [
'id' => $row['staff_id'],
'branch_id' => $row['branch_id'],
'title' => $row['staff_shortname'] . ' ('.$row['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')',
'name' => $row['staff_name'],
'tier' => $get_staff_tier['level']
] ;
}
}
// select all department
$select = $mysqli->query( "SELECT a.department_id, b.department_desc FROM setting_department a
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$departments[] = $row ;
}
}
// select all branch
$branches = [] ;
$select_branch = $mysqli->query( "SELECT branch_id, branch_name FROM branch a
WHERE a.deleted_at IS NULL" . $where_branch ) ;
if ( $select_branch->num_rows > 0 ){
while ( $row_branch = $select_branch->fetch_assoc() ){
$branches[] = [
'id' => $row_branch['branch_id'],
'title' => dataFilter( $row_branch['branch_name'] )
] ;
}
}
// select all staff department
$select = $mysqli->query( "SELECT a.staff_id, a.department_id FROM staff_department a
WHERE a.deleted_at IS NULL" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
if ( $staffs[ $row['staff_id'] ] != null && $staffs[ $row['staff_id'] ] != undefined ){
$staff = $staffs[ $row['staff_id'] ] ;
$staff_departments[$staff['branch_id']][$row['department_id']][] = $staff ;
}
}
}
$reset_branches = [] ;
foreach ( $branches as $kbranch => $vbranch ){
// reset
$reset_departments = [] ;
$reset_departments[] = [
'id' => '0',
'title' => 'Cross Department',
'staffs' => []
] ;
foreach ( $departments as $k => $v ){
if ( $staff_departments[$vbranch['id']][$v['department_id']] != null && $staff_departments[$vbranch['id']][$v['department_id']] != undefined ){
$reset_departments[] = [
'id' => $v['department_id'],
'title' => $v['department_desc'],
'staffs' => $staff_departments[$vbranch['id']][$v['department_id']]
] ;
}
}
$reset_branches[] = [
'id' => $vbranch['id'],
'title' => $vbranch['title'],
'departments' => $reset_departments
] ;
}
$data = [
'adjustments' => $adjustments,
'default_branch' => $array['branch_id'],
'branches' => $reset_branches
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+61
View File
@@ -0,0 +1,61 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
// select all department
$department_list = [] ;
$select = $mysqli->query( "SELECT a.department_id, b.department_desc FROM setting_department a
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$department_list[$row['department_id']] = $row['department_desc'] ;
}
}
// select all staff
$staff_list = [] ;
$select = $mysqli->query( "SELECT a.staff_id, a.staff_name, a.staff_shortname, a.staff_idno FROM staff a
WHERE a.deleted_at IS NULL AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL )" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$staff_list[$row['staff_id']] = $row['staff_shortname'] . ' ( '.$row['staff_idno'].' )' ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND ( a.remark LIKE '%".$array['search']."%' OR b.title LIKE '%".$array['search']."%' )" ;
}
$query = "SELECT a.adjustment_id, a.adjustment_so, a.adjustment_type, a.created_by, a.department_id, a.point, a.remark, a.created_at, b.title FROM staff_adjustment a
LEFT JOIN setting_adjustment_translation b ON ( a.setting_adjustment_id = b.adjustment_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND ( a.created_branch_id = '".$array['branch_id']."' AND a.created_by = '".$staff_info['staff_id']."' ) " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.adjustment_id DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['department'] = $department_list[ $row['department_id'] ] ;
$row['created_by_name'] = $staff_list[ $row['created_by'] ] ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+172
View File
@@ -0,0 +1,172 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
require( $require_path.'languages/'.$array['lang'].'.php' ) ;
$html = '' ;
if ( $boolean_login ){
$status = '201' ;
$search_year = ( $array['search_year'] != '' ? $array['search_year'] : date('Y') ) ;
$search_type = ( $array['search_type'] != '' ? $array['search_type'] : 'personal' ) ;
$staff_settings = $staff_info['staff_settings'] ;
$months = [] ;
$months_name = [ $lang['Jan'], $lang['Feb'], $lang['Mar'], $lang['Apr'], $lang['May'], $lang['Jun'], $lang['Jul'], $lang['Aug'], $lang['Sep'], $lang['Oct'], $lang['Nov'], $lang['Dec'] ] ;
for ( $a = 1 ; $a <= 12 ; $a++ ){ $months[$a] = 0 ; }
// monthly report = by personal or whole branch
$array_report = [
'personal' => [
'plus' => $months,
'minus' => $months
],
] ;
if ( $staff_settings['reportadjustmentbranch'] == 'yes' ){
$array_report['branch'] = [
'plus' => $months,
'minus' => $months
] ;
}
$filtertype = [] ;
foreach ( $array_report as $k => $v ){
if ( $k == $search_type ){
$filtertype[] = $k ;
}
}
foreach ( $filtertype as $k => $v ){
$search_query = " AND ( b.created_branch_id = '".$array['branch_id']."' XXXXXX )" ;
switch ( $v ){
case 'personal' :
$search_query = str_replace( 'XXXXXX', " AND b.created_by = '".$staff_info['staff_id']."'", $search_query ) ;
break ;
case 'branch' :
$search_query = str_replace( 'XXXXXX', '', $search_query ) ;
break ;
}
$select_report = $mysqli->query( "SELECT SUM(a.point) as total, b.adjustment_type, MONTH(b.created_at) as month FROM staff_adjustment_point a
LEFT JOIN staff_adjustment b ON ( a.adjustment_id = b.adjustment_id )
WHERE a.deleted_at IS NULL AND b.deleted_at IS NULL AND b.created_at LIKE '%".$search_year."%' ".$search_query."
GROUP BY b.adjustment_type, MONTH(b.created_at)" ) ;
if ( $select_report->num_rows > 0 ){
while ( $row_report = $select_report->fetch_assoc() ){
$array_report[$v][$row_report['adjustment_type']][$row_report['month']] = $row_report['total'] ;
}
}
}
// direct echo
if ( $array['iswebview'] == 'yes' ){
$html .= '
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="'.PATH.'css/bootstrap.css?v='.filemtime($require_path.'css/bootstrap.css').'" />
<script src="'.PATH.'scripts/chart.js"></script>
</head>
<body>
<div class="report_chart_main">
<div class="report_chart_filter_year">
<a href="?search_year='.( $search_year - 1 ).resetGetParams($array, [ 'search_year' ]).'" class="report_chart_filter_year_button">
<i class="fa fa-chevron-left" aria-hidden="true"></i>
</a>
<span class="report_chart_filter_year_span">'. $search_year .'</span>
<a href="?search_year='.( $search_year + 1 ).resetGetParams($array, [ 'search_year' ]).'" class="report_chart_filter_year_button">
<i class="fa fa-chevron-right" aria-hidden="true"></i>
</a>
</div>' ;
if ( count($array_report) > 1 ){
$html .= '
<div class="report_chart_filter_type">
<a href="?search_type=personal'.resetGetParams($array, [ 'search_type' ]).'" class="report_chart_filter_type_button '.( $search_type == 'personal' ? 'active' : '' ).'">
'.$lang['By Personal'].'
</a>
<a href="?search_type=branch'.resetGetParams($array, [ 'search_type' ]).'" class="report_chart_filter_type_button '.( $search_type == 'branch' ? 'active' : '' ).'">
'.$lang['By Branch'].'
</a>
</div>' ;
}
foreach ( $array_report as $kreport => $vreport ){
if ( $kreport == $search_type ){
$title = $lang['By '.ucwords($kreport).' Report'] ;
$titlename = $title.' ( '.$lang['Year'].' '.$search_year.' )' ;
$html .= '
<div class="report_chart_line">
<canvas id="myChart'.$kreport.'"></canvas>
</div>
<script>
const ctx'.$kreport.' = document.getElementById("myChart'.$kreport.'") ;
const config'.$kreport.' = {
type : "line",
data : {
datasets : [
{
label : "'.$lang['Give Point'].'",
data : [ "'.implode( '", "', $vreport['plus'] ).'" ]
},
{
label : "'.$lang['Minus Point'].'",
data : [ "'.implode( '", "', $vreport['minus'] ).'" ]
}
],
labels : [ "'.implode( '", "', $months_name ).'" ]
},
options: {
responsive : true,
maintainAspectRatio : false,
plugins : {
legend : {
position : "top",
},
title : {
display : true,
text : "'.$titlename.'"
}
}
}
} ;
new Chart( ctx'.$kreport.', config'.$kreport.' ) ;
</script>' ;
}
}
$html .= '
</div>
</body>
</html>' ;
}
}
if ( $array['iswebview'] == 'yes' ){
echo $html ;
exit ;
}
require( $require_sub.'footer.php' ) ;
?>
+72
View File
@@ -0,0 +1,72 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
// select all department
$department_list = [] ;
$select = $mysqli->query( "SELECT a.department_id, b.department_desc FROM setting_department a
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$department_list[$row['department_id']] = $row['department_desc'] ;
}
}
// select all staff
$staff_list = [] ;
$select = $mysqli->query( "SELECT a.staff_id, a.staff_name, a.staff_shortname, a.staff_idno FROM staff a
WHERE a.deleted_at IS NULL AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL )" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$staff_list[$row['staff_id']] = $row['staff_shortname'] . ' ( '.$row['staff_idno'].' )' ;
}
}
$search_query = '' ;
$search_query .= " AND a.adjustment_id = '".$array['adjustment_id']."'" ;
$query = "SELECT a.adjustment_id, a.adjustment_so, a.adjustment_type, a.created_by, a.department_id, a.point, a.remark, a.created_at, b.title FROM staff_adjustment a
LEFT JOIN setting_adjustment_translation b ON ( a.setting_adjustment_id = b.adjustment_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$search_query2 = '' ;
if ( $row['created_by'] != $staff_info['staff_id'] ){
$search_query2 .= " AND staff_id = '".$staff_info['staff_id']."'" ;
}
$related_staff = [] ;
$select_related = $mysqli->query( "SELECT staff_id FROM staff_adjustment_point
WHERE deleted_at IS NULL AND adjustment_id = '".$array['adjustment_id']."'" . $search_query2 ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
$related_staff[] = $staff_list[$row_related['staff_id']] ;
}
}
$row['title'] = dataFilter( $row['title'] ) ;
$row['department'] = $department_list[ $row['department_id'] ] ;
$row['created_by_name'] = $staff_list[ $row['created_by'] ] ;
$row['related_staff'] = $related_staff ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+199
View File
@@ -0,0 +1,199 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$adjustment_id = $array['adjustment_id'] ;
if ( $array['adjustment_type'] != '' && $array['setting_adjustment_id'] != '' && $array['department_id'] != '' && $array['point'] != ''&& arrayCheck( $array['related_staffs'] ) ){
$status = '253' ;
$point = $array['point'] ;
switch ( $array['adjustment_type'] ){
case 'plus' :
$point = ( $point > 0 ? $point : -($point) ) ;
break ;
case 'minus' :
$point = ( $point > 0 ? -($point) : $point ) ;
break ;
}
if ( $point > 0 || $point < 0 ){
$status = '203' ;
$select_adjustment = $mysqli->query( "SELECT a.adjustment_id, a.adjustment_group, a.adjustment_scenario, a.adjustment_times, b.title FROM setting_adjustment a
LEFT JOIN setting_adjustment_translation b ON ( a.adjustment_id = b.adjustment_id )
WHERE a.deleted_at IS NULL AND b.lang = 'en' AND a.adjustment_id = '".$array['setting_adjustment_id']."'
LIMIT 1" ) ;
if ( $select_adjustment->num_rows > 0 ){
$status = '271' ;
$row_adjustment = $select_adjustment->fetch_assoc() ;
$adjustment_times = $row_adjustment['adjustment_times'] ;
$list_adjustment = [] ;
$list_adjustment[]= $row_adjustment['adjustment_id'] ;
if ( $row_adjustment['adjustment_group'] > 0 ){
$select_group = $mysqli->query( "SELECT adjustment_id FROM setting_adjustment
WHERE deleted_at IS NULL AND adjustment_site = 'frontend' AND adjustment_group = '".$row_adjustment['adjustment_group']."'" ) ;
if ( $select_group->num_rows > 0 ){
while ( $row_group = $select_group->fetch_assoc() ){
$list_adjustment[] = $row_group['adjustment_id'] ;
}
}
}
$is_allow = false ;
switch ( $row_adjustment['adjustment_scenario'] ){
case 'none' :
$is_allow = true ;
break ;
case 'daily' :
$boolean_all = true ;
foreach ( $array['related_staffs'] as $k => $v ){
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND created_at LIKE '%".date( 'Y-m-d', time() )."%'" ) ;
if ( $select_total->num_rows >= $adjustment_times ){
$boolean_all = false ;
}
}
if ( $boolean_all ){
$is_allow = true ;
}
break ;
case '2daily' :
$boolean_all = true ;
foreach ( $array['related_staffs'] as $k => $v ){
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND ( created_at LIKE '%".date( 'Y-m-d', strtotime( "-1 days" ) )."%' OR created_at LIKE '%".date( 'Y-m-d', time() )."%' )" ) ;
if ( $select_total->num_rows >= $adjustment_times ){
$boolean_all = false ;
}
}
if ( $boolean_all ){
$is_allow = true ;
}
break ;
case 'weekly' :
$boolean_all = true ;
foreach ( $array['related_staffs'] as $k => $v ){
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND created_at BETWEEN '".date( 'Y-m-d', strtotime('monday this week') )." 00:00:00' AND '".date( 'Y-m-d', strtotime('sunday this week') )." 23:59:59'" ) ;
if ( $select_total->num_rows >= $adjustment_times ){
$boolean_all = false ;
}
}
if ( $boolean_all ){
$is_allow = true ;
}
break ;
case 'monthly' :
$boolean_all = true ;
foreach ( $array['related_staffs'] as $k => $v ){
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND ( created_at LIKE '%".date( 'Y-m', time() )."%' )" ) ;
if ( $select_total->num_rows >= $adjustment_times ){
$boolean_all = false ;
}
}
if ( $boolean_all ){
$is_allow = true ;
}
break ;
case 'quaterly' :
$array_quarter = [
'1' => [ '01', '02', '03' ],
'2' => [ '04', '05', '06' ],
'3' => [ '07', '08', '09' ],
'4' => [ '10', '11', '12' ],
] ;
$current_month = date( "m", time() ) ;
$current_quarter = ceil( $current_month / 3 ) ;
$get_quarter = $array_quarter[$current_quarter] ;
$boolean_all = true ;
foreach ( $array['related_staffs'] as $k => $v ){
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND ( created_at LIKE '%".date( 'Y-', time() ).$array_quarter[0]."%' OR created_at LIKE '%".date( 'Y-', time() ).$array_quarter[1]."%' OR created_at LIKE '%".date( 'Y-', time() ).$array_quarter[2]."%' )" ) ;
if ( $select_total->num_rows >= $adjustment_times ){
$boolean_all = false ;
}
}
if ( $boolean_all ){
$is_allow = true ;
}
break ;
case 'annually' :
$boolean_all = true ;
foreach ( $array['related_staffs'] as $k => $v ){
$select_total = $mysqli->query( "SELECT point_id FROM staff_adjustment_point
WHERE setting_adjustment_id IN ( ".implode( ', ', $list_adjustment )." ) AND staff_id = '".$v['id']."' AND ( created_at LIKE '%".date( 'Y-', time() )."%' )" ) ;
if ( $select_total->num_rows >= $adjustment_times ){
$boolean_all = false ;
}
}
if ( $boolean_all ){
$is_allow = true ;
}
break ;
}
if ( $is_allow ){
if ( $mysqli->query( "INSERT INTO staff_adjustment
( `adjustment_type`, `created_branch_id`, `created_by`, `department_id`, `setting_adjustment_id`, `point`, `remark` ) VALUES
( '".$array['adjustment_type']."', '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['department_id']."', '".$array['setting_adjustment_id']."', '".$point."', '".$array['remark']."' )" ) ){
$status = '200' ;
$adjustment_id = $mysqli->insert_id ;
$adjustment_so = 'AD'.strPad( 6, $adjustment_id ) ;
$mysqli->query( "UPDATE staff_adjustment SET adjustment_so = '".$adjustment_so."' WHERE adjustment_id = '".$adjustment_id."'" ) ;
// set point movement
// $remark = $staff_info['staff_shortname'].' ('.$staff_info['staff_idno'].') '.( $point > 0 ? 'give' : 'deduct' ).' the point ('.$row_adjustment['title'].') from adjustment ( ' . $adjustment_so . ' )' ;
$remark = 'You have been '.( $point > 0 ? 'given' : 'deducted' ).' the point ('.$row_adjustment['title'].') from adjustment (' . $adjustment_so . ')' ;
foreach ( $array['related_staffs'] as $k => $v ){
$mysqli->query( "INSERT INTO staff_adjustment_point ( `adjustment_id`, `setting_adjustment_id`, `staff_id`, `point` ) VALUES ( '".$adjustment_id."', '".$array['setting_adjustment_id']."', '".$v['id']."', '".$point."' )" ) ;
pointMovement( 'adjustment', $adjustment_id, $array['adjustment_type'], 'normal', $v['id'], $point, $remark ) ;
pushToUserCron( 'staff_adjustment', $adjustment_id, $v['id'], 'Point Adjustment', $remark ) ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+44
View File
@@ -0,0 +1,44 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '312' ;
if ( $array['is_tick'] == 'yes' ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND announcement_id = '".$array['id']."'" ;
$query = "SELECT announcement_id FROM announcement
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$mysqli->query( "INSERT INTO staff_announcement
( announcement_id, staff_id ) VALUES
( '".$array['id']."', '".$staff_info['staff_id']."' ) " ) ;
// update inbox as read
$select_inbox = $mysqli->query( "SELECT a.view_id FROM staff_inbox_view a
LEFT JOIN inbox b ON ( a.inbox_id = b.inbox_id )
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.is_read = '0' AND b.deleted_at IS NULL AND b.from_table = 'announcement' AND b.from_id = '".$array['id']."'" ) ;
if ( $select_inbox->num_rows > 0 ){
while ( $row_inbox = $select_inbox->fetch_assoc() ){
$mysqli->query( "UPDATE staff_inbox_view SET
is_read = '1'
WHERE view_id = '".$row_inbox['view_id']."'" ) ;
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+70
View File
@@ -0,0 +1,70 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'MPDF/mpdf.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$id = $array['id'] ;
$search_query = '' ;
$search_query .= " AND a.announcement_id = '".$id."'" ;
$query = "SELECT a.announcement_id, a.file, a.is_showagree, a.created_at, b.title, b.content FROM announcement a
LEFT JOIN announcement_translation b ON ( a.announcement_id = b.announcement_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$content = dataFilter( $row['content'] ) ;
$file = ( $row['file'] != '' ? PATH.'uploads/Announcement/b/'.$row['file'] : '' ) ;
// check if agree or not
$is_agreed = 'no' ;
$select_agree = $mysqli->query( "SELECT * FROM staff_announcement
WHERE deleted_at IS NULL AND announcement_id = '".$array['id']."' AND staff_id = '".$staff_info['staff_id']."' LIMIT 1" ) ;
if ( $select_agree->num_rows > 0 ){
$is_agreed = 'yes' ;
}
$filename = 'pdfs/announcement-'.strPad( 3, $id ).'.pdf' ;
$filename_save = $require_path . $filename ;
$filename_source = PATH . $filename ;
$header = '' ;
$footer = '' ;
$html = mergeImageWithContent( $file, $content ) ;
$mpdf = new mPDF( 'utf-8', 'A4', '', 'freesans', 15, 15, 15, 15, 5, 5 ) ;
$mpdf->mirrorMargins = 1 ;
$mpdf->useAdobeCJK = true ;
$mpdf->SetHTMLHeader( $header ) ;
$mpdf->SetHTMLHeader( $header,'E' ) ;
$mpdf->SetHTMLFooter( $footer ) ;
$mpdf->SetHTMLFooter( $footer,'E' ) ;
$mpdf->WriteHTML( $html ) ;
$mpdf->Output( $filename_save, 'F' ) ;
$row['id'] = dataFilter( $row['announcement_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = $content ;
$row['file'] = $file ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$row['is_agreed'] = $is_agreed ;
$row['source'] = $filename_source ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.announcement_id, a.is_hide, a.file, a.created_at, b.title FROM announcement a
LEFT JOIN announcement_translation b ON ( a.announcement_id = b.announcement_id )
WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['announcement_id'] ) ;
$row['title'] = ( $row['is_hide'] == 'no' ? dataFilter( $row['title'] ) : '' ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Announcement/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,42 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY a.sortable ASC, a.created_at DESC' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT a.category_id, a.file, b.title FROM association_category a
LEFT JOIN association_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' AND a.status = 'active' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/AssociationCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+46
View File
@@ -0,0 +1,46 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND association_id = '".$array['id']."'" ;
$query = "SELECT association_id, association_type, date_start, date_end, file, status, created_at FROM association
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '248' ;
$row = $mysqli_query->fetch_assoc() ;
$is_association = 'no' ;
if ( $row['status'] == 'active' ){
if ( $row['association_type'] == 'all' || ( $row['association_type'] == 'date' && $row['date_start'] <= TODAYDAY && $row['date_end'] >= TODAYDAY ) ){
$is_association = 'yes' ;
}
}
if ( $is_association == 'yes' ){
$status = '200' ;
$mysqli->query( "INSERT INTO staff_association
( association_id, branch_id, staff_id, status ) VALUES
( '".$array['id']."', '".$array['branch_id']."', '".$staff_info['staff_id']."', 'pending' ) " ) ;
$view_id = $mysqli->insert_id ;
$association_so = 'AS'.strPad( 6, $view_id ) ;
$mysqli->query( "UPDATE staff_association SET association_so = '".$association_so."' WHERE view_id = '".$view_id."'" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+60
View File
@@ -0,0 +1,60 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.association_id = '".$array['id']."'" ;
$join_filter = "" ;
$join_query = "" ;
if ( $array['mode'] == 'view' ){
$join_filter .= ", c.association_so, c.status as association_status, c.remark as association_remark, c.rated as association_rated, c.comment as association_comment" ;
$join_query .= " LEFT JOIN staff_association c ON ( a.association_id = c.association_id )" ;
$search_query .= " AND c.view_id = '".$array['view_id']."' AND c.staff_id = '".$staff_info['staff_id']."'" ;
}
$query = "SELECT a.association_id, a.association_type, a.date_start, a.date_end, a.file, a.status, a.created_at, b.title, b.content ".$join_filter." FROM association a
LEFT JOIN association_translation b ON ( a.association_id = b.association_id )
".$join_query."
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$generatecode = generateQrcode( '', $row['association_so'], $row['association_so'] ) ;
$row = $mysqli_query->fetch_assoc() ;
$row['id'] = dataFilter( $row['association_id'] ) ;
$row['sonumber'] = dataFilter( $row['association_so'] ) ;
$row['qrcode'] = $generatecode['url'] ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Association/b/'.$row['file'] : '' ) ;
$is_association = 'no' ;
if ( $row['status'] == 'active' ){
if ( $row['association_type'] == 'all' || ( $row['association_type'] == 'date' && $row['date_start'] <= TODAYDAY && $row['date_end'] >= TODAYDAY ) ){
$is_association = 'yes' ;
}
}
$row['is_association'] = $is_association ;
$row['date_start'] = resetDateFormat( $row['date_start'] ) ;
$row['date_end'] = resetDateFormat( $row['date_end'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['association_status'] = ( checkExists( $row['association_status'] ) != '' ? $row['association_status'] : '') ;
$row['association_remark'] = dataFilter( checkExists( $row['association_remark'] ) != '' ? $row['association_remark'] : '') ;
$row['association_rated'] = dataFilter( checkExists( $row['association_rated'] ) != '' ? $row['association_rated'] : 0) ;
$row['association_comment'] = dataFilter( checkExists( $row['association_comment'] ) != '' ? $row['association_comment'] : '') ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$join_filter = '' ;
$join_query = '' ;
$query = "SELECT a.category_id, b.title FROM association_gallery_category a
LEFT JOIN association_gallery_category_translation b ON ( a.category_id = b.category_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' AND a.status = 'active'" ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.sortable" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['category_id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,46 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY created_at DESC' ;
$search_query = '' ;
switch ( $array['filter'] ){
case 'myself' :
$search_query .= " AND staff_id = '".$staff_info['staff_id']."'" ;
break ;
case 'group' :
$search_query .= " AND branch_id = '".$array['branch_id']."' AND status = 'confirmed' AND category_id = '".$array['category_id']."'" ;
break ;
}
$query = "SELECT title, file, filetype, status, created_at FROM association_gallery
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['date'] = resetDateFormat( $row['created_at'] ) ;
$row['time'] = resetTimeFormat( $row['created_at'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/AssociationGallery/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,35 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$title = $array['title'] ;
$photos = $array['photos'] ;
if ( $title != '' && $array['photos'] != '' && count( $photos ) > 0 ){
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'AssociationGallery', time(), $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO association_gallery
( branch_id, staff_id, title, file, filetype ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$title."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$is_going = $array['is_going'] ;
$update_status = ( $is_going == 'yes' ? 'confirmed' : 'cancelled' ) ;
if ( $array['id'] != '' && $array['view_id'] != '' && $is_going != '' ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND association_id = '".$array['id']."'" ;
$query = "SELECT association_id, association_type, date_start, date_end, file, status, created_at FROM association
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$mysqli->query( "UPDATE staff_association SET
is_going = '".$array['is_going']."',
status = '".$update_status."'
WHERE view_id = '".$array['view_id']."'" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+70
View File
@@ -0,0 +1,70 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$searchfilter = $array['searchfilter'] ;
$searchfilter = ( $searchfilter != '' ? $searchfilter : 'current' ) ;
$join_filter = '' ;
$join_query = '' ;
$query_sortable = 'ORDER BY a.sortable ASC, a.created_at DESC' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.title LIKE '%".$array['search']."%'" ;
}
if ( $array['category_id'] != '' ){
$search_query .= " AND a.category_id = '".$array['category_id']."'" ;
}
if ( $searchfilter != '' ){
switch ( $searchfilter ){
case 'current' :
$search_query .= " AND a.branch LIKE '%/".$array['branch_id']."/%' AND a.status = 'active' AND ( ( a.association_type = 'all' ) OR ( a.association_type = 'date' AND a.date_start <= '".TODAYDAY."' AND a.date_end >= '".TODAYDAY."' ) )" ;
break ;
case 'previous' :
$join_filter = ", c.view_id, c.status as association_status" ;
$join_query = "LEFT JOIN staff_association c ON ( a.association_id = c.association_id )" ;
$search_query .= " AND c.branch_id = '".$array['branch_id']."' AND c.staff_id = '".$staff_info['staff_id']."'" ;
$query_sortable = "ORDER BY view_id DESC" ;
break ;
case 'expired' :
$search_query .= " AND a.branch LIKE '%/".$array['branch_id']."/%' AND ( a.status = 'inactive' OR ( a.association_type = 'date' AND a.date_start <= '".TODAYDAY."' AND NOT ( a.date_end >= '".TODAYDAY."' ) ) )" ;
break ;
}
}
$query = "SELECT a.association_id, a.association_type, a.date_start, a.date_end, a.file, a.created_at, b.title ".$join_filter." FROM association a
LEFT JOIN association_translation b ON ( a.association_id = b.association_id )
".$join_query."
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ".$query_sortable." LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['association_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['date_start'] = resetDateFormat( $row['date_start'] ) ;
$row['date_end'] = resetDateFormat( $row['date_end'] ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$row['association_status'] = ( checkExists( $row['association_status'] ) != '' ? $row['association_status'] : '' ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Association/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
if ( $array['id'] != '' && $array['view_id'] != '' && $array['association_rated'] != '' && $array['association_comment'] != '' ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND association_id = '".$array['id']."'" ;
$query = "SELECT association_id, association_type, date_start, date_end, file, status, created_at FROM association
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$mysqli->query( "UPDATE staff_association SET
rated = '".$array['association_rated']."',
comment = '".$array['association_comment']."',
status = 'rated'
WHERE view_id = '".$array['view_id']."'" ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+42
View File
@@ -0,0 +1,42 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND catalog_id = '".$array['id']."'" ;
$query = "SELECT catalog_id, title, content, view_format, file, file_type, video_url, created_at FROM catalog
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$file = '' ;
if ( $row['file'] != '' ){
if ( $row['file_type'] == 'pdf' ){
$file = PATH.'uploads/Catalog/'.$row['file'] ;
}else{
$file = PATH.'uploads/Catalog/b/'.$row['file'] ;
}
}
$row['id'] = dataFilter( $row['catalog_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['file'] = $file ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+41
View File
@@ -0,0 +1,41 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['category_id'] != '' ){
$search_query .= " AND category_id = '".$array['category_id']."'" ;
}
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT catalog_id, title, created_at FROM catalog
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY sortable ASC, created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['catalog_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/Catalog/b/'.$row['file'] : '' ) ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT category_id, title, file, created_at FROM catalog_category
WHERE deleted_at IS NULL AND category_type = 'main' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY sortable ASC, created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/CatalogCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT category_id, title, file, created_at FROM catalog_category
WHERE deleted_at IS NULL AND category_type = 'sub' AND category_parent = '".$array['category_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY sortable ASC, created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['category_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/CatalogCategory/b/'.$row['file'] : '' ) ;
$list[] = $row ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+83
View File
@@ -0,0 +1,83 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
// select all department
$department_list = [] ;
$select = $mysqli->query( "SELECT a.department_id, b.department_desc FROM setting_department a
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$department_list[$row['department_id']] = $row['department_desc'] ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT formheadcount_id, staff_id, title, content, status, created_at FROM formheadcount
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$staff_list = [] ;
$formheadcount_id = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['formheadcount_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['departments'] = '' ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
$staff_list[$row['staff_id']] = $row['staff_id'] ;
$formheadcount_id[$row['formheadcount_id']] = $row['formheadcount_id'] ;
}
// select related formheadcount media
$media_list = [] ;
$select_media = $mysqli->query( "SELECT formheadcount_id, file FROM formheadcount_media a
WHERE a.deleted_at IS NULL AND formheadcount_id IN ( ".implode( ',', $formheadcount_id )." ) AND filetype IN ( 'jpg', 'png', 'gif' )" ) ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
$media_list[$row_media['formheadcount_id']][] = ( $row_media['file'] != '' ? PATH.'uploads/FormHeadCount/b/'.$row_media['file'] : '' ) ;
}
}
// select all staff related deparment
$related_list = [] ;
$select_related = $mysqli->query( "SELECT a.staff_id, a.department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND a.staff_id IN ( ".implode( ',', $staff_list )." )" ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
if ( checkExists( $department_list[$row_related['department_id']] ) ){
$related_list[$row_related['staff_id']][] = $department_list[$row_related['department_id']] ;
}
}
}
foreach ( $list as $k => $v ){
$list[$k]['departments'] = ( checkExists( $related_list[$v['staff_id']] ) ? implode( ', ', $related_list[$v['staff_id']] ) : '' ) ;
$list[$k]['files'] = ( checkExists( $media_list[$v['formheadcount_id']] ) ? $media_list[$v['formheadcount_id']] : [] ) ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+68
View File
@@ -0,0 +1,68 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND formheadcount_id = '".$array['formheadcount_id']."'" ;
$query = "SELECT formheadcount_id, title, content, remark, comment, status, created_at, updated_at FROM formheadcount
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['remark'] = dataFilter( $row['remark'] ) ;
$row['comment'] = dataFilter( $row['comment'] ) ;
// get all media
$select_media = $mysqli->query( "SELECT media_id, file, filetype FROM formheadcount_media
WHERE deleted_at IS NULL AND formheadcount_id = '".$array['formheadcount_id']."'" ) ;
$photos = [] ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
switch ( $row_media['filetype'] ){
case 'jpg' :
case 'jpeg' :
case 'png' :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/FormHeadCount/b/'.$row_media['file'] : '' )
] ;
break ;
default :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/FormHeadCount/'.$row_media['file'] : '' )
] ;
}
}
}
$row['photos'] = $photos ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+50
View File
@@ -0,0 +1,50 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$formheadcount_id = $array['formheadcount_id'] ;
$photos = $array['photos'] ;
if ( $array['title'] != '' && $array['content'] != '' && $array['photos'] != '' && count( $photos ) > 0 ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO formheadcount
( `branch_id`, `staff_id`, `title`, `content`, `remark`, `status` ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['title']."', '".$array['content']."', '".$array['remark']."', 'pending' )" ) ){
$status = '200' ;
$boolean_submit = true ;
$formheadcount_id = $mysqli->insert_id ;
$formheadcount_so = 'FH'.strPad( 6, $formheadcount_id ) ;
$mysqli->query( "UPDATE formheadcount SET
formheadcount_so = '".$formheadcount_so."'
WHERE formheadcount_id = '".$formheadcount_id."'" ) ;
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'FormHeadCount', $formheadcount_id.'-'.$formheadcount_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO formheadcount_media
( formheadcount_id, file, filetype ) VALUES
( '".$formheadcount_id."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,78 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
// select all
$staffs = [] ;
$question_list = [] ;
$form_list = [] ;
$all_tier = getAllTier( $array['lang'] ) ;
// select all staff
$select = $mysqli->query( "SELECT a.staff_id, a.staff_idno, a.staff_name, a.staff_shortname, a.staff_tier FROM staff a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL ) " ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$get_staff_tier = $all_tier[$row['staff_tier']] ;
$staffs[] = [
'id' => $row['staff_id'],
'title' => $row['staff_shortname'] . ' ('.$row['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')',
'name' => $row['staff_name'],
'tier' => $get_staff_tier['level']
] ;
}
}
$where_question = '' ;
if ( $array['submission_type'] != '' ){
$where_question .= " AND a.nomination_type = '".$array['submission_type']."'" ;
}
// question & form
$select_question = $mysqli->query( "SELECT a.question_id, a.question_type, b.title, b.content, b.questions FROM formnomination_question a
LEFT JOIN formnomination_question_translation b ON ( a.question_id = b.question_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' ".$where_question." ORDER BY a.sortable" ) ;
if ( $select_question->num_rows > 0 ){
while ( $row_question = $select_question->fetch_assoc() ){
if ( $row_question['question_type'] == 'question' ){
$temp = $row_question ;
$temp['title'] = dataFilter( $temp['title'] ) ;
$temp['content'] = dataFilter( $temp['content'] ) ;
$temp['questions'] = ( $temp['questions'] != '' ? explode( '|', $temp['questions'] ) : [] ) ;
$question_list[] = $temp ;
}
if ( $row_question['question_type'] == 'form' ){
$temp = $row_question ;
$temp['title'] = dataFilter( $temp['title'] ) ;
$temp['content'] = dataFilter( $temp['content'] ) ;
$temp['questions'] = ( $temp['questions'] != '' ? explode( '|', $temp['questions'] ) : [] ) ;
$form_list[] = $temp ;
}
}
}
$data = [
'staffs' => $staffs,
'questions' => $question_list,
'forms' => $form_list
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+89
View File
@@ -0,0 +1,89 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
// select all department
$department_list = [] ;
$select = $mysqli->query( "SELECT a.department_id, b.department_desc FROM setting_department a
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$department_list[$row['department_id']] = $row['department_desc'] ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND b.staff_name LIKE '%".$array['search']."%'" ;
}
if ( $array['submission_type'] != '' ){
$search_query .= " AND a.formnomination_type = '".$array['submission_type']."'" ;
}
$query = "SELECT a.formnomination_id, a.staff_id, a.nominee_staff_id, a.status, a.created_at FROM formnomination a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' AND a.staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY a.created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$nominee_staff_list = [] ;
$formnomination_id = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['formnomination_id'] ) ;
$row['nominee_name'] = '' ;
$row['nominee_departments'] = '' ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
$nominee_staff_list[$row['nominee_staff_id']] = $row['nominee_staff_id'] ;
}
// select all staff
$related_staff_list = [] ;
$select_related_staff = $mysqli->query( "SELECT a.staff_id, a.staff_name FROM staff a
WHERE a.deleted_at IS NULL AND a.staff_id IN ( ".implode( ',', $nominee_staff_list )." )" ) ;
if ( $select_related_staff->num_rows > 0 ){
while ( $row_related_staff = $select_related_staff->fetch_assoc() ){
$related_staff_list[$row_related_staff['staff_id']] = [
'staff_name' => $row_related_staff['staff_name']
] ;
}
}
// select all staff related deparment
$related_list = [] ;
$select_related = $mysqli->query( "SELECT a.staff_id, a.department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND a.staff_id IN ( ".implode( ',', $nominee_staff_list )." )" ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
if ( checkExists( $department_list[$row_related['department_id']] ) ){
$related_list[$row_related['staff_id']][] = $department_list[$row_related['department_id']] ;
}
}
}
foreach ( $list as $k => $v ){
$selected_staff = ( checkExists( $related_staff_list[$v['nominee_staff_id']] ) ? $related_staff_list[$v['nominee_staff_id']] : [] ) ;
$list[$k]['nominee_name'] = ( checkExists( $selected_staff['staff_name'] ) ? checkExists( $selected_staff['staff_name'] ) : 'Unknown' ) ;
$list[$k]['nominee_departments'] = ( checkExists( $related_list[$v['nominee_staff_id']] ) ? implode( ', ', $related_list[$v['nominee_staff_id']] ) : '' ) ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+65
View File
@@ -0,0 +1,65 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND formnomination_id = '".$array['formnomination_id']."'" ;
$query = "SELECT formnomination_id, nominee_staff_id, comment, status, created_at, updated_at FROM formnomination
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$row['comment'] = dataFilter( $row['comment'] ) ;
// select all staff
$nominee_to_name = '' ;
$select_related_staff = $mysqli->query( "SELECT a.staff_id, a.staff_name FROM staff a
WHERE a.deleted_at IS NULL AND a.staff_id = '".$row['nominee_staff_id']."' LIMIT 1" ) ;
if ( $select_related_staff->num_rows > 0 ){
$row_related_staff = $select_related_staff->fetch_assoc() ;
$nominee_to_name = $row_related_staff['staff_name'] ;
}
$row['nominee_to_name'] = $nominee_to_name ;
// select all answer
$question_list = [] ;
$form_list = [] ;
$select_answer = $mysqli->query( "SELECT a.question_type, a.checkbox, a.chosen, a.remark, c.title, c.content FROM formnomination_answer a
LEFT JOIN formnomination_question b ON ( a.question_id = b.question_id )
LEFT JOIN formnomination_question_translation c ON ( b.question_id = c.question_id )
WHERE a.formnomination_id = '".$row['formnomination_id']."' AND c.lang = '".$array['lang']."' ORDER BY b.sortable" ) ;
if ( $select_answer->num_rows > 0 ){
while ( $row_answer = $select_answer->fetch_assoc() ){
if ( $row_answer['question_type'] == 'question' ){
$question_list[] = $row_answer ;
}
if ( $row_answer['question_type'] == 'form' ){
$form_list[] = $row_answer ;
}
}
}
$row['questions'] = $question_list ;
$row['forms'] = $form_list ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,85 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$nominee_to = $array['nominee_to'] ;
$formnomination_id = $array['formnomination_id'] ;
$forms = $array['forms'] ;
if ( $nominee_to != '' && $formnomination_id != '' && count($forms) > 0 ){
$status = '201' ;
$where_question = '' ;
if ( $array['submission_type'] != '' ){
$where_question .= " AND a.nomination_type = '".$array['submission_type']."'" ;
}
$select_formnomination = $mysqli->query( "SELECT * FROM formnomination
WHERE deleted_at IS NULL AND formnomination_id = '".$formnomination_id."' AND status = 'pending' LIMIT 1" ) ;
if ( $select_formnomination->num_rows > 0 ){
$status = '314' ;
$row_formnomination = $select_formnomination->fetch_assoc() ;
$form_list = [] ;
$select_form = $mysqli->query( "SELECT a.question_id FROM formnomination_question a
WHERE a.deleted_at IS NULL AND a.question_type = 'form'" . $where_question ) ;
$total_form = $select_form->num_rows ;
$total_remark = 0 ;
foreach ( $forms as $kform => $vform ){
if ( $vform['remark'] != '' ){
$total_remark++ ;
}
}
if ( count($forms) == $total_form && $total_form == $total_remark ){
$status = '200' ;
$mysqli->query( "UPDATE formnomination SET
nominee_staff_id = '".$nominee_to."',
status = 'approved'
WHERE formnomination_id = '".$formnomination_id."'" ) ;
foreach ( $forms as $kform => $vform ){
$mysqli->query( "INSERT INTO formnomination_answer
( formnomination_id, question_id, question_type, checkbox, chosen, remark ) VALUES
( '".$formnomination_id."', '".$vform['id']."', 'form', '".$vform['checkbox']."', '".$vform['radio']."', '".$vform['remark']."' )" ) ;
}
$mailer = new Mailer() ;
$mailer->from = EMAILNOREPLY ;
$select_staff = $mysqli->query( "SELECT a.staff_id, a.staff_name, a.staff_email FROM staff a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL ) AND a.staff_settings LIKE '%\"ishrmanager\":\"yes\"%'" ) ;
if ( $select_staff->num_rows > 0 ){
while ( $row_staff = $select_staff->fetch_assoc() ){
pushToUserCron( 'formnomination', $array['formnomination_id'], $row_staff['staff_id'], 'Nomination', 'Nomination '.$row_formnomination['formnomination_so'].' need you to review' ) ;
if ( $row_staff['staff_email'] != '' ){
$mailer->to = [ $row_staff['staff_email'] ] ;
// $mailer->cc = $EMAILCC ;
$mailer->subject = 'Reminder for Nomination' ;
$mailer->body = 'Dear HR Manager, '.dataFilter($staff_info['staff_name']).' has submitted an nomination request. Please log in to review.
<br /><br />
* This is an auto-generated message, please do not reply.' ;
$mailer->send() ;
}
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,81 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$questions = $array['questions'] ;
if ( count($questions) > 0 ){
$status = '314' ;
$where_question = '' ;
if ( $array['submission_type'] != '' ){
$where_question .= " AND a.nomination_type = '".$array['submission_type']."'" ;
}
$question_list = [] ;
$select_question = $mysqli->query( "SELECT a.question_id FROM formnomination_question a
WHERE a.deleted_at IS NULL AND a.question_type = 'question'" . $where_question ) ;
$total_question = $select_question->num_rows ;
$point_peryes = ( 100 / $total_question ) ;
$point_questionyes = 0 ;
$total_yesno = 0 ;
foreach ( $questions as $kquestion => $vquestion ){
if ( $vquestion['checkbox'] == 'yes' ){
$point_questionyes += $point_peryes ;
}
if ( $vquestion['checkbox'] != '' ){
$total_yesno++ ;
}
}
if ( count($questions) == $total_question && $total_yesno == $total_question ){
$status = '99' ;
$update_status = 'cancelled' ;
if ( $point_questionyes >= NOMINATIONPOINT ){
$status = '98' ;
$update_status = 'pending' ;
}
if ( $mysqli->query( "INSERT INTO formnomination
( `formnomination_type`, `branch_id`, `staff_id`, `status` ) VALUES
( '".$array['submission_type']."', '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$update_status."' )" ) ){
$boolean_submit = true ;
$formnomination_id = $mysqli->insert_id ;
$formnomination_so = 'FN'.strPad( 6, $formnomination_id ) ;
$mysqli->query( "UPDATE formnomination SET
formnomination_so = '".$formnomination_so."'
WHERE formnomination_id = '".$formnomination_id."'" ) ;
foreach ( $questions as $kquestion => $vquestion ){
$mysqli->query( "INSERT INTO formnomination_answer
( formnomination_id, question_id, question_type, checkbox, chosen, remark ) VALUES
( '".$formnomination_id."', '".$vquestion['id']."', 'question', '".$vquestion['checkbox']."', '".$vquestion['radio']."', '".$vquestion['remark']."' )" ) ;
}
$data = [
'formnomination_id' => $formnomination_id,
'update_status' => $update_status
] ;
}else{
$status = '203' ;
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,36 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '200' ;
$staffs = [] ;
$all_tier = getAllTier( $array['lang'] ) ;
// select all staff
$select = $mysqli->query( "SELECT a.staff_id, a.staff_idno, a.staff_name, a.staff_shortname, a.staff_tier FROM staff a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL ) AND a.staff_settings LIKE '%\"ismanager\":\"yes\"%'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$get_staff_tier = $all_tier[$row['staff_tier']] ;
$staffs[] = [
'id' => $row['staff_id'],
'title' => dataFilter( $row['staff_shortname'] ) . ' ('.$row['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')',
'name' => dataFilter( $row['staff_name'] ),
'tier' => $get_staff_tier['level']
] ;
}
}
$data = [
'staffs' => $staffs
] ;
}
require( $require_sub.'footer.php' ) ;
?>
+84
View File
@@ -0,0 +1,84 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
// select all department
$department_list = [] ;
$select = $mysqli->query( "SELECT a.department_id, b.department_desc FROM setting_department a
LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."'" ) ;
if ( $select->num_rows > 0 ){
while ( $row = $select->fetch_assoc() ){
$department_list[$row['department_id']] = $row['department_desc'] ;
}
}
$search_query = '' ;
if ( $array['search'] != '' ){
$search_query .= " AND title LIKE '%".$array['search']."%'" ;
}
$query = "SELECT formresignation_id, staff_id, title, content, status_manager, status_hr, created_at FROM formresignation
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND staff_id = '".$staff_info['staff_id']."' " . $search_query ;
$mysqli_query = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$staff_list = [] ;
$formresignation_id = [] ;
while ( $row = $mysqli_query->fetch_assoc() ){
$row['id'] = dataFilter( $row['formresignation_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$row['departments'] = '' ;
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
$list[] = $row ;
$staff_list[$row['staff_id']] = $row['staff_id'] ;
$formresignation_id[$row['formresignation_id']] = $row['formresignation_id'] ;
}
// select related formresignation media
$media_list = [] ;
$select_media = $mysqli->query( "SELECT formresignation_id, file FROM formresignation_media a
WHERE a.deleted_at IS NULL AND formresignation_id IN ( ".implode( ',', $formresignation_id )." ) AND filetype IN ( 'jpg', 'png', 'gif' )" ) ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
$media_list[$row_media['formresignation_id']][] = ( $row_media['file'] != '' ? PATH.'uploads/FormResignation/b/'.$row_media['file'] : '' ) ;
}
}
// select all staff related deparment
$related_list = [] ;
$select_related = $mysqli->query( "SELECT a.staff_id, a.department_id FROM staff_department a
WHERE a.deleted_at IS NULL AND a.staff_id IN ( ".implode( ',', $staff_list )." )" ) ;
if ( $select_related->num_rows > 0 ){
while ( $row_related = $select_related->fetch_assoc() ){
if ( checkExists( $department_list[$row_related['department_id']] ) ){
$related_list[$row_related['staff_id']][] = $department_list[$row_related['department_id']] ;
}
}
}
foreach ( $list as $k => $v ){
$list[$k]['departments'] = ( checkExists( $related_list[$v['staff_id']] ) ? implode( ', ', $related_list[$v['staff_id']] ) : '' ) ;
$list[$k]['files'] = ( checkExists( $media_list[$v['formresignation_id']] ) ? $media_list[$v['formresignation_id']] : [] ) ;
}
$data['list'] = $list ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+113
View File
@@ -0,0 +1,113 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$all_tier = getAllTier( $array['lang'] ) ;
$staff_settings = $staff_info['staff_settings'] ;
$search_query = '' ;
$search_query .= " AND formresignation_id = '".$array['formresignation_id']."'" ;
$query = "SELECT formresignation_id, title, content, staff_id_manager, comment_manager, comment_hr, status_manager, staff_id_hr, status_hr, created_at, updated_at FROM formresignation
WHERE deleted_at IS NULL " . $search_query ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$list = [] ;
$row = $mysqli_query->fetch_assoc() ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['content'] = dataFilter( $row['content'] ) ;
$manager_name = '' ;
$hr_name = '' ;
// select manager / hr manager
$staff_ids = [ $row['staff_id_manager'] ] ;
if ( $row['staff_id_hr'] > 0 ){
$staff_ids[] = $row['staff_id_hr'] ;
}
$select_staff = $mysqli->query( "SELECT staff_id, staff_idno, staff_name, staff_shortname, staff_tier FROM staff
WHERE staff_id IN ( ".implode(',', $staff_ids)." ) LIMIT 2" ) ;
if ( $select_staff->num_rows > 0 ){
while ( $row_staff = $select_staff->fetch_assoc() ){
$get_staff_tier = $all_tier[$row_staff['staff_tier']] ;
if ( $row_staff['staff_id'] == $row['staff_id_manager'] ){
$manager_name = dataFilter( $row_staff['staff_shortname'] ) . ' ('.$row_staff['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')' ;
}
if ( $row_staff['staff_id'] == $row['staff_id_hr'] ){
$hr_name = dataFilter( $row_staff['staff_shortname'] ) . ' ('.$row_staff['staff_idno'].' / '.strtoupper( $get_staff_tier['title'] ).')' ;
}
}
}
$is_manager_update = 'no' ;
if ( $staff_settings['ismanager'] == 'yes' ){
if ( $row['status_manager'] == 'pending' && $row['status_hr'] == 'pending' ){
if ( $staff_info['staff_id'] == $row['staff_id_manager'] ){
$is_manager_update = 'yes' ;
}
}
}
$row['is_manager_update'] = $is_manager_update ;
$row['manager_name'] = $manager_name ;
$row['comment_manager'] = ( $row['comment_manager'] != '' ? '<pre>'.dataFilter( $row['comment_manager'] ).'</pre>': '' ) ;
$is_hr_update = 'no' ;
if ( $staff_settings['ishrmanager'] == 'yes' ){
if ( $row['status_manager'] == 'confirmed' && $row['status_hr'] == 'pending' ){
$is_hr_update = 'yes' ;
}
}
$row['is_hr_update'] = $is_hr_update ;
$row['hr_name'] = $hr_name ;
$row['comment_hr'] = ( $row['comment_hr'] != '' ? '<pre>'.dataFilter( $row['comment_hr'] ).'</pre>': '' ) ;
// get all media
$select_media = $mysqli->query( "SELECT media_id, file, filetype FROM formresignation_media
WHERE deleted_at IS NULL AND formresignation_id = '".$array['formresignation_id']."'" ) ;
$photos = [] ;
if ( $select_media->num_rows > 0 ){
while ( $row_media = $select_media->fetch_assoc() ){
switch ( $row_media['filetype'] ){
case 'jpg' :
case 'jpeg' :
case 'png' :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/FormResignation/b/'.$row_media['file'] : '' )
] ;
break ;
default :
$photos[] = [
'media_id' => $row_media['media_id'],
'type' => 'online',
'filetype' => $row_media['filetype'],
'file' => ( $row_media['file'] != '' ? PATH.'uploads/FormResignation/'.$row_media['file'] : '' )
] ;
}
}
}
$row['photos'] = $photos ;
$data = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,53 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '303' ;
if ( $staff_info['staff_settings']['ishrmanager'] == 'yes' ){
$status = '300' ;
if ( $array['update_status'] != '' && $array['comment_hr'] != '' ){
$status = '201' ;
$query = "SELECT formresignation_id, formresignation_so, staff_id, title, content, staff_id_manager, comment_manager, comment_hr, status_manager, staff_id_hr, status_hr, created_at, updated_at FROM formresignation
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND formresignation_id = '".$array['formresignation_id']."' AND status_manager = 'confirmed' AND status_hr = 'pending'" ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$status = '308' ;
$update_status = ( $array['update_status'] == 'confirmed' ? 'confirmed' : 'rejected' ) ;
if ( $update_status != '' ){
$status = '200' ;
$mysqli->query( "UPDATE formresignation SET
staff_id_hr = '".$staff_info['staff_id']."',
status_hr = '".$update_status."',
comment_hr = '".$array['comment_hr']."',
date_hr = '".TODAYDATE."'
WHERE formresignation_id = '".$array['formresignation_id']."'" ) ;
if ( $update_status == 'confirmed' ){
pushToUserCron( 'formresignation', $array['formresignation_id'], $row['staff_id'], 'Resignation', 'Resignation is confirmed by your HR Manager' ) ;
}else{
pushToUserCron( 'formresignation', $array['formresignation_id'], $row['staff_id'], 'Resignation', 'Resignation is rejected by your HR Manager' ) ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,76 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_path.'extensions/mailer.php' ) ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '303' ;
if ( $staff_info['staff_settings']['ismanager'] == 'yes' ){
$status = '300' ;
if ( $array['update_status'] != '' && $array['comment_manager'] != '' ){
$status = '201' ;
$query = "SELECT formresignation_id, formresignation_so, staff_id, title, content, staff_id_manager, comment_manager, comment_hr, status_manager, staff_id_hr, status_hr, created_at, updated_at FROM formresignation
WHERE deleted_at IS NULL AND branch_id = '".$array['branch_id']."' AND formresignation_id = '".$array['formresignation_id']."' AND staff_id_manager = '".$staff_info['staff_id']."' AND status_manager = 'pending' AND status_hr = 'pending'" ;
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
if ( $mysqli_query->num_rows > 0 ){
$row = $mysqli_query->fetch_assoc() ;
$status = '308' ;
$update_status = ( $array['update_status'] == 'confirmed' ? 'confirmed' : 'rejected' ) ;
if ( $update_status != '' ){
$status = '200' ;
$mysqli->query( "UPDATE formresignation SET
status_manager = '".$update_status."',
comment_manager = '".$array['comment_manager']."',
date_manager = '".TODAYDATE."'
WHERE formresignation_id = '".$array['formresignation_id']."'" ) ;
// push notification to hr manager
$mailer = new Mailer() ;
$mailer->from = EMAILNOREPLY ;
if ( $update_status == 'confirmed' ){
$select_staff = $mysqli->query( "SELECT a.staff_id, a.staff_name, a.staff_email FROM staff a
WHERE a.deleted_at IS NULL AND a.branch_id = '".$array['branch_id']."' AND ( a.staff_date_resigned >= '".date("Y-m-d",time())."' OR a.staff_date_resigned = '0000-00-00' OR a.staff_date_resigned IS NULL ) AND a.staff_settings LIKE '%\"ishrmanager\":\"yes\"%'" ) ;
if ( $select_staff->num_rows > 0 ){
while ( $row_staff = $select_staff->fetch_assoc() ){
pushToUserCron( 'formresignation', $array['formresignation_id'], $row_staff['staff_id'], 'Resignation', 'Resignation '.$row['formresignation_so'].' need your approval or rejection' ) ;
if ( $row_staff['staff_email'] != '' ){
$mailer->to = [ $row_staff['staff_email'] ] ;
$mailer->cc = $EMAILCC ;
$mailer->subject = 'Reminder for Resignation' ;
$mailer->body = 'Dear HR Manager, '.dataFilter($staff_info['staff_name']).' has submitted an resignation request. Please log in to review.
<br /><br />
* This is an auto-generated message, please do not reply.' ;
$mailer->send() ;
}
}
}
pushToUserCron( 'formresignation', $array['formresignation_id'], $row['staff_id'], 'Resignation', 'Resignation is confirmed by your Manager, we will send to HR Manager to do approval and rejection' ) ;
}else{
pushToUserCron( 'formresignation', $array['formresignation_id'], $row['staff_id'], 'Resignation', 'Resignation is rejected by your Manager' ) ;
}
}
}
}
}
}
require( $require_sub.'footer.php' ) ;
?>
@@ -0,0 +1,53 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '300' ;
$formresignation_id = $array['formresignation_id'] ;
$photos = $array['photos'] ;
if ( $array['staff_id_manager'] != '' && $array['staff_id_manager'] > 0 && $array['title'] != '' && $array['content'] != '' && $array['photos'] != '' && count( $photos ) > 0 ){
$status = '203' ;
if ( $mysqli->query( "INSERT INTO formresignation
( `branch_id`, `staff_id`, `staff_id_manager`, `title`, `content`, `status_manager`, `status_hr` ) VALUES
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['staff_id_manager']."', '".$array['title']."', '".$array['content']."', 'pending', 'pending' )" ) ){
$status = '200' ;
$boolean_submit = true ;
$formresignation_id = $mysqli->insert_id ;
$formresignation_so = 'FR'.strPad( 6, $formresignation_id ) ;
$mysqli->query( "UPDATE formresignation SET
formresignation_so = '".$formresignation_so."'
WHERE formresignation_id = '".$formresignation_id."'" ) ;
if ( checkExists($photos) ){
foreach ( $photos as $k => $v ){
if ( $v['type'] == 'local' ){
$file_upload = ( $v['file'] ) ;
$upload = uploadImage( 'FormResignation', $formresignation_id.'-'.$formresignation_id, $file_upload ) ;
if ( $upload['status'] != '200' ){
$count_upload++ ;
}else{
$mysqli->query( "INSERT INTO formresignation_media
( formresignation_id, file, filetype ) VALUES
( '".$formresignation_id."', '".$upload['data']['file_name']."', '".$upload['data']['file_type']."' )" ) ;
$status = '200' ;
}
}
}
}
pushToUserCron( 'formresignation', $formresignation_id, $array['staff_id_manager'], 'Resignation', 'Resignation '.$formresignation_so.' need your approval or rejection' ) ;
}
}
}
require( $require_sub.'footer.php' ) ;
?>
+42
View File
@@ -0,0 +1,42 @@
<?php
$must_login = true ;
$require_path = '../../../' ;
$require_sub = '../../' ;
require( $require_sub.'header.php' ) ;
if ( $boolean_login ){
$status = '201' ;
$search_query = '' ;
$search_query .= " AND a.form_id = '".$array['id']."'" ;
$query = "SELECT a.form_id, a.file, a.file_type, a.created_at, b.title FROM form a
LEFT JOIN form_translation b ON ( a.form_id = b.form_id )
WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND ( ( a.receiver_type IN ( '0' ) ) OR ( a.receiver_type IN ( '1', '2' ) AND a.staff_id LIKE '%/".$staff_info['staff_id']."/%' ) ) " . $search_query ;
$mysqli_query = $mysqli->query( $query ) ;
if ( $mysqli_query->num_rows > 0 ){
$status = '200' ;
$row = $mysqli_query->fetch_assoc() ;
$file = '' ;
if ( $row['file'] != '' ){
if ( $row['file_type'] == 'pdf' || $row['file_type'] == 'xls' || $row['file_type'] == 'xlsx' || $row['file_type'] == 'doc' || $row['file_type'] == 'docx' ){
$file = PATH.'uploads/Form/'.$row['file'] ;
}else{
$file = PATH.'uploads/Form/b/'.$row['file'] ;
}
}
$row['id'] = dataFilter( $row['form_id'] ) ;
$row['title'] = dataFilter( $row['title'] ) ;
$row['file'] = $file ;
$row['created_at'] = dataFilter( $row['created_at'] ) ;
$data['list'] = $row ;
}
}
require( $require_sub.'footer.php' ) ;
?>

Some files were not shown because too many files have changed in this diff Show More