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,13 +5,14 @@ | ||
| 5 | use Yii; | 5 | use Yii; |
| 6 | use yii\behaviors\TimestampBehavior; | 6 | use yii\behaviors\TimestampBehavior; |
| 7 | use yii\db\ActiveRecord; | 7 | use yii\db\ActiveRecord; |
| 8 | - | 8 | + |
| 9 | /** | 9 | /** |
| 10 | * This is the model class for table "order". | 10 | * This is the model class for table "order". |
| 11 | * | 11 | * |
| 12 | * @property integer $id | 12 | * @property integer $id |
| 13 | * @property integer $user_id | 13 | * @property integer $user_id |
| 14 | * @property string $name | 14 | * @property string $name |
| 15 | + * @property string $secondname | ||
| 15 | * @property string $phone | 16 | * @property string $phone |
| 16 | * @property string $email | 17 | * @property string $email |
| 17 | * @property string $city | 18 | * @property string $city |
| @@ -38,7 +39,7 @@ | @@ -38,7 +39,7 @@ | ||
| 38 | { | 39 | { |
| 39 | return 'order'; | 40 | return 'order'; |
| 40 | } | 41 | } |
| 41 | - | 42 | + |
| 42 | public function behaviors() | 43 | public function behaviors() |
| 43 | { | 44 | { |
| 44 | return [ | 45 | return [ |
| @@ -136,7 +137,7 @@ | @@ -136,7 +137,7 @@ | ||
| 136 | 'created_at' => Yii::t('order', 'Created At'), | 137 | 'created_at' => Yii::t('order', 'Created At'), |
| 137 | 'updated_at' => Yii::t('order', 'Updated At'), | 138 | 'updated_at' => Yii::t('order', 'Updated At'), |
| 138 | 'deleted_at' => Yii::t('order', 'Deleted At'), | 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,7 +180,7 @@ | ||
| 179 | { | 180 | { |
| 180 | return $this->hasMany(OrderProduct::className(), [ 'order_id' => 'id' ]); | 181 | return $this->hasMany(OrderProduct::className(), [ 'order_id' => 'id' ]); |
| 181 | } | 182 | } |
| 182 | - | 183 | + |
| 183 | public function getCustomer() | 184 | public function getCustomer() |
| 184 | { | 185 | { |
| 185 | return $this->hasOne(Customer::className(), [ 'id' => 'user_id' ]); | 186 | return $this->hasOne(Customer::className(), [ 'id' => 'user_id' ]); |
models/OrderProduct.php
| @@ -171,6 +171,7 @@ | @@ -171,6 +171,7 @@ | ||
| 171 | } | 171 | } |
| 172 | } | 172 | } |
| 173 | $orderProducts = array_merge($orderProducts, $newItems); | 173 | $orderProducts = array_merge($orderProducts, $newItems); |
| 174 | + | ||
| 174 | foreach ($orderProducts as $orderProduct) { | 175 | foreach ($orderProducts as $orderProduct) { |
| 175 | $orderProduct->save(); | 176 | $orderProduct->save(); |
| 176 | } | 177 | } |
models/OrderSearch.php
| @@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
| 21 | return [ | 21 | return [ |
| 22 | [ | 22 | [ |
| 23 | [ | 23 | [ |
| 24 | - 'id', | 24 | + // 'id', |
| 25 | 'user_id', | 25 | 'user_id', |
| 26 | 'label_id', | 26 | 'label_id', |
| 27 | ], | 27 | ], |
| @@ -30,6 +30,7 @@ | @@ -30,6 +30,7 @@ | ||
| 30 | [ | 30 | [ |
| 31 | [ | 31 | [ |
| 32 | 'name', | 32 | 'name', |
| 33 | + 'secondname', | ||
| 33 | 'phone', | 34 | 'phone', |
| 34 | 'email', | 35 | 'email', |
| 35 | ], | 36 | ], |
| @@ -65,12 +66,7 @@ | @@ -65,12 +66,7 @@ | ||
| 65 | 'count(*)', | 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 | // add conditions that should always apply here | 71 | // add conditions that should always apply here |
| 76 | 72 | ||
| @@ -78,16 +74,20 @@ | @@ -78,16 +74,20 @@ | ||
| 78 | [ | 74 | [ |
| 79 | 'query' => $query, | 75 | 'query' => $query, |
| 80 | 'sort' => [ | 76 | 'sort' => [ |
| 81 | - 'attributes' => [ | 77 | + 'attributes' => [ |
| 82 | 'count', | 78 | 'count', |
| 83 | 'id', | 79 | 'id', |
| 84 | 'user_id', | 80 | 'user_id', |
| 85 | 'name', | 81 | 'name', |
| 82 | + 'secondname', | ||
| 86 | 'label_id', | 83 | 'label_id', |
| 87 | 'created_at', | 84 | 'created_at', |
| 88 | 'phone', | 85 | 'phone', |
| 89 | 'email', | 86 | 'email', |
| 90 | ], | 87 | ], |
| 88 | + 'defaultOrder' => [ | ||
| 89 | + 'created_at' => SORT_DESC, | ||
| 90 | + ], | ||
| 91 | ], | 91 | ], |
| 92 | ] | 92 | ] |
| 93 | ); | 93 | ); |
| @@ -103,7 +103,7 @@ | @@ -103,7 +103,7 @@ | ||
| 103 | // grid filtering conditions | 103 | // grid filtering conditions |
| 104 | $query->andFilterWhere( | 104 | $query->andFilterWhere( |
| 105 | [ | 105 | [ |
| 106 | - 'id' => $this->id, | 106 | + // 'id' => $this->id, |
| 107 | 'user_id' => $this->user_id, | 107 | 'user_id' => $this->user_id, |
| 108 | 'label_id' => $this->label_id, | 108 | 'label_id' => $this->label_id, |
| 109 | 'delivery_id' => $this->delivery_id, | 109 | 'delivery_id' => $this->delivery_id, |
| @@ -117,13 +117,20 @@ | @@ -117,13 +117,20 @@ | ||
| 117 | 117 | ||
| 118 | $query->andFilterWhere( | 118 | $query->andFilterWhere( |
| 119 | [ | 119 | [ |
| 120 | - 'like', | 120 | + 'ilike', |
| 121 | 'name', | 121 | 'name', |
| 122 | $this->name, | 122 | $this->name, |
| 123 | ] | 123 | ] |
| 124 | ) | 124 | ) |
| 125 | ->andFilterWhere( | 125 | ->andFilterWhere( |
| 126 | [ | 126 | [ |
| 127 | + 'ilike', | ||
| 128 | + 'secondname', | ||
| 129 | + $this->secondname, | ||
| 130 | + ] | ||
| 131 | + ) | ||
| 132 | + ->andFilterWhere( | ||
| 133 | + [ | ||
| 127 | 'like', | 134 | 'like', |
| 128 | 'phone', | 135 | 'phone', |
| 129 | $this->phone, | 136 | $this->phone, |
| @@ -131,28 +138,28 @@ | @@ -131,28 +138,28 @@ | ||
| 131 | ) | 138 | ) |
| 132 | ->andFilterWhere( | 139 | ->andFilterWhere( |
| 133 | [ | 140 | [ |
| 134 | - 'like', | 141 | + 'ilike', |
| 135 | 'email', | 142 | 'email', |
| 136 | $this->email, | 143 | $this->email, |
| 137 | ] | 144 | ] |
| 138 | ) | 145 | ) |
| 139 | ->andFilterWhere( | 146 | ->andFilterWhere( |
| 140 | [ | 147 | [ |
| 141 | - 'like', | 148 | + 'ilike', |
| 142 | 'city', | 149 | 'city', |
| 143 | $this->city, | 150 | $this->city, |
| 144 | ] | 151 | ] |
| 145 | ) | 152 | ) |
| 146 | ->andFilterWhere( | 153 | ->andFilterWhere( |
| 147 | [ | 154 | [ |
| 148 | - 'like', | 155 | + 'ilike', |
| 149 | 'address', | 156 | 'address', |
| 150 | $this->address, | 157 | $this->address, |
| 151 | ] | 158 | ] |
| 152 | ) | 159 | ) |
| 153 | ->andFilterWhere( | 160 | ->andFilterWhere( |
| 154 | [ | 161 | [ |
| 155 | - 'like', | 162 | + 'ilike', |
| 156 | 'comment', | 163 | 'comment', |
| 157 | $this->comment, | 164 | $this->comment, |
| 158 | ] | 165 | ] |
views/order/_form.php
| @@ -58,43 +58,6 @@ | @@ -58,43 +58,6 @@ | ||
| 58 | ->dropDownList($payments) ?> | 58 | ->dropDownList($payments) ?> |
| 59 | 59 | ||
| 60 | <div class="order-product-container"> | 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 | <div class="row"> | 61 | <div class="row"> |
| 99 | <div class="col-md-8"> | 62 | <div class="col-md-8"> |
| 100 | <?php | 63 | <?php |
| @@ -155,6 +118,43 @@ | @@ -155,6 +118,43 @@ | ||
| 155 | ?> | 118 | ?> |
| 156 | </div> | 119 | </div> |
| 157 | </div> | 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 | </div> | 158 | </div> |
| 159 | 159 | ||
| 160 | <div class="ln_solid"></div> | 160 | <div class="ln_solid"></div> |
views/order/index.php
| @@ -31,11 +31,9 @@ | @@ -31,11 +31,9 @@ | ||
| 31 | 'dataProvider' => $dataProvider, | 31 | 'dataProvider' => $dataProvider, |
| 32 | 'filterModel' => $searchModel, | 32 | 'filterModel' => $searchModel, |
| 33 | 'columns' => [ | 33 | 'columns' => [ |
| 34 | - [ 'class' => 'yii\grid\SerialColumn' ], | ||
| 35 | - | ||
| 36 | 'id', | 34 | 'id', |
| 37 | - 'user_id', | ||
| 38 | 'name', | 35 | 'name', |
| 36 | + 'secondname', | ||
| 39 | 'phone', | 37 | 'phone', |
| 40 | 'email:email', | 38 | 'email:email', |
| 41 | [ | 39 | [ |