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