diff --git a/backstage/application/backstage/controllers/Order.php b/backstage/application/backstage/controllers/Order.php index ced04c3..286dceb 100644 --- a/backstage/application/backstage/controllers/Order.php +++ b/backstage/application/backstage/controllers/Order.php @@ -912,4 +912,267 @@ class Order extends CI_Controller } + // 瑞克斯VIP餐 个人化要求统计 + public function index_bj() + { + $data['asset'] = $this->asset; + $data['pageTitle'] = $this->pageTitle; + $data['breadcrumb'] = array(array('包间订单管理', null)); + $hallId = $this->session->userdata('hallId'); + $data['deliverPlaceList'] = $this->order_model->get_deliver_place($hallId); + $data['mealList'] = $this->meal_model->getbjMealTypeList(); + $this->lw_load->normalLoad($data, 'order/bj/bjorder_index'); + } + + public function orderListBj($page){ + $this->load->library('lw_pagination2'); + $hallId = $this->session->userdata('hallId'); + + //处理参数 + //处理提交参数 + $dishDateStart = $this->input->post("dishDateStart", true); + $dishDateEnd = $this->input->post("dishDateEnd", true); + $searchPlaceType = $this->input->post("searchPlaceType", true); + $searchMealType= $this->input->post("searchMealType", true); + + + //处理参数 + if (is_array($searchPlaceType)) { + if (count($searchPlaceType) == 1 && $searchPlaceType[0] == -1) { + unset($searchUserType); + } + } + + if (is_array($searchMealType)) { + if (count($searchMealType) == 1 && $searchMealType[0] == -1) { + unset($searchMealType); + } + } + + $dishDateStart = $this->db->escape_str($dishDateStart); + $dishDateEnd = $this->db->escape_str($dishDateEnd); + + $where = " 1 "; + + //处理数组 + if ($searchPlaceType) { + $tstr = "0"; + foreach ($searchPlaceType as $k => $v) { + $tstr .= "," . intval($v); + } + $where .= " and a.deliver_place_id in (" . $tstr . ")"; + } + + if ($searchMealType) { + $tstr = "0"; + foreach ($searchMealType as $k => $v) { + $tstr .= "," . intval($v); + } + $where .= " and d.id in (" . $tstr . ")"; + } + + + if ($dishDateStart) { + if ($dishDateEnd) { + $where .= " and c.dc_date between '" . $dishDateStart . "' and '" . $dishDateEnd . "' "; + } else { + $where .= " and c.dc_date >'" . $dishDateStart . "'"; + } + } + + $where .= " and g.dining_hall_id = ".$hallId; + + + $sql = " + SELECT + a.id, + c.dc_date, + d.NAME, + b.username, + g.`name`, + a.reason, + a.total_price, + h.name as stateName, + a.date_id + FROM + tb_order a + LEFT JOIN tb_user b ON a.uid = b.id + LEFT JOIN tb_date c ON c.id = a.date_id + LEFT JOIN tb_meal_type d ON c.dc_type = d.id + LEFT JOIN tb_date_dish e ON a.date_id = e.date_id + LEFT JOIN tb_order_deliver_place g ON g.id = a.deliver_place_id + left join tb_order_state h on h.id = a.state_id + where + ". $where; + $param = array(); + $group = "a.id"; + $order = "a.id desc"; + $action = "getListByPage"; + $hasWhere = true; + $dataName = 'orderList'; + $paramFilter = array(); + $rowData = $this->lw_pagination2->lists($sql, $param, $page, $hasWhere, $group, $order, $action, $dataName, $paramFilter); +// echo "
";
+//        print_r($rowData);
+//        echo "
"; +// exit(); + + $data = $rowData; + // 获取菜品名称并且拼接 + foreach ($rowData['orderList'] as $k => $v){ + $sql = "select a.* from tb_dish a, tb_date_dish b WHERE a.id = b.dish_id and b.date_id = ".$v['date_id']; + $dishList = array(); + $mealName = ""; + $dishList = $this->db->query($sql)->result_array(); + if (count($dishList)>0){ + foreach ($dishList as $dk => $dv){ + if (empty($mealName) || $mealName == "")$mealName = $dv['dish_name']; + else $mealName .= "/".$dv['dish_name']; + } + $data['orderList'][$k]['dish_name'] = $mealName; + } + else $data['orderList'][$k]['dish_name'] = "-"; + + } + + echo $this->load->view('order/bj/bjorder_list', $data, true); + } + + public function orderExcelBj(){ + $this->load->library('lw_db', array('tb_name' => 'tb_admin'), 'tb_admin'); + $this->load->library('lw_pagination2'); + $this->load->database(); + $this->load->library('lw_string'); + $this->load->helper('excel'); + $hallId = $this->session->userdata('hallId'); + + //处理参数 + //处理提交参数 + $dishDateStart = $this->input->post("dishDateStart", true); + $dishDateEnd = $this->input->post("dishDateEnd", true); + $searchPlaceType = $this->input->post("searchPlaceType", true); + $searchMealType= $this->input->post("searchMealType", true); + + + //处理参数 + if (is_array($searchPlaceType)) { + if (count($searchPlaceType) == 1 && $searchPlaceType[0] == -1) { + unset($searchUserType); + } + } + + if (is_array($searchMealType)) { + if (count($searchMealType) == 1 && $searchMealType[0] == -1) { + unset($searchMealType); + } + } + + $dishDateStart = $this->db->escape_str($dishDateStart); + $dishDateEnd = $this->db->escape_str($dishDateEnd); + + $where = " 1 "; + + //处理数组 + if ($searchPlaceType) { + $tstr = "0"; + foreach ($searchPlaceType as $k => $v) { + $tstr .= "," . intval($v); + } + $where .= " and a.deliver_place_id in (" . $tstr . ")"; + } + + if ($searchMealType) { + $tstr = "0"; + foreach ($searchMealType as $k => $v) { + $tstr .= "," . intval($v); + } + $where .= " and d.id in (" . $tstr . ")"; + } + + + if ($dishDateStart) { + if ($dishDateEnd) { + $where .= " and c.dc_date between '" . $dishDateStart . "' and '" . $dishDateEnd . "' "; + } else { + $where .= " and c.dc_date >'" . $dishDateStart . "'"; + } + } + + $where .= " and g.dining_hall_id = ".$hallId; + + $sql = " + SELECT + a.date_id, + c.dc_date, + d.NAME, + b.username, + g.`name`, + a.reason, + a.total_price, + h.name as stateName + FROM + tb_order a + LEFT JOIN tb_user b ON a.uid = b.id + LEFT JOIN tb_date c ON c.id = a.date_id + LEFT JOIN tb_meal_type d ON c.dc_type = d.id + LEFT JOIN tb_date_dish e ON a.date_id = e.date_id + LEFT JOIN tb_order_deliver_place g ON g.id = a.deliver_place_id + left join tb_order_state h on h.id = a.state_id + where + ". $where. " group by a.id order by a.id desc"; + + // echo $sql;exit; + $excelData = $this->order_model->getExcelInfoBySql($sql); + + // 获取菜品名称并且拼接 + foreach ($excelData as $k => $v){ + + $sql = "select a.* from tb_dish a, tb_date_dish b WHERE a.id = b.dish_id and b.date_id = ".$v['date_id']; + $dishList = array(); + $mealName = ""; + $dishList = $this->db->query($sql)->result_array(); + if (count($dishList)>0){ + foreach ($dishList as $dk => $dv){ + if (empty($mealName) || $mealName == "")$mealName = $dv['dish_name']; + else $mealName .= "/".$dv['dish_name']; + } + $excelData[$k]['dish_name'] = $mealName; + } + else $excelData[$k]['dish_name'] = "-"; + unset($excelData[$k]['date_id']); + + } + + $title = array( + '日期', + '餐次', + '下单人', + '房间', + '备注内容', + '金额', + '状态', + '菜式', + ); + + + for($i=0;$ilw_string->getUniName(); + $path="outputExcel/order/".$date; + //print_r($path); + if(!is_dir($path)) { + mkdir($path,0777,true); + } + $fn=$path."/".$uniStr.".xls"; + getExcel($title, $width, $excelData, "$fn"); + $truePath = base_url($fn); + $data=array('success'=>true,'msg'=>$truePath); + echo json_encode($data); + + } + } diff --git a/backstage/application/backstage/models/Meal_model.php b/backstage/application/backstage/models/Meal_model.php index 6f87b4f..faa6ff1 100644 --- a/backstage/application/backstage/models/Meal_model.php +++ b/backstage/application/backstage/models/Meal_model.php @@ -123,4 +123,14 @@ class Meal_model extends CI_Model { return $this->db->query("select * from tb_meal_type where company_id='{$this->session->companyId}' and status='1' {$where} order by idx desc,id asc")->result_array(); } + + + //获取包间 + public function getbjMealTypeList() + { + return $this->db->select('*')->from('tb_meal_type') + ->where(array('status' => 1, 'company_id' => $this->session->companyId, 'mealtype' => 6)) + ->get() + ->result_array(); + } } \ No newline at end of file diff --git a/backstage/application/backstage/views/order/bj/bjorder_index.php b/backstage/application/backstage/views/order/bj/bjorder_index.php new file mode 100644 index 0000000..8ec1d96 --- /dev/null +++ b/backstage/application/backstage/views/order/bj/bjorder_index.php @@ -0,0 +1,164 @@ + +
+
+
+
+

筛选与添加

+
+ +
+
+
+
+
+
+ + +
+
+
+ +
+ "> + +
+
+
+
+ +
+ + +
+
+
+
+ + +
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/backstage/application/backstage/views/order/bj/bjorder_list.php b/backstage/application/backstage/views/order/bj/bjorder_list.php new file mode 100644 index 0000000..add6064 --- /dev/null +++ b/backstage/application/backstage/views/order/bj/bjorder_list.php @@ -0,0 +1,77 @@ + +
+
+
+ + + + + + + + + + + + + + + + 当前没有数据"; }else{$i=1; foreach($orderList as $order):?> + + + + + + + + + + + + + +
#日期餐次下单人房间菜式备注内容金额状态
+
+
+
+
+
+ +
+
+ + +