Commit 287e356df186852b79de35342dd66090986827a0
1 parent
2ccf4bd2
-Permissions ready - test
Showing
6 changed files
with
781 additions
and
659 deletions
Show diff stats
controllers/OrderController.php
| ... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | use artweb\artbox\ecommerce\models\OrderLabelHistory; |
| 7 | 7 | use artweb\artbox\ecommerce\models\OrderSearch; |
| 8 | 8 | use common\components\CreditHelper; |
| 9 | + use common\models\Permissions; | |
| 9 | 10 | use common\models\User; |
| 10 | 11 | use Yii; |
| 11 | 12 | use yii\data\ArrayDataProvider; |
| ... | ... | @@ -57,7 +58,12 @@ |
| 57 | 58 | |
| 58 | 59 | public function actionIndex() |
| 59 | 60 | { |
| 61 | + /** | |
| 62 | + * @var Permissions $permissions | |
| 63 | + */ | |
| 64 | + $permissions = \Yii::$app->user->identity->permissions; | |
| 60 | 65 | $searchModel = new OrderSearch(); |
| 66 | + $searchModel->permissions = $permissions; | |
| 61 | 67 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
| 62 | 68 | |
| 63 | 69 | return $this->render( |
| ... | ... | @@ -65,6 +71,8 @@ |
| 65 | 71 | [ |
| 66 | 72 | 'dataProvider' => $dataProvider, |
| 67 | 73 | 'searchModel' => $searchModel, |
| 74 | + 'allowedLabels' => empty($permissions) ? [] : $permissions->labelsArray, | |
| 75 | + 'canCreate' => empty($permissions) ? false : $permissions->create, | |
| 68 | 76 | ] |
| 69 | 77 | ); |
| 70 | 78 | } |
| ... | ... | @@ -247,6 +255,19 @@ |
| 247 | 255 | |
| 248 | 256 | public function actionCreate() |
| 249 | 257 | { |
| 258 | + /** | |
| 259 | + * @var Permissions $permissions | |
| 260 | + */ | |
| 261 | + $permissions = \Yii::$app->user->identity->permissions; | |
| 262 | + | |
| 263 | + if (empty($permissions)) { | |
| 264 | + throw new ForbiddenHttpException(); | |
| 265 | + } else { | |
| 266 | + if (!$permissions->create) { | |
| 267 | + throw new ForbiddenHttpException(); | |
| 268 | + } | |
| 269 | + } | |
| 270 | + | |
| 250 | 271 | if (\Yii::$app->request->post('hasEditable')) { |
| 251 | 272 | $orderProductId = \Yii::$app->request->post('editableKey'); |
| 252 | 273 | $orderProduct = OrderProduct::findOne($orderProductId); |
| ... | ... | @@ -388,6 +409,14 @@ |
| 388 | 409 | throw new ForbiddenHttpException(); |
| 389 | 410 | } |
| 390 | 411 | } |
| 412 | + if (!empty($user->permissions)) { | |
| 413 | + $permissions = $user->permissions; | |
| 414 | + if (!in_array($model->label, $user->permissions->labelsArray)) { | |
| 415 | + throw new ForbiddenHttpException(); | |
| 416 | + } | |
| 417 | + } else { | |
| 418 | + $permissions = Permissions::getDefault(); | |
| 419 | + } | |
| 391 | 420 | |
| 392 | 421 | $dataProvider = new ActiveDataProvider( |
| 393 | 422 | [ |
| ... | ... | @@ -432,6 +461,7 @@ |
| 432 | 461 | [ |
| 433 | 462 | 'model' => $model, |
| 434 | 463 | 'dataProvider' => $dataProvider, |
| 464 | + 'permissions' => $permissions, | |
| 435 | 465 | ] |
| 436 | 466 | ); |
| 437 | 467 | } else { |
| ... | ... | @@ -440,6 +470,7 @@ |
| 440 | 470 | [ |
| 441 | 471 | 'model' => $model, |
| 442 | 472 | 'dataProvider' => $dataProvider, |
| 473 | + 'permissions' => $permissions, | |
| 443 | 474 | ] |
| 444 | 475 | ); |
| 445 | 476 | } | ... | ... |
models/Order.php
| ... | ... | @@ -336,39 +336,38 @@ |
| 336 | 336 | public static function attributeNames() |
| 337 | 337 | { |
| 338 | 338 | return [ |
| 339 | - 'name' => Yii::t('app', 'order_name'), | |
| 340 | - 'phone' => Yii::t('app', 'order_phone'), | |
| 341 | - 'phone2' => Yii::t('app', 'Конактный телефон 2'), | |
| 342 | - 'email' => Yii::t('app', 'E-mail'), | |
| 343 | - 'comment' => Yii::t('app', 'Комментарий '), | |
| 344 | - 'created_at' => Yii::t('app', 'Дата добавления'), | |
| 345 | - 'updated_at' => Yii::t('app', 'Дата обновления'), | |
| 346 | - 'deleted_at' => Yii::t('app', 'Дата удаления'), | |
| 347 | - 'deadline' => Yii::t('app', 'Дедлайн'), | |
| 348 | - 'reason' => Yii::t('app', 'Причина'), | |
| 349 | - 'check' => Yii::t('app', 'Чек'), | |
| 350 | - 'sms' => Yii::t('app', 'СМС'), | |
| 351 | - 'consignment' => Yii::t('app', 'Номер накладной'), | |
| 352 | - 'manager_id' => Yii::t('app', 'Менеджер'), | |
| 353 | - 'delivery_cost' => Yii::t('app', 'Стоимость доставки'), | |
| 354 | - 'published' => Yii::t('app', 'Опубликован'), | |
| 355 | - 'label' => Yii::t('app', 'Метка'), | |
| 356 | - 'declaration' => Yii::t('app', 'Номер декларации'), | |
| 357 | - 'delivery' => Yii::t('app', 'Способ доставки'), | |
| 358 | - 'total' => Yii::t('app', 'Сумма'), | |
| 359 | - 'adress' => Yii::t('app', 'Адрес'), | |
| 360 | - 'pay' => Yii::t('app', 'Оплата'), | |
| 361 | - 'body' => Yii::t('app', 'Комментарий менеджера'), | |
| 362 | - 'id' => Yii::t('app', 'Номер'), | |
| 363 | - 'stock' => Yii::t('app', 'Номер склада'), | |
| 364 | - 'payment' => Yii::t('app', 'Способ оплаты'), | |
| 365 | - 'insurance' => Yii::t('app', 'Страховка'), | |
| 366 | - 'amount_imposed' => Yii::t('app', 'Сумма наложенного'), | |
| 367 | - 'shipping_by' => Yii::t('app', 'Отправка за счет'), | |
| 368 | - 'city' => Yii::t('app', 'Город'), | |
| 369 | - 'numbercard' => Yii::t('app', '№ карточки'), | |
| 370 | - 'credit_month' => Yii::t('app', 'Количество месяцев'), | |
| 371 | - 'credit_sum' => Yii::t('app', 'Первоначальный взнос'), | |
| 339 | + 'name' => Yii::t('app', 'order_name'), | |
| 340 | + 'phone' => Yii::t('app', 'order_phone'), | |
| 341 | + 'phone2' => Yii::t('app', 'Конактный телефон 2'), | |
| 342 | + 'email' => Yii::t('app', 'E-mail'), | |
| 343 | + 'comment' => Yii::t('app', 'Комментарий '), | |
| 344 | + 'deadline' => Yii::t('app', 'Дедлайн'), | |
| 345 | + 'reason' => Yii::t('app', 'Причина'), | |
| 346 | + 'check' => Yii::t('app', 'Чек'), | |
| 347 | + 'sms' => Yii::t('app', 'СМС'), | |
| 348 | + 'consignment' => Yii::t('app', 'Номер накладной'), | |
| 349 | + 'manager_id' => Yii::t('app', 'Менеджер'), | |
| 350 | + 'delivery_cost' => Yii::t('app', 'Стоимость доставки'), | |
| 351 | + 'label' => Yii::t('app', 'Метка'), | |
| 352 | + 'declaration' => Yii::t('app', 'Номер декларации'), | |
| 353 | + 'delivery' => Yii::t('app', 'Способ доставки'), | |
| 354 | + 'adress' => Yii::t('app', 'Адрес'), | |
| 355 | + 'pay' => Yii::t('app', 'Оплата'), | |
| 356 | + 'body' => Yii::t('app', 'Комментарий менеджера'), | |
| 357 | + 'stock' => Yii::t('app', 'Номер склада'), | |
| 358 | + 'payment' => Yii::t('app', 'Способ оплаты'), | |
| 359 | + 'insurance' => Yii::t('app', 'Страховка'), | |
| 360 | + 'amount_imposed' => Yii::t('app', 'Сумма наложенного'), | |
| 361 | + 'shipping_by' => Yii::t('app', 'Отправка за счет'), | |
| 362 | + 'city' => Yii::t('app', 'Город'), | |
| 363 | + 'numbercard' => Yii::t('app', '№ карточки'), | |
| 364 | + 'send_sms' => Yii::t('app', 'Отправлять смс'), | |
| 365 | + 'product_booking' => Yii::t('app', 'Бронь товара'), | |
| 366 | + 'product_status' => Yii::t('app', 'Статус товара'), | |
| 367 | + 'product_return' => Yii::t('app', 'Возврат товара'), | |
| 368 | + 'add_product' => Yii::t('app', 'Добавить товар'), | |
| 369 | + 'delete_product' => Yii::t('app', 'Удалить товар'), | |
| 370 | + 'product_count' => Yii::t('app', 'Количество товара'), | |
| 372 | 371 | ]; |
| 373 | 372 | } |
| 374 | 373 | |
| ... | ... | @@ -443,7 +442,7 @@ |
| 443 | 442 | { |
| 444 | 443 | return $this->hasMany(OrderLog::className(), [ 'order_id' => 'id' ]); |
| 445 | 444 | } |
| 446 | - | |
| 445 | + | |
| 447 | 446 | /** |
| 448 | 447 | * @return \yii\db\ActiveQuery |
| 449 | 448 | */ | ... | ... |
models/OrderSearch.php
| ... | ... | @@ -2,13 +2,15 @@ |
| 2 | 2 | |
| 3 | 3 | namespace artweb\artbox\ecommerce\models; |
| 4 | 4 | |
| 5 | + use common\models\Permissions; | |
| 5 | 6 | use yii\base\Model; |
| 6 | 7 | use yii\data\ActiveDataProvider; |
| 7 | 8 | use yii\helpers\ArrayHelper; |
| 8 | - use yii\helpers\VarDumper; | |
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * OrderSearch represents the model behind the search form about `\artweb\artbox\ecommerce\models\Order`. |
| 12 | + * | |
| 13 | + * @property Permissions $permissions | |
| 12 | 14 | */ |
| 13 | 15 | class OrderSearch extends Order |
| 14 | 16 | { |
| ... | ... | @@ -17,6 +19,8 @@ |
| 17 | 19 | public $date_range; |
| 18 | 20 | public $sku; |
| 19 | 21 | |
| 22 | + public $permissions; | |
| 23 | + | |
| 20 | 24 | /** |
| 21 | 25 | * @inheritdoc |
| 22 | 26 | */ |
| ... | ... | @@ -160,6 +164,14 @@ |
| 160 | 164 | $this->declaration, |
| 161 | 165 | ] |
| 162 | 166 | ); |
| 167 | + | |
| 168 | + if (!empty($this->permissions)) | |
| 169 | + { | |
| 170 | + $query->andFilterWhere([ | |
| 171 | + 'label' => $this->permissions->labelsArray, | |
| 172 | + ]); | |
| 173 | + } | |
| 174 | + | |
| 163 | 175 | $query->andFilterWhere( |
| 164 | 176 | [ |
| 165 | 177 | 'label' => $this->label, | ... | ... |
views/order/_form.php
| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | use artweb\artbox\ecommerce\models\OrderPayment; |
| 6 | 6 | use artweb\artbox\ecommerce\models\OrderProduct; |
| 7 | 7 | use backend\models\SmsTemplate; |
| 8 | + use common\models\Permissions; | |
| 8 | 9 | use common\models\User; |
| 9 | 10 | use kartik\grid\GridView; |
| 10 | 11 | use kartik\grid\SerialColumn; |
| ... | ... | @@ -27,6 +28,7 @@ |
| 27 | 28 | * @var ActiveForm $form |
| 28 | 29 | * @var ActiveDataProvider $dataProvider |
| 29 | 30 | * @var User $user |
| 31 | + * @var Permissions $permissions | |
| 30 | 32 | */ |
| 31 | 33 | |
| 32 | 34 | $user = \Yii::$app->user->identity; |
| ... | ... | @@ -160,231 +162,266 @@ JS; |
| 160 | 162 | </div> |
| 161 | 163 | </div> |
| 162 | 164 | <div class="box-body"> |
| 163 | - | |
| 164 | - | |
| 165 | -<div class="container"> | |
| 166 | - <div class="form-group"> | |
| 167 | - <br> | |
| 168 | 165 | |
| 169 | 166 | |
| 170 | - | |
| 171 | - <div class="row"> | |
| 172 | - <div class="col-sm-6"> | |
| 173 | - | |
| 174 | - <?= $form->field($model, 'deadline') | |
| 175 | - ->widget( | |
| 176 | - DatePicker::className(), | |
| 177 | - [ | |
| 178 | - | |
| 179 | - ] | |
| 180 | - ) ?> | |
| 181 | - | |
| 182 | - <?php | |
| 183 | - if ($user->isAdmin()) { | |
| 184 | - echo $form->field($model, 'pay') | |
| 185 | - ->widget( | |
| 186 | - SwitchInput::className(), | |
| 187 | - [ | |
| 188 | - 'name' => 'pay', | |
| 189 | - 'pluginOptions' => [ | |
| 190 | - 'onText' => \Yii::t('app', 'Оплачено'), | |
| 191 | - 'offText' => \Yii::t('app', 'Не оплачено'), | |
| 192 | - ], | |
| 193 | - ] | |
| 194 | - ); | |
| 195 | - } | |
| 196 | - ?> | |
| 197 | - | |
| 198 | - <?= $form->field($model, 'reason') | |
| 199 | - ->dropDownList( | |
| 200 | - Order::REASONS, | |
| 201 | - [ 'prompt' => 'Выберите причину' ] | |
| 202 | - ) ?> | |
| 203 | - | |
| 204 | - <?= $form->field($model, 'label') | |
| 205 | - ->dropDownList( | |
| 206 | - ArrayHelper::map( | |
| 207 | - Label::find() | |
| 208 | - ->asArray() | |
| 209 | - ->all(), | |
| 210 | - 'id', | |
| 211 | - 'label' | |
| 212 | - ), | |
| 213 | - [ 'prompt' => 'Выберите метку' ] | |
| 214 | - ); ?> | |
| 215 | - | |
| 216 | - <?= $form->field($model, 'name') ?> | |
| 217 | - | |
| 218 | - <?= $form->field($model, 'phone') ?> | |
| 219 | - | |
| 220 | - <?= $form->field($model, 'phone2') ?> | |
| 221 | - | |
| 222 | - <?= $form->field($model, 'email') | |
| 223 | - ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?> | |
| 224 | - | |
| 225 | - <?= $form->field( | |
| 226 | - $model, | |
| 227 | - 'numbercard' | |
| 228 | - ) | |
| 229 | - ->textInput([ 'readonly' => true ]) ?> | |
| 230 | - | |
| 231 | - <?= $form->field($model, 'comment') | |
| 232 | - ->textarea([ 'rows' => '3' ]) ?> | |
| 233 | - <?= $form->field($model, 'delivery') | |
| 234 | - ->dropDownList( | |
| 235 | - ArrayHelper::map( | |
| 236 | - Delivery::find() | |
| 237 | - ->joinWith('lang') | |
| 238 | - ->asArray() | |
| 239 | - ->all(), | |
| 240 | - 'id', | |
| 241 | - 'lang.title' | |
| 242 | - ), | |
| 243 | - [ 'prompt' => \Yii::t('app', 'Выберите доставку ...') ] | |
| 244 | - ) ?> | |
| 245 | - | |
| 246 | - <?php | |
| 247 | - | |
| 248 | - if ($user->isAdmin()) { | |
| 249 | - echo $form->field($model, 'manager_id') | |
| 250 | - ->dropDownList( | |
| 251 | - ArrayHelper::map( | |
| 252 | - User::find() | |
| 253 | - ->asArray() | |
| 254 | - ->all(), | |
| 255 | - 'id', | |
| 256 | - 'username' | |
| 257 | - ), | |
| 258 | - [ 'prompt' => \Yii::t('app', 'Менеджер') ] | |
| 259 | - ); | |
| 260 | - } | |
| 261 | - ?> | |
| 262 | - | |
| 263 | - <h2><?php echo \Yii::t('app', 'Отправить смс'); ?></h2> | |
| 264 | - <?php | |
| 265 | - echo Select2::widget( | |
| 266 | - [ | |
| 267 | - 'id' => 'sms-template-selector', | |
| 268 | - 'name' => 'select-sms-template', | |
| 269 | - 'data' => ArrayHelper::map( | |
| 270 | - SmsTemplate::find() | |
| 271 | - ->asArray() | |
| 272 | - ->all(), | |
| 273 | - 'text', | |
| 274 | - 'title' | |
| 275 | - ), | |
| 276 | - 'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ], | |
| 277 | - 'pluginOptions' => [ | |
| 278 | - 'allowClear' => true, | |
| 279 | - ], | |
| 280 | - ] | |
| 281 | - ); | |
| 282 | - | |
| 283 | - ?> | |
| 284 | - <br> | |
| 285 | - <?php | |
| 286 | - echo Html::textarea( | |
| 287 | - 'sms-text', | |
| 288 | - '', | |
| 289 | - [ | |
| 290 | - 'rows' => 3, | |
| 291 | - 'id' => 'sms-text-area', | |
| 292 | - 'class' => 'form-control', | |
| 293 | - ] | |
| 294 | - ); | |
| 295 | - ?> | |
| 167 | + <div class="container"> | |
| 168 | + <div class="form-group"> | |
| 296 | 169 | <br> |
| 170 | + | |
| 171 | + | |
| 297 | 172 | <div class="row"> |
| 298 | - <div class="col-md-6"> | |
| 173 | + <div class="col-sm-6"> | |
| 174 | + | |
| 175 | + <?= $form->field($model, 'deadline') | |
| 176 | + ->widget( | |
| 177 | + DatePicker::className(), | |
| 178 | + [ | |
| 179 | + 'disabled' => !$permissions->checkAttr('deadline'), | |
| 180 | + ] | |
| 181 | + ) ?> | |
| 182 | + | |
| 299 | 183 | <?php |
| 300 | - if ($model->isNewRecord) { | |
| 301 | - echo Html::button( | |
| 302 | - \Yii::t('app', 'Отправить'), | |
| 303 | - [ | |
| 304 | - 'class' => 'btn btn-warning disabled', | |
| 305 | - ] | |
| 306 | - ); | |
| 307 | - } else { | |
| 308 | - echo Html::button( | |
| 309 | - \Yii::t('app', 'Отправить'), | |
| 310 | - [ | |
| 311 | - 'class' => 'btn btn-warning', | |
| 312 | - 'id' => 'send-sms-action', | |
| 313 | - ] | |
| 314 | - ); | |
| 184 | + if ($permissions->checkAttr('pay')) { | |
| 185 | + echo $form->field($model, 'pay') | |
| 186 | + ->widget( | |
| 187 | + SwitchInput::className(), | |
| 188 | + [ | |
| 189 | + 'name' => 'pay', | |
| 190 | + 'pluginOptions' => [ | |
| 191 | + 'onText' => \Yii::t('app', 'Оплачено'), | |
| 192 | + 'offText' => \Yii::t('app', 'Не оплачено'), | |
| 193 | + ], | |
| 194 | + ] | |
| 195 | + ); | |
| 315 | 196 | } |
| 316 | 197 | ?> |
| 317 | - </div> | |
| 318 | - <div class="col-md-6"> | |
| 198 | + | |
| 199 | + <?= $form->field($model, 'reason') | |
| 200 | + ->dropDownList( | |
| 201 | + Order::REASONS, | |
| 202 | + [ | |
| 203 | + 'prompt' => 'Выберите причину', | |
| 204 | + 'disabled' => !$permissions->checkAttr('reason'), | |
| 205 | + ] | |
| 206 | + ) ?> | |
| 207 | + | |
| 208 | + <?= $form->field($model, 'label') | |
| 209 | + ->dropDownList( | |
| 210 | + ArrayHelper::map( | |
| 211 | + Label::find() | |
| 212 | + ->asArray() | |
| 213 | + ->all(), | |
| 214 | + 'id', | |
| 215 | + 'label' | |
| 216 | + ), | |
| 217 | + [ | |
| 218 | + 'prompt' => 'Выберите метку', | |
| 219 | + 'disabled' => !$permissions->checkAttr('label'), | |
| 220 | + ] | |
| 221 | + ); ?> | |
| 222 | + | |
| 223 | + <?= $form->field($model, 'name') | |
| 224 | + ->textInput([ 'readonly' => !$permissions->checkAttr('name') ]) ?> | |
| 225 | + | |
| 226 | + <?= $form->field($model, 'phone') | |
| 227 | + ->textInput([ 'readonly' => !$permissions->checkAttr('phone') ]) ?> | |
| 228 | + | |
| 229 | + <?= $form->field($model, 'phone2') | |
| 230 | + ->textInput([ 'readonly' => !$permissions->checkAttr('phone2') ]) ?> | |
| 231 | + | |
| 232 | + <?= $form->field($model, 'email') | |
| 233 | + ->textInput([ 'readonly' => !$permissions->checkAttr('email') ]) ?> | |
| 234 | + | |
| 235 | + <?= $form->field( | |
| 236 | + $model, | |
| 237 | + 'numbercard' | |
| 238 | + ) | |
| 239 | + ->textInput([ 'readonly' => !$permissions->checkAttr('numbercard') ]) ?> | |
| 240 | + | |
| 241 | + <?= $form->field($model, 'comment') | |
| 242 | + ->textarea( | |
| 243 | + [ | |
| 244 | + 'rows' => '3', | |
| 245 | + 'readonly' => !$permissions->checkAttr('comment'), | |
| 246 | + ] | |
| 247 | + ) ?> | |
| 248 | + <?= $form->field($model, 'delivery') | |
| 249 | + ->dropDownList( | |
| 250 | + ArrayHelper::map( | |
| 251 | + Delivery::find() | |
| 252 | + ->joinWith('lang') | |
| 253 | + ->asArray() | |
| 254 | + ->all(), | |
| 255 | + 'id', | |
| 256 | + 'lang.title' | |
| 257 | + ), | |
| 258 | + [ | |
| 259 | + 'prompt' => \Yii::t('app', 'Выберите доставку ...'), | |
| 260 | + 'disabled' => !$permissions->checkAttr('delivery'), | |
| 261 | + ] | |
| 262 | + ) ?> | |
| 263 | + | |
| 264 | + <?php | |
| 265 | + | |
| 266 | + if (!$permissions->checkAttr('manager_id')) { | |
| 267 | + echo $form->field($model, 'manager_id') | |
| 268 | + ->dropDownList( | |
| 269 | + ArrayHelper::map( | |
| 270 | + User::find() | |
| 271 | + ->asArray() | |
| 272 | + ->all(), | |
| 273 | + 'id', | |
| 274 | + 'username' | |
| 275 | + ), | |
| 276 | + [ 'prompt' => \Yii::t('app', 'Менеджер') ] | |
| 277 | + ); | |
| 278 | + } | |
| 279 | + ?> | |
| 280 | + | |
| 281 | + <h2><?php echo \Yii::t('app', 'Отправить смс'); ?></h2> | |
| 282 | + <?php | |
| 283 | + echo Select2::widget( | |
| 284 | + [ | |
| 285 | + 'id' => 'sms-template-selector', | |
| 286 | + 'name' => 'select-sms-template', | |
| 287 | + 'data' => ArrayHelper::map( | |
| 288 | + SmsTemplate::find() | |
| 289 | + ->asArray() | |
| 290 | + ->all(), | |
| 291 | + 'text', | |
| 292 | + 'title' | |
| 293 | + ), | |
| 294 | + 'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ], | |
| 295 | + 'pluginOptions' => [ | |
| 296 | + 'allowClear' => true, | |
| 297 | + ], | |
| 298 | + ] | |
| 299 | + ); | |
| 300 | + | |
| 301 | + ?> | |
| 302 | + <br> | |
| 319 | 303 | <?php |
| 320 | - echo Html::radioList( | |
| 321 | - 'send-phone', | |
| 322 | - '1', | |
| 304 | + echo Html::textarea( | |
| 305 | + 'sms-text', | |
| 306 | + '', | |
| 323 | 307 | [ |
| 324 | - '1' => 'Первый номер', | |
| 325 | - '2' => 'Второй номер', | |
| 308 | + 'rows' => 3, | |
| 309 | + 'id' => 'sms-text-area', | |
| 310 | + 'class' => 'form-control', | |
| 326 | 311 | ] |
| 327 | 312 | ); |
| 328 | 313 | ?> |
| 314 | + <br> | |
| 315 | + <div class="row"> | |
| 316 | + <div class="col-md-6"> | |
| 317 | + <?php | |
| 318 | + if (!$permissions->checkAttr('send_sms')) { | |
| 319 | + echo Html::button( | |
| 320 | + \Yii::t('app', 'Отправить'), | |
| 321 | + [ | |
| 322 | + 'class' => 'btn btn-warning disabled', | |
| 323 | + ] | |
| 324 | + ); | |
| 325 | + } else { | |
| 326 | + echo Html::button( | |
| 327 | + \Yii::t('app', 'Отправить'), | |
| 328 | + [ | |
| 329 | + 'class' => 'btn btn-warning', | |
| 330 | + 'id' => 'send-sms-action', | |
| 331 | + ] | |
| 332 | + ); | |
| 333 | + } | |
| 334 | + ?> | |
| 335 | + </div> | |
| 336 | + <div class="col-md-6"> | |
| 337 | + <?php | |
| 338 | + echo Html::radioList( | |
| 339 | + 'send-phone', | |
| 340 | + '1', | |
| 341 | + [ | |
| 342 | + '1' => 'Первый номер', | |
| 343 | + '2' => 'Второй номер', | |
| 344 | + ] | |
| 345 | + ); | |
| 346 | + ?> | |
| 347 | + </div> | |
| 348 | + </div> | |
| 349 | + | |
| 350 | + </div> | |
| 351 | + <div class="col-sm-6"> | |
| 352 | + | |
| 353 | + <?= $form->field($model, 'declaration') | |
| 354 | + ->textInput([ 'readonly' => !$permissions->checkAttr('declaration') ]) ?> | |
| 355 | + | |
| 356 | + <?= $form->field($model, 'stock') | |
| 357 | + ->textInput([ 'readonly' => !$permissions->checkAttr('stock') ]) ?> | |
| 358 | + | |
| 359 | + <?= $form->field($model, 'consignment') | |
| 360 | + ->textInput([ 'readonly' => !$permissions->checkAttr('consignment') ]) ?> | |
| 361 | + | |
| 362 | + <?= $form->field($model, 'payment') | |
| 363 | + ->dropDownList( | |
| 364 | + ArrayHelper::map( | |
| 365 | + OrderPayment::find() | |
| 366 | + ->where([ 'status' => OrderPayment::ACTIVE ]) | |
| 367 | + ->asArray() | |
| 368 | + ->all(), | |
| 369 | + 'id', | |
| 370 | + 'short' | |
| 371 | + ), | |
| 372 | + [ | |
| 373 | + 'prompt' => 'Способ оплаты ...', | |
| 374 | + 'disabled' => ( $model->payment == 10 || !$permissions->checkAttr( | |
| 375 | + 'payment' | |
| 376 | + ) ) ? 'disabled' : false, | |
| 377 | + ] | |
| 378 | + ); ?> | |
| 379 | + | |
| 380 | + <?= $form->field($model, 'insurance') | |
| 381 | + ->textInput([ 'readonly' => !$permissions->checkAttr('insurance') ]) ?> | |
| 382 | + | |
| 383 | + <?= $form->field($model, 'amount_imposed') | |
| 384 | + ->textInput([ 'readonly' => !$permissions->checkAttr('amount_imposed') ]) ?> | |
| 385 | + | |
| 386 | + <?= $form->field($model, 'shipping_by') | |
| 387 | + ->dropDownList( | |
| 388 | + ArrayHelper::getColumn(Order::SHIPPING_BY, 'label'), | |
| 389 | + [ | |
| 390 | + 'prompt' => 'Оплата доставки ...', | |
| 391 | + 'disabled' => !$permissions->checkAttr('shipping_by'), | |
| 392 | + ] | |
| 393 | + ); ?> | |
| 394 | + | |
| 395 | + <?= $form->field($model, 'city') | |
| 396 | + ->textInput([ 'readonly' => !$permissions->checkAttr('city') ]) ?> | |
| 397 | + | |
| 398 | + <?= $form->field($model, 'adress') | |
| 399 | + ->textInput([ 'readonly' => !$permissions->checkAttr('adress') ]) ?> | |
| 400 | + | |
| 401 | + <?= $form->field($model, 'body') | |
| 402 | + ->textarea( | |
| 403 | + [ | |
| 404 | + 'rows' => '3', | |
| 405 | + 'readonly' => !$permissions->checkAttr('body'), | |
| 406 | + ] | |
| 407 | + ) ?> | |
| 408 | + | |
| 409 | + <?= $form->field($model, 'check') | |
| 410 | + ->textInput([ 'readonly' => !$permissions->checkAttr('check') ]) ?> | |
| 411 | + | |
| 412 | + <?= $form->field($model, 'sms') | |
| 413 | + ->textInput([ 'readonly' => !$permissions->checkAttr('sms') ]) ?> | |
| 414 | + | |
| 415 | + <?= $form->field($model, 'delivery_cost') | |
| 416 | + ->textInput([ 'readonly' => !$permissions->checkAttr('delivery_cost') ]) ?> | |
| 417 | + | |
| 329 | 418 | </div> |
| 330 | 419 | </div> |
| 331 | 420 | |
| 332 | - </div> | |
| 333 | - <div class="col-sm-6"> | |
| 334 | - | |
| 335 | - <?= $form->field($model, 'declaration') ?> | |
| 336 | - | |
| 337 | - <?= $form->field($model, 'stock') ?> | |
| 338 | - | |
| 339 | - <?= $form->field($model, 'consignment') ?> | |
| 340 | - | |
| 341 | - <?= $form->field($model, 'payment') | |
| 342 | - ->dropDownList( | |
| 343 | - ArrayHelper::map( | |
| 344 | - OrderPayment::find() | |
| 345 | - ->where([ 'status' => OrderPayment::ACTIVE ]) | |
| 346 | - ->asArray() | |
| 347 | - ->all(), | |
| 348 | - 'id', | |
| 349 | - 'short' | |
| 350 | - ), | |
| 351 | - [ | |
| 352 | - 'prompt' => 'Способ оплаты ...', | |
| 353 | - 'disabled' => $model->payment == 10 ? 'disabled' : false, | |
| 354 | - ] | |
| 355 | - ); ?> | |
| 356 | - | |
| 357 | - <?= $form->field($model, 'insurance') ?> | |
| 358 | - | |
| 359 | - <?= $form->field($model, 'amount_imposed') ?> | |
| 360 | - | |
| 361 | - <?= $form->field($model, 'shipping_by') | |
| 362 | - ->dropDownList( | |
| 363 | - ArrayHelper::getColumn(Order::SHIPPING_BY, 'label'), | |
| 364 | - [ 'prompt' => 'Оплата доставки ...' ] | |
| 365 | - ); ?> | |
| 366 | - | |
| 367 | - <?= $form->field($model, 'city') ?> | |
| 368 | - | |
| 369 | - <?= $form->field($model, 'adress') ?> | |
| 370 | - | |
| 371 | - <?= $form->field($model, 'body') | |
| 372 | - ->textarea([ 'rows' => '3' ]) ?> | |
| 373 | - | |
| 374 | - <?= $form->field($model, 'check') ?> | |
| 375 | - | |
| 376 | - <?= $form->field($model, 'sms') ?> | |
| 377 | - | |
| 378 | - <?= $form->field($model, 'delivery_cost') ?> | |
| 379 | 421 | |
| 380 | 422 | </div> |
| 381 | 423 | </div> |
| 382 | 424 | |
| 383 | - | |
| 384 | - | |
| 385 | - </div> | |
| 386 | -</div> | |
| 387 | - | |
| 388 | 425 | </div><!-- /.box-body --> |
| 389 | 426 | </div><!-- /.box --> |
| 390 | 427 | |
| ... | ... | @@ -401,242 +438,247 @@ JS; |
| 401 | 438 | </div> |
| 402 | 439 | <div class="box-body"> |
| 403 | 440 | |
| 404 | -<div class="container"> | |
| 405 | - <div class="row"> | |
| 406 | - <?php | |
| 407 | - echo GridView::widget( | |
| 408 | - [ | |
| 409 | - 'dataProvider' => $dataProvider, | |
| 410 | - 'rowOptions' => function ($model) { | |
| 411 | - if ($model->removed) { | |
| 412 | - return [ 'class' => 'danger' ]; | |
| 413 | - } else { | |
| 414 | - return []; | |
| 415 | - } | |
| 416 | - }, | |
| 417 | - 'layout' => '{items}{pager}', | |
| 418 | - 'columns' => [ | |
| 419 | - [ | |
| 420 | - 'class' => SerialColumn::className(), | |
| 421 | - ], | |
| 422 | - 'sku', | |
| 423 | - [ | |
| 424 | - 'attribute' => 'product_name', | |
| 425 | - 'content' => function ($model) { | |
| 426 | - if (!empty( $model->product_name )) { | |
| 427 | - | |
| 428 | - if (empty( $model->productVariant )) { | |
| 429 | - return ''; | |
| 430 | - } | |
| 431 | - | |
| 432 | - return Html::a( | |
| 433 | - StringHelper::truncate($model->product_name, 10, '...'), | |
| 434 | - '#', | |
| 435 | - [ | |
| 436 | - 'onclick' => 'event.preventDefault();', | |
| 437 | - 'data-toggle' => 'popover', | |
| 438 | - 'data-placement' => 'right', | |
| 439 | - 'data-html' => 'true', | |
| 440 | - 'data-content' => Html::img( | |
| 441 | - $model->productVariant->imageUrl, | |
| 442 | - [ | |
| 443 | - 'class' => 'img-rounded', | |
| 444 | - ] | |
| 445 | - ) . Html::tag('p', $model->product_name), | |
| 446 | - ] | |
| 447 | - ); | |
| 448 | - } else { | |
| 449 | - return ''; | |
| 450 | - } | |
| 451 | - }, | |
| 452 | - ], | |
| 453 | - [ | |
| 454 | - 'attribute' => 'productVariant.product.brand.lang.title', | |
| 455 | - 'label' => 'Брэнд', | |
| 456 | - ], | |
| 457 | - [ | |
| 458 | - 'attribute' => 'productVariant.lang.title', | |
| 459 | - 'label' => \Yii::t('app', 'Цвет'), | |
| 460 | - 'content' => function ($model) { | |
| 461 | - | |
| 462 | - if (empty( $model->productVariant )) { | |
| 463 | - return ''; | |
| 464 | - } | |
| 465 | - | |
| 466 | - if (preg_match('@.*\.(png|jpg|gif)@i', $model->productVariant->lang->title)) { | |
| 467 | - return ''; | |
| 468 | - } else { | |
| 469 | - return $model->productVariant->lang->title; | |
| 470 | - } | |
| 471 | - }, | |
| 472 | - ], | |
| 473 | - [ | |
| 474 | - 'attribute' => 'productVariant.size', | |
| 475 | - 'label' => 'Размер', | |
| 476 | - ], | |
| 477 | - 'price', | |
| 478 | - [ | |
| 479 | - 'class' => 'kartik\grid\EditableColumn', | |
| 480 | - 'attribute' => 'count', | |
| 481 | - 'editableOptions' => [ | |
| 482 | - 'header' => \Yii::t('app', 'Количество'), | |
| 483 | - 'inputType' => kartik\editable\Editable::INPUT_SPIN, | |
| 484 | - 'options' => [ | |
| 485 | - 'pluginOptions' => [ | |
| 486 | - 'min' => 0, | |
| 487 | - 'max' => 5000, | |
| 488 | - ], | |
| 489 | - ], | |
| 490 | - 'pluginEvents' => [ | |
| 491 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 492 | - ], | |
| 493 | - ], | |
| 494 | - 'format' => [ | |
| 495 | - 'decimal', | |
| 496 | - 0, | |
| 497 | - ], | |
| 498 | - 'pageSummary' => false, | |
| 499 | - ], | |
| 500 | - 'sum_cost', | |
| 501 | - [ | |
| 502 | - 'class' => 'kartik\grid\EditableColumn', | |
| 503 | - 'attribute' => 'booking', | |
| 504 | - 'editableOptions' => [ | |
| 505 | - 'header' => \Yii::t('app', 'Бронь'), | |
| 506 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 507 | - 'options' => [ | |
| 508 | - 'class' => 'booking-typeahead', | |
| 509 | - 'pluginOptions' => [ | |
| 510 | - 'min' => 0, | |
| 511 | - 'max' => 20, | |
| 512 | - ], | |
| 513 | - ], | |
| 514 | - 'pluginEvents' => [ | |
| 515 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 516 | - ], | |
| 517 | - ], | |
| 518 | - 'format' => [ | |
| 519 | - 'text', | |
| 520 | - ], | |
| 521 | - 'pageSummary' => false, | |
| 522 | - ], | |
| 523 | - [ | |
| 524 | - 'class' => 'kartik\grid\EditableColumn', | |
| 525 | - 'attribute' => 'status', | |
| 526 | - 'editableOptions' => [ | |
| 527 | - 'header' => \Yii::t('app', 'Статус'), | |
| 528 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 529 | - 'options' => [ | |
| 530 | - 'class' => 'status-typeahead', | |
| 531 | - 'pluginOptions' => [ | |
| 532 | - 'min' => 0, | |
| 533 | - 'max' => 20, | |
| 534 | - ], | |
| 535 | - ], | |
| 536 | - 'pluginEvents' => [ | |
| 537 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 538 | - ], | |
| 539 | - ], | |
| 540 | - 'format' => [ | |
| 541 | - 'text', | |
| 542 | - ], | |
| 543 | - 'pageSummary' => false, | |
| 544 | - ], | |
| 545 | - [ | |
| 546 | - 'class' => 'kartik\grid\EditableColumn', | |
| 547 | - 'attribute' => 'return', | |
| 548 | - 'editableOptions' => [ | |
| 549 | - 'header' => \Yii::t('app', 'Возврат'), | |
| 550 | - 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX, | |
| 551 | - 'options' => [], | |
| 552 | - 'pluginEvents' => [ | |
| 553 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 554 | - ], | |
| 555 | - ], | |
| 556 | - 'format' => [ | |
| 557 | - 'boolean', | |
| 558 | - ], | |
| 559 | - 'pageSummary' => false, | |
| 560 | - ], | |
| 561 | - [ | |
| 562 | - 'content' => function ($model) { | |
| 563 | - | |
| 564 | - if (empty( $model->productVariant )) { | |
| 565 | - return '<i class="glyphicon glyphicon-remove"></i>'; | |
| 566 | - } | |
| 567 | - | |
| 568 | - $content = '<table class="table"><tbody><tr><th>Склад</th><th>кол.</th></tr>'; | |
| 569 | - foreach ($model->productVariant->variantStocks as $stock) { | |
| 570 | - $content .= '<tr><td>' . $stock->stock->title . '</td><td>' . $stock->quantity . '</td></tr>'; | |
| 571 | - } | |
| 572 | - return Html::a( | |
| 573 | - '<i class="glyphicon glyphicon-home"></i>', | |
| 574 | - '#', | |
| 575 | - [ | |
| 576 | - 'onclick' => 'event.preventDefault();', | |
| 577 | - 'data-toggle' => 'popover', | |
| 578 | - 'data-placement' => 'left', | |
| 579 | - 'data-html' => 'true', | |
| 580 | - 'data-content' => $content . '</tbody></table>', | |
| 581 | - ] | |
| 582 | - ); | |
| 583 | - }, | |
| 584 | - ], | |
| 585 | - [ | |
| 586 | - 'class' => 'yii\grid\ActionColumn', | |
| 587 | - 'template' => '{delete}', | |
| 588 | - 'buttons' => [ | |
| 589 | - 'delete' => function ($url, $product) { | |
| 590 | - if ($product->removed) { | |
| 591 | - return ''; | |
| 592 | - } else { | |
| 593 | - return Html::a( | |
| 594 | - Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]), | |
| 595 | - [ | |
| 596 | - 'delete-product', | |
| 597 | - 'id' => $product->id, | |
| 598 | - ], | |
| 599 | - [ | |
| 600 | - 'class' => 'delete-button', | |
| 601 | - ] | |
| 602 | - ); | |
| 603 | - } | |
| 604 | - }, | |
| 605 | - ], | |
| 606 | - ], | |
| 607 | - ], | |
| 608 | - 'responsive' => true, | |
| 609 | - 'hover' => true, | |
| 610 | - 'pjax' => true, | |
| 611 | - 'pjaxSettings' => [ | |
| 612 | - 'options' => [ | |
| 613 | - 'scrollTo' => 'false', | |
| 614 | - 'id' => 'order-products-grid', | |
| 615 | - ], | |
| 616 | - ], | |
| 617 | - ] | |
| 618 | - ); | |
| 619 | - ?> | |
| 441 | + <div class="container"> | |
| 442 | + <div class="row"> | |
| 443 | + <?php | |
| 444 | + echo GridView::widget( | |
| 445 | + [ | |
| 446 | + 'dataProvider' => $dataProvider, | |
| 447 | + 'rowOptions' => function($model) { | |
| 448 | + if ($model->removed) { | |
| 449 | + return [ 'class' => 'danger' ]; | |
| 450 | + } else { | |
| 451 | + return []; | |
| 452 | + } | |
| 453 | + }, | |
| 454 | + 'layout' => '{items}{pager}', | |
| 455 | + 'columns' => [ | |
| 456 | + [ | |
| 457 | + 'class' => SerialColumn::className(), | |
| 458 | + ], | |
| 459 | + 'sku', | |
| 460 | + [ | |
| 461 | + 'attribute' => 'product_name', | |
| 462 | + 'content' => function($model) { | |
| 463 | + if (!empty($model->product_name)) { | |
| 464 | + | |
| 465 | + if (empty($model->productVariant)) { | |
| 466 | + return ''; | |
| 467 | + } | |
| 468 | + | |
| 469 | + return Html::a( | |
| 470 | + StringHelper::truncate($model->product_name, 10, '...'), | |
| 471 | + '#', | |
| 472 | + [ | |
| 473 | + 'onclick' => 'event.preventDefault();', | |
| 474 | + 'data-toggle' => 'popover', | |
| 475 | + 'data-placement' => 'right', | |
| 476 | + 'data-html' => 'true', | |
| 477 | + 'data-content' => Html::img( | |
| 478 | + $model->productVariant->imageUrl, | |
| 479 | + [ | |
| 480 | + 'class' => 'img-rounded', | |
| 481 | + ] | |
| 482 | + ) . Html::tag('p', $model->product_name), | |
| 483 | + ] | |
| 484 | + ); | |
| 485 | + } else { | |
| 486 | + return ''; | |
| 487 | + } | |
| 488 | + }, | |
| 489 | + ], | |
| 490 | + [ | |
| 491 | + 'attribute' => 'productVariant.product.brand.lang.title', | |
| 492 | + 'label' => 'Брэнд', | |
| 493 | + ], | |
| 494 | + [ | |
| 495 | + 'attribute' => 'productVariant.lang.title', | |
| 496 | + 'label' => \Yii::t('app', 'Цвет'), | |
| 497 | + 'content' => function($model) { | |
| 498 | + | |
| 499 | + if (empty($model->productVariant)) { | |
| 500 | + return ''; | |
| 501 | + } | |
| 502 | + | |
| 503 | + if (preg_match('@.*\.(png|jpg|gif)@i', $model->productVariant->lang->title)) { | |
| 504 | + return ''; | |
| 505 | + } else { | |
| 506 | + return $model->productVariant->lang->title; | |
| 507 | + } | |
| 508 | + }, | |
| 509 | + ], | |
| 510 | + [ | |
| 511 | + 'attribute' => 'productVariant.size', | |
| 512 | + 'label' => 'Размер', | |
| 513 | + ], | |
| 514 | + 'price', | |
| 515 | + [ | |
| 516 | + 'class' => 'kartik\grid\EditableColumn', | |
| 517 | + 'attribute' => 'count', | |
| 518 | + 'editableOptions' => [ | |
| 519 | + 'header' => \Yii::t('app', 'Количество'), | |
| 520 | + 'inputType' => kartik\editable\Editable::INPUT_SPIN, | |
| 521 | + 'options' => [ | |
| 522 | + 'pluginOptions' => [ | |
| 523 | + 'min' => 0, | |
| 524 | + 'max' => 5000, | |
| 525 | + ], | |
| 526 | + 'disabled' => !$permissions->checkAttr('product_count'), | |
| 527 | + ], | |
| 528 | + 'pluginEvents' => [ | |
| 529 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 530 | + ], | |
| 531 | + ], | |
| 532 | + 'format' => [ | |
| 533 | + 'decimal', | |
| 534 | + 0, | |
| 535 | + ], | |
| 536 | + 'pageSummary' => false, | |
| 537 | + ], | |
| 538 | + 'sum_cost', | |
| 539 | + [ | |
| 540 | + 'class' => 'kartik\grid\EditableColumn', | |
| 541 | + 'attribute' => 'booking', | |
| 542 | + 'editableOptions' => [ | |
| 543 | + 'header' => \Yii::t('app', 'Бронь'), | |
| 544 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 545 | + 'options' => [ | |
| 546 | + 'class' => 'booking-typeahead', | |
| 547 | + 'pluginOptions' => [ | |
| 548 | + 'min' => 0, | |
| 549 | + 'max' => 20, | |
| 550 | + ], | |
| 551 | + 'disabled' => !$permissions->checkAttr('product_booking'), | |
| 552 | + ], | |
| 553 | + 'pluginEvents' => [ | |
| 554 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 555 | + ], | |
| 556 | + ], | |
| 557 | + 'format' => [ | |
| 558 | + 'text', | |
| 559 | + ], | |
| 560 | + 'pageSummary' => false, | |
| 561 | + ], | |
| 562 | + [ | |
| 563 | + 'class' => 'kartik\grid\EditableColumn', | |
| 564 | + 'attribute' => 'status', | |
| 565 | + 'editableOptions' => [ | |
| 566 | + 'header' => \Yii::t('app', 'Статус'), | |
| 567 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 568 | + 'options' => [ | |
| 569 | + 'class' => 'status-typeahead', | |
| 570 | + 'pluginOptions' => [ | |
| 571 | + 'min' => 0, | |
| 572 | + 'max' => 20, | |
| 573 | + ], | |
| 574 | + 'disabled' => !$permissions->checkAttr('product_status'), | |
| 575 | + ], | |
| 576 | + 'pluginEvents' => [ | |
| 577 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 578 | + ], | |
| 579 | + ], | |
| 580 | + 'format' => [ | |
| 581 | + 'text', | |
| 582 | + ], | |
| 583 | + 'pageSummary' => false, | |
| 584 | + ], | |
| 585 | + [ | |
| 586 | + 'class' => 'kartik\grid\EditableColumn', | |
| 587 | + 'attribute' => 'return', | |
| 588 | + 'editableOptions' => [ | |
| 589 | + 'header' => \Yii::t('app', 'Возврат'), | |
| 590 | + 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX, | |
| 591 | + 'options' => [ | |
| 592 | + 'disabled' => !$permissions->checkAttr('product_return'), | |
| 593 | + ], | |
| 594 | + 'pluginEvents' => [ | |
| 595 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 596 | + ], | |
| 597 | + ], | |
| 598 | + 'format' => [ | |
| 599 | + 'boolean', | |
| 600 | + ], | |
| 601 | + 'pageSummary' => false, | |
| 602 | + ], | |
| 603 | + [ | |
| 604 | + 'content' => function($model) { | |
| 605 | + | |
| 606 | + if (empty($model->productVariant)) { | |
| 607 | + return '<i class="glyphicon glyphicon-remove"></i>'; | |
| 608 | + } | |
| 609 | + | |
| 610 | + $content = '<table class="table"><tbody><tr><th>Склад</th><th>кол.</th></tr>'; | |
| 611 | + foreach ($model->productVariant->variantStocks as $stock) { | |
| 612 | + $content .= '<tr><td>' . $stock->stock->title . '</td><td>' . $stock->quantity . '</td></tr>'; | |
| 613 | + } | |
| 614 | + return Html::a( | |
| 615 | + '<i class="glyphicon glyphicon-home"></i>', | |
| 616 | + '#', | |
| 617 | + [ | |
| 618 | + 'onclick' => 'event.preventDefault();', | |
| 619 | + 'data-toggle' => 'popover', | |
| 620 | + 'data-placement' => 'left', | |
| 621 | + 'data-html' => 'true', | |
| 622 | + 'data-content' => $content . '</tbody></table>', | |
| 623 | + ] | |
| 624 | + ); | |
| 625 | + }, | |
| 626 | + ], | |
| 627 | + [ | |
| 628 | + 'class' => 'yii\grid\ActionColumn', | |
| 629 | + 'template' => '{delete}', | |
| 630 | + 'buttons' => [ | |
| 631 | + 'delete' => function($url, $product) use ($permissions) { | |
| 632 | + if ($product->removed || !$permissions->checkAttr('delete_product')) { | |
| 633 | + return ''; | |
| 634 | + } else { | |
| 635 | + return Html::a( | |
| 636 | + Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]), | |
| 637 | + [ | |
| 638 | + 'delete-product', | |
| 639 | + 'id' => $product->id, | |
| 640 | + ], | |
| 641 | + [ | |
| 642 | + 'class' => 'delete-button', | |
| 643 | + ] | |
| 644 | + ); | |
| 645 | + } | |
| 646 | + }, | |
| 647 | + ], | |
| 648 | + ], | |
| 649 | + ], | |
| 650 | + 'responsive' => true, | |
| 651 | + 'hover' => true, | |
| 652 | + 'pjax' => true, | |
| 653 | + 'pjaxSettings' => [ | |
| 654 | + 'options' => [ | |
| 655 | + 'scrollTo' => 'false', | |
| 656 | + 'id' => 'order-products-grid', | |
| 657 | + ], | |
| 658 | + ], | |
| 659 | + ] | |
| 660 | + ); | |
| 661 | + ?> | |
| 662 | + </div> | |
| 620 | 663 | </div> |
| 621 | -</div> | |
| 622 | -<div class="container"> | |
| 623 | - <?php Pjax::begin([ 'id' => 'total-cost' ]); ?> | |
| 624 | - <h2>Сумма заказа : <span class="label label-success"><?php echo $model->total; ?><?php echo \Yii::t( | |
| 625 | - 'app', | |
| 626 | - 'грн' | |
| 627 | - ) ?></span></h2> | |
| 628 | - <?php Pjax::end(); ?> | |
| 629 | -</div> | |
| 630 | -<div class="container"> | |
| 631 | - <div class="row"> | |
| 632 | - <?php $newProductForm = ActiveForm::begin( | |
| 633 | - [ | |
| 634 | - 'action' => yii\helpers\Url::to([ 'add' ]), | |
| 635 | - 'id' => 'add-product-form', | |
| 636 | - ] | |
| 637 | - ); | |
| 638 | - $newOrderProduct = new OrderProduct(); | |
| 639 | - ?> | |
| 664 | + <div class="container"> | |
| 665 | + <?php Pjax::begin([ 'id' => 'total-cost' ]); ?> | |
| 666 | + <h2>Сумма заказа : <span class="label label-success"><?php echo $model->total; ?><?php echo \Yii::t( | |
| 667 | + 'app', | |
| 668 | + 'грн' | |
| 669 | + ) ?></span></h2> | |
| 670 | + <?php Pjax::end(); ?> | |
| 671 | + </div> | |
| 672 | + <div class="container"> | |
| 673 | + <div class="row"> | |
| 674 | + <?php $newProductForm = ActiveForm::begin( | |
| 675 | + [ | |
| 676 | + 'action' => yii\helpers\Url::to([ 'add' ]), | |
| 677 | + 'id' => 'add-product-form', | |
| 678 | + ] | |
| 679 | + ); | |
| 680 | + $newOrderProduct = new OrderProduct(); | |
| 681 | + ?> | |
| 640 | 682 | <div class="col-md-8"> |
| 641 | 683 | <?php echo $newProductForm->field($newOrderProduct, 'id') |
| 642 | 684 | ->widget( |
| ... | ... | @@ -691,64 +733,65 @@ JS; |
| 691 | 733 | <?php echo Html::submitButton( |
| 692 | 734 | \Yii::t('app', 'Добавить'), |
| 693 | 735 | [ |
| 694 | - 'class' => $model->isNewRecord ? 'btn btn-primary disabled' : 'btn btn-primary', | |
| 736 | + 'class' => ( $model->isNewRecord || !$permissions->checkAttr( | |
| 737 | + 'add_product' | |
| 738 | + ) ) ? 'btn btn-primary disabled' : 'btn btn-primary', | |
| 695 | 739 | ] |
| 696 | 740 | ) ?> |
| 697 | 741 | </div> |
| 698 | - <?php echo $newProductForm->field($newOrderProduct, 'order_id') | |
| 699 | - ->hiddenInput( | |
| 700 | - [ | |
| 701 | - 'value' => $model->id, | |
| 702 | - ] | |
| 703 | - ) | |
| 704 | - ->label(false) ?> | |
| 705 | - <?php ActiveForm::end(); ?> | |
| 706 | - </div> | |
| 707 | - | |
| 742 | + <?php echo $newProductForm->field($newOrderProduct, 'order_id') | |
| 743 | + ->hiddenInput( | |
| 744 | + [ | |
| 745 | + 'value' => $model->id, | |
| 746 | + ] | |
| 747 | + ) | |
| 748 | + ->label(false) ?> | |
| 749 | + <?php ActiveForm::end(); ?> | |
| 750 | + </div> | |
| 708 | 751 | |
| 709 | 752 | |
| 710 | -</div> | |
| 753 | + </div> | |
| 711 | 754 | |
| 712 | 755 | </div><!-- /.box-body --> |
| 713 | 756 | </div><!-- /.box --> |
| 714 | - | |
| 715 | - | |
| 716 | - <br> | |
| 757 | + | |
| 758 | + | |
| 759 | +<br> | |
| 717 | 760 | <div class="container"> |
| 718 | - <div class="row"> | |
| 719 | - <?= Html::button( | |
| 720 | - $model->isNewRecord ? \Yii::t('app', 'Создать') : \Yii::t('app', 'Сохранить'), | |
| 721 | - [ | |
| 722 | - 'class' => $model->isNewRecord ? 'btn btn-success btn-lg' : 'btn btn-primary btn-lg', | |
| 723 | - 'id' => 'page-submit', | |
| 724 | - ] | |
| 725 | - ) ?> | |
| 726 | - <?= Html::a( | |
| 727 | - \Yii::t('app', 'Печать'), | |
| 728 | - yii\helpers\Url::to( | |
| 729 | - [ | |
| 730 | - 'order/print', | |
| 731 | - 'order_id' => $model->id, | |
| 732 | - ] | |
| 733 | - ), | |
| 734 | - [ | |
| 735 | - 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
| 736 | - 'target' => '_blank', | |
| 737 | - ] | |
| 738 | - ) ?> | |
| 739 | - <?= Html::a( | |
| 740 | - \Yii::t('app', 'Выйти'), | |
| 741 | - yii\helpers\Url::to( | |
| 742 | - [ | |
| 743 | - 'close-order', | |
| 744 | - 'id' => $model->id, | |
| 745 | - ] | |
| 746 | - ), | |
| 747 | - [ | |
| 748 | - 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
| 749 | - ] | |
| 750 | - ) ?> | |
| 751 | - </div> | |
| 761 | + <div class="row"> | |
| 762 | + <?= Html::button( | |
| 763 | + $model->isNewRecord ? \Yii::t('app', 'Создать') : \Yii::t('app', 'Сохранить'), | |
| 764 | + [ | |
| 765 | + 'class' => $model->isNewRecord ? 'btn btn-success btn-lg' : 'btn btn-primary btn-lg', | |
| 766 | + 'id' => 'page-submit', | |
| 767 | + ] | |
| 768 | + ) ?> | |
| 769 | + <?= Html::a( | |
| 770 | + \Yii::t('app', 'Печать'), | |
| 771 | + yii\helpers\Url::to( | |
| 772 | + [ | |
| 773 | + 'order/print', | |
| 774 | + 'order_id' => $model->id, | |
| 775 | + ] | |
| 776 | + ), | |
| 777 | + [ | |
| 778 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
| 779 | + 'target' => '_blank', | |
| 780 | + ] | |
| 781 | + ) ?> | |
| 782 | + <?= Html::a( | |
| 783 | + \Yii::t('app', 'Выйти'), | |
| 784 | + yii\helpers\Url::to( | |
| 785 | + [ | |
| 786 | + 'close-order', | |
| 787 | + 'id' => $model->id, | |
| 788 | + ] | |
| 789 | + ), | |
| 790 | + [ | |
| 791 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
| 792 | + ] | |
| 793 | + ) ?> | |
| 794 | + </div> | |
| 752 | 795 | </div> |
| 753 | 796 | <br> |
| 754 | 797 | <br> | ... | ... |
views/order/index.php
| ... | ... | @@ -3,6 +3,8 @@ |
| 3 | 3 | * @var ActiveDataProvider $dataProvider |
| 4 | 4 | * @var OrderSearch $searchModel |
| 5 | 5 | * @var View $this |
| 6 | + * @var array $allowedLabels | |
| 7 | + * @var boolean $canCreate | |
| 6 | 8 | */ |
| 7 | 9 | |
| 8 | 10 | use artweb\artbox\ecommerce\models\Delivery; |
| ... | ... | @@ -37,7 +39,10 @@ JS; |
| 37 | 39 | ?> |
| 38 | 40 | <h1>Заказы</h1> |
| 39 | 41 | <p> |
| 40 | - <?= Html::a(\Yii::t('app', 'Добавить заказ'), [ 'create' ], [ 'class' => 'btn btn-success btn-lg' ]) ?> | |
| 42 | + <?= Html::a(\Yii::t('app', 'Добавить заказ'), [ 'create' ], [ | |
| 43 | + 'class' => $canCreate ? 'btn btn-success btn-lg' : 'btn btn-success btn-lg disabled', | |
| 44 | + | |
| 45 | + ]) ?> | |
| 41 | 46 | </p> |
| 42 | 47 | <?php Pjax::begin(); ?> |
| 43 | 48 | <?php |
| ... | ... | @@ -51,19 +56,19 @@ JS; |
| 51 | 56 | ?> |
| 52 | 57 | |
| 53 | 58 | |
| 54 | - | |
| 55 | - | |
| 59 | + | |
| 60 | + | |
| 56 | 61 | |
| 57 | 62 | <?php |
| 58 | -// echo Html::button(\Yii::t('app', 'Скрыть/Показать'), [ | |
| 59 | -// 'data-toggle' => 'collapse', | |
| 60 | -// 'data-target' => '#search-fields', | |
| 61 | -// 'class' => 'btn btn-default' | |
| 62 | -//]); | |
| 63 | -//?> | |
| 63 | + // echo Html::button(\Yii::t('app', 'Скрыть/Показать'), [ | |
| 64 | + // 'data-toggle' => 'collapse', | |
| 65 | + // 'data-target' => '#search-fields', | |
| 66 | + // 'class' => 'btn btn-default' | |
| 67 | + //]); | |
| 68 | + //?> | |
| 64 | 69 | <div class="box box-primary"> |
| 65 | 70 | <div class="box-header with-border"> |
| 66 | -<!-- <h3 class="box-title"></h3>--> | |
| 71 | + <!-- <h3 class="box-title"></h3>--> | |
| 67 | 72 | <?php echo Html::submitButton( |
| 68 | 73 | \Yii::t('app', 'Искать'), |
| 69 | 74 | [ |
| ... | ... | @@ -74,126 +79,127 @@ JS; |
| 74 | 79 | <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button> |
| 75 | 80 | </div> |
| 76 | 81 | </div> |
| 77 | - | |
| 78 | -<div class="row box-body" id="search-fields"> | |
| 79 | - <div class="col-md-4"> | |
| 80 | - <?php | |
| 81 | - echo $searchForm->field($searchModel, 'label') | |
| 82 | - ->widget( | |
| 83 | - Select2::className(), | |
| 84 | - [ | |
| 85 | - 'data' => Label::find() | |
| 86 | - ->joinWith('lang') | |
| 87 | - ->select( | |
| 88 | - [ | |
| 89 | - 'CONCAT(order_label.label,order_label_lang.title) AS name', | |
| 90 | - 'id', | |
| 91 | - ] | |
| 92 | - ) | |
| 93 | - ->indexBy('id') | |
| 94 | - ->asArray() | |
| 95 | - ->column(), | |
| 96 | - 'options' => [ 'placeholder' => 'Выберите метки ...' ], | |
| 97 | - 'pluginOptions' => [ | |
| 98 | - 'allowClear' => true, | |
| 99 | - 'multiple' => true, | |
| 100 | - ], | |
| 101 | - ] | |
| 102 | - ); | |
| 103 | - ?> | |
| 104 | - <?php | |
| 105 | - echo $searchForm->field($searchModel, 'delivery') | |
| 106 | - ->widget( | |
| 107 | - Select2::className(), | |
| 108 | - [ | |
| 109 | - 'data' => Delivery::find() | |
| 110 | - ->joinWith('lang') | |
| 111 | - ->select('order_delivery_lang.title, id') | |
| 112 | - ->indexBy('id') | |
| 113 | - ->asArray() | |
| 114 | - ->column(), | |
| 115 | - 'options' => [ 'placeholder' => 'Выберите способ доставки ...' ], | |
| 116 | - 'pluginOptions' => [ | |
| 117 | - 'allowClear' => true, | |
| 118 | - 'multiple' => true, | |
| 119 | - ], | |
| 120 | - ] | |
| 121 | - ); | |
| 122 | - ?> | |
| 123 | - | |
| 124 | - <?php | |
| 125 | - $query = new JsExpression( | |
| 126 | - 'function(params) { return {q:params.term}; }' | |
| 127 | - ); | |
| 128 | - echo $searchForm->field($searchModel, 'sku') | |
| 129 | - ->widget( | |
| 130 | - Select2::className(), | |
| 131 | - [ | |
| 132 | - 'options' => [ 'placeholder' => 'Search for a product ...' ], | |
| 133 | - 'pluginOptions' => [ | |
| 134 | - 'allowClear' => true, | |
| 135 | - 'minimumInputLength' => 3, | |
| 136 | - 'language' => [ | |
| 137 | - 'errorLoading' => new JsExpression( | |
| 138 | - "function () { return 'Waiting for results...'; }" | |
| 139 | - ), | |
| 140 | - ], | |
| 141 | - 'ajax' => [ | |
| 142 | - 'url' => \yii\helpers\Url::to([ 'find-product' ]), | |
| 143 | - 'dataType' => 'json', | |
| 144 | - 'data' => $query, | |
| 145 | - ], | |
| 146 | - 'escapeMarkup' => new JsExpression( | |
| 147 | - 'function (markup) { return markup; }' | |
| 148 | - ), | |
| 149 | - 'templateResult' => new JsExpression( | |
| 150 | - 'function(data) { return data.sku; }' | |
| 151 | - ), | |
| 152 | - 'templateSelection' => new JsExpression( | |
| 153 | - 'function (data) { | |
| 82 | + | |
| 83 | + <div class="row box-body" id="search-fields"> | |
| 84 | + <div class="col-md-4"> | |
| 85 | + <?php | |
| 86 | + echo $searchForm->field($searchModel, 'label') | |
| 87 | + ->widget( | |
| 88 | + Select2::className(), | |
| 89 | + [ | |
| 90 | + 'data' => Label::find() | |
| 91 | + ->joinWith('lang') | |
| 92 | + ->select( | |
| 93 | + [ | |
| 94 | + 'CONCAT(order_label.label,order_label_lang.title) AS name', | |
| 95 | + 'id', | |
| 96 | + ] | |
| 97 | + ) | |
| 98 | + ->filterWhere([ 'id' => $allowedLabels ]) | |
| 99 | + ->indexBy('id') | |
| 100 | + ->asArray() | |
| 101 | + ->column(), | |
| 102 | + 'options' => [ 'placeholder' => 'Выберите метки ...' ], | |
| 103 | + 'pluginOptions' => [ | |
| 104 | + 'allowClear' => true, | |
| 105 | + 'multiple' => true, | |
| 106 | + ], | |
| 107 | + ] | |
| 108 | + ); | |
| 109 | + ?> | |
| 110 | + <?php | |
| 111 | + echo $searchForm->field($searchModel, 'delivery') | |
| 112 | + ->widget( | |
| 113 | + Select2::className(), | |
| 114 | + [ | |
| 115 | + 'data' => Delivery::find() | |
| 116 | + ->joinWith('lang') | |
| 117 | + ->select('order_delivery_lang.title, id') | |
| 118 | + ->indexBy('id') | |
| 119 | + ->asArray() | |
| 120 | + ->column(), | |
| 121 | + 'options' => [ 'placeholder' => 'Выберите способ доставки ...' ], | |
| 122 | + 'pluginOptions' => [ | |
| 123 | + 'allowClear' => true, | |
| 124 | + 'multiple' => true, | |
| 125 | + ], | |
| 126 | + ] | |
| 127 | + ); | |
| 128 | + ?> | |
| 129 | + | |
| 130 | + <?php | |
| 131 | + $query = new JsExpression( | |
| 132 | + 'function(params) { return {q:params.term}; }' | |
| 133 | + ); | |
| 134 | + echo $searchForm->field($searchModel, 'sku') | |
| 135 | + ->widget( | |
| 136 | + Select2::className(), | |
| 137 | + [ | |
| 138 | + 'options' => [ 'placeholder' => 'Search for a product ...' ], | |
| 139 | + 'pluginOptions' => [ | |
| 140 | + 'allowClear' => true, | |
| 141 | + 'minimumInputLength' => 3, | |
| 142 | + 'language' => [ | |
| 143 | + 'errorLoading' => new JsExpression( | |
| 144 | + "function () { return 'Waiting for results...'; }" | |
| 145 | + ), | |
| 146 | + ], | |
| 147 | + 'ajax' => [ | |
| 148 | + 'url' => \yii\helpers\Url::to([ 'find-product' ]), | |
| 149 | + 'dataType' => 'json', | |
| 150 | + 'data' => $query, | |
| 151 | + ], | |
| 152 | + 'escapeMarkup' => new JsExpression( | |
| 153 | + 'function (markup) { return markup; }' | |
| 154 | + ), | |
| 155 | + 'templateResult' => new JsExpression( | |
| 156 | + 'function(data) { return data.sku; }' | |
| 157 | + ), | |
| 158 | + 'templateSelection' => new JsExpression( | |
| 159 | + 'function (data) { | |
| 154 | 160 | if(data.sku == undefined) { |
| 155 | 161 | return "sku"; |
| 156 | 162 | } else { |
| 157 | 163 | return data.sku; |
| 158 | 164 | } |
| 159 | 165 | }' |
| 160 | - ), | |
| 161 | - ], | |
| 162 | - ] | |
| 163 | - ); | |
| 164 | - | |
| 165 | - ?> | |
| 166 | - </div> | |
| 166 | + ), | |
| 167 | + ], | |
| 168 | + ] | |
| 169 | + ); | |
| 170 | + | |
| 171 | + ?> | |
| 172 | + </div> | |
| 167 | 173 | |
| 168 | 174 | |
| 169 | - <div class="col-md-4"> | |
| 170 | - <?= $searchForm->field($searchModel, 'manager_id') | |
| 171 | - ->dropDownList( | |
| 172 | - ArrayHelper::map( | |
| 173 | - User::find() | |
| 174 | - ->asArray() | |
| 175 | - ->all(), | |
| 176 | - 'id', | |
| 177 | - 'username' | |
| 178 | - ), | |
| 179 | - [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ] | |
| 180 | - ) ?> | |
| 181 | - | |
| 182 | - <?= $searchForm->field($searchModel, 'email') | |
| 183 | - ->textInput() ?> | |
| 175 | + <div class="col-md-4"> | |
| 176 | + <?= $searchForm->field($searchModel, 'manager_id') | |
| 177 | + ->dropDownList( | |
| 178 | + ArrayHelper::map( | |
| 179 | + User::find() | |
| 180 | + ->asArray() | |
| 181 | + ->all(), | |
| 182 | + 'id', | |
| 183 | + 'username' | |
| 184 | + ), | |
| 185 | + [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ] | |
| 186 | + ) ?> | |
| 187 | + | |
| 188 | + <?= $searchForm->field($searchModel, 'email') | |
| 189 | + ->textInput() ?> | |
| 184 | 190 | |
| 191 | + </div> | |
| 192 | + <div class="col-md-4"> | |
| 193 | + <?= $searchForm->field($searchModel, 'declaration') | |
| 194 | + ->textInput() ?> | |
| 195 | + | |
| 196 | + <?= $searchForm->field($searchModel, 'consignment') | |
| 197 | + ->textInput() ?> | |
| 198 | + </div> | |
| 185 | 199 | </div> |
| 186 | - <div class="col-md-4"> | |
| 187 | - <?= $searchForm->field($searchModel, 'declaration') | |
| 188 | - ->textInput() ?> | |
| 189 | - | |
| 190 | - <?= $searchForm->field($searchModel, 'consignment') | |
| 191 | - ->textInput() ?> | |
| 192 | - </div> | |
| 193 | -</div> | |
| 194 | 200 | |
| 195 | 201 | </div> |
| 196 | - | |
| 202 | + | |
| 197 | 203 | <p> |
| 198 | 204 | <?php |
| 199 | 205 | echo GridView::widget( |
| ... | ... | @@ -216,9 +222,29 @@ JS; |
| 216 | 222 | 'content' => function($model) { |
| 217 | 223 | $manager = $model->manager; |
| 218 | 224 | if (empty($manager)) { |
| 219 | - return Html::a($model->id, ['update', 'id' => $model->id], ['target' => '_blank', 'data-pjax' => '0']); | |
| 225 | + return Html::a( | |
| 226 | + $model->id, | |
| 227 | + [ | |
| 228 | + 'update', | |
| 229 | + 'id' => $model->id, | |
| 230 | + ], | |
| 231 | + [ | |
| 232 | + 'target' => '_blank', | |
| 233 | + 'data-pjax' => '0', | |
| 234 | + ] | |
| 235 | + ); | |
| 220 | 236 | } else { |
| 221 | - return Html::a($model->id, ['update', 'id' => $model->id], ['target' => '_blank', 'data-pjax' => '0']) . '<br>' . $manager->username; | |
| 237 | + return Html::a( | |
| 238 | + $model->id, | |
| 239 | + [ | |
| 240 | + 'update', | |
| 241 | + 'id' => $model->id, | |
| 242 | + ], | |
| 243 | + [ | |
| 244 | + 'target' => '_blank', | |
| 245 | + 'data-pjax' => '0', | |
| 246 | + ] | |
| 247 | + ) . '<br>' . $manager->username; | |
| 222 | 248 | } |
| 223 | 249 | }, |
| 224 | 250 | ], |
| ... | ... | @@ -279,10 +305,10 @@ JS; |
| 279 | 305 | }, |
| 280 | 306 | ], |
| 281 | 307 | [ |
| 282 | - 'attribute' => 'phone', | |
| 283 | - 'content' => function($model) { | |
| 284 | - return $model->phone . '<br>' . $model->phone2; | |
| 285 | - } | |
| 308 | + 'attribute' => 'phone', | |
| 309 | + 'content' => function($model) { | |
| 310 | + return $model->phone . '<br>' . $model->phone2; | |
| 311 | + }, | |
| 286 | 312 | ], |
| 287 | 313 | [ |
| 288 | 314 | 'attribute' => 'adress', |
| ... | ... | @@ -349,22 +375,25 @@ JS; |
| 349 | 375 | 'template' => \Yii::$app->user->identity->isAdmin( |
| 350 | 376 | ) ? '{history} {view} {update} {delete}' : '{view} {update}', |
| 351 | 377 | 'buttons' => [ |
| 352 | - 'update' => function($url, $model) { | |
| 378 | + 'update' => function($url, $model) { | |
| 353 | 379 | return Html::a( |
| 354 | 380 | Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-pencil' ]), |
| 355 | 381 | $url, |
| 356 | 382 | [ |
| 357 | - 'target' => '_blank', | |
| 358 | - 'data-pjax' => '0', | |
| 383 | + 'target' => '_blank', | |
| 384 | + 'data-pjax' => '0', | |
| 359 | 385 | ] |
| 360 | 386 | ); |
| 361 | 387 | }, |
| 362 | 388 | 'history' => function($url, $model) { |
| 363 | 389 | return Html::a( |
| 364 | 390 | Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-time' ]), |
| 365 | - ['log', 'id' => $model->id], | |
| 366 | 391 | [ |
| 367 | - 'target' => '_blank', | |
| 392 | + 'log', | |
| 393 | + 'id' => $model->id, | |
| 394 | + ], | |
| 395 | + [ | |
| 396 | + 'target' => '_blank', | |
| 368 | 397 | 'data-pjax' => '0', |
| 369 | 398 | ] |
| 370 | 399 | ); | ... | ... |
views/order/update.php
| ... | ... | @@ -3,9 +3,11 @@ |
| 3 | 3 | * @var Order $model |
| 4 | 4 | * @var View $this |
| 5 | 5 | * @var ActiveDataProvider $dataProvider |
| 6 | + * @var Permissions $permissions | |
| 6 | 7 | */ |
| 7 | 8 | |
| 8 | 9 | use artweb\artbox\ecommerce\models\Order; |
| 10 | + use common\models\Permissions; | |
| 9 | 11 | use yii\data\ActiveDataProvider; |
| 10 | 12 | use yii\helpers\Html; |
| 11 | 13 | use yii\web\View; |
| ... | ... | @@ -16,7 +18,12 @@ |
| 16 | 18 | 'label' => \Yii::t('app', 'Заказы'), |
| 17 | 19 | ]; |
| 18 | 20 | $this->params[ 'breadcrumbs' ][] = [ |
| 19 | - 'url' => yii\helpers\Url::to([ '/ecommerce/order/view', 'id' => $model->id, ]), | |
| 21 | + 'url' => yii\helpers\Url::to( | |
| 22 | + [ | |
| 23 | + '/ecommerce/order/view', | |
| 24 | + 'id' => $model->id, | |
| 25 | + ] | |
| 26 | + ), | |
| 20 | 27 | 'label' => \Yii::t('app', 'Заказ #') . $model->id, |
| 21 | 28 | ]; |
| 22 | 29 | $this->params[ 'breadcrumbs' ][] = $this->title; |
| ... | ... | @@ -58,18 +65,18 @@ $.ajax({ |
| 58 | 65 | '; |
| 59 | 66 | |
| 60 | 67 | $this->registerJs($js, View::POS_READY); |
| 61 | - | |
| 68 | + | |
| 62 | 69 | if (!empty(\Yii::$app->session->getFlash('label_update'))) { |
| 63 | - $js = ' | |
| 70 | + $js = ' | |
| 64 | 71 | $.notify({ |
| 65 | 72 | message: "Статус заказа обновлен" |
| 66 | 73 | }, { |
| 67 | 74 | type : "warning" |
| 68 | 75 | }) |
| 69 | 76 | '; |
| 70 | - $this->registerJs($js, View::POS_READY); | |
| 77 | + $this->registerJs($js, View::POS_READY); | |
| 71 | 78 | } |
| 72 | - | |
| 79 | + | |
| 73 | 80 | ?> |
| 74 | 81 | <div class="order-update"> |
| 75 | 82 | <div class="container callout bg-olive"> |
| ... | ... | @@ -84,6 +91,7 @@ $.notify({ |
| 84 | 91 | [ |
| 85 | 92 | 'model' => $model, |
| 86 | 93 | 'dataProvider' => $dataProvider, |
| 94 | + 'permissions' => $permissions, | |
| 87 | 95 | ] |
| 88 | 96 | ) ?> |
| 89 | 97 | </div> |
| 90 | 98 | \ No newline at end of file | ... | ... |