<?php

namespace Admin\Controller;

use Think\Controller;

/**
 * 订单管理（控制器）
 *
 * @author sunxiaodong
 */
class DingdanController extends CheckController {
    public function index(){
        $fl  = I("fl");
        if($fl!="")
        {
            $where="status=1";
        }
        else
        {
            $where="";
        }
        
        $count = M('dingdan')->where($where)->count(); // 查询满足要求的总记录数

        $page = new \Think\Page($count, 15); //每页显示5条数据
        $page->setConfig('prev', '上一页');

        $page->setConfig('next', '下一页');

        $page->setConfig('last', '末页');

        $page->setConfig('first', '首页');

        $page->setConfig('theme', '%UP_PAGE% %LINK_PAGE% %DOWN_PAGE%');

        $startno = $page->firstRow; //第一列
//        $nowpage = $page->nowPage; //当前页

        $pagesize = $page->listRows; //页面大小

        $list = M('dingdan')->where($where)->order('id desc')->limit("$startno,$pagesize")->select();

        $pageinfo = $page->show(); // 分页显示输出

        $this->assign('page', $pageinfo);
        
//        $list = M('dingdan')->order("id desc")->where($where)->select();
        
        $on = I('column');
        $this->assign('list',$list);
        $this->assign("on", $on);
        $this->display();
    }

    public function del(){
       $dingdan = D("dingdan"); //获取当期模块的操作对象
       $id = $_POST['id'];  //判断id是数组还是一个数值
       if(is_array($id)){
         $where = 'id in('.implode(',',$id).')';
       }else{
        $where = 'id='.$id;
       }  //dump($where);
       $list=$dingdan->where($where)->delete();
       if($list!==false) {
          $this->success("成功删除{$list}条！", U("Admin/dingdan/index"));
       }else{
         $this->error('删除失败！');
       } 
    }

}
