Commit b5de253e5e21b955e31e721b385cf701b2ae772a

Authored by Yarik
1 parent 35b03e57

test

common/models/CustomerSearch.php
... ... @@ -97,6 +97,58 @@
97 97 'query' => $query,
98 98 ]);
99 99  
  100 + $dataProvider->setSort([
  101 + 'defaultOrder' => [
  102 + 'name' => SORT_ASC,
  103 + ],
  104 + 'attributes' => [
  105 + 'name' => [
  106 + 'asc' => [
  107 + 'company_info.name' => SORT_ASC,
  108 + 'firstname' => SORT_ASC,
  109 + 'lastname' => SORT_ASC,
  110 + ],
  111 + 'desc' => [
  112 + 'company_info.name' => SORT_DESC,
  113 + 'firstname' => SORT_DESC,
  114 + 'lastname' => SORT_DESC,
  115 + ],
  116 + 'default' => SORT_ASC,
  117 + 'label' => 'Название',
  118 + ],
  119 + 'staff' => [
  120 + 'asc' => [
  121 + 'company_info.staff' => SORT_ASC,
  122 + ],
  123 + 'desc' => [
  124 + 'company_info.staff' => SORT_DESC,
  125 + ],
  126 + 'default' => SORT_DESC,
  127 + 'label' => 'Количество сотрудников',
  128 + ],
  129 + 'visit' => [
  130 + 'asc' => [
  131 + 'user_info.date_visit' => SORT_ASC,
  132 + ],
  133 + 'desc' => [
  134 + 'user_info.date_visit' => SORT_DESC,
  135 + ],
  136 + 'default' => SORT_DESC,
  137 + 'label' => 'Последний визит',
  138 + ],
  139 + 'city' => [
  140 + 'asc' => [
  141 + 'user_info.city' => SORT_ASC,
  142 + ],
  143 + 'desc' => [
  144 + 'user_info.city' => SORT_DESC,
  145 + ],
  146 + 'default' => SORT_ASC,
  147 + 'label' => 'Город',
  148 + ],
  149 + ],
  150 + ]);
  151 +
100 152 $this->load($params);
101 153  
102 154 if(!$this->validate()) {
... ...
frontend/controllers/SearchController.php
... ... @@ -75,57 +75,6 @@ use common\models\Social;
75 75 $dataProvider->setPagination([
76 76 'pageSize' => 5,
77 77 ]);
78   - $dataProvider->setSort([
79   - 'defaultOrder' => [
80   - 'name' => SORT_ASC,
81   - ],
82   - 'attributes' => [
83   - 'name' => [
84   - 'asc' => [
85   - 'company_info.name' => SORT_ASC,
86   - 'firstname' => SORT_ASC,
87   - 'lastname' => SORT_ASC,
88   - ],
89   - 'desc' => [
90   - 'company_info.name' => SORT_DESC,
91   - 'firstname' => SORT_DESC,
92   - 'lastname' => SORT_DESC,
93   - ],
94   - 'default' => SORT_ASC,
95   - 'label' => 'Название',
96   - ],
97   - 'staff' => [
98   - 'asc' => [
99   - 'company_info.staff' => SORT_ASC,
100   - ],
101   - 'desc' => [
102   - 'company_info.staff' => SORT_DESC,
103   - ],
104   - 'default' => SORT_DESC,
105   - 'label' => 'Количество сотрудников',
106   - ],
107   - 'visit' => [
108   - 'asc' => [
109   - 'user_info.date_visit' => SORT_ASC,
110   - ],
111   - 'desc' => [
112   - 'user_info.date_visit' => SORT_DESC,
113   - ],
114   - 'default' => SORT_DESC,
115   - 'label' => 'Последний визит',
116   - ],
117   - 'city' => [
118   - 'asc' => [
119   - 'user_info.city' => SORT_ASC,
120   - ],
121   - 'desc' => [
122   - 'user_info.city' => SORT_DESC,
123   - ],
124   - 'default' => SORT_ASC,
125   - 'label' => 'Город',
126   - ],
127   - ],
128   - ]);
129 78 $model->load(Yii::$app->request->queryParams);
130 79 return $this->render('customer', [
131 80 'model' => $model,
... ...