<?php
	/**
	*Author 雷日锦 362606856@qq.com 
	*控制器自动生成
	*/
	if(!defined("ROOT_PATH")) exit("die Access ");
	class paotui_senderControl extends skymvc{
		
		public function __construct(){
			parent::__construct();
			 
		}
		
		public function onDefault(){
			$where=SITEWHERE." status in(0,1,2)";
			$url="/moduleadmin.php?m=paotui_sender&a=default";
			$limit=20;
			$start=get("per_page","i");
			$option=array(
				"start"=>$start,
				"limit"=>$limit,
				"order"=>" senderid DESC",
				"where"=>$where
			);
			$rscount=true;
			$data=M("mod_paotui_sender")->select($option,$rscount);
			if($data){
				foreach($data as $k=>$v){
					$v["imgurl"]=images_site($v["imgurl"]);
					$data[$k]=$v;
				}
			}
			$per_page=$start+$limit;
			$per_page=$per_page>$rscount?0:$per_page;
			$pagelist=$this->pagelist($rscount,$limit,$url);
			$this->smarty->goassign(
				array(
					"list"=>$data,
					"per_page"=>$per_page,
					"pagelist"=>$pagelist,
					"rscount"=>$rscount,
					"url"=>$url
				)
			);
			$this->smarty->display("paotui_sender/index.html");
		}
		
		public function onAdd(){
			$senderid=get_post("senderid","i");
			if($senderid){
				$data=M("mod_paotui_sender")->selectRow(array("where"=>"senderid=".$senderid));
				
			}
			$this->smarty->goassign(array(
				"data"=>$data
			));
			$this->smarty->display("paotui_sender/add.html");
		}
		
		public function onSave(){
			$senderid=get_post("senderid","i");
			$data=M("mod_paotui_sender")->postData();
			if($senderid){
				M("mod_paotui_sender")->update($data,"senderid='$senderid'");
			}else{
				M("mod_paotui_sender")->insert($data);
			}
			$this->goall("保存成功");
		}
		
		public function onStatus(){
			$senderid=get_post('senderid',"i");
			$status=get_post("status","i");
			M("mod_paotui_sender")->update(array("status"=>$status),"senderid=$senderid");
			$this->goall("状态修改成功");
		}
		
		public function onDelete(){
			$senderid=get_post('senderid',"i");
			M("mod_paotui_sender")->update(array("status"=>11),"senderid=$senderid");
			$this->goAll("删除成功");
			 
		}
		
		
	}

?>