From: vladfo Date: Mon, 14 Oct 2024 14:53:31 +0000 (+0300) Subject: Добавил номер чека X-Git-Tag: 1.6~31^2~3 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=00e604f28043e846bec59aa96e41cd3df1f5dc87;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 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; ?>

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