Example #1
0
/* @var $searchModel \skeeks\cms\models\Search */
/* @var $dataProvider yii\data\ActiveDataProvider */
$dataProvider->setSort(['defaultOrder' => ['published_at' => SORT_DESC]]);
$sortAttr = $dataProvider->getSort()->attributes;
$dataProvider->query->joinWith('shopProduct as sp');
$dataProvider->getSort()->attributes = \yii\helpers\ArrayHelper::merge($sortAttr, ['quantity' => ['asc' => ['sp.quantity' => SORT_ASC], 'desc' => ['sp.quantity' => SORT_DESC], 'label' => \Yii::t('skeeks/shop/app', 'Available quantity'), 'default' => SORT_ASC]]);
$cmsContent = null;
if ($content_id = \Yii::$app->request->get('content_id')) {
    $dataProvider->query->andWhere(['content_id' => $content_id]);
    /**
     * @var $cmsContent \skeeks\cms\models\CmsContent
     */
    $cmsContent = \skeeks\cms\models\CmsContent::findOne($content_id);
    $searchModel->content_id = $content_id;
}
$columns = \skeeks\cms\shop\controllers\AdminCmsContentElementController::getColumns($cmsContent, $dataProvider);
$columns = \yii\helpers\ArrayHelper::merge($columns, [['label' => \Yii::t('skeeks/shop/app', 'Available quantity'), 'class' => \yii\grid\DataColumn::class, 'visible' => false, 'attribute' => 'quantity', 'value' => function (\skeeks\cms\shop\models\ShopCmsContentElement $shopCmsContentElement) {
    return $shopCmsContentElement->shopProduct ? $shopCmsContentElement->shopProduct->quantity : " - ";
}]]);
?>

<? $pjax = \yii\widgets\Pjax::begin(); ?>

    <?php 
echo $this->render('_search', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'content_id' => $content_id, 'cmsContent' => $cmsContent]);
?>

    <?php 
echo \skeeks\cms\modules\admin\widgets\GridViewStandart::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'autoColumns' => false, 'pjax' => $pjax, 'adminController' => $controller, 'settingsData' => ['namespace' => \Yii::$app->controller->action->getUniqueId() . $content_id], 'columns' => $columns]);
?>
Example #2
0
echo $form->fieldRadioListBoolean($shopProduct, 'subscribe');
?>
        </div>

<? if ($shopContent->childrenContent) : ?>
    <div id="sx-shop-product-tradeOffers">

        <? if ($model->isNewRecord) : ?>

            <?php 
echo \yii\bootstrap\Alert::widget(['options' => ['class' => 'alert-warning'], 'body' => \Yii::t('skeeks/shop/app', 'Management will be available after saving')]);
?>
        <? else:  ?>

            <?php 
echo \skeeks\cms\modules\admin\widgets\RelatedModelsGrid::widget(['label' => $shopContent->childrenContent->name, 'parentModel' => $model, 'relation' => ['content_id' => $shopContent->childrenContent->id, 'parent_content_element_id' => $model->id], 'sort' => ['defaultOrder' => ['priority' => 'published_at']], 'controllerRoute' => 'shop/admin-cms-content-element', 'gridViewOptions' => ['columns' => (array) \skeeks\cms\shop\controllers\AdminCmsContentElementController::getColumns($shopContent->childrenContent)]]);
?>

        <? endif; ?>

    </div>
<? endif; ?>


<?php 
echo $form->fieldSetEnd();
?>