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 indexAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization();
     try {
         //-----------BI開始------------
         //執行查詢
         $strSQL = "select * from account";
         $data = $VTs->QueryData($strSQL);
         //debug,印出資料用
         $VTs->debug($data);
         //日期轉換
         $date = date("Y-m-d");
         $changeDate = $VTs->DateTime("ADyyyyMMdd_RCyyyMMdd", $date);
         $this->viewContnet['pageContent'] = $changeDate;
         //-----------BI結束------------
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("IndexController", "indexAction", $error->getMessage());
     }
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     return new ViewModel($this->viewContnet);
 }
 public function orginmenuAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization();
     $strSQL = "select uid,nid,parent_layer,class_style,href,click_action from sys_menu ";
     $strSQL .= "order by sequence,uid asc";
     $data = $VTs->QueryData($strSQL);
     $this->viewContnet['pageContent'] = $VTs->Data2Json($data);
     return new ViewModel($this->viewContnet);
 }
Esempio n. 4
0
 public function indexAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization();
     //-----------BI開始------------
     //執行查詢
     $strSQL = "select * from account";
     $data = $VTs->QueryData($strSQL);
     //資料轉換
     $data = $VTs->Data2Array($data);
     //debug,印出資料用
     $VTs->debug($data);
     //日期轉換
     $date = date("Y-m-d");
     $changeDate = $VTs->DateTime("ADyyyyMMdd_RCyyyMMdd", $date);
     $this->viewContnet['pageContent'] = $changeDate;
     //-----------BI結束------------
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     return new ViewModel($this->viewContnet);
 }
