From 00e604f28043e846bec59aa96e41cd3df1f5dc87 Mon Sep 17 00:00:00 2001 From: vladfo Date: Mon, 14 Oct 2024 17:53:31 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?utf8?q?=D0=BD=D0=BE=D0=BC=D0=B5=D1=80=20=D1=87=D0=B5=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/views/motivation/test-self-cost.php | 89 ++++++++++++++--------- 1 file changed, 53 insertions(+), 36 deletions(-) diff --git a/erp24/views/motivation/test-self-cost.php b/erp24/views/motivation/test-self-cost.php index 200dc186..a9b2abd9 100644 --- a/erp24/views/motivation/test-self-cost.php +++ b/erp24/views/motivation/test-self-cost.php @@ -3,6 +3,7 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; use kartik\select2\Select2; use yii\grid\GridView; +use yii_app\records\Sales; /* @var $this yii\web\View */ /* @var $storeList array */ @@ -43,41 +44,58 @@ $this->title = 'Себестоимость товаров по магазина -

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

- 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' => 'summ', 'label' => 'Сумма', 'footer' => array_sum(array_column($data, 'summ')),], - ['attribute' => 'discount', 'label' => 'Скидка', 'footer' => array_sum(array_column($data, 'discount')),], - ['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' => 'Дата'], +

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

+ new \yii\data\ArrayDataProvider([ + 'allModels' => $data, + 'pagination' => false, + ]), + 'showFooter' => true, + 'columns' => [ + ['attribute' => 'product_id', 'label' => 'ID товара'], + ['attribute' => 'check_id', 'label' => 'ID чека'], + [ + 'label' => 'Номер чека', + 'value' => function ($model) { + // Выполняем запрос к таблице Sales для получения номера чека + $salesRecord = Sales::findOne($model['check_id']); + return $salesRecord ? $salesRecord->number : 'Неизвестно'; + }, ], - ]); ?> + ['attribute' => 'product_name', 'label' => 'Название'], + ['attribute' => 'm_price', 'label' => 'Цена'], + [ + 'attribute' => 'summ', + 'label' => 'Сумма', + 'footer' => array_sum(array_column($data, 'summ')), + ], + [ + 'attribute' => 'discount', + 'label' => 'Скидка', + 'footer' => array_sum(array_column($data, 'discount')), + ], + ['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' => 'Дата'], + ], + ]); + ?> -

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

-

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

+

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

+

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

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

title = 'Себестоимость товаров по магазина }, $uniqueProductsData)), ], ], - ]); ?> - - + ]); + endif; ?>

Продажи за период