<?php
// update every 12 oclock
include '../connect/cms-config.php' ;
include '../requires/function.php' ;

$select = $mysqli->query( "SELECT * FROM setting_holiday 
						   WHERE deleted_at IS NULL AND holiday_date = '".date('Y-m-d', time())."' LIMIT 1" ) ;
if ( $select->num_rows > 0 ){
	$row_select = $select->fetch_assoc() ;

	$mysqli_staff = $mysqli->query("SELECT staff_id, staff_name, staff_idno FROM staff
									WHERE ( staff_date_resigned IS NULL || staff_date_resigned = '0000-00-00' || staff_date_resigned >= '".TODAYDATE."' ) AND deleted_at IS NULL ") ;
	if ( $mysqli_staff->num_rows > 0 ){
		while ( $row_staff = $mysqli_staff->fetch_assoc() ){
			pushToUserCron( 'holiday', $row_select['holiday_id'], $row_staff['staff_id'], 'Holiday', 'It is public holiday today ( '.$row_select['holiday_name'].' ), kindly enjoy.' ) ;
		}
	}

}

?>