From 12082b52abe0c35e185dc18f80f3b4b90a1054e4 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 5 Apr 2019 18:41:21 +0200 Subject: [PATCH] Fixed differences in highlighting for expiring/expired items in header vs table on stock overview page (fixes #198) --- public/js/grocy.js | 10 ++++++++++ services/StockService.php | 4 ++-- views/stockoverview.blade.php | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/public/js/grocy.js b/public/js/grocy.js index 4feabde9..0b264f29 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -511,3 +511,13 @@ $(document).on("click", ".easy-link-copy-textbox", function() { $(this).select(); }); +$('.dropdown-toggle').click(function () +{ + dropDownFixPosition($('button'), $('.dropdown-menu')); +}); +function dropDownFixPosition(button, dropdown) +{ + var dropDownTop = button.offset().top + button.outerHeight(); + dropdown.css('top', dropDownTop + "px"); + dropdown.css('left', button.offset().left + "px"); +} diff --git a/services/StockService.php b/services/StockService.php index 6611aa51..52678335 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -53,11 +53,11 @@ class StockService extends BaseService public function GetExpiringProducts(int $days = 5, bool $excludeExpired = false) { $currentStock = $this->GetCurrentStock(true); - $currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d', strtotime("+$days days")), '<'); + $currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d 23:59:59', strtotime("+$days days")), '<'); if ($excludeExpired) { - $currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d', strtotime('now')), '>'); + $currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d 23:59:59', strtotime('now')), '>'); } return $currentStock; diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index 0bc5bd89..4de82b44 100644 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -137,7 +137,7 @@ @endforeach - @if($currentStockEntry->best_before_date < date('Y-m-d 23:59:59', strtotime('-1 days')) && $currentStockEntry->amount > 0) expired @elseif($currentStockEntry->best_before_date < date('Y-m-d 23:59:59', strtotime("+$nextXDays days")) && $currentStockEntry->amount > 0) expiring @elseif (FindObjectInArrayByPropertyValue($missingProducts, 'id', $currentStockEntry->product_id) !== null) belowminstockamount @endif + @if($currentStockEntry->best_before_date < date('Y-m-d 23:59:59', strtotime('-1 days')) && $currentStockEntry->amount > 0) expired @elseif($currentStockEntry->best_before_date < date('Y-m-d 23:59:59', strtotime("+$nextXDays days")) && $currentStockEntry->amount > 0) expiring @endif @if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $currentStockEntry->product_id) !== null) belowminstockamount @endif @php $productGroup = FindObjectInArrayByPropertyValue($productGroups, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->product_group_id) @endphp