From: Alexander Smirnov Date: Thu, 3 Apr 2025 07:51:06 +0000 (+0300) Subject: Merge branch 'develop' into feature_smirnov_erp-381_edit_price_and_show_nacenka X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=1746c62a342fdd8bba2661b90f2581fe25f7598b;p=erp24_rep%2Fyii-erp24%2F.git Merge branch 'develop' into feature_smirnov_erp-381_edit_price_and_show_nacenka # Conflicts: # erp24/views/bouquet/index.php --- 1746c62a342fdd8bba2661b90f2581fe25f7598b diff --cc erp24/views/bouquet/index.php index 54ff5662,c46ae151..20065f35 --- a/erp24/views/bouquet/index.php +++ b/erp24/views/bouquet/index.php @@@ -10,9 -10,12 +10,13 @@@ use yii_app\records\Files use yii_app\records\MatrixType; use yii_app\records\Products1c; use yii_app\records\WriteOffsErp; +use yii_app\records\BouquetCompositionPrice; + use yii\web\View; /** @var yii\web\View $this */ + + $this->registerCssFile('@web/css/lightbox.min.css'); + $this->registerJsFile('@web/js/lightbox.min.js', ['position' => View::POS_END]); $this->title = 'Содержание матрицы'; ?>
@@@ -72,163 -75,188 +76,193 @@@
$dataProvider, - 'layout' => "{items}\n{pager}", + 'layout' => "{items}\n{pager}", 'tableOptions' => ['class' => 'table'], - 'columns' => [ + 'columns' => [ [ - 'attribute' => 'name', - 'format' => 'raw', - 'value' => function ($model) { + 'attribute' => 'name', + 'format' => 'raw', + 'value' => function ($model) { $compositionHtml = "
"; - if (is_array($model->bouquetCompositionProducts)) { foreach ($model->bouquetCompositionProducts as $item) { - $product = Products1c::findOne($item->product_guid); + $product = Products1c::findOne($item->product_guid); $productName = $product ? $product->name : 'Неизвестный продукт'; - $compositionHtml .= " -
-
{$productName}
-
{$item->count}
-
"; +
+
{$productName}
+
{$item->count}
+
"; } } + $compositionHtml .= "
"; - $images = Files::find() - ->where(['entity_id' => $model->id, 'entity' => \yii_app\records\BouquetComposition::PHOTO_BOUQUET]) - ->limit(3) + $images = Files::find() + ->where([ + 'entity_id' => $model->id, + 'entity' => BouquetComposition::PHOTO_BOUQUET + ]) ->all(); - $imageUrls = array_map(fn($file) => Url::to($file->url), $images); - $imageUrls += array_fill(0, 3 - count($imageUrls), null); - $compositionHtml .= "
"; + $allImageUrls = array_map(fn($file) => Url::to($file->url), $images); + $previewImageUrls = array_slice($allImageUrls, 0, 3); + $previewImageUrls += array_fill(0, 3 - count($previewImageUrls), null); + + $galleryId = 'gallery-' . $model->id; + + $hiddenLinks = ""; + if (count($allImageUrls) > 3) { + foreach (array_slice($allImageUrls, 3) as $url) { + $hiddenLinks .= Html::a('', $url, [ + 'data-lightbox' => $galleryId, + 'style' => 'display:none;' + ]); + } + } + $cmNN = $model->getCostModel(BouquetComposition::REGION_NN); + $cmMsk = $model->getCostModel(BouquetComposition::REGION_MSK); + /* @var $cmNN BouquetCompositionPrice */ + /* @var $cmMsk BouquetCompositionPrice */ - return " ++ + $html = " -
-
-
-

{$model->name}

-
- {$compositionHtml} -
-
+
-
++
+
+

{$model->name}

-
+ {$compositionHtml} +
+
Нижегородская обл.
- Себестоимость: " . round($model->getSelfCost()) . "₽
- Наценка: +30% / +" . round(BouquetComposition::PROCENT_30 * $model->getSelfCost()) . "₽
- Цена: " . round($model->getBouquetCost(BouquetComposition::REGION_NN)) . "₽. +" . round($model->getBouquetCostMarkup(BouquetComposition::REGION_NN), 2) . "%
+ Себестоимость: " . round($cmNN->selfcost) . "₽
+ Наценка: +". round($cmNN->selfcost_markup) ."% / +" . round($cmNN->selfcost_markup_price) . "₽
+ Цена: " . round($cmNN->price) . "₽. +" . round($cmNN->price_markup, 2) . "%
Московская обл.
- Себестоимость: " . round($model->getSelfCost()) . "₽
- Наценка: +30% / +" . round(BouquetComposition::PROCENT_30 * $model->getSelfCost()) . "₽
- Цена: " . round($model->getBouquetCost(BouquetComposition::REGIONO_MSK)) . "₽. +" . round($model->getBouquetCostMarkup(BouquetComposition::REGIONO_MSK), 2) . "%
+ Себестоимость: " . round($cmMsk->selfcost) . "₽
+ Наценка: +". round($cmMsk->selfcost_markup) ."% / +" . round($cmMsk->selfcost_markup_price) . "₽
+ Цена: " . round($cmMsk->price) . "₽. +" . round($cmMsk->price_markup, 2) . "%
-
+
+
+ +
+
+
"; + if (isset($previewImageUrls[0])) { + $html .= Html::a( + Html::img($previewImageUrls[0], [ + 'style' => 'width: 100%; height: 100%; object-fit: cover;', + ]), + $previewImageUrls[0], + ['data-lightbox' => $galleryId] + ); + } + $html .= "
- -
-
-
" . - Html::img(Url::to($imageUrls[0]), [ - 'style' => 'width: 100%; height: 100%; object-fit: cover;' - ]) . " -
-
- -
-
+
+ +
+
" . Html::tag('video', '', [ - 'class' => 'video-preview', - 'src' => Url::to($model->presentation->url ?? null), - 'style' => 'width: 100%; height: 100%; object-fit: cover;', - 'autoplay' => true, - 'muted' => true, - 'loop' => true, - 'playsinline' => true + 'class' => 'video-preview', + 'src' => Url::to($model->presentation->url ?? null), + 'style' => 'width: 100%; height: 100%; object-fit: cover;', + 'autoplay' => true, + 'muted' => true, + 'loop' => true, + 'playsinline' => true, ]) . " -
Презентация
-
-
" . - Html::img(Url::to($imageUrls[1]), [ - 'style' => 'width: 100%; height: 100%; object-fit: cover;' - ]) . " -
-
- -
-
" . - Html::tag('video', '', [ - 'class' => 'video-preview', - 'src' => Url::to($model->buildProcess->url ?? null), - 'style' => 'width: 100%; height: 100%; object-fit: cover;', - 'autoplay' => true, - 'muted' => true, - 'loop' => true, - 'playsinline' => true +
Презентация
+
+
"; + if (isset($previewImageUrls[1])) { + $html .= Html::a( + Html::img($previewImageUrls[1], [ + 'style' => 'width: 100%; height: 100%; object-fit: cover;', + ]), + $previewImageUrls[1], + ['data-lightbox' => $galleryId] + ); + } + $html .= " +
+
+ +
+
+ " . Html::tag('video', '', [ + 'class' => 'video-preview', + 'src' => Url::to($model->buildProcess->url ?? null), + 'style' => 'width: 100%; height: 100%; object-fit: cover;', + 'autoplay' => true, + 'muted' => true, + 'loop' => true, + 'playsinline' => true, ]) . " -
Процесс сборки
-
-
" . - Html::img(is_array($imageUrls) && isset($imageUrls[2]) ? Url::to($imageUrls[2]) : null, - ['style' => 'width: 100%; height: 100%; object-fit: cover;']) . " -
-
-
-
- " . (!empty($model->status) ? " - - 'bg-success', - WriteOffsErp::STATUS_SEND => 'bg-warning', - WriteOffsErp::STATUS_DISABLE, - WriteOffsErp::STATUS_ERROR_1С => 'bg-danger', - default => 'bg-secondary', - } . - " fs-6 text-white px-7 w-100 mb-4 d-block'> - " . Html::encode(\yii_app\records\WriteOffsErp::STATUSES[$model->status] ?? '') . " - - " : "") . " -
- " . (!empty($model->error_text) ? " -
- - - " . Html::encode($model->error_text) . " - -
- " : "") . " -
-
-
-
- " . - Html::a('Редактировать', Url::to(['/bouquet/view', 'id' => $model['id']]), [ +
Процесс сборки
+
+
"; + if (isset($previewImageUrls[2])) { + $html .= Html::a( + Html::img($previewImageUrls[2], [ + 'style' => 'width: 100%; height: 100%; object-fit: cover;' + ]), + $previewImageUrls[2], + ['data-lightbox' => $galleryId] + ); + } + $html .= " +
+
+
+
+ " . (!empty($model->status) ? " + + 'bg-success', + WriteOffsErp::STATUS_SEND => 'bg-warning', + WriteOffsErp::STATUS_DISABLE, + WriteOffsErp::STATUS_ERROR_1С => 'bg-danger', + default => 'bg-secondary', + } . + " fs-6 text-white px-7 w-100 mb-4 d-block'> + " . Html::encode(WriteOffsErp::STATUSES[$model->status] ?? '') . " + + " : "") . " +
+ " . (!empty($model->error_text) ? " +
+ + + " . Html::encode($model->error_text) . " + +
+ " : "") . " +
+
+
+
+ " . Html::a('Редактировать', Url::to(['/bouquet/view', 'id' => $model['id']]), [ 'class' => 'btn btn-warning btn-edit' - // . - // ((Yii::$app->request->get('year') < date('Y') || // Если год в прошлом → disabled - // (Yii::$app->request->get('year') == date('Y') && Yii::$app->request->get('month') < date('m')) || - // (Yii::$app->request->get('year') == date('Y') && Yii::$app->request->get('month') == date('m') && BouquetComposition::disabledButtons()) || - // (Yii::$app->request->get('year') == date('Y') && Yii::$app->request->get('month') == date('m') + 1 &&BouquetComposition::disabledButtons()) - // ) ? ' disabled' : ''), - ]) - . " -
-
+ ]) . "
-
"; +
+
+ " . $hiddenLinks . " +
"; + return $html; }, 'contentOptions' => ['class' => 'align-top'], - 'headerOptions' => ['style' => 'display:none'], + 'headerOptions' => ['style' => 'display:none'], ], ], ]) ?>