]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Merge branch 'develop' into feature_smirnov_erp-381_edit_price_and_show_nacenka origin/feature_smirnov_erp-381_edit_price_and_show_nacenka
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 3 Apr 2025 07:51:06 +0000 (10:51 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 3 Apr 2025 07:51:06 +0000 (10:51 +0300)
# Conflicts:
# erp24/views/bouquet/index.php

1  2 
erp24/controllers/BouquetController.php
erp24/views/bouquet/index.php

index 54ff566228f104be6aaee93183538f6f317b3566,c46ae151d6c742e8f954b9e9c3a1f427dbd23a8c..20065f357a2da7a0ab915cb4147ed165ac447848
@@@ -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 = 'Содержание матрицы';
  ?>
  <div class="bouquet-index p-4">
      <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);
+                         $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;'
+                                 ]);
+                             }
+                         }
  
-                         return "
 +                        $cmNN = $model->getCostModel(BouquetComposition::REGION_NN);
 +                        $cmMsk = $model->getCostModel(BouquetComposition::REGION_MSK);
 +                        /* @var $cmNN BouquetCompositionPrice */
 +                        /* @var $cmMsk BouquetCompositionPrice */
 -                <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'>
++
+                         $html = "
-                         <div class='col-md-1'></div>
 +                        <div class='matrix-data mx-3'>
-                            <div class='bg-white border rounded shadow-sm' 
++                            <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'>
                                      <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($cmNN->selfcost) . "₽<br>
 +                                    Наценка: +". round($cmNN->selfcost_markup)  ."% / +" . round($cmNN->selfcost_markup_price) . "₽<br>
 +                                    Цена: " . round($cmNN->price) . "₽. +" . round($cmNN->price_markup, 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>
 +                                    Себестоимость: " . round($cmMsk->selfcost) . "₽<br>
 +                                    Наценка: +". round($cmMsk->selfcost_markup)  ."% / +" . round($cmMsk->selfcost_markup_price) . "₽<br>
 +                                    Цена: " . round($cmMsk->price) . "₽. +" . round($cmMsk->price_markup, 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'],
                  ],
              ],
          ]) ?>