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;
$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;
$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'));
}
}
use kartik\select2\Select2;
use yii_app\helpers\HtmlHelper;
-
+use yii_app\records\SalesWriteOffsPlan;
/* @var $model DynamicModel */
/* @var $years array */
/* @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]);
<?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; ?>