/**
     * @inheritdoc
     */
    public function actions()
    {
        return ArrayHelper::merge(parent::actions(), ['index' => ["columns" => [['class' => CreatedAtColumn::className()], 'id', ['class' => DataColumn::className(), 'attribute' => 'status_code', 'format' => 'raw', 'filter' => ArrayHelper::map(ShopOrderStatus::find()->all(), 'code', 'name'), 'value' => function (ShopOrder $order) {
            return Html::label($order->status->name, null, ['style' => "background: {$order->status->color}", 'class' => "label"]) . "<br />" . Html::tag("small", \Yii::$app->formatter->asDatetime($order->status_at) . " (" . \Yii::$app->formatter->asRelativeTime($order->status_at) . ")");
        }], ['class' => BooleanColumn::className(), 'attribute' => 'payed', 'format' => 'raw'], ['class' => DataColumn::className(), 'attribute' => "canceled", 'format' => "raw", 'filter' => ['Y' => \Yii::t('app', 'Yes'), 'N' => \Yii::t('app', 'No')], 'value' => function (ShopOrder $shopOrder) {
            return $shopOrder->canceled == "Y" ? \Yii::t('app', 'Yes') : \Yii::t('app', 'No');
        }], ['class' => DataColumn::className(), 'attribute' => "user_id", 'label' => \skeeks\cms\shop\Module::t('app', 'Buyer'), 'format' => "raw", 'value' => function (ShopOrder $shopOrder) {
            return (new \skeeks\cms\shop\widgets\AdminBuyerUserWidget(['user' => $shopOrder->user]))->run();
        }], ['class' => DataColumn::className(), 'filter' => false, 'format' => 'raw', 'label' => \skeeks\cms\shop\Module::t('app', 'Good'), 'value' => function (ShopOrder $model) {
            if ($model->shopBaskets) {
                $result = [];
                foreach ($model->shopBaskets as $shopBasket) {
                    $money = \Yii::$app->money->intlFormatter()->format($shopBasket->money);
                    $result[] = Html::a($shopBasket->name, $shopBasket->product->cmsContentElement->url, ['target' => '_blank']) . <<<HTML
  — {$shopBasket->quantity} {$shopBasket->measure_name}
HTML;
                }
                return implode('<hr style="margin: 0px;"/>', $result);
            }
        }], ['class' => DataColumn::className(), 'format' => 'raw', 'attribute' => 'price', 'label' => \skeeks\cms\shop\Module::t('app', 'Sum'), 'value' => function (ShopOrder $model) {
            return \Yii::$app->money->intlFormatter()->format($model->money);
        }], ['class' => DataColumn::className(), 'filter' => ArrayHelper::map(CmsSite::find()->active()->all(), 'id', 'name'), 'attribute' => 'site_id', 'format' => 'raw', 'visible' => false, 'label' => \skeeks\cms\shop\Module::t('app', 'Site'), 'value' => function (ShopOrder $model) {
            return $model->site->name . " [{$model->site->code}]";
        }]]], "view" => ['class' => AdminOneModelEditAction::className(), "name" => \Yii::t('app', "Информация"), "icon" => "glyphicon glyphicon-eye-open", "priority" => 5, "callback" => [$this, 'view']]]);
    }
 /**
  * @return bool
  */
 public function isVisible()
 {
     if (!parent::isVisible()) {
         return false;
     }
     return Validate::validate(new HasBehavior(HasRelatedProperties::className()), $this->controller->model)->isValid();
 }
 /**
  * @inheritdoc
  */
 public function actions()
 {
     $actions = ArrayHelper::merge(parent::actions(), ['index' => ["modelSearchClassName" => ShopCmsContentElementSearch::className(), "dataProviderCallback" => function (ActiveDataProvider $dataProvider) {
         $query = $dataProvider->query;
         /**
          * @var ActiveQuery $query
          */
         //$query->select(['app_company.*', 'count(`app_company_officer_user`.`id`) as countOfficer']);
         $query->with('image');
         $query->with('cmsTree');
         $query->with('cmsContentElementTrees');
         $query->with('cmsContent');
         $query->with('relatedProperties');
         $query->with('relatedElementProperties');
         $query->with('cmsContentElementTrees.tree');
         $query->with('shopProduct');
         $query->with('shopProduct.baseProductPrice');
         //$query->with('shopProduct.minProductPrice');
     }], "create" => ['class' => AdminModelEditorCreateAction::className(), "callback" => [$this, 'create']], "update" => ['class' => AdminOneModelEditAction::className(), "callback" => [$this, 'update']], "activate-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \Yii::t('skeeks/shop/app', 'Activate'), "eachCallback" => [$this, 'eachMultiActivate']], "inActivate-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \Yii::t('skeeks/shop/app', 'Deactivate'), "eachCallback" => [$this, 'eachMultiInActivate']], "change-tree-multi" => ['class' => AdminMultiDialogModelEditAction::class, "name" => \Yii::t('skeeks/shop/app', 'The main section'), "viewDialog" => "@skeeks/cms/views/admin-cms-content-element/change-tree-form", "eachCallback" => [\Yii::$app->createController('/cms/admin-cms-content-element')[0], 'eachMultiChangeTree']], "change-trees-multi" => ['class' => AdminMultiDialogModelEditAction::class, "name" => \Yii::t('skeeks/shop/app', 'Related topics'), "viewDialog" => "@skeeks/cms/views/admin-cms-content-element/change-trees-form", "eachCallback" => [\Yii::$app->createController('/cms/admin-cms-content-element')[0], 'eachMultiChangeTrees']], "rp" => ['class' => AdminMultiDialogModelEditAction::class, "name" => \Yii::t('skeeks/shop/app', 'Properties'), "viewDialog" => "@skeeks/cms/views/admin-cms-content-element/multi-rp", "eachCallback" => [\Yii::$app->createController('/cms/admin-cms-content-element')[0], 'eachRelatedProperties']]]);
     if (isset($actions['related-properties'])) {
         unset($actions['related-properties']);
     }
     if (isset($actions['shop'])) {
         unset($actions['shop']);
     }
     return $actions;
 }
