<?php
	require_once "pageBase.php";
	require_once "../dal/registryDAL.php";
	class _advancedSet extends pageBase {
		public function load() {
			$this->limitID = "51";
			if (!parent::chkUserLimit()) {
				$this->alertMsg = "您沒有使用此頁面的權限!如有疑問請洽主管理者!";
				$this->locationHref = "index.php";
			} else {
				parent::isPostBack() ? $this->saveData() : $this->loadData();
			}
			parent::loadTemplateFile(dirname(__FILE__) . "/templates/advancedSet.html");
			parent::load();
		}
		
		public function loadData() {
			$webConfig = registryDAL::getRegistryValues();
			foreach ($webConfig as $key => &$value) {
				$value = $value ?? "";
				parent::addParameter($key, $value);
			}
			parent::loadData();
		}
		
		public function saveData() {
			$aryR = [
				"loginType" => parent::getPost("loginType", "0"),
				"isGoogleLogin" => parent::getPost("isGoogleLogin", "0"),
				"isLineLogin" => parent::getPost("isLineLogin", "0"),
				"webType" => parent::getPost("webType", "10"),
				"isPayPage" => parent::getPost("isPayPage", "0"),
				"isCustomer" => parent::getPost("isCustomer", "0"),
				"isShopCar" => parent::getPost("isShopCar", "0"),
				"isInvoice" => parent::getPost("isInvoice", "0"),
				"isScore" => parent::getPost("isScore", "1"),
				"istwsms" => parent::getPost("istwsms", "0"),
				"webSeoSearch" => parent::getPost("webSeoSearch", "1"),
				"bannerMaximum" => parent::getPost("bannerMaximum", "10"),
				"isAnalyze" => parent::getPost("isAnalyze", "0"),
				"ModifiedTime" => time(),
			];

			foreach ($aryR as $key => $value) {
				registryDAL::saveRegistry($key, $value);
			}
			$this->alertMsg = "儲存完畢!";
			$this->locationHref = "advancedSet.php";
		}
	}
	$page = new _advancedSet();
	$page->load();
	$page->render();
?>