public function buildLoadDataShiftRemains($groups, $storeGuid, $normal = true)
{
$productsClass = ProductsClass::find()->select(['category_id'])->where(['tip' => $groups])->column();
- $products = ArrayHelper::map(
+ $products =
Products1c::find()->alias('p')
- ->select(['p.id', 'p.name'])
+ ->select(['p.id', 'p.name', 'p.articule'])
->leftJoin('products_class pc', 'pc.category_id = p.parent_id')
->where(['parent_id' => $productsClass])
->orderBy([
// Обычная алфавитная сортировка
'p.name' => SORT_ASC,
])
- ->all(), 'id', 'name'
- );
+ ->indexBy('id')->asArray()->all();
$balance = ArrayHelper::map(Balances::find()->select(['quantity', 'product_id'])
->where(['store_id' => $storeGuid])->all(), 'product_id', 'quantity');
$productGuids = [];
- foreach ($products as $key => $name) {
+ foreach ($products as $key => $data) {
if (isset($balance[$key]) && $balance[$key] > 0) {
- $productGuids[$key] = $name . ' (' . $balance[$key] . ' шт.)';
+ $productGuids[$key] = $data['name'] . ' (арт. ' . $data['articule'] . ')';
}
else {
if (!$normal) {
- $productGuids[$key] = $name;
+ $productGuids[$key] = $data['name'];
}
}
}
'allModels' => $shiftTransfer->shiftRemains,
'pagination' => false,
]),
-// 'showFooter' => true,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'label' => 'Продукт',
'pageSummary' => 'Итого:',
'value' => function($data) {
- $products = ArrayHelper::map(Products1c::find()->select(['id', 'name'])
- ->where(['id' => $data['product_guid']])->all(), 'id', 'name');
+ $products = Products1c::find()->select(['id', 'name', 'articule'])
+ ->where(['id' => $data['product_guid']])->indexBy('id')->asArray()->all();
- return ($products[$data['product_guid']] ?? '') . ' (' . ($data['retail_price'] ?? '') . ' руб.)';
+ return ($products[$data['product_guid']]['name'] ?? '') . ' (арт.' . ($products[$data['product_guid']]['articule'] ?? '') . ')';
},
],
[
return number_format($data['remains_summ'] ?? '', 2, '.', ' ');
},
],
- [
- 'attribute' => 'self_cost',
- 'label' => 'Себестоимость, руб',
- 'pageSummary' => true,
- 'value' => function($data) {
- return number_format($data['self_cost'] ?? '', 2, '.', ' ');
- },
- ],
+// [
+// 'attribute' => 'self_cost',
+// 'label' => 'Себестоимость, руб',
+// 'pageSummary' => true,
+// 'value' => function($data) {
+// return number_format($data['self_cost'] ?? '', 2, '.', ' ');
+// },
+// ],
],
'layout' => '{items}',
'showPageSummary' => true,