From: vladfo Date: Fri, 11 Oct 2024 13:57:06 +0000 (+0300) Subject: Добавили расчет продаж X-Git-Tag: 1.6~31^2~6 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=b96367768ef9a3e8c1c7e2cceec656ce7d9bc173;p=erp24_rep%2Fyii-erp24%2F.git Добавили расчет продаж --- 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