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