1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- class Order extends Backend
- {
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\Order;
- $this->view->assign("ordertypeList", $this->model->getOrdertypeList());
- $this->view->assign("statusList", $this->model->getStatusList());
- $this->view->assign("paytypeList", $this->model->getPaytypeList());
- }
-
-
- public function index()
- {
-
- $this->relationSearch = true;
-
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
-
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
- $where_op = [];
- if($this->auth->company_id){
- $where_op['order.company_id'] = $this->auth->company_id;
- }
- $list = $this->model
- ->with(['company','staff','user','preorder','servicetype'])
- ->where($where)
- ->where($where_op)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $row) {
- $row->getRelation('company')->visible(['name']);
- $row->getRelation('staff')->visible(['truename','mobile']);
- $row->getRelation('user')->visible(['nickname','mobile']);
- $row->getRelation('preorder')->visible(['pre_order_no']);
- $row->getRelation('servicetype')->visible(['title']);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- }
|