Commit 19a97a72b7c0b19f8420f6608da943e0755f8185
1 parent
f8f0b405
-Finish what i begun!!!
Showing
5 changed files
with
65 additions
and
58 deletions
Show diff stats
models/Order.php
| ... | ... | @@ -5,13 +5,14 @@ |
| 5 | 5 | use Yii; |
| 6 | 6 | use yii\behaviors\TimestampBehavior; |
| 7 | 7 | use yii\db\ActiveRecord; |
| 8 | - | |
| 8 | + | |
| 9 | 9 | /** |
| 10 | 10 | * This is the model class for table "order". |
| 11 | 11 | * |
| 12 | 12 | * @property integer $id |
| 13 | 13 | * @property integer $user_id |
| 14 | 14 | * @property string $name |
| 15 | + * @property string $secondname | |
| 15 | 16 | * @property string $phone |
| 16 | 17 | * @property string $email |
| 17 | 18 | * @property string $city |
| ... | ... | @@ -38,7 +39,7 @@ |
| 38 | 39 | { |
| 39 | 40 | return 'order'; |
| 40 | 41 | } |
| 41 | - | |
| 42 | + | |
| 42 | 43 | public function behaviors() |
| 43 | 44 | { |
| 44 | 45 | return [ |
| ... | ... | @@ -136,7 +137,7 @@ |
| 136 | 137 | 'created_at' => Yii::t('order', 'Created At'), |
| 137 | 138 | 'updated_at' => Yii::t('order', 'Updated At'), |
| 138 | 139 | 'deleted_at' => Yii::t('order', 'Deleted At'), |
| 139 | - 'secondname' => \Yii::t('order', 'Фамилия'), | |
| 140 | + 'secondname' => \Yii::t('order', 'Фамилия'), | |
| 140 | 141 | ]; |
| 141 | 142 | } |
| 142 | 143 | |
| ... | ... | @@ -179,7 +180,7 @@ |
| 179 | 180 | { |
| 180 | 181 | return $this->hasMany(OrderProduct::className(), [ 'order_id' => 'id' ]); |
| 181 | 182 | } |
| 182 | - | |
| 183 | + | |
| 183 | 184 | public function getCustomer() |
| 184 | 185 | { |
| 185 | 186 | return $this->hasOne(Customer::className(), [ 'id' => 'user_id' ]); | ... | ... |
models/OrderProduct.php
models/OrderSearch.php
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | return [ |
| 22 | 22 | [ |
| 23 | 23 | [ |
| 24 | - 'id', | |
| 24 | + // 'id', | |
| 25 | 25 | 'user_id', |
| 26 | 26 | 'label_id', |
| 27 | 27 | ], |
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | [ |
| 31 | 31 | [ |
| 32 | 32 | 'name', |
| 33 | + 'secondname', | |
| 33 | 34 | 'phone', |
| 34 | 35 | 'email', |
| 35 | 36 | ], |
| ... | ... | @@ -65,12 +66,7 @@ |
| 65 | 66 | 'count(*)', |
| 66 | 67 | ] |
| 67 | 68 | ) |
| 68 | - ->groupBy('order.id') | |
| 69 | - ->orderBy( | |
| 70 | - [ | |
| 71 | - 'order.id' => SORT_DESC, | |
| 72 | - ] | |
| 73 | - ); | |
| 69 | + ->groupBy('order.id'); | |
| 74 | 70 | |
| 75 | 71 | // add conditions that should always apply here |
| 76 | 72 | |
| ... | ... | @@ -78,16 +74,20 @@ |
| 78 | 74 | [ |
| 79 | 75 | 'query' => $query, |
| 80 | 76 | 'sort' => [ |
| 81 | - 'attributes' => [ | |
| 77 | + 'attributes' => [ | |
| 82 | 78 | 'count', |
| 83 | 79 | 'id', |
| 84 | 80 | 'user_id', |
| 85 | 81 | 'name', |
| 82 | + 'secondname', | |
| 86 | 83 | 'label_id', |
| 87 | 84 | 'created_at', |
| 88 | 85 | 'phone', |
| 89 | 86 | 'email', |
| 90 | 87 | ], |
| 88 | + 'defaultOrder' => [ | |
| 89 | + 'created_at' => SORT_DESC, | |
| 90 | + ], | |
| 91 | 91 | ], |
| 92 | 92 | ] |
| 93 | 93 | ); |
| ... | ... | @@ -103,7 +103,7 @@ |
| 103 | 103 | // grid filtering conditions |
| 104 | 104 | $query->andFilterWhere( |
| 105 | 105 | [ |
| 106 | - 'id' => $this->id, | |
| 106 | + // 'id' => $this->id, | |
| 107 | 107 | 'user_id' => $this->user_id, |
| 108 | 108 | 'label_id' => $this->label_id, |
| 109 | 109 | 'delivery_id' => $this->delivery_id, |
| ... | ... | @@ -117,13 +117,20 @@ |
| 117 | 117 | |
| 118 | 118 | $query->andFilterWhere( |
| 119 | 119 | [ |
| 120 | - 'like', | |
| 120 | + 'ilike', | |
| 121 | 121 | 'name', |
| 122 | 122 | $this->name, |
| 123 | 123 | ] |
| 124 | 124 | ) |
| 125 | 125 | ->andFilterWhere( |
| 126 | 126 | [ |
| 127 | + 'ilike', | |
| 128 | + 'secondname', | |
| 129 | + $this->secondname, | |
| 130 | + ] | |
| 131 | + ) | |
| 132 | + ->andFilterWhere( | |
| 133 | + [ | |
| 127 | 134 | 'like', |
| 128 | 135 | 'phone', |
| 129 | 136 | $this->phone, |
| ... | ... | @@ -131,28 +138,28 @@ |
| 131 | 138 | ) |
| 132 | 139 | ->andFilterWhere( |
| 133 | 140 | [ |
| 134 | - 'like', | |
| 141 | + 'ilike', | |
| 135 | 142 | 'email', |
| 136 | 143 | $this->email, |
| 137 | 144 | ] |
| 138 | 145 | ) |
| 139 | 146 | ->andFilterWhere( |
| 140 | 147 | [ |
| 141 | - 'like', | |
| 148 | + 'ilike', | |
| 142 | 149 | 'city', |
| 143 | 150 | $this->city, |
| 144 | 151 | ] |
| 145 | 152 | ) |
| 146 | 153 | ->andFilterWhere( |
| 147 | 154 | [ |
| 148 | - 'like', | |
| 155 | + 'ilike', | |
| 149 | 156 | 'address', |
| 150 | 157 | $this->address, |
| 151 | 158 | ] |
| 152 | 159 | ) |
| 153 | 160 | ->andFilterWhere( |
| 154 | 161 | [ |
| 155 | - 'like', | |
| 162 | + 'ilike', | |
| 156 | 163 | 'comment', |
| 157 | 164 | $this->comment, |
| 158 | 165 | ] | ... | ... |
views/order/_form.php
| ... | ... | @@ -58,43 +58,6 @@ |
| 58 | 58 | ->dropDownList($payments) ?> |
| 59 | 59 | |
| 60 | 60 | <div class="order-product-container"> |
| 61 | - <div id="order-product-pjax" style="position: relative;"> | |
| 62 | - <div class="row strong"> | |
| 63 | - <div class="col-md-4"> | |
| 64 | - <?php | |
| 65 | - echo Html::tag('strong', \Yii::t('order', 'Product')); | |
| 66 | - ?> | |
| 67 | - </div> | |
| 68 | - <div class="col-md-4"> | |
| 69 | - <?php | |
| 70 | - echo Html::tag('strong', \Yii::t('order', 'Price')); | |
| 71 | - ?> | |
| 72 | - </div> | |
| 73 | - <div class="col-md-4"> | |
| 74 | - <?php | |
| 75 | - echo Html::tag('strong', \Yii::t('order', 'Count')); | |
| 76 | - ?> | |
| 77 | - </div> | |
| 78 | - </div> | |
| 79 | - <div id="product-rows"> | |
| 80 | - <?php | |
| 81 | - if (!$model->isNewRecord) { | |
| 82 | - foreach ($model->orderProducts as $index => $orderProduct) { | |
| 83 | - echo $this->render( | |
| 84 | - '_order_product', | |
| 85 | - [ | |
| 86 | - 'orderProduct' => $orderProduct, | |
| 87 | - 'price' => $orderProduct->price, | |
| 88 | - 'index' => $index, | |
| 89 | - 'variant' => $orderProduct->variant, | |
| 90 | - 'form' => $form, | |
| 91 | - ] | |
| 92 | - ); | |
| 93 | - } | |
| 94 | - } | |
| 95 | - ?> | |
| 96 | - </div> | |
| 97 | - </div> | |
| 98 | 61 | <div class="row"> |
| 99 | 62 | <div class="col-md-8"> |
| 100 | 63 | <?php |
| ... | ... | @@ -155,6 +118,43 @@ |
| 155 | 118 | ?> |
| 156 | 119 | </div> |
| 157 | 120 | </div> |
| 121 | + <div class="row" id="order-product-pjax" style="position: relative;"> | |
| 122 | + <div class="row strong"> | |
| 123 | + <div class="col-md-4"> | |
| 124 | + <?php | |
| 125 | + echo Html::tag('strong', \Yii::t('order', 'Product')); | |
| 126 | + ?> | |
| 127 | + </div> | |
| 128 | + <div class="col-md-4"> | |
| 129 | + <?php | |
| 130 | + echo Html::tag('strong', \Yii::t('order', 'Price')); | |
| 131 | + ?> | |
| 132 | + </div> | |
| 133 | + <div class="col-md-4"> | |
| 134 | + <?php | |
| 135 | + echo Html::tag('strong', \Yii::t('order', 'Count')); | |
| 136 | + ?> | |
| 137 | + </div> | |
| 138 | + </div> | |
| 139 | + <div id="product-rows"> | |
| 140 | + <?php | |
| 141 | + if (!$model->isNewRecord) { | |
| 142 | + foreach ($model->orderProducts as $index => $orderProduct) { | |
| 143 | + echo $this->render( | |
| 144 | + '_order_product', | |
| 145 | + [ | |
| 146 | + 'orderProduct' => $orderProduct, | |
| 147 | + 'price' => $orderProduct->price, | |
| 148 | + 'index' => $index, | |
| 149 | + 'variant' => $orderProduct->variant, | |
| 150 | + 'form' => $form, | |
| 151 | + ] | |
| 152 | + ); | |
| 153 | + } | |
| 154 | + } | |
| 155 | + ?> | |
| 156 | + </div> | |
| 157 | + </div> | |
| 158 | 158 | </div> |
| 159 | 159 | |
| 160 | 160 | <div class="ln_solid"></div> | ... | ... |
views/order/index.php