<div class="grid-view px-5">
<?= GridView::widget([
'dataProvider' => $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 = "<div class='row'>";
-
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 .= "
- <div class='row border-bottom mb-1'>
- <div class='col-md-9 fw-bold'>{$productName}</div>
- <div class='col-md-3 fw-bold text-right'>{$item->count}</div>
- </div>";
+ <div class='row border-bottom mb-1'>
+ <div class='col-md-9 fw-bold'>{$productName}</div>
+ <div class='col-md-3 fw-bold text-right'>{$item->count}</div>
+ </div>";
}
}
+ $compositionHtml .= "</div>";
- $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 .= "</div>";
+ $allImageUrls = array_map(fn($file) => Url::to($file->url), $images);
+ $previewImageUrls = array_slice($allImageUrls, 0, 3);
+ $previewImageUrls += array_fill(0, 3 - count($previewImageUrls), null);
- return "
- <div class='matrix-data mx-3'>
- <div class='col-md-1'></div>
- <div class='col-md-4'>
- <h4>{$model->name}</h4>
- <div class='bg-white border rounded shadow-sm'
- style='height: 160px; padding: 10px; overflow-y: auto; overflow-x: hidden; max-width: 100%; word-wrap: break-word;'>
- {$compositionHtml}
- </div>
- <div class='self-cost pt-3'>
+ $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;'
+ ]);
+ }
+ }
+
+ $html = "
+ <div class='matrix-data mx-3'>
+ <div class='col-md-1'></div>
+ <div class='col-md-4'>
+ <h4>{$model->name}</h4>
+ <div class='bg-white border rounded shadow-sm'
+ style='height: 160px; padding: 10px; overflow-y: auto; overflow-x: hidden; max-width: 100%; word-wrap: break-word;'>
+ {$compositionHtml}
+ </div>
- <div class='self-cost pt-3' style='display: flex; gap: 10px;'>
- Себестоимость: " . $model->getSelfCost() . "<br>
- Наценка: " . $model->getMarkUp() . "<br>
- Цена: " . $model->getCost() . "<br>
++ <div class='self-cost pt-3'>
+ <div><strong>Нижегородская обл.</strong></div>
+ <div>
- Себестоимость: " . round($model->getSelfCost()) . "₽<br>
- Наценка: +30% / +" . round(BouquetComposition::PROCENT_30 * $model->getSelfCost()) . "₽<br>
- Цена: " . round($model->getBouquetCost(BouquetComposition::REGION_NN)) . "₽. +" . round($model->getBouquetCostMarkup(BouquetComposition::REGION_NN), 2) . "%<br>
++ Себестоимость: " . round($model->getSelfCost()) . "₽<br>
++ Наценка: +30% / +" . round(BouquetComposition::PROCENT_30 * $model->getSelfCost()) . "₽<br>
++ Цена: " . round($model->getBouquetCost(BouquetComposition::REGION_NN)) . "₽. +" . round($model->getBouquetCostMarkup(BouquetComposition::REGION_NN), 2) . "%<br>
+ </div>
+ </div>
+ <div class='self-cost pt-3'>
+ <div><strong>Московская обл.</strong></div>
+ <div>
+ Себестоимость: " . round($model->getSelfCost()) . "₽<br>
+ Наценка: +30% / +" . round(BouquetComposition::PROCENT_30 * $model->getSelfCost()) . "₽<br>
+ Цена: " . round($model->getBouquetCost(BouquetComposition::REGIONO_MSK)) . "₽. +" . round($model->getBouquetCostMarkup(BouquetComposition::REGIONO_MSK), 2) . "%<br>
+ </div>
- </div>
+ </div>
+ </div>
+
+ <div class='row'>
+ <div class='col-md-5'>
+ <div class='card' style='aspect-ratio: 1/1; display: flex; overflow: hidden;'>";
+ 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 .= "
</div>
-
- <div class='row'>
- <div class='col-md-5'>
- <div class='card' style='aspect-ratio: 1/1; display: flex; overflow: hidden;'> " .
- Html::img(Url::to($imageUrls[0]), [
- 'style' => 'width: 100%; height: 100%; object-fit: cover;'
- ]) . "
- </div>
- </div>
-
- <div class='col-md-2 d-flex flex-column gap-2'>
- <div class='card bg-transparent border-0' style='aspect-ratio: 1/1; width: 100%; flex: 1;'>
+ </div>
+
+ <div class='col-md-2 d-flex flex-column gap-2'>
+ <div class='card bg-transparent border-0' style='aspect-ratio: 1/1; width: 100%; flex: 1;'>
" . 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,
]) . "
- <div class='text-center bg-transparent fw-bold p-0 m-0'>Презентация</div>
- </div>
- <div class='card' style='aspect-ratio: 1/1; width: 100%; flex: 1;'> " .
- Html::img(Url::to($imageUrls[1]), [
- 'style' => 'width: 100%; height: 100%; object-fit: cover;'
- ]) . "
- </div>
- </div>
-
- <div class='col-md-2 d-flex flex-column gap-2'>
- <div class='card bg-transparent border-0' style='aspect-ratio: 1/1; width: 100%; flex: 1;'> " .
- 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
+ <div class='text-center bg-transparent fw-bold p-0 m-0'>Презентация</div>
+ </div>
+ <div class='card' style='aspect-ratio: 1/1; width: 100%; flex: 1;'>";
+ 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 .= "
+ </div>
+ </div>
+
+ <div class='col-md-2 d-flex flex-column gap-2'>
+ <div class='card bg-transparent border-0' style='aspect-ratio: 1/1; width: 100%; flex: 1;'>
+ " . 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,
]) . "
- <div class='text-center bg-transparent fw-bold'>Процесс сборки</div>
- </div>
- <div class='card' style='aspect-ratio: 1/1; width: 100%; flex: 1;'> " .
- Html::img(is_array($imageUrls) && isset($imageUrls[2]) ? Url::to($imageUrls[2]) : null,
- ['style' => 'width: 100%; height: 100%; object-fit: cover;']) . "
- </div>
- </div>
- <div class='col-md-3 pt-1 text-center'>
- <div class='row'>
- " . (!empty($model->status) ? "
- <label class='h5 fw-bold mb-1'>Статус букета</label>
- <span class='badge " .
- match ($model->status) {
- WriteOffsErp::STATUS_CREATED => 'bg-info',
- WriteOffsErp::STATUS_CONFIRM,
- WriteOffsErp::STATUS_CREATED_1С => '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] ?? '') . "
- </span>
- " : "") . "
- </div>
- " . (!empty($model->error_text) ? "
- <div class='row'>
- <label class='h5 fw-bold mb-1'>Ошибка</label>
- <span class='badge bg-danger fs-6 text-white w-100 mb-4 d-block' style='word-wrap: break-word; white-space: normal;'>
- " . Html::encode($model->error_text) . "
- </span>
- </div>
- " : "") . "
- </div>
- <div class='row mt-auto text-center'>
- <div class='col-md-7'></div>
- <div class='col-md-2'>
- " .
- Html::a('Редактировать', Url::to(['/bouquet/view', 'id' => $model['id']]), [
+ <div class='text-center bg-transparent fw-bold'>Процесс сборки</div>
+ </div>
+ <div class='card' style='aspect-ratio: 1/1; width: 100%; flex: 1;'>";
+ 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 .= "
+ </div>
+ </div>
+ <div class='col-md-3 pt-1 text-center'>
+ <div class='row'>
+ " . (!empty($model->status) ? "
+ <label class='h5 fw-bold mb-1'>Статус букета</label>
+ <span class='badge " .
+ match ($model->status) {
+ WriteOffsErp::STATUS_CREATED => 'bg-info',
+ WriteOffsErp::STATUS_CONFIRM,
+ WriteOffsErp::STATUS_CREATED_1С => '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] ?? '') . "
+ </span>
+ " : "") . "
+ </div>
+ " . (!empty($model->error_text) ? "
+ <div class='row'>
+ <label class='h5 fw-bold mb-1'>Ошибка</label>
+ <span class='badge bg-danger fs-6 text-white w-100 mb-4 d-block' style='word-wrap: break-word; white-space: normal;'>
+ " . Html::encode($model->error_text) . "
+ </span>
+ </div>
+ " : "") . "
+ </div>
+ <div class='row mt-auto text-center'>
+ <div class='col-md-7'></div>
+ <div class='col-md-2'>
+ " . 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' : ''),
- ])
- . "
- </div>
- </div>
+ ]) . "
</div>
- </div>";
+ </div>
+ </div>
+ " . $hiddenLinks . "
+ </div>";
+ return $html;
},
'contentOptions' => ['class' => 'align-top'],
- 'headerOptions' => ['style' => 'display:none'],
+ 'headerOptions' => ['style' => 'display:none'],
],
],
]) ?>