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
+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' ) ;
?>