<?php
	require_once "pageBase.php";
	require_once "../../bin/system/conver.php";
	require_once "../../dal/book_categoryDAL.php";
	require_once "../../dal/bookDAL.php";
	class _book_category extends pageBase{
		private $dal;
		public function load(){
			$this->dal = new book_categoryDAL();
			$action = conver::toDbString(trim($_POST["do"]));
			switch(trim(strtolower($action))){
				case "del":
					$this->delete();
					break;
				default:
					break;
			}
			parent::load();
		}
		private function delete(){
			$id = conver::toDbString(trim($_POST["id"]));
			$dalN = new bookDAL();
			if($dalN->countRecordset("a.`CategoryID`='".$id."'") > 0){
				echo "-10";
			}else{
				if($this->dal->deleteRecord($id))
					echo "1";
				else
					echo "-1";
			}
		}
	}

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