<?php
header('Content-Type: application/json; charset=utf-8');
include("../function/func.php");
$data = json_decode(file_get_contents('php://input'), true);
$line = json_encode($data);
$f=fopen("createTest.log","a+");
fwrite($f,$line."\r\n");
fclose($f);
$orderID=$data['orderID'];
$resultCode['retCode']=1;
$resultCode['resMessage']="";
for($i=0;$i<count($data['test']);$i++){
    $serialNum=(int)$data['test'][$i]['serialNum'];
    $testLocat=$data['test'][$i]['testLocat'];
    $productionDate=$data['test'][$i]['productionDate'];
    $kN=$data['test'][$i]['kN'];
    $kgf=$data['test'][$i]['kgf'];
    $length=$data['test'][$i]['length'];
    $width=$data['test'][$i]['width'];
    $area=$data['test'][$i]['area'];
    $strengthKGF=$data['test'][$i]['strengthKGF'];
    $strengthMPa=$data['test'][$i]['strengthMPa'];
    $destructionLocat=$data['test'][$i]['destructionLocat'];
    $destructionMode=$data['test'][$i]['destructionMode'];
    //$line=$orderID."##".$serialNum."##".$testLocat."##".$productionDate."##".$kN."##".$kgf."##".$length."##".$width."##".$area."##".$strengthKGF."##".$strengthMPa."##".$destructionLocat."##".$destructionMode;
    $id=getIDFromOrderID($orderID);
    $result=createTest($id,$serialNum,$testLocat,$productionDate,$kN,$kgf,$length,$width,$area,$strengthKGF,$strengthMPa,$destructionLocat,$destructionMode);
    if($result!=1){
        $resultCode['retCode']=0;
        $resultCode['resMessage']=$result;
        break;
    }
}
echo json_encode($resultCode);
?>