<?php
	/**
	*Author 雷日锦 362606856@qq.com 
	*控制器自动生成
	*/
	if(!defined("ROOT_PATH")) exit("die Access ");
	class book_commentControl extends skymvc{
		
		public function __construct(){
			parent::__construct();
			 
		}
		
		public function onDefault(){
			$title=get("title","h");
			$id=get("id","i");
			$type=get("type","h");
			$where=" status in(0,1,2)";
			$url="/moduleadmin.php?m=book_comment&a=default";
			switch($type){
				case "pass":
					$where="   status=1 ";
					$type_name="已通过";
					break;
				case "forbid":
					$where="  status=2 ";
					$type_name="已下架";
					break;
				case "all":
					$where=" status in(0,1,2) ";
					$type_name="全部";
					break;
				default:
					$where="   status=0 ";
					$type_name="待审核";
					break;
			}
			if($title){
				$where.=" AND title like '%".$title."%' ";
				$url.="&title=".urlencode($title);
			}
			if($id){
				$where.=" AND id=".$id;
			}
			$limit=20;
			$start=get("per_page","i");
			$option=array(
				"start"=>$start,
				"limit"=>$limit,
				"order"=>" id DESC",
				"where"=>$where
			);
			$rscount=true;
			$data=M("mod_book_comment")->select($option,$rscount);
			$per_page=$start+$limit;
			$per_page=$per_page>$rscount?0:$per_page;
			$pagelist=$this->pagelist($rscount,$limit,$url);
			$this->smarty->goassign(
				array(
					"title"=>$title,
					"id"=>$id,
					"type"=>$type,
					"type_name"=>$type_name,
					"list"=>$data,
					"per_page"=>$per_page,
					"pagelist"=>$pagelist,
					"rscount"=>$rscount,
					"url"=>$url
				)
			);
			$this->smarty->display("book_comment/index.html");
		}
		
		public function onShow(){
			$id=get_post("id","i");
			$data=M("mod_book_comment")->selectRow(array("where"=>"id=".$id));
			$this->smarty->goassign(array(
				"data"=>$data
			));
			$this->smarty->display("book_comment/show.html");
		}
		public function onStatus(){
			$id=get_post('id',"i");
			$row=M("mod_book_comment")->selectRow("id=".$id);
			if($row["status"]==1){
				$status=2;
			}else{
				$status=1;
			}
			 
			M("mod_book_comment")->update(array("status"=>$status),"id=$id");
			$this->goall("状态修改成功",0,$status);
		}
		
		public function onDelete(){
			$id=get_post('id',"i");
			M("mod_book_comment")->update(array("status"=>11),"id=$id");
			$this->goAll("删除成功");
			 
		}
		
		
	}

?>