<?php
	require_once "pageBase.php";
	require_once "../../bin/system/conver.php";
	require_once "../../dal/menuDAL.php";
	class _menu extends pageBase{
		private $dal;
		public function load(){
			$this->dal = new menuDAL();
			$action = conver::toDbString(trim($_POST["do"]));
			switch(strtolower($action)){
				case "vis":
					$this->visible();
					break;
				case "del":
					$this->delete();
					break;
				default:
					echo "-2";
					break;
			}
			parent::load();
		}
		private function visible(){
			$id = conver::toDbString(trim($_POST["id"]));
			$vis = conver::toDbString(trim($_POST["vis"]));
			$this->dal->MenuID = $id;
			$this->dal->loadRecord();
			$this->dal->Visible = $vis;
			if(!$this->dal->updateRecord()){
				echo "-1";
			}else{
				echo $vis;
			}
		}
		private function delete(){
			$id = conver::toDbString(trim($_POST["id"]));
			if($this->dal->deleteRecord($id))
				echo "1";
			else
				echo "-1";
		}
	}

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