コード例 #1
0
 public function add()
 {
     //所有分类
     $cate_list_mod = D('seller_cate');
     $cate_list = $cate_list_mod->where("status=1")->order("sort DESC")->select();
     $cate_list = set_array_form_item($cate_list, 'id', 'name');
     //所有分类
     //选中分类
     $seller_list_cate_mod = D('seller_list_cate');
     $seller_list_cate = $seller_list_cate_mod->where("list_id={$seller_list_id}")->select();
     //筛选出选中分类的id以及名称
     $sellect_cate_list = '';
     foreach ($seller_list_cate as $key => $val) {
         if (array_key_exists($val['cate_id'], $cate_list)) {
             $sellect_cate_list .= $val['cate_id'] . ',';
         }
     }
     $sellect_cate_list = substr($sellect_cate_list, 0, -1);
     $sellect_cate_list = explode(',', $sellect_cate_list);
     $cate_str = '';
     foreach ($cate_list as $key => $value) {
         if (in_array($key, $sellect_cate_list)) {
             $cate_str .= ' <input type="checkbox" value="' . $key . '" name="cate_id[]" checked="checked"> ' . $value . '';
         } else {
             $cate_str .= ' <input type="checkbox" value="' . $key . '" name="cate_id[]"> ' . $value . '';
         }
     }
     $this->assign('cate_str', $cate_str);
     $this->display();
 }
コード例 #2
0
 public function index()
 {
     $agent_mod = M('Agent');
     $Store_mod = M('Store');
     $cate_list_mod = M('Store_cate');
     $Store_cate_mod = M('Store_list_cate');
     $cate_list = $cate_list_mod->where("status=1")->order("sort DESC")->select();
     $cate_list = set_array_form_item($cate_list, 'id', 'name');
     $keyword = isset($_GET['keyword']) ? trim($_GET['keyword']) : '';
     $typeid = isset($_GET['typeid']) ? trim($_GET['typeid']) : '';
     //店铺类型
     $agentid = isset($_GET['agentid']) ? trim($_GET['agentid']) : '';
     //代理商
     $cate_id = isset($_GET['cate_id']) && intval($_GET['cate_id']) && $_GET['cate_id'] != 0 ? intval($_GET['cate_id']) : '';
     //$where = '1=1';
     //关键字查询e
     if ($keyword != '') {
         $map['storename'] = array('like', '%' . $keyword . '%');
         $map['tel'] = array('eq', $keyword);
         $map['contact'] = array('eq', $keyword);
         //$map['Team.crttime'] = array('like binary ', '%' . $keywords . '%');
         $map['_logic'] = 'OR';
         $where['_complex'] = $map;
         $this->assign('keyword', $keyword);
     }
     //根据商店性质查询
     if ($typeid) {
         $where['type'] = $typeid;
         $this->assign('typeid', $typeid);
     }
     //商家类型查询
     if ($cate_id) {
         $Store_id = $Store_cate_mod->where("cate_id='{$cate_id}'")->field('list_id')->select();
         $str = '';
         foreach ($Store_id as $value) {
             $str .= $value['list_id'] . ',';
         }
         $str = substr($str, 0, -1);
         $where['id'] = array('in', $str);
         $this->assign('cate_id', $cate_id);
     }
     //根据代理商查询
     $roleid = $this->getSessionId('role_id');
     if ($agentid && $agentid != 'undefined') {
         $where['agentid'] = $agentid;
         $this->assign('agentid', $agentid);
     } else {
         //角色条件区分判断
         if ($roleid == 1) {
             $ids = $this->getAgentStoreList();
             $where['agentid'] = array('in', $ids);
         }
         if ($roleid == 2) {
             $where['agentid'] = $this->getSessionId('id');
         }
     }
     import("ORG.Util.Page");
     $count = $Store_mod->where($where)->count();
     $p = new Page($count, 20);
     $Store_list = $Store_mod->where($where)->limit($p->firstRow . ',' . $p->listRows)->order('ctime desc')->select();
     //echo $Store_mod->getLastSql();
     //print_r($Store_list);exit;
     $ids = $this->getAgentStoreList();
     if ($ids) {
         $awhere['adminid'] = array('in', $ids);
     }
     $agentlist = $agent_mod->where($awhere)->select();
     //echo $agent_mod->getLastSql();
     $page = $p->show();
     $this->assign('agentlist', $agentlist);
     $this->assign('cate_list', $cate_list);
     $this->assign('role_id', $roleid);
     $this->assign('page', $page);
     $this->assign('seller_list_list', $Store_list);
     $this->display();
 }