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