<?php
//ini_set('display_errors','1');
//error_reporting(E_ALL);
$page="main";
include("../function/func.php");
session_start();
checkSession();
$info=getOrderDetail($_REQUEST['id']);
//var_dump($info);

if($_REQUEST['insertOneTest']==1){
    $ordersID=$_REQUEST['id'];
    $serialNum=(int)$_REQUEST['serialNum'];
    $testLocat=$_REQUEST['testLocat'];
    $productionDate=$_REQUEST['productionDate'];
    $kN=$_REQUEST['kN'];
    $kgf=$_REQUEST['kgf'];
    $length=$_REQUEST['length'];
    $width=$_REQUEST['width'];
    $area=$_REQUEST['area'];
    $strengthKGF=$_REQUEST['strengthKGF'];
    $strengthMPa=$_REQUEST['strengthMPa'];
    $destructionLocat=$_REQUEST['destructionLocat'];
    $destructionMode=$_REQUEST['destructionMode'];
    createTest($ordersID,$serialNum,$testLocat,$productionDate,$kN,$kgf,$length,$width,$area,$strengthKGF,$strengthMPa,$destructionLocat,$destructionMode);
    header("refresh:0;url=testItemList.php?id=".$_REQUEST['id']);
}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>桂田技術顧問訂單管理系統</title>
    <link href="./css/common.css?id=<?php echo rand(0,10000);?>" rel="stylesheet">
    <link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
    <script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
    <script>
        $( function() {
            $( "#productionDate" ).datepicker({
                showButtonPanel: true,
                dateFormat: 'yy-mm-dd'
            });
        } );
    </script>
  </head>
<body>
    <div class="bgBody">
        <?php include("./module/header.php");?>
        <div class="container">
            <?php include("./module/menu.php");?>
            <div class="mainContent">
                <div class="head">
                    <div class="item title">測試項目資訊</div>
                    <a href="testItemList.php?id=<?php echo $_REQUEST['id'];?>"><div class="item searchInput" style="padding-top:0.3em">回測試項目列表</div></a>
                    <div class="clear"></div>
                </div>
                <div class="testItemList">
                <div class="testItem gray">
                    <form action="insertTestItem.php?insertOneTest=1&id=<?php echo $_REQUEST['id'];?>" method="post">
                        <div class="item"><span style="color:#1b61e4">新增一筆測試項目</span></div>
                        <div class="item">項目編號：<input type="text" name="serialNum" value=""></div>
                        <div class="item">測試位置/樣品名稱：<input type="text" name="testLocat" value=""></div>
                        <div class="item">製作日期：<input type="text" name="productionDate" value="" id="productionDate"></div>
                        <?php if(substr($info[0]['equipUsed'],0,3) =="Pro"){?>
                        <div class="item">抗拉荷重kN：<input type="text" name="kN" id="kN" value=""></div>
                        <div class="item">抗拉荷重kgf：<input type="text" name="kgf" id="kgf" value=""  style="background-color:#ddd;border:0"></div>
                        <?php  }else{?>
                        <div class="item">抗拉荷重kN：<input type="text" name="kN" id="kN" value="" style="background-color:#ddd;border:0"></div>
                        <div class="item">抗拉荷重kgf：<input type="text" name="kgf" id="kgf" value=""  ></div>
                        <?php }?>
                        <div class="item">長度：<input type="text" name="length" id="length" value=""></div>
                        <div class="item">寬度：<input type="text" name="width" id="width" value=""></div>
                        <div class="item">面積：<input type="text" name="area" id="area" value=""></div>
                        <div class="item">強度kgf：<input type="text" name="strengthKGF" id="strengthKGF" value="" readonly="readonly" style="background-color:#ddd;border:0"></div>
                        <div class="item">強度MPa：<input type="text" name="strengthMPa" id="strengthMPa" value="" readonly="readonly" style="background-color:#ddd;border:0"></div>
                        <div class="item">破壞位置：
                        <select name="destructionLocat" id="destructionLocat">
                                <option value="A" <?php if($orderInfo[0]['destructionLocat']=="A"){echo "selected";};?>>A</option>
                                <option value="B" <?php if($orderInfo[0]['destructionLocat']=="B"){echo "selected";};?>>B</option>
                                <option value="C" <?php if($orderInfo[0]['destructionLocat']=="C"){echo "selected";};?>>C</option>
                                <option value="D" <?php if($orderInfo[0]['destructionLocat']=="D"){echo "selected";};?>>D</option>
                                <option value="E" <?php if($orderInfo[0]['destructionLocat']=="E"){echo "selected";};?>>E</option>
                            </select>
                        </div>
                        <div class="item">破壞模式：<input type="text" name="destructionMode" id="destructionMode" value="黏著強度"  style="background-color:#ddd;border:0" readonly="readonly"></div>

                        <div class="input"><input type="submit" value="新增測試"></div>
                    </form>
                </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script src="cal.js"></script>
