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

$status                  = '300' ;

$commission_array = $array['commission_array'];

if ( count($commission_array) > 0 ){

    $status = '203';
    foreach($commission_array as $key => $value){
        $staff_id = $value['staff_id'];
        $commission_num = $value['commision_student_count'];
        $commission = $value['commission'];
        $month = $value['month'];

        $query_commission_temp = $mysqli->query("SELECT temp_id FROM staff_commission_temp WHERE staff_id='$staff_id' AND month='$month'");
        if(mysqli_num_rows($query_commission_temp)==0){
              $insert = $mysqli->query("INSERT INTO staff_commission_temp (staff_id, commission_num, commission, month) VALUES ('$staff_id', '$commission_num', '$commission', '$month') ");
        }
    }

    if($insert){
        $status = '200';
    }

}

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