function edit($id) { if ($this->input->post('title')) { $id = $this->input->post('id'); $keys = array('title', 'desc', 'posterUrl'); foreach ($keys as $key) { $data[$key] = $this->input->post($key); } $data['couponType'] = avosPointer('CouponType', $this->input->post('couponTypeId')); $data['subType'] = avosPointer('CouponType', $this->input->post('subTypeId')); $result = $this->model->update($id, $data); if ($result < 0) { echo $result; } else { $this->session->set_flashdata('msg', '修改成功'); redirect('admin/shops/index', 'refresh'); } } else { $headTypes = $this->ctype_m->get_all_headType(); $subTypes = array(); foreach ($headTypes as $type) { $subTypes = array_merge($subTypes, $type['subTypes']); } $shop = $this->model->get($id); $data['title'] = '编辑主商户'; $data['main'] = 'admin_shops_edit'; $data['model'] = $shop; $data['shopBranches'] = $shop['shopBranches']; $data['coupons'] = $shop['coupons']; $data['couponTypes'] = $headTypes; $data['subTypes'] = $subTypes; $this->load->view($this->config->item('admin_template'), $data); } }
function index($offset = 0) { $models = $this->model->get_all_headType(); $this->load->library('pagination'); // $config['base_url'] = site_url('admin/coupontypes/index/'); $config['total_rows'] = count($models); $config['per_page'] = 20; $config['uri_segment'] = 4; $config['full_tag_open'] = '<p>'; $config['full_tag_close'] = '</p>'; $this->pagination->initialize($config); $data['title'] = '优惠券类型管理'; $data['main'] = 'admin_coupontypes_home'; $data['models'] = $models; // var_dump($data['models']); $this->load->view($this->config->item('admin_template'), $data); }
public function headCouponTypes_get() { $results = $this->ctype_m->get_all_headType(); return $this->output_results($results); }