public function getAddHtmlAction() { //session_start(); $VTs = new clsSystem(); $VTs->initialization(); //-----BI開始----- typeunit 單位表IUD頁面 $type = $_GET["type"]; switch ($type) { case '0': $path = dirname(__DIR__) . "\\..\\..\\..\\..\\public\\include\\pageSetting\\styles\\editor\\typeunit_addlist.html"; $html = $VTs->GetHtmlContent($path); $data = $VTs->json2data($VTs->UrlDataGet("http://127.0.0.1:88/editor/getdbdata?page=type_a")); $str = ''; foreach ($data as $opData) { $str .= '<option value=' . $opData->uid . '>' . $opData->name . '</option>'; } $html = str_replace('@@select@@', $str, $html); break; } $pageContent = $html . $VTs->CreateFinishOptionBtn(["uid" => 1], 'test/tw', 'inputClass', 'contentClass'); //-----BI結束----- //關閉資料庫連線 $VTs->DBClose(); //釋放 $VTs = null; $this->viewContnet['pageContent'] = $pageContent; return new ViewModel($this->viewContnet); }
public function editPageAction() { $VTs = new clsSystem(); $VTs->initialization(); try { //-----BI開始----- $pathString = dirname(__DIR__) . "\\..\\..\\..\\..\\public\\include\\pageSetting"; if (empty($_SESSION)) { $pagePath = $pathString . "\\index\\login_page.html"; $pageContent = $VTs->GetHtmlContent($pagePath); } else { if (!empty($_POST)) { $apurl = "http://211.21.170.18:99"; //$apurl = "http://127.0.0.1:99"; $action = $_POST["action"]; // echo $action; $editPagePath = $pathString . "\\employeemanage\\newPage.html"; $editPage = $VTs->GetHtmlContent($editPagePath); switch ($action) { case "insertData": $basicInfoPagePath = $pathString . "\\employeemanage\\basicInfo.html"; break; case "updateData": $basicInfoPagePath = $pathString . "\\employeemanage\\basicInfo_edit.html"; break; default: } $basicInfoPage = $VTs->GetHtmlContent($basicInfoPagePath); $addressPagePath = $pathString . "\\employeemanage\\address.html"; $addressPage = $VTs->GetHtmlContent($addressPagePath); $communicationPagePath = $pathString . "\\employeemanage\\communication.html"; $communicationPage = $VTs->GetHtmlContent($communicationPagePath); $dataArr = ["userName" => $_SESSION["userName"], "basicInfo" => $basicInfoPage, "address" => $addressPage, "communication" => $communicationPage]; $editPage = $VTs->ContentReplace($dataArr, $editPage); switch ($action) { case "insertData": $optionData = $VTs->json2data($VTs->UrlDAtaGet($apurl . "/employeemanage/getdata?type=relationOption")); // $VTs->debug($option); $selectElement = "<select id='relation'><option value='0'>-請選擇-</option>"; if (!empty($optionData)) { foreach ($optionData->dataList as $data) { $optionElement = "<option value='" . $data->uid . "'>" . $data->relation . "</option>"; $selectElement .= $optionElement; } } else { // echo "AP Action getdata has problem."; } $selectElement .= "</select>"; //basicInfo $dataArr = ["name" => "", "sid" => "", "birthday" => ""]; $editPage = $VTs->ContentReplace($dataArr, $editPage); //address $dataArr = ["zip" => "", "city" => "", "area" => "", "vil" => "", "verge" => "", "road" => "", "addr" => ""]; $editPage = $VTs->ContentReplace($dataArr, $editPage); //communication $dataArr = ["belong" => "", "relation" => $selectElement, "relation1" => "", "mobile" => "", "tel_h" => "", "tel_o" => "", "tel_ext" => "", "email" => ""]; $editPage = $VTs->ContentReplace($dataArr, $editPage); //function arg $dataArr = ["action" => $action, "uid" => ""]; $editPage = $VTs->ContentReplace($dataArr, $editPage); $pageContent = $editPage; break; case "updateData": $uid = $_POST["uid"]; // echo "uid: ".$uid; $arr = $VTs->json2data($VTs->UrlDataGet($apurl . "/employeemanage/getdata?uid=" . $uid . "")); if ($arr->status) { // $VTs->debug($arr); $optionData = $VTs->json2data($VTs->UrlDAtaGet($apurl . "/employeemanage/getdata?type=relationOption")); $selectElement = "<select id='relation'><option value='0'>-請選擇-</option>"; foreach ($optionData->dataList as $data) { if ($arr->dataList[0]->relation == $data->relation) { $optionElement = "<option value='" . $data->uid . "' selected>" . $data->relation . "</option>"; } else { $optionElement = "<option value='" . $data->uid . "'>" . $data->relation . "</option>"; } $selectElement .= $optionElement; } $selectElement .= "</select>"; //basicInfo $basicDataArr = ["name" => $arr->dataList[0]->name, "sid" => $arr->dataList[0]->sid, "sex" => $arr->dataList[0]->sex, "birthday" => $arr->dataList[0]->birthday]; $editPage = $VTs->ContentReplace($basicDataArr, $editPage); //address $addressDataArr = ["zip" => $arr->dataList[0]->zip, "city" => $arr->dataList[0]->city, "area" => $arr->dataList[0]->area, "vil" => $arr->dataList[0]->vil, "verge" => $arr->dataList[0]->verge, "road" => $arr->dataList[0]->road, "addr" => $arr->dataList[0]->addr]; $editPage = $VTs->ContentReplace($addressDataArr, $editPage); //commonication $communicatonDataArr = ["belong" => $arr->dataList[0]->belong, "relation" => $selectElement, "relation1" => $arr->dataList[0]->relation1, "mobile" => $arr->dataList[0]->mobile, "tel_h" => $arr->dataList[0]->tel_h, "tel_o" => $arr->dataList[0]->tel_o, "tel_ext" => $arr->dataList[0]->tel_ext, "email" => $arr->dataList[0]->email]; $editPage = $VTs->ContentReplace($communicatonDataArr, $editPage); //function arg $dataArr = ["action" => $action, "uid" => ", '" . $uid . "'"]; $editPage = $VTs->ContentReplace($dataArr, $editPage); $pageContent = $editPage; } else { $pageContent = "Query has error!"; } break; default: $pageContent = "EditPage action has error!"; } } } //----BI結束---- } catch (Exception $error) { //依據Controller, Action補上對應位置, $error->getMessage()為固定部份 $VTs->WriteLog("EmployeemanageController", "editPageAction", $error->getMessage()); } $VTs = null; $this->viewContnet['pageContent'] = $pageContent; return new ViewModel($this->viewContnet); }