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

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

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

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

        $query         = "SELECT staff_id, training_so, status FROM staff_training
                          WHERE deleted_at IS NULL " . $search_query ;
        $mysqli_query  = $mysqli->query( $query ) ;

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

            $row        = $mysqli_query->fetch_assoc() ;

            if ( $row['status'] == 'confirmed' ){
                $status = '200' ;

                $mysqli->query( "UPDATE staff_training SET 
                                 rated         = '".$array['training_rated']."',
                                 comment       = '".$array['training_comment']."',
                                 status        = 'rated'
                                 WHERE view_id = '".$array['view_id']."'" ) ;

                $remark = 'Review training ( '.$row['training_so'].' ) to get points' ;
                pointMovement( 'training', $array['view_id'], '1time', 'normal', $row['staff_id'], 0, $remark ) ;
                pushToUserCron( 'staff_training', $array['view_id'], $row['staff_id'], 'Review Point', $remark ) ;

            }

        }

    }

}

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