From b96367768ef9a3e8c1c7e2cceec656ce7d9bc173 Mon Sep 17 00:00:00 2001 From: vladfo Date: Fri, 11 Oct 2024 16:57:06 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=D0=B8?= =?utf8?q?=20=D1=80=D0=B0=D1=81=D1=87=D0=B5=D1=82=20=D0=BF=D1=80=D0=BE?= =?utf8?q?=D0=B4=D0=B0=D0=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../actions/motivation/TestSelfCostAction.php | 1 + erp24/views/motivation/test-self-cost.php | 113 +++++++++++------- 2 files changed, 68 insertions(+), 46 deletions(-) diff --git a/erp24/actions/motivation/TestSelfCostAction.php b/erp24/actions/motivation/TestSelfCostAction.php index f88f4421..09cd8c1d 100644 --- a/erp24/actions/motivation/TestSelfCostAction.php +++ b/erp24/actions/motivation/TestSelfCostAction.php @@ -64,6 +64,7 @@ class TestSelfCostAction extends Action 'product_id' => $productId, 'product_name' => $item['product_name'], 'price' => $item['price'], + 'm_price' => $item['m_price'], 'quantity' => $item['quantity'], ]; } else { diff --git a/erp24/views/motivation/test-self-cost.php b/erp24/views/motivation/test-self-cost.php index 8e0180ec..bc17c5da 100644 --- a/erp24/views/motivation/test-self-cost.php +++ b/erp24/views/motivation/test-self-cost.php @@ -2,6 +2,7 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; use kartik\select2\Select2; +use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $storeList array */ @@ -41,55 +42,75 @@ $this->title = 'Себестоимость товаров по магазина

Результаты (Полные данные)

- - - - - - - - - - - - - - - - - - - - - - - - - -
ID товараID чекаНазваниеСебестоимостьЦенаКол-воДата
+ new \yii\data\ArrayDataProvider([ + 'allModels' => $data, + 'pagination' => false, + ]), + 'showFooter' => true, + 'columns' => [ + ['attribute' => 'product_id', 'label' => 'ID товара'], + ['attribute' => 'check_id', 'label' => 'ID чека'], + ['attribute' => 'product_name', 'label' => 'Название'], + ['attribute' => 'm_price', 'label' => 'Цена'], + ['attribute' => 'price', 'label' => 'Себестоимость ед'], + [ + 'attribute' => 'quantity', + 'label' => 'Кол-во', + 'footer' => array_sum(array_column($data, 'quantity')), + ], + [ + 'label' => 'Себестоимость итого', + 'value' => function ($model) { + return $model['price'] * $model['quantity']; + }, + 'footer' => array_sum(array_map(function ($item) { + return $item['price'] * $item['quantity']; + }, $data)), + ], + ['attribute' => 'date', 'label' => 'Дата'], + ], + ]); ?> +

Общая стоимость:

Сумма всех товаров:

Результаты (Уникальные товары)

- - - - - - - - - - - - - - - - - - - -
ID товараНазваниеЦенаОбщее кол-во
+ new \yii\data\ArrayDataProvider([ + 'allModels' => $uniqueProductsData, + 'pagination' => false, + ]), + 'showFooter' => true, + 'columns' => [ + ['attribute' => 'product_id', 'label' => 'ID товара'], + ['attribute' => 'product_name', 'label' => 'Название'], + ['attribute' => 'price', 'label' => 'Себестоимость ед'], + ['attribute' => 'm_price', 'label' => 'Цена ед'], + [ + 'attribute' => 'quantity', + 'label' => 'Общее кол-во', + 'footer' => array_sum(array_column($uniqueProductsData, 'quantity')), + ], + [ + 'label' => 'Себестоимость * Кол-во', + 'value' => function ($model) { + return $model['price'] * $model['quantity']; + }, + 'footer' => array_sum(array_map(function ($item) { + return $item['price'] * $item['quantity']; + }, $uniqueProductsData)), + ], + [ + 'label' => 'Цена * Кол-во', + 'value' => function ($model) { + return $model['m_price'] * $model['quantity']; + }, + 'footer' => array_sum(array_map(function ($item) { + return $item['m_price'] * $item['quantity']; + }, $uniqueProductsData)), + ], + ], + ]); ?> \ No newline at end of file -- 2.39.5