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

$status         = '300' ;

$qrocde 		= $array['qrcode'] ;

if ( $qrocde   != '' ){
	$status     = '307' ;

    if ( strpos($qrocde, 'AS') !== false ) {
        $status             = '303' ;

        if ( $staff_info['staff_settings']['checkassociation'] == 'yes' ){
            $status         = '201' ;

            $select         = $mysqli->query( "SELECT view_id, status FROM staff_association 
                                               WHERE deleted_at IS NULL AND association_so = '".$qrocde."' LIMIT 1" ) ;
            if ( $select->num_rows > 0 ){
                $status     = '299' ;

                $row        = $select->fetch_assoc() ;

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

                    $mysqli->query( "UPDATE staff_association SET
                                     status        = 'confirmed'
                                     WHERE view_id = '".$row['view_id']."'" ) ;
                }

            }

        }

    }

    

    if ( strpos($qrocde, 'TN') !== false ) {
        $status             = '303' ;

        if ( $staff_info['staff_settings']['checktraining'] == 'yes' ){
            $status         = '201' ;

            $select         = $mysqli->query( "SELECT view_id, status FROM staff_training 
                                               WHERE deleted_at IS NULL AND training_so = '".$qrocde."' LIMIT 1" ) ;
            if ( $select->num_rows > 0 ){
                $status     = '299' ;

                $row        = $select->fetch_assoc() ;

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

                    $mysqli->query( "UPDATE staff_training SET
                                     status        = 'confirmed'
                                     WHERE view_id = '".$row['view_id']."'" ) ;
                }

            }
        }
    }
	
}

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