diff --git a/admin/controllers/biz/brand/Brand.php b/admin/controllers/biz/brand/Brand.php index eb2a6660..5d12e00c 100755 --- a/admin/controllers/biz/brand/Brand.php +++ b/admin/controllers/biz/brand/Brand.php @@ -32,6 +32,10 @@ class Brand extends HD_Controller $this->data['brand_name'] && $where["brand_name like '%" . $this->data['brand_name'] . "%'"] = null; $count = $this->bizBrand->count($where); $list = $this->bizBrand->select($where, 'id desc', $page, $pagesize); + $typeAry = $this->bizBrand->type_ary();//类型 + foreach($list as &$brand){ + $brand['type_name'] = $typeAry[$brand['type']]; + } $this->data['lists'] = $list; $this->data['pager'] = array('count' => ceil($count / $pagesize), 'curr' => $page, 'totle' => $count); $this->data['_title'] = '品牌列表'; @@ -47,9 +51,15 @@ class Brand extends HD_Controller if (!$info || empty($info)) { return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); } - $this->data['id'] = $id; - $this->data['info'] = $info; + $action = '/biz/brand/brand/edit'; + } else { + $info = array('type' => 0); + $action = '/biz/brand/brand/add'; } + + $this->data['info'] = $info; + $this->data['action'] = $action; + $this->data['typeAry'] = $this->bizBrand->type_ary(); $this->data['_title'] = $id ? '编辑品牌' : '新增品牌'; return $this->show_view('biz/brand/edit'); } @@ -75,8 +85,10 @@ class Brand extends HD_Controller if (!$this->if_ajax) { return $this->show_json(SYS_CODE_FAIL, '提交出错!'); } - $brand_name = $this->input->post('brand_name'); - $img = $this->input->post('img'); + $info = $this->input->post('info'); + $brand_name = $info['brand_name']; + $img = $info['brand_logo']; + $type = $info['type']; if (!$brand_name || empty($brand_name)) { return $this->show_json(SYS_CODE_FAIL, '品牌名称不能为空'); } @@ -89,6 +101,7 @@ class Brand extends HD_Controller $add_brand_data = array( 'brand_name' => $brand_name, 'brand_logo' => $img, + 'type' => intval($type), 'c_time' => time() ); $brand_id = $this->bizBrand->add($add_brand_data); @@ -103,17 +116,19 @@ class Brand extends HD_Controller if (!$this->if_ajax) { return $this->show_json(SYS_CODE_FAIL, '提交出错!'); } - $id = $this->input->get('id'); - $info = $this->bizBrand->get(array('id' => $id)); - if (!$info || empty($info)) { + $info = $this->input->post('info'); + $id = $info['id']; + $brand_name = $info['brand_name']; + $img = $info['brand_logo']; + $type = $info['type']; + $row = $this->bizBrand->get(array('id' => $id)); + if (!$row || empty($row)) { return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); } - $brand_name = $this->input->post('brand_name'); - $img = $this->input->post('img'); if (!$brand_name || empty($brand_name)) { return $this->show_json(SYS_CODE_FAIL, '品牌名称不能为空'); } - //防止品牌名称重复添加 + //防止品牌名称重复 $where1 = array('brand_name' => $brand_name, "status<>-1" => null); $id && $where1['id <>'] = $id;//修改时也不允许重复 $old = $this->bizBrand->get($where1); @@ -123,6 +138,7 @@ class Brand extends HD_Controller $add_brand_data = array( 'brand_name' => $brand_name, 'brand_logo' => $img, + 'type' => intval($type), ); $this->bizBrand->update($add_brand_data, array('id' => $id)); return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); diff --git a/admin/views/biz/brand/edit.php b/admin/views/biz/brand/edit.php index 4f51cb2a..a7bcdbc0 100755 --- a/admin/views/biz/brand/edit.php +++ b/admin/views/biz/brand/edit.php @@ -1,35 +1,100 @@ - -