<?php
/**
 * [LJCMS] (C)2012-2099 LJdev,Inc.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2014.04.03
*/

class control extends oabase {
    
	public function action_run() {
            	$model = parent::model('deptGrade', 'oa');
		$list = $model -> get_DeptGrade_list();
                $var_array = array(
                    'list'=>$list,
                  );            
               unset($model);
               TPL::assign($var_array);
	       TPL::display($this->cptpl.'DeptGrade/deptGrade.tpl');
        }
        
        	/**编辑页面 **/
	public function action_read() {
                $id=$_REQUEST['id'];
		$model = parent::model('deptGrade', 'oa');
		$vo = $model -> get_top_menu_data($id);
		
			if (!empty($vo)) {// 读取成功
				$return['data'] = $vo;
				$return['status'] = 1;
				$return['info'] = "读取成功";
				echo json_encode($return);
			} else {
				$return['status'] = 0;
				$return['info'] = "读取错误";
				echo json_encode($return);
			}
		
		//$this -> assign('vo', $vo);
	//	$this -> display();
		//return $vo;
	}
        public function action_add(){
             	
             TPL::display($this->cptpl.'DeptGrade/add.tpl');
        }

        public function action_save(){
            $arr=$_POST;
            $id=$arr['id'];
            $model = parent::model('deptGrade', 'oa');
              $arr=$this->SafeFilter($arr);
            if($arr['opmode']=='add'){
                $result = $model->doadd($arr);
            }else{
                $result = $model->doEdit($id, $arr);
            }
            if (true === $result) {
                $data['status']=1;
                $data['info']="编辑成功";
            }
            else {
                $data['info']="编辑失败";
            }
            echo json_encode($data);
        }
        
 
        public function action_del(){
                $id=$_POST['id'];
                if($id==''){
                     $data['info']='操作失败';
                     echo json_encode($data);
                die;
                }
                $model = parent::model('deptGrade', 'oa');
		
		$res=$model->del($id);
                if($res){
                     $data['status']=1;
                     $data['info']='删除成功';
                } else {
                     $data['info']='操作失败';
                }
                 echo json_encode($data);
                die;
	}
    
}
?>
