<?php
	require_once "pageBase.php";
	require_once "../dal/pictureDAL.php";
	class _logoSet extends pageBase {
		private $dal;
		public function load() {
			$this->dal = new pictureDAL();

			$this->limitID = "63";
			if (!parent::chkUserLimit()) {
				$this->alertMsg = "您沒有使用此頁面的權限!如有疑問請洽主管理者!";
				$this->locationHref = "index.php";
			} else {
				parent::isPostBack() ? $this->saveData() : $this->loadData();
			}
			parent::loadTemplateFile(dirname(__FILE__) . "/templates/logoSet.html");
			parent::load();
		}
		
		public function loadData() {
			for ($i = 1; $i <= 3; $i++) {
				$this->dal->PictureType = ($i == 1) ? "10" : (($i == 2) ? "15" : "0");
				$this->dal->TypeOrderNO = "0";
				$this->dal->loadRecord();
				parent::addParameter("Image$i", $this->dal->Image);
				parent::addParameter("Title$i", $this->dal->Title);
				parent::addParameter("Link$i", $this->dal->Link);
			}
			
			parent::loadData();
		}

		public function saveData() {
			for ($i = 1; $i <= 3; $i++) {
				$this->dal->PictureType = ($i == 1) ? "10" : (($i == 2) ? "15" : "0");
				$this->dal->TypeOrderNO = "0";
				$this->dal->Image = parent::getPost("Image$i");
				$this->dal->Title = parent::getPost("Title$i");
				$this->dal->Link = parent::getPost("Link$i");
				$this->dal->BanColor = "";
				$this->dal->DanDesc = "";
				$this->dal->ShowType = "0";
				$this->dal->PictureVideo = "";
				$this->dal->replaceRecord();
			}
			
			$this->alertMsg = "儲存完畢!";
			$this->locationHref = "logoSet.php";
		}
	}

	$page = new _logoSet();
	$page->load();
	$page->render();
?>