예제 #1
0
 /**
  * Получает объект заказа из сессии
  * @param bool $refresh получить заново
  * @return Order
  * @throws \yii\base\InvalidConfigException
  */
 public function getOrder($refresh = false)
 {
     if ($this->_order === null or $refresh) {
         $this->_order = Yii::$app->session->get($this->sessionKey);
         if (!$this->_order) {
             $this->_order = Yii::createObject(["class" => Order::className(), "scenario" => Order::SCENARIO_CONFIRM]);
             $status = Status::find()->byDefault()->one();
             if ($status) {
                 $this->_order->status_id = $status->id;
             }
         }
     }
     $this->_order->clearErrors();
     return $this->_order;
 }
예제 #2
0
 /**
  * Связь со статусами
  * @return \yii\db\ActiveQuery
  */
 public function getStatus()
 {
     return $this->hasOne(Status::className(), ["id" => "status_id"]);
 }
예제 #3
0
 /**
  * Загрузка шаблона
  * @param Status $status статус
  */
 public function loadStatusTpl(Status $status)
 {
     $name = Yii::getAlias($this->tplPath . '/' . $status->getTplName());
     $status->tplHtml = file_get_contents($name);
 }
예제 #4
0
 /**
  * Возвращает список статусов для выпадающего списка
  * @return array
  */
 public function getStatusList()
 {
     $models = Status::find()->published()->orderBy(["title" => SORT_ASC])->all();
     return ArrayHelper::map($models, "id", "title");
 }
예제 #5
0
 /**
  * Список статусов заказа
  * @return array|\yii\db\ActiveRecord[]
  */
 public function actionStatuses()
 {
     return Status::find()->published()->all();
 }
예제 #6
0
<?php

use app\modules\shop\models;
return ['controllerMap' => ['migrate' => ['migrationLookup' => ['@webapp/modules/shop/migrations']]], 'modules' => ['shop' => ['class' => 'app\\modules\\shop\\Shop', 'modelClasses' => ['app\\modules\\catalog\\models\\Catalog'], 'components' => ['orderLetters' => \app\modules\shop\components\OrderLetters::className(), 'clientNotifier' => \app\modules\shop\components\ClientNotifier::className(), 'adminNotifier' => \app\modules\shop\components\AdminNotifier::className(), 'basket' => ['class' => \app\modules\shop\components\Basket::className(), 'components' => ['orderManager' => ['class' => \app\modules\shop\components\OrderManager::className()]]]], 'controllerNamespace' => 'app\\modules\\shop\\controllers', 'modules' => ['admin' => ['class' => 'app\\modules\\shop\\modules\\admin\\Admin', 'controllerNamespace' => 'app\\modules\\shop\\modules\\admin\\controllers', 'menuItems' => function () {
    return [['label' => Yii::t('shop/app', 'Shop module'), 'icon' => 'glyphicon glyphicon-shopping-cart', 'items' => [['label' => Yii::t('shop/app', 'Orders'), 'url' => ['/admin/shop/order'], "permission" => ["listModels", ["model" => Yii::createObject(models\Order::className())]]], ['label' => Yii::t('shop/app', 'Goods'), 'url' => ['/admin/shop/good'], "permission" => ["listModels", ["model" => Yii::createObject(models\Good::className())]]], ['label' => Yii::t('shop/app', 'Statuses'), 'url' => ['/admin/shop/status'], "permission" => ["listModels", ["model" => Yii::createObject(models\Status::className())]]], ['label' => Yii::t('shop/app', 'Payments'), 'url' => ['/admin/shop/payment'], "permission" => ["listModels", ["model" => Yii::createObject(models\Payment::className())]]], ['label' => Yii::t('shop/app', 'Deliveries'), 'url' => ['/admin/shop/delivery'], "permission" => ["listModels", ["model" => Yii::createObject(models\Delivery::className())]]]]]];
}]]]], 'components' => ['i18n' => ['translations' => ['shop/*' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@webapp/modules/shop/messages', 'fileMap' => ['shop/app' => 'app.php']]]], 'urlManager' => ['rules' => ['shop/orders-rest/update/<id:\\d+>' => 'shop/orders-rest/update']]]];
예제 #7
0
 /**
  * Действия
  * @return array
  */
 public function actions()
 {
     $class = Status::className();
     return ['index' => ['class' => crud\Admin::className(), 'modelClass' => $class], 'create' => ['class' => crud\Create::className(), 'modelClass' => $class], 'update' => ['class' => crud\Update::className(), 'modelClass' => $class], 'view' => ['class' => crud\View::className(), 'modelClass' => $class], 'delete' => ['class' => crud\Delete::className(), 'modelClass' => $class], 'groupdelete' => ['class' => crud\GroupDelete::className(), 'modelClass' => $class], 'editable' => ['class' => crud\XEditable::className(), 'modelClass' => $class]];
 }