コード例 #1
0
 /**
  * @inheritdoc
  */
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['index' => ["gridConfig" => [], "columns" => [['class' => \yii\grid\SerialColumn::className()], ['class' => \yii\grid\DataColumn::className(), 'attribute' => 'name', 'format' => 'raw', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
         $widget = new \skeeks\cms\modules\admin\widgets\AdminImagePreviewWidget(['image' => $shopBasket->product->cmsContentElement->image]);
         return $widget->run();
     }], ['class' => \yii\grid\DataColumn::className(), 'attribute' => 'name', 'format' => 'raw', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
         if ($shopBasket->product) {
             return Html::a($shopBasket->name, $shopBasket->product->cmsContentElement->url, ['target' => '_blank', 'titla' => \Yii::t('skeeks/shop/app', 'Watch Online'), 'data-pjax' => 0]);
         } else {
             return $shopBasket->name;
         }
     }], ['class' => \yii\grid\DataColumn::className(), 'attribute' => 'quantity', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
         return $shopBasket->quantity . " " . $shopBasket->measure_name;
     }], ['class' => \yii\grid\DataColumn::className(), 'label' => \Yii::t('skeeks/shop/app', 'Price'), 'attribute' => 'price', 'format' => 'raw', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
         if ($shopBasket->discount_value) {
             return "<span style='text-decoration: line-through;'>" . \Yii::$app->money->intlFormatter()->format($shopBasket->moneyOriginal) . "</span><br />" . Html::tag('small', $shopBasket->notes) . "<br />" . \Yii::$app->money->intlFormatter()->format($shopBasket->money) . "<br />" . Html::tag('small', \Yii::t('skeeks/shop/app', 'Discount') . ": " . $shopBasket->discount_value);
         } else {
             return \Yii::$app->money->intlFormatter()->format($shopBasket->money) . "<br />" . Html::tag('small', $shopBasket->notes);
         }
     }], ['class' => \yii\grid\DataColumn::className(), 'label' => \Yii::t('skeeks/shop/app', 'Sum'), 'attribute' => 'price', 'format' => 'raw', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
         return \Yii::$app->money->intlFormatter()->format($shopBasket->money->multiply($shopBasket->quantity));
     }]]]]);
 }
コード例 #2
0
ファイル: _form.php プロジェクト: 3737002/cms-shop
    <?php 
echo \skeeks\cms\modules\admin\widgets\BlockTitleWidget::widget(['content' => 'Комментарий']);
?>
    <?php 
echo \yii\widgets\DetailView::widget(['model' => $model, 'template' => "<tr><th style='width: 50%; text-align: right;'>{label}</th><td>{value}</td></tr>", 'attributes' => [['label' => \skeeks\cms\shop\Module::t('app', 'Comment'), 'format' => 'raw', 'value' => $form->field($model, 'comments')->textarea(['rows' => 5])->hint(\skeeks\cms\shop\Module::t('app', 'Internal comment, the customer (buyer) does not see'))->label(false)]]]);
?>


    <?php 
echo \skeeks\cms\modules\admin\widgets\BlockTitleWidget::widget(['content' => \skeeks\cms\shop\Module::t('app', 'The composition of the order')]);
?>

        <?php 
echo \skeeks\cms\modules\admin\widgets\GridView::widget(['dataProvider' => new \yii\data\ArrayDataProvider(['models' => $model->shopBaskets]), 'layout' => "{items}\n{pager}", 'columns' => [['class' => \yii\grid\SerialColumn::className()], ['class' => \yii\grid\DataColumn::className(), 'attribute' => 'name', 'format' => 'raw', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
    $widget = new \skeeks\cms\modules\admin\widgets\AdminImagePreviewWidget(['image' => $shopBasket->product->cmsContentElement->image]);
    return $widget->run();
}], ['class' => \yii\grid\DataColumn::className(), 'attribute' => 'name', 'format' => 'raw', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
    if ($shopBasket->product) {
        return Html::a($shopBasket->name, $shopBasket->product->cmsContentElement->url, ['target' => '_blank', 'titla' => "Смотреть на сайте", 'data-pjax' => 0]);
    } else {
        return $shopBasket->name;
    }
}], ['class' => \yii\grid\DataColumn::className(), 'attribute' => 'quantity', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
    return $shopBasket->quantity . " " . $shopBasket->measure_name;
}], ['class' => \yii\grid\DataColumn::className(), 'label' => \skeeks\cms\shop\Module::t('app', 'Price'), 'attribute' => 'price', 'format' => 'raw', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
    if ($shopBasket->discount_value) {
        return "<span style='text-decoration: line-through;'>" . \Yii::$app->money->intlFormatter()->format($shopBasket->moneyOriginal) . "</span><br />" . Html::tag('small', $shopBasket->notes) . "<br />" . \Yii::$app->money->intlFormatter()->format($shopBasket->money) . "<br />" . Html::tag('small', \skeeks\cms\shop\Module::t('app', 'Discount') . ": " . $shopBasket->discount_value);
    } else {
        return \Yii::$app->money->intlFormatter()->format($shopBasket->money) . "<br />" . Html::tag('small', $shopBasket->notes);
    }
}], ['class' => \yii\grid\DataColumn::className(), 'label' => \skeeks\cms\shop\Module::t('app', 'Sum'), 'attribute' => 'price', 'format' => 'raw', 'value' => function (\skeeks\cms\shop\models\ShopBasket $shopBasket) {
コード例 #3
0
 /**
  * @param \skeeks\cms\shop\models\ShopBasket $model
  * @param mixed $key
  * @param int $index
  * @return null|string
  */
 protected function renderDataCellContent($model, $key, $index)
 {
     $widget = new \skeeks\cms\modules\admin\widgets\AdminImagePreviewWidget(['image' => $model->image]);
     return $widget->run();
 }