alert("Sorry, you don\'t have permission to view the page");' ;
exit ;
}
$mysqli_page = $mysqli->query( "SELECT * FROM staff_employment
WHERE employment_id = '".$page."' AND employment_trash = '0' LIMIT 1" ) ;
if ( $mysqli_page->num_rows == 0 ){
echo '' ;
exit ;
}
$row_page = $mysqli_page->fetch_assoc() ;
$branch_hr_email = '' ;
$branch_hr_cc = [] ;
$branch_email_footer = '' ;
$mysqli_branch = $mysqli->query( "SELECT * FROM branch
WHERE deleted_at IS NULL AND branch_id = '".$row_page['employment_branch']."' LIMIT 1" ) ;
if ( $mysqli_branch->num_rows == 0 ){
echo '' ;
exit ;
}
$row_branch = $mysqli_branch->fetch_assoc() ;
$branch_name = dataFilter( $row_branch['branch_name'] ) ;
$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'] ) ) ;
$mysqli_schedule_date = $mysqli->query("SELECT weekdays FROM setting_employment_schedule
WHERE deleted_at IS NULL LIMIT 1") ;
if ( $mysqli_schedule_date->num_rows == 0 ){
echo '' ;
exit ;
}
$row_schedule_date = $mysqli_schedule_date->fetch_assoc() ;
$weekdays = json_decode( $row_schedule_date['weekdays'] ) ;
// get position
$mysqli_position = $mysqli->query("SELECT a.job_position_id, 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 = 'en' AND a.job_position_id = '".$row_page['employment_position']."' LIMIT 1") ;
$job_position_desc = '' ;
if ( $mysqli_position->num_rows > 0 ){
$row_position = $mysqli_position->fetch_assoc() ;
$job_position_desc = $row_position['job_position_desc'] ;
}
// page header
$letter_head = getOwnerCompanyLetterHead($branch_id) ;
$header = $letter_head['header'] ;
if ( $_POST['hidden'] != '' ){
$employment_interview_date = escapeString($_POST['employment_interview_date']) ;
$is_reschedule = escapeString($_POST['is_reschedule']) ;
$error = 'Selected date was select by other candidate' ;
$select_check_date = $mysqli->query( "SELECT * FROM staff_employment
WHERE employment_id != '".$page."' AND employment_trash = '0' AND ( employment_interview_date = '".$employment_interview_date."' OR employment_r_candidate = '".$employment_interview_date."' ) LIMIT 1" ) ;
if ( $select_check_date->num_rows == 0 ){
$error = 'Cannot set schedule date' ;
$is_sendemail = '' ;
switch ( $is_reschedule ){
case 'no' :
$error = 'Failed to update' ;
if ( $mysqli->query( "UPDATE staff_employment SET
employment_status = 'Processing Interview Slot',
employment_interview_date = '".$employment_interview_date."'
WHERE employment_id = '".$page."'" ) ){
$descrition = 'Candidate schedule interview date to ' . $employment_interview_date . '.' ;
$mysqli->query( "INSERT INTO system_log_employment (log_table, log_action, log_page_id, log_page_name, log_user_id, log_description, log_record, log_date) VALUES
( 'employment', 'update-status', '200', 'AF-".$page."', '', '".$descrition."', '', NOW())" ) ;
$is_sendemail = 'selected' ;
$error = 'Success' ;
}
break ;
case 'yes' :
$error = 'Failed to update' ;
if ( $mysqli->query( "UPDATE staff_employment SET
employment_status = 'Reschedule',
employment_r_interview_date = '".$employment_interview_date."',
employment_r_candidate = '1'
WHERE employment_id = '".$page."'" ) ){
$descrition = 'Candidate reschedule interview date from ' . $row_page['employment_interview_date'] . ' to ' . $employment_interview_date ;
$mysqli->query( "INSERT INTO system_log_employment (log_table, log_action, log_page_id, log_page_name, log_user_id, log_description, log_record, log_date) VALUES
( 'employment', 'update-status', '200', 'AF-".$page."', '', '".$descrition."', '', NOW())" ) ;
$is_sendemail = 'reschedule' ;
$error = 'Success' ;
}
break ;
}
if ( $is_sendemail ){
$mailer->from = $branch_hr_email ;
$mailer->fromname = COMPANY ;
$mailer->to = [ $branch_hr_email ] ;
if ( count($branch_hr_cc) > 0 ){
$mailer->cc = $branch_hr_cc ;
}
$mailer->subject = 'Reminder for Recruitment' ;
$mailer->body = 'Dear HR, '.ucwords($row_page['employment_name']).' has '.$is_sendemail.' interview slot for '.$job_position_desc.'. Please log in to review.
* This is an auto-generated message, please do not reply.' ;
$mailer->send() ;
}
}
$_SESSION['system_error'] = $error ;
header( "Refresh:0;" ) ;
exit ;
}
?>