<?php
$must_login            = true ;
$require_path          = '../../../' ;
$require_sub           = '../../' ;
require( $require_sub.'header.php' ) ;

if ( $boolean_login ){
    $status            = '300' ;

    $is_going          = $array['is_going'] ;
    $update_status     = ( $is_going == 'yes' ? 'confirmed' : 'cancelled' ) ;

    if ( $array['id'] != '' && $array['view_id'] != '' && $is_going != '' ){
        $status        = '201' ;

        $search_query  = '' ;
        $search_query .= " AND training_id = '".$array['id']."'" ;

        $query         = "SELECT training_id, training_type, date_start, date_end, file, status, created_at FROM training
                          WHERE deleted_at IS NULL " . $search_query ;
        $mysqli_query  = $mysqli->query( $query ) ;

        if ( $mysqli_query->num_rows > 0 ){
            $status    = '200' ;

            $row       = $mysqli_query->fetch_assoc() ;

            $mysqli->query( "UPDATE staff_training SET 
                             is_going      = '".$array['is_going']."',
                             status        = '".$update_status."'
                             WHERE view_id = '".$array['view_id']."'" ) ;

        }

    }

}

require( $require_sub.'footer.php' ) ;
?>