function index($skip = 0) { $limit = 20; $models = $this->model->get_all_headShops($skip, $limit); $total_rows = $this->model->count_all_headShops(); $this->load->library('pagination'); $config['base_url'] = site_url('admin/shops/index/'); $config['total_rows'] = $total_rows; $config['per_page'] = $limit; $this->pagination->initialize($config); $data['title'] = '商户管理'; $data['main'] = 'admin_shops_home'; $data['models'] = $models; $this->load->view($this->config->item('admin_template'), $data); }
function edit($id) { if ($this->input->post('title')) { // var_dump($_POST); $keys = array('title', 'discountContent', 'validate', 'usage', 'avatarUrl'); foreach ($keys as $key) { $data[$key] = $this->input->post($key); } $shopId = $this->input->post('shopId'); $data['shop'] = avosPointer('Shop', $shopId); $id = $this->input->post('id'); // echobr($id); // var_dump($data); $objectId = $this->model->update($id, $data); if ($objectId < 0) { echo $objectId; } else { $this->session->set_flashdata('msg', '修改优惠券成功'); redirect('admin/coupons/index', 'refresh'); } } else { // display form $coupon = $this->model->get($id); $shopId = $coupon['shop']['objectId']; $shops = $this->shop_m->get_all_headShops(0, 200); if ($shops < 0) { var_dump($shops); } $data['title'] = '编辑优惠券'; $data['main'] = 'admin_coupons_edit'; $data['shopId'] = $shopId; $data['shops'] = $shops; $data['model'] = $coupon; $this->load->view($this->config->item('admin_template'), $data); } }