Example #4
0
 public function actions()
 {
     $actions = ArrayHelper::merge(parent::actions(), ['change-password' => ["class" => AdminOneModelEditAction::className(), "name" => "Изменение пароля", "icon" => "glyphicon glyphicon-cog", "callback" => [$this, 'actionChangePassword']], 'file-manager' => ["class" => AdminOneModelEditAction::className(), "name" => "Личные файлы", "icon" => "glyphicon glyphicon-folder-open", "callback" => [$this, 'actionFileManager']]]);
     unset($actions['delete']);
     unset($actions['create']);
     unset($actions['index']);
     return $actions;
 }
 /**
  * Renders a view
  *
  * @param string $viewName view name
  * @return string result of the rendering
  */
 protected function render($viewName)
 {
     try {
         $output = parent::render($viewName);
     } catch (InvalidParamException $e) {
         $output = parent::render('_form');
     }
     return $output;
 }
 public function run()
 {
     /**
      * @var $contentElement CmsContentElement
      */
     $contentElement = $this->controller->model;
     $model = ShopProduct::find()->where(['id' => $contentElement->id])->one();
     $productPrices = [];
     if (!$model) {
         $model = new ShopProduct(['id' => $contentElement->id]);
     } else {
         if ($typePrices = ShopTypePrice::find()->where(['!=', 'def', Cms::BOOL_Y])->all()) {
             foreach ($typePrices as $typePrice) {
                 $productPrice = ShopProductPrice::find()->where(['product_id' => $model->id, 'type_price_id' => $typePrice->id])->one();
                 if (!$productPrice) {
                     $productPrice = new ShopProductPrice(['product_id' => $model->id, 'type_price_id' => $typePrice->id]);
                 }
                 if ($post = \Yii::$app->request->post()) {
                     $data = ArrayHelper::getValue($post, 'prices.' . $typePrice->id);
                     $productPrice->load($data, "");
                 }
                 $productPrices[] = $productPrice;
             }
         }
     }
     $rr = new RequestResponse();
     if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
         return $rr->ajaxValidateForm($model);
     }
     if ($rr->isRequestPjaxPost()) {
         /**
          * @var $productPrice ShopProductPrice
          */
         foreach ($productPrices as $productPrice) {
             if ($productPrice->save()) {
             } else {
                 \Yii::$app->getSession()->setFlash('error', \skeeks\cms\shop\Module::t('app', 'Check the correctness of the prices'));
             }
         }
         if ($model->load(\Yii::$app->request->post()) && $model->save()) {
             \Yii::$app->getSession()->setFlash('success', 'Saved');
             if (\Yii::$app->request->post('submit-btn') == 'apply') {
             } else {
                 return $this->controller->redirect($this->controller->indexUrl);
             }
             $model->refresh();
         } else {
             \Yii::$app->getSession()->setFlash('error', \skeeks\cms\shop\Module::t('app', 'Failed to save'));
         }
     }
     $this->viewParams = ['model' => $model, 'productPrices' => $productPrices];
     return parent::run();
 }
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['index' => ['class' => AdminAction::className(), 'callback' => [$this, 'actionIndex']], 'view' => ["class" => AdminOneModelEditAction::className(), "name" => "Смотреть", "icon" => "glyphicon glyphicon-eye-open", "callback" => [$this, "actionView"]], 'create' => ['class' => AdminAction::className(), 'callback' => [$this, 'actionCreate']], "update-data" => ["class" => AdminAction::className(), "name" => \Yii::t('app', "Update privileges"), "icon" => "glyphicon glyphicon-retweet", "method" => "post", "request" => "ajax", 'callback' => [$this, 'actionUpdateData']]]);
 }
Example #8
0
 public function actions()
 {
     $actions = ArrayHelper::merge(parent::actions(), ['index' => ['class' => AdminAction::className(), 'name' => 'Разделы', 'viewParams' => $this->indexData()], 'create' => ['visible' => false], "update" => ['class' => AdminOneModelEditAction::className(), "callback" => [$this, 'update']]]);
     unset($actions['create']);
     return $actions;
 }
