Show product group Userfields on the shopping list (closes #2069)

This commit is contained in:
Bernd Bestel
2022-12-18 20:56:02 +01:00
parent 38a4ad8ec4
commit 2ebb9b2cd9
4 changed files with 37 additions and 3 deletions

View File

@@ -44,7 +44,7 @@
### Userfields ### Userfields
- xxx - Product group Userfields are now also rendered on the shopping list
### General ### General

View File

@@ -352,7 +352,6 @@ class StockController extends BaseController
public function ShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) public function ShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{ {
$listId = 1; $listId = 1;
if (isset($request->getQueryParams()['list'])) if (isset($request->getQueryParams()['list']))
{ {
$listId = $request->getQueryParams()['list']; $listId = $request->getQueryParams()['list'];
@@ -368,6 +367,8 @@ class StockController extends BaseController
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(), 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'productUserfields' => $this->getUserfieldsService()->GetFields('products'), 'productUserfields' => $this->getUserfieldsService()->GetFields('products'),
'productUserfieldValues' => $this->getUserfieldsService()->GetAllValues('products'), 'productUserfieldValues' => $this->getUserfieldsService()->GetAllValues('products'),
'productGroupUserfields' => $this->getUserfieldsService()->GetFields('product_groups'),
'productGroupUserfieldValues' => $this->getUserfieldsService()->GetAllValues('product_groups'),
'userfields' => $this->getUserfieldsService()->GetFields('shopping_list'), 'userfields' => $this->getUserfieldsService()->GetFields('shopping_list'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('shopping_list') 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('shopping_list')
]); ]);

27
migrations/0205.sql Normal file
View File

@@ -0,0 +1,27 @@
DROP VIEW uihelper_shopping_list;
CREATE VIEW uihelper_shopping_list
AS
SELECT
sl.*,
p.name AS product_name,
plp.price AS last_price_unit,
plp.price * sl.amount AS last_price_total,
st.name AS default_shopping_location_name,
qu.name AS qu_name,
qu.name_plural AS qu_name_plural,
pg.id AS product_group_id,
pg.name AS product_group_name,
pbcs.barcodes AS product_barcodes
FROM shopping_list sl
LEFT JOIN products p
ON sl.product_id = p.id
LEFT JOIN products_last_purchased plp
ON sl.product_id = plp.product_id
LEFT JOIN shopping_locations st
ON p.shopping_location_id = st.id
LEFT JOIN quantity_units qu
ON sl.qu_id = qu.id
LEFT JOIN product_groups pg
ON p.product_group_id = pg.id
LEFT JOIN product_barcodes_comma_separated pbcs
ON sl.product_id = pbcs.product_id;

View File

@@ -376,7 +376,9 @@
@include('components.userfields_thead', array( @include('components.userfields_thead', array(
'userfields' => $productUserfields 'userfields' => $productUserfields
)) ))
@include('components.userfields_thead', array(
'userfields' => $productGroupUserfields
))
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -400,6 +402,10 @@
'userfields' => $productUserfields, 'userfields' => $productUserfields,
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($productUserfieldValues, 'object_id', $listItem->product_id) 'userfieldValues' => FindAllObjectsInArrayByPropertyValue($productUserfieldValues, 'object_id', $listItem->product_id)
)) ))
@include('components.userfields_tbody', array(
'userfields' => $productGroupUserfields,
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($productGroupUserfieldValues, 'object_id', $listItem->product_group_id)
))
</tr> </tr>
@endforeach @endforeach