Commit 0118578668ca12fa0e7c61807059ac4b09e9e00c
1 parent
4eefbba0
-Sms in process
Showing
7 changed files
with
302 additions
and
95 deletions
Show diff stats
controllers/OrderController.php
| @@ -202,7 +202,7 @@ | @@ -202,7 +202,7 @@ | ||
| 202 | 202 | ||
| 203 | $dataProvider = new ActiveDataProvider( | 203 | $dataProvider = new ActiveDataProvider( |
| 204 | [ | 204 | [ |
| 205 | - 'query' => $model->getProducts(), | 205 | + 'query' => $model->getProducts()->joinWith('productVariant'), |
| 206 | ] | 206 | ] |
| 207 | ); | 207 | ); |
| 208 | 208 | ||
| @@ -271,7 +271,7 @@ | @@ -271,7 +271,7 @@ | ||
| 271 | 271 | ||
| 272 | $dataProvider = new ActiveDataProvider( | 272 | $dataProvider = new ActiveDataProvider( |
| 273 | [ | 273 | [ |
| 274 | - 'query' => $model->getProducts(), | 274 | + 'query' => $model->getProducts()->joinWith('productVariant.product.brand'), |
| 275 | ] | 275 | ] |
| 276 | ); | 276 | ); |
| 277 | 277 |
models/Order.php
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | namespace artweb\artbox\ecommerce\models; | 2 | namespace artweb\artbox\ecommerce\models; |
| 3 | 3 | ||
| 4 | use artweb\artbox\models\Customer; | 4 | use artweb\artbox\models\Customer; |
| 5 | + use common\models\User; | ||
| 5 | use Yii; | 6 | use Yii; |
| 6 | use yii\behaviors\TimestampBehavior; | 7 | use yii\behaviors\TimestampBehavior; |
| 7 | use yii\db\ActiveRecord; | 8 | use yii\db\ActiveRecord; |
| @@ -20,6 +21,7 @@ | @@ -20,6 +21,7 @@ | ||
| 20 | * @property string $check | 21 | * @property string $check |
| 21 | * @property string $sms | 22 | * @property string $sms |
| 22 | * @property int $id | 23 | * @property int $id |
| 24 | + * @property integer $manager_id | ||
| 23 | * @property int $user_id | 25 | * @property int $user_id |
| 24 | * @property string $name | 26 | * @property string $name |
| 25 | * @property string $phone | 27 | * @property string $phone |
| @@ -88,10 +90,15 @@ | @@ -88,10 +90,15 @@ | ||
| 88 | 'payment', | 90 | 'payment', |
| 89 | 'reason', | 91 | 'reason', |
| 90 | 'label', | 92 | 'label', |
| 93 | + 'manager_id', | ||
| 91 | ], | 94 | ], |
| 92 | 'integer', | 95 | 'integer', |
| 93 | ], | 96 | ], |
| 94 | [ | 97 | [ |
| 98 | + [ 'total' ], | ||
| 99 | + 'double', | ||
| 100 | + ], | ||
| 101 | + [ | ||
| 95 | [ | 102 | [ |
| 96 | 'phone', | 103 | 'phone', |
| 97 | ], | 104 | ], |
| @@ -127,7 +134,6 @@ | @@ -127,7 +134,6 @@ | ||
| 127 | 'shipping_by', | 134 | 'shipping_by', |
| 128 | 'city', | 135 | 'city', |
| 129 | 'adress', | 136 | 'adress', |
| 130 | - 'total', | ||
| 131 | 'status', | 137 | 'status', |
| 132 | 'check', | 138 | 'check', |
| 133 | 'sms', | 139 | 'sms', |
| @@ -170,17 +176,19 @@ | @@ -170,17 +176,19 @@ | ||
| 170 | public function attributeLabels() | 176 | public function attributeLabels() |
| 171 | { | 177 | { |
| 172 | return [ | 178 | return [ |
| 173 | - 'name' => Yii::t('app', 'order_name'), | ||
| 174 | - 'phone' => Yii::t('app', 'order_phone'), | ||
| 175 | - 'email' => Yii::t('app', 'order_email'), | ||
| 176 | - 'comment' => Yii::t('app', 'order_comment'), | ||
| 177 | - 'created_at' => Yii::t('app', 'Дата добавления'), | ||
| 178 | - 'updated_at' => Yii::t('app', 'Дата обновления'), | ||
| 179 | - 'deleted_at' => Yii::t('app', 'Дата удаления'), | ||
| 180 | - 'deadline' => Yii::t('app', 'Дедлайн'), | ||
| 181 | - 'reason' => Yii::t('app', 'Причина'), | ||
| 182 | - 'check' => Yii::t('app', 'Чек'), | ||
| 183 | - 'sms' => Yii::t('app', 'СМС'), | 179 | + 'name' => Yii::t('app', 'order_name'), |
| 180 | + 'phone' => Yii::t('app', 'order_phone'), | ||
| 181 | + 'email' => Yii::t('app', 'order_email'), | ||
| 182 | + 'comment' => Yii::t('app', 'order_comment'), | ||
| 183 | + 'created_at' => Yii::t('app', 'Дата добавления'), | ||
| 184 | + 'updated_at' => Yii::t('app', 'Дата обновления'), | ||
| 185 | + 'deleted_at' => Yii::t('app', 'Дата удаления'), | ||
| 186 | + 'deadline' => Yii::t('app', 'Дедлайн'), | ||
| 187 | + 'reason' => Yii::t('app', 'Причина'), | ||
| 188 | + 'check' => Yii::t('app', 'Чек'), | ||
| 189 | + 'sms' => Yii::t('app', 'СМС'), | ||
| 190 | + 'consignment' => Yii::t('app', 'Номер накладной'), | ||
| 191 | + 'manager_id' => Yii::t('app', 'Менеджер'), | ||
| 184 | ]; | 192 | ]; |
| 185 | } | 193 | } |
| 186 | 194 | ||
| @@ -236,18 +244,27 @@ | @@ -236,18 +244,27 @@ | ||
| 236 | return ''; | 244 | return ''; |
| 237 | } | 245 | } |
| 238 | } | 246 | } |
| 239 | - | 247 | + |
| 240 | /** | 248 | /** |
| 241 | * If deadline is fucked up returns true, | 249 | * If deadline is fucked up returns true, |
| 242 | * if deadline is not setted return false, like everything is ok | 250 | * if deadline is not setted return false, like everything is ok |
| 251 | + * | ||
| 243 | * @return bool | 252 | * @return bool |
| 244 | */ | 253 | */ |
| 245 | public function getWasted() | 254 | public function getWasted() |
| 246 | { | 255 | { |
| 247 | - if (empty($this->deadline)) { | 256 | + if (empty( $this->deadline )) { |
| 248 | return false; | 257 | return false; |
| 249 | } else { | 258 | } else { |
| 250 | return time() > strtotime($this->deadline); | 259 | return time() > strtotime($this->deadline); |
| 251 | } | 260 | } |
| 252 | } | 261 | } |
| 262 | + | ||
| 263 | + /** | ||
| 264 | + * | ||
| 265 | + */ | ||
| 266 | + public function getManager() | ||
| 267 | + { | ||
| 268 | + $this->hasOne(User::className(), [ 'id' => 'manager_id' ]); | ||
| 269 | + } | ||
| 253 | } | 270 | } |
| 254 | \ No newline at end of file | 271 | \ No newline at end of file |
models/OrderProduct.php
| @@ -29,6 +29,13 @@ | @@ -29,6 +29,13 @@ | ||
| 29 | return 'order_product'; | 29 | return 'order_product'; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | + public function beforeSave($insert) | ||
| 33 | + { | ||
| 34 | + $this->price = $this->productVariant->price; | ||
| 35 | + $this->sum_cost = $this->price * $this->count; | ||
| 36 | + return parent::beforeSave($insert); // TODO: Change the autogenerated stub | ||
| 37 | + } | ||
| 38 | + | ||
| 32 | public function rules() | 39 | public function rules() |
| 33 | { | 40 | { |
| 34 | return [ | 41 | return [ |
models/OrderSearch.php
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | 4 | ||
| 5 | use yii\base\Model; | 5 | use yii\base\Model; |
| 6 | use yii\data\ActiveDataProvider; | 6 | use yii\data\ActiveDataProvider; |
| 7 | + use yii\helpers\VarDumper; | ||
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| 9 | * OrderSearch represents the model behind the search form about `\artweb\artbox\ecommerce\models\Order`. | 10 | * OrderSearch represents the model behind the search form about `\artweb\artbox\ecommerce\models\Order`. |
| @@ -13,6 +14,7 @@ | @@ -13,6 +14,7 @@ | ||
| 13 | public $date_from; | 14 | public $date_from; |
| 14 | public $date_to; | 15 | public $date_to; |
| 15 | public $date_range; | 16 | public $date_range; |
| 17 | + public $sku; | ||
| 16 | 18 | ||
| 17 | /** | 19 | /** |
| 18 | * @inheritdoc | 20 | * @inheritdoc |
| @@ -23,10 +25,7 @@ | @@ -23,10 +25,7 @@ | ||
| 23 | [ | 25 | [ |
| 24 | [ | 26 | [ |
| 25 | 'id', | 27 | 'id', |
| 26 | - 'user_id', | ||
| 27 | - 'delivery', | ||
| 28 | - 'payment', | ||
| 29 | - 'status', | 28 | + 'manager_id', |
| 30 | ], | 29 | ], |
| 31 | 'integer', | 30 | 'integer', |
| 32 | ], | 31 | ], |
| @@ -38,7 +37,13 @@ | @@ -38,7 +37,13 @@ | ||
| 38 | 'date_from', | 37 | 'date_from', |
| 39 | 'date_to', | 38 | 'date_to', |
| 40 | 'date_range', | 39 | 'date_range', |
| 41 | - 'created_at' | 40 | + 'created_at', |
| 41 | + 'body', | ||
| 42 | + 'declaration', | ||
| 43 | + 'consignment', | ||
| 44 | + 'delivery', | ||
| 45 | + 'label', | ||
| 46 | + 'sku', | ||
| 42 | ], | 47 | ], |
| 43 | 'safe', | 48 | 'safe', |
| 44 | ], | 49 | ], |
| @@ -75,20 +80,27 @@ | @@ -75,20 +80,27 @@ | ||
| 75 | 80 | ||
| 76 | $this->load($params); | 81 | $this->load($params); |
| 77 | 82 | ||
| 83 | + // VarDumper::dump($params, 10, true); die(); | ||
| 84 | + | ||
| 78 | if (!$this->validate()) { | 85 | if (!$this->validate()) { |
| 79 | // uncomment the following line if you do not want to return any records when validation fails | 86 | // uncomment the following line if you do not want to return any records when validation fails |
| 80 | // $query->where('0=1'); | 87 | // $query->where('0=1'); |
| 81 | return $dataProvider; | 88 | return $dataProvider; |
| 82 | } | 89 | } |
| 83 | 90 | ||
| 91 | + if (!empty( $this->sku )) { | ||
| 92 | + $query->innerJoinWith('products.productVariant') | ||
| 93 | + ->andWhere( | ||
| 94 | + [ | ||
| 95 | + 'product_variant.id' => $this->sku, | ||
| 96 | + ] | ||
| 97 | + ); | ||
| 98 | + } | ||
| 99 | + | ||
| 84 | // grid filtering conditions | 100 | // grid filtering conditions |
| 85 | $query->andFilterWhere( | 101 | $query->andFilterWhere( |
| 86 | [ | 102 | [ |
| 87 | - 'id' => $this->id, | ||
| 88 | - 'user_id' => $this->user_id, | ||
| 89 | - 'delivery' => $this->delivery, | ||
| 90 | - 'payment' => $this->payment, | ||
| 91 | - 'status' => $this->status, | 103 | + 'id' => $this->id, |
| 92 | ] | 104 | ] |
| 93 | ); | 105 | ); |
| 94 | 106 | ||
| @@ -98,25 +110,63 @@ | @@ -98,25 +110,63 @@ | ||
| 98 | 'name', | 110 | 'name', |
| 99 | $this->name, | 111 | $this->name, |
| 100 | ] | 112 | ] |
| 101 | - ) | ||
| 102 | - ->andFilterWhere( | ||
| 103 | - [ | ||
| 104 | - 'like', | ||
| 105 | - 'email', | ||
| 106 | - $this->email, | ||
| 107 | - ] | ||
| 108 | - ) | ||
| 109 | - ->andFilterWhere( | ||
| 110 | - [ | ||
| 111 | - 'like', | ||
| 112 | - 'phone', | ||
| 113 | - $this->phone, | ||
| 114 | - ] | ||
| 115 | - ); | ||
| 116 | - if (!empty($this->date_range)) { | 113 | + ); |
| 114 | + $query->andFilterWhere( | ||
| 115 | + [ | ||
| 116 | + 'like', | ||
| 117 | + 'email', | ||
| 118 | + $this->email, | ||
| 119 | + ] | ||
| 120 | + ); | ||
| 121 | + $query->andFilterWhere( | ||
| 122 | + [ | ||
| 123 | + 'like', | ||
| 124 | + 'phone', | ||
| 125 | + $this->phone, | ||
| 126 | + ] | ||
| 127 | + ); | ||
| 128 | + $query->andFilterWhere( | ||
| 129 | + [ | ||
| 130 | + 'like', | ||
| 131 | + 'body', | ||
| 132 | + $this->body, | ||
| 133 | + ] | ||
| 134 | + ); | ||
| 135 | + $query->andFilterWhere( | ||
| 136 | + [ | ||
| 137 | + 'like', | ||
| 138 | + 'consignment', | ||
| 139 | + $this->consignment, | ||
| 140 | + ] | ||
| 141 | + ); | ||
| 142 | + $query->andFilterWhere( | ||
| 143 | + [ | ||
| 144 | + 'like', | ||
| 145 | + 'declaration', | ||
| 146 | + $this->declaration, | ||
| 147 | + ] | ||
| 148 | + ); | ||
| 149 | + $query->andFilterWhere( | ||
| 150 | + [ | ||
| 151 | + 'label' => $this->label, | ||
| 152 | + | ||
| 153 | + ] | ||
| 154 | + ); | ||
| 155 | + $query->andFilterWhere( | ||
| 156 | + [ | ||
| 157 | + 'manager_id' => $this->manager_id, | ||
| 158 | + | ||
| 159 | + ] | ||
| 160 | + ); | ||
| 161 | + $query->andFilterWhere( | ||
| 162 | + [ | ||
| 163 | + 'delivery' => $this->delivery, | ||
| 164 | + ] | ||
| 165 | + ); | ||
| 166 | + if (!empty( $this->date_range )) { | ||
| 117 | $this->date_from = strtotime(explode('to', $this->date_range)[ 0 ]); | 167 | $this->date_from = strtotime(explode('to', $this->date_range)[ 0 ]); |
| 118 | $this->date_to = strtotime(explode('to', $this->date_range)[ 1 ]); | 168 | $this->date_to = strtotime(explode('to', $this->date_range)[ 1 ]); |
| 119 | - | 169 | + |
| 120 | $query->andFilterWhere( | 170 | $query->andFilterWhere( |
| 121 | [ | 171 | [ |
| 122 | '>=', | 172 | '>=', |
models/TaxGroup.php
| @@ -117,8 +117,8 @@ | @@ -117,8 +117,8 @@ | ||
| 117 | 'is_filter' => 'Use in filter', | 117 | 'is_filter' => 'Use in filter', |
| 118 | 'sort' => 'Sort', | 118 | 'sort' => 'Sort', |
| 119 | 'display' => 'Display', | 119 | 'display' => 'Display', |
| 120 | - 'is_menu' => 'Отображать в меню', | ||
| 121 | - 'level' => 'уровень', | 120 | + 'is_menu' => 'Отображать в характеристиках', |
| 121 | + 'level' => 'уровень', | ||
| 122 | 'ppsition' => 'Позиция', | 122 | 'ppsition' => 'Позиция', |
| 123 | ]; | 123 | ]; |
| 124 | } | 124 | } |
views/order/_form.php
| @@ -4,10 +4,12 @@ | @@ -4,10 +4,12 @@ | ||
| 4 | use artweb\artbox\ecommerce\models\Order; | 4 | use artweb\artbox\ecommerce\models\Order; |
| 5 | use artweb\artbox\ecommerce\models\OrderPayment; | 5 | use artweb\artbox\ecommerce\models\OrderPayment; |
| 6 | use artweb\artbox\ecommerce\models\OrderProduct; | 6 | use artweb\artbox\ecommerce\models\OrderProduct; |
| 7 | + use backend\models\SmsTemplate; | ||
| 7 | use kartik\grid\GridView; | 8 | use kartik\grid\GridView; |
| 8 | use kartik\widgets\DatePicker; | 9 | use kartik\widgets\DatePicker; |
| 9 | use kartik\widgets\Select2; | 10 | use kartik\widgets\Select2; |
| 10 | use kartik\widgets\SwitchInput; | 11 | use kartik\widgets\SwitchInput; |
| 12 | + use yii\bootstrap\Dropdown; | ||
| 11 | use yii\data\ActiveDataProvider; | 13 | use yii\data\ActiveDataProvider; |
| 12 | use yii\helpers\Html; | 14 | use yii\helpers\Html; |
| 13 | use yii\bootstrap\ActiveForm; | 15 | use yii\bootstrap\ActiveForm; |
| @@ -52,7 +54,17 @@ $('#order-phone, #order-phone2').mask('+38(000)000-00-00', { | @@ -52,7 +54,17 @@ $('#order-phone, #order-phone2').mask('+38(000)000-00-00', { | ||
| 52 | JS; | 54 | JS; |
| 53 | 55 | ||
| 54 | $this->registerJs($js, View::POS_READY); | 56 | $this->registerJs($js, View::POS_READY); |
| 55 | - | 57 | + |
| 58 | + $js = <<< JS | ||
| 59 | +$(document).on('change', '#sms-template-selector', function(event) { | ||
| 60 | + var text = $('#select2-sms-template-selector-container').attr('title'); | ||
| 61 | + var val = $('option:contains(' + text + ')') | ||
| 62 | + console.log(text); | ||
| 63 | + console.log(val); | ||
| 64 | +}); | ||
| 65 | +JS; | ||
| 66 | + | ||
| 67 | + $this->registerJs($js, View::POS_READY); | ||
| 56 | ?> | 68 | ?> |
| 57 | 69 | ||
| 58 | <?php $form = ActiveForm::begin(); ?> | 70 | <?php $form = ActiveForm::begin(); ?> |
| @@ -65,9 +77,14 @@ JS; | @@ -65,9 +77,14 @@ JS; | ||
| 65 | ) ?> | 77 | ) ?> |
| 66 | <?= Html::a( | 78 | <?= Html::a( |
| 67 | \Yii::t('app', 'Печать'), | 79 | \Yii::t('app', 'Печать'), |
| 68 | - '#', | 80 | + yii\helpers\Url::to( |
| 81 | + [ | ||
| 82 | + 'order/print', | ||
| 83 | + 'order_id' => $model->id, | ||
| 84 | + ] | ||
| 85 | + ), | ||
| 69 | [ | 86 | [ |
| 70 | - 'class' => 'btn btn-info', | 87 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled' : 'btn btn-info', |
| 71 | 'target' => '_blank', | 88 | 'target' => '_blank', |
| 72 | ] | 89 | ] |
| 73 | ) ?> | 90 | ) ?> |
| @@ -206,20 +223,26 @@ JS; | @@ -206,20 +223,26 @@ JS; | ||
| 206 | 'layout' => '{items}{pager}', | 223 | 'layout' => '{items}{pager}', |
| 207 | 'columns' => [ | 224 | 'columns' => [ |
| 208 | 'id', | 225 | 'id', |
| 209 | - 'product_name', | ||
| 210 | 'sku', | 226 | 'sku', |
| 227 | + 'product_name', | ||
| 228 | + 'productVariant.product.brand.lang.title', | ||
| 229 | + 'productVariant.lang.title', | ||
| 230 | + 'price', | ||
| 211 | [ | 231 | [ |
| 212 | 'class' => 'kartik\grid\EditableColumn', | 232 | 'class' => 'kartik\grid\EditableColumn', |
| 213 | 'attribute' => 'count', | 233 | 'attribute' => 'count', |
| 214 | 'editableOptions' => [ | 234 | 'editableOptions' => [ |
| 215 | - 'header' => \Yii::t('app', 'Количество'), | ||
| 216 | - 'inputType' => kartik\editable\Editable::INPUT_SPIN, | ||
| 217 | - 'options' => [ | 235 | + 'header' => \Yii::t('app', 'Количество'), |
| 236 | + 'inputType' => kartik\editable\Editable::INPUT_SPIN, | ||
| 237 | + 'options' => [ | ||
| 218 | 'pluginOptions' => [ | 238 | 'pluginOptions' => [ |
| 219 | 'min' => 0, | 239 | 'min' => 0, |
| 220 | 'max' => 5000, | 240 | 'max' => 5000, |
| 221 | ], | 241 | ], |
| 222 | ], | 242 | ], |
| 243 | + 'pluginEvents' => [ | ||
| 244 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | ||
| 245 | + ], | ||
| 223 | ], | 246 | ], |
| 224 | 'format' => [ | 247 | 'format' => [ |
| 225 | 'decimal', | 248 | 'decimal', |
| @@ -227,6 +250,7 @@ JS; | @@ -227,6 +250,7 @@ JS; | ||
| 227 | ], | 250 | ], |
| 228 | 'pageSummary' => false, | 251 | 'pageSummary' => false, |
| 229 | ], | 252 | ], |
| 253 | + 'sum_cost', | ||
| 230 | [ | 254 | [ |
| 231 | 'class' => 'yii\grid\ActionColumn', | 255 | 'class' => 'yii\grid\ActionColumn', |
| 232 | 'template' => '{delete}', | 256 | 'template' => '{delete}', |
| @@ -316,3 +340,42 @@ JS; | @@ -316,3 +340,42 @@ JS; | ||
| 316 | <?php ActiveForm::end(); ?> | 340 | <?php ActiveForm::end(); ?> |
| 317 | </div> | 341 | </div> |
| 318 | </div> | 342 | </div> |
| 343 | +<br> | ||
| 344 | +<br> | ||
| 345 | +<br> | ||
| 346 | +<br> | ||
| 347 | +<br> | ||
| 348 | +<div class="container"> | ||
| 349 | + <div class="row"> | ||
| 350 | + <?php | ||
| 351 | + echo Select2::widget( | ||
| 352 | + [ | ||
| 353 | + 'id' => 'sms-template-selector', | ||
| 354 | + 'name' => 'select-sms-template', | ||
| 355 | + 'data' => ArrayHelper::map( | ||
| 356 | + SmsTemplate::find() | ||
| 357 | + ->asArray() | ||
| 358 | + ->all(), | ||
| 359 | + 'text', | ||
| 360 | + 'title' | ||
| 361 | + ), | ||
| 362 | + 'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ], | ||
| 363 | + 'pluginOptions' => [ | ||
| 364 | + 'allowClear' => true, | ||
| 365 | + ], | ||
| 366 | + ] | ||
| 367 | + ); | ||
| 368 | + | ||
| 369 | + ?> | ||
| 370 | + | ||
| 371 | + <?php | ||
| 372 | + echo Html::textarea( | ||
| 373 | + 'sms-text', | ||
| 374 | + '', | ||
| 375 | + [ | ||
| 376 | + 'rows' => 5, | ||
| 377 | + ] | ||
| 378 | + ); | ||
| 379 | + ?> | ||
| 380 | + </div> | ||
| 381 | +</div> |
views/order/index.php
| @@ -9,15 +9,19 @@ | @@ -9,15 +9,19 @@ | ||
| 9 | use artweb\artbox\ecommerce\models\Label; | 9 | use artweb\artbox\ecommerce\models\Label; |
| 10 | use artweb\artbox\ecommerce\models\Order; | 10 | use artweb\artbox\ecommerce\models\Order; |
| 11 | use artweb\artbox\ecommerce\models\OrderSearch; | 11 | use artweb\artbox\ecommerce\models\OrderSearch; |
| 12 | + use common\models\User; | ||
| 12 | use kartik\daterange\DateRangePicker; | 13 | use kartik\daterange\DateRangePicker; |
| 13 | use kartik\select2\Select2; | 14 | use kartik\select2\Select2; |
| 14 | use yii\data\ActiveDataProvider; | 15 | use yii\data\ActiveDataProvider; |
| 16 | + use yii\helpers\ArrayHelper; | ||
| 15 | use yii\helpers\Html; | 17 | use yii\helpers\Html; |
| 16 | use kartik\grid\GridView; | 18 | use kartik\grid\GridView; |
| 17 | use yii\helpers\StringHelper; | 19 | use yii\helpers\StringHelper; |
| 18 | use yii\helpers\Url; | 20 | use yii\helpers\Url; |
| 21 | + use yii\web\JsExpression; | ||
| 19 | use yii\web\View; | 22 | use yii\web\View; |
| 20 | use yii\widgets\ActiveForm; | 23 | use yii\widgets\ActiveForm; |
| 24 | + use yii\widgets\Pjax; | ||
| 21 | 25 | ||
| 22 | $this->title = 'Заказы'; | 26 | $this->title = 'Заказы'; |
| 23 | $this->params[ 'breadcrumbs' ][] = $this->title; | 27 | $this->params[ 'breadcrumbs' ][] = $this->title; |
| @@ -34,7 +38,7 @@ JS; | @@ -34,7 +38,7 @@ JS; | ||
| 34 | <p> | 38 | <p> |
| 35 | <?= Html::a('Add order', [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | 39 | <?= Html::a('Add order', [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> |
| 36 | </p> | 40 | </p> |
| 37 | - | 41 | +<?php Pjax::begin(); ?> |
| 38 | <?php | 42 | <?php |
| 39 | $searchForm = ActiveForm::begin( | 43 | $searchForm = ActiveForm::begin( |
| 40 | [ | 44 | [ |
| @@ -57,49 +61,113 @@ JS; | @@ -57,49 +61,113 @@ JS; | ||
| 57 | </p> | 61 | </p> |
| 58 | 62 | ||
| 59 | <?php | 63 | <?php |
| 60 | - echo Select2::widget( | ||
| 61 | - [ | ||
| 62 | - 'model' => $searchModel, | ||
| 63 | - 'attribute' => 'label', | ||
| 64 | - 'data' => Label::find() | ||
| 65 | - ->joinWith('lang') | ||
| 66 | - ->select( | ||
| 67 | - [ | ||
| 68 | - 'CONCAT(order_label.label,order_label_lang.title) AS name', | ||
| 69 | - 'id', | ||
| 70 | - ] | ||
| 71 | - ) | ||
| 72 | - ->indexBy('id') | ||
| 73 | - ->asArray() | ||
| 74 | - ->column(), | ||
| 75 | - 'options' => [ 'placeholder' => 'Select a state ...' ], | ||
| 76 | - 'pluginOptions' => [ | ||
| 77 | - 'allowClear' => true, | ||
| 78 | - 'multiple' => true, | ||
| 79 | - ], | ||
| 80 | - ] | ||
| 81 | - ); | 64 | + echo $searchForm->field($searchModel, 'label') |
| 65 | + ->widget( | ||
| 66 | + Select2::className(), | ||
| 67 | + [ | ||
| 68 | + 'data' => Label::find() | ||
| 69 | + ->joinWith('lang') | ||
| 70 | + ->select( | ||
| 71 | + [ | ||
| 72 | + 'CONCAT(order_label.label,order_label_lang.title) AS name', | ||
| 73 | + 'id', | ||
| 74 | + ] | ||
| 75 | + ) | ||
| 76 | + ->indexBy('id') | ||
| 77 | + ->asArray() | ||
| 78 | + ->column(), | ||
| 79 | + 'options' => [ 'placeholder' => 'Select a state ...' ], | ||
| 80 | + 'pluginOptions' => [ | ||
| 81 | + 'allowClear' => true, | ||
| 82 | + 'multiple' => true, | ||
| 83 | + ], | ||
| 84 | + ] | ||
| 85 | + ); | ||
| 82 | ?> | 86 | ?> |
| 83 | <br> | 87 | <br> |
| 84 | <?php | 88 | <?php |
| 85 | - echo Select2::widget( | ||
| 86 | - [ | ||
| 87 | - 'model' => $searchModel, | ||
| 88 | - 'attribute' => 'delivery', | ||
| 89 | - 'data' => Delivery::find() | ||
| 90 | - ->joinWith('lang') | ||
| 91 | - ->select('order_delivery_lang.title, id') | ||
| 92 | - ->indexBy('id') | ||
| 93 | - ->asArray() | ||
| 94 | - ->column(), | ||
| 95 | - 'options' => [ 'placeholder' => 'Select a state ...' ], | ||
| 96 | - 'pluginOptions' => [ | ||
| 97 | - 'allowClear' => true, | ||
| 98 | - 'multiple' => true, | ||
| 99 | - ], | ||
| 100 | - ] | ||
| 101 | - ); | 89 | + echo $searchForm->field($searchModel, 'delivery') |
| 90 | + ->widget( | ||
| 91 | + Select2::className(), | ||
| 92 | + [ | ||
| 93 | + 'data' => Delivery::find() | ||
| 94 | + ->joinWith('lang') | ||
| 95 | + ->select('order_delivery_lang.title, id') | ||
| 96 | + ->indexBy('id') | ||
| 97 | + ->asArray() | ||
| 98 | + ->column(), | ||
| 99 | + 'options' => [ 'placeholder' => 'Select a state ...' ], | ||
| 100 | + 'pluginOptions' => [ | ||
| 101 | + 'allowClear' => true, | ||
| 102 | + 'multiple' => true, | ||
| 103 | + ], | ||
| 104 | + ] | ||
| 105 | + ); | ||
| 106 | +?> | ||
| 107 | + | ||
| 108 | +<?php echo $searchForm->field($searchModel, 'sku') | ||
| 109 | + ->widget( | ||
| 110 | + Select2::className(), | ||
| 111 | + [ | ||
| 112 | + 'options' => [ 'placeholder' => 'Search for a product ...' ], | ||
| 113 | + 'pluginOptions' => [ | ||
| 114 | + 'allowClear' => true, | ||
| 115 | + 'minimumInputLength' => 3, | ||
| 116 | + 'language' => [ | ||
| 117 | + 'errorLoading' => new JsExpression( | ||
| 118 | + "function () { return 'Waiting for results...'; }" | ||
| 119 | + ), | ||
| 120 | + ], | ||
| 121 | + 'ajax' => [ | ||
| 122 | + 'url' => \yii\helpers\Url::to([ 'find-product' ]), | ||
| 123 | + 'dataType' => 'json', | ||
| 124 | + 'data' => new JsExpression( | ||
| 125 | + 'function(params) { return {q:params.term}; }' | ||
| 126 | + ), | ||
| 127 | + ], | ||
| 128 | + 'escapeMarkup' => new JsExpression( | ||
| 129 | + 'function (markup) { return markup; }' | ||
| 130 | + ), | ||
| 131 | + 'templateResult' => new JsExpression( | ||
| 132 | + 'function(data) { return data.sku; }' | ||
| 133 | + ), | ||
| 134 | + 'templateSelection' => new JsExpression( | ||
| 135 | + 'function (data) { | ||
| 136 | + if(data.sku == undefined) { | ||
| 137 | + return "sku"; | ||
| 138 | + } else { | ||
| 139 | + return data.sku; | ||
| 140 | + } | ||
| 141 | + }' | ||
| 142 | + ), | ||
| 143 | + ], | ||
| 144 | + ] | ||
| 145 | + ); | ||
| 146 | + | ||
| 102 | ?> | 147 | ?> |
| 148 | + | ||
| 149 | +<?= $searchForm->field($searchModel, 'manager_id') | ||
| 150 | + ->dropDownList( | ||
| 151 | + ArrayHelper::map( | ||
| 152 | + User::find() | ||
| 153 | + ->asArray() | ||
| 154 | + ->all(), | ||
| 155 | + 'id', | ||
| 156 | + 'username' | ||
| 157 | + ), | ||
| 158 | + [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ] | ||
| 159 | + ) ?> | ||
| 160 | + | ||
| 161 | +<?= $searchForm->field($searchModel, 'email') | ||
| 162 | + ->textInput() ?> | ||
| 163 | + | ||
| 164 | +<?= $searchForm->field($searchModel, 'declaration') | ||
| 165 | + ->textInput() ?> | ||
| 166 | + | ||
| 167 | +<?= $searchForm->field($searchModel, 'consignment') | ||
| 168 | + ->textInput() ?> | ||
| 169 | + | ||
| 170 | + | ||
| 103 | <p> | 171 | <p> |
| 104 | <?php | 172 | <?php |
| 105 | echo GridView::widget( | 173 | echo GridView::widget( |
| @@ -141,13 +209,13 @@ JS; | @@ -141,13 +209,13 @@ JS; | ||
| 141 | ], | 209 | ], |
| 142 | [ | 210 | [ |
| 143 | 'attribute' => 'deadline', | 211 | 'attribute' => 'deadline', |
| 144 | - 'content' => function($model) { | ||
| 145 | - if ($model->deadline == ''){ | 212 | + 'content' => function($model) { |
| 213 | + if ($model->deadline == '') { | ||
| 146 | return ''; | 214 | return ''; |
| 147 | } else { | 215 | } else { |
| 148 | return \Yii::$app->formatter->asDate($model->deadline); | 216 | return \Yii::$app->formatter->asDate($model->deadline); |
| 149 | } | 217 | } |
| 150 | - } | 218 | + }, |
| 151 | ], | 219 | ], |
| 152 | 'name', | 220 | 'name', |
| 153 | 'total', | 221 | 'total', |
| @@ -165,6 +233,7 @@ JS; | @@ -165,6 +233,7 @@ JS; | ||
| 165 | 'adress', | 233 | 'adress', |
| 166 | [ | 234 | [ |
| 167 | 'attribute' => 'label', | 235 | 'attribute' => 'label', |
| 236 | + 'filter' => false, | ||
| 168 | 'value' => function($model) { | 237 | 'value' => function($model) { |
| 169 | /** | 238 | /** |
| 170 | * @var Order $modl | 239 | * @var Order $modl |
| @@ -199,3 +268,4 @@ JS; | @@ -199,3 +268,4 @@ JS; | ||
| 199 | <?php | 268 | <?php |
| 200 | ActiveForm::end(); | 269 | ActiveForm::end(); |
| 201 | ?> | 270 | ?> |
| 271 | +<?php Pjax::end(); ?> |