コード例 #1
0
 public function examinerecordAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization("oldhouseDB");
     //-----BI開始-----
     $action = array();
     $action["status"] = false;
     //$VTs->debug($_POST["record"]);
     if (!empty($_POST)) {
         $TargetID = !empty($_POST["record"]["TargetID"]) ? $_POST["record"]["TargetID"] : 0;
         $TypeID = !empty($_POST["record"]["TypeID"]) ? $_POST["record"]["TypeID"] : 0;
         $ScaleID1 = !empty($_POST["record"]["ScaleID1"]) ? $_POST["record"]["ScaleID1"] : null;
         $ScaleID2 = !empty($_POST["record"]["ScaleID2"]) ? $_POST["record"]["ScaleID2"] : null;
         $StructID = !empty($_POST["record"]["StructID"]) ? $_POST["record"]["StructID"] : 0;
         //新增qc_info
         $date = date("Y-m-d");
         //echo $date;
         if ($ScaleID2 != null) {
             $strSQL = "insert into qc_info (huid, htid, htmid1, htmid2, htsid, `date`)\n                     values(" . $TargetID . ", " . $TypeID . ", " . $ScaleID1 . ", " . $ScaleID2 . ", " . $StructID . ", '" . $date . "')";
             //"insert into qc_info (huid, htid, htmid1, htmid2, htsid, `date`)
             // values(".$_POST["record"]["TargetID"].", ".$_POST["record"]["TypeID"].", ".$_POST["record"]["ScaleID1"].", ".$_POST["record"]["ScaleID2"].", ".$_POST["record"]["StructID"].", '".$date."')";
         } else {
             $strSQL = "insert into qc_info (huid, htid, htmid1, htsid, `date`)\n                     values(" . $TargetID . ", " . $TypeID . ", " . $ScaleID1 . ", " . $StructID . ", '" . $date . "')";
         }
         //print_r("qc_info:  " . $strSQL . "<br><br>");
         $VTs->ExecuteNonQuery($strSQL);
         $strSQL = "select uid from qc_info order by uid desc Limit 1";
         //print_r("qc_info_uid:  " . $strSQL . "<br><br>");
         $data = $VTs->QueryData($strSQL);
         $ifid = $data[0]["uid"];
         //新增照片
         $datas = $_POST["record"]["RecordDatas"];
         //print_r("Datas:");
         //$VTs->debug($datas);
         foreach ($datas as $i => $content) {
             //print_r("Imgs:");
             //$VTs->debug($content["imgs"]);
             //圖片存檔
             $Imgs = $content["imgs"];
             $imgId = ImgSet($Imgs);
             //print_r("照片ID:".$imgId);
             //echo "imgID: ". $imgId;
             //計算危險等級
             //$VTs->Debug($content);
             //量化資料才需計算等級,質化資料之Val即為危險等級。
             if ($content["Length"] > 0 || $content["Width"] > 0 || $content["Depth"] > 0 || $content["Area"] > 0) {
                 $content = Quality2Amount($content);
             }
             //$VTs->Debug($content);
             //新增qc_item
             $Length = !empty($content["Length"]) ? $content["Length"] : 0;
             $Width = !empty($content["Width"]) ? $content["Width"] : 0;
             $Depth = !empty($content["Depth"]) ? $content["Depth"] : 0;
             $Area = !empty($content["Area"]) ? $content["Area"] : 0;
             $ValID = !empty($content["ValID"]) ? $content["ValID"] : 0;
             $strSQL = "insert into qc_item (ifid, strid, ciid, `length`, width, depth, `area`, val, imgids, remark) ";
             $strSQL .= "values (" . $ifid . ", " . $content["PlaceID"] . ", " . $content["ProblemID"] . ", " . $Length . ", " . $Width . ", " . $Depth . ", " . $Area . ", " . $ValID . ", " . $imgId . ", '" . $content["Remark"] . "')";
             //print_r("qc_item:  " . $strSQL . "<br><br>");
             $VTs->ExecuteNonQuery($strSQL);
         }
         $action["status"] = true;
     } else {
         $action["msg"] = '新增失敗';
     }
     #產PDF
     $strSQL = "select hname, htel from qc_house where uid = " . $TargetID;
     //print_r($strSQL);
     $data = $VTs->QueryData($strSQL);
     if (!empty($data)) {
         //print_r("產生PDF");
         //print_r("http://211.21.170.18/Oldhouse/report?targetid=".$TargetID."&page=main_page");
         //$VTs->Page2PDF("http://127.0.0.1:200/Oldhouse/report?targetid=".$TargetID, "D:\\php_dev\\AP-Service\\public\\old_house_pdf\\".md5($data[0]["hname"])."-".$data[0]["htel"]);
         //$VTs->Page2PDF("http://192.168.0.188/Oldhouse/report?targetid=".$TargetID, "C:\\xampp\\htdocs\\Construct-Management\\public\\old_house_pdf\\".iconv("utf-8", "big5", $data[0]["hname"])."-".$data[0]["htel"]);
         echo $VTs->Page2PDF("http://211.21.170.18/Oldhouse/report?targetid=" . $TargetID . "&page=main_page", "C:\\xampp\\htdocs\\Construct-Management\\public\\old_house_pdf\\" . iconv("utf-8", "big5", $data[0]["hname"]) . "-" . $data[0]["htel"]);
         echo "<br/>";
         echo $VTs->Page2PDF("http://211.21.170.18/Oldhouse/report?targetid=" . $TargetID . "&page=img_page", "C:\\xampp\\htdocs\\Construct-Management\\public\\old_house_pdf\\" . iconv("utf-8", "big5", $data[0]["hname"]) . "-" . $data[0]["htel"] . "-imgs");
         echo "<br/>";
         // $VTs->Page2PDF("http://127.0.0.1:200/Oldhouse/report?targetid=".$TargetID."&page=main_page", "D:\\php_dev\\Construct-Management\\public\\old_house_pdf\\".iconv("utf-8", "big5", $data[0]["hname"])."-".$data[0]["htel"]);
         // $VTs->Page2PDF("http://127.0.0.1:200/Oldhouse/report?targetid=".$TargetID."&page=img_page", "D:\\php_dev\\Construct-Management\\public\\old_house_pdf\\".iconv("utf-8", "big5", $data[0]["hname"])."-".$data[0]["htel"]."-imgs");
     }
     $pageContent = $VTs->Data2Json($action);
     //-----BI結束-----
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }