diff --git a/backstage/application/backstage/controllers/Order.php b/backstage/application/backstage/controllers/Order.php index 286dceb..3dcf317 100644 --- a/backstage/application/backstage/controllers/Order.php +++ b/backstage/application/backstage/controllers/Order.php @@ -15,6 +15,7 @@ class Order extends CI_Controller $this->load->model('dish_model'); $this->load->model('meal_model'); $this->load->helper('common'); + $this->load->library('lw_db', array('tb_name' => 'tb_dining_hall'), 'tb_dining_hall'); $this->pageTitle = "订单管理"; $this->asset = $this->lw_assets->validate($this->asset); @@ -916,7 +917,7 @@ class Order extends CI_Controller public function index_bj() { $data['asset'] = $this->asset; - $data['pageTitle'] = $this->pageTitle; + $data['pageTitle'] = "包间订单管理"; $data['breadcrumb'] = array(array('包间订单管理', null)); $hallId = $this->session->userdata('hallId'); $data['deliverPlaceList'] = $this->order_model->get_deliver_place($hallId); @@ -1175,4 +1176,70 @@ class Order extends CI_Controller } + public function index_bjgl() + { + $data['asset'] = $this->asset; + $data['pageTitle'] = "包间管理"; + $data['breadcrumb'] = array(array('包间管理',null)); + $this->lw_load->normalLoad($data, 'order/bj/bjgl/index'); + } + + public function lists_bjgl($page) + { + + $post = $this->input->post(); + $data = $this->order_model->getALLbjData($page,$post); + $this->rs['html'] = $this->load->view('order/bj/bjgl/list', $data, true); + $this->rs['msg'] = '列表'; + $this->rs['success'] = true; + lwReturn($this->rs); + } + + /** + * 添加控制器方法操作: type = 1 是控制器 type = 2 是方法 + * 初始化一个空的控制器或方法,然后编辑操作 + */ + public function add_bjgl() + { + $this->edit_bjgl(0); + } + + public function edit_bjgl($id, $action = 'edit') + { + $diningHalls = $this->session->userdata("hallIds"); + $post = $this->input->post(); + $actionName = $id === 0 ? '添加' : '编辑'; + if (isset($post['doSubmit'])) { + // 提交 + $rs = $this->order_model->editbjData($id, $post, $actionName); + lwReturn($rs); + } else { + // 渲染视图 + if ($id != 0){ + $data['dataList']['id'] = $id; + $data['dataList']['bjData'] = $this->order_model->getBjData($id); + } + $data['dataList']['diningList'] = $this->tb_dining_hall->get_all('*',array('enabled'=>1,'company_id' => $this->session->companyId)); + $this->rs['msg'] = '列表'; + $this->rs['success'] = true; + $this->rs['html'] = $this->load->view('order/bj/bjgl/edit', $data, true); + lwReturn($this->rs); +//// lwReturn($this->rs); +// echo $this->load->view('order/bj/bjgl/edit', $data,true); + } + } + + public function del_bjgl($id,$enabled = 1) + { + $update_state = $this->order_model->delorRebj($id,$enabled); + if(!$update_state){ + $this->rs['success'] = false; + $this->rs['msg'] = '更新包间状态失败'; + }else{ + $this->rs['success'] = true; + $this->rs['msg'] = '更新包间状态成功'; + } + lwReturn($this->rs); + } + } diff --git a/backstage/application/backstage/models/Order_model.php b/backstage/application/backstage/models/Order_model.php index 200d661..f336200 100644 --- a/backstage/application/backstage/models/Order_model.php +++ b/backstage/application/backstage/models/Order_model.php @@ -5,6 +5,8 @@ class Order_model extends CI_Model { parent::__construct(); $this->load->database(); + $this->load->helper('common'); + $this->load->library('lw_db', array('tb_name' => 'tb_order_deliver_place'), 'tb_order_deliver_place'); } /* @@ -193,4 +195,63 @@ class Order_model extends CI_Model $receive_meal_num_list = $this->db->query("select dish_ids from tb_dish_receive_meal where company_id='{$company_id}' and status='1'")->row_array(); return $this->db->query("select * from tb_dish where enabled='1' and id in ({$receive_meal_num_list['dish_ids']})")->result_array(); } + + public function getBjData($id) { + $sql = " + select a.*,b.name as diningName,b.id as diningId from tb_order_deliver_place a left join tb_dining_hall b on a.dining_hall_id = b.id where a.id = ('{$id}') + "; + return $this->db->query($sql)->row_array(); + } + + //获取所有包间信息 + public function getALLbjData($page) + { + $this->load->library('lw_pagination2'); + $param = $this->input->post('param'); + $diningHalls = $this->session->userdata("hallIds"); + $sql = " + select a.*,b.name as diningName from tb_order_deliver_place a left join tb_dining_hall b on a.dining_hall_id = b.id where a.dining_hall_id in ({$diningHalls}) + "; + $hasWhere = true; + $group = null; + $order = "a.id ASC"; + $action = "getListByPage"; + $dataName = 'dataList'; + $paramFilter = array('a.name'); + $data = $this->lw_pagination2->lists($sql, $param, $page, $hasWhere, $group, $order, $action, $dataName, $paramFilter); + return $data; + } + + public function editbjData($id, $post, $actionName) + { + $rowExist = array(); + if (empty($post['name'])) { + $this->rs['msg'] = '包间名不能为空, 请重新输入'; + return $this->rs; + } + unset($post['doSubmit']); + $rowExist = $this->tb_order_deliver_place->check_exist(array('name' => $post['name'],'dining_hall_id' => $post['dining_hall_id'], 'enabled' => 1)); + if ($rowExist) { + $this->rs['msg'] = '名称已经存在, 请重新输入'; + return $this->rs; + } + if ($id == 0) { + $post['enabled'] = 1; + $result = $this->tb_order_deliver_place->insert($post); + } else { + $result = $this->tb_order_deliver_place->update($post, array('id' => $id)); + } + if ($result) { + $this->rs['success'] = true; + $this->rs['msg'] = $actionName . '成功'; + } else { + $this->rs['msg'] = $actionName . '失败'; + } + return $this->rs; + } + + public function delorRebj($id , $enabled) { + $update_state = $this->db->update("tb_order_deliver_place", array('enabled'=> $enabled), array('id' => $id)); + return $update_state; + } } \ No newline at end of file diff --git a/backstage/application/backstage/views/order/bj/bjgl/edit.php b/backstage/application/backstage/views/order/bj/bjgl/edit.php new file mode 100644 index 0000000..a4715de --- /dev/null +++ b/backstage/application/backstage/views/order/bj/bjgl/edit.php @@ -0,0 +1,86 @@ + + + \ No newline at end of file diff --git a/backstage/application/backstage/views/order/bj/bjgl/index.php b/backstage/application/backstage/views/order/bj/bjgl/index.php new file mode 100644 index 0000000..cd89e97 --- /dev/null +++ b/backstage/application/backstage/views/order/bj/bjgl/index.php @@ -0,0 +1,111 @@ + +
+
+
+
+

筛选与添加

+ +
+ +
+
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+

列表

+ +
+ +
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/backstage/application/backstage/views/order/bj/bjgl/list.php b/backstage/application/backstage/views/order/bj/bjgl/list.php new file mode 100644 index 0000000..1850fe0 --- /dev/null +++ b/backstage/application/backstage/views/order/bj/bjgl/list.php @@ -0,0 +1,115 @@ + +
+
+ + + + + + + + + + + + 当前没有数据"; + } else { + $i = 1; + foreach ($dataList as $data) : ?> + + + + + + + + +
#包间名字包间关联饭堂操作
+ + 复通"; + }else{ + echo ""; + } + ?> +
+
+
+
+
+ +
+
+ + \ No newline at end of file