<?php

namespace Admin\Controller;

use Think\Controller;

/**
 * 系统设置（控制器）
 *
 * @author sunxiaodong
 */
class FenleiController extends CheckController {

    public function index() {
        if(IS_POST)
        {
            $data['name'] = I('post.name');
            $data['add_time'] = date("Y-m-d H:i:s");
            if(M('assortment')->add($data))
            {
              echo "<script>alert('修改成功');parent.location.href='/index.php/Admin/Fenlei/index?column=flgl'; </script>";
               
            } else {
                echo "<script>alert('修改失败')</script>";
            }            
        }
        $list =M('assortment')->select();
        $this->assign('list',$list);
        $on = I('column');
        $this->assign('on', $on);
        $this->display();
    }
    
    //删除分类
    
    public function delete($id){
        if(M('assortment')->delete($id))
        {
            echo "<script>alert('删除成功');parent.location.href='/index.php/Admin/Fenlei/index?column=flgl';</script>";
        }
        
    }
    
    //修改分类
    
    public function update($id)
    {
		if(IS_POST){
			$data=I('post.');
			M('assortment')->save($data);
			$this->redirect('index');
		}
        $list = M('assortment')->find($id);
        $this->assign('list',$list);
        $on = I('column');
        $this->assign('on', $on);
        $this->display();
    }

}
