public function getDBdataAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization('');
     //-----------BI開始------------
     $page = $_GET['page'];
     switch ($page) {
         case 'typeunit':
             //typeunit單位表
             $strSQL = "select t1.*,t2.name from el_type_unit as t1,eng_type_a as t2 where t1.typeid_a=t2.uid";
             $data = $VTs->QueryData($strSQL);
             break;
         case 'type_a':
             $strSQL = "SELECT * FROM `eng_type_a`";
             $data = $VTs->QueryData($strSQL);
             break;
     }
     $pageContent = $VTs->Data2Json($data);
     //-----------BI結束------------
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function getDBdataAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization();
     try {
         //-----------BI開始------------
         //echo "Receipt getData.";
         $arr = array();
         $arr["status"] = false;
         if (!empty($_GET)) {
             //確認所需資料來源
             $type = isset($_GET["type"]) ? $_GET["type"] : "";
             switch ($type) {
                 case "sulist":
                     $strSQL = "SELECT * FROM `su_supply`";
                     $data = $VTs->QueryData($strSQL);
                     break;
                 default:
                     $arr["msg"] = "Search type is wrong.\n";
                     break;
             }
             //回傳
             if (!empty($data)) {
                 $arr["status"] = true;
                 $arr["data"] = $data;
                 // $arr["msg"] = $strSQL;
             } else {
                 $arr["msg"] = "Query no data.";
                 // $arr["msg"] = $strSQL;
             }
         } else {
             $arr["msg"] = "Have no parameter to query data.";
         }
         $pageContent = $VTs->Data2Json($arr);
         //-----------BI結束------------
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("ReceiptController", "getDataAction", $error->getMessage());
     }
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 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);
 }
 public function getlogoAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization();
     try {
         //-----BI開始-----
         $action = array();
         $action["status"] = false;
         if (!empty($_SESSION["uuid"]) and !empty($_SESSION["userName"])) {
             $logoPath = dirname(__DIR__) . "\\..\\..\\..\\..\\public\\include\\pageSetting\\styles\\logo\\logoContent.html";
             $logoStyle = $VTs->GetHtmlContent($logoPath);
             $action["logoString"] = $logoStyle;
             $action["status"] = true;
         } else {
             $action["msg"] = 'Please Login Again!';
         }
         $pageContent = $VTs->Data2Json($action);
         //-----BI結束-----
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("PageactionController", "acinfoAction", $error->getMessage());
     }
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
Example #5
0
<?php

