<?php
	require_once "pageBase.php";
	require_once "../bin/system/conver.php";
	require_once "../dal/pictureDAL.php";
	class _logoSet extends pageBase{
		private $dal;

		//覆蓋父類load()方法
		public function load(){
			if(!parent::chkUserLimit('38')){
				parent::alert2('您沒有使用此頁面的權限!如有疑問請洽主管理者!','index.php');
				exit;
			}

			$this->dal = new pictureDAL();

			if(!parent::isPostBack())
				$this->loadData();
			else
				$this->saveData();

			parent::load();
		}

		public function loadData(){
			$this->dal->PictureType = "10";
			$this->dal->TypeOrderNO = "0";
			$this->dal->loadRecord();
			parent::addParameter("Image1",$this->dal->Image);
			parent::addParameter("Title1",$this->dal->Title);
			parent::addParameter("Link1",$this->dal->Link);

			$this->dal->PictureType = "20";
			$this->dal->TypeOrderNO = "0";
			$this->dal->loadRecord();
			parent::addParameter("Image2",$this->dal->Image);
			parent::addParameter("Title2",$this->dal->Title);
			parent::addParameter("Link2",$this->dal->Link);
			
			$this->dal->PictureType = "15";
			$this->dal->TypeOrderNO = "0";
			$this->dal->loadRecord();
			parent::addParameter("Image3",$this->dal->Image);
			parent::addParameter("Title3",$this->dal->Title);
			parent::addParameter("Link3",$this->dal->Link);

			parent::loadTemplateFile(dirname(__FILE__)."/templates/logoSet.html");
			parent::loadData();
		}
		public function saveData(){
			$this->dal->PictureType = "10";
			$this->dal->TypeOrderNO = "0";
			$this->dal->Image = conver::toDbString(trim($_POST["Image1"]));
			$this->dal->Title = conver::toDbString(trim($_POST["Title1"]));
			$this->dal->Link = conver::toDbString(trim($_POST["Link1"]));
			$this->dal->replaceRecord();

			$this->dal->PictureType = "20";
			$this->dal->TypeOrderNO = "0";
			$this->dal->Image = conver::toDbString(trim($_POST["Image2"]));
			$this->dal->Title = conver::toDbString(trim($_POST["Title2"]));
			$this->dal->Link = conver::toDbString(trim($_POST["Link2"]));
			$this->dal->replaceRecord();
			
			$this->dal->PictureType = "15";
			$this->dal->TypeOrderNO = "0";
			$this->dal->Image = conver::toDbString(trim($_POST["Image3"]));
			$this->dal->Title = conver::toDbString(trim($_POST["Title3"]));
			$this->dal->Link = conver::toDbString(trim($_POST["Link3"]));
			$this->dal->replaceRecord();

			parent::alert2("儲存完畢!","logoSet.php");
		}
	}

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