- $dataProvider,
- 'rowOptions' => function($model) {
- if ($model->removed) {
- return [ 'class' => 'danger' ];
- } else {
- return [];
- }
- },
- 'layout' => '{items}{pager}',
- 'columns' => [
- [
- 'class' => SerialColumn::className(),
- ],
- 'sku',
- [
- 'attribute' => 'product_name',
- 'content' => function($model) {
- if (!empty($model->product_name)) {
+
+ $dataProvider,
+ 'rowOptions' => function ($model) {
+ if ($model->removed) {
+ return [ 'class' => 'danger' ];
+ } else {
+ return [];
+ }
+ },
+ 'layout' => '{items}{pager}',
+ 'columns' => [
+ [
+ 'class' => SerialColumn::className(),
+ ],
+ 'sku',
+ [
+ 'attribute' => 'product_name',
+ 'content' => function ($model) {
+ if (!empty( $model->product_name )) {
+
+ if (empty( $model->productVariant )) {
+ return '';
+ }
+
+ return Html::a(
+ StringHelper::truncate($model->product_name, 10, '...'),
+ '#',
+ [
+ 'onclick' => 'event.preventDefault();',
+ 'data-toggle' => 'popover',
+ 'data-placement' => 'right',
+ 'data-html' => 'true',
+ 'data-content' => Html::img(
+ $model->productVariant->imageUrl,
+ [
+ 'class' => 'img-rounded',
+ ]
+ ) . Html::tag('p', $model->product_name),
+ ]
+ );
+ } else {
+ return '';
+ }
+ },
+ ],
+ [
+ 'attribute' => 'productVariant.product.brand.lang.title',
+ 'label' => 'Брэнд',
+ ],
+ [
+ 'attribute' => 'productVariant.lang.title',
+ 'label' => \Yii::t('app', 'Цвет'),
+ 'content' => function ($model) {
- if (empty($model->productVariant)) {
+ if (empty( $model->productVariant )) {
return '';
- }
-
- return Html::a(
- StringHelper::truncate($model->product_name, 10, '...'),
- '#',
- [
- 'onclick' => 'event.preventDefault();',
- 'data-toggle' => 'popover',
- 'data-placement' => 'right',
- 'data-html' => 'true',
- 'data-content' => Html::img(
- $model->productVariant->imageUrl,
- [
- 'class' => 'img-rounded',
- ]
- ) . Html::tag('p', $model->product_name),
- ]
- );
- } else {
- return '';
- }
- },
- ],
- [
- 'attribute' => 'productVariant.product.brand.lang.title',
- 'label' => 'Брэнд',
- ],
- [
- 'attribute' => 'productVariant.lang.title',
- 'label' => \Yii::t('app', 'Цвет'),
- 'content' => function($model) {
-
- if (empty($model->productVariant)) {
- return '';
- }
-
- if (preg_match('@.*\.(png|jpg|gif)@i', $model->productVariant->lang->title)) {
- return '';
- } else {
- return $model->productVariant->lang->title;
- }
- },
- ],
- [
- 'attribute' => 'productVariant.size',
- 'label' => 'Размер',
- ],
- 'price',
- [
- 'class' => 'kartik\grid\EditableColumn',
- 'attribute' => 'count',
- 'editableOptions' => [
- 'header' => \Yii::t('app', 'Количество'),
- 'inputType' => kartik\editable\Editable::INPUT_SPIN,
- 'options' => [
- 'pluginOptions' => [
- 'min' => 0,
- 'max' => 5000,
- ],
- ],
- 'pluginEvents' => [
- 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }',
- ],
- ],
- 'format' => [
- 'decimal',
- 0,
- ],
- 'pageSummary' => false,
- ],
- 'sum_cost',
- [
- 'class' => 'kartik\grid\EditableColumn',
- 'attribute' => 'booking',
- 'editableOptions' => [
- 'header' => \Yii::t('app', 'Бронь'),
- 'inputType' => kartik\editable\Editable::INPUT_TEXT,
- 'options' => [
- 'class' => 'booking-typeahead',
- 'pluginOptions' => [
- 'min' => 0,
- 'max' => 20,
- ],
- ],
- 'pluginEvents' => [
- 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }',
- ],
- ],
- 'format' => [
- 'text',
- ],
- 'pageSummary' => false,
- ],
- [
- 'class' => 'kartik\grid\EditableColumn',
- 'attribute' => 'status',
- 'editableOptions' => [
- 'header' => \Yii::t('app', 'Статус'),
- 'inputType' => kartik\editable\Editable::INPUT_TEXT,
- 'options' => [
- 'class' => 'status-typeahead',
- 'pluginOptions' => [
- 'min' => 0,
- 'max' => 20,
- ],
- ],
- 'pluginEvents' => [
- 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }',
- ],
- ],
- 'format' => [
- 'text',
- ],
- 'pageSummary' => false,
- ],
- [
- 'class' => 'kartik\grid\EditableColumn',
- 'attribute' => 'return',
- 'editableOptions' => [
- 'header' => \Yii::t('app', 'Возврат'),
- 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX,
- 'options' => [],
- 'pluginEvents' => [
- 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }',
- ],
- ],
- 'format' => [
- 'boolean',
- ],
- 'pageSummary' => false,
- ],
- [
- 'content' => function($model) {
-
- if (empty($model->productVariant)) {
- return '
';
- }
-
- $content = '
Склад | кол. |
';
- foreach ($model->productVariant->variantStocks as $stock) {
- $content .= '' . $stock->stock->title . ' | ' . $stock->quantity . ' |
';
- }
- return Html::a(
- '',
- '#',
- [
- 'onclick' => 'event.preventDefault();',
- 'data-toggle' => 'popover',
- 'data-placement' => 'left',
- 'data-html' => 'true',
- 'data-content' => $content . '
',
- ]
- );
- },
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{delete}',
- 'buttons' => [
- 'delete' => function($url, $product) {
- if ($product->removed) {
- return '';
- } else {
- return Html::a(
- Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]),
- [
- 'delete-product',
- 'id' => $product->id,
- ],
- [
- 'class' => 'delete-button',
- // 'data' => [
- // 'confirm' => 'Вы уверены, что хотите удалить этот элемент?',
- // 'method' => 'GET',
- // ],
- ]
- );
- }
- },
- ],
- ],
- ],
- 'responsive' => true,
- 'hover' => true,
- 'pjax' => true,
- 'pjaxSettings' => [
- 'options' => [
- 'scrollTo' => 'false',
- 'id' => 'order-products-grid',
- ],
- ],
- ]
- );
- ?>
-
+ }
+
+ if (preg_match('@.*\.(png|jpg|gif)@i', $model->productVariant->lang->title)) {
+ return '';
+ } else {
+ return $model->productVariant->lang->title;
+ }
+ },
+ ],
+ [
+ 'attribute' => 'productVariant.size',
+ 'label' => 'Размер',
+ ],
+ 'price',
+ [
+ 'class' => 'kartik\grid\EditableColumn',
+ 'attribute' => 'count',
+ 'editableOptions' => [
+ 'header' => \Yii::t('app', 'Количество'),
+ 'inputType' => kartik\editable\Editable::INPUT_SPIN,
+ 'options' => [
+ 'pluginOptions' => [
+ 'min' => 0,
+ 'max' => 5000,
+ ],
+ ],
+ 'pluginEvents' => [
+ 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }',
+ ],
+ ],
+ 'format' => [
+ 'decimal',
+ 0,
+ ],
+ 'pageSummary' => false,
+ ],
+ 'sum_cost',
+ [
+ 'class' => 'kartik\grid\EditableColumn',
+ 'attribute' => 'booking',
+ 'editableOptions' => [
+ 'header' => \Yii::t('app', 'Бронь'),
+ 'inputType' => kartik\editable\Editable::INPUT_TEXT,
+ 'options' => [
+ 'class' => 'booking-typeahead',
+ 'pluginOptions' => [
+ 'min' => 0,
+ 'max' => 20,
+ ],
+ ],
+ 'pluginEvents' => [
+ 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }',
+ ],
+ ],
+ 'format' => [
+ 'text',
+ ],
+ 'pageSummary' => false,
+ ],
+ [
+ 'class' => 'kartik\grid\EditableColumn',
+ 'attribute' => 'status',
+ 'editableOptions' => [
+ 'header' => \Yii::t('app', 'Статус'),
+ 'inputType' => kartik\editable\Editable::INPUT_TEXT,
+ 'options' => [
+ 'class' => 'status-typeahead',
+ 'pluginOptions' => [
+ 'min' => 0,
+ 'max' => 20,
+ ],
+ ],
+ 'pluginEvents' => [
+ 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }',
+ ],
+ ],
+ 'format' => [
+ 'text',
+ ],
+ 'pageSummary' => false,
+ ],
+ [
+ 'class' => 'kartik\grid\EditableColumn',
+ 'attribute' => 'return',
+ 'editableOptions' => [
+ 'header' => \Yii::t('app', 'Возврат'),
+ 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX,
+ 'options' => [],
+ 'pluginEvents' => [
+ 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }',
+ ],
+ ],
+ 'format' => [
+ 'boolean',
+ ],
+ 'pageSummary' => false,
+ ],
+ [
+ 'content' => function ($model) {
+
+ if (empty( $model->productVariant )) {
+ return '
';
+ }
+
+ $content = '
Склад | кол. |
';
+ foreach ($model->productVariant->variantStocks as $stock) {
+ $content .= '' . $stock->stock->title . ' | ' . $stock->quantity . ' |
';
+ }
+ return Html::a(
+ '',
+ '#',
+ [
+ 'onclick' => 'event.preventDefault();',
+ 'data-toggle' => 'popover',
+ 'data-placement' => 'left',
+ 'data-html' => 'true',
+ 'data-content' => $content . '
',
+ ]
+ );
+ },
+ ],
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => '{delete}',
+ 'buttons' => [
+ 'delete' => function ($url, $product) {
+ if ($product->removed) {
+ return '';
+ } else {
+ return Html::a(
+ Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]),
+ [
+ 'delete-product',
+ 'id' => $product->id,
+ ],
+ [
+ 'class' => 'delete-button',
+ // 'data' => [
+ // 'confirm' => 'Вы уверены, что хотите удалить этот элемент?',
+ // 'method' => 'GET',
+ // ],
+ ]
+ );
+ }
+ },
+ ],
+ ],
+ ],
+ 'responsive' => true,
+ 'hover' => true,
+ 'pjax' => true,
+ 'pjaxSettings' => [
+ 'options' => [
+ 'scrollTo' => 'false',
+ 'id' => 'order-products-grid',
+ ],
+ ],
+ ]
+ );
+ ?>
+