//跨網域請求
header("Access-Control-Allow-Origin: *");
include "include/config.php";
use System_APService\clsSystem;
$VTs = new clsSystem();
//先初始化
$VTs->initialization('oauth');
$strSQL = "select * from token where access_token = '" . $_POST["access_token"] . "'";
$data = $VTs->QueryData($strSQL);
//從別的系統登入
if ($data[0]["login_type"] == 1) {
    $strSQL = "select a.uuid,a.userName,a.userMail,b.login_date from thirdparty_oauth a ";
    $strSQL .= "left join token b on a.uuid = b.uuid ";
    $strSQL .= "where a.uuid = '" . $data[0]["uuid"] . "'";
    $data = $VTs->QueryData($strSQL);
} else {
    if ($data[0]["login_type"] == 0) {
        $strSQL = "select b.uuid,b.userName,b.userMail,login_date from token a ";
        $strSQL .= "left join account b on a.uuid = b.uuid ";
        $strSQL .= " where a.uuid = '" . $data[0]["uuid"] . "'";
        $data = $VTs->QueryData($strSQL);
    }
}
//$basis->debug($data[0]);
echo $VTs->Data2Json($data[0]);
$VTs = null;
 public function photocountAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization();
     try {
         //-----BI開始-----
         $action = [];
         $action["status"] = false;
         if (isset($_GET["datel"])) {
             $datel = $_GET['datel'];
             if ($datel == 0) {
                 $datel = date("Y-m-d");
             }
             $strSQL = "\n\t            \tSELECT count(t1.uid) AS count\n\t            \tFROM qc_checklist AS t1\n\t\t\t\t\tLEFT JOIN el_petition AS t2 ON t2.uid=t1.dataid\n\t\t\t\t\tLEFT JOIN prj_materiel AS t3 ON t2.prj_mid=t3.uid \n\t\t\t\t\tLEFT JOIN prj_materiel_items AS t4 ON t3.uid=t4.prj_mid\n\t\t\t\t\tLEFT JOIN el_materiel AS t5 ON t4.materielid=t5.uid\n\t\t\t\t\tLEFT JOIN img_picture AS t6 ON t1.imgid = t6.uid\n\t\t\t\t\twhere t1.imgid is not null AND t1.typeid=1\n\t\t\t\t\tAND to_days(t1.datec)=to_days('" . $datel . "')\n\t\t\t\t\torder by t1.uid desc;\n\t\t\t\t";
             $arr = $VTs->QueryData($strSQL);
             if ($arr[0]["count"]) {
                 $action["count"] = $arr[0]["count"];
             } else {
                 $action["count"] = 0;
             }
             $action["status"] = ture;
         } else {
             $action["msg"] = "尚未設定日期";
         }
         //-----BI結束-----
         $pageContent = $VTs->Data2Json($action);
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("IndexController", "indexAction", $error->getMessage());
     }
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function getpurchaseimgAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization();
     try {
         //-----BI開始-----
         $action = [];
         $action["status"] = false;
         if ($_GET["uid"]) {
             //先取出照片檔名
             $strSQL = "select b.imgfile from el_petition as a ";
             $strSQL .= "left join el_purchase_img as b on a.purchase = b.uid ";
             $strSQL .= "where a.uid = '" . $_GET["uid"] . "'";
             $imgFileData = $VTs->QueryData($strSQL);
             $imgFileData = $imgFileData[0]["imgfile"];
             //CreateDirectory
             $filePath = dirname(__DIR__) . "\\..\\..\\..\\..\\public\\purchase_img\\";
             if (file_exists($filePath)) {
                 $filePath .= $imgFileData;
                 $imgArr = $VTs->GetINIInfo($filePath, "", "", "", true);
                 $action["imgs"] = $imgArr;
             } else {
                 $filePath = str_replace("\\", "/", $filePath);
                 if (file_exists($filePath)) {
                     $filePath .= $imgFileData;
                     $imgArr = $VTs->GetINIInfo($filePath, "", "", "", true);
                     $action["imgs"] = $imgArr;
                 } else {
                     $action["msg"] = 'Can not find img files';
                     //$action["test"] = $filePath;
                 }
             }
             //再取出對應說明
             $strSQL = "select uid,img_number,purchase_number,purchase_count from el_purchase where petition_id = '" . $_GET["uid"] . "'";
             $imgMemo = $VTs->QueryData($strSQL);
             $tmpImgMemo = [];
             foreach ($imgMemo as $content) {
                 $tmpImgMemo[$content["img_number"]] = ["uid" => $content["uid"], "purchase_number" => $content["purchase_number"], "purchase_count" => $content["purchase_count"]];
             }
             $action["imgMemo"] = (object) $tmpImgMemo;
             //$action["test"] = $strSQL;
             $action["status"] = true;
         } else {
             $action["msg"] = "id or value is empty";
         }
         $pageContent = $VTs->Data2Json($action);
         //----BI結束----
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("IndexController", "indexAction", $error->getMessage());
     }
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function modifytmpuserdataAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization("tmpCardDB");
     try {
         //-----BI開始-----
         $action = array();
         $action["status"] = false;
         if ($_POST["uid"]) {
             $strSQL = "update tc_user_info set user_id = '" . $_POST["user_id"] . "', name = '" . $_POST["name"] . "', company='" . $_POST["company"] . "', phone='" . $_POST["phone"] . "',admin_edit_date='" . $VTs->DateTime("CTime_Now") . "' where uid =" . $_POST["uid"];
             $VTs->ExecuteNonQuery($strSQL);
             $action["status"] = true;
         } else {
             $action["msg"] = "id or value is empty";
         }
         $pageContent = $VTs->Data2Json($action);
         //----BI結束----
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("IndexController", "indexAction", $error->getMessage());
     }
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function pageAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization();
     //-----BI開始-----
     $action = array();
     $action["status"] = false;
     if (!empty($_POST)) {
         switch ($_POST["type"]) {
             //取得語言
             case "getLan":
                 //如果未設定語系,先設定
                 if (!isset($_SESSION["lang"])) {
                     //先取得語系列表
                     $langListArr = $this->langList();
                     //取得伺服器本身的語言
                     $lang = strtolower(strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ','));
                     $lang = str_replace("zh-", "", $lang);
                     if (!empty($langListArr)) {
                         if (!in_array($lang, $langListArr["list"])) {
                             $lang = 'tw';
                         }
                     } else {
                         $lang = 'tw';
                     }
                 }
                 //取得語言設定檔
                 $langPath = dirname(__DIR__) . "\\..\\..\\..\\..\\public\\include\\language\\";
                 $langPath .= !empty($_POST["selectLang"]) ? $_POST["selectLang"] : $lang;
                 $langPath .= ".ini";
                 if (!file_exists($langPath)) {
                     $langPath = str_replace("\\", "/", $langPath);
                 }
                 if (file_exists($langPath)) {
                     $action["langContent"] = $VTs->GetINIInfo($langPath, "", "", "", true);
                     $action["status"] = true;
                 } else {
                     $action["msg"] = 'Lang File is not Find';
                 }
                 $action["lang"] = $lang;
                 break;
                 //取得語言設定檔
             //取得語言設定檔
             case "getLanContent":
                 if (!empty($_POST["selectLang"])) {
                     $langPath = dirname(__DIR__) . "\\..\\..\\..\\..\\public\\include\\language\\" . $_POST["selectLang"] . ".ini";
                     if (!file_exists($langPath)) {
                         $langPath = str_replace("\\", "/", $langPath);
                     }
                     if (file_exists($langPath)) {
                         $action["langContent"] = $VTs->GetINIInfo($langPath, "", "", "", true);
                         $action["status"] = true;
                     } else {
                         $action["msg"] = 'Lang File is not Find';
                     }
                 } else {
                     $action["msg"] = 'Lang Select is Empty';
                 }
                 break;
         }
     }
     $pageContent = $VTs->Data2Json($action);
     //----BI結束----
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function updateDataAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization();
     try {
         //-----------BI開始------------
         $arr = array();
         $arr["status"] = false;
         if (!empty($_POST)) {
             $table = isset($_POST["table"]) ? $_POST["table"] : "";
             switch ($table) {
                 case "eng_type_a":
                 case "eng_type_b":
                 case "eng_type_c":
                 case "eng_type_d":
                     $ori_name = isset($_POST["ori_name"]) ? $_POST["ori_name"] : "";
                     $code = isset($_POST["code"]) ? $_POST["code"] : "";
                     $name = isset($_POST["name"]) ? $_POST["name"] : "";
                     $unit = isset($_POST["unit"]) ? $_POST["unit"] : "";
                     if ($table != "eng_type_d") {
                         $strSQL = "UPDATE " . $table . "\n\t\t\t\t\t\t\t\t SET name = '" . $name . "'\n\t\t\t\t\t\t\t\t WHERE name = '" . $ori_name . "' AND code = '" . $code . "'";
                     } else {
                         $strSQL = "UPDATE " . $table . "\n\t\t\t\t\t\t\t\t SET name = '" . $name . "', typeid_u = '" . $unit . "'\n\t\t\t\t\t\t\t\t WHERE name = '" . $ori_name . "' AND code = '" . $code . "'";
                     }
                     $VTs->ExecuteNonQuery($strSQL);
                     $strSQL = "SELECT * FROM " . $table . " WHERE name = '" . $name . "' AND code = '" . $code . "'";
                     $data = $VTs->QueryData($strSQL);
                     if (!empty($data)) {
                         $arr["status"] = true;
                         $arr["data"] = $data;
                     } else {
                         $arr["msg"] = "update error.";
                     }
                     break;
                 case "eng_str_b":
                 case "eng_str_e":
                     $ori_code = isset($_POST["ori_code"]) ? $_POST["ori_code"] : "";
                     $ori_name = isset($_POST["ori_name"]) ? $_POST["ori_name"] : "";
                     $code = isset($_POST["code"]) ? $_POST["code"] : "";
                     $name = isset($_POST["name"]) ? $_POST["name"] : "";
                     $ismodel = isset($_POST["ismodel"]) ? $_POST["ismodel"] : "";
                     $strSQL = "UPDATE " . $table . " ";
                     if ($table == "eng_str_b") {
                         $strSQL .= "SET code = '" . $code . "', name = '" . $name . "', ismodel = '" . $ismodel . "'";
                     } else {
                         $strSQL .= "SET code = '" . $code . "', name = '" . $name . "'";
                     }
                     $strSQL .= "WHERE name = '" . $ori_name . "' AND code = '" . $ori_code . "'";
                     $VTs->ExecuteNonQuery($strSQL);
                     $arr["updateSQL"] = $strSQL;
                     $strSQL = "SELECT * FROM " . $table . " WHERE code = '" . $code . "' AND name = '" . $name . "'";
                     $data = $VTs->QueryData($strSQL);
                     if (!empty($data)) {
                         $arr["status"] = true;
                         $arr["msg"] = "修改成功";
                     } else {
                         $arr["msg"] = "修改失敗";
                     }
                     break;
                 default:
             }
         }
         $pageContent = $VTs->Data2Json($arr);
         $this->viewContnet['pageContent'] = $pageContent;
         //-----------BI結束------------
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("EngineeringmanageController", "updateDataAction", $error->getMessage());
     }
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     return new ViewModel($this->viewContnet);
 }
 public function reportAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization('');
     try {
         //-----------BI開始------------
         $arr = array();
         $arr["status"] = false;
         // $nowDate = $VTs->DateTime("CTime");
         $nowDate = isset($_POST["date"]) ? $_POST["date"] : $VTs->DateTime("CTime");
         // $nowDate = "2015-12-02";
         $strSQL = "SELECT COUNT(DISTINCT a.suworkid) w_count, b.suid, b.worksid, c.name supply_name, d.name work_type \n\t\t\t\t\t\t\tFROM su_checktime AS a \n\t\t\t\t\t\t\t\tJOIN su_worker AS b ON a.suworkid=b.uid\n\t\t\t\t\t\t\t\tJOIN su_supply AS c ON b.suid=c.uid\n\t\t\t\t\t\t\t\tJOIN su_type_works AS d ON b.worksid=d.uid\n\t\t\t\t\t\t\tWHERE iotime LIKE '" . $nowDate . "%' \n\t\t\t\t\t\t\tGROUP BY b.suid, b.worksid\n\t\t\t\t\t\t\tORDER BY b.worksid";
         // echo $strSQL;
         // exit;
         $data = $VTs->QueryData($strSQL);
         if (!empty($data)) {
             $arr["status"] = true;
             $arr["data"] = $data;
         }
         $pageContent = $VTs->Data2Json($arr);
         // $pageContent = '[{"w_count":"10","suid":"1","worksid":"2","supply_name":"\u4e1e\u90b5\u71df\u5efa\u5de5\u7a0b\u516c\u53f8","work_type":"\u92fc\u7b4b"},
         // {"w_count":"8","suid":"2","worksid":"2","supply_name":"\u6b63\u4e2d\u71df\u5efa\u5de5\u7a0b\u516c\u53f8","work_type":"\u92fc\u7b4b"},
         // {"w_count":"5","suid":"2","worksid":"3","supply_name":"\u6b63\u4e2d\u71df\u5efa\u5de5\u7a0b\u516c\u53f8","work_type":"\u6df7\u6ce5\u571f"},
         // {"w_count":"20","suid":"1","worksid":"3","supply_name":"\u4e1e\u90b5\u71df\u5efa\u5de5\u7a0b\u516c\u53f8","work_type":"\u6df7\u6ce5\u571f"}]';
         //-----------BI結束------------
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("SARController", "reportAction", $error->getMessage());
     }
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function facebooksigninAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization('oauth');
     //-----------BI開始------------
     //設定資訊陣列
     $uidInfo = array();
     $uidInfo["status"] = false;
     //接收已於Google驗證好的資料
     if ($_POST["authResponse"]["accessToken"]) {
         //1. 先與Google做AccessToken的認證
         $url = "https://graph.facebook.com/v2.5/me?access_token=" . $_POST["authResponse"]["accessToken"];
         $facebookLoginInfo = $VTs->Json2Data($VTs->UrlDataGet($url));
         $facebookUserID = $facebookLoginInfo->id;
         $facebookUserName = $facebookLoginInfo->name;
         //$VTs->debug($facebookLoginInfo);
         //exit();
         //1-1. 確認認證無誤
         if ($facebookUserID) {
             //2. 執行查詢看資料庫是否已有新增過
             //執行查詢
             $strSQL = "select * from thirdparty_oauth where thirdparty_uid = '" . $facebookUserID . "'";
             $data = $VTs->QueryData($strSQL);
             //2-1. 沒有新增過,準備新增
             if (empty($data)) {
                 //執行新增
                 $strSQL = "insert into thirdparty_oauth(thirdparty_uid,userName,oauth_type, approveCode, approveStatus) values('" . $facebookUserID . "','" . $facebookUserName . "',1,'1234',0)";
                 $VTs->ExecuteNonQuery($strSQL);
                 //2-2. 重新執行查詢,並取得UUID
                 $strSQL = "select * from thirdparty_oauth where thirdparty_uid='" . $facebookUserID . "'";
                 $data = $VTs->QueryData($strSQL);
             }
             $uuid = $data[0]["uuid"];
             //驗證USER是否已存在Token
             $strSQL = "select uuid from token where uuid='" . $uuid . "'";
             $TokenData = $VTs->QueryData($strSQL);
             //產生Token,會回傳Login_Code、Access_Token
             $loginArr = $VTs->CreatLoginCodeAndToken($uuid);
             //存到Token資料表中,以供後續Oauth使用
             if ($uuid) {
                 if (empty($TokenData)) {
                     $strSQL = "insert into token(uuid,login_code,access_token,login_from,login_type) values('" . $uuid . "','" . $loginArr["Login_Code"] . "','" . $loginArr["Access_Token"] . "','" . $_SERVER["REMOTE_ADDR"] . "',1)";
                 } else {
                     $strSQL = "update token set login_code='" . $loginArr["Login_Code"] . "',access_token='" . $loginArr["Access_Token"] . "',login_from='" . $_SERVER["REMOTE_ADDR"] . "',login_date='" . date("Y-m-d H:i:s") . "' where uuid='" . $uuid . "'";
                 }
             } else {
                 echo "System error";
                 exit;
             }
             //確定存取Token到資料表中
             $VTs->QueryData($strSQL);
             //紀錄SESSION
             $_SESSION["uuid"] = $uuid;
             $_SESSION["name"] = $data[0]["userName"];
             $_SESSION["mail"] = $data[0]["userMail"];
             $_SESSION["LoginCode"] = $loginArr["Login_Code"];
             $uidInfo["LoginCode"] = $loginArr["Login_Code"];
             $uidInfo["status"] = true;
         } else {
             //1-2. 未通過驗證
             $uidInfo["error"] = 'The Accound is not Sing up!';
             $uidInfo["code"] = '6';
         }
     } else {
         $uidInfo["error"] = 'You did not have Facebook access token!';
         $uidInfo["code"] = '5';
     }
     $this->viewContnet['pageContent'] = $VTs->Data2Json($uidInfo);
     //-----------BI結束------------
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     return new ViewModel($this->viewContnet);
 }
 public function settingmenuAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization();
     //-----BI開始-----
     $action["status"] = false;
     if (@$_POST["uuid"]) {
         $strSQL = "select * from acl_account_position_list where uuid = '" . $_POST["uuid"] . "'";
         $data = $VTs->QueryData($strSQL);
         $position = '';
         if (!empty($data)) {
             foreach ($data as $content) {
                 $position .= $content["position_uid"] . ',';
             }
             $position = substr($position, 0, strlen($position) - 1);
         } else {
             $position = 0;
         }
         if (strpos($position, '99999') >= 0) {
             $uid = $_POST["uid"];
             $click_action = $_POST["click_action"][$uid];
             $click_action = $click_action == 'null' ? "click_action=null, " : "click_action='" . $click_action . "', ";
             $strSQL = "update sys_menu set href='" . $_POST["href"][$uid] . "', ";
             $strSQL .= $click_action;
             $strSQL .= " nid='" . $_POST["nid"][$uid] . "', parent_layer='" . $_POST["parent_layer"][$uid] . "' where uid = " . $uid;
             $action["status"] = true;
             //$action["msg"] = $strSQL;
             $VTs->ExecuteNonQuery($strSQL);
         } else {
             $action["msg"] = 'You Can not Change Menu';
         }
     } else {
         $action["msg"] = 'You Can not Change Menu';
     }
     $pageContent = $VTs->Data2Json($action);
     //-----BI結束-----
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function getDBdataAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization('');
     //-----------BI開始------------
     $type = $_GET['type'];
     switch ($type) {
         //list lobgook主頁
         case 'list':
             $strSQL = "SELECT uid,no,date,dates FROM `eng_diary_info` WHERE to_days(date)!=to_days(now()) order by date desc";
             $data = $VTs->QueryData($strSQL);
             break;
         case 'reportinfo':
             $uid = $_GET['uid'];
             //取得資料資訊
             $strSQL = "SELECT a.*,(select name from sys_type_weather where uid=a.am_wthid) as amweather ," . " (select name from sys_type_weather where uid=a.pm_wthid) as pmweather" . " FROM `eng_diary_info` as a" . " WHERE uid=" . $uid . ";";
             $d = $VTs->QueryData($strSQL);
             $data["info"] = $d[0];
             // $data["info"]['date']="2015-12-04";
             //取得表頭項目
             $strSQL = "SELECT a.name as prjname ,b.name as supplyname,a.days as pday,a.days_m as cday,a.dates as start ,a.datee as end" . " FROM `prj_project` as a" . " left join su_supply as b on a.suid=b.uid" . " where a.uid=1;";
             $d = $VTs->QueryData($strSQL);
             $data["project"] = $d[0];
             $strSQL = "SELECT * FROM `sys_config`";
             $d = $VTs->QueryData($strSQL);
             $data["project"]["supplyname"] = $d["0"]["val"];
             $Ydate = strtotime($data["info"]['date'] . " -1 day");
             //取得進度
             $strSQL = "SELECT price_tbp,price_twp FROM `eng_schedule` WHERE dates='" . date("Y/m/d", $Ydate) . "';";
             $d = $VTs->QueryData($strSQL);
             $data["schedule"] = $d[0];
             if ($data["schedule"]["price_twp"] == 0 && $data["schedule"] != null) {
                 $strSQL = "SELECT price_twp FROM `eng_schedule` WHERE price_twp <>0 order by dates desc limit 1";
                 $d = $VTs->QueryData($strSQL);
                 $data["schedule"]['price_twp'] = $d[0]['price_twp'];
             }
             //材料管理
             // $strSQL="SELECT c.name as name ,d.unit1 as unit,b.count as pcount,b.count_in as incount, sum(a.count) as count"
             //         ." FROM `el_petition`  as a"
             //         ." left join prj_materiel as b on a.prj_mid=b.uid"
             //         ." left join el_materiel as c on b.materielid=c.uid"
             //         ." left join el_type_unit as d on c.typeid_u=d.uid"
             //         ." left join qc_checklist as e on a.uid=e.dataid"
             //         ." WHERE to_days(e.datec)=to_days('". $data["info"]['date']."') AND e.isok=1 AND e.typeid=1"
             //         ." GROUP BY c.name;";
             // $strSQL="SELECT c.name as name ,d.unit1 as unit,g.count as pcount,g.count_in as incount, sum(a.count) as count"
             //       ." FROM `el_petition` as a"
             //       ." left join prj_materiel as b on a.prj_mid=b.uid"
             //       ." left join prj_materiel_items as f on f.prj_mid=b.uid"
             //       ." left join el_quantity as g on b.prjid=g.prjid and f.materielid=g.materielid"
             //       ." left join el_materiel as c on f.materielid=c.uid"
             //       ." left join el_type_unit as d on c.typeid_u=d.uid"
             //       ." left join qc_checklist as e on a.uid=e.dataid"
             //       ." WHERE to_days(e.datec)=to_days('". $data["info"]['date']."') AND e.typeid=1"
             //       ." GROUP BY c.name";
             $strSQL = "SELECT c.name as name ,d.unit1 as unit,g.qty_w as pcount,g.qty_s as incount, sum(a.count) as count\n                        FROM `el_petition` as a left join prj_materiel as b on a.prj_mid=b.uid \n                        left join prj_materiel_items as f on f.prj_mid=b.uid \n                        left join eng_count_materiel as g on b.prjid=g.prjid and f.materielid=g.materielid \n                        left join el_materiel as c on f.materielid=c.uid \n                        left join el_type_unit as d on c.typeid_u=d.uid \n                        left join qc_checklist as e on a.uid=e.dataid \n                        WHERE to_days(e.datec)=to_days('" . $data["info"]['date'] . "') AND e.typeid=1 AND to_days(g.datew)=to_days('" . $data["info"]['date'] . "') GROUP BY c.name";
             // echo $strSQL;
             // exit;
             $d = $VTs->QueryData($strSQL);
             $data["materielcount"] = $d;
             $date_dash = str_replace('/', '-', $data["info"]['date']);
             //人員數量workcount
             // $strSQL="SELECT COUNT(DISTINCT t1.suworkid) as count,t3.name as wtypename"
             // ." FROM su_checktime AS t1"
             // ." LEFT JOIN su_worker AS t2 ON t1.suworkid=t2.uid"
             // ." LEFT JOIN su_type_works AS t3 ON t2.worksid=t3.uid"
             // ." WHERE t1.iotime like '".$date_dash."%'"
             // ." GROUP BY t3.name;";
             $strSQL = "SELECT COUNT(DISTINCT t1.suworkid) as count,t3.name as wtypename ,t4.count_w,t4.count_s,t2.worksid" . " FROM su_checktime AS t1" . " LEFT JOIN su_worker AS t2 ON t1.suworkid=t2.uid" . " LEFT JOIN su_type_works AS t3 ON t2.worksid=t3.uid" . " LEFT JOIN eng_count_workers AS t4 ON t2.worksid=t4.worksid" . " WHERE t1.iotime like '" . $date_dash . "%' AND t4.datew='" . $data["info"]['date'] . "'" . " GROUP BY t3.name;";
             $d = $VTs->QueryData($strSQL);
             $data["workcount"] = $d;
             // print_R($data["workcount"]);
             // exit;
             // foreach ($data["workcount"] as  $value) {
             //   if(!empty($value["count_s"])){
             //     $strSQL="SELECT count FROM `eng_count_workers` WHERE worksid=".$value["worksid"]." order by uid desc LIMIT 1";
             //     $d = $VTs->QueryData($strSQL);
             //     $value["count_s"]=$d[0]["count_s"];
             //   }
             // }
             //日誌內容
             $strSQL = "SELECT * FROM `eng_diary_contents` WHERE type=2 and date='" . $date_dash . "'";
             $d = $VTs->QueryData($strSQL);
             $data["fifth"] = $d[0]['contents'];
             $strSQL = "SELECT * FROM `eng_diary_contents` WHERE type=4 and date='" . $date_dash . "'";
             $d = $VTs->QueryData($strSQL);
             $data["seventh"] = $d[0]['contents'];
             // $data["info"]['date']='2015-12-02';
             //施工項目
             // $date_con=$data["info"]['date'];
             // echo $date_con;
             // exit;
             // $strSQL="SELECT t4.name n1,t6.unit1, SUM(t1.qty) qty_work,t7.qty qty_budget"
             // ." FROM eng_worklist_areaitem t1"
             // ." LEFT JOIN eng_worklist_workitem t2 ON t2.uid=t1.wl_wiid"
             // ." LEFT JOIN eng_model_area t3 ON t3.uid=t2.m_areaid"
             // ." LEFT JOIN eng_type_c t4 ON t4.uid=t2.typeid_c"
             // ." LEFT JOIN eng_model_area t5 ON t5.uid=t2.m_areaid"
             // ." LEFT JOIN el_type_unit t6 ON t6.uid=t5.typeid_u"
             // ." left join eng_budgetbon t7 on t7.typeid_c=t2.typeid_c"
             // ." WHERE t1.datee LIKE '".$date_dash."%' and t1.isfinish=1"
             // ." GROUP BY t1.wl_wiid";
             $strSQL = "SELECT t4.name n1,t6.unit1, SUM(t1.qty) qty_work,t7.qty qty_budget,t8.qty_s,t2.typeid_c" . " FROM eng_worklist_areaitem t1" . " LEFT JOIN eng_worklist_workitem t2 ON t2.uid=t1.wl_wiid" . " LEFT JOIN eng_model_area t3 ON t3.uid=t2.m_areaid" . " LEFT JOIN eng_type_c t4 ON t4.uid=t2.typeid_c" . " LEFT JOIN eng_model_area t5 ON t5.uid=t2.m_areaid" . " LEFT JOIN el_type_unit t6 ON t6.uid=t5.typeid_u" . " left join eng_budgetbon t7 on t7.typeid_c=t2.typeid_c" . " LEFT JOIN eng_count_typec t8 ON t8.typeid_c=t2.typeid_c" . " WHERE t1.datee LIKE '" . $date_dash . "%' and t1.isfinish=1 AND t8.datew='" . $data["info"]['date'] . "'" . " GROUP BY t4.name ,t6.unit1";
             $d = $VTs->QueryData($strSQL);
             $data["construction"] = $d;
             // foreach ($data["construction"] as  $value) {
             //   if(!empty($value["qty_s"])){
             //     $strSQL="SELECT qty_s FROM `eng_count_typec` WHERE typeid_c=".$value["typeid_c"]." order by uid desc LIMIT 1";
             //     $d = $VTs->QueryData($strSQL);
             //     $value["qty_s"]=$d[0]["qty_s"];
             //   }
             // }
             break;
         case 'setcontent':
             $strSQL = "SELECT * FROM eng_diary_info WHERE to_days(datec)=to_days(now())";
             $d = $VTs->QueryData($strSQL);
             $data['content'] = $d[0];
             $strSQL = "SELECT * FROM `sys_type_weather`;";
             $d = $VTs->QueryData($strSQL);
             $data['weather'] = $d;
             //取得表頭項目
             $strSQL = "SELECT a.name as prjname ,b.name as supplyname,a.days as pday,a.days_m as cday,a.dates as start ,a.datee as end" . " FROM `prj_project` as a" . " left join su_supply as b on a.suid=b.uid" . " where a.uid=1;";
             $d = $VTs->QueryData($strSQL);
             $data["project"] = $d[0];
             $strSQL = "SELECT * FROM `sys_config`";
             $d = $VTs->QueryData($strSQL);
             $data["project"]["supplyname"] = $d["0"]["val"];
             //取得進度
             // $strSQL="SELECT price_tbp,price_twp FROM `eng_schedule` WHERE dates='".date("Y/m/d",strtotime("-1 day"))."';";
             $strSQL = "SELECT price_tbp FROM `eng_schedule` WHERE dates='" . date("Y/m/d") . "';";
             $d = $VTs->QueryData($strSQL);
             $data["schedule"] = $d[0];
             // if($data["schedule"]["price_twp"]==0){
             //   $strSQL="SELECT price_twp FROM `eng_schedule` WHERE price_twp <>0 order by dates desc limit 1";
             //   $d = $VTs->QueryData($strSQL);
             //   $data["schedule"]['price_twp']=$d[0]['price_twp'];
             // }
             //材料管理
             // $strSQL="SELECT c.name as name ,d.unit1 as unit,b.count as pcount,b.count_in as incount, sum(a.count) as count"
             //         ." FROM `el_petition`  as a"
             //         ." left join prj_materiel as b on a.prj_mid=b.uid"
             //         ." left join el_materiel as c on b.materielid=c.uid"
             //         ." left join el_type_unit as d on c.typeid_u=d.uid"
             //         ." left join qc_checklist as e on a.uid=e.dataid"
             //         ." WHERE to_days(e.datec)=to_days('".date('Y-m-d')."') AND e.typeid=1"
             //         ." GROUP BY c.name;";
             $strSQL = "SELECT c.name as name ,d.unit1 as unit,g.count as pcount,g.count_in as incount, sum(a.count) as count" . " FROM `el_petition` as a" . " left join prj_materiel as b on a.prj_mid=b.uid" . " left join prj_materiel_items as f on f.prj_mid=b.uid" . " left join el_quantity as g on b.prjid=g.prjid and f.materielid=g.materielid" . " left join el_materiel as c on f.materielid=c.uid" . " left join el_type_unit as d on c.typeid_u=d.uid" . " left join qc_checklist as e on a.uid=e.dataid" . " WHERE to_days(e.datec)=to_days('" . date('Y-m-d') . "') AND e.typeid=1" . " GROUP BY c.name";
             $d = $VTs->QueryData($strSQL);
             $data["materielcount"] = $d;
             //人員數量workcount
             $strSQL = "SELECT COUNT(DISTINCT t1.suworkid) as count,t3.name as wtypename" . " FROM su_checktime AS t1" . " LEFT JOIN su_worker AS t2 ON t1.suworkid=t2.uid" . " LEFT JOIN su_type_works AS t3 ON t2.worksid=t3.uid" . " WHERE t1.iotime like '" . date('Y-m-d') . "%'" . " GROUP BY t3.name;";
             // $strSQL="SELECT COUNT(DISTINCT t1.suworkid) as count,t3.name as wtypename ,t4.count_w,t4.count_s,t2.worksid"
             //         ." FROM su_checktime AS t1"
             //         ." LEFT JOIN su_worker AS t2 ON t1.suworkid=t2.uid"
             //         ." LEFT JOIN su_type_works AS t3 ON t2.worksid=t3.uid"
             //         ." LEFT JOIN eng_count_workers AS t4 ON t2.worksid=t4.worksid"
             //         ." WHERE t1.iotime like '".date('Y-m-d')."%' AND t4.datew='".date('Y/m/d')."'"
             //         ." GROUP BY t3.name;";
             $d = $VTs->QueryData($strSQL);
             $data["workcount"] = $d;
             // foreach ($data["workcount"] as  $value) {
             //   if(!empty($value["count_s"])){
             //     $strSQL="SELECT count FROM `eng_count_workers` WHERE worksid=".$value["worksid"]." order by uid desc LIMIT 1";
             //     $d = $VTs->QueryData($strSQL);
             //     $value["count_s"]=$d[0]["count_s"];
             //   }
             // }
             //日誌內容
             $strSQL = "SELECT * FROM `eng_diary_contents` WHERE type=2 and date='" . date('Y-m-d') . "'";
             $d = $VTs->QueryData($strSQL);
             $data["fifth"] = $d[0]['contents'];
             $strSQL = "SELECT * FROM `eng_diary_contents` WHERE type=4 and date='" . date('Y-m-d') . "'";
             $d = $VTs->QueryData($strSQL);
             $data["seventh"] = $d[0]['contents'];
             // $data["info"]['date']='2015-12-02';
             //施工項目
             // $strSQL="SELECT t4.name n1,t6.unit1, SUM(t1.qty) qty_work,t7.qty qty_budget"
             //         ." FROM eng_worklist_areaitem t1"
             //         ." LEFT JOIN eng_worklist_workitem t2 ON t2.uid=t1.wl_wiid"
             //         ." LEFT JOIN eng_model_area t3 ON t3.uid=t2.m_areaid"
             //         ." LEFT JOIN eng_type_c t4 ON t4.uid=t2.typeid_c"
             //         ." LEFT JOIN eng_model_area t5 ON t5.uid=t2.m_areaid"
             //         ." LEFT JOIN el_type_unit t6 ON t6.uid=t5.typeid_u"
             //         ." left join eng_budgetbon t7 on t7.typeid_c=t2.typeid_c"
             //         ." WHERE t1.datee LIKE '".date('Y-m-d')."%' and t1.isfinish=1"
             //         ." GROUP BY t1.wl_wiid";
             $strSQL = "SELECT t4.name n1,t6.unit1, SUM(t1.qty) qty_work,t7.qty qty_budget,t8.qty_s,t2.typeid_c" . " FROM eng_worklist_areaitem t1" . " LEFT JOIN eng_worklist_workitem t2 ON t2.uid=t1.wl_wiid" . " LEFT JOIN eng_model_area t3 ON t3.uid=t2.m_areaid" . " LEFT JOIN eng_type_c t4 ON t4.uid=t2.typeid_c" . " LEFT JOIN eng_model_area t5 ON t5.uid=t2.m_areaid" . " LEFT JOIN el_type_unit t6 ON t6.uid=t5.typeid_u" . " left join eng_budgetbon t7 on t7.typeid_c=t2.typeid_c" . " LEFT JOIN eng_count_typec t8 ON t8.typeid_c=t2.typeid_c" . " WHERE t1.datee LIKE '" . date('Y-m-d') . "%' and t1.isfinish=1 AND t8.datew='" . date('Y/m/d') . "'" . " GROUP BY t4.name ,t6.unit1";
             $d = $VTs->QueryData($strSQL);
             $data["construction"] = $d;
             //累計數量
             break;
         case 'laborsafety':
             $strSQL = "SELECT dates FROM `eng_diary_info` WHERE date='" . date('Y/m/d') . "';";
             $d = $VTs->QueryData($strSQL);
             $data['dates'] = $d[0]['dates'];
             $strSQL = "SELECT * FROM `eng_diary_contents` WHERE type=2 AND date='" . date('Y-m-d') . "';";
             $d = $VTs->QueryData($strSQL);
             $data['fifth'] = $d[0];
             $strSQL = "SELECT * FROM `eng_diary_contents` WHERE type=4 AND date='" . date('Y-m-d') . "';";
             $d = $VTs->QueryData($strSQL);
             $data['seventh'] = $d[0];
             break;
     }
     // $data = $VTs->QueryData($strSQL);
     $pageContent = $VTs->Data2Json($data);
     //-----------BI結束------------
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function exitotherselectitemAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization();
     //-----------BI開始------------
     try {
         $action = [];
         $action["status"] = false;
         $petitionlist_id = "";
         $strSQL = "select * from el_exit_type where uid not in (3,5) order by uid asc";
         $data = $VTs->QueryData($strSQL);
         if (!empty($data)) {
             $action["list"] = $data;
             $action["status"] = true;
         } else {
             $action["msg"] = "select item is empty";
         }
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("IndexController", "indexAction", $error->getMessage());
     }
     $pageContent = $VTs->Data2Json($action);
     //-----------BI結束------------
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function insertDataAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization();
     try {
         //-----------BI開始------------
         //echo "Receipt insertData.";
         $arr = array();
         $arr["status"] = false;
         if (!empty($_POST)) {
             $dates = isset($_POST["dates"]) ? $_POST["dates"] : "";
             $datee = isset($_POST["datee"]) ? $_POST["datee"] : "";
             $amount = isset($_POST["amount"]) ? $_POST["amount"] : "";
             $prjid_su = isset($_POST["prjid_su"]) ? $_POST["prjid_su"] : "";
             $suid = isset($_POST["suid"]) ? $_POST["suid"] : "";
             $date_pay = isset($_POST["date_pay"]) ? $_POST["date_pay"] : "";
             //取得目前單號
             $date = date("Ym");
             $date = substr($date, 1);
             $strSQL = "SELECT voucher FROM acc_payment WHERE voucher like '%" . $date . "%' ORDER BY uid desc LIMIT 1";
             $data = $VTs->QueryData($strSQL);
             if (!empty($data)) {
                 $voucher = getVoucher($data[0]["voucher"]);
             } else {
                 $voucher = "A" . $date . "0001";
             }
             //新增資料
             $strSQL = "INSERT INTO acc_payment (voucher, dates, datee, amount, prjid_su, suid, date_pay)\n\t\t\t\t\t VALUES ('" . $voucher . "', '" . $dates . "', '" . $datee . "', '" . $amount . "', '" . $prjid_su . "', '" . $suid . "', '" . $date_pay . "')";
             $VTs->ExecuteNonQuery($strSQL);
             //確認是否新增成功
             $strSQL = "SELECT * FROM acc_payment WHERE voucher = '" . $voucher . "'";
             $data = $VTs->QueryData($strSQL);
             if (!empty($data)) {
                 $strSQL = "UPDATE acc_schedule\n\t\t\t\t\t\t SET payid = '" . $data[0]["uid"] . " '\n\t\t\t\t\t\t WHERE prjid_su = '" . $data[0]["prjid_su"] . "'";
                 $VTs->ExecuteNonQuery($strSQL);
                 $arr["status"] = true;
             } else {
                 $arr["msg"] = "Data does not insert into table.";
             }
         } else {
             $arr["msg"] = "No insert data.";
         }
         $pageContent = $VTs->Data2Json($arr);
         //-----------BI結束------------
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("ReceiptController", "insertDataAction", $error->getMessage());
     }
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }
 public function updateDataAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization();
     try {
         //-----------BI開始------------
         $arr = $_POST;
         $uid = $_GET["uid"];
         if (!empty($arr)) {
             //update basicInfo
             $strSQL = "UPDATE emp_common \n\t\t\t\t\t\t\tSET name = '" . $arr["name"] . "', sid = '" . $arr["sid"] . "', sex = '" . $arr["sex"] . "', birthday = '" . $arr["birthday"] . "'\n\t\t\t\t\t\t\tWHERE uid = '" . $uid . "'";
             $VTs->ExecuteNonQuery($strSQL);
             //update address
             $strSQL = "UPDATE emp_common_address\n\t\t\t\t\t\t\tSET zip = '" . $arr["zip"] . "', city = '" . $arr["city"] . "', area = '" . $arr["area"] . "', vil = '" . $arr["vil"] . "', verge = '" . $arr["verge"] . "', road = '" . $arr["road"] . "', addr = '" . $arr["addr"] . "'\n\t\t\t\t\t\t\tWHERE memid = '" . $uid . "'";
             $VTs->ExecuteNonQuery($strSQL);
             //get belong id
             $strSQL = "SELECT uid FROM emp_common WHERE name = '" . $arr["belong"] . "'";
             $belongUid = $VTs->QueryData($strSQL);
             //update communication
             if (!empty($belongUid)) {
                 $strSQL = "UPDATE emp_common_communication\n\t\t\t\t\t\t\t\tSET belong = '" . $belongUid[0]["uid"] . "', relationid = '" . $arr["relation"] . "', mobile = '" . $arr["mobile"] . "', tel_h = '" . $arr["tel_h"] . "', tel_o = '" . $arr["tel_o"] . "', tel_ext = '" . $arr["tel_ext"] . "', email = '" . $arr["email"] . "'\n\t\t\t\t\t\t\t\tWHERE memid = '" . $uid . "'";
                 $VTs->ExecuteNonQuery($strSQL);
             } else {
                 $strSQL = "UPDATE emp_common_communication\n\t\t\t\t\t\t\t\tSET relationid = '" . $arr["relation"] . "', mobile = '" . $arr["mobile"] . "', tel_h = '" . $arr["tel_h"] . "', tel_o = '" . $arr["tel_o"] . "', tel_ext = '" . $arr["tel_ext"] . "', email = '" . $arr["email"] . "'\n\t\t\t\t\t\t\t\tWHERE memid = '" . $uid . "'";
                 $VTs->ExecuteNonQuery($strSQL);
             }
             $pageContent = $VTs->Data2Json($arr);
         } else {
             $pageContent = "Error";
         }
         //-----------BI結束------------
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("EmployeemanageController", "updateDataAction", $error->getMessage());
     }
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     $this->viewContnet['pageContent'] = $pageContent;
     return new ViewModel($this->viewContnet);
 }