]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-283] планы взяты из /sales-write-offs-plan
authorAlexander Smirnov <fredeom@mail.ru>
Wed, 22 Jan 2025 11:05:54 +0000 (14:05 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Wed, 22 Jan 2025 11:05:54 +0000 (14:05 +0300)
erp24/controllers/CategoryPlanController.php
erp24/views/category-plan/index.php

index 80fdfaaf7b626a32ebdb5bc63f79db509a941015..69f8de5ab4896ab0f8db470d70ca0a904264ec42 100644 (file)
@@ -9,6 +9,7 @@ use yii\web\Controller;
 use yii_app\records\CityStore;
 use yii_app\records\ExportImportTable;
 use yii_app\records\Sales;
+use yii_app\records\SalesWriteOffsPlan;
 use yii_app\records\WriteOffs;
 use yii_app\records\WriteOffsErp;
 
@@ -116,6 +117,8 @@ class CategoryPlanController extends Controller {
         $types = array_keys($types);
         /////////////////////////////////////////////////////////////////////////////////////
 
+        $salesWriteOffsPlan = SalesWriteOffsPlan::find()->where(['year' => $model->year, 'month' => $model->month, 'store_id' => $model->store_id])->one();
+
         $years = [];
         for ($i = 3; $i >= 0; $i--) {
             $year = date("Y") - $i;
@@ -124,6 +127,6 @@ class CategoryPlanController extends Controller {
         $stores = ArrayHelper::map(CityStore::find()->andWhere(['visible' => '1'])->all(), 'id', 'name');
 
         return $this->render('index', compact('model', 'years', 'stores', 'table', 'tableOnline',
-            'tableWriteOffs', 'types'));
+            'tableWriteOffs', 'types', 'salesWriteOffsPlan'));
     }
 }
index 3df10e13413156339cc1528054b5a708617f02b2..a86f2dff24574d5c3524314b21849277573e4750 100644 (file)
@@ -5,7 +5,7 @@ use yii\widgets\ActiveForm;
 
 use kartik\select2\Select2;
 use yii_app\helpers\HtmlHelper;
-
+use yii_app\records\SalesWriteOffsPlan;
 
 /* @var $model DynamicModel */
 /* @var $years array */
@@ -14,6 +14,7 @@ use yii_app\helpers\HtmlHelper;
 /* @var $tableOnline array */
 /* @var $types array */
 /* @var $tableWriteOffs array */
+/* @var $salesWriteOffsPlan SalesWriteOffsPlan */
 
 $this->registerJsFile('/js/category-plan/index.js', ['position' => \yii\web\View::POS_END]);
 
@@ -61,26 +62,33 @@ $this->registerJsFile('/js/category-plan/index.js', ['position' => \yii\web\View
     <?php if (isset($model->store_id)): ?>
         <div class="table-responsive" style="max-width: 1285px;">
             <table id="categoryPlan">
+                <?php
+                $offline_sale = $salesWriteOffsPlan->offline_sales_plan;
+                $online_sale = $salesWriteOffsPlan->online_sales_shop_plan;
+                $write_offs = $salesWriteOffsPlan->write_offs_plan;
+                ?>
                 <thead>
-                    <tr><th rowspan="4" class="text-center align-middle border">Категории</th><th colspan="6" class="text-center border">План продаж</th><th colspan="2" class="text-center border">Списания</th></tr>
-                    <tr><th colspan="2" class="text-center border">Оффлайн</th><th colspan="2" class="text-center border">Интернет-Магазин</th><th colspan="2" class="text-center border">Маркетплейс</th><th colspan="2" class="text-center border">Списания</th></tr>
-                    <tr><th colspan="2" class="text-center border">1 100 000</th><th colspan="2" class="text-center border">800 000</th><th colspan="2" class="text-center border">0</th><th colspan="2" class="text-center border">300 000</th></tr>
-                    <tr><th class="text-center border">%</th><th class="text-center border">Сумма</th><th class="text-center border">%</th><th class="text-center border">Cумма</th><th class="text-center border">%</th><th class="text-center border">Cумма</th><th class="text-center border">%</th><th class="text-center border">Cумма</th></tr>
+                    <tr><th rowspan="4" class="text-center align-middle border">Категории</th><th colspan="4" class="text-center border">План продаж</th><th colspan="2" class="text-center border">Списания</th></tr>
+                    <tr><th colspan="2" class="text-center border">Оффлайн</th><th colspan="2" class="text-center border">Интернет-Магазин</th><!--th colspan="2" class="text-center border">Маркетплейс</th--><th colspan="2" class="text-center border">Списания</th></tr>
+                    <tr><th colspan="2" class="text-center border"><?= number_format($offline_sale, 0, '.', ' ') ?></th>
+                        <th colspan="2" class="text-center border"><?= number_format($online_sale, 0, '.', ' ') ?></th><!--th colspan="2" class="text-center border">0</th-->
+                        <th colspan="2" class="text-center border"><?= number_format($write_offs, 0, '.', ' ') ?></th></tr>
+                    <tr><th class="text-center border">%</th><th class="text-center border">Сумма</th><th class="text-center border">%</th><th class="text-center border">Cумма</th><!--th class="text-center border">%</th><th class="text-center border">Cумма</th--><th class="text-center border">%</th><th class="text-center border">Cумма</th></tr>
                 </thead>
                 <tbody>
                     <?php foreach ($types as $type): ?>
                         <?php $data = $table[$model->store_id][$type] ?? 0; ?>
                         <tr>
                             <th><?= $type ?></th>
-                            <td><?= number_format($data / 110000 * 100, 0, '.', ' ') ?>%</td>
+                            <td><?= number_format($offline_sale <= 0 ? 0 : $data / $offline_sale * 100, 0, '.', ' ') ?>%</td>
                             <td><?= number_format($data, 0, '.', ' ') ?></td>
                             <?php $data2 = $tableOnline[$model->store_id][$type] ?? 0; ?>
-                            <td><?= number_format($data2 / 800000 * 100, 0, '.', ' ') ?>%</td>
+                            <td><?= number_format($online_sale <= 0 ? 0 : $data2 / $online_sale * 100, 0, '.', ' ') ?>%</td>
                             <td><?= number_format($data2, 0, '.', ' ') ?></td>
-                            <td></td>
-                            <td></td>
+                            <!--td></td>
+                            <td></td-->
                             <?php $data4 = $tableWriteOffs[$type] ?? 0; ?>
-                            <td><?= number_format($data4 / 300000 * 100, 0, '.', ' ') ?>%</td>
+                            <td><?= number_format($write_offs <= 0 ? 0 : $data4 / $write_offs * 100, 0, '.', ' ') ?>%</td>
                             <td><?= number_format($data4, 0, '.', ' ') ?></td>
                         </tr>
                     <?php endforeach; ?>