Simplified product specific QU display/edit and added more demo QU conversions

This commit is contained in:
Bernd Bestel 2022-12-04 20:25:33 +01:00
parent c1dea5c254
commit 8175b1bcfe
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
6 changed files with 16 additions and 26 deletions

View File

@ -187,7 +187,7 @@ class StockController extends BaseController
'products' => $this->getDatabase()->products()->where('id != :1 AND parent_product_id IS NULL and active = 1', $product->id)->orderBy('name', 'COLLATE NOCASE'),
'isSubProductOfOthers' => $this->getDatabase()->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
'mode' => 'edit',
'quConversions' => $this->getDatabase()->quantity_unit_conversions(),
'quConversions' => $this->getDatabase()->quantity_unit_conversions()->where('product_id', $product->id),
'productBarcodeUserfields' => $this->getUserfieldsService()->GetFields('product_barcodes'),
'productBarcodeUserfieldValues' => $this->getUserfieldsService()->GetAllValues('product_barcodes')
]);

View File

@ -380,3 +380,8 @@ msgstr ""
msgid "Ukrainian"
msgstr ""
msgid "Kilogram"
msgid_plural "Kilograms"
msgstr[0] ""
msgstr[1] ""

View File

@ -1217,9 +1217,6 @@ msgstr ""
msgid "QU conversions"
msgstr ""
msgid "Product overrides"
msgstr ""
msgid "Override for product"
msgstr ""
@ -2350,3 +2347,6 @@ msgstr ""
msgid "QU conversions resolved"
msgstr ""
msgid "Product specifc QU conversions"
msgstr ""

View File

@ -293,16 +293,10 @@ $("#delete-current-product-picture-button").on("click", function(e)
var quConversionsTable = $('#qu-conversions-table-products').DataTable({
'order': [[1, 'asc']],
"orderFixed": [[4, 'asc']],
'columnDefs': [
{ 'orderable': false, 'targets': 0 },
{ 'searchable': false, "targets": 0 },
{ 'visible': false, 'targets': 4 }
].concat($.fn.dataTable.defaults.columnDefs),
'rowGroup': {
enable: true,
dataSrc: 4
}
{ 'searchable': false, "targets": 0 }
].concat($.fn.dataTable.defaults.columnDefs)
});
$('#qu-conversions-table-products tbody').removeClass("d-none");
quConversionsTable.columns.adjust().draw();

View File

@ -65,6 +65,8 @@ class DemoDataGeneratorService extends BaseService
INSERT INTO quantity_units (id, name, name_plural) VALUES (11, '{$this->__n_sql(1, 'Milliliter', 'Milliliters')}', '{$this->__n_sql(2, 'Milliliter', 'Milliliters')}'); --11
DELETE FROM quantity_units WHERE name = '{$this->__t_sql('Slice')}';
INSERT INTO quantity_units (id, name, name_plural) VALUES (12, '{$this->__n_sql(1, 'Slice', 'Slices')}', '{$this->__n_sql(2, 'Slice', 'Slices')}'); --12
DELETE FROM quantity_units WHERE name = '{$this->__t_sql('Kilogram')}';
INSERT INTO quantity_units (id, name, name_plural) VALUES (13, '{$this->__n_sql(1, 'Kilogram', 'Kilograms')}', '{$this->__n_sql(2, 'Kilogram', 'Kilograms')}'); --13
INSERT INTO product_groups(name) VALUES ('01 {$this->__t_sql('Sweets')}'); --1
INSERT INTO product_groups(name) VALUES ('02 {$this->__t_sql('Bakery products')}'); --2
@ -112,6 +114,8 @@ class DemoDataGeneratorService extends BaseService
INSERT INTO quantity_unit_conversions (from_qu_id, to_qu_id, factor, product_id) VALUES (3, 12, 10, 10);
INSERT INTO quantity_unit_conversions (from_qu_id, to_qu_id, factor, product_id) VALUES (3, 8, 1000, 22);
INSERT INTO quantity_unit_conversions (from_qu_id, to_qu_id, factor) VALUES (13, 8, 1000);
INSERT INTO quantity_unit_conversions (from_qu_id, to_qu_id, factor) VALUES (9, 11, 1000);
INSERT INTO shopping_list (note, amount) VALUES ('{$this->__t_sql('Some good snacks')}', 1);
INSERT INTO shopping_list (product_id, amount) VALUES (20, 1);

View File

@ -706,7 +706,7 @@
<div class="col">
<div class="title-related-links">
<h4>
{{ $__t('QU conversions') }}
{{ $__t('Product specifc QU conversions') }}
</h4>
<button class="btn btn-outline-dark d-md-none mt-2 float-right order-1 order-md-3"
type="button"
@ -731,9 +731,6 @@
@endif
</div>
<h5 id="qu-conversion-headline-info"
class="text-muted font-italic"></h5>
<table id="qu-conversions-table-products"
class="table table-sm table-striped nowrap w-100">
<thead>
@ -747,14 +744,12 @@
<th class="allow-grouping">{{ $__t('Quantity unit from') }}</th>
<th class="allow-grouping">{{ $__t('Quantity unit to') }}</th>
<th>{{ $__t('Factor') }}</th>
<th class="allow-grouping">{{ $__t('Group')}}</th>
<th></th>
</tr>
</thead>
<tbody class="d-none">
@if($mode == "edit")
@foreach($quConversions as $quConversion)
@if($quConversion->product_id == $product->id || $quConversion->product_id == null && ($quConversion->product_id != null || $quConversion->from_qu_id == $product->qu_id_purchase || $quConversion->from_qu_id == $product->qu_id_stock || $quConversion->to_qu_id == $product->qu_id_purchase || $quConversion->to_qu_id == $product->qu_id_stock))
<tr>
<td class="fit-content border-right">
<a class="btn btn-sm btn-info show-as-dialog-link @if($quConversion->product_id == null) disabled @endif"
@ -776,18 +771,10 @@
<td>
<span class="locale-number locale-number-quantity-amount">{{ $quConversion->factor }}</span>
</td>
<td class="d-none">
@if($quConversion->product_id != null)
{{ $__t('Product overrides') }}
@else
{{ $__t('Default conversions') }}
@endif
</td>
<td class="font-italic">
{!! $__t('This means 1 %1$s is the same as %2$s %3$s', FindObjectInArrayByPropertyValue($quantityunits, 'id', $quConversion->from_qu_id)->name, '<span class="locale-number locale-number-quantity-amount">' . $quConversion->factor . '</span>', $__n($quConversion->factor, FindObjectInArrayByPropertyValue($quantityunits, 'id', $quConversion->to_qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $quConversion->to_qu_id)->name_plural, true)) !!}
</td>
</tr>
@endif
@endforeach
@endif
</tbody>