]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Вывод расчетов
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 16 Apr 2025 06:45:08 +0000 (09:45 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 16 Apr 2025 06:45:08 +0000 (09:45 +0300)
erp24/controllers/BouquetController.php
erp24/services/StorePlanService.php
erp24/views/bouquet/month-goal.php

index e3e0f85ae1fd2d5b9875e6597f30c002ca6a44ab..6adf096b67472cd58d66503987de21437ba7fe40 100644 (file)
@@ -253,22 +253,22 @@ class BouquetController extends Controller
         return $data;
     }
 
-    public function actionMonthGoal($month, $year)
+    public function actionMonthGoal()
     {
+        $request = Yii::$app->request;
+
+        $month = $request->post('month') ? (int)$request->post('month') : 5;
+        $year = $request->post('year') ? (int)$request->post('year') : 2025;
 
         $result = StorePlanService::getBouquetSpiecesMonthGoal($month, $year);
 
-        $month = $month ?? 5;
-        $year = $year ?? 2025;
         $stores = CityStore::find()
             ->select(['id', 'name'])
             ->where(['visible' => CityStore::IS_VISIBLE])
             ->asArray()
             ->all();
-
         $storesMap = ArrayHelper::map($stores, 'id', 'name');
 
-
         return $this->render('month-goal', [
             'result'    => $result,
             'storesMap' => $storesMap,
index 98bab0ec4ba62371fc268479f6aa8291c994761b..4137efd3cb00590aec8f2e95cf88d263380c43e3 100755 (executable)
@@ -863,7 +863,6 @@ class StorePlanService
         $finalResult = [];
         foreach ($resultArr as $typeSalesId => $speciesData) {
             foreach ($speciesData as $species => $salesDetails) {
-                // Здесь $salesDetails — это массив вида [storeSalesType1 => cost1, storeSalesType2 => cost2, …]
                 $finalResult[$typeSalesId][$species] = round(array_sum($salesDetails), 2);
             }
         }
index a6ff09ca25b5dbf340f071d9bc9150f304874340..29a078427c26b532414f6ff3624b7c438f61974d 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+use yii\helpers\Html;
+use yii\helpers\Url;
+
 /* @var $result array   // Массив с ключами 'detail' и 'final'
 @var $storesMap array // Маппинг [store_id => store_name]
 @var $month integer
@@ -7,6 +10,20 @@
 ?>
 <h1>Цели на месяц: <?= $month ?>/<?= $year ?></h1>
 
+<!-- Форма для выбора месяца и года -->
+<?= Html::beginForm(Url::to(['bouquet/month-goal']), 'post') ?>
+<label for="month">Месяц:</label>
+<?= Html::input('number', 'month', $month, ['min' => 1, 'max' => 12]) ?>
+
+<label for="year">Год:</label>
+<?= Html::input('number', 'year', $year, ['min' => 2000, 'max' => 2100]) ?>
+
+<?= Html::submitButton('Показать', ['class' => 'btn btn-primary']) ?>
+<?= Html::endForm() ?>
+
+<hr>
+
+<!-- Таблица для итоговых сумм ('final') -->
 <h2>Итоговые суммы по магазинам и видам продукции</h2>
 <table border="1" cellpadding="5" cellspacing="0">
     <thead>
     <?php if (!empty($result['final'])): ?>
         <?php foreach ($result['final'] as $storeId => $speciesData): ?>
             <?php
-            // Ð\9eпÑ\80еделÑ\8fем Ð¸Ð¼Ñ\8f Ð¼Ð°Ð³Ð°Ð·Ð¸Ð½Ð° Ð¿Ð¾ mapping'Ñ\83, ÐµÑ\81ли Ð¾Ð½Ð¾ Ð¾Ñ\82Ñ\81Ñ\83Ñ\82Ñ\81Ñ\82вÑ\83еÑ\82 – выводим id
+            // Ð\95Ñ\81ли Ð¸Ð¼Ñ\8f Ð¼Ð°Ð³Ð°Ð·Ð¸Ð½Ð° Ð¾Ñ\82Ñ\81Ñ\83Ñ\82Ñ\81Ñ\82вÑ\83еÑ\82 Ð² mapping'е – выводим id
             $storeName = isset($storesMap[$storeId]) ? $storesMap[$storeId] : $storeId;
             ?>
             <?php foreach ($speciesData as $species => $sum): ?>
                 <tr>
-                    <td><?= htmlspecialchars($storeName) ?></td>
-                    <td><?= htmlspecialchars($species) ?></td>
+                    <td><?= Html::encode($storeName) ?></td>
+                    <td><?= Html::encode($species) ?></td>
                     <td><?= $sum ?></td>
                 </tr>
             <?php endforeach; ?>
         </tr>
     <?php endif; ?>
     </tbody>
+</table>
+
+<!-- Таблица для подробного расчёта ('detail') -->
+<h2>Подробный расчёт по магазинам</h2>
+<table border="1" cellpadding="5" cellspacing="0">
+    <thead>
+    <tr>
+        <th>Магазин</th>
+        <th>Вид продукции</th>
+        <th>Тип продаж</th>
+        <th>Сумма</th>
+    </tr>
+    </thead>
+    <tbody>
+    <?php if (!empty($result['detail'])): ?>
+        <?php foreach ($result['detail'] as $storeId => $speciesData): ?>
+            <?php
+            // Определяем имя магазина по mapping'у
+            $storeName = isset($storesMap[$storeId]) ? $storesMap[$storeId] : $storeId;
+            ?>
+            <?php foreach ($speciesData as $species => $saleTypes): ?>
+                <?php foreach ($saleTypes as $saleType => $amount): ?>
+                    <tr>
+                        <td><?= Html::encode($storeName) ?></td>
+                        <td><?= Html::encode($species) ?></td>
+                        <td><?= Html::encode($saleType) ?></td>
+                        <td><?= $amount ?></td>
+                    </tr>
+                <?php endforeach; ?>
+            <?php endforeach; ?>
+        <?php endforeach; ?>
+    <?php else: ?>
+        <tr>
+            <td colspan="4">Нет данных для отображения.</td>
+        </tr>
+    <?php endif; ?>
+    </tbody>
 </table>
\ No newline at end of file