Esempio n. 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 usercarddetailAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization("tmpCardDB");
     try {
         //-----BI開始-----
         $action = array();
         $action["status"] = false;
         if ($_POST["uid"]) {
             //先尋找已新增卡片資料
             $strSQL = "select ui.uid, ci.number, ui.user_id, ui.name, ui.purpose, ui.use_date, ui.company, ui.phone, img.imgfile from tc_user_info as ui ";
             $strSQL .= "left join tc_card_info as ci on ui.card_id = ci.uid ";
             $strSQL .= "left join tc_img as img on ui.img_id = img.uid ";
             $strSQL .= "where ui.uid = " . $_POST["uid"];
             $data = $VTs->QueryData($strSQL);
             if (!empty($data)) {
                 $filePath = dirname(__DIR__) . "\\..\\..\\..\\..\\public\\tmpcard_img\\";
                 if (file_exists($filePath)) {
                     $filePath .= $data[0]["imgfile"];
                     $imgArr = $VTs->GetINIInfo($filePath, "", "", "", true);
                 } else {
                     $imgArr = 'Can not find img files';
                 }
                 $data[0]["imgfile"] = $imgArr;
                 $action["ui_data"] = $data;
                 $action["status"] = true;
             } else {
                 $action["msg"] = "暫無資料";
             }
         } else {
             $action["msg"] = "id 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 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 dbmodifyAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization('');
     //-----------BI開始------------
     $type = $_POST['type'];
     switch ($type) {
         case "chkorder":
             $strSQL = '';
             $ls_uid = $_POST['id'];
             $arr_uid = explode(",", $ls_uid);
             foreach ($arr_uid as $uid) {
                 $strSQL .= "UPDATE `el_petition` SET `check`=1,`datel`='" . $VTs->DateTime("CTime_Now") . "' WHERE uid=" . $uid . ";";
             }
             $VTs->ExecuteNonQuery($strSQL);
             break;
         case "chkin":
             $uid = $_POST['id'];
             $count = $_POST['count'];
             $strSQL = "UPDATE `el_petition` SET `datein`='" . $VTs->DateTime("CTime_Now") . "' WHERE uid=" . $uid . ";";
             $VTs->ExecuteNonQuery($strSQL);
             $quid = $_POST['quid'];
             $count = $_POST['count'];
             $strSQL = "SELECT count_order,count_in FROM `el_quantity` WHERE uid=" . $quid . ";";
             $d = $VTs->QueryData($strSQL);
             $data = $d[0];
             $count_order = $data['count_order'] - $count;
             $count_in = $data['count_in'] + $count;
             $strSQL = "UPDATE el_quantity SET count_order=" . $count_order . ", count_in =" . $count_in . " WHERE uid=" . $quid . ";";
             $VTs->ExecuteNonQuery($strSQL);
             break;
     }
     //-----------BI結束------------
     //關閉資料庫連線
     $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 DBinsertAction()
 {
     $VTs = new clsSystem();
     //先初始化
     $VTs->initialization();
     //-----------BI開始------------
     $strSQL = '';
     $data = $_POST;
     $type = $data['type'];
     switch ($type) {
         case 'laborsafety':
             $strSQL = "INSERT INTO `eng_diary_contents` (`uid`, `date`, `Identity`, `type`, `contents`) VALUES (NULL, '" . date('Y-m-d') . "', '1', '2', '" . $data['fifth'] . "');";
             $VTs->ExecuteNonQuery($strSQL);
             $strSQL = "INSERT INTO `eng_diary_contents` (`uid`, `date`, `Identity`, `type`, `contents`) VALUES (NULL, '" . date('Y-m-d') . "', '1', '4', '" . $data['seventh'] . "');";
             $VTs->ExecuteNonQuery($strSQL);
             break;
         case 'diary_info':
             // $strSQL="SELECT no FROM `eng_diary_info` order by date desc LIMIT 1;";
             // $d = $VTs->QueryData($strSQL);
             // $no=$d[0]['no']+1;
             $strSQL = "SELECT code FROM `prj_project` WHERE uid =1";
             $d = $VTs->QueryData($strSQL);
             $no = $d[0]['code'] . "_" . date('ymd');
             $strSQL = "INSERT INTO `eng_diary_info`" . " ( `no`, `am_wthid`, `pm_wthid`, `date`, `week`)" . " VALUES" . "('" . $no . "'," . $data["amwather"] . "," . $data["pmwather"] . ", '" . date("Y/m/d") . "','" . $data["week"] . "');";
             // echo $strSQL;
             $VTs->ExecuteNonQuery($strSQL);
             break;
     }
     //   $strSQL="INSERT INTO `eng_diary_info`"
     //           ." ( `no`, `am_wthid`, `pm_wthid`, `date`, `week`)"
     //           ." VALUES"
     //           ."(0,".$data["amwather"].",".$data["pmwather"].", '".date("Y")."-".date("m")."-".date("d")."','".$data["week"]."');";
     //   $VTs->ExecuteNonQuery($strSQL);
     //   $strSQL="SELECT uid FROM eng_diary_info WHERE date='".date("Y")."-".date("m")."-".date("d")."';";
     //   $d = $VTs->QueryData($strSQL);
     //   $iuid=$d[0]['uid'];
     //   $strSQL="INSERT INTO `eng_diary_contents`"
     //           ." (`fourth`, `fifth`, `sixth`, `seventh`, `eighth`, `iuid`)"
     //           ." VALUES ( ".$data['fourth'].","
     //           ." ".$data['fifth'].","
     //           ." ".$data['sixth'].","
     //           ." ".$data['seventh'].","
     //           ." ".$data['eighth'].","
     //           ." ".$iuid.");";
     // $VTs->ExecuteNonQuery($strSQL);
     //-----------BI結束------------
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     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 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 ListAction()
 {
     $VTs = new clsSystem();
     $VTs->initialization('oldhouseDB');
     try {
         //-----BI開始-----
         $strSQL = "SELECT t2.`hname`, t2.`htel`, t2.`hmobil`,\n                               t2.`ZipCode`, t2.`City`, t2.`Area`, t2.`Vil`, t2.`Verge`, t2.`Road`, t2.`addr`,\n                               t3.desc 'strType', t4.desc 'scale', t5.desc 'type', t1.date, t8.name 'ename', t7.`licenseid` 'license'\n                        FROM qc_info AS t1\n                            LEFT JOIN qc_house AS t2 ON t2.uid = t1.`huid`\n                            LEFT JOIN house_type AS t3 ON t3.`uid` = t1.htid\n                            LEFT JOIN house_type_model AS T4 ON t4.uid = t1.`htmid1`\n                            LEFT JOIN house_type_structure AS t5 ON t5.uid = t1.htsid\n                            LEFT JOIN `eng_engineer_city` AS t6 ON t6.uid = t2.`ecid`\n                            LEFT JOIN `eng_engineer` AS t7 ON t7.uid = t6.`eid`\n                            LEFT JOIN `ass_common` AS t8 ON t8.uid = t7.`cmid`";
         $data = $VTs->QueryData($strSQL);
         //$VTs->Debug($data);
         //$Path = "D:\\php_dev\\AP-Service\\public\\old_house_pdf\\";
         $Path = "..\\old_house_pdf\\";
         $link_html = "";
         if (!empty($data)) {
             foreach ($data as $key => $value) {
                 $mainFile = $Path . $value["hname"] . "-" . $value["htel"] . ".pdf";
                 $imgsFile = $Path . $value["hname"] . "-" . $value["htel"] . "-imgs.pdf";
                 //$link = $value["hname"]."-".$value["htel"]."<a href = '".$filePath."'>下載PDF</a><br>";
                 $link = $value["ZipCode"] . $value["City"] . $value["Area"] . $value["Vil"] . $value["Verge"] . $value["Road"] . $value["addr"] . "<a href = '" . $mainFile . "'>下載PDF</a>_<a href = '" . $imgsFile . "'>下載PDF</a><br>";
                 $link_html .= $link;
             }
         }
         //-----BI結束-----
     } catch (Exception $error) {
         //依據Controller, Action補上對應位置, $error->getMessage()為固定部份
         $VTs->WriteLog("IndexController", "indexAction", $error->getMessage());
     }
     //關閉資料庫連線
     $VTs->DBClose();
     //釋放
     $VTs = null;
     $this->viewContnet['pageContent'] = $link_html;
     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);
 }