From: vladfo Date: Tue, 15 Oct 2024 07:58:38 +0000 (+0300) Subject: Правки по таблице X-Git-Tag: 1.6~31^2~2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=7de328431eeb7495cbf1a5fd92f457e1f7d53f46;p=erp24_rep%2Fyii-erp24%2F.git Правки по таблице --- diff --git a/erp24/views/motivation/test-self-cost.php b/erp24/views/motivation/test-self-cost.php index a9b2abd9..58410122 100644 --- a/erp24/views/motivation/test-self-cost.php +++ b/erp24/views/motivation/test-self-cost.php @@ -44,59 +44,70 @@ $this->title = 'Себестоимость товаров по магазина -

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

- 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)), +

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

+ 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) { + $salesRecord = Sales::findOne($model['check_id']); + return $salesRecord ? $salesRecord->number : 'Неизвестно'; + }, + ], + ['attribute' => 'product_name', 'label' => 'Название'], + [ + 'attribute' => 'm_price', + 'label' => 'Цена', + 'format' => ['decimal', 2], + ], + [ + 'attribute' => 'summ', + 'label' => 'Сумма', + 'format' => ['decimal', 2], + 'footer' => round(array_sum(array_column($data, 'summ')), 2), + ], + [ + 'attribute' => 'discount', + 'label' => 'Скидка', + 'format' => ['decimal', 2], + 'footer' => round(array_sum(array_column($data, 'discount')), 2), + ], + [ + 'attribute' => 'price', + 'label' => 'Себестоимость ед', + 'format' => ['decimal', 2], + ], + [ + 'attribute' => 'quantity', + 'label' => 'Кол-во', + 'format' => ['decimal', 2], + 'footer' => round(array_sum(array_column($data, 'quantity')), 2), + ], + [ + 'label' => 'Себестоимость итого', + 'value' => function ($model) { + return round($model['price'] * $model['quantity'], 2); + }, + 'format' => ['decimal', 2], + 'footer' => round(array_sum(array_map(function ($item) { + return $item['price'] * $item['quantity']; + }, $data)), 2), + ], + ['attribute' => 'date', 'label' => 'Дата'], ], - ['attribute' => 'date', 'label' => 'Дата'], - ], - ]); - ?> + ]); + ?> -

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

-

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

+

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

+

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

new \yii\data\ArrayDataProvider([ @@ -107,34 +118,45 @@ $this->title = 'Себестоимость товаров по магазина 'columns' => [ ['attribute' => 'product_id', 'label' => 'ID товара'], ['attribute' => 'product_name', 'label' => 'Название'], - ['attribute' => 'price', 'label' => 'Себестоимость ед'], - ['attribute' => 'm_price', 'label' => 'Цена ед'], + [ + 'attribute' => 'price', + 'label' => 'Себестоимость ед', + 'format' => ['decimal', 2], + ], + [ + 'attribute' => 'm_price', + 'label' => 'Цена ед', + 'format' => ['decimal', 2], + ], [ 'attribute' => 'quantity', 'label' => 'Общее кол-во', - 'footer' => array_sum(array_column($uniqueProductsData, 'quantity')), + 'format' => ['decimal', 2], + 'footer' => round(array_sum(array_column($uniqueProductsData, 'quantity')), 2), ], [ 'label' => 'Себестоимость * Кол-во', 'value' => function ($model) { - return $model['price'] * $model['quantity']; + return round($model['price'] * $model['quantity'], 2); }, - 'footer' => array_sum(array_map(function ($item) { + 'format' => ['decimal', 2], + 'footer' => round(array_sum(array_map(function ($item) { return $item['price'] * $item['quantity']; - }, $uniqueProductsData)), + }, $uniqueProductsData)), 2), ], [ 'label' => 'Цена * Кол-во', 'value' => function ($model) { - return $model['m_price'] * $model['quantity']; + return round($model['m_price'] * $model['quantity'], 2); }, - 'footer' => array_sum(array_map(function ($item) { + 'format' => ['decimal', 2], + 'footer' => round(array_sum(array_map(function ($item) { return $item['m_price'] * $item['quantity']; - }, $uniqueProductsData)), + }, $uniqueProductsData)), 2), ], ], ]); - endif; ?> + endif; ?>

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

title = 'Себестоимость товаров по магазина 'allModels' => $salesRecords, 'pagination' => false, ]), - 'showFooter' => true, // Показываем подвал таблицы + 'showFooter' => true, 'columns' => [ ['attribute' => 'id', 'label' => 'ID продажи'], + ['attribute' => 'number', 'label' => 'Номер чека'], ['attribute' => 'operation', 'label' => 'Операция'], ['attribute' => 'status', 'label' => 'Статус'], [ 'attribute' => 'summ', 'label' => 'Сумма', - 'footer' => array_sum(array_column($salesRecords, 'summ')), // Сумма всех значений столбца "Сумма" + 'format' => ['decimal', 2], + 'footer' => round(array_sum(array_column($salesRecords, 'summ')), 2), ], - ['attribute' => 'sales_check', 'label' => 'Чек возврата'], + ['attribute' => 'date', 'label' => 'Дата'], ], ]); ?> @@ -167,11 +191,17 @@ $this->title = 'Себестоимость товаров по магазина ]), 'columns' => [ ['attribute' => 'id', 'label' => 'ID возврата'], + ['attribute' => 'number', 'label' => 'Номер чека'], ['attribute' => 'date', 'label' => 'Дата'], + [ + 'attribute' => 'summ', + 'label' => 'Сумма', + 'format' => ['decimal', 2], + 'footer' => round(array_sum(array_column($salesRecords, 'summ')), 2), + ], ['attribute' => 'sales_check', 'label' => 'ID продажи'], ], ]); ?> - \ No newline at end of file