<?php
	require_once "pageBase.php";
	require_once "../../bin/system/conver.php";
	require_once "../../dal/faqDAL.php";
	class _faq extends pageBase{
		private $dal;
		public function load(){
			$this->dal = new faqDAL();
			$action = conver::toDbString(trim($_POST["do"]));
			switch(trim(strtolower($action))){
				case "del":
					$this->delete();
					break;
				case "vis":
					$this->visible();
					break;
				case "unvis":
					$this->unVisible();
					break;
				default:
					break;
			}
			parent::load();
		}
		private function delete(){
			$id = conver::toDbString(trim($_POST["id"]));
			$ids = conver::toDbString(trim($_POST["ids"]));
			if(isset($id) && $id != "" && $id != "0"){
				if($this->dal->deleteRecord($id))
					echo "1";
				else
					echo "-1";
			}else if(isset($ids) && $ids != "" && $ids != "0"){
				if($this->dal->batDelete($ids))
					echo "1";
				else
					echo "-1";
			}
		}
		private function visible(){
			$ids = conver::toDbString(trim($_POST["ids"]));
			if(isset($ids) && $ids != "" && $ids != "0"){
				if($this->dal->batUpdateVisible($ids,1))
					echo "1";
				else
					echo "-1";
			}
		}
		private function unVisible(){
			$ids = conver::toDbString(trim($_POST["ids"]));
			if(isset($ids) && $ids != "" && $ids != "0"){
				if($this->dal->batUpdateVisible($ids,0))
					echo "1";
				else
					echo "-1";
			}
		}
	}

	$page = new _faq();
	$page->load();
?>