Optimizations regarding displaying prices (closes #1743)

This commit is contained in:
Bernd Bestel
2022-04-02 17:49:35 +02:00
parent 7ad979cba9
commit 6a50f74a14
8 changed files with 215 additions and 71 deletions

View File

@@ -49,15 +49,32 @@
class="pl-2 text-secondary d-none"><i class="fas fa-custom-sigma-sign"></i> <span id="productcard-product-stock-amount-aggregated"
class="locale-number locale-number-quantity-amount"></span> <span id="productcard-product-stock-qu-name-aggregated"></span> <span id="productcard-product-stock-opened-amount-aggregated locale-number locale-number-quantity-amount"
class="small font-italic"></span></span><br>
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)<strong>{{ $__t('Stock value') }}:</strong> <span id="productcard-product-stock-value"
class="locale-number locale-number-currency"></span><br>@endif
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
<strong>{{ $__t('Stock value') }}:</strong> <span id="productcard-product-stock-value"
class="locale-number locale-number-currency"></span><br>
@endif
@if(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)<strong>{{ $__t('Default location') }}:</strong> <span id="productcard-product-location"></span><br>@endif
<strong>{{ $__t('Last purchased') }}:</strong> <span id="productcard-product-last-purchased"></span> <time id="productcard-product-last-purchased-timeago"
class="timeago timeago-contextual"></time><br>
<strong>{{ $__t('Last used') }}:</strong> <span id="productcard-product-last-used"></span> <time id="productcard-product-last-used-timeago"
class="timeago timeago-contextual"></time><br>
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)<strong>{{ $__t('Last price') }}:</strong> <span id="productcard-product-last-price"></span><br>@endif
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)<strong>{{ $__t('Average price') }}:</strong> <span id="productcard-product-average-price"></span><br>@endif
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)<strong>
{{ $__t('Last price') }}:</strong> <span id="productcard-product-last-price"
data-toggle="tooltip"
data-trigger="hover click"></span>
<br>
@endif
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
<strong>{{ $__t('Average price') }}:</strong> <span id="productcard-product-average-price"
data-toggle="tooltip"
data-trigger="hover click"></span>
<br>
@endif
@if(GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)<strong>{{ $__t('Average shelf life') }}:</strong> <span id="productcard-product-average-shelf-life"></span><br>@endif
<strong>{{ $__t('Spoil rate') }}:</strong> <span id="productcard-product-spoil-rate"></span>

View File

@@ -261,11 +261,15 @@
{{ FindObjectInArrayByPropertyValue($shoppinglocations, 'id', $stockEntry->shopping_location_id)->name }}
@endif
</td>
<td id="stock-{{ $stockEntry->id }}-price"
class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif"
class="locale-number locale-number-currency"
data-price-id="{{ $stockEntry->price }}">
{{ $stockEntry->price }}
<td data-order="{{$stockEntry->price}}"
class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">
<span id="stock-{{ $stockEntry->id }}-price"
data-toggle="tooltip"
data-trigger="hover click"
data-html="true"
title="{!! $__t('%1$s per %2$s', '<span class=\'locale-number locale-number-currency\'>' . $stockEntry->price . '</span>', FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_stock)->name) !!}">
{!! $__t('%1$s per %2$s', '<span class="locale-number locale-number-currency">' . floatval($stockEntry->price) * floatval(FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_factor_purchase_to_stock) . '</span>', FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_purchase)->name) !!}
</span>
</td>
<td>
<span id="stock-{{ $stockEntry->id }}-purchased-date">{{ $stockEntry->purchased_date }}</span>

View File

@@ -399,8 +399,16 @@
<time class="timeago timeago-contextual"
datetime="{{ $currentStockEntry->last_purchased }}"></time>
</td>
<td class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">
<span class="locale-number locale-number-currency">{{ $currentStockEntry->last_price }}</span>
<td data-order="{{$currentStockEntry->last_price}}"
class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">
@if(!empty($currentStockEntry->last_price))
<span data-toggle="tooltip"
data-trigger="hover click"
data-html="true"
title="{!! $__t('%1$s per %2$s', '<span class=\'locale-number locale-number-currency\'>' . $currentStockEntry->last_price . '</span>', $currentStockEntry->qu_unit_name) !!}">
{!! $__t('%1$s per %2$s', '<span class="locale-number locale-number-currency">' . floatval($currentStockEntry->last_price) * floatval($currentStockEntry->product_qu_factor_purchase_to_stock) . '</span>', $currentStockEntry->qu_purchase_unit_name) !!}
</span>
@endif
</td>
<td>
<span class="locale-number locale-number-quantity-amount">{{ $currentStockEntry->min_stock_amount }}</span>
@@ -421,8 +429,16 @@
class="lazy">
@endif
</td>
<td class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">
<span class="locale-number locale-number-currency">{{ $currentStockEntry->average_price }}</span>
<td data-order="{{$currentStockEntry->average_price}}"
class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">
@if(!empty($currentStockEntry->average_price))
<span data-toggle="tooltip"
data-trigger="hover click"
data-html="true"
title="{!! $__t('%1$s per %2$s', '<span class=\'locale-number locale-number-currency\'>' . $currentStockEntry->average_price . '</span>', $currentStockEntry->qu_unit_name) !!}">
{!! $__t('%1$s per %2$s', '<span class="locale-number locale-number-currency">' . floatval($currentStockEntry->average_price) * floatval($currentStockEntry->product_qu_factor_purchase_to_stock) . '</span>', $currentStockEntry->qu_purchase_unit_name) !!}
</span>
@endif
</td>
@include('components.userfields_tbody', array(