Example #9
0
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['index' => ['class' => AdminAction::className(), 'callback' => [$this, 'actionIndex']], 'view' => ["class" => AdminOneModelEditAction::className(), "name" => \Yii::t('app', "Watch"), "icon" => "glyphicon glyphicon-eye-open", "callback" => [$this, "actionView"]], 'create' => ['class' => AdminAction::className(), 'callback' => [$this, 'actionCreate']], "update" => ['class' => AdminOneModelEditAction::className(), 'callback' => [$this, 'actionUpdate']]]);
 }
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['delete-tmp-dir' => ["class" => AdminOneModelEditAction::className(), "name" => "Удалить временные файлы", "icon" => "glyphicon glyphicon-folder-open", "method" => "post", "request" => "ajax", "callback" => [$this, 'actionDeleteTmpDir']], 'download' => ["class" => AdminOneModelEditAction::className(), "name" => "Скачать", "icon" => "glyphicon glyphicon-circle-arrow-down", "method" => "post", "callback" => [$this, 'actionDownload']], 'create' => ['visible' => false]]);
 }
Example #11
0
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['create' => ['modelScenario' => 'create'], 'update' => ['modelScenario' => 'update'], 'change-password' => ["class" => AdminOneModelEditAction::className(), "name" => "Изменение пароля", "icon" => "glyphicon glyphicon-cog", "callback" => [$this, "actionChangePassword"]], "activate-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => "Активировать", "eachCallback" => [$this, 'eachMultiActivate']], "inActivate-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => "Деактивировать", "eachCallback" => [$this, 'eachMultiInActivate']]]);
 }
 /**
  * @inheritdoc
  */
 public function actions()
 {
     $actions = ArrayHelper::merge(parent::actions(), ["index" => ['modelSearchClassName' => CmsContentElementSearch::className()], "create" => ['class' => AdminModelEditorCreateAction::className(), "callback" => [$this, 'create']], "update" => ['class' => AdminOneModelEditAction::className(), "callback" => [$this, 'update']], "activate-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \Yii::t('skeeks/cms', 'Activate'), "eachCallback" => [$this, 'eachMultiActivate']], "inActivate-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \Yii::t('skeeks/cms', 'Deactivate'), "eachCallback" => [$this, 'eachMultiInActivate']], "change-tree-multi" => ['class' => AdminMultiDialogModelEditAction::className(), "name" => \Yii::t('skeeks/cms', 'The main section'), "viewDialog" => "change-tree-form", "eachCallback" => [$this, 'eachMultiChangeTree']], "change-trees-multi" => ['class' => AdminMultiDialogModelEditAction::className(), "name" => \Yii::t('skeeks/cms', 'Related topics'), "viewDialog" => "change-trees-form", "eachCallback" => [$this, 'eachMultiChangeTrees']], "rp" => ['class' => AdminMultiDialogModelEditAction::className(), "name" => \Yii::t('skeeks/cms', 'Properties'), "viewDialog" => "multi-rp", "eachCallback" => [$this, 'eachRelatedProperties']]]);
     return $actions;
 }
 /**
  * @inheritdoc
  */
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['view' => ['class' => AdminOneModelEditAction::className(), 'name' => \Yii::t('skeeks/form2/app', 'Result'), "icon" => "glyphicon glyphicon-eye-open", "priority" => 0]]);
 }
 /**
  * @inheritdoc
  */
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['index' => ['class' => ModelEditorGridAction::className(), 'name' => \Yii::t('app', 'List'), "icon" => "glyphicon glyphicon-th-list", "priority" => 10], 'create' => ['class' => AdminModelEditorCreateAction::className(), 'name' => \Yii::t('app', 'Add'), "icon" => "glyphicon glyphicon-plus"], "update" => ['class' => AdminOneModelUpdateAction::className(), "name" => \Yii::t('app', "Edit"), "icon" => "glyphicon glyphicon-pencil", "priority" => 10], "delete" => ['class' => AdminOneModelEditAction::className(), "name" => \Yii::t('app', "Delete"), "icon" => "glyphicon glyphicon-trash", "confirm" => \Yii::t('yii', 'Are you sure you want to delete this item?'), "method" => "post", "request" => "ajax", "callback" => [$this, 'actionDelete'], "priority" => 99999], "delete-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \Yii::t('app', "Delete"), "icon" => "glyphicon glyphicon-trash", "confirm" => \Yii::t('yii', 'Are you sure you want to permanently delete the selected items?'), "eachCallback" => [$this, 'eachMultiDelete'], "priority" => 99999]]);
 }
Example #15
0
 public function actions()
 {
     $actions = ArrayHelper::merge(parent::actions(), ["index" => ['modelSearchClassName' => CmsUserSearch::className()], 'create' => ['class' => AdminModelEditorCreateAction::className(), "callback" => [$this, 'create']], 'update' => ['class' => AdminOneModelEditAction::className(), "callback" => [$this, 'update']], "activate-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => "Активировать", "eachCallback" => [$this, 'eachMultiActivate']], "inActivate-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => "Деактивировать", "eachCallback" => [$this, 'eachMultiInActivate']]]);
     return $actions;
 }