Compare commits

...

1049 Commits

Author SHA1 Message Date
Bernd Bestel
4c5fbffd25 Optimized date input shorthand handling (fixes #2806) 2025-09-14 13:48:01 +02:00
Bernd Bestel
8509645985 Optimized datetimepicker next input focus handling (fixes #2807) 2025-09-14 10:32:26 +02:00
Bernd Bestel
7de98db143 Added changelog for #2794 2025-08-15 16:59:23 +02:00
DeepCoreSystem
31185beac5 Enhance product card chart colors for better visibility (#2794)
* Enhance product card chart colors for better visibility

* Code style

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2025-08-15 16:55:50 +02:00
Bernd Bestel
c8ee47f935 Don't use double quoted string literals (in triggers / RAISE) 2025-08-03 23:22:38 +02:00
Bernd Bestel
4148f8e88e Don't use double quoted string literals (in triggers / RAISE) 2025-08-03 23:21:01 +02:00
Bernd Bestel
ba2cb6ce08 Don't use double quoted string literals (in triggers / RAISE) 2025-08-03 23:14:33 +02:00
Bernd Bestel
6b18b0a7be Allow German Umlauts in OOF plugin product names (fixes #2740) 2025-06-07 18:00:38 +02:00
Bernd Bestel
ad0447497c Pulled translations from Transifex 2025-06-07 17:33:46 +02:00
Bernd Bestel
3e4f200475 Updated dependencies 2025-06-07 17:27:22 +02:00
Bernd Bestel
8560becb83 Optimized product picker barcode clear handling (fixes #2745) 2025-05-26 20:20:40 +02:00
Bernd Bestel
d6f3595684 Fixed shoppinglistitemtostock flow purchase dialog close handling (fixes #2739) 2025-05-25 21:44:12 +02:00
Bernd Bestel
8de5700310 Allow 0 for shopping list item amounts (references #2712) 2025-04-02 20:50:40 +02:00
Bernd Bestel
21aa5eab21 Prepared next release 2025-03-28 19:54:16 +01:00
Bernd Bestel
b5c9cbccf5 Updated dependencies 2025-03-28 19:47:24 +01:00
Bernd Bestel
de7ad6b115 Pulled translations from Transifex 2025-03-28 19:38:48 +01:00
Bernd Bestel
a3f66b664b Change the default Grocycode type to DataMatrix 2025-03-21 17:49:31 +01:00
Bernd Bestel
4364f07899 Added changelog for #2706 / #2705 2025-03-21 17:47:39 +01:00
Bernd Bestel
d26f24a28b Updated dependencies 2025-03-21 17:42:58 +01:00
Fándly Gergő
e786433273 Replaced barcode scanning library with ZXing (#2706)
* Replaced barcode scanning library with ZXing

* Applied code formatting rules

* Delete now obsolete user settings

* Review

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2025-03-21 17:41:39 +01:00
Bernd Bestel
03ab765ccd Added changelog for #2704 / #2318 2025-03-21 16:41:34 +01:00
Bernd Bestel
b2ba1de9e3 Use JSON label printer webhooks by default 2025-03-21 16:40:56 +01:00
Fándly Gergő
89b8a9c1a9 Added option to include details in the webhook sent to label printers (#2704)
* Added option to include details in the webhook sent to label printers

* Removed LABEL_PRINTER_INCLUDE_DETAILS flag

* Make this actually work

* Care about all places where webhooks are used / don't forget recipes

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2025-03-21 16:34:33 +01:00
Bernd Bestel
541318e964 Include non-latin font variants / clean up font-weight (closes #2699) 2025-03-12 17:48:06 +01:00
Bernd Bestel
d1a8900f98 Also show the product's default store on /stockoverview (closes #2698) 2025-03-10 17:36:23 +01:00
Bertrand SIFRE
6ca87a9a49 fix(openapi): volatile is not an array, it's an object (#2694) 2025-03-10 17:22:56 +01:00
Bernd Bestel
2a3e23ded4 Handle image URLs with query parameters returned from an external barcode lookup plugin 2025-03-04 20:40:48 +01:00
Bernd Bestel
46253c455f Optimize product name special characters handling in OFF external barcode lookup plugin 2025-03-04 20:38:10 +01:00
Bernd Bestel
63dcfcde47 Prepared next release 2025-02-28 17:12:16 +01:00
Bernd Bestel
54cd5a004d Updated README / changelog 2025-02-28 16:14:26 +01:00
Bernd Bestel
c11bbba214 Updated changelog 2025-02-27 21:23:56 +01:00
Bernd Bestel
fdddc9295d Updated dependencies 2025-02-27 18:01:56 +01:00
Bernd Bestel
1d6e545710 Pulled translations from Transifex 2025-02-27 18:01:40 +01:00
Bernd Bestel
57438409c4 Reduce package size 2025-02-27 18:01:18 +01:00
Bernd Bestel
72453eac0a Transpose product column index when searching in it (fixes #2688) 2025-02-27 17:07:30 +01:00
Bernd Bestel
27b79841fc Scale up values on the shopping list when shopping_list_round_up is enabled (closes #2687) 2025-02-25 18:43:42 +01:00
Bernd Bestel
2b994fd2ee Handle window.top in embedded iframe situations (fixes #2686) 2025-02-24 19:52:43 +01:00
Bernd Bestel
ce5be6645e Optimized /locationcontentsheet only-in-stock checkbox page reload persistence (in Chrome) (references #2669) 2025-02-06 20:27:35 +01:00
Bernd Bestel
b7c4011e80 Fixed link userfield saving (fixes #2670) 2025-02-06 20:09:19 +01:00
Bernd Bestel
ebcc9a422e Use OFF localized product names if available (closes #2666) 2025-02-03 18:55:33 +01:00
Bernd Bestel
6a7436dbf0 Persist shopping list print settings (closes #2667) 2025-02-03 18:36:10 +01:00
Bernd Bestel
bf353d9622 API: Expose permission_hierarchy read only via generic entity interactions (closes #2662) 2025-02-01 09:34:16 +01:00
Pierre Penninckx
2690e535e3 Make labels on login form point to correct inputs (#2661)
Co-authored-by: ibizaman <ibizapeanut@gmail.com>
2025-02-01 09:31:54 +01:00
Bernd Bestel
98769aea11 grocy/grocy-docker has been retired 2025-01-31 18:18:40 +01:00
Bernd Bestel
9c60fdec5a Prepared next release 2025-01-31 16:42:05 +01:00
Bernd Bestel
d37c98e5f0 Pulled translations from Transifex 2025-01-31 16:38:59 +01:00
Bernd Bestel
a1dea994c9 Updated dependencies 2025-01-31 16:36:02 +01:00
Bernd Bestel
11fdf5929a Apply table filters on /tasks load (fixes #2660) 2025-01-31 16:33:55 +01:00
Bernd Bestel
56d8c2f13a Changed shopping_list_defaults default amount 2025-01-31 15:56:15 +01:00
Bernd Bestel
aa88046ca4 Added database version to system info 2025-01-31 15:44:57 +01:00
Bernd Bestel
a35db9f1d3 Optimized form input field navigation delay 2025-01-31 15:35:34 +01:00
Bernd Bestel
c8ac094bf4 Prevent non-number amounts for shopping list items on database level (closes #2657) 2025-01-30 19:42:56 +01:00
Bernd Bestel
a177e2a185 Fixed preset-checklist userfield saving (fixes #2655) 2025-01-29 23:27:17 +01:00
Bernd Bestel
1f5263ef22 Escape DataTable regex searches (fixes #2654) 2025-01-27 17:25:25 +01:00
Bernd Bestel
d747a6c86a Fixed OFF barcode lookup plugin API URL (fixes #2653) 2025-01-27 09:12:14 +01:00
Bernd Bestel
e3d0ddbce6 Prepared next release 2025-01-24 17:30:04 +01:00
Bernd Bestel
ab09ce219c Removed unnecessary localization strings 2025-01-24 17:20:46 +01:00
Bernd Bestel
646263ab2a Pulled translations from Transifex 2025-01-24 17:20:05 +01:00
Bernd Bestel
cccf1d430f Pulled translations from Transifex 2025-01-24 17:12:33 +01:00
Bernd Bestel
aad589eaca Optimized product picker focus handling 2025-01-24 16:46:42 +01:00
Bernd Bestel
f4226876c9 Set focus to input after canceled product picker workflow 2025-01-23 23:22:50 +01:00
Bernd Bestel
12a318c6f2 Updated changelog 2025-01-23 20:53:21 +01:00
Bernd Bestel
844d6279ae Optimized title 2025-01-23 20:20:14 +01:00
Bernd Bestel
de881eb78e Fixed missing en strings 2025-01-23 19:57:55 +01:00
Bernd Bestel
0d1a8bdfb6 Minor style refinements 2025-01-23 19:37:32 +01:00
Bernd Bestel
bbd5f5e7ae Minor style refinements 2025-01-23 18:08:50 +01:00
Bernd Bestel
262f3df3ab Only show the shopping list button on the product card if the feature is enabled 2025-01-23 17:56:01 +01:00
Bernd Bestel
f8e2e4ced7 Uppdated README 2025-01-22 21:08:46 +01:00
Bernd Bestel
c24679b799 Updated screenshots 2025-01-22 20:46:36 +01:00
Bernd Bestel
33ec1626e8 Fixed typo 2025-01-22 20:40:17 +01:00
Bernd Bestel
4468a6ac98 Updated screenshots 2025-01-22 20:36:35 +01:00
Bernd Bestel
4f964cb386 Pulled translations from Transifex 2025-01-22 20:24:20 +01:00
Bernd Bestel
9d92020a07 Updated dependencies 2025-01-22 20:19:41 +01:00
Bernd Bestel
3abf4865bc Added product card on /recipes 2025-01-22 19:39:14 +01:00
Bernd Bestel
69e21fd483 Streamlined inventory input field hints 2025-01-22 19:28:47 +01:00
Bernd Bestel
0bbc06a70c Remove unnecessary help tooltip 2025-01-22 19:25:28 +01:00
Bernd Bestel
8e1d9a4871 Improved mobile filter element spacing 2025-01-22 19:23:41 +01:00
Bernd Bestel
d76d5d2537 Optimized night mode sidebar colors 2025-01-21 21:28:26 +01:00
Bernd Bestel
38882c5ec6 Optimized night mode custom-select background color 2025-01-21 21:09:31 +01:00
Bernd Bestel
4f9e39edd7 Fixed HTML markup 2025-01-21 21:04:56 +01:00
Bernd Bestel
9c0e0c5870 Optimized big header button menus 2025-01-21 20:59:01 +01:00
Bernd Bestel
a4b3a5592e Updated changelog 2025-01-19 21:35:47 +01:00
Bernd Bestel
ef9413c5c1 Optimized recipe missing ingredients shopping list item handling (closes #1890, closes #2134) 2025-01-19 21:31:36 +01:00
Bernd Bestel
0ff5aee6f6 Optimized the recipe ingredient mark as done button layout 2025-01-19 20:45:56 +01:00
Bernd Bestel
61b6afa364 Optimized settings pages layout 2025-01-19 20:35:56 +01:00
Bernd Bestel
1946ff870e Make it possible to round up shopping list and recipe ingredient amounts (closes #902, closes #2644) 2025-01-19 20:16:37 +01:00
Bernd Bestel
e3965ed82c Added a new product option default_purchase_price_type (closes #566) 2025-01-19 16:35:45 +01:00
Bernd Bestel
f3effc5a60 Use qu_id_purchase when adding products to the shopping list (closes #1355) 2025-01-19 15:16:40 +01:00
Bernd Bestel
bc78359dba Make it possible to disable open per product (closes #1911) 2025-01-19 14:57:19 +01:00
Bernd Bestel
72e1a9aee7 Updated API endpoint description (references #386) 2025-01-18 10:38:56 +01:00
Bernd Bestel
83b8b95b73 Streamline in stock / out of stock wording 2025-01-18 10:33:26 +01:00
Bernd Bestel
23d7b6ad3c Allow partially in stock recipes to be consumed (closes #386) 2025-01-18 10:23:31 +01:00
Bernd Bestel
f9c7c67dc7 Indicate incomplete recipe costs information (closes #1941) 2025-01-17 20:37:43 +01:00
Bernd Bestel
c05181aa53 Updated changelog 2025-01-17 20:01:48 +01:00
Bernd Bestel
1daa15a303 Added an upper limit for stock_decimal_places_* settings (references #2508) 2025-01-17 19:48:14 +01:00
Bernd Bestel
4300da8f64 Optimized night mode mobile sidebar active page color 2025-01-17 19:37:02 +01:00
Bernd Bestel
abf109885a Show the amount in stock next to the ingredient hint "Enough in stock" (closes #2119) 2025-01-17 18:42:40 +01:00
Bernd Bestel
f142798a81 Clear /data/viewcache also when BASE_URL or BASE_PATH changed (references #2384) 2025-01-17 17:13:11 +01:00
Bernd Bestel
fe2a628f35 Right align the sidebar on mobile 2025-01-17 17:06:21 +01:00
Bernd Bestel
6605eeafd0 Optimized tooltip hide handling 2025-01-17 16:22:41 +01:00
Bernd Bestel
ded742a7c1 Various minor usability refinements 2025-01-16 21:34:01 +01:00
Bernd Bestel
b0dded1346 Added a new stock settings to always show all products on /stockoverview (closes #2398) 2025-01-15 21:44:45 +01:00
Bernd Bestel
113a9ecf39 Pulled translations from Transifex 2025-01-15 20:40:42 +01:00
Bernd Bestel
9e5ce48091 Updated dependencies 2025-01-15 20:36:41 +01:00
Bernd Bestel
dc05753a0f Added a new product preset for default_stock_label_type (closes #2445) 2025-01-15 20:34:53 +01:00
Bernd Bestel
49839d933b Upgraded some dependencies 2025-01-15 17:41:30 +01:00
Bernd Bestel
97dbd7bf08 Optimized chore on-time tracking (closes #2385) 2025-01-14 20:39:07 +01:00
Bernd Bestel
9cac3b2311 Make track now / next schedule buttons on /choresoverview swappable (closes #2424) 2025-01-14 19:43:12 +01:00
Bernd Bestel
11d28622e8 Squashed commit
Make it possible to actively not-check a mandatory checkbox Userfield (closes #2601)
Pluralize the "opened" localization string (closes #2280)
Added a trendline to the price history chart (closes #2237)
Various minor style/code refinements
2025-01-14 17:54:06 +01:00
Bernd Bestel
c99dd46007 Keep selected date range when navigating through different group by variants of the stockreport/spendings (closes #2532) 2025-01-13 23:13:24 +01:00
Bernd Bestel
645f9e2599 Optimized only_check_single_unit_in_stock recipe ingredient shopping list item handling related to QU conversions (closes #2545) 2025-01-13 23:01:42 +01:00
Bernd Bestel
caa28af0d2 Make product barcode matching case insensitive (closes #2609) 2025-01-13 22:29:33 +01:00
Bernd Bestel
cc40344845 Fixed recipes_nestings_resolved recursive serving calculation (fixes #2361) 2025-01-13 21:37:16 +01:00
Bernd Bestel
c8ccc0b529 Optimized Userfield save event handling (fixes #2458) 2025-01-13 21:00:06 +01:00
Bernd Bestel
a734d1c3ae data/viewcache is now cleared automatically (references #2384) 2025-01-13 18:08:20 +01:00
Bernd Bestel
f4d5f21832 Squashed commit
Fixed recipe ingredient costs/calories calculation when having different QUs and when only_check_single_unit_in_stock is set (fixes #2529)
Added a new column "Product picture" on /products (closes #2640)
Fixed partly opening stock entries stock_id handling (fixes #2391)
2025-01-13 17:41:08 +01:00
Bernd Bestel
e7cea3d949 Optimized camera barcode scanner component 2025-01-13 00:09:28 +01:00
Bernd Bestel
96059a1b32 Optimized camera barcode scanner component 2025-01-12 23:51:00 +01:00
Bernd Bestel
a06991f81b Added external barcode lookup demo videos 2025-01-12 21:05:42 +01:00
Bernd Bestel
245bdbe6e8 Optimized camera display/selection in barcodescanner.js 2025-01-12 19:21:40 +01:00
Bernd Bestel
4a674e3bfa Remove non-numeric characters when looking up OFF barcodes 2025-01-12 18:36:30 +01:00
Bernd Bestel
632162c1be More initial form field focus optimizations 2025-01-12 17:57:50 +01:00
Bernd Bestel
7d6b76effb Fixed Userfield initialization on /purchase and /inventory (fixes #2581) 2025-01-12 17:40:39 +01:00
Bernd Bestel
b706f0c65a Automate manual update steps (closes #2384) 2025-01-12 15:24:18 +01:00
Bernd Bestel
b6ce9eec30 Allow empty QU when editing product barcodes (fixes #2526) 2025-01-12 14:27:19 +01:00
Bernd Bestel
c73be7d18e Finalized frontend external barcode lookup implementation (references #158) 2025-01-12 13:58:47 +01:00
Bernd Bestel
c9ffe4885d Implemented frontend external barcode lookup workflow + a plugin for Open Food Facts (closes #158) 2025-01-11 20:04:32 +01:00
Bernd Bestel
a2c2049037 More modal iframe dialog handling improvements 2025-01-11 15:41:04 +01:00
Bernd Bestel
2c0b1a7be0 More modal iframe dialog handling improvements 2025-01-11 12:29:45 +01:00
Bernd Bestel
5721c4bd62 More modal iframe dialog handling improvements 2025-01-10 20:58:30 +01:00
Bernd Bestel
a373f8ae4b More modal iframe dialog handling improvements 2025-01-10 20:26:37 +01:00
Bernd Bestel
201bda93a2 Revamped modal iframe dialog handling 2025-01-10 17:15:09 +01:00
Bernd Bestel
1900a5b8a2 Visual refresh 2025-01-08 20:50:35 +01:00
Bernd Bestel
98fad559d4 Don't replace due date on freezing when default_best_before_days_after_freezing are set to 0 (closes #1880) 2025-01-06 19:55:18 +01:00
Bernd Bestel
bed18b1981 Show wget progress in update.sh (closes #2633) 2025-01-05 18:31:28 +01:00
Bernd Bestel
0270f6aa08 Improved API key delete confirmation dialog (references #2625) 2024-12-29 20:18:10 +01:00
Bernd Bestel
5f26e914a2 Improve delete confirmation wording details (references #2624) 2024-12-26 10:46:54 +01:00
Bernd Bestel
b2aa882abb Restored staged changes of 27f9d70b56 2024-12-23 18:01:29 +01:00
Bernd Bestel
e273158796 Prepared next release 2024-12-23 17:50:40 +01:00
Bernd Bestel
a1008eac30 Pulled translations from Transifex 2024-12-23 17:46:12 +01:00
Bernd Bestel
d7b5b8958a Stage changes of 27f9d70b56 (not ready yet) 2024-12-23 17:39:59 +01:00
Bernd Bestel
04c5928612 Allow underscores in Userfield names (closes #2611) 2024-12-23 17:35:49 +01:00
Bernd Bestel
9a319a6ee0 Fixed/optimized shopping list invalidation when removing table rows (fixes #2608) 2024-12-23 17:31:22 +01:00
Bernd Bestel
cd25284d35 Fixed DOMSubtreeModified deprecation notice 2024-12-23 17:20:23 +01:00
Bernd Bestel
58eda2f152 Upgraded iframe-resizer package 2024-12-23 17:11:35 +01:00
Bernd Bestel
ceb6774260 Updated dependencies 2024-12-23 16:46:33 +01:00
Bernd Bestel
7b7293e108 Updated footer 2024-12-23 16:43:31 +01:00
Bernd Bestel
11ea8f3716 Fixed shopping list print view table/list sorting (fixes #2602) 2024-11-08 16:40:30 +01:00
Bernd Bestel
1b8f4e6a4f Updated README 2024-11-01 10:44:16 +01:00
Bernd Bestel
3321deec70 Added changelog of #2596 2024-10-25 23:25:17 +02:00
Daniel Reinoso
5b48004449 Exclude self-produced product prices from spending reports (#2596)
* Exclude self-produced product prices from spending reports

* Fix SQL query

* Code style

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2024-10-25 23:19:00 +02:00
Bernd Bestel
9e1020b7f8 Round amount picker max by stock_decimal_places_amounts (closes #2578) 2024-09-10 21:55:31 +02:00
Stefan
185e6b20ad Make date in backup filename ISO 8601 compliant (#2574) 2024-09-01 17:23:06 +02:00
Bernd Bestel
2bc58e083d Fixed recipe edit button on recipes page gallery view (fixes #2541) 2024-08-24 20:01:01 +02:00
Bernd Bestel
1323fff3e2 Add table options also to userobjects view (closes #2573) 2024-08-24 19:42:41 +02:00
Bernd Bestel
d186e26898 Fixed products page table filter regex (references #2570) 2024-08-24 18:28:38 +02:00
Bernd Bestel
4f6075d8c5 Fixed product barcode scanning on the recipe ingredient edit page (fixes #2572) 2024-08-24 18:22:39 +02:00
Bernd Bestel
d5dacb1053 Optimized product Grocycode handling on consume page (and others / general) (fixes #2571) 2024-08-24 18:20:40 +02:00
Bernd Bestel
1246f402e5 Fixed product Grocycode handling on /purchase (references #2571) 2024-08-24 11:32:15 +02:00
Bernd Bestel
7080ec9a8f Pulled translations from Transifex 2024-08-24 11:01:37 +02:00
Bernd Bestel
df28026a80 Updated dependencies 2024-08-24 10:53:33 +02:00
Bernd Bestel
434525826e Fixed products page product group filter to use an exact search instead of contains (fixes #2570) 2024-08-24 10:49:19 +02:00
Bernd Bestel
c21090f522 Allow non-ASCII characters in file names of uploaded files (closes #2484) 2024-08-19 20:51:47 +02:00
Bernd Bestel
5a2600209f Fixed recipe shopping list button feature flag relation (fixes #2552) 2024-07-13 13:41:18 +02:00
Bernd Bestel
8ac8000f30 Updated dependencies 2024-05-10 17:45:29 +02:00
Bernd Bestel
8821280642 Pulled translations from Transifex 2024-05-10 17:42:13 +02:00
Bernd Bestel
2047d38c6e Updated about page 2024-04-14 19:24:32 +02:00
Bernd Bestel
a68c1087dd Update README 2024-04-13 17:43:57 +02:00
Bernd Bestel
2f7478bddb Update README 2024-04-13 13:20:35 +02:00
Bernd Bestel
af1f2aef96 Don't allow amounts <= 0 on purchase/consume
References https://github.com/grocy/grocy/issues/2156#issuecomment-2040336492
2024-04-05 20:12:11 +02:00
Bernd Bestel
6602c76005 Completed changelog for #2501 2024-03-17 21:26:06 +01:00
TheDodger
8f9b295e68 Also copy treat_opened_as_out_of_stock when copying a product (#2501) 2024-03-17 21:24:35 +01:00
Bernd Bestel
5167ba1154 Add recipe name to note of the created stock entry when self producing products (closes #2497) 2024-03-17 17:11:09 +01:00
Bernd Bestel
b26dfe3fb0 Restored staged changes of 27f9d70b56 2024-03-15 18:48:51 +01:00
Bernd Bestel
402d98757e Optimized iframe-resizer handling 2024-03-15 18:39:31 +01:00
Bernd Bestel
a7fc87c9bc Prepared next release 2024-03-15 18:12:58 +01:00
Bernd Bestel
5c1814989a Stage changes of 27f9d70b56 (not ready yet) 2024-03-15 18:06:46 +01:00
Bernd Bestel
e005c51b1a Pulled translations from Transifex 2024-03-15 18:04:16 +01:00
Bernd Bestel
f14110aa1e Updated dependencies 2024-03-15 18:01:05 +01:00
Bernd Bestel
affa7c41a1 Added missing DataTables option (fixes #2494) 2024-03-13 22:05:05 +01:00
Bernd Bestel
9c123bd92a Completed changelog for #2492 2024-03-10 18:59:16 +01:00
TheDodger
7f1dfd0496 Align settings (wrench) menu entries (#2492)
* Made settings menu (wrench) entries aligned by changing the icons to fixed width

* If, then take care of all those kind of menus

---------

Co-authored-by: Manuel Worschech <mw@abot.xyz>
Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2024-03-10 18:57:10 +01:00
Bernd Bestel
49ff780e3f Completed changelog for #2490 2024-03-10 18:16:43 +01:00
TheDodger
477f333466 Add userfields to battery charge cycle tracking (#2490)
Co-authored-by: Manuel Worschech <mw@abot.xyz>
2024-03-10 18:12:02 +01:00
Bernd Bestel
e01e0f3abe Revamped iframe modal handling (references #2480 and #2421) 2024-02-25 10:40:11 +01:00
Bernd Bestel
8ba3305a21 Default any add-to-shopping-list-actions to the default shopping list (closes #2472) 2024-02-24 20:15:23 +01:00
Bernd Bestel
24cac247f5 Don't resize invisible embedded iframes (references #2480 and #2421) 2024-02-24 20:13:39 +01:00
Bernd Bestel
6a68e410e4 Prefill specific stock entry information by a scanned stock entry Grocycode on /transfer (closes #2481) 2024-02-24 17:48:58 +01:00
Bernd Bestel
88d0d32ea0 Added changelog for #2480 2024-02-24 15:47:57 +01:00
Bernd Bestel
11ac985e57 Added a workaround for sporadically (not fully reproducible) empty modal iframes in Chrome based Browsers (references #2480 and #2421) 2024-02-24 15:36:43 +01:00
Bernd Bestel
ac26c5510b Prefill desired_servings by base_servings when creating a recipe (closes #2479) 2024-02-23 18:09:55 +01:00
Bernd Bestel
85bff136de Added changelog for #2477 2024-02-23 17:58:24 +01:00
bbx0
d2a878e98e Stream uploads to file (#2477)
* Stream uploads to file

* Adapt code style / use up to date reasonable chunk size

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2024-02-23 17:56:32 +01:00
Bernd Bestel
4d8f08eddd Also copy move_on_open when copying a product (fixes #2478) 2024-02-23 17:08:34 +01:00
Bernd Bestel
edf973df00 Improved meal plan item buttons (closes #2471) 2024-02-13 20:07:24 +01:00
Bernd Bestel
8497f37b24 Fixed product's last_price related to empty / 0 stock transactions (fixes #2470) 2024-02-13 13:12:56 +01:00
Bernd Bestel
40d1a9c3d0 Show the number of items per shopping list in the shopping lists dropdown (closes #2467) 2024-02-12 20:36:33 +01:00
Bernd Bestel
c7abed0d68 Restored staged changes (ref 27f9d70b56 and 7b1a864486) 2024-02-09 18:26:23 +01:00
Bernd Bestel
bf05434a5c Prepared next release 2024-02-09 17:32:35 +01:00
Bernd Bestel
18125d8989 Pulled translations from Transifex 2024-02-09 17:25:00 +01:00
Bernd Bestel
75f0af2bd3 Updated dependencies 2024-02-09 16:46:33 +01:00
Bernd Bestel
7b1a864486 Revert / disable 27f9d70b56 (not ready yet) 2024-02-09 16:38:55 +01:00
Bernd Bestel
f2f9a16e59 Fixed stock entry page consume amount handling (fixes #2397) 2024-02-09 16:29:19 +01:00
Bernd Bestel
9f94ba55a4 Improved API doc related to the /stock endpoint (closes #2456) 2024-02-03 09:28:18 +01:00
Bernd Bestel
15ab198af0 Enable night mode on /login if that's the system preferred color scheme (references #71) 2024-01-28 09:39:58 +01:00
Bernd Bestel
4659f51551 Fixed user create handling in embedded mode (closes grocy/grocy-desktop#51) 2024-01-15 17:10:36 +01:00
Bernd Bestel
33d5ec44d2 Again more iframe dialog handling optimizations (references #2421) 2024-01-13 20:27:35 +01:00
Bernd Bestel
fc072b13f2 More iframe dialog handling optimizations (references #2421) 2024-01-13 09:32:59 +01:00
Bernd Bestel
efae5fea5b Don't lazy load iframes (fixes #2421) 2024-01-10 21:52:54 +01:00
jan-karwowski
3aeecfa24d Fix data types in opeanapi description (#2433)
* In Openapi schema mark fields that return only date as date

next_due_data and last_uset were using date-time format instead of date

* In Openapi description fix type product_barcodes to be array

Openapi schema should say thatn product_barcodes field in
ProductDetailsResponse is an array of ProductBarcode not a single
object.

Make the value an array not a single field

* In openapi schema fix purchased date format in stock log entry

It should be just date not a date-time format.

---------

Co-authored-by: Jan Karwowski <jan_karwowski@wp.pl>
2024-01-09 18:49:38 +01:00
Bernd Bestel
bae83535dd Merge branch 'master' of https://github.com/grocy/grocy 2024-01-09 18:39:57 +01:00
Bernd Bestel
fb407a7fa7 Added changelog for #2432 2024-01-09 18:39:42 +01:00
Torqu3Wr3nch
151bd7f025 Fix blank/missing items in spending report (#2432)
* Fixes blank/missing items in spending report

Use left (outer) join when connecting product to optional product group

* Properly display ungrouped items in table and chart

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2024-01-09 18:36:09 +01:00
Bernd Bestel
99f448dd64 Strip spaces from uploaded file names (fixes #2415) 2023-12-30 19:49:21 +01:00
Bernd Bestel
7f7f1e8dce Added changelog for #2412 2023-12-25 08:49:29 +01:00
geoffwright240
6b69487bc5 Added 'category' filter to tasks view. (#2412)
* Added 'category' filter to tasks view.

* Remove extraneous css attributes.

* Applied code style rules

* Use correct column

* Task categories are not something that is translated...

* Added "Uncategorized" as additional filter option

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2023-12-25 08:47:21 +01:00
Bernd Bestel
ee01f41979 Support PHP 8.3, no longer support PHP 8.1 2023-12-16 15:08:59 +01:00
Bernd Bestel
97ecbd25b6 Pulled translations from Transifex 2023-12-16 15:07:59 +01:00
Bernd Bestel
9458eb8b90 Updated dependencies 2023-12-16 15:04:07 +01:00
Bernd Bestel
3c35a69c32 Optimized created API key table highlighting (closes #2403) 2023-12-11 22:03:00 +01:00
Bernd Bestel
c9bc10820d Fixed typo in localization string 2023-12-01 19:26:29 +01:00
Bernd Bestel
8f52aaeadc Handle stock userfields in generic entity interaction API endpoints (closes #2381) 2023-11-14 21:07:30 +01:00
Bernd Bestel
dc05476d09 Reload calendar after color config changed (references #2368) 2023-11-04 14:18:51 +01:00
Bernd Bestel
80d7284d72 Implemented calendar category colors (closes #2368) 2023-11-04 14:11:02 +01:00
Bernd Bestel
b3a5128dbd Pulled translations from Transifex 2023-11-04 13:26:58 +01:00
Bernd Bestel
7969145bbf Updated dependencies 2023-11-04 13:23:18 +01:00
Bernd Bestel
f01ca33c33 Optimized initial focus / workflow handling for recipeposform and shoppinglistitemform 2023-11-04 13:19:46 +01:00
Bernd Bestel
fdf5559c25 Fixed typo 2023-11-03 20:51:42 +01:00
Bernd Bestel
27f9d70b56 Implemented a way to use the external barcode lookup plugin also from within the frontend as a product picker workflow 2023-11-03 20:47:43 +01:00
Bernd Bestel
c9215a9a4e Added a workaround for the not working customRangeLabel option of the daterangepicker component (fixes #2353) 2023-10-04 16:46:24 +02:00
Bernd Bestel
69db4b558b Fixed typo 2023-10-01 21:43:28 +02:00
Bernd Bestel
35a4b75432 Added changelog for #2344 2023-09-19 18:08:36 +02:00
Chris Thorn
f36ad805b3 Optimize sidebar icon spacing (#2344)
* Update default.blade.php

Add `fa-fw` class to all side navigation icons to make them all fixed width

* Do this also for userentities

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2023-09-19 18:07:30 +02:00
Bernd Bestel
35766bf5b3 Optimized CurrentVolatileStock handling (fixes #2341) 2023-09-15 17:24:29 +02:00
Bernd Bestel
3308e79027 Use bind params when copying a recipe (fixes #2337) 2023-09-15 13:58:57 +02:00
Bernd Bestel
1e60f940e4 Properly handle empty select-multiple userfield (fixes #2339) 2023-09-15 13:43:58 +02:00
Bernd Bestel
c8891236e6 Optimized meal plan weekRecipe handling (fixes #2333) 2023-09-05 21:07:38 +02:00
Bernd Bestel
b0d6e24bd4 Fixed consume page location dropdown handling (fixes #2328) 2023-09-02 10:17:43 +02:00
Bernd Bestel
b2295ce6d2 Prepared next release 2023-09-02 09:28:19 +02:00
Bernd Bestel
32ce04a1b7 Pulled translations from Transifex 2023-09-02 09:25:43 +02:00
Bernd Bestel
dfa3262426 Updated dependencies 2023-09-02 09:15:11 +02:00
Bernd Bestel
1f7580af3f Fixed GetCurrentStock caching 2023-09-02 09:12:37 +02:00
Bernd Bestel
60adda2b42 Optimized performance of CurrentVolatileStock 2023-09-01 18:11:36 +02:00
Bernd Bestel
387a5f7dd3 Move GetParsedAndFilteredRequestBody into BaseApiController 2023-09-01 17:58:02 +02:00
Bernd Bestel
f6bdb6e836 Added new Userfield type "Number (currency)" (closes #2276) 2023-09-01 17:48:46 +02:00
Bernd Bestel
82d899d609 Optimized DataTables state save handling performance 2023-09-01 17:04:11 +02:00
Bernd Bestel
fdbb8a045a Optimized performance of GetProductDetails 2023-09-01 17:03:22 +02:00
Bernd Bestel
07db1f35bc Cache multiple single-key user setting queries (closes #2323) 2023-09-01 17:02:36 +02:00
Bernd Bestel
dde577b98b Updated README 2023-09-01 17:00:50 +02:00
Bernd Bestel
5080d776a7 Only accept application/json requests for (JSON) API requests 2023-09-01 00:53:25 +02:00
Bernd Bestel
8c21969b84 Added changelog for PR #2322 2023-08-22 19:43:43 +02:00
Aleksandar Kuzmanoski
13e99d3f07 stock_current view now uses cached QUCs -> Recipes consume 50% faster (#2322)
* stock_current view now uses cache__quantity_unit_conversions_resolved -> Recipes consume 50% faster

* Adapted code style

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2023-08-22 19:41:44 +02:00
Bernd Bestel
dedbee3181 Allow user editing in embedded (+ disabled authentication) mode (closes grocy/grocy-desktop#47) 2023-08-19 08:48:52 +02:00
Bernd Bestel
16f686deb8 Prepared next release 2023-08-19 08:24:52 +02:00
Bernd Bestel
973e4226b6 Pulled translations from Transifex 2023-08-19 08:18:36 +02:00
Bernd Bestel
6e22d3b100 Updated dependencies 2023-08-19 08:15:33 +02:00
Bernd Bestel
9b119da8e0 Merged the by @alkuzman contributed new quantity_unit_conversions_resolved view (closes #2297) 2023-08-19 08:13:34 +02:00
Bernd Bestel
03f9ba45ea Fixed initial product QU conversion handling (fixes #2312) 2023-08-16 17:05:18 +02:00
Bernd Bestel
a965d01fb9 Optimized server error display handling when consuming a recipe (closes #2310) 2023-08-15 18:51:40 +02:00
Bernd Bestel
a123535b0a Optimized locale number display handling (fixes #2309) 2023-08-15 09:35:40 +02:00
Bernd Bestel
3a2929c016 stockreports/spendings: Support grouping by store (closes #2308) 2023-08-14 18:12:40 +02:00
Bernd Bestel
106f25cc6b Fixed stock entry open button amount on /stockentries (fixes #2303) 2023-08-13 08:27:02 +02:00
Bernd Bestel
d6cc87ac86 More optimizations around edited stock entries handling (references #2292) 2023-08-13 00:27:37 +02:00
Bernd Bestel
a47bccab3f Added some comments to newest changed SQL views (references #2292) 2023-08-12 20:16:44 +02:00
Bernd Bestel
393a312186 More fixes regarding edited stock entries and calculating the products average price + price history (fixes #2292) 2023-08-12 18:08:12 +02:00
Bernd Bestel
7f21e2de34 Switched back to original gettext/gettext package
References https://github.com/php-gettext/Gettext/pull/289
2023-08-10 16:58:40 +02:00
Bernd Bestel
82ac996b3a Fixed typo 2023-08-09 22:36:50 +02:00
Bernd Bestel
827134c972 Changelog wording improvements 2023-08-09 22:34:30 +02:00
Bernd Bestel
787d5f11e0 Fixed dynamic manifest didn't work with enabled authentication 2023-08-09 21:00:35 +02:00
Bernd Bestel
2d2039f988 Fixed recipe cost/energy calculation (fixes #2301) 2023-08-08 17:59:10 +02:00
Bernd Bestel
268f0d8a50 Fixed typo 2023-08-08 09:43:17 +02:00
Bernd Bestel
9dde46d419 Changelog wording improvements 2023-08-07 22:13:47 +02:00
Bernd Bestel
162ba267a1 Changelog wording improvements 2023-08-07 22:12:00 +02:00
Bernd Bestel
4691b45510 Removed unnecessary calculation step in view uihelper_shopping_list (closes #2298) 2023-08-07 21:57:12 +02:00
Bernd Bestel
e2ebc037f2 Prepared next release 2023-08-06 15:29:28 +02:00
Bernd Bestel
550aa5565b Pulled translations from Transifex 2023-08-06 15:17:38 +02:00
Bernd Bestel
c105ebc979 Enabled Composer optimize-autoloader 2023-08-06 15:11:27 +02:00
Bernd Bestel
7ef744a995 Relate prices on the shopping to the there selected QU (closes #2294) 2023-08-06 14:31:38 +02:00
Bernd Bestel
ee4a082c74 Fixed handling of edited stock entries when calculating a product's average price (references #2292) 2023-08-06 14:05:35 +02:00
Bernd Bestel
1d7f7b2992 Cache expensive stock data calculations 2023-08-06 13:28:14 +02:00
Bernd Bestel
7689356a57 Changed manifest title 2023-08-06 09:28:41 +02:00
Bernd Bestel
1401ed5c00 Updated dependencies 2023-08-06 09:27:41 +02:00
Bernd Bestel
bae4a7f04c Added missing semicolon 2023-08-05 21:51:13 +02:00
Bernd Bestel
a44d746176 Fixed stock_edited_entries view (references #2292) 2023-08-05 21:44:22 +02:00
Bernd Bestel
3afb9643c4 Fix handling when there are no single edited stock entries at all (references #2292) 2023-08-05 18:28:49 +02:00
Bernd Bestel
61a3a4329b Unified edited stock transactions handling (fixes #2292) 2023-08-05 09:58:21 +02:00
Bernd Bestel
491ad8c791 Optimized indentation 2023-08-04 15:44:14 +02:00
Bernd Bestel
339a1ebffc Mention supported browsers in README 2023-08-04 15:41:44 +02:00
Bernd Bestel
1c35fecc85 Added the possibility to skip demo data generation in dev/demo/prerelease mode 2023-08-02 21:10:03 +02:00
Bernd Bestel
d006436d49 Upgraded PHP-CS-Fixer / applied optimized rules 2023-08-02 18:44:30 +02:00
Bernd Bestel
6c4cc00fd5 Added PHP 8.2 support 2023-08-01 21:23:59 +02:00
Bernd Bestel
847337443d Optimized /shoppinglist performance 2023-08-01 20:47:47 +02:00
Bernd Bestel
b74fbddd94 Use a dynamic (title / URL) manifest 2023-08-01 17:12:35 +02:00
Bernd Bestel
8b444a03e5 Simplified initial /mealplan start date handling (fixes #2286) 2023-07-31 21:29:28 +02:00
Bernd Bestel
e946ec79d5 Fixed typo 2023-07-31 18:27:53 +02:00
Bernd Bestel
ca740e8cee Improved product average shelf life calculation (references #2283) 2023-07-31 17:41:36 +02:00
Bernd Bestel
5d48b02b37 Added the possibility to log executed SQL statements (DEV mode only) 2023-07-31 17:08:55 +02:00
Bernd Bestel
73ad9d39ab Workaround for crap product specific QU conversions for migration 0207 (fixes #2285) 2023-07-31 16:58:41 +02:00
Bernd Bestel
fd7e24b7d1 Optimized StockService->GetProductDetails performance (fixes #2283) 2023-07-31 16:54:58 +02:00
Bernd Bestel
57ccb8645e Updated screenshots 2023-07-30 17:18:59 +02:00
Bernd Bestel
e8d6d455f4 grocy-desktop => Grocy Desktop 2023-07-29 21:17:59 +02:00
Bernd Bestel
f7c22ec384 Prepared next release 2023-07-29 14:44:48 +02:00
Bernd Bestel
98768bd846 Upgraded package swagger-ui-dist 2023-07-29 14:12:18 +02:00
Bernd Bestel
e52b1c5f60 Upgraded package php-di/php-di 2023-07-29 14:02:56 +02:00
Bernd Bestel
c263aba6a5 Updated dependencies 2023-07-29 14:00:24 +02:00
Bernd Bestel
edca302b71 Pulled translations from Transifex 2023-07-29 13:55:18 +02:00
Bernd Bestel
f6d6e933e3 Recalculate chore assignments when undoing an execution (fixes #2278) 2023-07-29 13:49:14 +02:00
Bernd Bestel
78e4e918c6 Added Estonian translation 2023-07-22 11:16:06 +02:00
Bernd Bestel
fa35d933e0 Pulled translations from Transifex 2023-07-22 11:00:45 +02:00
Bernd Bestel
9ae7c72e87 Unified calendar time format (closes #2266) 2023-07-05 21:30:00 +02:00
Bernd Bestel
c415e2f8da Fixed a (theoretical, not practically relevant for the target use case of Grocy) SQL injection possibility (closes #2259) 2023-06-22 15:07:47 +02:00
Bernd Bestel
297cc57244 Expose recipes_pos_resolved via the API (read only) (closes #2258) 2023-06-21 22:06:46 +02:00
Bernd Bestel
1496a58673 Show sidebar scroll bar only on hover (closes #2255) 2023-06-17 10:39:26 +02:00
Bernd Bestel
d05038e311 Exclude products with hide_on_stock_overview enabled in current stock info on /stockoverview (fixes #2250) 2023-06-08 22:15:33 +02:00
Bernd Bestel
de4c6e8b60 Renamed third party packages directories 2023-06-03 17:36:01 +02:00
Bernd Bestel
70bb014c9f Removed pre-release special version handling 2023-05-24 20:32:48 +02:00
Bernd Bestel
8c033ff6c8 Revert "Cache StockService->GetCurrentStock result"
This (partly) reverts commit bc5051351a.
2023-05-23 21:26:53 +02:00
Bernd Bestel
8c79cc4f8e Fixed new API key modal 2023-05-23 21:22:54 +02:00
Bernd Bestel
89c6d6683a Remove unused frontend package on /manageapikeys 2023-05-23 20:34:24 +02:00
Bernd Bestel
d0e0102752 API keys can now have a description 2023-05-23 20:31:51 +02:00
Bernd Bestel
bc5051351a Cache StockService->GetCurrentStock result 2023-05-23 17:34:38 +02:00
Bernd Bestel
08c1efa0ad Unified product-/chore-/battery-card modal handling 2023-05-23 17:32:54 +02:00
Bernd Bestel
2633d3d1a5 Fixed stock entry label info handling when the corresponding feature flag is disabled 2023-05-22 22:33:36 +02:00
Bernd Bestel
aec71bd408 Fixed typo 2023-05-22 22:09:20 +02:00
Bernd Bestel
10661706b9 Updated README 2023-05-22 22:08:32 +02:00
Bernd Bestel
2c0a71078f Fixed productcard opened amount display 2023-05-22 21:53:15 +02:00
Bernd Bestel
02fe3f2119 Show to amount of "Label per unit" stock entry labels (closes #2241) 2023-05-22 21:23:19 +02:00
Bernd Bestel
55adc140b2 Updated README 2023-05-21 20:41:06 +02:00
Bernd Bestel
04f362b723 Added a product context menu on /stockjournal (the same as on /stockoverview) (closes #2239) 2023-05-21 18:40:59 +02:00
Bernd Bestel
979c67b44c Various JS optimizations 2023-05-21 18:01:47 +02:00
Bernd Bestel
825321593b Optimized content spacing with collapsed sidebar 2023-05-21 17:33:40 +02:00
Bernd Bestel
99db10a490 Fixed <select> style 2023-05-21 14:47:37 +02:00
Bernd Bestel
2cba3ce7e9 Updated dependencies 2023-05-21 14:41:00 +02:00
Bernd Bestel
b53cdd4c42 Use minified files of packages (where available) 2023-05-21 14:29:19 +02:00
Bernd Bestel
cd7139c6cf Optmized imports 2023-05-21 14:19:01 +02:00
Bernd Bestel
c3dd1c4187 Cache routes 2023-05-21 14:13:05 +02:00
Bernd Bestel
89761ac141 Fixed syntax error 2023-05-21 14:12:43 +02:00
Bernd Bestel
f427849e89 Load all frontend packages conditionally 2023-05-21 10:56:38 +02:00
Bernd Bestel
d16d976d0b Simplified viewjs / active page handling 2023-05-20 18:20:30 +02:00
Bernd Bestel
ddf0ff0aef Various small layout adjustments 2023-05-20 11:03:13 +02:00
Bernd Bestel
fb57d9ef13 Fixed frontend translation with numbered arguments did not work (after upgrading gettext-translator) 2023-05-20 09:58:33 +02:00
Bernd Bestel
c43fe24e47 Changed font 2023-05-20 09:31:03 +02:00
Bernd Bestel
6ab5bc3a29 Optimized sidebar collapsed state / active nav handling 2023-05-19 21:14:57 +02:00
Bernd Bestel
ecb9f53bb4 Declare logo width 2023-05-19 20:59:03 +02:00
Bernd Bestel
6e3182884a Changed app icon background color 2023-05-19 19:23:50 +02:00
Bernd Bestel
ceb50774dc Adjusted README logo height 2023-05-19 18:12:50 +02:00
Bernd Bestel
5f65f2abd0 New logo 2023-05-19 18:08:26 +02:00
Bernd Bestel
49daed6c2b Upgraded some frontend dependencies 2023-05-19 17:23:32 +02:00
Bernd Bestel
628e779902 Moved sidebar / menu layout into own (customized) component 2023-05-19 15:12:11 +02:00
Bernd Bestel
99546815f9 Remove unneeded meta tags 2023-05-19 14:19:14 +02:00
Bernd Bestel
7ceba3c0c1 Updated README 2023-05-18 17:55:46 +02:00
Bernd Bestel
d03175f75a Added a separate QU for displaying prices (closes #2225) 2023-05-18 13:37:13 +02:00
Bernd Bestel
f4639c9bb2 Stream files directly from disk (instead of loading them completely in memory first) 2023-05-18 10:51:14 +02:00
Bernd Bestel
f6d77ac8d7 Pulled translations from Transifex 2023-05-18 10:44:17 +02:00
Bernd Bestel
d43f59d9a9 Updated README 2023-05-18 10:43:40 +02:00
Bernd Bestel
631f03e62c Optimized DataTables fixedOrder handling (fixes #2235) 2023-05-17 22:44:42 +02:00
Bernd Bestel
778cf847d3 Fixed more missing fields when copying a product (fixes #2231) 2023-05-17 21:10:14 +02:00
Shamshid
02a71a5edb fix syntax error (#2230) 2023-05-17 21:04:39 +02:00
Bernd Bestel
629333e1ab Fixed QU conversion factor selection (API) 2023-05-14 17:05:28 +02:00
Bernd Bestel
dd5bd3852a Optimized imports 2023-05-13 14:43:51 +02:00
Bernd Bestel
491412807c Fixed table column visibility selection 2023-05-13 14:28:50 +02:00
Bernd Bestel
9cdb0908d6 Make it possible to hide locations/stores/QUs/product_groups/task_categories (closes #2222) 2023-05-13 14:24:52 +02:00
Bernd Bestel
b5d3e68d68 Added a "today button" to the calendar (closes #2218) 2023-05-12 20:53:04 +02:00
Bernd Bestel
48564b5286 Fixed that default_consume_location_id wasn't copied on copying a product (fixes #2223) 2023-05-12 20:48:44 +02:00
Bernd Bestel
8bdb74a8e0 Optimized button click tooltip hide handling (fixes #2206) 2023-05-03 08:32:49 +02:00
Bernd Bestel
5ab31f726a Support dynamic "today" for MEAL_PLAN_FIRST_DAY_OF_WEEK (closes #2205) 2023-05-01 14:49:02 +02:00
Bernd Bestel
7ee79ec56c Fixed permission check when deleting API keys (fixes #2204) 2023-04-30 22:32:08 +02:00
Bernd Bestel
df4907f5d4 Fixed a theoretical (not relevant for SQLite) SQL injection possibility (references #2201) 2023-04-29 08:57:05 +02:00
Bernd Bestel
a4992ff602 Optimized purchase/inventory price hint / last price suggestion decimals handling 2023-04-24 18:17:39 +02:00
Bernd Bestel
f4874ed8d0 Prefill barcode note on /purchase and /inventory (closes #2193) 2023-04-17 19:54:24 +02:00
Bernd Bestel
84bd74a1bc Show the product card also on /products (closes #2185) 2023-04-13 20:36:21 +02:00
Bernd Bestel
16011b91c6 Added a filter option to only show currently out-of-stock products on /products (closes #2192) 2023-04-13 20:28:28 +02:00
Bernd Bestel
2bce428339 Fixed missing plural localization strings.pot
(Report from a translator on Transifex)
2023-04-12 09:06:39 +02:00
Bernd Bestel
a56de30268 Fixed /stockoverview "Min. stock amount" column sorting (fixes #2189) 2023-04-03 18:35:38 +02:00
Bernd Bestel
71d44edb8c Optimized week recipe handling in mealplan (fixes #2168) 2023-04-01 22:04:30 +02:00
Bernd Bestel
cc6b01de08 Added changelog for #2135 (also references #64) 2023-04-01 17:12:03 +02:00
Travis Raup
340832c361 Feature: Stock Purchase Metrics (#2135)
* Feature: Stock Purchase Metrics

* chart update

* Refactor to chartjs

* More suggestion edits

- locale in javascript
- global translations
- commit migrations sql file

* Rename 0215.sql to 0216.sql

Fixed merge conflict

* Fixed merge conflict

* Applied code style

* Added missing demo data translations

* Removed unused package "canvasjs"

* Don't include daterangepicker globally when only needed on a single page / fixed view section imports

* Rename this to "Spendings" / name it more generically "Stock reports"

* Reuse the existing product_price_history view

* Final cleanup

* Whitespace fix

---------

Co-authored-by: Travis Raup <travis.raup@platform.sh>
Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2023-04-01 17:05:41 +02:00
Bernd Bestel
98469248eb Optimized tracking button handling on /choresoverview (closes #2186) 2023-03-31 20:12:06 +02:00
Bernd Bestel
3d01854fa1 Don't use double quotes for SQL string literals (references #2170) 2023-03-16 21:16:27 +01:00
Bernd Bestel
756133a9eb Removed shopping list table fixed order (fixes #2167) 2023-03-16 18:52:41 +01:00
Bernd Bestel
1090f070c9 Optimized shopping list done items filter handling (fixes #2169) 2023-03-16 18:47:01 +01:00
Bernd Bestel
6857796ef0 Fixed produces product amount handling when consuming meal plan shadow recipes (references #2160) 2023-03-12 22:45:04 +01:00
Bernd Bestel
792c710bdc Fixed produces product handling when consuming meal plan shadow recipes (fixes #2160) 2023-03-12 16:35:18 +01:00
Bernd Bestel
7336693ca2 Optimized stock_missing_products view (fixes #2154) 2023-03-02 19:36:57 +01:00
Bernd Bestel
91700e7dae Fixed JS syntax error 2023-02-06 20:42:11 +01:00
Bernd Bestel
c9c0baefeb Optimized datetime Userfields handling (fixes #2108) 2023-02-06 20:36:26 +01:00
Bernd Bestel
b18bd2ff87 Fixed table dropdown menu overflow handling when columns are reordered (fixes #2130) 2023-02-06 20:25:51 +01:00
Bernd Bestel
d9667b4534 Removed type conversions where no longer needed
PHP 8.1 PDO SQLite now returns native data types
2023-02-06 20:22:10 +01:00
Bernd Bestel
d8d3c3ef0b Split the quick consume and open amount product option (closes #2127) 2023-02-05 20:37:39 +01:00
Bernd Bestel
b64d726c42 Added a new config option for energy unit display (closes #2109) 2023-02-05 15:55:45 +01:00
Bernd Bestel
0bd698c968 Print stock entry labels when consuming a "Produces product" recipe (closes #2123) 2023-02-05 15:24:28 +01:00
Bernd Bestel
9ef5045c9b Added changelog for #2118 2023-02-05 15:09:13 +01:00
Webysther Sperandio
902cb20710 Add Sub feature flag FEATURE_FLAG_RECIPES_MEALPLAN (#2118)
* Update routes.php

Added sub feature FEATURE_FLAG_RECIPES_MEALPLAN

* Update default.blade.php

Added sub feature flag FEATURE_FLAG_RECIPES_MEALPLAN

* Update SystemController.php

Added Sub feature flags FEATURE_FLAG_RECIPES_MEALPLAN

* Update config-dist.php

Sub feature flags FEATURE_FLAG_RECIPES_MEALPLAN

* Update routes.php

TYPO

* Code formatting / structure

---------

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2023-02-05 15:06:59 +01:00
Bernd Bestel
1e9a4d9590 Added Romanian translation 2023-02-05 14:55:23 +01:00
Bernd Bestel
5d7efebd40 Pulled translations from Transifex 2023-02-05 14:43:15 +01:00
Bernd Bestel
b9c58423a9 Updated dependencies 2023-02-05 14:40:25 +01:00
Bernd Bestel
efc7b999bb Fixed product average price/last price/price history chart handling regarding empty/0 prices (fixes #2106) 2023-01-13 13:19:22 +01:00
Bernd Bestel
995df64054 Support OFFSET without LIMIT in API query filters (closes #2105) 2023-01-12 13:32:12 +01:00
Bernd Bestel
a5788511e3 Optimized productform sticky footer spacing (fixes #2104) 2023-01-11 16:25:06 +01:00
Bernd Bestel
4e56dee6f0 Finalized "Auto reprint stock entry label" (closes #2092) 2023-01-05 20:12:15 +01:00
Bernd Bestel
3b160659f3 Typo 2023-01-05 18:28:57 +01:00
Bernd Bestel
83fa02d8ad Added an option to reprint stock entry labels when editing them (closes #2092) 2023-01-05 18:15:21 +01:00
Bernd Bestel
daf5ad33c7 Show recipe ingredients/preparation side by side in fullscreen mode (closes #2051) 2023-01-05 17:44:07 +01:00
Bernd Bestel
597abe236d AddMissingProductsToShoppingList also on adding/editing products (references #2094) 2023-01-04 22:54:12 +01:00
Bernd Bestel
0c8e8cab97 Revert "Refresh product/chore/battery card only when actually visible"
This reverts commit c934bfb7b3.
2023-01-04 20:06:19 +01:00
Bernd Bestel
f057ae7e06 Add note to barcode created by the workflow InplaceAddBarcodeToExistingProduct on /purchase and /inventory (closes #2093) 2023-01-04 19:56:55 +01:00
Bernd Bestel
c0fbc4adaf Fixed /stockoverview value column sort format (fixes #2088) 2023-01-01 20:33:08 +01:00
Bernd Bestel
efae0b193d Add amount to barcode created by the workflow InplaceAddBarcodeToExistingProduct on /purchase (closes #2085) 2022-12-29 11:21:33 +01:00
Bernd Bestel
c934bfb7b3 Refresh product/chore/battery card only when actually visible 2022-12-26 20:22:38 +01:00
Bernd Bestel
76500c57bd Optimize recipe ingredient costs/calories calculation when only_check_single_unit_in_stock is used (closes #780) 2022-12-26 19:48:26 +01:00
Bernd Bestel
3f2ad17460 Make it possible to add recipes from /recipes to the meal plan (closes #2003) 2022-12-26 14:25:33 +01:00
Luís Neto
c60a1783da Fix typo (conume -> consume) in 3.3.2 changelog (#2083) 2022-12-26 13:43:46 +01:00
Bernd Bestel
0585e80c70 Implemented "Default quantity unit consume" (closes #1845) 2022-12-26 11:11:55 +01:00
Bernd Bestel
39d1f49431 Fixed demo data generation 2022-12-26 10:12:29 +01:00
Bernd Bestel
2d62f8ddeb Automatically create a default (product specific 1 to 1) QU conversion when a product with qu_stock != qu_purchase was created and when no default QU conversion applies 2022-12-26 09:28:18 +01:00
Bernd Bestel
b76abf54ab Simplified qu_factor_purchase_to_stock handling 2022-12-26 09:20:41 +01:00
Bernd Bestel
337cbb73ee Added new .devtools script 2022-12-26 09:11:49 +01:00
Daniel Albert
79590cd5ac Add migration for improved quantity_unit_conversions_resolved view (#2082) 2022-12-26 09:06:17 +01:00
Bernd Bestel
383ac49919 Added note in README and Changelog about better performance when using a more recent SQLite version (references #2056) 2022-12-26 08:46:44 +01:00
Bernd Bestel
15f7ac3da0 Fixed required SQLite version in PrerequisiteChecker 2022-12-25 20:53:49 +01:00
Bernd Bestel
46c4cdb81a Return numbers as numbers on all API endpoints 2022-12-25 20:49:11 +01:00
Bernd Bestel
639ef0da5b Fixed PHP 8.1 deprecation notice 2022-12-25 20:35:25 +01:00
Bernd Bestel
0229d187ae Removed qu_factor_purchase_to_stock (migrated existing factors to normal product specific QU conversions) 2022-12-25 19:48:22 +01:00
Bernd Bestel
dea6f3f820 Replace also the unit when displaying a recipe ingredient with a variable amount (closes #2080) 2022-12-24 13:06:27 +01:00
Bernd Bestel
dd409b4bf9 Fixed consume amount calculation when consuming multiple substituted subproducts at once and when multiple/different conversion factors were involved (fixes #2076) 2022-12-21 21:00:49 +01:00
Bernd Bestel
407344e86a Fixed recipe ingredient costs/calories calculation when product substitution and unit conversions is involved at the same time (fixes #2075) 2022-12-21 20:16:22 +01:00
Bernd Bestel
f6e0ff11f1 Fixed column visibility handling when there is a shadow rowgroup column (fixes #2074) 2022-12-20 22:11:35 +01:00
Bernd Bestel
2ebb9b2cd9 Show product group Userfields on the shopping list (closes #2069) 2022-12-18 20:56:02 +01:00
Bernd Bestel
38a4ad8ec4 Upgraded to PHP 8.1 2022-12-10 15:19:11 +01:00
Bernd Bestel
84e3707f4f Optimized .devtools 2022-12-06 20:41:09 +01:00
Bernd Bestel
fce6458df6 Optimized modal dialog sizing 2022-12-04 21:59:20 +01:00
Bernd Bestel
018449c648 Added more demo QU conversions 2022-12-04 20:39:16 +01:00
Bernd Bestel
8175b1bcfe Simplified product specific QU display/edit and added more demo QU conversions 2022-12-04 20:25:33 +01:00
Bernd Bestel
c1dea5c254 Optimized /quantityunitconversionsresolved view 2022-12-04 19:52:48 +01:00
Bernd Bestel
50fac692ad Added a dialog to show product related resolved QU conversions (references #2056 and #1360) 2022-12-04 19:02:15 +01:00
Daniel Albert
d889e9d3ad Fix quantity_unit_conversions_resolved view (#2057)
This change makes the view work for products to which only default
conversions apply.
Before, they would not have appeared in the results.
2022-12-04 18:39:33 +01:00
Bernd Bestel
4be447fc60 Expose quantity_unit_conversions_resolved via the API (read only) (references #2056 and #1360) 2022-12-04 13:41:44 +01:00
Bernd Bestel
daa0a59c5f Support transitive QU conversions on the frontend (references #2056, closes #1360) 2022-12-04 13:12:01 +01:00
Bernd Bestel
df39f94fca Added changelog for #2056 2022-12-04 12:37:50 +01:00
Bernd Bestel
46313e2c75 Applied code formatting rules for #2056 2022-12-04 12:33:12 +01:00
Daniel Albert
541c0be6be Add support for transitive unit conversions (#2056)
* Add support for transitive unit conversions

* Rewrite quantity_unit_conversions_resolved view
2022-12-04 12:18:18 +01:00
Bernd Bestel
3b3212d101 Updated README + Changelog regarding supported PHP runtime info 2022-11-29 20:03:40 +01:00
Bernd Bestel
f03bb5eeee Optimized default consume location empty check (references #2053) 2022-11-28 17:58:30 +01:00
Bernd Bestel
6affa01f81 Added a "Clear done items" button to the shopping list (closes #1999) 2022-11-19 19:45:00 +01:00
Bernd Bestel
605ceb1b19 Fixed typos 2022-11-19 19:35:10 +01:00
Bernd Bestel
7d4a9602ab Return the battery object in endpoint /batteries (closes #2045) 2022-11-19 19:33:50 +01:00
Bernd Bestel
eb370dad1e Fixed changelog typo 2022-11-13 14:22:29 +01:00
Bernd Bestel
8676b86575 Prepared next release 2022-11-12 18:24:01 +01:00
Bernd Bestel
6036786153 Fix/Workaround for DataTables ColReorder bug with data-order attributes (fixes #2019) 2022-11-12 18:10:32 +01:00
Bernd Bestel
88950f00d5 Pulled translations from Transifex 2022-11-12 17:31:17 +01:00
Bernd Bestel
f90ced5a39 Updated dependencies 2022-11-12 17:29:04 +01:00
Bernd Bestel
2b2dd0568b Move back again to original tempusdominus-bootstrap-4 package (references #143 and #2036) 2022-11-12 17:25:09 +01:00
Bernd Bestel
3f60a2b5fa Move back again to own forked tempusdominus-bootstrap-4 package (fixes #2036, references #143) 2022-11-10 11:42:28 +01:00
Bernd Bestel
3070448555 Fixed granular user permission checking in GenericEntityApiController (fixes #2025) 2022-10-17 21:00:10 +02:00
Bernd Bestel
80a873da3e Removed old products.barcode field in grocy.openapi.json (references #2023) 2022-10-12 21:07:03 +02:00
Bernd Bestel
e8f76e5694 Prevent adding recipe ingredients with a unit for which no conversion exists (closes #2013)
Wasn't a problem of the web frontend, only possible by externally/manually using the API and not thinking about that that's bullshit.
2022-09-30 12:32:39 +02:00
Bernd Bestel
fa49b449dd Allow img style attribute in HTML filter (fixes #2011) 2022-09-28 21:04:41 +02:00
Bernd Bestel
121050960c Fixed conflicting php-cs-fixer VSCode setting 2022-09-28 11:17:03 +02:00
Bernd Bestel
bb0cc50ffc Added Ukrainian translation (closes #2008) 2022-09-26 13:31:35 +02:00
Bernd Bestel
e1967bd603 Allow chevrons in HTML filter (fixes #2007) 2022-09-25 22:39:06 +02:00
Bernd Bestel
a5c2157320 Fixed more chore form validation edge cases (fixes #2001) 2022-09-20 15:02:24 +02:00
Bernd Bestel
ff056f8d81 Raise minimum SQLite version in PrerequisiteChecker as mentioned in #1939 2022-09-03 19:13:40 +02:00
Bernd Bestel
af4715e17f Fixed product average price rounding 2022-08-29 20:56:15 +02:00
Bernd Bestel
68aad90a59 Optimize SQLite database file after migrations have run 2022-08-28 20:45:22 +02:00
Bernd Bestel
24c9247663 Make it possible to edit a user without necessarily updating the users password (closes #1942) 2022-08-27 14:54:52 +02:00
Bernd Bestel
7e2f30396f Fixed consume recipe product_id handling /w parent/child products (closes #1982) 2022-08-27 14:25:55 +02:00
Bernd Bestel
e8dc334758 Always allow move_on_open (closes #1983) 2022-08-27 11:27:49 +02:00
Bernd Bestel
f1bc2cc40f Fixed that consuming partially fulfilled recipes was possible (fixes #1981) 2022-08-27 00:08:23 +02:00
Bernd Bestel
c0d0b8fc90 Fixed default consume rule ORDER BY handling related to stock_next_use (fixes #1979) 2022-08-26 11:15:15 +02:00
Bernd Bestel
d883474f03 Fixed LABEL_PRINTER_HOOK_JSON check was missing when running label printer WebHooks client side (fixes #1978) 2022-08-25 18:46:49 +02:00
Bernd Bestel
c396c2a84c Also update from_qu_id and to_qu_id of inverse unit conversions automatically (closes #1977) 2022-08-24 21:10:22 +02:00
Bernd Bestel
52e2c6d480 Fixed qu_id_stock change handling related to product_barcode amounts (fixes #1976) 2022-08-22 23:58:34 +02:00
Bernd Bestel
2fbd559105 Fixed qu_id_stock change handling related to the products own amount properties (fixes #1975) 2022-08-22 23:46:47 +02:00
Bernd Bestel
58c6b72d77 Fixed qu_id_stock change handling when needed conversion is only defined by the products qu_factor_purchase_to_stock (fixes #1973) 2022-08-22 20:11:57 +02:00
Bernd Bestel
dfe9868a48 Fixed qu_id_stock change handling when needed conversion is only defined globally (fixes #1974) 2022-08-22 19:53:58 +02:00
Bernd Bestel
06968ac289 Fixed stock entry Userfield edit handling (fixes #1969) 2022-08-18 21:29:19 +02:00
Bernd Bestel
9b52168b94 Fixed /userfields/{entity}* endpoints OpenAPI definition (fixes #1967) 2022-08-14 23:09:27 +02:00
Bernd Bestel
54d91b8b76 Added changelog for #1962 2022-08-06 17:38:43 +02:00
Akosh Pinter
312dd8a200 Fixes for losing Stock Note field content #1961 (#1962)
* Fixed losing Note field content #1961

Fixed losing Note field content when splitting stock entries #1961

* Applied code formatting rules

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2022-08-06 17:35:11 +02:00
Bernd Bestel
57d70851c8 Fixed stock overview page status button counters related to the product option "Never show on stock overview" (fixes #1956) 2022-07-24 21:36:29 +02:00
Bernd Bestel
5b53175ed6 Handle null Userfield values in userfieldsform component (fixes #1953) 2022-07-22 16:47:23 +02:00
Bernd Bestel
721a0ce417 Move back to original tempusdominus-bootstrap-4 package (references #143) 2022-07-19 16:40:12 +02:00
Bernd Bestel
0b532f7624 Fixed StockService->ConsumeProduct $productStockAmount check (fixes #1949) 2022-07-18 17:35:35 +02:00
Bernd Bestel
e64df711e2 Optimized dynamic leading zeros rounding in productamountpicker (fixes #1943) 2022-07-14 17:01:12 +02:00
Bernd Bestel
8cb9157c73 Fixed shopping list item form product barcode scan handling (fixes #1940) 2022-07-12 19:00:40 +02:00
Bernd Bestel
b57ba59243 Fixed unreproducible edge case JS error when rescheduling chores (references #1938) 2022-07-09 09:00:15 +02:00
Bernd Bestel
a85af22d6a Allow h1-h6 tags in HTMLPurifier (fixes #1932) 2022-07-03 08:24:32 +02:00
Bernd Bestel
9b2c96c085 Added Lithuanian translation 2022-07-02 16:46:46 +02:00
Bernd Bestel
a80e048c2d Optimized product_barcodes handling (references #1928) 2022-06-30 13:38:30 +02:00
Bernd Bestel
bef261d869 Fixed average shelf life (productcard) for edited stock entries (fixes #1924) 2022-06-27 20:26:32 +02:00
Bernd Bestel
dbf660f953 Fix stock_auto_decimal_separator_prices input value handling (references #1917) 2022-06-11 13:51:19 +02:00
Bernd Bestel
2de87eb446 Only apply stock_auto_decimal_separator_prices when value is not empty and not already contains a decimal separator (fixes #1917) 2022-06-11 13:25:52 +02:00
Bernd Bestel
9498dd9c67 Improve /purchase tab order handling (closes #1915) 2022-06-11 12:48:20 +02:00
Bernd Bestel
7cb19f2c66 Prepared next release 2022-06-10 18:13:01 +02:00
Bernd Bestel
8faa76e965 Pulled translations from Transifex 2022-06-10 18:12:30 +02:00
Bernd Bestel
264ed3887a Updated dependencies 2022-06-10 17:53:53 +02:00
Bernd Bestel
fe92caaed4 Fixed price history chart data parsing (fixes #1914) 2022-06-09 22:14:00 +02:00
Bernd Bestel
48e9467a99 Fixed that rescheduling of "Track date only"-chores for today was not possible (fixes #1908) 2022-06-05 23:48:52 +02:00
Bernd Bestel
27582611c1 Split user setting stock_decimal_places_prices into separate settings for input/display (closes #1893) 2022-06-04 14:09:35 +02:00
Bernd Bestel
337ca7d4ba Pulled translations from Transifex 2022-06-04 13:48:20 +02:00
Bernd Bestel
1ef64025c5 Fixed potential JS error when copying product with empty but not null description 2022-06-04 13:32:31 +02:00
Bernd Bestel
cd41c27ee1 Fixed plural form missing handling (references #1878 and #1903) 2022-06-01 22:33:13 +02:00
Bernd Bestel
fd7a4e02be Fixed chore form validation edge case (fixes #1905) 2022-06-01 20:59:57 +02:00
Bernd Bestel
3d3e4bac75 Fixed edit shopping list item QU initialisation 2022-06-01 20:43:42 +02:00
Bernd Bestel
3b8944d61b Fixed recipes_pos_resolved.missing_amount calculation (references #1903) 2022-06-01 20:32:31 +02:00
Bernd Bestel
6da637ab66 Fixed API filter >= and <= comparison (fixes #1904) 2022-05-30 17:20:15 +02:00
Bernd Bestel
e757cab0da Fixed recipe ingredient costs/calories when using substituted product with unit conversions (fixes #1903) 2022-05-29 22:48:48 +02:00
Bernd Bestel
aeae1b0db3 Added changelog for #1891 2022-05-29 17:08:03 +02:00
Thomas Johanns
dd966fd198 Handle stock_id in OpenProductByBarcode (#1891)
* Handle stock_id in OpenProductByBarcode

* Code formatting

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2022-05-29 17:05:41 +02:00
Bernd Bestel
dfdf45fa56 Fixed meal plan product/note calendar items links (fixes #1897) 2022-05-23 22:28:45 +02:00
Bernd Bestel
af7de61c43 Typo 2022-05-14 17:11:40 +02:00
Bernd Bestel
5406448be0 Use singular localization form when plural form is not provided (closes #1878) 2022-05-14 17:10:48 +02:00
Bernd Bestel
e21875bf2a Updated changelog 2022-05-14 17:04:19 +02:00
Bernd Bestel
a5e3442602 Don't enforce first/last name when creating users (closes #1888) 2022-05-14 16:59:11 +02:00
Bernd Bestel
9c1fd176c0 Fixed shopping_list_to_stock_workflow_auto_submit_when_prefilled user settings control initialization (fixes #1875) 2022-04-29 11:46:50 +02:00
Bernd Bestel
8ab511361a Do "auto add missing products to shopping list" also on product open actions (fixes #1873) 2022-04-27 22:50:20 +02:00
Bernd Bestel
845e69fb96 Escape HTML when displaying recipes on /mealplan (references #1868) 2022-04-21 21:32:28 +02:00
Bernd Bestel
c4388a6f8f Fixed product edit page stock journal button link (fixes #1867) 2022-04-21 19:34:08 +02:00
Bernd Bestel
6ad761e067 Optimized LDAP error handling (references #1865) 2022-04-19 16:56:48 +02:00
Bernd Bestel
900a49a36a Fixed JS / display errors on refreshing a row on /stockentries 2022-04-18 18:42:40 +02:00
Bernd Bestel
44c6865ba1 Added changelog for #1863 2022-04-18 18:32:28 +02:00
Rosemary Orchard
5e30e89737 Add support for "Move on Open" (#1863)
* Add functionality to move a product when it is opened

* Update the API to support this (and some other new fields)

* Remove console, update move on open when either the default or the consume location change

* Fix conflict from fridge

* Ignore .DS_STORE from macOS

* Fix the migration conflict

* Fix the default location not appending properly

* Revert changes no longer needed

* Fix the checkbox disable logic, and call the function on page load

* Simplify the transfer to use the existing function (which also adds logs)

* Only move it if it's moving

* Code formatting / naming

* Clarify help text (it's not always about one unit, but about the corresponding amount opened)

* Handle splitted stock entries + optimized/unified product property checks

* Added UI feedback on auto moving

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2022-04-18 18:25:08 +02:00
Bernd Bestel
0152f1c69d Fixed typo 2022-04-17 21:32:54 +02:00
Bernd Bestel
00ac935367 Enforce a conversion factor of 1 between QU stock/purchase when they are the same (references #1862) 2022-04-17 21:28:58 +02:00
Bernd Bestel
d4bd6b2fb3 Fixed /stock/products/{productId}/add request body parameter validation (fixes #1860) 2022-04-15 15:40:55 +02:00
Bernd Bestel
f7eb8cc127 Optimized stock entry form initial input field focus 2022-04-12 22:54:12 +02:00
Bernd Bestel
c0a727fcfc Fixed recipe ingredient stock fulfillment icon for nested recipes (fixes #1851) 2022-04-09 22:07:56 +02:00
Bernd Bestel
e9421e9102 Prepared next release 2022-04-08 17:31:25 +02:00
Bernd Bestel
04d6496c05 Pulled translations from Transifex 2022-04-08 17:28:33 +02:00
Bernd Bestel
893cfe13cd Set proper HTTP status when redirecting to /login 2022-04-08 17:06:51 +02:00
Bernd Bestel
150cfba455 Don't show invisible columns in table options 2022-04-07 19:46:13 +02:00
Bernd Bestel
632db0d8d1 Fixed new user settings naming 2022-04-07 19:25:27 +02:00
Bernd Bestel
e0c72c05c2 Reviewed changelog 2022-04-07 18:33:39 +02:00
Bernd Bestel
01a43f59ca Pulled translations from Transifex 2022-04-07 18:13:57 +02:00
Bernd Bestel
e1928a7265 Updated dependencies 2022-04-07 18:13:10 +02:00
Bernd Bestel
73e539604f Don't show relative time for invalid dates 2022-04-07 18:12:49 +02:00
Bernd Bestel
35474f2466 Improved QU conversion validation messages (references #1844) 2022-04-07 18:12:02 +02:00
Bernd Bestel
ca77ba6d19 Improved QU conversion validation messages (references #1844) 2022-04-07 07:26:06 +02:00
Bernd Bestel
6ecf94073d Automatically create/update/delete inverse QU conversions (closes #1844) 2022-04-06 22:21:21 +02:00
Bernd Bestel
cefc1b7b9c Fixed shopping list item form initial input field focus 2022-04-06 21:32:35 +02:00
Bernd Bestel
cab34df2d6 Related the price on /inventory to the selected QU instead of QU stock (closes #1346) 2022-04-06 21:27:47 +02:00
Bernd Bestel
e91fa02974 Optimized shopping list item form success message handling 2022-04-06 20:58:16 +02:00
Bernd Bestel
59277c898a Fixed shopping list item form initial input field focus 2022-04-06 20:54:42 +02:00
Bernd Bestel
36b8309943 Unified purchase / stock entry form field order 2022-04-06 20:50:51 +02:00
Bernd Bestel
76d6342156 Show stock userfields on the stock entry edit form 2022-04-06 19:08:17 +02:00
Bernd Bestel
4da546fc80 Don't compact stock entries with userfields 2022-04-06 19:07:33 +02:00
Bernd Bestel
af4dd446ab Fixed QU conversion form from_qu_id initialisation (references #1843) 2022-04-05 20:57:46 +02:00
Bernd Bestel
5df81a74c6 Fixed QU conversion form from_qu_id initialisation (fixes #1843) 2022-04-05 20:50:19 +02:00
Bernd Bestel
03bba4b9e5 Fixed "Search for recipes containing this product" (fixes #1842) 2022-04-05 18:21:25 +02:00
Bernd Bestel
adaa54ba8b Only load night mode stylesheet when night mode is actually on 2022-04-05 18:18:38 +02:00
Bernd Bestel
4d4ae9812b Make it more clear that QU stock = QU purchase means always a conversion factor of 1 (references #1841) 2022-04-05 00:08:27 +02:00
Bernd Bestel
59cd071512 Fixed localization string 2022-04-04 22:45:57 +02:00
Bernd Bestel
a676e06c65 Optimized clear filter buttons 2022-04-04 22:42:10 +02:00
Bernd Bestel
bbaaf4c17d Font Awesome 6 upgrade fixes 2022-04-04 21:17:46 +02:00
Bernd Bestel
efbb0ebf6a Removed debug statement 2022-04-04 21:10:35 +02:00
Bernd Bestel
6f5eb42f2a Updated issue templates 2022-04-04 21:08:50 +02:00
Bernd Bestel
cca35a302c Make clear filter buttons more compact 2022-04-04 21:07:14 +02:00
Bernd Bestel
e336f24225 Upgraded Font Awesome to v6 2022-04-04 20:27:51 +02:00
Bernd Bestel
d871fe7aa8 Unified settings pages 2022-04-04 20:02:42 +02:00
Bernd Bestel
b6d7ef403c Some night mode style refinements 2022-04-04 18:34:22 +02:00
Bernd Bestel
7ddfe83ffa Removed unused localization strings 2022-04-04 18:33:50 +02:00
Bernd Bestel
70f5e616c1 Optimized datetimepicker (references #1478) 2022-04-03 22:32:25 +02:00
Bernd Bestel
61ed756dd0 Implemented "default consume location" handling (closes #1365) 2022-04-03 21:15:05 +02:00
Bernd Bestel
e69e7a9a9a Added a location filter to the stock entries page 2022-04-03 19:28:59 +02:00
Bernd Bestel
5c6f84a68e General code review 2022-04-03 19:14:54 +02:00
Bernd Bestel
3091a06194 Optimized meal plan entry add/edit dialog titles 2022-04-03 19:08:36 +02:00
Bernd Bestel
49a2b8232f Removed unused localization strings 2022-04-03 17:07:13 +02:00
Bernd Bestel
d4eb5f07db Make the meal plan entry day editable (closes #775) 2022-04-03 17:03:23 +02:00
Bernd Bestel
97626b4a59 Added userfield default values for userfield types date & datetime (closes #1166) 2022-04-03 14:32:31 +02:00
Bernd Bestel
3efecb8bed Make it possible to manually re-assign chores (closes #1492, references #1830) 2022-04-03 13:56:14 +02:00
Bernd Bestel
a5294262e6 Added a user setting to automatically add missing products to the shopping list (closes #1266) 2022-04-03 13:00:14 +02:00
Bernd Bestel
34859ada02 Make new barcode added via productpicker InplaceAddBarcodeToExistingProduct flow immediately searchable (closes #839) 2022-04-03 12:33:22 +02:00
Bernd Bestel
35ed7299af Removed unnecessary user setting checks regarding night mode (references #1334) 2022-04-02 19:31:54 +02:00
Bernd Bestel
2042db29ee Use prefers-color-scheme for night mode by default (closes #1334) 2022-04-02 19:26:55 +02:00
Bernd Bestel
3e4f2eaf5d Delete userfield values when deleting a product/chore/battery/userfield (closes #1632) 2022-04-02 18:05:54 +02:00
Bernd Bestel
6a50f74a14 Optimizations regarding displaying prices (closes #1743) 2022-04-02 17:49:35 +02:00
Bernd Bestel
7ad979cba9 Also convert prices when changing a products stock QU (references #1326) 2022-04-02 16:00:47 +02:00
Bernd Bestel
a5ff947936 Show the substituted product for parent product ingredients currently not in-stock (closes #1797) 2022-04-02 11:54:07 +02:00
Bernd Bestel
05485b3a4c Make it possible to add multiple files / PDFs to equipment by using Userfields (closes #978) 2022-04-02 10:37:53 +02:00
Bernd Bestel
8c1deefebf Show a little optional checkbox to mark recipe ingredients as done (closes #1606) 2022-04-01 22:43:49 +02:00
Bernd Bestel
ba289d6e6a Optimized location content sheet layout / don't show empty locations 2022-04-01 22:10:24 +02:00
Bernd Bestel
f7c33a4579 Optionally show out of stock products on the location content sheet (closes #1641) 2022-04-01 21:55:06 +02:00
Bernd Bestel
ebfc55064e Prevent adding "Disable own stock"-products to stock (references #564) 2022-04-01 19:52:43 +02:00
Bernd Bestel
ccc59dfc8b Added a new product option "Disable own stock" (closes #564) 2022-04-01 18:49:17 +02:00
Bernd Bestel
b53d1a076f Reviewed latest changes regarding price handling views 2022-04-01 17:04:09 +02:00
Bernd Bestel
cd60c239af Squashed commit
Improved locale number display on stockoverview page
Fixed choresoverview chore execution color highlighting
Highlight recipe ingredients based on the new due score (references #1813)
Reworked current price handling views (mostly needed for recipes)
2022-03-31 22:52:38 +02:00
Bernd Bestel
fbb84277bf Unified form validation handling 2022-03-30 18:00:28 +02:00
Bernd Bestel
77d75d16df Added missing chore field in grocy.openapi.json 2022-03-30 17:48:22 +02:00
Bernd Bestel
62fcc89ddc Fixed recipes status search (references #1813) 2022-03-30 17:39:26 +02:00
Bernd Bestel
d3a39270de Implemented notes and Userfields for stock entries (closes #443) 2022-03-30 17:32:53 +02:00
Bernd Bestel
2983687f34 Fixed changelog typo 2022-03-29 20:40:08 +02:00
Bernd Bestel
8e68477a78 Implemented a "recipes due score" (closes #1813) 2022-03-29 20:38:26 +02:00
Bernd Bestel
91b984d52d Make user settings available in SQLite (needed for #1813) 2022-03-29 19:44:01 +02:00
Bernd Bestel
acebed5aae Clear manually rescheduled date on chore execution (references #1830) 2022-03-27 16:11:16 +02:00
Bernd Bestel
f41a219760 Optimized chores and tasks demo data 2022-03-27 14:48:19 +02:00
Bernd Bestel
fa07b861ad Optimized reschedule-chore-modal (references #1830) 2022-03-26 20:25:17 +01:00
Bernd Bestel
d65734c896 Added the possibility to manually reschedule chores (closes #1830) 2022-03-26 18:30:26 +01:00
Bernd Bestel
033cd306c1 Improved products/chore merge dialogs form validation 2022-03-26 11:17:08 +01:00
Bernd Bestel
585ec1212d Fixed chore tracking page skip button disabled handling (references #1836) 2022-03-26 11:06:03 +01:00
Bernd Bestel
7c3e7daa56 Typo 2022-03-26 10:35:15 +01:00
Bernd Bestel
81b54182de Improved form validation handling (closes #1836) 2022-03-26 10:34:00 +01:00
Bernd Bestel
6aae97de73 Fixed number input page reload behavior (fixes #1835) 2022-03-25 18:17:20 +01:00
Bernd Bestel
f0db2a7709 Fixed that tasks without a due date were highlighted in red (fixes #1833) 2022-03-23 19:35:48 +01:00
Bernd Bestel
9db66048d1 Fixed chore skip handling via /choresoverview (references #1830) 2022-03-23 18:22:50 +01:00
Bernd Bestel
5dc745f301 Use the given time when skipping chores via /choretracking (references #1830) 2022-03-23 17:51:05 +01:00
Bernd Bestel
00466972e2 Typo 2022-03-23 17:36:36 +01:00
Bernd Bestel
bda230537a Fixed purchase/consume page handling when FEATURE_FLAG_STOCK_LOCATION_TRACKING is disabled (fixes #1829) 2022-03-23 17:35:06 +01:00
Bernd Bestel
dce14b8999 Fixed chore upgrade handling when having nonsensical user data (fixes #1826) 2022-03-23 17:17:39 +01:00
Bernd Bestel
23f285c3fb Fixed recipes gallery view search (fixes #1825) 2022-03-22 13:21:09 +01:00
Bernd Bestel
790368cdf4 Added changelog for #1819 2022-03-14 22:49:28 +01:00
miguelangel-nubla
e2c1d2e226 fix: can't print in landscape (#1819)
* fix: can't print in landscape

Layout settings are hidden in the print dialog when printing a page like the mealplan.Bootstrap 4 bug https://github.com/twbs/bootstrap/issues/25629

* Moved @page rule to @media print section

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2022-03-14 22:47:12 +01:00
Bernd Bestel
a4b1a80cdc Fixed meal plan note item edit button tooltip (fixes #1821) 2022-03-14 22:43:07 +01:00
Bernd Bestel
0ba1a82e01 Show the products grocycode as a (hidden by default) column on /products (closes #1820) 2022-03-14 22:39:35 +01:00
Bernd Bestel
7ea9984fd3 Make it possible to change a products stock QU after it was once added to stock (closes #1326) 2022-03-13 17:09:07 +01:00
Bernd Bestel
7532626123 Optimized datetimepicker relative time display handling 2022-03-07 17:57:14 +01:00
Bernd Bestel
632a542236 Fixed stock overview numeric sorting of value columns (fixes #1811) 2022-03-06 09:31:47 +01:00
Bernd Bestel
1a82d0599c Use child product substitution on consuming during chore execution (fixes #1807) 2022-03-05 09:03:57 +01:00
Bernd Bestel
620f938065 Fixed multi-nested recipe serving amount calculation (fixes #1806) 2022-03-03 17:38:51 +01:00
Bernd Bestel
54a8c331c2 Prefill default QU conversion factor for qu_factor_purchase_to_stock for new products (closes #1803) 2022-03-01 18:03:01 +01:00
Bernd Bestel
45d1c87975 Fixed "Treat opened as out of stock" missing stock amount handling (fixes #1804) 2022-03-01 18:02:04 +01:00
Bernd Bestel
cc2a137783 Fixed calories locale number display (fixes #1802) 2022-02-28 20:59:58 +01:00
Bernd Bestel
bab0e1d5fb Fixed battery charge cycle undo handling (fixes #1800) 2022-02-26 17:38:58 +01:00
Bernd Bestel
a027077211 Enforce stock QU on /purchase for tare weight handling enabled products (fixes #1795) 2022-02-20 19:33:55 +01:00
Bernd Bestel
5bfdddd52b Delete QU conversions when deleting QU (theoretical problem, closes #1796) 2022-02-20 19:18:10 +01:00
Bernd Bestel
777fcbae77 Use products stock QU for product_barcodes when empty (references #1794) 2022-02-20 17:07:22 +01:00
Bernd Bestel
8abb55b058 Updated changelog 2022-02-20 16:11:17 +01:00
Bernd Bestel
823088b9cd Updated changelog 2022-02-20 16:08:42 +01:00
Bernd Bestel
1aa7db9c2a Added an daily-same-time chore period type (closes #1793) 2022-02-20 16:03:50 +01:00
Bernd Bestel
e220b3e9f3 Fixed products product stock entry price (fixes #1791) 2022-02-19 09:03:42 +01:00
Bernd Bestel
01c7d4e49a Added changelog for #1788 2022-02-16 08:45:15 +01:00
Bernd Bestel
486a58909d Merge pull request #1788 from andreheuer/master
Fixed battery label printing
2022-02-16 08:42:49 +01:00
André Heuer
db43a4bf3a Fixed battery label printing 2022-02-15 23:02:07 +01:00
Bernd Bestel
424bfa9313 Fixed formatting 2022-02-15 18:43:02 +01:00
Bernd Bestel
926b7d8aea Table options: Only allow columns to be grouped for which it makes sense (closes #1535) 2022-02-15 18:40:42 +01:00
Bernd Bestel
e9a7b10730 Make recipe card buttons a little bigger 2022-02-15 18:39:38 +01:00
Bernd Bestel
8338421912 Update issue templates 2022-02-15 18:38:58 +01:00
Bernd Bestel
21d5952950 Fixed batteries stock overview page was broken when having any Userfield (fixes #1786) 2022-02-14 17:52:24 +01:00
Bernd Bestel
c5b47badad Typo 2022-02-13 20:38:21 +01:00
Bernd Bestel
66bd3f0d59 Added a new API endpoint to get all stock entries per location
References https://www.reddit.com/r/grocy/comments/srfwfs
2022-02-13 20:34:49 +01:00
Bernd Bestel
2457c2c2fd Optimized returnto-links handling (fixes #1785) 2022-02-13 20:07:29 +01:00
Bernd Bestel
d38a5efb3d New Transifex command-line client compatibility 2022-02-13 18:25:42 +01:00
Bernd Bestel
6aa3dcc44a Removed accidentally added localization strings 2022-02-13 18:04:13 +01:00
Bernd Bestel
37744822d8 Handle not having any QU in LocalizationService (fixes #1783) 2022-02-12 22:31:35 +01:00
Bernd Bestel
1344e84534 Fixed recipe consume stock fulfillment checking (frontend and API) (fixes #1781) 2022-02-12 22:08:10 +01:00
Bernd Bestel
8e3a9d6c04 Updated some screenshots 2022-02-11 19:56:12 +01:00
Bernd Bestel
9b2a551ee4 Updated screenshots 2022-02-11 19:35:13 +01:00
Bernd Bestel
f52b8e11bb Support camera barcode scanning in recipepicker (references #1562) 2022-02-11 18:18:17 +01:00
Bernd Bestel
79b2dc3ed8 Prepared next release 2022-02-11 17:51:53 +01:00
Bernd Bestel
222c518a5f Added grocycode for recipes (closes #1562) 2022-02-11 17:49:30 +01:00
Bernd Bestel
51fdefaede Removed unused properties 2022-02-11 17:48:44 +01:00
Bernd Bestel
a5a53d1d1e Optimized print layout 2022-02-11 17:47:35 +01:00
Bernd Bestel
8e033d035a Reviewed config-dist.php 2022-02-11 17:46:40 +01:00
Bernd Bestel
88452a187c Fixed column selection of ix_chores_log_performance1 index 2022-02-11 17:46:17 +01:00
Bernd Bestel
cfaf2838d4 Pulled translations from Transifex 2022-02-11 17:45:30 +01:00
Bernd Bestel
107f51f4ae Update bug report issue template 2022-02-11 17:41:19 +01:00
Bernd Bestel
c304578443 Updated issue templates 2022-02-11 17:39:10 +01:00
Bernd Bestel
84476ad093 Updated SECURITY.md 2022-02-10 21:51:03 +01:00
Bernd Bestel
0f7d57d0a0 Added https://grocy.info/#say-thanks as GitHub sponsors link (references #1714) 2022-02-10 21:44:01 +01:00
Bernd Bestel
b2b04c843d Reviewed changelog 2022-02-10 20:33:03 +01:00
Bernd Bestel
296897d91a Pulled translations from Transifex 2022-02-10 20:27:51 +01:00
Bernd Bestel
a7cc867cf0 Updated dependencies 2022-02-10 20:01:55 +01:00
Bernd Bestel
69a7ea6057 Added a new "adaptive" chore period type (closes #1495) 2022-02-10 18:06:33 +01:00
Bernd Bestel
091a93ff4e Reviewed README 2022-02-10 18:04:33 +01:00
Bernd Bestel
f88bad4bde Remove period_days for old dynamic-regular chores on migration 2022-02-09 20:28:03 +01:00
Bernd Bestel
7d4c9fefa9 Removed the dynamic regular chore period type (since it's the same as daily) 2022-02-09 20:25:16 +01:00
Bernd Bestel
10d7d44825 Added new hourly chore period type (closes #266) 2022-02-09 20:02:11 +01:00
Bernd Bestel
c9a2041fae Optimized chore schedule help text 2022-02-09 19:52:19 +01:00
Bernd Bestel
0d1f2ad09d Squashed commit
Optimized new chore start date handling (references #1612)
Change yearly chore schedule to be on the same day each year (closes #817)
Use the last price for out of stock ingredients (closes #779)
Make it optionally possible to show the recipes list full-width (closes #1772)
2022-02-09 17:48:21 +01:00
Bernd Bestel
aaf248c1b3 Added missing localization string 2022-02-08 21:21:19 +01:00
Bernd Bestel
ce74062a9f Added new chore property to API schema definition (references #1612) 2022-02-08 20:39:36 +01:00
Bernd Bestel
61a1b1428a Added a chore start date option (closes #1612) 2022-02-08 20:35:47 +01:00
Bernd Bestel
411dbabc90 Show the meal plan section for a meal plan entry types on the calendar (references #1582) 2022-02-08 19:09:17 +01:00
Bernd Bestel
66cf7e4ffa Squashed commit
Updated dependencies
Added the possibility to skip chore schedules (closes #1486)
Show the meal plan section on the corresponding calendar events (closes #1582)
Make it possible to define a time for meal plan sections and use that time for the corresponding calendar events (references #1582)
Added a changelog template
Make it possible to toggle the meal plan calendar view on bigger screens (closes #1678)
2022-02-08 18:08:26 +01:00
Bernd Bestel
4279bf6445 Prefill the stock entry amount when using a stock entry grocycode on /consume (closes #1736) 2022-02-07 20:48:17 +01:00
Bernd Bestel
dd36301460 Use same plural definition for QU translator (references #1705) 2022-02-07 20:42:54 +01:00
Bernd Bestel
d1d52aea44 Move FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT to per product option (closes #1753) 2022-02-07 19:12:31 +01:00
Bernd Bestel
12e5377c40 Split application translation strings and QU strings (fixes #1705) 2022-02-06 21:09:34 +01:00
Bernd Bestel
28f7700dac Fixed recipe ingredient stock fulfillment shopping list amount comparison (fixes #1717) 2022-02-06 20:02:19 +01:00
Bernd Bestel
9eb46df517 Added a button to quickly create multiple tasks without having to close/reopen the dialog (closes #1776) 2022-02-06 18:35:19 +01:00
Bernd Bestel
e6a6d7ae42 Added new relative date input shorthand (closes #1773) 2022-02-06 18:13:25 +01:00
Bernd Bestel
da54b945da Fixed task edit page initial due date (fixes #1774) 2022-02-06 17:49:04 +01:00
Bernd Bestel
7e6efb4a14 Optimized no-sidebar pages spacing / centering (closes #1760) 2022-01-24 21:17:45 +01:00
Bernd Bestel
fa3e705673 Show chore description on chorecard (closes #1759) 2022-01-23 20:02:16 +01:00
Bernd Bestel
cf52e5ec96 Make it possible to disable chores/tasks/batteries due soon filters/highlighting (closes #1485) 2022-01-23 19:20:23 +01:00
Bernd Bestel
04a3069294 Added workarounds to make Summernote embeds responsive (closes #1758) 2022-01-23 18:28:50 +01:00
Bernd Bestel
8f7f88c8ad Added missing plural translations for new strings 2022-01-23 17:51:51 +01:00
Bernd Bestel
aef646e9df Highlight chores/tasks/batteries due today in a separate color + status filter (closes #1740) 2022-01-23 17:42:55 +01:00
Bernd Bestel
dfd6262f4a Fixed missing recipe ingredient amount when "Only check if any amount is in stock" is enabled and when there are unit conversions (fixes #1718) 2022-01-23 13:56:41 +01:00
Bernd Bestel
49f44d241b Fixed meal plan edit product entry initial amount 2022-01-23 12:53:21 +01:00
Bernd Bestel
f6c750a1ea Fixed meal plan calories display (fixes #1757) 2022-01-23 12:43:16 +01:00
Bernd Bestel
1950e4b513 Added changelog for #1750 2022-01-16 16:21:21 +01:00
Bernd Bestel
c190002ebb More recipes page performance optimizations (references #1750) 2022-01-16 16:08:57 +01:00
Bernd Bestel
3b3f079754 Recipes page performance optimizations (references #1750) 2022-01-16 15:48:49 +01:00
Bernd Bestel
dfc274643f Optimized user settings save handling (fixes #1747) 2022-01-16 14:58:42 +01:00
Bernd Bestel
e3808c71b9 Added changelog for #1746 2022-01-16 14:49:10 +01:00
Marc Ole Bulling
187654d8b3 Added support for reading auth header from env variable (#1746)
* Added support for reading auth header from env variable

* Check if variable is set, more accurate error description

* Formatting

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2022-01-16 14:46:04 +01:00
Bernd Bestel
8ec0d9319b Exclude tasks without an due date from the iCal export (fixes #1745) 2022-01-11 20:54:23 +01:00
Bernd Bestel
ec75779bf3 Streamlined integer/number format declarations 2022-01-11 20:48:53 +01:00
Bernd Bestel
894568d2ee Added an missing API endpoint parameter (references #1741) 2022-01-11 20:32:53 +01:00
Bernd Bestel
c1952e98bc Show stock journal entries of deleted users / fixed default user handling (fixes #1725) 2022-01-06 15:14:32 +01:00
Bernd Bestel
789e6a5291 Don't crash the recipes page when the amount contains user-desired (and manually edited) bullshit (fixes #1691) 2022-01-06 14:36:35 +01:00
Bernd Bestel
ae5fad290f Sort entities on the /api page 2022-01-06 14:17:02 +01:00
Bernd Bestel
003a416b74 Expose products_last_purchased and products_average_price (read only, closes #1732) 2022-01-06 14:16:23 +01:00
Bernd Bestel
3a6f04f770 Optionally remove only done shopping list items (/stock/shoppinglist/clear API endpoint, closes #1730) 2022-01-06 14:07:29 +01:00
Bernd Bestel
0b36d02aa1 Fixed prefilled consume page initialization (fixes #1716) 2022-01-06 13:54:42 +01:00
Bernd Bestel
5f8299cf4a Also show the logout button when using externally managed auth (fixes #1709) 2022-01-06 13:46:20 +01:00
Bernd Bestel
ad0dbdfc22 Lookup product barcodes case insensitive (fixes #1734) 2022-01-06 13:42:38 +01:00
Bernd Bestel
8455b5a64a Allow HTML tags for the product description column on the stock overview page (fixes #1735) 2022-01-06 13:38:00 +01:00
Bernd Bestel
a711bbd8f6 Print stock entry labels also on inventory when adding products (closes #1713) 2021-12-09 18:32:59 +01:00
Bernd Bestel
3e20c2cc3d Added changelog for #1710 2021-12-06 22:25:27 +01:00
FloSet
1e8a1d7ffb Update LdapAuthMiddleware.php (#1710) 2021-12-06 22:22:10 +01:00
Graham Christensen
c8c63bea5d Label printing: include the model number for the label paper (#1701) 2021-11-30 08:45:25 +01:00
Bernd Bestel
4ea20ce076 Added changelog for #1695 2021-11-25 19:10:08 +01:00
JOKer
b2eec2b111 Improve sorting for stock entries view (#1695)
In the stockentries view the ordering by expiration date, amount, price
and purchase date did not work as expected. b5fc64cf already addressed a
similar issue for other views. This commit now does the same: set
DataTables types on the specific columns.

Since the units being part of the "amount" column break numeric sorting,
this commit adds a "data-order" field for that column, so numeric
sorting can still work. This is done in aligment with the stockoverview
page, that already contains such an entry to facilitate proper sorting.
2021-11-25 19:08:53 +01:00
Bernd Bestel
8876c6cf95 Added changelog for #1687 2021-11-15 20:09:04 +01:00
Tallyrald
98bf36dbc8 Replace Timeago with momentjs (#1687)
* Replaced timeago with moment.fromNow

* Fixed datetime when best_before_date is empty

* Removed the now unnecessary timeago package

* Removed not longer localization strings

* Check for empty instead of string comparison

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2021-11-15 20:05:10 +01:00
Bernd Bestel
b83e4f53b1 Don't print stock entry labels when not desired (server side WebHook execution) (references #1686) 2021-11-15 09:06:19 +01:00
Bernd Bestel
33ca6070f4 Fixed typo 2021-11-14 19:39:27 +01:00
Bernd Bestel
c2b675eb06 Deleted empty changelog file 2021-11-14 16:36:20 +01:00
Bernd Bestel
e552f4b730 Updated dependencies 2021-11-14 16:31:34 +01:00
Bernd Bestel
12f6296c75 Reviewed changelog 2021-11-14 16:30:19 +01:00
Bernd Bestel
3842f05ce9 Pulled translations from Transifex 2021-11-14 16:27:37 +01:00
Bernd Bestel
4d21668265 Added the possibility to merge chores 2021-11-14 16:19:52 +01:00
Bernd Bestel
693dcc1020 Prepared next release 2021-11-14 15:59:58 +01:00
Bernd Bestel
f5562602f0 Always show the add item button on the shopping list on mobile (closes #1645) 2021-11-14 15:50:48 +01:00
Bernd Bestel
86aa8f19f7 Fixed typos 2021-11-14 15:37:10 +01:00
Bernd Bestel
43ba3b4920 Added missing API changelog (references #1676) 2021-11-14 15:33:13 +01:00
Bernd Bestel
6070507b04 Fixed per unit stock grocycodes weren't unique per unit (fixes #1676) 2021-11-14 15:26:38 +01:00
Bernd Bestel
fc413a05d1 Simplified stock entry label printing options (on purchase) (references #1647) 2021-11-13 18:26:01 +01:00
Bernd Bestel
89b87156de Added changelog for #1672 2021-11-13 17:41:51 +01:00
Graham Christensen
a7f3f64d89 StockService: Set the product's bestBeforeDate to the freezer date if it is being purchased to a freezer (#1672)
* StockService: Set the product's bestBeforeDate to the freezer date if it is being purchased to a freezer

* Formatting / feature flag checks / proper data type comparision

* Prefill due date also on location change

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2021-11-13 17:41:04 +01:00
Bernd Bestel
10bd5ce900 Added a new "Presets for new products" stock setting for the "Default due days" option of new products (closes #1552) 2021-11-13 17:05:23 +01:00
Bernd Bestel
a6ffe8480a Show stock QU hint also for the energy field on the product edit page (closes #1682) 2021-11-13 16:45:55 +01:00
Bernd Bestel
2a2335c8f4 Use original column index when accessing data table columns (fixes #1684) 2021-11-12 18:26:19 +01:00
Bernd Bestel
4338ccc132 Restore the original due date when undoing a product opened transaction (fixes #1659) 2021-11-12 18:12:34 +01:00
Bernd Bestel
f2bef554a4 Fixed track date only chores next_estimated_tracking time comparision (fixes #1655) 2021-11-12 18:02:46 +01:00
Bernd Bestel
ab53a157e4 Allow backslashes in API query filters (fixes #1649) 2021-11-12 17:52:32 +01:00
Bernd Bestel
beae32ef23 Added the products average price as a hidden by default column on the stock overview page (closes #1677) 2021-11-09 19:39:32 +01:00
Bernd Bestel
787c885ccf Fixed addnewproduct productpicker flow shopping list selection on return (fixes #1646) 2021-11-08 22:09:48 +01:00
Bernd Bestel
286351b6d2 Fixed modal dialogs / iframes initial input focus (fixes #1665) 2021-11-08 21:59:02 +01:00
Bernd Bestel
29371163ad Fixed night mode over midnight time range check (fixes #1673) 2021-11-08 21:38:19 +01:00
Bernd Bestel
3f88b8dfa2 Fixed issue templates 2021-11-08 17:39:33 +01:00
Bernd Bestel
1c161b2b29 Added changelog for #1664 2021-11-08 17:36:29 +01:00
Bernd Bestel
5ea8ec2dda Update issue templates 2021-11-08 17:36:16 +01:00
Corbo
eb8c9848eb dark bg was missing in dropdown, text was dark on dark bg in product ellipsis (#1664)
Signed-off-by: corbolais <corbolais@gmail.com>
2021-11-08 17:29:34 +01:00
Bernd Bestel
2b97ac7c1c Added buttons to the products stock entries/journal on the product edit page (like on the productcard) (closes #1670) 2021-11-08 17:21:15 +01:00
Bernd Bestel
3c656ba618 Allow renaming the default shopping list (closes #1667) 2021-11-08 17:08:37 +01:00
Bernd Bestel
edddfe234c Include duesoon/overdue/expired products for the belowminstockamount filter on the stock overview page (closes #1666) 2021-11-08 17:06:20 +01:00
Bernd Bestel
8105dea17f Added changelog for #1661 2021-11-03 21:50:44 +01:00
Dmitri Iouchtchenko
dc1954cb05 Add name to stay_logged_in checkbox (#1661)
The attribute was dropped in 9942a2d.
2021-11-03 21:47:35 +01:00
Bernd Bestel
ea63246a12 Apply timezone for iCalendar events (closes #1637) 2021-10-05 20:55:29 +02:00
Bernd Bestel
196bdbe246 Added SECURITIY.md (references #1643) 2021-10-05 15:36:57 +02:00
Bernd Bestel
01ddeb4dfd Added data_generation_scripts 2021-10-02 17:39:36 +02:00
Bernd Bestel
282168f92c Potentially fix a type mismatch problem (fixes #1629) 2021-09-29 09:21:45 +02:00
Bernd Bestel
3c74d92eb0 Prepared next release 2021-09-27 18:21:28 +02:00
Bernd Bestel
fe622cacb2 Updated dependencies 2021-09-27 18:19:04 +02:00
Bernd Bestel
5ddb438134 Pulled translations from Transifex 2021-09-27 18:18:09 +02:00
Bernd Bestel
35469c3d98 Fixed QU resolve priority (fixes #1616) 2021-09-27 18:09:30 +02:00
Bernd Bestel
b32a26cf7e Typo 2021-09-27 17:50:38 +02:00
Bernd Bestel
bed7965989 Fixed undo consume stock transaction location handling (references #1602) 2021-09-27 17:50:19 +02:00
Bernd Bestel
19ff782c00 Fixed consume transaction journal location handling (fixes #1602) 2021-09-27 17:46:42 +02:00
Bernd Bestel
cebb368a28 Enforce min_stock_amount for child products where the parent has cumulate_min_stock_amount_of_sub_products enabled (fixes #1595) 2021-09-27 17:39:00 +02:00
Bernd Bestel
038917b030 Don't show battery grocycode when not available 2021-09-27 17:20:52 +02:00
Bernd Bestel
04d826943c Don't include events without a start time in iCal export (fixes #1625) 2021-09-24 13:22:24 +02:00
Bernd Bestel
e0735ce2e4 Hide stock value on productcard when FEATURE_FLAG_STOCK_PRICE_TRACKING is disabled 2021-09-24 13:13:38 +02:00
Bernd Bestel
849c281912 Allow spaces in API filter values (fixes #1624) 2021-09-22 10:12:57 +02:00
Bernd Bestel
c06bb7784a Include OS and client information in easy error info copy/paste and on the about dialog 2021-09-20 20:16:41 +02:00
Bernd Bestel
b9fff4954a Fixed modal backdrop z-index (references #1589) 2021-09-19 16:20:06 +02:00
Bernd Bestel
7aa9e5748e Allow to add a product picture on product creation (closes #1620) 2021-09-19 16:06:16 +02:00
Bernd Bestel
6175afa6be Don't apply the barocde qu_id if empty (fixes #1619) 2021-09-19 10:07:25 +02:00
Sebastian Ecker
5563e7ed4c StockLogEntry Property is date instead of date-time (#1617) 2021-09-17 16:22:26 +02:00
Bernd Bestel
305f846dbf Implemented bottom-sticky save buttons for product and chore edit forms (closes #1589) 2021-09-15 14:59:11 +02:00
Bernd Bestel
3f850c540b Fixed stock overview context menu item disabled handling (fixes #1609) 2021-09-15 14:24:50 +02:00
Bernd Bestel
2c3af45f5c Added missing changelog 2021-09-15 14:14:24 +02:00
Bernd Bestel
230901a28a Added changelog for #1599 2021-09-15 14:11:44 +02:00
Travis Howse
30e1a5c9b0 Store the list of buttons at the workflow start and iterate over that as the workflow progresses. (#1599) 2021-09-15 14:08:23 +02:00
Bernd Bestel
616e1dd5d7 Fixed negative number plural form handling (fixes #1601) 2021-09-06 22:26:31 +02:00
Bernd Bestel
a323bca9ec Added check for mbstring PHP extension (required by eluceo/ical, references #1603) 2021-09-06 22:19:36 +02:00
Bernd Bestel
14bb04d285 Allow any letters in API filter values (fixes #1591) 2021-08-27 21:05:46 +02:00
Bernd Bestel
edd372f8c4 Optimized chore/battery tracking input focus handling 2021-08-27 20:54:27 +02:00
Bernd Bestel
b4a7642af5 Reload shopping list page on list clearing 2021-08-27 20:39:47 +02:00
Bernd Bestel
580f49e69f Update README.md 2021-08-27 20:30:09 +02:00
Bernd Bestel
22db124624 Optimized ReverseProxyAuthMiddleware error message 2021-08-22 12:55:09 +02:00
Bernd Bestel
e88294eb40 Strikethrough reverted changes 2021-08-21 22:16:44 +02:00
Bernd Bestel
ae3bacf8fe Fixed changelog typos 2021-08-21 22:12:41 +02:00
Bernd Bestel
90305ca8d7 Prepared next release 2021-08-21 20:24:18 +02:00
Bernd Bestel
3967b28481 Fixed stock overview dynamic < min. stock amount background handling 2021-08-21 20:20:16 +02:00
Bernd Bestel
2d67adedd7 Updated dependencies 2021-08-21 20:11:45 +02:00
Bernd Bestel
ef271c6247 Pulled translations from Transifex 2021-08-21 20:10:28 +02:00
Bernd Bestel
2c0b6368e1 Revert "Return numbers as numbers on all API endpoints" (14cd6ca3bf, fixes #1564) 2021-08-20 21:45:56 +02:00
Bernd Bestel
1d5ca5ed64 Fixed external barcode lookup (plugin) add product handling related to barcodes (fixes #1568) 2021-08-19 19:56:43 +02:00
Bernd Bestel
4d0c5502a1 Added changelog for #1584 2021-08-19 19:48:00 +02:00
David Mott
a0cf58b974 fix: make stockentry grocycodes consume the actual stock entry not the product in general (#1584)
* fix: make stockentry grocycodes consume the actual stock entry not the product in general

if the stock_entry_id is in the request body use this instead of the stockentry grocycode
this may not be the correct way to interpret this but one of them has to win

* Undo formatting changes

* fix: add variable definition and reorder args used in ConsumeProduct

* Simplify

* Fix this also for transferring a product

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2021-08-19 19:44:39 +02:00
Bernd Bestel
61a58ddef0 Fixed Userfield value assignment handling (/objects/{entity} API endpoint) (fixes #1572) 2021-08-17 18:23:06 +02:00
Bernd Bestel
3608eec8fb Fixed FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS clear shopping list confirm message handling (fixes #1315) 2021-08-17 18:05:32 +02:00
Bernd Bestel
cebf7a3e54 Don't consider inactive products to be missing (fixes #1578) 2021-08-17 18:00:33 +02:00
Bernd Bestel
23be96b5d6 Restore the rest of "orderFixed" (DataTables rowgroup option) (again closes #1534) 2021-08-17 17:52:28 +02:00
Bernd Bestel
7f70f0ec07 Fixed chore/battery camera barcode scanning blur event handling (fixes #1585) 2021-08-17 17:48:45 +02:00
Bernd Bestel
8e552f1146 Added changelog for #1581 2021-08-15 10:46:37 +02:00
David Mott
95cb9ffb90 fix: confirm grocycode is of PRODUCT type in GetProductIdFromBarcode (#1581)
* fix: confirm grocycode is of PRODUCT type in GetProductIdFromBarcode

* Fixed formatting

* Don't output the given input (for security reasons)

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2021-08-15 10:45:05 +02:00
Bernd Bestel
d23f730a0b Added changelog for #1559 2021-08-06 20:20:00 +02:00
Kris
b539c93319 Hide elements when printing (#1559)
* Hide elements when printing

* Hide elements when printing

* Also hide the title menu collapse button

* Added a print button

All print-optimized pages have that

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2021-08-06 20:18:43 +02:00
Kris
eecb321086 Change PHP Dependency from >= to ^ (#1566)
* Change PHP Dependency from >= to ^

* Remove name, description, license
2021-08-06 15:49:14 +02:00
Bernd Bestel
1891bc6f32 Restore fixed order for grouped column (fixes #1534) 2021-08-04 17:41:20 +02:00
Daniel Tihanyi
10c1ccd6e4 Extend REQUIRED_PHP_EXTENSIONS check about core extensions (#1540)
* Extend Grocy REQUIRED_PHP_EXTENSIONS

After installing Grocy on FreeBSD, even with all extensions installed that are listed in REQUIRED_PHP_EXTENSIONS, Grocy still couldn't start. The added 3 PHP Extensions are also needed to run Grocy.

* Added note about core extensions

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2021-08-04 17:25:24 +02:00
Bernd Bestel
12af9a944b Added changelog for #1561 2021-08-04 17:08:38 +02:00
Akosh Pinter
1fafd32aaf Possible fix for the chore & battery dropdown clearing issue - #1560 (#1561)
* Possible fix for the chore & battery dropdown clearing issue - #1560

* Revert formatting changes - #1560

Co-authored-by: Akos Pinter <akos.pinter@mhp.com>
2021-08-04 17:06:40 +02:00
Bernd Bestel
9f9b9d864e Added changelog for #1557 2021-08-04 16:37:08 +02:00
Lars van Erp
a79247a30c Fixed the bug where grocy would return "Not a grocycode" all the time (#1557) 2021-08-04 16:35:26 +02:00
Bernd Bestel
53e405c4f8 Fixed migration when having unsupported parent/child product nesting levels (fixes #1542) 2021-07-25 20:22:10 +02:00
Bernd Bestel
cf382bb47f Also note how to apply database migrations in "How to update" section
References #1548 and all the other same questions arising after each release multiple times
2021-07-25 13:03:19 +02:00
Bernd Bestel
8225215e39 Fixed that the calendar iCal export was broken when having "Track date only" chores (fixes #1547) 2021-07-24 10:24:21 +02:00
Bernd Bestel
f47ca963ab Fixed duplicate barcode migration error (fixes #1546) 2021-07-23 16:37:45 +02:00
Bernd Bestel
d871ed7b53 Updated README.md 2021-07-17 20:17:02 +02:00
Bernd Bestel
3e31450532 Typo 2021-07-17 00:26:26 +02:00
Bernd Bestel
5478bec2c7 Optimized "auto decimal separator for price inputs" (references #1345) 2021-07-17 00:21:48 +02:00
Bernd Bestel
edfa404ed6 Squashed commit
Always execute migration 9999 (can be used to fix things manually)
Optimized meal plan navigation / date range filtering
Prepared next release
Pulled translations from Transifex
Various code optimizations
2021-07-16 17:32:08 +02:00
Bernd Bestel
2d1d5d46f6 Updated screenshots 2021-07-15 21:04:52 +02:00
Bernd Bestel
45fe6a6362 Updated create_release_package.bat 2021-07-15 20:58:01 +02:00
Bernd Bestel
23f697f812 Pulled translations from Transifex 2021-07-15 20:53:12 +02:00
Bernd Bestel
263181baa0 Updated dependencies 2021-07-15 20:48:27 +02:00
Bernd Bestel
9132e222fe Upgraded bwip-js 2021-07-15 20:34:22 +02:00
Bernd Bestel
2bc108fe3e Only init meal plan menu entry when feature flag is enabled 2021-07-15 20:19:04 +02:00
Bernd Bestel
02d0121f4d Fixed meal plan note adding 2021-07-15 20:11:49 +02:00
Bernd Bestel
b5acb4c49b Settings menu order == sidebar menu order 2021-07-15 20:09:33 +02:00
Bernd Bestel
cd05a95a0f Fix meal plan section title in (some) foreign languages 2021-07-15 20:07:31 +02:00
Bernd Bestel
2d2700cacb Implemented meal plan sections (closes #370) 2021-07-15 17:54:48 +02:00
Bernd Bestel
1bacd8e13d Typo / added missing changelog 2021-07-14 18:15:02 +02:00
Bernd Bestel
f6986fac18 Fixed cost/calories calculation for nested recipes (references #1264) 2021-07-14 16:27:03 +02:00
Bernd Bestel
8b6f882edc Fixed missing FEATURE_FLAG_SHOPPINGLIST handling on /stockoverview, /mealplan and /stockentries pages (references #322) 2021-07-13 21:24:08 +02:00
Bernd Bestel
91d8eaeb74 Squashed commit
Improve journal pages loading time (new date range filter)
Various small style adjustments (meal plan page and others)
Pulled German translations from Transifex
Show the shopping list total value (closes #1309)
Make it possible to copy recipes (closes #714)
Implemented optional "auto decimal separator for price inputs" (closes #1345)
Removed table grouped column fixed order restriction (closes #1402)
Don't filter out style, class, id attributes of html text (closes #1298)
Added product picture as column on the stock overview page (closes #1283)
Added grocycodes also for chores and batteries (+ camera barcode scanning for /choretracking and /batterytracking, this now closes #221)
2021-07-13 19:29:23 +02:00
Bernd Bestel
8d2c3ae584 Partly reverted b856911f0f
Loading localization strings async for the fronted currently doesn't work in all cases...
2021-07-12 21:20:39 +02:00
Bernd Bestel
18e8fc8293 Added missing localization string 2021-07-12 20:48:14 +02:00
Bernd Bestel
e1c702f3d0 Typo 2021-07-12 20:45:30 +02:00
Bernd Bestel
71cede74a3 Make it possible to copy meal plan days (closes #573) 2021-07-12 20:44:42 +02:00
Bernd Bestel
7b0bc9e472 Fixed stock entries page missing columns 2021-07-12 19:55:53 +02:00
Bernd Bestel
8cb8611b4f Added a new product option "Should not be frozen" (closes #1320) 2021-07-12 19:27:21 +02:00
Bernd Bestel
c048f403e6 Check for missing localization strings also client side (dev mode only) 2021-07-12 19:10:07 +02:00
Bernd Bestel
4aee175105 Keep the newest instead of the oldest on campacting stock entries 2021-07-12 18:58:49 +02:00
Bernd Bestel
cf8604e984 Show row_created_timestamp on the stock entries page (closes #1063) 2021-07-12 18:25:07 +02:00
Bernd Bestel
cdf6ac78e2 Optimized product edit page default button handling (closes #1276) 2021-07-12 18:15:57 +02:00
Bernd Bestel
70433aace5 Added an status filter to only show in-stock products on the stock overview page (closes #1263) 2021-07-12 18:02:57 +02:00
Bernd Bestel
247221950d Never extend the original due date on when opening a product which has default_best_before_days (closes #1342) 2021-07-12 17:56:09 +02:00
Bernd Bestel
866d6647d2 Small meal plan page adjustments 2021-07-12 17:43:30 +02:00
Bernd Bestel
f1da3ef5e8 Optimized clean response handling 2021-07-12 17:08:59 +02:00
Bernd Bestel
2cc4f4d382 Make sure to clean the response before returning files
Was a problemw when returning images and there were leading empty lines in config.php which seem to get added to the response always...
2021-07-12 15:34:26 +02:00
Bernd Bestel
6659a5cd08 Add an option to make Userfields mandatory (closes #1339) 2021-07-11 22:05:08 +02:00
Bernd Bestel
21c221b520 Improved recipe page / group by fulfillment status 2021-07-11 21:32:24 +02:00
Bernd Bestel
55807bfc94 Auto-compact stock entries (closes #1343) 2021-07-11 21:06:05 +02:00
Bernd Bestel
696e9b3e28 Typo 2021-07-11 19:47:27 +02:00
Bernd Bestel
198216f38b Make it possible to track any information on chore execution (by using Userfields, closes #825) 2021-07-11 19:44:06 +02:00
Bernd Bestel
27b46e1abf Optimized meal plan week navigation 2021-07-11 18:44:04 +02:00
Bernd Bestel
7380175093 Make it possible to mark meal plan entries as done (closes #924) 2021-07-11 18:32:26 +02:00
Bernd Bestel
1ad0360e42 Fixed untranslated string 2021-07-11 10:55:29 +02:00
Bernd Bestel
2503590463 config-dist.php formatting 2021-07-11 10:34:46 +02:00
Bernd Bestel
40e16db01f Fixed consume amount validation when consuming a parent product (fixes #1306)
More a workaround for now, the max constraint is just removed when the product has child products,
but the amount to be consumed is checked by StockService anyway, so should not be a problem...
2021-07-11 10:21:36 +02:00
Bernd Bestel
684aef0a42 Made migration path faster (references #695) 2021-07-11 10:06:31 +02:00
Bernd Bestel
dd9cae5482 Fixed migration path (references #695) 2021-07-11 09:58:39 +02:00
Bernd Bestel
7ee15946c7 Improved page loading time of /recipes and /mealplan when having a big meal plan (closes #695) 2021-07-10 22:56:39 +02:00
Bernd Bestel
6660e1ff73 Fixed mealplan-shadow recipe handling when removing an meal plan entry (references #1391) 2021-07-10 20:51:20 +02:00
Bernd Bestel
2847908523 Some small recipe page adjustments 2021-07-10 20:35:38 +02:00
Bernd Bestel
9b37c450ed Fixed API error when adding missing products to the shopping list from a meal plan entry (references #b0d38b87de) 2021-07-10 19:56:35 +02:00
Bernd Bestel
003aea6047 Removed unnecessary migration (references #1264) 2021-07-10 19:15:17 +02:00
Bernd Bestel
9d1440fb45 Typo... 2021-07-10 18:30:50 +02:00
Bernd Bestel
832d83dfde Fixed indirect QU conversion factors (fixes #1264) 2021-07-10 18:28:19 +02:00
Bernd Bestel
90a0caf1dc Fixed meal plan recipe servings stock fulfillment checking (fixes #1391) 2021-07-10 12:32:29 +02:00
Bernd Bestel
d3c134e13f Fixed nested recipe ingredient amount calculation (fixes #1252) 2021-07-10 11:16:51 +02:00
Bernd Bestel
269ae34db3 Fixed battery_charge_cycles.battery_id data type
Kind of, doesn't really matter for SQLite; doesn't change anything practically
2021-07-10 09:33:10 +02:00
Bernd Bestel
8ff8c1ac5d Made the used grocycode barcode type configurable
DataMatrix reading via Quagga2 doesn't work currently, so default to an supported 1D barcode (=> Code128)
2021-07-09 23:08:47 +02:00
Bernd Bestel
2638bce851 Improve handling of not in-stock but valid manually entered products on the consume and transfer page (references #1429) 2021-07-09 22:16:08 +02:00
Bernd Bestel
72e6ed76bf Fixed an error when adding object and there are no Userfields (references b0d38b87de) 2021-07-09 21:30:35 +02:00
Bernd Bestel
8348438148 Workaround for file upload problem when the file name contains Umlaute (seems to be a Linux only issue, fixes #1382) 2021-07-09 21:23:04 +02:00
Bernd Bestel
338a5016cf Allow cyrillic letters in API filter values (fixes #1296) 2021-07-09 20:23:30 +02:00
Bernd Bestel
11b71e3af2 Issue template update 2021-07-08 20:52:28 +02:00
Bernd Bestel
8c5c12cb47 Added new columns on the stock overview page (closes #1351) 2021-07-08 20:42:07 +02:00
Bernd Bestel
8b977644f7 Added the product descrption as a column on the stock overview page (closes #1362) 2021-07-08 20:22:51 +02:00
Bernd Bestel
7595d640f5 Return empty Userfields empty (closes #1412) 2021-07-08 20:12:58 +02:00
Bernd Bestel
14cd6ca3bf Return numbers as numbers on all API endpoints 2021-07-08 19:34:16 +02:00
Bernd Bestel
633b26bf7e Add recipe ingredient notes to the corresponding shopping list item (closes #1397) 2021-07-06 20:19:50 +02:00
Bernd Bestel
1ead23cb87 Added on option to only show in-stock products on the /products page (closes #1388) 2021-07-06 20:08:02 +02:00
Bernd Bestel
6530d0f9df Clarify that "Group by product group" (printing a shopping list) works only for the list layout type (closes #1405) 2021-07-06 19:48:55 +02:00
Bernd Bestel
135ac118b0 Added a filter for only done items on the /shoppinglist page (closes #1406) 2021-07-06 19:40:26 +02:00
Bernd Bestel
70d51c757b Only show in-stock products on the /consume page (closes #1429) 2021-07-06 19:31:55 +02:00
Bernd Bestel
ffad8bfa7f Make it possible to search on the stock overview page for product barcodes (closes #1443) 2021-07-06 19:25:34 +02:00
Bernd Bestel
ffc5ba013f Added new API things related to #1494 and #1493 to grocy.openapi.json 2021-07-06 19:17:43 +02:00
Bernd Bestel
aaa054e0a5 Also return the next_execution_assigned_user for the /chores API endpoint (closes #1493)
Include the user and category object for the /tasks API endpoint (closes #1494)
2021-07-06 19:07:45 +02:00
Bernd Bestel
54bf7ed659 Produce a schema-valid OpenAPI specification (closes #1457) 2021-07-05 23:23:59 +02:00
Bernd Bestel
6462dd8af6 Removed legacy error suppression 2021-07-05 22:51:02 +02:00
Bernd Bestel
079437384e Use the now available @once directive instead of the legacy hack to only include component scripts once 2021-07-05 22:49:51 +02:00
Bernd Bestel
10fcd9177c Define error reporting 2021-07-05 22:40:01 +02:00
Bernd Bestel
b0d38b87de PHP 8 support 2021-07-05 17:48:34 +02:00
Bernd Bestel
d9470cb377 Added .devtools scripts to package.json 2021-07-05 17:47:47 +02:00
Bernd Bestel
b4ce0555d9 Upgraded/Replaced rubellum/slim-blade-view to support Laravel Blade Templates v8 2021-07-05 17:13:01 +02:00
Bernd Bestel
9ba7ee54a7 Invalidate browser cache on language change 2021-07-04 21:54:58 +02:00
Bernd Bestel
cb24a7149f Revert "Upgraded gettext/gettext (+ JS-Translator)"
This reverts commit 9abb92763d.
2021-07-04 21:47:55 +02:00
Bernd Bestel
9abb92763d Upgraded gettext/gettext (+ JS-Translator) 2021-07-04 21:47:10 +02:00
Bernd Bestel
54d4c90ec4 Upgraded morris/lessql 2021-07-04 20:06:49 +02:00
Bernd Bestel
76037d1f4e Upgraded gumlet/php-image-resize 2021-07-04 20:05:00 +02:00
Bernd Bestel
735743047f Upgraded eluceo/ical 2021-07-04 20:02:04 +02:00
Bernd Bestel
82c474d0ae Allow hyphens in API filter value (fixes #1333) 2021-07-04 17:48:58 +02:00
Bernd Bestel
0dc37fb361 Don't allow a min. stock amount for child products when the parent has "Accumulate sub products min. stock amount" set (references #1409) 2021-07-04 17:36:44 +02:00
Bernd Bestel
734e174442 Fixed the "Add as barcode to existing product" productpicker workflow from the /shoppinglistitem page (fixes #1262) 2021-07-04 15:46:19 +02:00
Bernd Bestel
4086a63ebd Improved tables horizontally scrollbar appearance (fixes #1476) 2021-07-04 15:34:39 +02:00
Bernd Bestel
f2a0b7cded Pulled translations from Transifex 2021-07-04 12:31:17 +02:00
Bernd Bestel
bda40dfbb9 Updated dependencies 2021-07-04 12:26:14 +02:00
Bernd Bestel
fbb0064505 Consider selected QU for calories calculation for "Only check if any amount is in stock" recipe ingredients (fixes #1338) 2021-07-03 20:01:49 +02:00
Bernd Bestel
4b02ac8f35 Fixed shopping list setting initialization (fixes #1344) 2021-07-03 19:43:32 +02:00
Bernd Bestel
47c936e026 Reworked authentication related menu item handling (fixes #1462) 2021-07-03 19:40:42 +02:00
Bernd Bestel
bcf963ac49 Fixed self production amount was wrong for tare weight handling enabled products (fixes #1431) 2021-07-03 18:30:53 +02:00
Bernd Bestel
765ba77621 Fixed shopping list unit/total price QU handling (fixes #1460) 2021-07-03 18:15:30 +02:00
Bernd Bestel
0f88eed08c Upgraded to PHP-CS-Fixer v3 2021-07-03 17:46:47 +02:00
Bernd Bestel
766eae5a7a Remove accidentally committed debug statement 2021-07-02 22:19:54 +02:00
Bernd Bestel
90b8ea15ff Also delete downscaled image files when deleting an image (closes #1499) 2021-07-02 20:50:52 +02:00
Bernd Bestel
34ffb96ae3 Enforce file groups 2021-07-02 20:29:53 +02:00
Bernd Bestel
74d745cfc4 Typo 2021-07-02 20:29:25 +02:00
Bernd Bestel
cc9345136c Use exact search for product filter on /stockjournal and /stockjournalsummary (fixes #1353) 2021-07-02 18:24:08 +02:00
Bernd Bestel
5ba9bbbcd1 Fixed mssing-recipe-ingredients-to-shopping-list checkbox inner-click (fixes #1383) 2021-07-02 18:04:20 +02:00
Bernd Bestel
cae924eb81 Fixed shopping list QU handling (fixes #1385, fixes #1384) 2021-07-02 17:37:06 +02:00
Bernd Bestel
187d48f93d Use stock_log location instead of product location for stock journal (fixes #1381) 2021-07-02 17:04:40 +02:00
Bernd Bestel
9f833b9bd5 Prvent potentially duplicate stock items in drodpown on /consume and /transfer page (fixes #1368) 2021-07-02 16:59:37 +02:00
Bernd Bestel
b856911f0f Browser-cache localization strings (+ new API endpoint to get them) 2021-06-29 20:24:02 +02:00
Bernd Bestel
d18a8d8b56 Added changelog for #1527 2021-06-29 17:43:13 +02:00
André Heuer
416c138017 Added support for Code 39 (#1527) 2021-06-29 17:40:28 +02:00
Bernd Bestel
76cfe7fece Fixed productcard spoil rate (fixes #1319) 2021-06-28 19:43:08 +02:00
Bernd Bestel
7587ead732 Fixed /tasks group by category (fixes #1274) 2021-06-28 19:31:27 +02:00
Bernd Bestel
69f8c237ff Fixed /stockentries group by purchased_date (fixes #1419) 2021-06-28 19:14:15 +02:00
Bernd Bestel
b8e15b990b Typo 2021-06-28 18:39:08 +02:00
Bernd Bestel
35fb87ab1e Squashed commit
Use managed fonts
Include userentities dynamically in grocy.openapi.json for /userfields/{entity}/{objectId} endpoints (closes #1218)
Fixed userfieldsform load / save (for products and recipes) handling (fixes #1302)
Fixed PUT/DELETE /objects/{entity}/{objectId} when the given object id was invalid (fixes #1396)
Allow arrays in HTMLPurifier (fixes #1407)
2021-06-28 17:00:16 +02:00
Bernd Bestel
acb81187d9 Fixed missing shopping_location_id on stock transfer actions (fixes #1408) 2021-06-27 20:55:38 +02:00
Bernd Bestel
5153818b4e Fixed shopping_list_id when adding products from /stockoverview to the shopping list (fixes #1442) 2021-06-27 20:46:21 +02:00
Bernd Bestel
5c3809aa33 Exclude inactive products from recipe ingredient edit page (fixes #1448) 2021-06-27 20:34:18 +02:00
Bernd Bestel
95d212a076 Added missing shopping_list_id for ShoppingListItem in grocy.openapi.json (fixes #1451) 2021-06-27 20:30:05 +02:00
Bernd Bestel
7133c85deb Persist filters on reload (recipe selection change) on the /recipes page (fixes #1455) 2021-06-27 20:28:12 +02:00
Bernd Bestel
7ab59273da Allow links and iframes in HTMLPurifier (fixes #1461) 2021-06-27 20:13:24 +02:00
Bernd Bestel
33ea1e56cf Trigger help-tooltips also by click (instead of only hover, which is Bootstraps default) (fixes #1468) 2021-06-27 19:34:28 +02:00
Bernd Bestel
b7a6b91039 Fixed stock QU change restriction / include undone stock transactions (fixes #1473) 2021-06-27 19:11:45 +02:00
Bernd Bestel
e646dd9332 Fixed barcode QU was not saved for single QU products (fixes #1504) 2021-06-27 19:04:09 +02:00
Bernd Bestel
30e5cc3bc3 Fixed filter clearing on /quantityunits (fixes #1511) 2021-06-27 18:42:15 +02:00
Bernd Bestel
e44f4802d5 Fixed filter clearing on /products (fixes #1512) 2021-06-27 18:41:07 +02:00
Bernd Bestel
9ef48e79cd Remove user request parameter when clearing filter on /choresoverview (fixes #1513) 2021-06-27 18:39:29 +02:00
Bernd Bestel
3acad5056a Fixed inventory action hint when entered amount equals current stock amount (fixes #1522) 2021-06-27 18:37:18 +02:00
Bernd Bestel
44d6173569 Also disable generic consume context menu item on /stockoverview when the item is not in stock (fixes #1523) 2021-06-27 18:34:58 +02:00
Bernd Bestel
9a0cad079c Fixed undoing consume/open from notification on /stockentries (fixes #1524) 2021-06-27 18:32:22 +02:00
Katharina Bogad
f5da53a761 Migrated bootstrap3 col-xs-* to bootstrap4 col-* classes (#1521) 2021-06-24 22:46:47 +02:00
Bernd Bestel
f8fa5db3e7 Fixed multiple datetimepicker contextual timeago (references #1520) 2021-06-24 07:46:32 +02:00
Bernd Bestel
5e189c8a4a Fixed multi instace date/time Userfields (fixes #1520) 2021-06-23 22:13:54 +02:00
Bernd Bestel
9e3c68982b Added changelog for #1380 2021-06-20 13:27:16 +02:00
tank0226
b3ed80d186 Improved support for other LDAP servers (#1380)
Co-authored-by: kuanhong <>
2021-06-20 13:22:18 +02:00
Bernd Bestel
a4f7aac963 Mention newly required PHP extensions in changelog (references #1273) 2021-06-20 13:19:09 +02:00
Bernd Bestel
c45034e6b1 Fixed composer.lock merge conflict (references #1273) 2021-06-18 20:58:51 +02:00
Bernd Bestel
5ad4d9f421 Added changelog for #1273 2021-06-18 20:57:08 +02:00
Marc Ole Bulling
eb135aee39 Add support for printing shoppinglist with thermal printer (#1273)
* Added escpos-php library

* Added button to shoppinglist print menu

* Added to translation

* Added basic printing logic and API call

* Working implementation for printing with the API

* Added openapi json

* Correctly parsing boolean parameter

* Working button in UI

* Change to grocy formatting

* Add Date

* Only show thermal print button when Feature Flag is set

* Fixed API call and added error message parsing

* Undo translation

* Add flag to print quantities as well

* Added printing notes

* Added quantity conversion

* Increse feed

* Fixed that checkbox was undefined, as dialog was already closed

* Added padding

* Formatting

* Added note about user permission

* Fixed error when using notes instead of products

* Review

- Default FEATURE_FLAG_THERMAL_PRINTER to disabled
- Added missing localization strings (and slightly adjusted one)

* Fixed merge conflicts

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2021-06-18 20:45:42 +02:00
Bernd Bestel
fe59fac1c3 Fixed client side webhook runner (references #1500) 2021-06-13 08:40:16 +02:00
Bernd Bestel
26979a4321 Set HTMLPurifier cache path (fixes #1497) 2021-06-12 20:56:58 +02:00
Kendell R
a0e5f45da3 More night mode improvements (#1336)
* More night mode improvements

* Update grocy_night_mode.css

* Update extensions.js

* Update grocy_night_mode.css

* Update public/css/grocy_night_mode.css
2021-06-12 20:39:08 +02:00
Bernd Bestel
739379fabb Fixed stock entry grocycode download (references #1500) 2021-06-12 20:15:48 +02:00
Bernd Bestel
96fff2e5f4 Added changelog for #1500 2021-06-12 17:21:48 +02:00
Katharina Bogad
2471e78188 Grocycode, label printing (#1500)
* Grocycode: Productpicker, StockService

* Grocycode: Datamatrix generation

* Grocycode: Display in UI, make Images downloadable

* Grocycode: Do not show on product card

* Grocycode: Stockentry Label view

* Grocycode: Webhooks & Labelprinter Feature

* Grocycode: Manual Label printing

* Grocycode: Print Label from product form

* Quagga2: use zxing for DataMatrix recognition

* Grocycode: Default settings for label printing

* Prepare merge of master

* Grocycode: docs

* Docs: label printing webhook

* Review

- "grocy" is currently written lower-case everywhere, so let's do this also for "grocycode"
- Unified phrases / capitalization
- Minor UI adjustments (mainly context menu item ordering / ordering/spacing on product edit page)
- Documented API changes for Swagger UI (grocy.openapi.json)
- Reverted German localizations (those are managed via Transifex; would cause conflicts when manually edited - will import them later there)
- Reverted a somehow messed up localization string (productform/help text for `cumulate_min_stock_amount_of_sub_products`)
- Suppress deprecation warnings when generating Datamatrix PNG (otherwise the PNG is invalid, https://github.com/jucksearm/php-barcode/issues/3)
- Default `FEATURE_FLAG_LABELPRINTER` to disabled

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2021-06-12 17:21:12 +02:00
Bernd Bestel
d23fda245e Fixed that the number picker up/down buttons did not work when the input field was empty or contained an invalid number 2021-03-31 22:26:27 +02:00
Bernd Bestel
791a17fcad Default shopping list item amount to 1 2021-03-31 22:22:28 +02:00
Bernd Bestel
dabc48fed3 Typo 2021-03-31 22:15:41 +02:00
rozgonik
980778e599 Fix untranslateable hint values (#1435) 2021-03-31 22:14:42 +02:00
Kai
68c5fd0617 Update README.md (#1432) 2021-03-31 22:14:05 +02:00
Edward Betts
7bbcec91aa Correct spelling (#1420) 2021-03-31 22:12:51 +02:00
Bernd Bestel
c483c34598 Display calories always per single serving (fixes #1359) 2021-02-21 20:57:34 +01:00
Bernd Bestel
906a9db628 Fixed embedded /transfer from /stockentries (fixes #1303) 2021-02-21 19:36:37 +01:00
Bernd Bestel
5583074001 Don't initialise numeric Userfields with 1.0 (fixes #1312) 2021-02-21 19:14:49 +01:00
Bernd Bestel
e4c8f6b023 Don't require 1 to be in stock for "Only check if any amount is in stock" 2021-02-21 19:10:10 +01:00
Bernd Bestel
4555bf3b63 Enforce product barcodes to be unique (references #1205) 2021-02-21 18:55:48 +01:00
Bernd Bestel
2aca551692 Fixed product page QU conversion hint pluralisation (fixes #1352) 2021-02-21 18:24:04 +01:00
Bernd Bestel
f5eff8ab49 Include due_type = "Expiration date" products in /stock/volatile API endpoint (fixes #1372) 2021-02-21 18:18:34 +01:00
Bernd Bestel
36f5fb23e9 Added changelog for #1347 2021-02-21 18:13:16 +01:00
Lauri Niskanen
33dcd17fbd Fix rounding error on total value calculation (#1347)
* Fix rounding error on total value calculation

* Remove unused 'amountSum' calculation
2021-02-21 18:10:41 +01:00
Bernd Bestel
3d82c9abbd Disabled platform-check (references #1285) 2021-02-18 12:14:57 +01:00
Bernd Bestel
779ac31ffe Added changelog for #1332 2021-02-14 12:56:21 +01:00
Lauri Niskanen
0a6c7d73a7 Hide unsuitable fields from printed recipe pages (#1332)
* Hide unsuitable fields from printed recipe pages

Resolves #1330.

* Use proper total energy label in the recipe page
2021-02-14 12:55:01 +01:00
Bernd Bestel
fc05044353 Added changelog for #1331 2021-02-14 12:51:40 +01:00
Kendell R
55ac768521 Night mode improvements (#1331)
* Night mode readability improvements

* Update grocy_night_mode.css

* Update grocy_night_mode.css
2021-02-14 12:49:44 +01:00
Bernd Bestel
a455a01204 Fixed print layout display handling (fixes #1272) 2021-01-30 13:11:40 +01:00
Bernd Bestel
8b963ae0f1 Merge branch 'master' of https://github.com/grocy/grocy 2021-01-30 13:07:16 +01:00
Bernd Bestel
a1adc80c29 Fixed consuming Scan Mode timing (fixes #1292) 2021-01-30 13:06:44 +01:00
Marius Boro
760914bf82 Update grocy_night_mode.css (#1269)
Night mode updates for Grocy 3
2021-01-30 12:49:51 +01:00
Bernd Bestel
42689ecefe Added changelog for #1297 2021-01-30 12:49:17 +01:00
Marc Ole Bulling
c889416c0a Fix for #1289 and #1261 (#1297) 2021-01-30 12:47:12 +01:00
Bernd Bestel
bfb5525ec1 Added changelog for #1286 2021-01-30 12:41:09 +01:00
Marc Ole Bulling
20380faeb3 Fix for #1271 (#1286) 2021-01-30 12:39:10 +01:00
Bernd Bestel
5ecd3a585e Added changelog for #1269 2021-01-12 18:14:32 +01:00
Bernd Bestel
bfa3347a20 Fixed that editing stock entries was not possible (fixes #1268) 2021-01-12 18:04:20 +01:00
Bernd Bestel
e42f4b405d Fixed PHP warning (fixes #1267) 2021-01-12 10:40:14 +01:00
Bernd Bestel
27169e1428 Fixed constant typo (fixes #1260) 2021-01-06 09:31:36 +01:00
Bernd Bestel
4a4d9c451f Prepared next release 2021-01-05 10:54:32 +01:00
Bernd Bestel
ced709bbf9 Auto create the data/viewcache folder if it doesn't exist (however) 2021-01-05 10:52:23 +01:00
Bernd Bestel
4a8d4120e1 Updated dependencies 2021-01-05 10:48:28 +01:00
Bernd Bestel
8f877dc716 Pulled translations from Transifex 2021-01-05 10:45:09 +01:00
Bernd Bestel
45abc99a77 Use barcode amounts also for Consume/Transfer/Inventory (closes #1254) 2021-01-04 21:59:19 +01:00
Bernd Bestel
d78e156609 Use barcode defaults also for scan mode (fixes #1253) 2021-01-04 21:15:22 +01:00
Bernd Bestel
030939e013 Typo 2021-01-03 22:42:16 +01:00
Bernd Bestel
a646f2c6bd Fixed included recipe missing amount resolving (references #1252) 2021-01-03 22:40:33 +01:00
Bernd Bestel
4e1531e4ee Merge branch 'master' of https://github.com/grocy/grocy 2021-01-03 22:26:24 +01:00
Bernd Bestel
7d07b382fd Fixed included recipe amount resolving (fixes #1252) 2021-01-03 22:26:08 +01:00
Bernd Bestel
621bbf79ab Update issue templates 2021-01-03 17:42:31 +01:00
Bernd Bestel
65f0253307 Fixed product form min tare weight 2021-01-03 16:22:58 +01:00
Bernd Bestel
fdeb4fd4d7 Validate product form once presets are prefilled (fixes #1250) 2021-01-03 16:22:35 +01:00
Bernd Bestel
97fdb0553c Fixed shopping list to stock worfklow skip button (fixes #1248) 2021-01-02 20:54:31 +01:00
Bernd Bestel
bd21e3a8d6 Don't filter ampersands (fixes #1247) 2021-01-02 20:08:13 +01:00
Bernd Bestel
966211b71a Fixed shopping list product userfields (fixes #1246) 2021-01-02 17:30:28 +01:00
Bernd Bestel
fe665ac766 Fixed potential problem mentioned in https://github.com/grocy/grocy/issues/882#issuecomment-753357049 2021-01-01 20:00:24 +01:00
Bernd Bestel
43ef9b793b Fixed chore form weekly day selection labels (fixes #1242) 2021-01-01 14:31:49 +01:00
Bernd Bestel
8c0ff04caa Fixed consume stock amount check for product substitution (fixes #1240) 2021-01-01 13:27:57 +01:00
Bernd Bestel
c57e554369 Updated changelog 2020-12-31 13:52:09 +01:00
Bernd Bestel
c65f375a68 Only change the current number input by arrow keys (fixes #1232) 2020-12-31 13:48:36 +01:00
Bernd Bestel
1459f8c441 Prevent form submit when any combobox-dropdown is open (fixes #1236) 2020-12-31 13:45:14 +01:00
Bernd Bestel
1e27f6c127 Fixed product opening success message (fixes #1237) 2020-12-31 13:11:51 +01:00
Bernd Bestel
97b93f23bd Fixed/unified shopping list item button tooltips (fixes #1239) 2020-12-31 13:09:55 +01:00
Bernd Bestel
5cd3fb092a Improved initial DataTables sorting (fixes #1235) 2020-12-30 13:55:01 +01:00
Bernd Bestel
200964edff Use numberpicker up/down buttons for up/down keys (fixes #1232) 2020-12-30 08:29:11 +01:00
Bernd Bestel
17a4d04053 Fixed store picker validation (fixes #1233) 2020-12-30 08:22:43 +01:00
Bernd Bestel
d79adc4660 Optimized embedded productpicker workflows (references #1226) 2020-12-29 21:18:51 +01:00
Bernd Bestel
9f1692e31f Improved shopping list item form validation (closes #1226) 2020-12-29 21:06:31 +01:00
Bernd Bestel
d9e42331f9 Allow some HTML tags in API request body (needed at least for HTML editor fields) (fixes #1228) 2020-12-29 19:19:04 +01:00
Bernd Bestel
87754830f7 Fix initial consume form validation (fixes #1230) 2020-12-29 18:11:45 +01:00
Bernd Bestel
278a5f004a Fix consuming when FEATURE_FLAG_STOCK_LOCATION_TRACKING is disabled (fixes #1229) 2020-12-29 18:06:56 +01:00
Bernd Bestel
b6139a6991 Optimized filter_var checks 2020-12-28 22:14:59 +01:00
Bernd Bestel
6263715c53 Fixed shopping list item form load handling (fixes #1222) 2020-12-28 19:59:18 +01:00
Bernd Bestel
b7349e287e Added changelog for #1223 2020-12-28 19:40:52 +01:00
Marc Ole Bulling
7e8f460dad Added /system/time API call (#1223)
* Inital structure for /system/time API call

* Parse arguments for offset

* Correctly parsing parameters

* Fixed implimentation, added to openapi.json

* Modified DOC

* Added Sqlite3 time to output

* Fixed error with negative offset

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-12-28 19:39:24 +01:00
Bernd Bestel
6fcc0636e8 Optimized textarea heights 2020-12-27 09:38:31 +01:00
Bernd Bestel
447b86b27f Merge branch 'master' of https://github.com/grocy/grocy 2020-12-24 15:07:31 +01:00
Bernd Bestel
590cbd2460 Support indirect QU conversions (fixes #1217) 2020-12-24 15:07:04 +01:00
Bernd Bestel
d8069c569e Typo... 2020-12-24 10:01:58 +01:00
Bernd Bestel
4766c81580 Allow API keys in ReverseProxyAuthMiddleware (closes #1216) 2020-12-24 10:00:51 +01:00
Bernd Bestel
2e3c237648 Fixed zero decimals handling (fixes #1213) 2020-12-23 19:56:37 +01:00
Bernd Bestel
bd185cfa32 Added changelog for #1215 2020-12-23 17:38:43 +01:00
Marc Ole Bulling
80acc7deea Added configuration validator class (#1215)
* Added configuration validator class

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-12-23 17:37:05 +01:00
Bernd Bestel
2f8207ab5f Fixed (again) purchase success message when FEATURE_FLAG_STOCK_PRICE_TRACKING is disabled (references #1214) 2020-12-23 15:58:05 +01:00
Bernd Bestel
c9f40782de Update SQLite requirement info (references #1209) 2020-12-23 14:56:10 +01:00
Bernd Bestel
904848d09a Fixed purchase success message when FEATURE_FLAG_STOCK_PRICE_TRACKING is disabled (fixes #1214) 2020-12-23 14:37:02 +01:00
Bernd Bestel
97b95803b8 Fix potential problem (again) when running/upgrading grocy v3.0.0 with SQLite > 3.8.3 < 3.9.0 (references #1209) 2020-12-23 11:54:39 +01:00
Bernd Bestel
f1efd08bc6 Raise minimum/tested runtime requirements (references #1209) 2020-12-22 21:54:49 +01:00
Bernd Bestel
5f09d4def1 Fix potential problem when running/upgrading grocy v3.0.0 with SQLite > 3.8.3 < 3.9.0 (references #1209) 2020-12-22 21:19:55 +01:00
Bernd Bestel
cf05be35fe Fix default for product option "Never show on stock overview" (fixes #1212) 2020-12-22 19:10:02 +01:00
Bernd Bestel
937bd6b702 Fixed camera scanning targets (fixes #1210) 2020-12-22 19:06:41 +01:00
Bernd Bestel
159ab253dd Fixed typo 2020-12-22 17:02:21 +01:00
Bernd Bestel
b42bcaaa44 Hide price decimals setting when FEATURE_FLAG_STOCK_PRICE_TRACKING is disabled 2020-12-22 16:24:13 +01:00
Bernd Bestel
2afa0c304d Merge remote-tracking branch 'remotes/origin/release' 2020-12-22 15:20:58 +01:00
Bernd Bestel
affe7de842 Fixed typo (references #1208) 2020-12-22 15:16:16 +01:00
Bernd Bestel
c54ae89212 Added changelog for #1208 2020-12-22 15:11:24 +01:00
Marc Ole Bulling
7ba48d5160 Added ctype requirement to PrerequisiteChecker (#1208) 2020-12-22 15:07:34 +01:00
Bernd Bestel
9d76859469 Added a note about that's better to have a valid currency code set in config.php (references #1206) 2020-12-22 12:27:30 +01:00
805 changed files with 89861 additions and 26609 deletions

View File

@@ -10,9 +10,9 @@ for /f "tokens=*" %%a in ('jq .Version versiontemp.json --raw-output') do set ve
del versiontemp.json
del "%releasePath%\grocy_%version%.zip"
7za a -r "%releasePath%\grocy_%version%.zip" "%projectPath%\*" -xr!.* -xr!build.bat -xr!composer.json -xr!composer.lock -xr!package.json -xr!yarn.lock
7za a -r "%releasePath%\grocy_%version%.zip" "%projectPath%\*" -xr!.* -xr!build.bat -xr!composer.json -xr!composer.lock -xr!package.json -xr!yarn.lock -xr!docs -xr!test -x!public\packages\@fortawesome\fontawesome-free\js -x!public\packages\@fortawesome\fontawesome-free\less -x!public\packages\@fortawesome\fontawesome-free\metadata -x!public\packages\@fortawesome\fontawesome-free\scss -x!public\packages\@fortawesome\fontawesome-free\sprites -x!public\packages\@fortawesome\fontawesome-free\svgs
7za a "%releasePath%\grocy_%version%.zip" "%projectPath%\public\.htaccess"
7za rn "%releasePath%\grocy_%version%.zip" .htaccess public\.htaccess
7za d "%releasePath%\grocy_%version%.zip" data\*.* data\storage data\viewcache\*
7za d "%releasePath%\grocy_%version%.zip" data\*.* data\storage data\viewcache\* changelog\__TEMPLATE.md
7za a "%releasePath%\grocy_%version%.zip" "%projectPath%\data\.htaccess"
7za rn "%releasePath%\grocy_%version%.zip" .htaccess data\.htaccess

View File

@@ -0,0 +1,27 @@
<?php
// This is executed inside DatabaseMigrationService class/context
use Grocy\Services\StockService;
$PRODUCTS = [3, 4, 5, 6, 7, 8];
$i = 1;
$days = -1;
while ($i <= 500)
{
$productId = $PRODUCTS[array_rand($PRODUCTS)];
$transactionId1 = $this->getStockService()->AddProduct($productId, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime("$days days")), XRandomPrice());
$transactionId2 = $this->getStockService()->ConsumeProduct($productId, 1, false, StockService::TRANSACTION_TYPE_CONSUME);
$this->getDatabaseService()->ExecuteDbStatement("UPDATE stock_log SET row_created_timestamp = DATETIME(row_created_timestamp, '$days days') WHERE transaction_id = '$transactionId1'");
$this->getDatabaseService()->ExecuteDbStatement("UPDATE stock_log SET row_created_timestamp = DATETIME(row_created_timestamp, '$days days') WHERE transaction_id = '$transactionId2'");
$days--;
$i++;
}
function XRandomPrice()
{
return mt_rand(2 * 100, 25 * 100) / 100 / 4;
}

View File

@@ -0,0 +1,16 @@
<?php
// This is executed inside DatabaseMigrationService class/context
use Grocy\Services\RecipesService;
$recipesService = RecipesService::getInstance();
for ($i = 1; $i <= 87; $i++)
{
$recipesService->CopyRecipe(1);
$recipesService->CopyRecipe(2);
$recipesService->CopyRecipe(3);
$recipesService->CopyRecipe(4);
$recipesService->CopyRecipe(5);
}

View File

@@ -0,0 +1,19 @@
<?php
// This is executed inside DatabaseMigrationService class/context
$db = $this->getDatabaseService()->GetDbConnection();
// Reset the password of the user "admin" to "admin"
$adminUserRow = $db->users()->where('username', 'admin')->fetch();
if ($adminUserRow == null)
{
$adminUserRow = $db->users()->createRow([
'username' => 'admin'
]);
}
$adminUserRow->update([
'password' => password_hash('admin', PASSWORD_DEFAULT)
]);

Binary file not shown.

View File

@@ -1,4 +1,4 @@
pushd ..
call composer install
yarn install
call yarn install
popd

View File

@@ -0,0 +1,3 @@
pushd ..
tx pull --all --resources grocy.strings --minimum-perc=70
popd

View File

@@ -1,6 +1,11 @@
pushd ..
tx pull --all --minimum-perc=70
tx pull --language en_GB
for /d %%d in (localization\*) do (
if %%~nxd neq en (
tx pull --languages %%~nxd --force
)
)
copy /Y localization\en\userfield_types.po localization\en_GB\userfield_types.po
copy /Y localization\en\stock_transaction_types.po localization\en_GB\stock_transaction_types.po
copy /Y localization\en\component_translations.po localization\en_GB\component_translations.po
@@ -8,4 +13,5 @@ copy /Y localization\en\chore_period_types.po localization\en_GB\chore_period_ty
copy /Y localization\en\chore_assignment_types.po localization\en_GB\chore_assignment_types.po
copy /Y localization\en\permissions.po localization\en_GB\permissions.po
copy /Y localization\en\locales.po localization\en_GB\locales.po
popd

View File

@@ -1,3 +1,3 @@
pushd ..
tx push --source
tx push --source --force
popd

View File

@@ -1,4 +1,4 @@
pushd ..
call composer update
yarn upgrade
call yarn upgrade
popd

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
custom: ["https://grocy.info/#say-thanks"]

22
.github/ISSUE_TEMPLATE/bug-report.md vendored Normal file
View File

@@ -0,0 +1,22 @@
---
name: Bug Report
about: If you've found something that does not work, please report it to help improve
Grocy
title: 'Bug: '
labels: bug
assignees: ''
---
<!--
Please make sure to:
- Describe the bug as detailed as possible by providing the exact steps how to reproduce it
- Attach screenshots where useful
- Check if the problem was maybe already reported or fixed by searching open and closed issues here
- Keep it to one topic per issue
Please also try to reproduce the problem on the pre-release demo: => https://demo-prerelease.grocy.info
- Use a private demo instance to make your example persistent
- If the problem is not reproducible there, it's most likely not a bug - please use the r/grocy subreddit for general help and usage questions: => https://www.reddit.com/r/grocy
-->

View File

@@ -1,10 +0,0 @@
---
name: Bug report
about: If you've found something that does not work, please report it to help improve grocy
title: 'Bug: '
labels: bug, ui-bug
assignees: ''
---
Please describe the bug as detailed as possible, provide the steps how to reproduce it and maybe attach screenshots where useful.

View File

@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Question / Help
- name: Questions / Help
url: https://www.reddit.com/r/grocy
about: Please use the r/grocy subreddit for general questions / help
about: Please use the r/grocy subreddit for general help and usage questions

View File

@@ -0,0 +1,17 @@
---
name: Feature Request
about: Ideas for improvements or new things which you would find useful are always
welcome
title: 'Feature Request: '
labels: enhancement
assignees: ''
---
<!--
Please make sure to:
- Describe what you would find useful as detailed as possible
- Check if your idea was maybe already requested by searching open requests here
- Keep it to one topic per request
-->

View File

@@ -1,10 +0,0 @@
---
name: Feature request
about: Ideas for improvements or new things which you would find useful are always welcome
title: 'Feature request: '
labels: enhancement
assignees: ''
---
Please describe what you would find useful and please also check (by searching open requests here) if that was maybe already requested.

5
.github/SECURITY.md vendored Normal file
View File

@@ -0,0 +1,5 @@
Grocy is not an enterprise application and neither one you (should) host publicly (means without authentication) on the internet.
So unless something really bad can be abused _unauthenticated_, it's considered practically irrelevant for the target use case of Grocy and therefore not even worth reporting that.
If you really think you've found something critical and valid for the target use case of Grocy and you feel the need to contact me privately on that, please see [berrnd.de](https://berrnd.de) for any contact information.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 637 KiB

After

Width:  |  Height:  |  Size: 540 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 212 KiB

7
.gitignore vendored
View File

@@ -1,4 +1,5 @@
/public/node_modules
/vendor
embedded.txt
.DS_Store
/.release
embedded.txt
/packages
/public/packages

54
.php-cs-fixer.php Normal file
View File

@@ -0,0 +1,54 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude(['packages'])
->ignoreVCSIgnored(true)
->files()->name('*.php')
->in(__DIR__);
$cfg = new PhpCsFixer\Config();
return $cfg
->setRules([
'@PSR2' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'class_attributes_separation' => true,
'class_attributes_separation' => ['elements' => ['const' => 'none', 'property' => 'none']],
'multiline_whitespace_before_semicolons' => false,
'single_quote' => true,
'blank_line_after_opening_tag' => true,
'curly_braces_position' => [
'control_structures_opening_brace' => 'next_line_unless_newline_at_signature_end',
'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end'
],
'control_structure_continuation_position' => [
'position' => 'next_line'
],
'cast_spaces' => [
'space' => 'none'
],
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'type_declaration_spaces' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'include' => true,
'lowercase_cast' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_spaces_around_offset' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'blank_lines_before_namespace' => true,
'ternary_operator_spaces' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'no_trailing_comma_in_singleline' => true
])
->setIndent("\t")
->setLineEnding("\n")
->setUsingCache(false)
->setFinder($finder);

97
.php_cs
View File

@@ -1,97 +0,0 @@
<?php
return PhpCsFixer\Config::create()
->setRules(array(
'@PSR2' => true,
'array_indentation' => true,
'array_syntax' => array('syntax' => 'short'),
'combine_consecutive_unsets' => true,
'method_separation' => true,
'no_multiline_whitespace_before_semicolons' => true,
'single_quote' => true,
'binary_operator_spaces' => array(
'align_double_arrow' => false,
'align_equals' => false,
),
// 'blank_line_after_opening_tag' => true,
// 'blank_line_before_return' => true,
'braces' => array(
'allow_single_line_closure' => true,
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'next',
'position_after_functions_and_oop_constructs' => 'next',
),
// 'cast_spaces' => true,
// 'class_definition' => array('singleLine' => true),
'concat_space' => array('spacing' => 'one'),
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'include' => true,
'lowercase_cast' => true,
// 'native_function_casing' => true,
// 'new_with_braces' => true,
// 'no_blank_lines_after_class_opening' => true,
// 'no_blank_lines_after_phpdoc' => true,
// 'no_empty_comment' => true,
// 'no_empty_phpdoc' => true,
// 'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => array(
'extra',
'parenthesis_brace_block',
'square_brace_block',
'throw',
'use',
),
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
// 'no_mixed_echo_print' => array('use' => 'echo'),
'no_multiline_whitespace_around_double_arrow' => true,
// 'no_short_bool_cast' => true,
// 'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
// 'no_trailing_comma_in_list_call' => true,
// 'no_trailing_comma_in_singleline_array' => true,
// 'no_unneeded_control_parentheses' => true,
// 'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
// 'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
// 'php_unit_fqcn_annotation' => true,
// 'phpdoc_align' => true,
// 'phpdoc_annotation_without_dot' => true,
// 'phpdoc_indent' => true,
// 'phpdoc_inline_tag' => true,
// 'phpdoc_no_access' => true,
// 'phpdoc_no_alias_tag' => true,
// 'phpdoc_no_empty_return' => true,
// 'phpdoc_no_package' => true,
// 'phpdoc_no_useless_inheritdoc' => true,
// 'phpdoc_return_self_reference' => true,
// 'phpdoc_scalar' => true,
// 'phpdoc_separation' => true,
// 'phpdoc_single_line_var_spacing' => true,
// 'phpdoc_summary' => true,
// 'phpdoc_to_comment' => true,
// 'phpdoc_trim' => true,
// 'phpdoc_types' => true,
// 'phpdoc_var_without_name' => true,
// 'pre_increment' => true,
// 'return_type_declaration' => true,
// 'self_accessor' => true,
// 'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
// 'single_class_element_per_statement' => true,
// 'space_after_semicolon' => true,
// 'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
// 'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
))
->setIndent("\t")
->setLineEnding("\n")
;

View File

@@ -1,56 +1,56 @@
[main]
host = https://www.transifex.com
[grocy.chore_period_types]
file_filter = localization/<lang>/chore_period_types.po
source_file = localization/chore_period_types.pot
source_lang = en
type = PO
[grocy.chore_assignment_types]
[o:grocy:p:grocy:r:chore_assignment_types]
file_filter = localization/<lang>/chore_assignment_types.po
source_file = localization/chore_assignment_types.pot
source_lang = en
type = PO
type = PO
[grocy.component_translations]
[o:grocy:p:grocy:r:chore_period_types]
file_filter = localization/<lang>/chore_period_types.po
source_file = localization/chore_period_types.pot
source_lang = en
type = PO
[o:grocy:p:grocy:r:component_translations]
file_filter = localization/<lang>/component_translations.po
source_file = localization/component_translations.pot
source_lang = en
type = PO
type = PO
[grocy.demo_data]
[o:grocy:p:grocy:r:demo_data]
file_filter = localization/<lang>/demo_data.po
source_file = localization/demo_data.pot
source_lang = en
type = PO
type = PO
[grocy.stock_transaction_types]
file_filter = localization/<lang>/stock_transaction_types.po
source_file = localization/stock_transaction_types.pot
source_lang = en
type = PO
[grocy.strings]
file_filter = localization/<lang>/strings.po
source_file = localization/strings.pot
source_lang = en
type = PO
[grocy.userfield_types]
file_filter = localization/<lang>/userfield_types.po
source_file = localization/userfield_types.pot
source_lang = en
type = PO
[grocy.permissions]
file_filter = localization/<lang>/permissions.po
source_file = localization/permissions.pot
source_lang = en
type = PO
[grocy.locales]
[o:grocy:p:grocy:r:locales]
file_filter = localization/<lang>/locales.po
source_file = localization/locales.pot
source_lang = en
type = PO
type = PO
[o:grocy:p:grocy:r:permissions]
file_filter = localization/<lang>/permissions.po
source_file = localization/permissions.pot
source_lang = en
type = PO
[o:grocy:p:grocy:r:stock_transaction_types]
file_filter = localization/<lang>/stock_transaction_types.po
source_file = localization/stock_transaction_types.pot
source_lang = en
type = PO
[o:grocy:p:grocy:r:strings]
file_filter = localization/<lang>/strings.po
source_file = localization/strings.pot
source_lang = en
type = PO
[o:grocy:p:grocy:r:userfield_types]
file_filter = localization/<lang>/userfield_types.po
source_file = localization/userfield_types.pot
source_lang = en
type = PO

View File

@@ -12,6 +12,5 @@
"html.format.wrapAttributes": "force",
"html.format.wrapLineLength": 0,
"php-cs-fixer.formatHtml": true,
"php-cs-fixer.autoFixBySemicolon": true,
"php-cs-fixer.onsave": true,
"php-cs-fixer.autoFixBySemicolon": true
}

View File

@@ -1,4 +1,4 @@
--modules-folder public/node_modules
--modules-folder public/packages
--install.production true
--install.ignore-scripts true
--install.ignore-optional true

145
README.md
View File

@@ -1,143 +1,198 @@
-----
<div align="center">
<img alt="Logo" height="50" src="https://raw.githubusercontent.com/grocy/grocy/master/public/img/grocy_logo.svg?sanitize=true"/>
<h3>ERP beyond your fridge</h3>
<h5> grocy is a web-based self-hosted groceries & household management solution for your home</h5>
<img alt="Logo" height="50" src="https://raw.githubusercontent.com/grocy/grocy/master/public/img/logo.svg?sanitize=true" />
<h2>ERP beyond your fridge</h2>
<h3>Grocy is a web-based self-hosted groceries & household management solution for your home</h3>
<em><h4>This is a hobby project by <a href="https://berrnd.de">Bernd Bestel</a></h4></em>
</div>
-----
## Give it a try
- Public demo of the latest stable version (`release` branch) &rarr; [https://demo.grocy.info](https://demo.grocy.info)
- Public demo of the current development version (`master` branch) &rarr; [https://demo-prerelease.grocy.info](https://demo-prerelease.grocy.info)
## Questions / Help / Bug reporting / Feature requests
There is the [r/grocy subreddit](https://www.reddit.com/r/grocy) to connect with other grocy users and getting help.
## Features
If you've found something that does not work or if you have an idea for an improvement or new things which you would find useful, feel free to open a request on the [issue tracker](https://github.com/grocy/grocy/issues) here.
See the website. &rarr; <https://grocy.info>
Please don't send me private messages regarding grocy help. I check the issue tracker and the subreddit pretty much daily, but don't provide grocy support beyond that.
## Questions / Help / Bug Reports / Feature Requests
- General help and usage questions &rarr; [r/grocy subreddit](https://www.reddit.com/r/grocy)
- Bug Reports and Feature Requests &rarr; [Issue Tracker](https://github.com/grocy/grocy/issues/new/choose)
_Please don't send me private messages or call me regarding anything Grocy. I check the issue tracker and the subreddit pretty much daily, but don't provide any support beyond that._
## Community contributions
See the website for a list of community contributed Add-ons / Tools: [https://grocy.info/addons](https://grocy.info/addons)
## Motivation
A household needs to be managed. I did this so far (almost 10 years) with my first self written software (a C# windows forms application) and with a bunch of Excel sheets. The software is a pain to use and Excel is Excel. So I searched for and tried different things for a (very) long time, nothing 100 % fitted, so this is my aim for a "complete household management"-thing. ERP your fridge!
See the website for a list of community contributed Add-ons / Tools. &rarr; [https://grocy.info/addons](https://grocy.info/addons)
## How to install
> Checkout [grocy-desktop](https://github.com/grocy/grocy-desktop), if you want to run grocy without having to manage a webserver just like a normal ("indows) desktop application.
> Checkout [Grocy Desktop](https://github.com/grocy/grocy-desktop), if you want to run Grocy without having to manage a webserver just like a normal (Windows) desktop application.
>
> Directly download the [latest release](https://releases.grocy.info/latest-desktop) - the installation is nothing more than just clicking 2 times "next".
See [https://grocy.info/links](https://grocy.info/links) for some installation guides and troubleshooting help.
grocy is technically a pretty simple PHP application, so the basic notes to get it running are:
Grocy is technically a pretty simple PHP application, so the basic notes to get it running are:
- Unpack the [latest release](https://releases.grocy.info/latest)
- Copy `config-dist.php` to `data/config.php` + edit to your needs
- Ensure that the `data` directory is writable
- The webserver root should point to the `public` directory
- Include `try_files $uri /index.php$is_args$query_string;` in your location block if you use nginx
- Or disable URL rewriting (see the option `DISABLE_URL_REWRITING` in `data/config.php`)
- SQLite 3.8.3 or higher is required and everything is currently only tested against PHP 7.4
- &rarr; Default login is user `admin` with password `admin`, please change the password immediately (user menu at the top right corner)
Alternatively clone this repository (the `release` branch always references the latest released version, or checkout the latest tagged revision) and install Composer and Yarn dependencies manually.
Alternatively clone this repository (the `release` branch always references the latest released version) and install Composer and Yarn dependencies manually.
See the website for more installation guides and troubleshooting help. &rarr; [https://grocy.info/links](https://grocy.info/links)
### Platform support
- PHP 8.2 or 8.3 (with SQLite 3.34.0+)
- Required PHP extensions: `fileinfo`, `pdo_sqlite`, `gd`, `ctype`, `intl`, `zlib`, `mbstring`
- _Recommendation: Benchmark tests showed that e.g. unit conversion handling is up to 5 times faster when using a more recent (3.39.4+) SQLite version._
- Recent Firefox, Chrome or Edge
## How to run using Docker
See [grocy/grocy-docker](https://github.com/grocy/grocy-docker) or [linuxserver/docker-grocy](https://github.com/linuxserver/docker-grocy) for instructions.
&rarr; https://hub.docker.com/r/linuxserver/grocy
## How to update
Just overwrite everything with the latest release while keeping the `data` directory, check `config-dist.php` for new configuration options and add them to your `data/config.php` where appropriate (the default values from `config-dist.php` will be used for not in `data/config.php` defined settings). Just to be sure, please empty `data/viewcache`.
If you run grocy on Linux, there is also `update.sh` (remember to make the script executable (`chmod +x update.sh`) and ensure that you have `unzip` installed) which does exactly this and additionally creates a backup (`.tgz` archive) of the current installation in `data/backups` (backups older than 60 days will be deleted during the update).
- Overwrite everything with the [latest release](https://releases.grocy.info/latest) while keeping the `data` directory
- Check `config-dist.php` for new configuration options and add them to your `data/config.php` where appropriate (the default values from `config-dist.php` will be used for not in `data/config.php` defined settings)
If you run Grocy on Linux, there is also `update.sh` (remember to make the script executable (`chmod +x update.sh`) and ensure that you have `unzip` installed) which does exactly this and additionally creates a backup (`.tgz` archive) of the current installation in `data/backups` (backups older than 60 days will be deleted during the update).
## Localization
grocy is fully localizable - the default language is English (integrated into code), a German localization is always maintained by me.
You can easily help translating grocy at https://www.transifex.com/grocy/grocy, if your language is incomplete or not available yet.
(The default language can be set in `data/config.php`, e. g. `Setting('DEFAULT_LOCALE', 'it');` and there is also a user setting (see the user settings page) to set a different language per user).
Grocy is fully localizable - the default language is English (integrated into code), a German localization is always maintained by me.
You can easily help translating Grocy on [Transifex](https://explore.transifex.com/grocy/grocy/) if your language is incomplete or not available yet.
The default language can be set in `data/config.php`, e. g. `Setting('DEFAULT_LOCALE', 'de');` and there is also a user setting (see the user settings page) to set a different language per user.
The [pre-release demo](https://demo-prerelease.grocy.info) is available for any translation which is at least 70 % complete and will pull the translations from Transifex 10 minutes past every hour, so you can have a kind of instant preview of your contributed translations. Thank you!
Also any translation which once reached a completion level of 70 % will be included in releases.
Also any translation which once reached a completion level of 70 % ([`strings` resource](https://app.transifex.com/grocy/grocy/strings/)) will be included in releases.
_RTL languages are unfortunately not yet supported._
## Motivation
A household needs to be managed. Before Grocy I did this (for almost 10 years) using my first self written software (a C# Windows forms application) and with a bunch of Excel sheets. The software was a pain to use at the end and Excel is Excel. So I searched for and tried different things for a (very) long time, nothing 100 % fitted, so this is my aim for a "complete household management"-thing. ERP your fridge!
## Things worth to know
### REST API & data model documentation
### REST API
See the integrated Swagger UI instance on [/api](https://demo.grocy.info/api).
The web frontend uses exactly this API for pretty much everything. So everything you can do there is also possible via the API.
### Barcode readers & camera scanning
Some fields (with a barcode icon above) also allow to select a value by scanning a barcode. It works best when your barcode reader prefixes every barcode with a letter which is normally not part of a item name (I use a `$`) and sends a `TAB` after a scan.
Additionally it's also possible to use your device camera to scan a barcode by using the camera button on the right side of the corresponding field (powered by [Quagga2](https://github.com/ericblade/quagga2), totally offline / client-side camera stream processing, please note due to browser security restrictions, this only works when serving grocy via a secure connection (`https://`)). Quick video demo: https://www.youtube.com/watch?v=Y5YH6IJFnfc
Additionally it's also possible to use your device camera to scan a barcode by using the camera button on the right side of the corresponding input field (powered by [ZXing](https://github.com/zxing-js/library), totally offline / client-side camera stream processing, please note due to browser security restrictions, this only works when serving Grocy via a secure connection (`https://`)). [Here](https://www.youtube.com/watch?v=veezFX4X1JU) and [there](https://www.youtube.com/watch?v=Y5YH6IJFnfc) are quick video demos of that.
_My personal recommendation: Use a USB barcode laser scanner. They are cheap and work 1000 % better, faster, under any lighting condition and from any angle._
### Barcode lookup via external services
Products can be directly added to the database via looking them up against external services by a barcode.
This can be done in-place using the product picker workflow "External barcode lookup" (the workflow dialog is displayed when entering something unknown in any product input field) Quick video demo: <https://www.youtube.com/watch?v=-moXPA-VvGc>
A plugin for [Open Food Facts](https://world.openfoodfacts.org/) is included and used by default (see the `data/config.php` option `STOCK_BARCODE_LOOKUP_PLUGIN`).
See that plugin or `plugins/DemoBarcodeLookupPlugin.php` for a commented example implementation if you want to build a plugin.
### Input shorthands for date fields
For (productivity) reasons all date (and time) input (and display) fields use the ISO-8601 format regardless of localization.
The following shorthands are available:
- `MMDD` gets expanded to the given day on the current year, if > today, or to the given day next year, if < today, in proper notation
- Example: `0517` will be converted to `2018-05-17`
- Example: `0517` will be converted to `2025-05-17`
- `YYYYMMDD` gets expanded to the proper ISO-8601 notation
- Example: `20190417` will be converted to `2019-04-17`
- Example: `20250417` will be converted to `2025-04-17`
- `YYYYMMe` or `YYYYMM+` gets expanded to the end of the given month in the given year in proper notation
- Example: `201807e` will be converted to `2018-07-31`
- `x` gets expanded to `2999-12-31` (which I use for products which are never overdue)
- Example: `202507e` will be converted to `2025-07-31`
- `[+/-]n[d/m/y]` gets expanded to a date relative to today, while adding (**+**) or subtracting (**-**) the **n**umber of **d**ays/**m**onths/**y**ears, in proper notation
- Example: `+1m` will be converted to the same day next month
- `x` gets expanded to `2999-12-31` (which is an alias for "never overdue")
- Down/up arrow keys will increase/decrease the date by 1 day
- Right/left arrow keys will increase/decrease the date by 1 week
- Shift + down/up arrow keys will increase/decrease the date by 1 month
- Shift + right/left arrow keys will increase/decrease the date by 1 year
### Keyboard shorthands for buttons
Wherever a button contains a bold highlighted letter, this is a shortcut key.
Example: Button "**P** Add as new product" can be "pressed" by using the `P` key on your keyboard.
### Barcode lookup via external services
Products can be directly added to the database via looking them up against external services by a barcode.
This is currently only possible through the REST API.
There is no plugin included for any service, see the reference implementation in `data/plugins/DemoBarcodeLookupPlugin.php`.
### Installable web app (PWA)
Grocy's web frontend is responsive and an "installable web app" ([PWA](https://en.wikipedia.org/wiki/Progressive_web_app), without providing any offline usage capabilities), that provides a pretty native mobile app-like experience without the need for additional tools.
- Quick video demo on Android/Firefox: <https://www.youtube.com/watch?v=L38drVZfwHs>
- Quick video demo on Android/Chrome: <https://www.youtube.com/watch?v=rjLdXUFDNuk>
### Database migrations
Database schema migration is automatically done when visiting the root (`/`) route (click on the logo in the left upper edge).
_Please note: Database migrations are supposed to work between releases, not between every commit. If you want to run the current `master` branch (which is the development version), however, you need to handle that (and maybe more) yourself._
Database schema migration is done when visiting the root (`/`) route (click on the logo in the left upper edge) as needed and is also triggered automatically if the version has changed (so when an update has been made).
_Please note: Database migrations are supposed to work between releases, not between every commit. If you want to run the current `master` branch (which is the development version), you need to handle that (and more) yourself._
### Disable certain features
If you don't use certain feature sets of grocy (for example if you don't need "Chores"), there are feature flags per major feature set to hide/disable the related UI elements (see `config-dist.php`)
If you don't use certain feature sets of Grocy (for example if you don't need "Chores"), there are feature flags per major feature set to hide/disable the related UI elements (see `config-dist.php`).
### Adding your own CSS or JS without to have to modify the application itself
- When the file `data/custom_js.html` exists, the contents of the file will be added just before `</body>` (end of body) on every page
- When the file `data/custom_css.html` exists, the contents of the file will be added just before `</head>` (end of head) on every page
### Demo mode
When the `MODE` setting is set to `dev`, `demo` or `prerelease`, the application will work in a demo mode which means authentication is disabled and some demo data will be generated during the database schema migration.
When the `MODE` setting is set to `dev`, `demo` or `prerelease`, the application will work in a demo mode which means authentication is disabled and some demo data will be generated during the database schema migration (pass the query parameter `nodemodata`, e.g. `https://grocy.example.com/?nodemodata` to skip that).
### Embedded mode
When the file `embedded.txt` exists, it must contain a valid and writable path which will be used as the data directory instead of `data` and authentication will be disabled (used in [grocy-desktop](https://github.com/grocy/grocy-desktop)).
When the file `embedded.txt` exists, it must contain a valid and writable path which will be used as the data directory instead of `data` and authentication will be disabled (used in [Grocy Desktop](https://github.com/grocy/grocy-desktop)).
In embedded mode, settings can be overridden by text files in `data/settingoverrides`, the file name must be `<SettingName>.txt` (e. g. `BASE_URL.txt`) and the content must be the setting value (normally one single line).
## Contributing / Say thanks
Any help is more than appreciated. Feel free to pick any open unassigned issue and submit a pull request, but please leave a short comment or assign the issue yourself, to avoid working on the same thing.
## Contributing / Say Thanks
See https://grocy.info/#say-thanks for more ideas if you just want to say thanks.
Any help is welcome, feel free to contribute anything which comes to your mind or see <https://grocy.info/#say-thanks> if you just want to say thanks.
## Roadmap
There is none. The progress of a specific bug/enhancement is always tracked in the corresponding issue, at least by commit comment references.
[Milestones](https://github.com/grocy/grocy/milestones) are used to indicate in which version the corresponding request was done (`vNEXT` means it's currently planned to do that for the next release).
## Screenshots
#### Stock overview
### Stock overview
![Stock overview](https://github.com/grocy/grocy/raw/master/.github/publication_assets/stock.png "Stock overview")
#### Shopping List
### Shopping List
![Shopping List](https://github.com/grocy/grocy/raw/master/.github/publication_assets/shoppinglist.png "Shopping List")
#### Meal Plan
### Meal Plan
![Meal Plan](https://github.com/grocy/grocy/raw/master/.github/publication_assets/mealplan.png "Meal Plan")
#### Chores overview
### Chores overview
![Chores overview](https://github.com/grocy/grocy/raw/master/.github/publication_assets/chores.png "Chores overview")
## License
The MIT License (MIT)

76
app.php
View File

@@ -1,23 +1,35 @@
<?php
use Grocy\Controllers\LoginController;
use Grocy\Controllers\ExceptionController;
use Grocy\Helpers\UrlManager;
use Grocy\Middleware\LocaleMiddleware;
use Grocy\Middleware\CorsMiddleware;
use Psr\Container\ContainerInterface as Container;
use Slim\Factory\AppFactory;
use Slim\Views\Blade;
// Load composer dependencies
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/packages/autoload.php';
// Load config files
require_once GROCY_DATAPATH . '/config.php';
require_once __DIR__ . '/config-dist.php'; // For not in own config defined values we use the default ones
require_once __DIR__ . '/helpers/ConfigurationValidator.php';
// Error reporting definitions
if (GROCY_MODE === 'dev')
{
error_reporting(E_ALL);
}
else
{
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
}
// Definitions for dev/demo/prerelease mode
if ((GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease') && !defined('GROCY_USER_ID'))
{
define('GROCY_USER_ID', 1);
define('GROCY_SHOW_AUTH_VIEWS', true);
}
// Definitions for disabled authentication mode
@@ -27,8 +39,43 @@ if (GROCY_DISABLE_AUTH === true)
{
define('GROCY_USER_ID', 1);
}
}
define('GROCY_SHOW_AUTH_VIEWS', false);
// Check if any invalid entries in config.php have been made
try
{
(new ConfigurationValidator())->validateConfig();
}
catch (EInvalidConfig $ex)
{
exit('Invalid setting in config.php: ' . $ex->getMessage());
}
// Create data/viewcache folder if it doesn't exist
$viewcachePath = GROCY_DATAPATH . '/viewcache';
if (!file_exists($viewcachePath))
{
mkdir($viewcachePath);
}
// Empty data/viewcache when and trigger database migrations when:
// The version changed (so when an update was done)
// GROCY_BASE_URL OR GROCY_BASE_PATH changed
$hash = hash('sha256', file_get_contents(__DIR__ . '/version.json') . GROCY_BASE_URL . GROCY_BASE_PATH);
$hashCacheFile = $viewcachePath . "/$hash.txt";
if (!file_exists($hashCacheFile))
{
EmptyFolder($viewcachePath);
touch($hashCacheFile);
if (function_exists('opcache_reset'))
{
opcache_reset();
}
// Schema migration happens on the root route, so redirect to there
header('Location: ' . (new UrlManager(GROCY_BASE_URL))->ConstructUrl('/'));
exit();
}
// Setup base application
@@ -36,13 +83,18 @@ AppFactory::setContainer(new DI\Container());
$app = AppFactory::create();
$container = $app->getContainer();
$container->set('view', function (Container $container) {
return new Slim\Views\Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
$container->set('view', function (Container $container)
{
return new Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
});
$container->set('UrlManager', function (Container $container) {
$container->set('UrlManager', function (Container $container)
{
return new UrlManager(GROCY_BASE_URL);
});
$container->set('ApiKeyHeaderName', function (Container $container) {
$container->set('ApiKeyHeaderName', function (Container $container)
{
return 'GROCY-API-KEY';
});
@@ -57,7 +109,7 @@ if (!empty(GROCY_BASE_PATH))
if (GROCY_MODE === 'production' || GROCY_MODE === 'dev')
{
$app->add(new \Grocy\Middleware\LocaleMiddleware($container));
$app->add(new LocaleMiddleware($container));
}
else
{
@@ -70,8 +122,12 @@ $app->add(new $authMiddlewareClass($container, $app->getResponseFactory()));
$app->addRoutingMiddleware();
$errorMiddleware = $app->addErrorMiddleware(true, false, false);
$errorMiddleware->setDefaultErrorHandler(
new \Grocy\Controllers\ExceptionController($app, $container)
new ExceptionController($app, $container)
);
$app->add(new CorsMiddleware($app->getResponseFactory()));
$app->getRouteCollector()->setCacheFile(GROCY_DATAPATH . '/viewcache/route_cache.php');
ob_clean(); // No response output before here
$app->run();

View File

@@ -1 +1 @@
- grocy is now fully localizable and ships by default with English and German translations
- Grocy is now fully localizable and ships by default with English and German translations

View File

@@ -1,3 +1,3 @@
- Upgraded Bootstrap and some other dependencies (grocy now looks even better!)
- Upgraded Bootstrap and some other dependencies (Grocy now looks even better!)
- Added Italian translation (thanks @davidoskky)
- => Demo for this language available at: https://it.demo.grocy.info

View File

@@ -1,5 +1,5 @@
This was released shortly after the last release to fix a small regression bug, original changes from Version 1.13.0:
- Upgraded Bootstrap and some other dependencies (grocy now looks even better!)
- Upgraded Bootstrap and some other dependencies (Grocy now looks even better!)
- Added Italian translation (thanks @davidoskky)
- => Demo for this language available at: https://it.demo.grocy.info

View File

@@ -10,4 +10,4 @@
- Sidebar collapse state is now remembered
- Fixed datetimepicker border
- Keep the parent sidebar menu item expanded if the active page is a sub menu item
- Custom JS/CSS file names have changed [see README](https://github.com/berrnd/grocy#adding-your-own-css-or-js-without-to-have-to-modify-the-application-itself)
- Custom JS/CSS file names have changed [see README](https://github.com/grocy/grocy#adding-your-own-css-or-js-without-to-have-to-modify-the-application-itself)

View File

@@ -1,9 +1,9 @@
- New related project: **grocy-desktop**
- => https://github.com/berrnd/grocy-desktop
- Run grocy without a webserver just like a normal (windows) desktop application
- New "embedded mode" for grocy to help running in "desktop application mode" [see README](https://github.com/berrnd/grocy#embedded-mode)
- New related project: **Grocy Desktop**
- => https://github.com/grocy/grocy-desktop
- Run Grocy without a webserver just like a normal (Windows) desktop application
- New "embedded mode" for Grocy to help running in "desktop application mode" [see README](https://github.com/grocy/grocy#embedded-mode)
- New datepicker shorthands and improvements
- `YYYYMMe` or `YYYYMM+` gets expanded to the end of the given month in the given year in proper notation
- Changed: `MMDD` will be expanded to the given day next year if > today
- [see README](https://github.com/berrnd/grocy#input-shorthands-for-date-fields)
- [see README](https://github.com/grocy/grocy#input-shorthands-for-date-fields)
- Some other small bug fixes

View File

@@ -2,7 +2,7 @@
- The currently defined user will automatically be migrated, please remove `HTTP_USER` and `HTTP_PASSWORD` from your config file afterwards
- For this it was necessary to delete all sessions and API keys during the migration
- Added an update script (`/update.sh`) to make updates (on Linux machines) easier
- See also ["How to update" in README](https://github.com/berrnd/grocy#how-to-update)
- See also ["How to update" in README](https://github.com/grocy/grocy#how-to-update)
- Added the possibility to track who did a habit
- Added a rudimentary habit analysis possibility
- Different small UI, code and translation improvements

View File

@@ -2,5 +2,5 @@
- Manage all your household equipment/devices in one place and have the information/instruction manual at hand when needed
- New feature: Products can now have pictures
- Add them in the product edit page
- Will be shown in the productcard (purchase/consume/etc. pages) and when you click the product name on the stock overview page (a little image icon next to the product name indicates if the product has an image)
- Will be shown in the product card (purchase/consume/etc. pages) and when you click the product name on the stock overview page (a little image icon next to the product name indicates if the product has an image)
- Recipes and the new equipment edit page now have a little editor with text formatting capabilities

View File

@@ -19,5 +19,5 @@
- Other improvements
- The calendar can now be shared/integrated in iCal format (button in the header on the calendar page)
- Added feature flags to hide/disable certain parts of grocy when you don't use them (for example hide "Chores" and all related UI elements, when you don't use it, see `config-dist.php`)
- Added a "Apple Touch Icon" and a "Web App Manifest" which should improve grocy on mobile devices and also enables "Add to Home screen" on major mobile browsers
- Added a "Apple Touch Icon" and a "Web App Manifest" which should improve Grocy on mobile devices and also enables "Add to Home screen" on major mobile browsers
- A lot of other minor small and bigger UI improvements

View File

@@ -11,7 +11,5 @@
- Some other small CSS fixes (context menus were not fully displayed when the parent container was to small, improved padding for text inputs)
- As always: Updated translations (thanks all the translators)
### Self promotion
[grocy-desktop](https://github.com/grocy/grocy-desktop) is now also available through the Microsoft Store
<a href="//www.microsoft.com/store/apps/9nwb1trnnksf?cid=storebadge&ocid=badge"><img src="https://assets.windowsphone.com/85864462-9c82-451e-9355-a3d5f874397a/English_get-it-from-MS_InvariantCulture_Default.png" alt="Get it from Microsoft" width="150px" /></a>
### Other
- [Grocy Desktop](https://github.com/grocy/grocy-desktop) is now also available through the Microsoft Store: https://apps.microsoft.com/detail/9NWB1TRNNKSF

View File

@@ -29,6 +29,6 @@
- Also applies to quantity units, n-plural forms can be entered on the quantity unit edit page
- It's not required to install the PHP gettext extension, on both, server and client, managed implementations of gettext are used ([oscarotero/Gettext](https://github.com/oscarotero/Gettext) & [oscarotero/gettext-translator](https://github.com/oscarotero/gettext-translator))
- Some other small fixes and improvements
- The "Add as barcode to existing product" productpicker workflow failed to add the barcode to the given product
- The "Add as barcode to existing product" product picker workflow failed to add the barcode to the given product
- Recipes can now be filter by stock availability
- Added a feature flag (`config.php` setting) to also be able to hide all stock related UI elements and routes

View File

@@ -2,7 +2,7 @@
- Fixed a problem that the user settings were not properly initialized for the frontend JS part when not logged only (so potentially affected only the login page)
- Fixed an issue that the shopping list did not load when a plural translation for a quantity unit was missing
- Fixed that tooltips were visible forever when consuming all products on the stock overview page
- Fixed that login did not work when "Stay logged in permanently" was set and grocy runs on a 32-bit system (thanks @matejdro)
- Fixed that login did not work when "Stay logged in permanently" was set and Grocy runs on a 32-bit system (thanks @matejdro)
- Fixed page reloads when "Auto reload on external changes" is enabled and there is unsaved form data (the detection did not work for forms in modal dialogs, e. g. when adding a entry to the meal plan)
- Fixed (again) that the product picker did not work properly when the product name contains single quotes
- Fixed that a entered barcode on the product edit page was only saved when "adding" it to the barcodes list by pressing `TAB` (is now automatically added to the list also when just leaving the field)

View File

@@ -1,14 +1,15 @@
### New feature: Custom entities / objects / lists
- Custom entities are based on Userfields and can be used to add any custom lists you want to have in grocy
### New Feature: Custom entities / objects / lists
- Custom entities are based on Userfields and can be used to add any custom lists you want to have in Grocy
- They can have an own menu entry in the sidebar
- => See "Manage master data" -> "Userentities" or try it on the demo: https://demo.grocy.info/userobjects/exampleuserentity
### New feature: Use the device camera for barcode scanning
### New Feature: Use the device camera for barcode scanning
- Available on any barcode-enabled field (so currently only for picking products) - a new camera button at the right of side the text field
- Implemented using [QuaggaJS](https://github.com/serratus/quaggaJS) - camera stream processing happens totally offline / client-side
- Please note due to browser security restrictions, this only works when serving grocy via a secure connection (`https://`)
- Please note due to browser security restrictions, this only works when serving Grocy via a secure connection (`https://`)
- There is also a `config.php` setting `DISABLE_BROWSER_BARCODE_CAMERA_SCANNING` to disable this, if you don't need it at all (defaults to `false`)
- I you have problems that barcodes are not recognized properly, there is a little "barcode scanner testing page" at [/barcodescannertesting](https://demo.grocy.info/barcodescannertesting)
- If you have problems that barcodes are not recognized properly, there is a little "barcode scanner testing page" at [/barcodescannertesting](https://demo.grocy.info/barcodescannertesting)
- => Quick video demo: https://www.youtube.com/watch?v=Y5YH6IJFnfc
### Stock improvements/fixes
@@ -20,7 +21,7 @@
- Quantity units can now be linked (related measurements / unit conversion)
- On the quantity unit edit page default conversion can be defined for each unit
- Products "inherit" the default conversion and additionally can have their own / override the default ones
- It's now possible to print a "Location Content Sheet" with the current stock per location - new button at the top of the stock overview page (thought to hang it at the location, note used amounts on paper and track it in grocy later)
- It's now possible to print a "Location Content Sheet" with the current stock per location - new button at the top of the stock overview page (thought to hang it at the location, note used amounts on paper and track it in Grocy later)
- Stock overview page improvements
- Options in the more/context-menu to directly open the purchase/consume/inventory pages prefilled with the current product in a popup/dialog
- Option in the more/context-menu to add the current product directly to a shopping list
@@ -66,7 +67,7 @@
### Userfield improvements/fixes
- New Userfield type "Select list" for a list of predefined values where a single or also multiple values can then be selected on the entity object
- New Userfield type "Link" - a single-line-textbox where the content will be rendered as a clickable link
- Userfields of type "checkbox" are rendered as a checkmark in tables when checked (instead of "1" as till now)
- Userfields of type "Checkbox" are rendered as a checkmark in tables when checked (instead of "1" as till now)
- Product Userfields are now also rendered on the shopping list (for items which have a product referenced)
- Fixed that the Userfield type "Preset list" had always the caption "Product group" instead of the configured one (thanks @oncleben31)
@@ -104,4 +105,4 @@
- It's now also possible to provide the API key via a query parameter (same name as the header, so `GROCY-API-KEY`)
#### Say thanks
Because there were some questions about that in the past: If grocy is useful for you, [say thanks](https://grocy.info/#say-thanks)!
Because there were some questions about that in the past: If Grocy is useful for you, [say thanks](https://grocy.info/#say-thanks)!

View File

@@ -3,7 +3,7 @@
- Fixed that the "X products are already expired" count on the stock overview page was wrong
- Fixed that after product actions (consume/purchase/etc.) on the stock overview page the highlighting of the row was maybe wrong
- After product actions (consume/purchase/etc.) on the stock overview page on a sub product, now also the parent product (row) is refreshed
- It's now possible to accumulate min. stock amounts on parent product level (new option per product, means the sub product will never be "missing" then, only the parent product)
- It's now possible to accumulate min. stock amounts on parent product level (new option per product, means the sub product will never be missing then, only the parent product)
- On the purchase page there is now an option to select that the price is the total price (for the whole amount) - below the price field, defaults to "Unit price" (as it was until now), when set to "Total price", the entered price will be divided by the amount before posting
- "Average shelf life" on the product card now displays just "Unlimited" when the resulting value would be > 200 years (for products which never expire, as they have a best before date of 2999-12-31)

View File

@@ -1,10 +1,10 @@
### New feature: Transfer products between locations and edit stock entries
### New Feature: Transfer products between locations and edit stock entries
- New menu entry in the sidebar to transfer products (or as a shortcut in the more/context menu per line on the stock overview page)
- New button "Stock entries" in the header of the stock overview page (or as a shortcut in the more/context menu per line) to show the detail stock entries behind each product
- From there you can also edit the stock entries
- (A huge THANK YOU goes to @kriddles for the work on this feature)
### New feature: Scan mode
### New Feature: Scan mode
- Just scan one product after another, no manual input required and audio feedback is provided
- New switch-button on the purchase and consume page
- When enabled
@@ -14,25 +14,25 @@
- Audio feedback is provided after scanning and on success/error of the transaction
- => Quick video demo: https://www.youtube.com/watch?v=83dm9iD718k
### New feature: Self produced products
### New Feature: Self produced products
- To a recipe a product can be attached
- This products needs a "Default best before date"
- On using "Consume all ingredients needed by this recipe" and when it has a product attached, one unit of that product (per serving in purchase quantity unit) will be added to stock (with the proper price based on the recipe ingredients)
- (Thanks @kriddles for the initial work on this)
### New feature: Freeze/Thaw products
### New Feature: Freeze/Thaw products
- New product options "Default best before days after freezing/thawing" to set how the best before date should be changed on freezing/thawing
- New location option "Is freezer" to indicate if the location is a freezer
- => When moving a product from/to a freezer location, the best before date is changed accordingly
- There is also a new sub feature flag `FEATURE_FLAG_STOCK_PRODUCT_FREEZING` to disable this if you don't need it (defaults to `true`)
### Stock improvements/fixes
- The productcard gets now also refreshed after a transaction was posted (purchase/consume/etc.) (thanks @kriddles)
- The product card gets now also refreshed after a transaction was posted (purchase/consume/etc.) (thanks @kriddles)
- The product field calories (kcal) now also allows decimal numbers
- On the inventory page, "New amount" is now prefilled with the current stock amount of the selected product
- Fixed that entering partial amounts was not possible on the inventory page (only applies if the product option "Allow partial units in stock" is enabled)
- Fixed that on purchase a wrong minimum amount was enforced for products with enabled tare weight handling in combination with different purchase/stock quantity units
- Fixed that the productcard did not load correctly when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was set to `false` (thanks @kriddles)
- Fixed that the product card did not load correctly when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was set to `false` (thanks @kriddles)
- Fixed that the "Add as barcode to existing product" workflow did not work twice when not switching the page inbetween
### Shopping list improvements/fixes

View File

@@ -1,5 +1,5 @@
## !! Important notice
If you run grocy in a subdirectory, you need to set a new `config.php` setting (`BASE_PATH`, see `config-dist.php`)
If you run Grocy in a subdirectory, you need to set a new `config.php` setting (`BASE_PATH`, see `config-dist.php`)
### Stock fixes
- Fixed purchase/consume/inventory problems when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was set to `false`

View File

@@ -1,4 +1,4 @@
### New feature: Price history per store
### New Feature: Price history per store
- Define stores under master data
- New product option to set the default store
- Track on purchase/inventory in which store you bought the product (gets prefilled by the last store you purchased the product, or the default store of the product if you never bought it)

View File

@@ -1,17 +1,25 @@
> ⚠️ The major version bump is due to breaking API changes, please see below if you use the API
### New feature: Use any product related quantity unit anywhere
> ⚠️⚠️ SQLite >= 3.9.0 (was released in late 2015) is required
>
> [Here](https://github.com/grocy/grocy/issues/1209#issuecomment-749760765) is a workaround if you still run a SQLite version >= 3.8.3 < 3.9.0
>
> _PHP 7.2 (with SQLite 3.8.3+) was the formerly minimum runtime requirement, any future release will only support PHP 7.4 (with SQLite 3.27.2+) - supporting those (very) old runtime stuff is too time consuming..._
> ❗ If some pages/tables doesn't load at all, please check that your `/data/config.php` setting `CURRENCY` is a valid ISO 4217 currency code - that's most probably the issue then.
### New Feature: Use any product related quantity unit anywhere
- Finally it's possible to use any product related quantity unit on any page
- Products still have one quantity unit stock and one (default) quantity unit purchase, but any QU, which has a direct or indirect conversion for that product, can be used to pick an amount
- Because the stock quantity unit is now the base for everything, it cannot be changed after the product was once added to stock (for now, maybe there will be a possibilty to change it in a future release)
### New feature: Prefill purchase data by barcodes
### New Feature: Prefill purchase data by barcodes
- Imagine you buy for example eggs in different pack sizes and they have different barcodes
- Each product barcode can be assigned an amount, quantity unit and store (on the product edit page), which is then automatically prefilled on the purchase page
- Additionally, the last price per barcode will be tracked and prefilled as a "Total price" on purchase
- (Thanks @kriddles for the initial work on this)
### New feature: User permissions
### New Feature: User permissions
- Users can now have permissions, can be configured per user on the "Manage users" page (lock icon)
- Default permissions for new users can be set via a new `config.php` setting `DEFAULT_PERMISSIONS` (defaults to `ADMIN`, so no changed behavior when not configured)
- All currently existing users will get all permissions (`ADMIN`) during the update/migration
@@ -19,14 +27,14 @@
- Other users only see their API keys on that page
- (Thanks @fipwmaqzufheoxq92ebc for the initial work on this)
### New feature: External authentication support
### New Feature: External authentication support
- New `config.php` setting `AUTH_CLASS` to change the used authentication provider
- Via LDAP
- New `config.php` settings `LDAP_DOMAIN`, `LDAP_ADDRESS` and `LDAP_BASE_DN`
- If you set `AUTH_CLASS` to `Grocy\Middleware\LdapAuthMiddleware`, users will be authenticated against your directory (and will also be created (in grocy), if not already present)
- If you set `AUTH_CLASS` to `Grocy\Middleware\LdapAuthMiddleware`, users will be authenticated against your directory (and will also be created (in Grocy), if not already present)
- Via a reverse proxy
- New `config.php` setting `REVERSE_PROXY_AUTH_HEADER`
- If you set `AUTH_CLASS` to `Grocy\Middleware\ReverseProxyAuthMiddleware` and your reverse proxy sends a username in the HTTP header `REMOTE_USER` (header name can be changed by the setting `REVERSE_PROXY_AUTH_HEADER`), the user is automatically authenticated (and will also be created (in grocy), if not already present)
- If you set `AUTH_CLASS` to `Grocy\Middleware\ReverseProxyAuthMiddleware` and your reverse proxy sends a username in the HTTP header `REMOTE_USER` (header name can be changed by the setting `REVERSE_PROXY_AUTH_HEADER`), the user is automatically authenticated (and will also be created (in Grocy), if not already present)
- (Thanks @fipwmaqzufheoxq92ebc for the initial work on this)
### Stock improvements/fixes
@@ -48,14 +56,14 @@
- Products can now be duplicated (new dropdown menu item on the products list page, all fields will be preset from the copied product, except the name)
- Products can now be merged (new dropdown menu item on the products list page)
- Useful if you have two products which are basically the same and want to replace all occurrences of one with the other one
- When consuming or opening a parent product, which is currently not in stock, any in-stock sub product will now be consumed/opened (like already automatically done when consuming recipes)
- When consuming or opening a parent product, which is currently not in stock, any in stock sub product will now be consumed/opened (like already automatically done when consuming recipes)
- Opened stock entries get now consumed first by default when no specific stock entry is used/selected
- So the default consume rule is now "Opened first, then first due first, then first in first out"
- Optimized/clarified what the total/unit price on the purchase page is (thanks @kriddles)
- On the purchase page the amount field is now displayed above/before the due date for better `TAB` handling (thanks @kriddles)
- Changed that when `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` is disabled, products now get internally a due date of "never overdue" (aka `2999-12-31`) instead of today (thanks @kriddles)
- Products can now be disabled to keep the history/journal, but hide it everywhere, without deleting it (new product option "Active", deleting a product now explicitly also deletes its journal and all other references) (thanks @kriddles for the initial work on this)
- Products can now be hidden from the stock overview page, even if they are in-stock (new product option "Never show on stock overview", disabled by default, so no changed behavior when not configured)
- Products can now be hidden from the stock overview page, even if they are in stock (new product option "Never show on stock overview", disabled by default, so no changed behavior when not configured)
- That's maybe useful for parent products you only use as a kind of "container"
- The due date is now also prefilled on the inventory page based on the products "Default due days" (was only done on the purchase page before)
- On the stock journal page, it's now visible if a consume-booking was spoiled
@@ -92,7 +100,7 @@
- Fixed that a "Total price" on purchase was not handled correctly for tare weight handling enabled products (the total price was wrongly related to the amount including the tare weight)
### Shopping list improvements
- Added a button to add all currently in-stock but overdue and expired products to the shopping list (thanks @m-byte)
- Added a button to add all currently in stock but overdue and expired products to the shopping list (thanks @m-byte)
- Improved that when `FEATURE_FLAG_STOCK` is disabled, all product/stock related inputs and buttons are now hidden on the shopping list page (thanks @fipwmaqzufheoxq92ebc)
- Shopping list items can now have their own Userfields (entity `shopping_list`), on the shopping list table those fields are rendered additionally to the product Userfields
- The print view is now configurable (new dialog before printing - option to hide header, group products by their product group, alternative list layout)
@@ -166,7 +174,7 @@
- Products, quantity units and product groups are possible to use now
- Means you can use for example the shopping list, recipes and the meal plan with products while the "stock handling part" is hidden
- Ordering now happens case-insensitive
- The data path (previously fixed to the `data` folder) is now configurable, making it possible to run multiple grocy instances from the same directory (with different `config.php` files / different database, etc.) (thanks @fgrsnau)
- The data path (previously fixed to the `data` folder) is now configurable, making it possible to run multiple Grocy instances from the same directory (with different `config.php` files / different database, etc.) (thanks @fgrsnau)
- Via an environment variable `GROCY_DATAPATH` (higher priority)
- Via an FastCGI parameter `GROCY_DATAPATH` (lower priority)
- The language can now be set per user (see the new user settings page / top right corner settings menu) (thanks @fipwmaqzufheoxq92ebc)
@@ -196,7 +204,7 @@
- All prices are now related to the products stock quantity unit (instead of the products purchase QU)
- All (product) amounts are now related to the products stock quantity unit (was related to the products purchase QU for the shopping list before)
- The product object no longer has a field `barcodes` with a comma separated barcode list, instead barcodes are now stored in a separate table/entity `product_barcodes` (use the existing "Generic entity interactions" endpoints to access them)
- The endpoint `/objects/{entity}/search` was removed (use the existing `/objects/{entity}` endpoint with new new filter capabilities mentioned below)
- The endpoint `/objects/{entity}/search` was removed (use the existing `/objects/{entity}` endpoint with the new filter capabilities mentioned below)
- The output / field names of `ProductDetailsResponse` have slightly changed (endpoint `/stock/products/{productId}`)
- Endpoint `/stock/volatile`
- The query parameter `expring_days` was renamed to `due_soon_days`
@@ -245,8 +253,8 @@
- `>=` greater or equal
- `§` regular expression
- `<value>` is the value to search for
- New endpoint `/stock/shoppinglist/add-overdue-products` to add all currently in-stock but overdue products to a shopping list (thanks @m-byte)
- New endpoint `/stock/shoppinglist/add-expired-products` to add all currently in-stock but expired products to a shopping list
- New endpoint `/stock/shoppinglist/add-overdue-products` to add all currently in stock but overdue products to a shopping list (thanks @m-byte)
- New endpoint `/stock/shoppinglist/add-expired-products` to add all currently in stock but expired products to a shopping list
- New endpoints GET/POST/PUT `/users/{userId}/permissions` for the new user permissions feature mentioned above
- New endpoint `/user` to get the currently authenticated user
- New endpoint DELETE `/user/settings/{settingKey}` to delete a user setting

View File

@@ -0,0 +1,19 @@
> ⚠️⚠️ SQLite >= 3.9.0 (was released in late 2015) is required
>
> [Here](https://github.com/grocy/grocy/issues/1209#issuecomment-749760765) is a workaround if you still run a SQLite version >= 3.8.3 < 3.9.0
>
> _PHP 7.2 (with SQLite 3.8.3+) was the formerly minimum runtime requirement, any future release will only support PHP 7.4 (with SQLite 3.27.2+) - supporting those (very) old runtime stuff is too time consuming..._
- Improved the prerequisites checker (added missing required PHP extension `ctype`) (thanks @Forceu)
- Added validation checks for most `data/config.php` settings to prevent using invalid ones (thanks @Forceu)
- When using reverse proxy authentication (`ReverseProxyAuthMiddleware`), _additionally_ a valid API key can now also be used for authentication (if you don't want to protect the API endpoints via your reverse proxy, however)
- Added a new API endpoint `/system/time` to get the current server time (thanks @Forceu)
- An amount attached to a barcode is now also prefiled when scanning the product on the Consume/Transfer/Inventory page
- Fixed that some number inputs were broken when the new decimal places setting were set to `0`
- Fixed that browser camera barcode scanning did not work on the product edit page for adding product barcodes
- Fixed that indirect unit conversions (those between units, not product overrides) could not be used/selected
- Fixed that the new product option "Never show on stock overview" was unintentionally set by default for new products
- Fixed that adding items to the shopping list from the context/more menu on the stock overview page did not work
- Fixed that consuming was not possible when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was disabled
- Fixed that adding images in text editor fields did not work
- Fixed some other minor UI glitches

View File

@@ -0,0 +1,128 @@
> ⚠️ The following PHP extensions are now additionally required: `json`, `intl`, `zlib`
> ⚠️ PHP 8.0 (with SQLite 3.27.2+) is from now on the only supported runtime version.
### New Feature: Grocycode / label printer support
#### (Own) Product/stock entry/chores/batteries labels/barcodes
- Print own labels/barcodes for products/stock entries/chores/batteries and then scan that code on every place a product/stock entry/chore/battery can be selected
- Can be printed (or downloaded) via
- The product/chore/battery edit page
- The context/more menu per line on the overview pages and for stock entries on the stock entries page
- Automatically on purchase (new option on the purchase page, defaults can be configured per product) for stock entries
- The used barcode type can be configured via the `config.php` option `GROCYCODE_TYPE`:
- `1D` (default) will produce a `Code128` 1D barcode (supported by the integrated camera barcode scanner)
- `2D` will produce a `DataMatrix` 2D barcode (currently not supported by the integrated camera barcode scanner, but can be probably printed smaller)
- Label printer functionality can be enabled via the new feature flag `FEATURE_FLAG_LABEL_PRINTER` (defaults to disabled)
- Label printer communication happens via WebHooks - see the new `LABEL_PRINTER*` `config.php` options
- grocycodes can also be used without a label printer - you can view or download thm as pictures and print them manually
- More information:
- https://github.com/grocy/grocy/tree/v3.1.0/docs/grocycode.md
- https://github.com/grocy/grocy/tree/v3.1.0/docs/label-printing.md
- (Thanks a lot @mistressofjellyfish for the initial work on this)
### New Feature: Meal plan sections
- Split the meal plan into sections like Breakfast/Lunch/Dinner
- => New button "Configure sections" on the meal plan page to configure the sections (top right corner)
- => Each meal plan entry can be assigned to a section
### New Feature: Shopping list thermal printer support
- The shopping list can now be printed on a thermal printer
- The printer must be compatible to the `ESC/POS` protocol and needs to be locally attached or network reachable to/by the machine hosting Grocy (so the server)
- See the new `TPRINTER*` `config.php` options to configure the printer connection and other options
- => New button on the shopping list print dialog
- Can be enabled via the new feature flag `FEATURE_FLAG_THERMAL_PRINTER` (defaults to disabled)
- (Thanks a lot @Forceu)
### Stock improvements/fixes
- Product barcodes are now enforced to be unique across products
- On the stock overview page it's now also possible to search/filter by product barcodes (via the general search field)
- The product picker on the consume and transfer page now only shows products which are currently in stock
- Added a filter option to only show currently in stock products on the stock overview and products list (master data) page
- Added new columns on the stock overview page (hidden by default): Product description, product default location, parent product, product picture
- Added a new product option "Should not be frozen" (defaults to disabled and only visible when `FEATURE_FLAG_STOCK_PRODUCT_FREEZING` is enabled)
- When enabled, on moving the product to a freezer location (so when freezing it), a corresponding warning will be shown
- Optimized that when opening a product which has "Default due days after opened" set, the resulting date now never extends the original due date
- Added a new stock setting (top right corner settings menu) "Add decimal separator automatically for price inputs" (defaults to disabled)
- When enabled, you always have to enter the value including decimal places, the decimal separator will be automatically added based on the amount of allowed decimal places
- Fixed that editing stock entries was not possible
- Fixed that consuming with Scan Mode was not possible
- Fixed that the current stock total value (header of the stock overview page) didn't include decimal amounts (thanks @Ape)
- Fixed that the transfer page was not fully populated when opening it from the stock entries page
- Fixed that undoing a consume/open action from the success notification on the stock entries page was not possible
- Fixed that adding a barcode to a product didn't save the selected quantity unit when the product only has a single one
- Fixed that the store information on a stock entry was lost when transferring a partial amount to a different location
- Fixed that the "Spoil rate" on the product card was wrong in some cases
- Fixed that the stock journal showed always the products default location (instead of the location of the transaction)
- Fixed that the aggregated amount of parent products was wrong when indirect quantity unit conversions were used
### Shopping list improvements/fixes
- The amount now defaults to `1` for adding items quicker
- Added a status filter for only _done_ items
- The total value is now also shown (based on "Last price (Total)" per item, displayed on the page header and only when `FEATURE_FLAG_STOCK_PRICE_TRACKING` is enabled)
- Fixed that shopping list prints had a grey background (thanks @Forceu)
- Fixed the form validation on the shopping list item page (thanks @Forceu)
- Fixed that when adding products to the shopping list from the stock overview page, the used quantity unit was always the products default purchase QU (and not the selected one)
- Fixed that the displayed last unit/total price was wrong when the used quantity unit was not the products stock QU
- Fixed that the "Add as barcode to existing product" product picker workflow did not work
### Recipe improvements/fixes
- Recipe printing improvements (thanks @Ape)
- Calories are now always displayed per single serving (on the recipe and meal plan page)
- The note of an ingredient will now also be added to the corresponding shopping list item when using "Put missing products on the shopping list"
- It's now possible to copy a recipe (button/dropdown menu item per recipe)
- Fixed that the recipe page was slow when there were a lot meal plan recipe entries
- Fixed that "Only check if any amount is in stock" (recipe ingredient option) didn't work for stock amounts < 1
- Fixed that when adding missing items to the shopping list, on the popup deselected items got also added
- Fixed that the amount of self produced products with tare weight handling enabled was wrong ("Produces product" recipe option)
- Fixed that the ingredient amount calculation for included/nested recipes was (for most cases) wrong
- Fixed that the ingredient amount was wrong when using a to the product indirectly related quantity unit
- Fixed that the calories amount calculation was wrong when quantity unit conversions were involved
### Meal plan improvements/fixes
- Improved the meal plan page loading time (drastically when having a big history of meal plan entries)
- Meal plan entries can now be visually marked as "done" (new button per entry)
- This happens automatically on consuming a recipe/product from the meal plan page
- It's now possible to copy all entries of a day to another day (in the dropdown of the add button in the header of each day column)
- The "Display recipe" button was removed, instead clicking the recipe title now displays the recipe (and this now also works for products; shows the product card)
- Fixed that stock fulfillment checking used the desired servings of the recipe (those selected on the recipes page, not them from the meal plan entry)
### Chores improvements/fixes
- It's now possible to track any addtional info on a chore execution by using Userfields
- => Configure the desired Userfields for the entity `chores_log`
- => The on chore execution tracking entered information is then visible on the corresponding chore journal entry
- Fixed that tracking chores with "Done by" a different user was not possible
### Userfield improvements/fixes
- Userfields can now be configured as mandatory (new Userfield option, defaults to disabled)
- Fixed that numeric Userfields were initialised with `1.0`
- Fixed that shortcuts (up/down key) and the format did not work correctly when using multiple date/time Userfields per object
- Fixed that Userfields were not saved when adding a product or a recipe (only on editing)
### General & other improvements/fixes
- LDAP authentication improvements / OpenLDAP support (thanks @tank0226)
- A read only service account can now be used for binding
- The username attribute is now configurable
- Filtering of accounts is now possible
- => See the new `LDAP*` `config.php` options
- Improved the page loading time of all journal pages (stock/chores/batteries) by adding a new date range filter
- Some night mode style improvements (thanks @BlizzWave and @KTibow)
- Help tooltips are now additionally also triggered by clicking on them (instead of only hovering them, which doesn't work on mobile / touch devices)
- The camera barcode scanner now also supports Code 39 barcodes (used for example in Germany on pharma products (PZN)) (thanks @andreheuer)
- Fixed that the number picker up/down buttons did not work when the input field was empty or contained an invalid number
- Fixed that links and embeds (e.g. YouTube videos) did not work in the text editor
- Fixed that the "Manage users" and "Manage API keys" menu was not shown when using reverse proxy authentication
### API improvements/fixes
> ~~❗ Numbers are now returned as numbers (so technically without quotes around them, were strings for nearly all endpoints before - should practically be no real difference)~~
>
> => ❗❗❗ This has been reverted after this (v3.1.0) release since it had unintended side effects
- Added a new endpoint `/system/localization-strings` to get the localization strings (gettext JSON representation; in the by the user desired language)
- Added a new endpoint `/recipes/{recipeId}/copy` to copy a recipe
- The `GET /chores` endpoint now also returns the `next_execution_assigned_user` object per chore (like the endpoint `GET /chores/{choreId}` already did for a single chore)
- The `GET /tasks` endpoint now also returns the assigned user and category object per task
- Empty Userfields are now also returned (were previously omitted, endpoint `GET /objects/{entity}` and `GET /objects/{entity}/{objectId}`)
- Fixed that due soon products with `due_type` = "Expiration date" were missing in `due_products` of the `/stock/volatile` endpoint
- Fixed that `PUT/DELETE /objects/{entity}/{objectId}` produced an internal server error when the given object id was invalid (now returns `400 Bad Request`)
- Fixed that hyphens in filter values did not work
- Fixed that cyrillic letters were not allowed in filter values

View File

@@ -0,0 +1,16 @@
- Fixed that the upgrade failed when having "> 2 times duplicate" (means the same barcode was added more than 2 times) product barcodes
- Fixed that the upgrade failed when having unsupported parent/child product nesting levels
- More information on this: Only 1 level is currently supported; creating > 1 level nestings was _never_ possible via the UI/frontend, but not checked/enforced by the backend before `v3.0.0` - so it was potentially possible via the API (or any third party app/tool which utilizes it) to create such a nesting which then made this upgrade to fail
- Fixed that it was not possible to select a chore/battery on the corresponding tracking pages by mouse/touch
- Fixed that grouping by columns in tables may caused duplicate groups
- Fixed that Grocycode camera barcode scanning didn't recognize the scanned code for chore/battery tracking
- Fixed that when having any "Track date only" chore on the calendar, the iCal export was broken
- Optimized the meal plan page to be properly printable (thanks @MrKrisKrisu)
### API
> ❗ The release before (v3.1.0) introduced that "numbers are now returned as numbers": **This was reverted** since it had unintended side effects (so all fields are technically strings now again, just like before - sorry for that)
- Fixed that `missing_products` of the `/stock/volatile` endpoint also contained inactive products
- Fixed that when having multiple Userfields for an entity, the `/objects/{entity}` endpoint returned wrong Userfield values
- Fixed that the `/stock/products/by-barcode/{barcode}/consume` and `/stock/products/by-barcode/{barcode}/transfer` endpoints haven't used the stock entry given by a stock entry Grocycode (thanks @lowlee for the initial work on this)
- Fixed that the "Stock by-barcode" API routes were broken for normal barcodes (only grocycodes were accepted) (thanks @larsverp)
- Fixed that the "Stock by-barcode" API routes also accepted chore or battery grocycodes (thanks @lowlee)

View File

@@ -0,0 +1,12 @@
- Fixed that the "Add all list items to stock" shopping list workflow did not work for more than ~6 items (thanks @tjhowse)
- Fixed that plural form handling (e.g. for quantity units) was wrong for negative numbers
- Fixed that the context menu entries `Consume` and `Transfer` on the stock overview page were disabled when the amount in stock was < 1
- Fixed that on consuming a product from not the products default location, the products default location was recorded in the stock journal
- Fixed that when undoing a stock consume transaction from not the products default location, the corresponding amount was always added back to to the products defaullt location
- Fixed that when having multiple quantity unit conversions for a products default QU purchase, on purchase was potentially a wrong conversion factor picked
- Fixed that when there was any chore with a schedule, but without a "next estimated tracking" date/time, the iCal export was broken
- The product and chore edit pages now have bottom-sticky save buttons
- A product picture can now be added when creating a product (was currently only possible when editing a product)
### API
- Fixed that international characters and spaces were not allowed in API query filters

View File

@@ -0,0 +1,19 @@
- The "Below min. stock amount" filter on the stock overview page now also includes due-soon, overdue or already expired products
- The default shopping list (named "Shopping list"; localized) can now be renamed
- Added the products average price as a (hidden by default) column on the stock overview page
- Added a new "Presets for new products" stock setting for the "Default due days" option of new products
- When adding (purchase) a product with "Default due days after freezing" set directly to a freezer location, the due date is now prefilled by that (instead of the normal "Default due days") (thanks @grahamc for the initial work on this)
- Chores can now be merged (new item in the context-/more-menu on the chores list page)
- Fixed that "Label per unit" stock entry labels (on purchase) weren't unique per unit
- Fixed that the "Add as new product" product picker workflow, started from the shopping list item form, always selected the default shopping list after finishing the flow
- Fixed that when undoing a product opened transaction and when the product has "Default due days after opened" set, the original due date wasn't restored
- Fixed that "Track date only"-chores were shown as overdue on the due day on the chores overview page
- Fixed that dropdown filters for tables maybe did not work after reordering columns
- Fixed that auto night mode over midnight did not always work
- Fixed that the labels of context-/more-menu items were not readable in Night Mode (thanks @corbolais)
- Fixed that the "Stay logged in permanently" checkbox on the login page had no effect (thanks @0)
### API
- New endpoint `/chores/{choreIdToKeep}/merge/{choreIdToRemove}` for merging chores
- Endpoint `/stock/products/{productId}/add` API endpoint: The (optional) request body parameter `print_stock_label` was renamed to `stock_label_type`
- Fixed that backslashes were not allowed in API query filters

View File

@@ -0,0 +1,79 @@
### Stock
- The `config.php` option `FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT` was removed and is now a new product option `Treat opened as out of stock`, means, if opened stock entries will be counted as missing for calculating if a product is below its minimum stock amount, can now be configured per product
- The existing option will be migrated to all existing products, so no changed behavior after the update
- There is also a new stock setting (section "Presets for new products") which can be used to configure the default when adding products (also that will be set based on the old setting on migration)
- When using/scanning a stock entry Grocycode on the consume page, the amount is now prefilled by the stock entry amount (making it essentially possible to consume the corresponding stock entry in one go)
- Stock entry labels get now also printed on inventory (only when adding products, same option "Stock entry label" like on the purchase page)
- Fixed that stock entry labels on purchase were printed, even when "No label" was selected (was only a problem when running label printer WebHooks server side)
- Fixed that formatted (HTML) text for the (hidden by default) product description column on the stock overview page was not correctly displayed
- Fixed that numeric and date-time sorting of table columns on the stock entries page did not work correctly (thanks @MasterofJOKers)
- Fixed that the consume page/dialog wasn't properly initialized when opening it from the stock entries page
- Fixed that entries for not existing users were missing on the stock journal
### Recipes
- Optimized recipe costs calculation to better reflect the current real costs: Out of stock ingredients now use the last price
- Background: Before v3.0.0 recipe costs were only based on the last price per product and since v3.0.0 the "real costs" (based on the default consume rule "Opened first, then first due first, then first in first out") are used, means out of stock items have no price - so using the last price for out of stock items should reflect the current real costs better
- Added a new recipes setting (top right corner settings menu) "Show the recipe list and the recipe side by side" (defaults to enabled, so no changed behaviour when not configured)
- When disabled, on the recipes page, the recipe list is displayed full-width and the recipe will be shown in a popup instead of on the right side
- Recipes are now also Grocycode enabled (works like any other Grocycode; download/print it via the recipes edit page or the more/context menu on the recipes page; use/scan it at any place a recipe can be selected)
- Performance improvements (page loading time) of the recipes page
- Fixed that when adding missing recipe ingredients, with the option "Only check if any amount is in stock" enabled, to the shopping list, unit conversions (if any) weren't considered
- Fixed that the recipe stock fulfillment information about shopping list amounts was not correct when the ingredient had a decimal amount
### Meal plan
- Meal plan sections can now (optionally) define a time, which will then be displayed on the meal plan section header and used for the corresponding calendar events
- Additionally the correspnding calendar event now also mentions the meal plan section name
- The day/week view can now be toggled
- New button on top right corner of the meal plan (only visible on bigger screens)
- On smaller screen the day view is still the default (no change)
- Fixed that the meal plan showed the total calories per recipe (instead of per serving as stated by the suffix)
### Chores
- Chore schedules can now be skipped
- New button on the chores overview and chore tracking page
- Skipped schedules will be highlighted accordingly on the chore journal
- Added a new chore option "Start date" which is used as a schedule starting point when the chore was never tracked
- Until now, the schedule starting point was the first tracked execution
- For all existing chores, the start date will be set to the first tracked execution time (or today, for chores which were never tracked) on migration
- The `Yearly` period type has been changed to be schedule the chore on the _same day_ each year
- This period type scheduled chores 1 year _after the last execution_ before, which is also possible by using the `Daily` period type and a period interval of 365 days; all existing `Yearly` schedules will be converted to that on migration
- Added a new `Hourly` period type (to schedule chores every `x` hours)
- Added a new `Adaptive` period type (to schedule chores dynamically based on the past average execution frequency)
- Removed the period type `Dynamic regular`, since it's the same as `Daily`
- All existing `Dynamic regular` schedules will be converted to that on migration
- The chorecard now also shows the average execution frequency (how often the chore was executed in the past on average)
### Calendar
- Fixed that when having a task without a due date, the iCal export was broken
### Tasks
- Added a "Save & add another task"-button on the add task dialog to quickly create multiple tasks without having to close/reopen the dialog
- Fixed that when editing a task without a due date, `1970-01-01` was shown
### General
- Added a separate status filter and table row highlighting (blue) on the chores, tasks and batteries overview pages for items due today
- Additionally, the "due soon" days of chores/tasks/batteries (top right corner settings menu) can be set to `0` to disable that filter/highlighting
- Optimized relative time display (also fixed a phrasing problem for some languages, e.g. Hungarian) (thanks @Tallyrald)
- New input shorthand `[+/-]n[d/m/y]` for date fields to quickly input a date relative to today (adding (**+**) or subtracting (**-**) the **n**umber of **d**ays/**m**onths/**y**ears, see the full list of available shorthands [here](https://github.com/grocy/grocy#input-shorthands-for-date-fields))
- When using LDAP authentication, the configured `LDAP_UID_ATTR` is now used to compare if the user already exists instead of the username entered on the login page (that prevents creating multiple users if you enter the username in different notations) (thanks @FloSet)
- When using reverse proxy authentication (`ReverseProxyAuthMiddleware`), it's now also possible to pass the username in an environment variable instead of an HTTP header (new `config.php` option `REVERSE_PROXY_AUTH_USE_ENV`) (thanks @Forceu)
- The `config.php` option `DISABLE_BROWSER_BARCODE_CAMERA_SCANNING` has been renamed to `FEATURE_FLAG_DISABLE_BROWSER_BARCODE_CAMERA_SCANNING`
- Fixed that when having a quantity unit matching any application string, the translation of that string was used to display that unit
- Fixed that the logout button/menu was missing when using external authentication (e.g. LDAP)
- New translations: (thanks all the translators)
- Catalan (demo available at https://ca.demo.grocy.info)
### API
- The API endpoint `/stock/shoppinglist/clear` has now a new optional request body parameter `done_only` (to only remove done items from the given shopping list, defaults to `false`)
- The API endpoint `/chores/{choreId}/execute` has now a new optional request body parameter `skipped` (to skip the next chore schedule, defaults to `false`)
- The API endpoint `/chores/{choreId}` has new response field/property `average_execution_frequency_hours` (contains the average past execution frequency in hours or `null`, when the chore was never executed before)
- New API endpoint `/recipes/{recipeId}/printlabel` (to print recipe grocycodes on the configured label printer)
- Fixed that the barcode lookup for the "Stock by-barcode" API endpoints was case sensitive

View File

@@ -0,0 +1,121 @@
### New Feature: Notes and Userfields for stock entries
- Stock entries can now have notes
- For example to distinguish between same, yet different products (e.g. having only a generic product "Chocolate" and note in that field what special one it is exactly this time - as an alternative to have sub products)
- Or for example to track ownership of stock items when sharing the fridge with your flatmates
- => New field on the purchase and inventory (and stock entry edit) page
- => New column on the stock entries and stock journal page
- => Visible also in the "Use a specific stock item" dropdown on the consume and transfer page
- Additionally it's also possible to add arbitrary own fields by using Userfields
- => Configure the desired Userfields for the entity `stock`
- => Those Userfields are then visible on the same places as mentioned above for the built-in "Note" field
### New Feature: Recipes "Due score"
- A number (new column on the recipes page) which represents a score which is higher the more ingredients, of the corresponding recipe, currently in stock are due soon, overdue or already expired
- Or in other words: A score to see which recipes to cook to not waste already overdue/expired or due soon products
- The score is in detail based on:
- 1 point for each due soon ingredient (based on the stock setting "Due soon days")
- 10 points per overdue ingredient
- 20 points per expired ingredient
- (or else 0)
- The corresponding ingredient is also highlighted in red/yellow/grey (same colors as on the stock overview page)
### Stock
- It's now possible to change a products stock QU, even after it was once added to stock
- When the product was once added to stock, there needs to exist a corresponding unit conversion for the new QU
- Product card, stock overiew and stock entries page optimizations regarding displaying prices:
- Prices are now shown per default purchase quantity unit, instead of per stock QU and when clicking/hovering, a tooltip shows the price per stock QU
- The price history chart is now based on the value per purchase QU, instead of per stock QU
- New product option "Default consume location" (not mandatory, defaults to not set / empty)
- When set, stock entries at that location will be consumed first
- => This will be automatically taken into account when consuming from the stock overview page and all other places where no specific location can be selected
- => On the consume page the location is preselected in the following order:
1. The new default consume location, if the product currently has any stock there, otherwise
2. The products default location, if the product currently has any stock there, otherwise
3. The first location where the product currently has any stock
- Optimized quantity unit conversion handling:
- The option "Create inverse QU conversion" was removed when creating a QU conversion
- => Instead the corresponding inverse conversion is now always created/updated/deleted automatically
- New product option "Disable own stock" (defaults to disabled)
- When enabled, the corresponding product can't have own stock, means it will not be selectable on purchase (useful for parent products which are just used as a summary/total view of the sub products)
- The location content sheet can now optionally list also out of stock products (at the products default location, new checkbox "Show only in stock products" at the top of the page, defaults to enabled)
- Added a location filter to the stock entries page
- Added the product Grocycode as a (hidden by default) column to the products list (master data)
- The price entered on the inventory page is now related to the selected quantity unit (like on the purchase page, was always related to the products stock QU before)
- Fixed that consuming via the consume page was not possible when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was disabled
### Shopping list
- Added a new shopping list setting (top right corner settings menu) to automatically add products, that are below their defined min. stock amount, to the shopping list (defaults to disabled)
- Fixed that when using "Add products that are below defined min. stock amount", the calculated missing amount was wrong for products which had the new product option `Treat opened as out of stock` set and when having at least one opened stock entry
### Recipes
- When a parent product is used as an ingredient, which is currently not in stock itself, the substituted product (so the one which was already taken into account when consuming the recipe) is now displayed below the ingredient and the costs (and calories) are taken from that one, to reflect the current real costs even better
- Added a new recipes setting (top right corner settings menu) "Show a little checkbox next to each ingredient to mark it as done" (defaults to disabled)
- When enabled, next to each ingredient a little checkbox will be shown
- When clicked, the ingredient is crossed out
- This status is not saved, means reset when the page is reloaded
- Fixed that consuming recipes was possible when not all ingredients were in stock (and this potentially consumed some of the in stock ingredients; not matching the message "nothing removed")
- Fixed that the price of the "Produces product"-product, which is added to stock on consuming a recipe, was wrong (was the recipe total costs multiplied by the serving amount instead of only the recipe total costs)
- Fixed that calories of recipe ingredients were displayed with an indefinite number of decimal places
- Fixed that ingredient amounts were wrong for multi-nested (> 2 levels) recipes, when the included recipe used an serving amount other than 1
- Fixed that searching/filtering the recipe gallery view did not work correctly
- Fixed that searching/filtering recipes by products did not work (e.g. via the context-/more menu option "Search for recipes containing this product" on the stock overview page)
### Meal plan
- The day is now editable on the edit dialog of any meal plan entry, which makes it possible to move entries to a different day
- Fixed that it was not possible to print the meal plan (and other pages) in landscape (thanks @miguelangel-nubla)
### Chores
- The `Daily` period type has been changed to schedule the chore at the _same time_ (based on the start date) each `n` days
- This period type scheduled chores `n` days _after the last execution_ before, which is also possible by using the `Hourly` period type and a corresponding period interval; all existing `Daily` schedules will be converted to that on migration
- It's now possible to manually reschedule / assign chores
- New entry "Reschedule next execution" in the context/more menu on the chores overview page
- If you have rescheduled a chore and want to continue the normal schedule/assignment instead, use the "Clear" button in the same dialog
- Rescheduled/reassigned chores will be highlighted with an corresponding icon next to the "Next estimated tracking date" / "Assigned to"
- Optimized that when skipping chores via the chore tracking page, the given time is used as the "skipped time", not the scheduled next estimated tracking time of the corresponding chore (making it essentially possible to skip more then one schedule at once)
- Fixed that when consuming a parent product on chore execution (chore option "Consume product on chore execution"), no child products were used if the parent product itself is not in stock
- Fixed that the upgrade to v3.2.0 failed when having any former "Dynamic Regular" chore with a "Period interval" of `0` (which makes absolutely no sense in reality)
### Tasks
- Fixed that tasks without a due date were highlighted in red (like overdue tasks)
### Batteries
- Fixed that the batteries overview page was broken when there was any battery Userfield with enabled "Show as column in tables" option
- Fixed that Grocycode label printer printing didn't work from the battery edit page (master data) (thanks @andreheuer)
- Fixed that undoing a battery charge cycle had no effect on "Last charged" and "Next planned charge cycle" of the corresponding battery
### Equipment
- It's now possible to add multiple files (PDFs / manuals) to each equipment
- Define as many Userfields for the entity `equipment` and use the type `File`
- => Each of those File-Userfields will be shown as a separate tab on the equipment page
### Userfields
- Userfields of type "Date & time" and "Date (without time)" have now the option to default to now / today for new objects (new Userfield option "Default value")
### General
- Optimized form validation: Save / submit buttons are now not disabled when the form is invalid, the invalid / missing fields are instead highlighted when trying to submit / save the form (making it more obvious which fields are invalid / missing exactly)
- Night mode can now use / follow the system preferred color scheme
- The view/user setting "Enable night mode" has been removed and replaced by "Night mode" which now defaults to "Use system setting" (which uses the system preferred color scheme, "On" and "Off" are other possible options to always enable/disable night mode)
- Some night mode style refinements
- Fixed an server error (on every page) when not having any quantity unit
- New translations: (thanks all the translators)
- Slovenian (demo available at <https://sl.demo.grocy.info>)
### API
- Added a new endpoint `GET /stock/locations/{locationId}/entries` to get all stock entries of a given location (similar to the already existing endpoint `GET /stock/products/{productId}/entries`)
- Endpoint `/recipes/{recipeId}/consume`: Fixed that consuming partially fulfilled recipes was possible, although an error was already returned in that case (and potentially some of the in stock ingredients were consumed in fact)
- Endpoint `/stock/products/{productId}`:
- New field/property `current_price` which returns the current price of the corresponding product, based on the stock entry to use next (defined by the default consume rule "Opened first, then first due first, then first in first out") or on the last price if the product is currently not in stock
- The field/property `oldest_price` is deprecated and will be removed in a future version (this had no real sense, currently returns the same as `current_price`)

View File

@@ -0,0 +1,33 @@
### Stock
- New product option "Move on open" (defaults to disabled)
- When enabled, on marking the product as opened, the corresponding amount will be moved to the products default consume location
- (Thanks @RosemaryOrchard)
- The stock setting "Decimal places allowed for prices" has been split into separate settings for input and displaying prices (the existing setting will be set for both new options on migration, so no changed behavior when not configured)
- Optimized that when the plural form(s) of a quantity unit is/are not provided, the singular form is used to display plural amounts
- Fixed that "Automatically add products that are below their defined min. stock amount to the shopping list" (stock setting) was only done when consuming products, not when opening them
- Fixed that the price history chart (product card) showed the price on a wrong date when having multiple purchases on the same date from different stores
### Recipes
- Fixed that when a substituted product is used to display costs and calories (so when a parent product ingredient is currently not in stock itself), no unit conversions were considered for costs/calories calculation
- Fixed that the displayed "already on the shopping list"-amount (for missing ingredients) was wrong when the products "Factor purchase to stock quantity unit" wasn't 1
### Chores
- Fixed that rescheduling of "Track date only"-chores for today was not possible
### Calendar
- Fixed that clicking on meal plan product and notes calendar entries redirected to an invalid page
### General
- LDAP authentication: Optimized that it's not required that LDAP accounts need to have a first-/lastname
### API
- Endpoint `/stock/products/{productId}`: New field/property `default_consume_location` (contains the products default consume location object)
- Endpoint `/stock/products/{productId}/add`: Fixed that the request body parameter `transaction_type` was ignored / always set to `purchase`
- Fixed that the endpoint `/stock/products/by-barcode/{barcode}/open` didn't handle stock entries provided by a Grocycode (thanks @jtommi)
- Fixed that less or equal (`<=`) and greater or equal (`>=`) filter comparisons didn't work (optional `query[]` request query parameter on most endpoints)

View File

@@ -0,0 +1,42 @@
### Stock
- Improved that when editing a unit conversion, the "Quantity unit from" and "Quantity unit to" of the corresponding inverse conversion is now also updated accordingly if changed (until now only the factor was updated automatically)
- Changed that the "Move on open" product option can now always be used/set, even when the "Default location" and "Default consume location" are the same
- Fixed that stock entry notes were lost when consuming/opening/transferring a partial amount of the corresponding stock entry (thanks @akoshpinter)
- Fixed that the average shelf life of a product (on the product card) was wrong when the corresponding stock entry was edited
- Fixed that when the stock setting "Decimal places allowed for amounts" was set to `0`, unit conversion (if any) failed when adding the corresponding product to stock
- Fixed that consuming a parent product which is not in stock itself (so essentially using any of the child products) may failed when unit conversions were involved (the current stock amount check was wrong in that case)
- Fixed that the status button counters on the stock overview page ("X products are overdue" and so on) included products which have the option `Never show on stock overview` enabled
- Fixed that adding Userfields to existing stock entries was not possible (only editing existing Userfield values, e.g. added during purchase or inventory, was possible)
- Fixed that it was not possible to change a products stock QU, when the needed unit conversion (old QU => new QU) was only defined globally (means on QU level) or by the products "Factor purchase to stock quantity unit"
- Fixed that when changing a products stock QU, the products "Quick consume mount", "Energy (kcal)" and "Tare weight" wasn't updated according to the corresponding unit conversion factor
- Fixed that when changing a products stock QU, the product barcode amounts were also changed based on the corresponding unit conversion factor
### Shopping list
- Fixed that products could not be added to the shopping list via barcode scanning
### Recipes
- Fixed that headlines in the recipe description (preparation text) were removed on saving
- Fixed that the default consume rule was not always applied correctly when a recipe consumed a substituted ingredient (so when having a parent product in the recipe which is currently not in stock itself)
### Userfields
- Fixed that edit forms were broken when editing an object with `null` Userfields (so when the field for that object was not set before / on the initial object creation)
### General
- It's now possible to edit a user without necessarily updating the users password
- Fixed that column reordering didn't work on the stock overview, stock entries and shopping list page when showing columns which are not shown by default
- Fixed that when running label printer WebHooks client side (so when `LABEL_PRINTER_RUN_SERVER` = `false`), the setting `LABEL_PRINTER_HOOK_JSON` was ignored (the WebHook data was always sent as form data)
- Fixed that granular user permissions (like "Shopping list / Add items" or "Equipment") didn't allow to add/edit the corresponding items without also having the "Edit master data" permission
- New translations: (thanks all the translators)
- Lithuanian (demo available at <https://lt.demo.grocy.info>)
- Ukrainian (demo available at <https://uk.demo.grocy.info>)
### API
- Endpoint `/stock/volatile`
- The field/property `missing_products` now also contains the `product` object
- Endpoint `/recipes/{recipeId}/consume`: Fixed (again) that consuming partially fulfilled recipes was possible, although an error was already returned in that case (and potentially some of the in stock ingredients were consumed in fact)

View File

@@ -0,0 +1,118 @@
> ⚠️ PHP 8.1 (with SQLite 3.34.0+) is from now on the only supported runtime version.
> ❗ The major version bump is due to breaking API changes, please see below if you use the API.
> _Recommendation: Benchmark tests showed that e.g. unit conversion handling is up to 5 times faster when using a more recent (3.39.4+) SQLite version._
### New Feature: Indirect quantity unit conversions with unlimited levels
- Quantity unit conversions now support indirect conversions with unlimited levels (thanks a lot @esclear)
- _Explained by a practical example: When a conversion between Teaspoons and Milliliters and another one between Milliliters and Liters exists (and so forth; unlimited levels), Grocy can now calculate Teaspoons to Liters (before a direct conversion definition between Teaspoons and Liters was required)_
- **Heads up:** If you have such "each to each absolute conversion definitions" currently (for the example above the conversion between Teaspoons and Liters), you should clean them up, since they are no longer needed
- The product option "Factor purchase to stock quantity unit" was removed
- => Use normal product specific QU conversions instead, if needed
- An existing "Factor purchase to stock quantity unit" was automatically migrated to a product specific QU conversion
### New Feature: Stock reports
- New button "Reports" on the stock overview page
- The first report (more to come) "Spendings" makes it possible to explore (pie chart and table data) the total value spend by product or product group in any time range
- (Thanks for the initial work on this @raupie)
### Stock
- New product option "Default quantity unit consume"
- Will be used/selected as the default quantity unit on the consume page
- The product's "Quick consume amount" is now displayed related to this quantity unit ("quick consume/open buttons" on the stock overview page)
- Defaults to the product's "Quantity unit stock" (so no changed behavior when not configured)
- New product option "Quantity unit for prices"
- Prices are now shown related to this quantity unit (instead of per "Default quantity unit purchase") on the product card, price history chart, stock overiew and stock entries page
- Defaults to the product's "Default quantity unit purchase" (so no changed behavior when not configured)
- Changed that when the ingredient option "Only check if any amount is in stock" is enabled, costs and calories are now based on the original entered amount instead of an "virtual" fixed amount of `1`
- When using the "Add as barcode to existing product" workflow on a purchase transaction, the selected quantity unit and the entered amount and note are now also added to the new barcode
- New product option "Auto reprint stock entry label"
- When enabled, auto-changing the due date of a stock entry (by opening/freezing/thawing and having corresponding default due days set) will reprint its label (only server side label printer WebHooks are supported)
- Defaults to disabled, so no changed behavior when not configured
- Added a new option "Reprint stock entry label" on the stock entry edit page (will print the correspondind stock entry label on save)
- This option will be automatically set on changing the entry's due date
- The product option "Quick consume amount" (the amount used for the "quick consume/open buttons" on the stock overview page) has been split into another option "Quick open amount", to be able to set different amounts for consume and open (defaults to the "Quick consume amount" per product, so no changed behavior when not configured)
- Changed that for the product's average and last price (and for the price history chart) stock transactions with an empty or `0` price are ignored
- Added a filter option to only show currently out of stock products on the products list (master data) page
- When clicking a product name on the products list (master data) or on the stock journal page, the product card will now be displayed (like on the stock overview page)
- When using/scanning a product barcode and the purchase or inventory page, the barcode's note will now also be prefilled (if any)
- Each row on the stock journal now also has a context-/more menu for quick access to product related actions (the same as on the stock overview page)
- The amount of "Label per unit" stock entry labels (on purchase and inventory) is now displayed, to help prevent printing a lot of labels where this maybe is not intended
- Fixed that hiding the "Purchased date" column (table options) on the stock entries page didn't work
- Fixed that sorting by the "Value" and "Min. stock amount" columns on the stock overview page didn't work
- Fixed that the consumed amount was wrong, when consuming multiple substituted subproducts at once and when multiple/different conversion factors were involved
- Fixed that for a product's average price, only currently in stock items were considered, not already consumed ones
- Fixed that when copying a product, some fields (like "Default consume location" or "Disable own stock) weren't copied along
- Fixed that the total product count on the stock overview page also included products with "Never show on stock overview" enabled
### Shopping list
- Added a new button "Clear done items" (to clear all done items with one click)
### Recipes
- Added a new entry "Add to meal plan" in the context/more menu per recipe to directly add a recipe to the meal plan from the recipes page
- Changed that when a ingredient has a "Variable amount" set, the text entered there now also replaces the unit when displaying the recipe (not only the amount as before)
- When displaying a recipe in fullscreen mode, the ingredients and preparation is now shown side by side (or below each other on small screens) instead of in tabs
- When consuming a recipe which has a "Produces product" set and when the product's "Default stock entry label" is configured accordingly, the corresponding label will now be printed on that action (only server side label printer WebHooks are supported)
- Fixed that hiding the "Requirements fulfilled" column (table options) on the recipes page didn't work
- Fixed that ingredient costs and calories were wrong when product substitution and unit conversions were involved at the same time
### Meal plan
- Added a new sub feature flag `FEATURE_FLAG_RECIPES_MEALPLAN` (in `config.php`) to only disable the meal plan if not needed (thanks @webysther)
- The `config.php` setting `MEAL_PLAN_FIRST_DAY_OF_WEEK` can now be set to `-1` to dynamically start the meal plan week on _today_
- Fixed that consuming a recipe from the meal plan didn't add its "Produces product"-product to stock (if any)
- Fixed that the "Put missing products on shopping list"-button in the header (to put all missing products on the shopping list for a whole week) was missing under certain circumstances (related to locale week numbers and turn of the year)
### Chores
- Changed the handling of the tracking buttons on the chores overview page
- The green button now tracks an execution of the corresponding chore on the next scheduled time, rather than for now/today
- New context-/more menu option "Track chore execution now" to track an execution for now/today (so the same what the green button did before)
- Removed the limitation on the chore tracking page that the tracked time couldn't be in the future
- Fixed that "assidgned to" was not recalculated when undoing chores
### Calendar
- Added a button to jump to today (between the prev/next buttons, top right corner)
### Tasks
- Fixed that hiding the "Category" column (table options) on the tasks page didn't work
### Userfields
- Product group Userfields are now also rendered on the shopping list
- Fixed that when having e.g. a Userfield for the `stock` entity and using the "Never overdue" shortcut checkbox for the due date on purchase, this Userfield would also be set to the corresponding "never overdue date"
### General
- Like already possible for products/chores/batteries, locations, stores, quantity units, product groups and task categories can now be disabled to keep them for existing references without deleting them, but to hide them everywhere for selections and so on (new option "Active")
- Added a new `config.php` setting `ENERGY_UNIT` to customize the label to display energy values (was fixed `kcal` before and defaults to that, so no changed behavior when not configured)
- New logo and "Grocy" is now officially spelled with a capital initial letter (before everything was lowercase)
- Various frontend performance enhancements
- Fixed that users were unable to delete their own API keys (when not having the `All permissions` permission)
- Fixed that button tooltips on some places didn't disappear after clicking the corresponding button
- New translations: (thanks all the translators)
- Estonian (demo available at <https://et.demo.grocy.info>)
- Romanian (demo available at <https://ro.demo.grocy.info>)
### API
- ⚠️ **Breaking changes**:
- The product property `qu_factor_purchase_to_stock` was removed (existing factors were migrated to normal product specific QU conversions, see above)
- Numbers are now returned as numbers (so technically without quotes around them, were strings for nearly all endpoints before)
- Endpoint `/stock/products/{productId}`:
- Added a new field/property `qu_conversion_factor_purchase_to_stock` for convenience (contains the conversion factor of the corresponding QU conversion from the product's `qu_id_purchase` to `qu_id_stock`)
- Added a new field/property `qu_conversion_factor_price_to_stock` for convenience (contains the conversion factor of the corresponding QU conversion from the product's `qu_id_price` to `qu_id_stock`)
- Added a new field/property `default_quantity_unit_consume` (contains the quantity unit object of the product's "Default quantity unit consume")
- The following entities are now also available via the endpoint `/objects/{entity}` (only listing, no edit)
- `quantity_unit_conversions_resolved` (returns all final/resolved conversion factors per product and any directly or indirectly related quantity units)
- `recipes_pos_resolved` (returns stock fulfilment information for all recipe ingredients)
- The endpoint `/batteries` now also returns the corresponding battery object (as field/property `battery`)
- API keys can now have a description (to e.g. track where the corresponding key is used)

View File

@@ -0,0 +1,19 @@
> 💡 PHP 8.2 is from now on (additionally to PHP 8.1) supported.
### Stock
- Fixed performance issues affecting all places where quantity unit conversions / prices are involved
- Fixed that the upgrade failed when having improperly defined product specific quantity unit conversions
- Fixed that edited stock entries were not considered in some cases (affecting the product's last price, average price, the price history and the stock reports)
### Shopping list
- Changed that unit prices on the shopping list (table column "Last price (Unit)") are now related to the there selected quantity unit (instead of to the product's QU stock as before)
### Meal plan
- Fixed that the meal plan did initially not display the current week when the settings `MEAL_PLAN_FIRST_DAY_OF_WEEK` and `CALENDAR_FIRST_DAY_OF_WEEK` were set to different values
### API
- Fixed performance issues on the endpoint `/stock/products/{productId}`

View File

@@ -0,0 +1,13 @@
### Stock
- The stock report "Spendings" now also supports grouping by stores
- Fixed that the upgrade failed when having (a lot of) redundant ("each to each") default quantity unit conversion definitions (thanks a lot @alkuzman and @esclear)
- More on that by a practical example: When a conversion between Teaspoons and Milliliters and another one between Milliliters and Liters exists (and so forth; unlimited levels), Grocy can now (since v4.0.0) calculate the derived factor to convert Teaspoons to Liters on its own (before a direct conversion definition between Teaspoons and Liters was required)
- So you might have a lot of such "each to each absolute conversion definitions" currently, when you were affected by failed upgrades (timeout problems due to that resolving indirect conversion factors took very long)
- **Heads up:** This is now fixed, but you should clean up those redundant "each to each" definitions (in the example above the conversion between Teaspoons and Liters), since they are no longer needed
- Fixed that the "Mark this stock entry as open"-button on the stock entries page opened always one unit instead of the whole stock entry
- Fixed that edited stock entries were not considered in some cases (affecting the product's average price and the stock reports)
### Recipes
- Fixed that ingredient cost/energy values were wrong when unit conversions but _no_ product substitutions were involved

View File

@@ -0,0 +1,12 @@
### Stock
- Performance improvements related to the stock overview page / displaying a product card
- Performance improvements related to consuming products (thanks @alkuzman)
### Userfields
- New Userfield type "Number (currency)", just like the type "Number (decimal)", but it will render the value according to / with the configured currency
### General
- Performance improvements related to table (layout) loading handling

View File

@@ -0,0 +1,43 @@
> 💡 PHP 8.3 is from now on (additionally to PHP 8.2) supported.
>
> ⚠️ PHP 8.1 is no longer supported.
### Stock
- Fixed that the location dropdown on the consume page contained the same location multiple times if there are currently stock entries at multiple locations of the corresponding product
- Fixed that the status filter "_n_ products are overdue" on the stock overview page also counted/included stock entries due today or tomorrow
- Fixed that the stock report "Spendings" did not take products without an assigned product group into account (thanks @Torqu3Wr3nch for the initial work on this)
- Fixed that the success message after opening a stock entry on the stock entries page displayed always an amount of `1` instead of the actual amount opened
- Fixed that the "Consume this stock entry as spoiled" context menu action on the stock entries page consumed always an amount of `1` instead of the whole stock entry
### Recipes
- Fixed that copying recipes with special characters in the name was not possible
### Meal plan
- Fixed that the meal plan page was broken after deleting all meal plan items of a week
### Calendar
- The different event types (due products, chores, tasks and so on) can now have different colors
- => New button "Configure colors" on the calendar page to configure these colors (top right corner)
### Tasks
- Added a new table filter for categories (thanks @geoffwright240 for the initial work on this)
### Userfields
- Fixed that when having a userfield of type "Select list (multiple items can be selected)" and selecting no item, editing of the corresponding form was broken
### General
- Night mode is now also used on the login page if that's the system preferred color scheme (generally if night mode is on or not is based on user settings and before logging in no user context is available)
- Optimized sidebar icon spacing (thanks @chris-thorn)
- Fixed that file uploads (product pictures and so on) didn't work for files where the file name contains multiple spaces
- Fixed that some dialogs were not properly (too small) displayed (mostly affecting Firefox >= 121)
### API
- Optimized that the endpoints `GET /objects/{entity}` and `GET /objects/{entity}/{objectId}` now also return Userfields for the entity `stock`

View File

@@ -0,0 +1,26 @@
### Stock
- When using/scanning a stock entry Grocycode on the transfer page, the "Use specific stock item" dropdown (and "From location") is now also prefilled accordingly
- Fixed that for the product's last price stock transactions with an empty or `0` price weren't ignored
- Fixed that when copying a product, the field "Move on open" wasn't copied along
### Shopping list
- The shopping lists dropdown on the shopping list page now also shows the number of items on the corresponding shopping list
### Recipes
- Optimized that when creating a recipe, the desired serving amount is now initially prefilled by the recipe's base serving amount
### Batteries
- It's now possible to track any addtional info on a battery charge cycle by using Userfields (thanks @TheDodger)
- => Configure the desired Userfields for the entity `battery_charge_cycles`
- => The on a battery charge cycle tracking entered information is then visible on the corresponding battery charge cycle journal entry
### General
- Optimized that file uploads are no longer completely buffered in memory before writing them to disk (thanks @bbx0)
- Optimized top right corner menus icon spacing (thanks @TheDodger for the initial work on this)
- Fixed again that some dialogs were not properly (too small) displayed (this time mostly affecting Chrome/Edge)
- Fixed that table states (visible columns, sorting, column order and so on) could be reset to default after not accessing/using the corresponding page for a certain amount of time

View File

@@ -0,0 +1,28 @@
### Stock
- Optimized form validation (max amount checks) related to unit conversion with a lot of decimal places on the consume and transfer page
- Optimized that the stock report "Spendings" now excludes self produced products (thanks @danielr18 for the initial work on this)
- Fixed that when copying a product, the field "Treat opened as out of stock" wasn't copied along (thanks @TheDodger)
- Fixed that the product groups filter on the master data products page used a contains search instead of an exact search
- Fixed that Scan Mode on the purchase and consume page didn't work (not all fields were properly populated) when using/scanning a product Grocycode
### Shopping list
- Fixed that when printing a shoppping list, the table/list wasn't sorted (will now be sorted alphabetically by the product name of the corresponding list item)
- Fixed that when deleting a shopping list item and marking another one as done while not reloading the page in-between, the deleted item reappeared (was only a visual problem, there was no problem on deleting the item on the backend / in the database)
### Recipes
- When self producing a product ("Produces product" recipe option) the name of the recipe is now added to the note field of the created stock entry
- Fixed that when `FEATURE_FLAG_STOCK_STOCK` was set to `false`, the "Put missing products on shopping list"-button was not visible
- Fixed that scanning a product barcode on the recipe ingredient edit page didn't work
- Fixed that the recipe edit button on the recipes page gallery view didn't work
### Userfields
- Userentity tables (custom objects / lists) now also have the table options icon (top left corner eye icon, to e.g. add a grouping condition)
- Userfield names can now also contain underscores
### API
- Optimized that uploading files where the file name contains non-ASCII characters is now also possible

View File

@@ -0,0 +1,86 @@
### New Feature: External Barcode Lookups as a product picker workflow + a built-in Plugin for Open Food Facts
- Added a new product picker workflow "External barcode lookup"
- This executes the configured barcode lookup plugin with the given barcode
- If the lookup was successful, the product edit page of the created product is displayed where the product setup can be completed (if required)
- After that, the transaction is continued with that product as usual
- A plugin for [Open Food Facts](https://world.openfoodfacts.org/) is now included and used by default (see the `config.php` option `STOCK_BARCODE_LOOKUP_PLUGIN` and maybe change it as needed)
- The product name and image (and of course the barcode itself) are taken over from Open Food Facts to the product being looked up
- => Quick video demo (using a Barcode Laser Scanner): https://www.youtube.com/watch?v=-moXPA-VvGc
- => Quick video demo (using Browser Camera Barcode Scanning): https://www.youtube.com/watch?v=veezFX4X1JU
### Stock
- Added a new stock setting (top right corner settings menu) "Show all out of stock products" to optionally also show all out of stock products on the stock overview page (defaults to disabled, so no changed behavior when not configured)
- By default the stock overview page lists all products which are currently in stock or below their min. stock amount
- When this new setting is enabled, all (active) products are always shown
- Added a new product option "Can't be opened"
- When enabled the product open functionality for that product is disabled
- Defaults to disabled, so no changed behavior when not configured
- Added a new product option "Default purchase price type"
- Can be used to set the default price type (Unit price / Total price) on the purchase page per product
- Previously "Unit price" was the default on purchase and the selection was not saved and not reset when selecting another product, means the price type selection was retained when doing multiple purchase transactions in one go
- The default for the new product option is "Unspecified" which keeps the previous behavior
- When products are automatically added to the shopping list (e.g. by the "below defined min. stock amount"-functionality or when adding missing recipe ingredients) the product's "Default quantity unit purchase" is now used (instead of the product's "Quantity unit stock")
- Product barcode matching is now case-insensitive
- Added a new column "Product picture" on the products list (master data) page (hidden by default)
- Optimized that when navigation between the different "Group by"-variants on the stock report "Spendings", the selected date range now remains persistent
- Added a new "Presets for new products" stock setting for the "Default stock entry label" option of new products
- Added a trendline to the price history chart (product card)
- Added a "Add to shopping list"-button on the product card
- Optimized that when moving a product to a freezer location (so when freezing it) the due date will no longer be replaced when the product option "Default due days after freezing" is set to `0`
- The "Decimal places allowed" stock settings now have an upper limit of 10 (since such a high number makes not so much sense in reality and causes form validation problems)
- Fixed that a once set quantity unit on a product barcode could not be removed on edit
- Fixed that when consuming a specific stock entry which is opened, and which originated from a before partly opened stock entry, the unopened one was wrongly consumed instead
### Shopping list
- Added a new shopping list setting (top right corner settings menu) "Round up quantity amounts to the nearest whole number"
- When enabled, all quantity amounts on the shopping list are always displayed rounded up to the nearest whole number
- Defaults to disabled, so no changed behavior when not configured
### Recipes
- Consuming a recipe is now also possible when not all needed ingredients are currently in stock (the in stock amount, if any, of the corresponding ingredient will be consumed in that case)
- For in stock ingredients, the amount actually in stock is now displayed next to the hint "Enough in stock"
- Added a new recipe ingredient option "Round up quantity amounts to the nearest whole number"
- When enabled, resulting quantity amounts (after scaling according the desired serving amount) are always rounded up to the nearest whole number
- Defaults to disabled, so no changed behavior when not configured
- Optimizations/changes when adding missing recipe ingredients to the shopping list:
- When the ingredient option "Only check if any amount is in stock" is enabled and when no corresponding unit conversion exists, the amount/unit is now taken "as is" (as defined in the recipe ingredient) into the created shopping list item
- The shopping list item no longer gets a note "Added for recipe" set and the ingredient note is no longer appended
- When the corresponding product is already on the shopping list, the amount of the existing item is incremented instead of creating a new shopping list item
- When a new shopping list item is created, the product's "Default quantity unit purchase" is now used (instead of the product's "Quantity unit stock")
- When no price information is available for at least one ingredient, a red exclamation mark is now displayed next to the recipe total cost information
- When clicking a recipe ingredient / product name, the product card will now be opened like on many other places throughout Grocy
- Fixed that calories/costs of recipe ingredients were wrong when the ingredient option "Only check if any amount is in stock" was set and the on the ingredient used quantity unit was different from the product's QU stock
- Fixed that multi-nested recipes (at least 3 levels of "included recipes") resulted in wrong amounts/costs/calories calculated for the ingredients originating in those nested recipes (also affected the meal plan)
### Meal plan
- Fixed that amounts/costs/calories were wrong for recipes which had at least 2 levels of "included recipes"
### Chores
- Added a possibility to see if a scheduled chore was tracked/done on time or not:
- When tracking chores, the "Next estimated tracking date" (so the current scheduled time) is now also stored in the corresponding chore journal entry and displayed in a new column "Scheduled tracking time" on the chores journal page
- When the "Tracked time" is later than the "Scheduled tracking time", the corresponding chore journal entry is now highlighted in red on the chores journal page
- Added a new column "Time of tracking" on the chores journal page (displays the time when the tracking actually happened, hidden by default)
- Added a new option "Swap track next schedule / track now buttons" (chores settings / top right corner settings menu) to swap the "Track next chore schedule" / "Track chore execution now" buttons/menu items on the chores overview page (defaults to disabled, so no changed behavior when not configured)
### Userfields
- Optimized Userfields of type "Checkbox"
- When it's a mandatory Userfield, the initial state of the corresponding checkbox is now indeterminate, means it's now also possible to actively not check it (previously mandatory meant the checkbox has to be set)
- Fixed that Userfield default values were not initialized for the `stock` entity (so affecting the purchase and inventory page)
- Fixed that uploading bigger or multiple files (so when the upload usually takes a little longer) didn't work (Userfield type "File")
### General
- Optimized nested modal dialogs:
- Nested dialogs are now no longer displayed "in each other" and instead "on top of each other"
- Dialogs can now be closed with the `ESC` key on the keyboard
- There is no longer a close button at the bottom (outside of the displayed `iframe`) and instead one at the top right corner of the dialog
- Wide dialogs (e.g. all showing a table, like showing stock entries of a product from the stock overview more/context menu per line) now use the full screen width
- Improved the handling of the initial field focus on form pages
- The previously manually necessary update steps (e.g. emptying the `data/viewcache` directory) are now fully automated, so no need to do this manually after this and future updates

View File

@@ -0,0 +1,21 @@
### Stock
- Fixed that the built-in Open Food Facts external barcode lookup plugin used the staging environment of the Open Food Facts API instead of the production one
- Fixed that the product group filter on the products page (master data) didn't work when the selected product group contained special characters
- Fixed that the product filter on the stock journal summary page didn't work when the selected product contained special characters
### Shopping list
- Optimized that non-number amounts are now prevented on database level (was infamously a problem when using specific community contributed alternative clients)
### Tasks
- Fixed that set table filters were not applied after editing or adding a task
### Userfields
- Fixed that saving Userfields of type "Select list (multiple items can be selected)" did not work
### General
- Optimized that when navigating between form input fields via the keyboard (`TAB`) there was an unwanted delay at some places

View File

@@ -0,0 +1,28 @@
### Stock
- Optimized that the built-in Open Food Facts external barcode lookup plugin now uses the localized product name (if provided by the Open Food Facts API, based on the set Grocy language of the current user)
- Fixed that the product filter on the stock entires page didn't work when the product column was reordered / not the second one
### Shopping list
- When the shopping list setting (top right corner settings menu) "Round up quantity amounts to the nearest whole number" is enabled, the "Last price (Total)" of each shopping list item and the total value of the shopping list are now also scaled up accordingly
- The print options (show header, layout type etc.) are now saved (as user settings, so global defaults can also defined in `config.php` as usual)
### Userfields
- Fixed that saving Userfields of type "Link (with title)" did not work
### General
- Fixed that most dialogs didn't work when hosting Grocy "embedded" in an `iframe` (affecting e.g. the [Home Assistant Add-on](https://github.com/hassio-addons/addon-grocy))
### API
- Exposed the `permission_hierarchy` entity (read only, => `GET /objects/permission_hierarchy`) to provide a permission name / id mapping
### Other
- A quick reminder about official native Grocy app experiences:
- Grocy's web frontend is responsive and an "installable web app" ([PWA](https://en.wikipedia.org/wiki/Progressive_web_app), without providing any offline usage capabilities), that provides a pretty native mobile app-like experience without the need for additional tools
- => Quick video demo on Android/Firefox: https://www.youtube.com/watch?v=L38drVZfwHs
- => Quick video demo on Android/Chrome: https://www.youtube.com/watch?v=rjLdXUFDNuk
- [Grocy Desktop](https://github.com/grocy/grocy-desktop) is a way to run Grocy without having to manage a webserver, just like a normal (Windows) desktop application - available as a [classic `.msi` installation package](https://releases.grocy.info/latest-desktop) or as a [Microsoft Store App](https://apps.microsoft.com/detail/9NWB1TRNNKSF)

View File

@@ -0,0 +1,16 @@
### Stock
- Optimizations in the built-in Open Food Facts external barcode lookup plugin:
- A provided but empty localized product name is now ignored
- Non-ASCII characters in product names are now ignored (e.g. line breaks caused problems)
- Optimized that when an external barcode lookup plugin returned an image URL with query parameters, an invalid picture (file name) was added to the created product
- Added a new column "Default store" on the stock overview page (hidden by default)
### General
- Optimized that the default font of the web frontend is now also used for non-latin characters
- Label printer WebHooks now include a new property/field `details` (that's the full product/chore/battery/etc. object)
- And also `stock_entry` (containing the full stock entry object) when printing a stock entry label
- The component used (so far [Quagga2](https://github.com/ericblade/quagga2)) that powers the camera barcode scanner was replaced by [ZXing](https://github.com/zxing-js/library) which should perform overall better and it also supports 2D barcodes (QRCode/DataMatrix) (thanks @gergof)
- New translations: (thanks all the translators)
- Bulgarian (demo available at <https://bg.demo.grocy.info>)

View File

@@ -0,0 +1,61 @@
> ⚠️ xxxBREAKING CHANGESxxx
> ❗ xxxImportant upgrade informationXXX
> 💡 xxxMinor upgrade informationXXX
### New Feature: xxxx
- xxx
### Stock
- Optimized the line plot markers color of the price history chart (product card) (thanks @DeepCoreSystem)
- Fixed that German Umlauts were removed from product names when looking up a barcode via the built-in Open Food Facts external barcode lookup plugin
- Fixed that when using/scanning a barcode on the purchase page with a note attached (which prefills the note field) and when manually selecting another product afterwards, the note of the previously used barcode was incorrectly prefilled again
- Fixed that the "next input focus handling" (jumping to the next input after entering a value) didn't work at some places (e.g. after entering a purchased date on the purchase page)
### Shopping list
- An amount of `0` is now allowed for shopping list items (just a convenience optimization, it was already possible to leave the amount field empty which implicitly resulted in an amount of `0`)
- Fixed that the "Add all list items to stock" workflow closed the dialog after every item instead only after the last one was added
### Recipes
- xxx
### Meal plan
- xxx
### Chores
- xxx
### Calendar
- xxx
### Tasks
- xxx
### Batteries
- xxx
### Equipment
- xxx
### Userfields
- xxx
### General
- Fixed that the date input shorthand `[+/-]n[d/m/y]` didn't work when the value lenght was >= 4 (e.g. `+10d`)
### API
- xxx

57
changelog/__TEMPLATE.md Normal file
View File

@@ -0,0 +1,57 @@
> ⚠️ xxxBREAKING CHANGESxxx
> ❗ xxxImportant upgrade informationXXX
> 💡 xxxMinor upgrade informationXXX
### New Feature: xxxx
- xxx
### Stock
- xxx
### Shopping list
- xxx
### Recipes
- xxx
### Meal plan
- xxx
### Chores
- xxx
### Calendar
- xxx
### Tasks
- xxx
### Batteries
- xxx
### Equipment
- xxx
### Userfields
- xxx
### General
- xxx
### API
- xxx

View File

@@ -1,18 +1,27 @@
{
"require": {
"php": ">=7.2",
"php": ">=8.2",
"slim/slim": "^4.0",
"slim/psr7": "^1.0",
"slim/http": "^1.0",
"php-di/php-di": "^6.0",
"rubellum/slim-blade-view": "^0.1.1",
"morris/lessql": "^0.4.1",
"gettext/gettext": "^4.8",
"eluceo/ical": "^0.16.0",
"php-di/php-di": "^7.0.3",
"berrnd/slim-blade-view": "^1.0.0",
"morris/lessql": "dev-php82",
"gettext/gettext": "^4.8.10",
"eluceo/ical": "^2.2.0",
"erusev/parsedown": "^1.7",
"gumlet/php-image-resize": "^1.9",
"ezyang/htmlpurifier": "^4.13"
"gumlet/php-image-resize": "^2.0",
"ezyang/htmlpurifier": "^4.13",
"interficieis/php-barcode": "^2.0.2",
"guzzlehttp/guzzle": "^7.0",
"mike42/escpos-php": "^4.0"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/berrnd/lessql"
}
],
"autoload": {
"psr-4": {
"Grocy\\Services\\": "services/",
@@ -23,5 +32,10 @@
"files": [
"helpers/extensions.php"
]
},
"config": {
"vendor-dir": "packages",
"platform-check": false,
"optimize-autoloader": true
}
}

2650
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,28 +1,29 @@
<?php
// Settings can also be overwritten in two ways
// Settings can also be overwritten in two ways:
//
// First priority
// First priority:
// A .txt file with the same name as the setting in /data/settingoverrides
// the content of the file is used as the setting value
//
// Second priority
// Second priority:
// An environment variable with the same name as the setting and prefix "GROCY_"
// so for example "GROCY_BASE_URL"
//
// Third priority
// Third priority:
// The settings defined here below
// Either "production", "dev", "demo" or "prerelease"
// When not "production", authentication will be disabled and
// demo data will be populated during database migrations
// When not "production", the application will work in a demo mode which means
// authentication is disabled and some demo data will be generated during the database schema migration
// (pass the query parameter "nodemodata", e.g. https://grocy.example.com/?nodemodata to skip that)
Setting('MODE', 'production');
// Either "en" or "de" or the directory name of
// one of the other available localization folders in the "/localization" directory
// The directory name of one of the available localization folders
// in the "/localization" directory (e.g. "en" or "de")
Setting('DEFAULT_LOCALE', 'en');
// This is used to define the first day of a week for calendar views in the frontend,
// This is used to define the first day of a week for calendar views,
// leave empty to use the locale default
// Needs to be a number where Sunday = 0, Monday = 1 and so forth
Setting('CALENDAR_FIRST_DAY_OF_WEEK', '');
@@ -30,14 +31,24 @@ Setting('CALENDAR_FIRST_DAY_OF_WEEK', '');
// If calendars should show week numbers
Setting('CALENDAR_SHOW_WEEK_OF_YEAR', true);
// To keep it simple: grocy does not handle any currency conversions,
// Set this if you want to have a different start day for the weekly meal plan view,
// leave empty to use CALENDAR_FIRST_DAY_OF_WEEK (see above)
// Needs to be a number where Sunday = 0, Monday = 1 and so forth
// Can also be set to -1 to dynamically start the meal plan week on "today"
Setting('MEAL_PLAN_FIRST_DAY_OF_WEEK', '');
// To keep it simple: Grocy does not handle any currency conversions,
// this here is used to format all money values,
// so doesn't really matter, but should be the
// so doesn't really matter, but needs to be the
// ISO 4217 code of the currency ("USD", "EUR", "GBP", etc.)
Setting('CURRENCY', 'USD');
// When running grocy in a subdirectory, this should be set to the relative path, otherwise empty
// It needs to be set to the part (of the URL) after the document root,
// Your preferred unit for energy
// E.g. "kcal" or "kJ" or something else (doesn't really matter, it's only used to display energy values)
Setting('ENERGY_UNIT', 'kcal');
// When running Grocy in a subdirectory, this should be set to the relative path, otherwise empty
// It needs to be set to the part (of the URL) AFTER the document root,
// if URL rewriting is disabled, including index.php
// Example with URL Rewriting support:
// Root URL = https://example.com/grocy
@@ -53,15 +64,16 @@ Setting('BASE_PATH', '');
Setting('BASE_URL', '/');
// The plugin to use for external barcode lookups,
// must be the filename without .php extension and must be located in /data/plugins,
// see /data/plugins/DemoBarcodeLookupPlugin.php for an example implementation
Setting('STOCK_BARCODE_LOOKUP_PLUGIN', 'DemoBarcodeLookupPlugin');
// must be the filename (folder "/plugins" for built-in plugins or "/data/plugins" for user plugins) without the .php extension,
// see /plugins/DemoBarcodeLookupPlugin.php for a commented example implementation
// Leave empty to disable external barcode lookups
Setting('STOCK_BARCODE_LOOKUP_PLUGIN', 'OpenFoodFactsBarcodeLookupPlugin');
// If, however, your webserver does not support URL rewriting, set this to true
Setting('DISABLE_URL_REWRITING', false);
// Specify an custom homepage if desired - by default the homepage will be set to the stock overview page,
// this needs to be one of the following values:
// Specify an custom homepage if desired, by default the homepage will be set to the stock overview page
// This needs to be one of the following values:
// stock, shoppinglist, recipes, chores, tasks, batteries, equipment, calendar, mealplan
Setting('ENTRY_PAGE', 'stock');
@@ -73,96 +85,49 @@ Setting('DISABLE_AUTH', false);
// or any class that implements Grocy\Middleware\AuthMiddleware
Setting('AUTH_CLASS', 'Grocy\Middleware\DefaultAuthMiddleware');
// When using ReverseProxyAuthMiddleware,
// the name of the HTTP header which your reverse proxy uses to pass the username (on successful authentication)
Setting('REVERSE_PROXY_AUTH_HEADER', 'REMOTE_USER');
// Options when using ReverseProxyAuthMiddleware
Setting('REVERSE_PROXY_AUTH_HEADER', 'REMOTE_USER'); // The name of the HTTP header which your reverse proxy uses to pass the username (on successful authentication)
Setting('REVERSE_PROXY_AUTH_USE_ENV', false); // Set to true if the username is passed as environment variable
// When using LdapAuthMiddleware
Setting('LDAP_DOMAIN', ''); // Example value "local"
// Options when using LdapAuthMiddleware
Setting('LDAP_ADDRESS', ''); // Example value "ldap://vm-dc2019.local.berrnd.net"
Setting('LDAP_BASE_DN', ''); // Example value "OU=OU_Users,DC=local,DC=berrnd,DC=net"
// Set this to true if you want to disable the ability to scan a barcode via the device camera (Browser API)
Setting('DISABLE_BROWSER_BARCODE_CAMERA_SCANNING', false);
// Set this if you want to have a different start day for the weekly meal plan view,
// leave empty to use CALENDAR_FIRST_DAY_OF_WEEK (see above)
// Needs to be a number where Sunday = 0, Monday = 1 and so forth
Setting('MEAL_PLAN_FIRST_DAY_OF_WEEK', '');
Setting('LDAP_BASE_DN', ''); // Example value "DC=local,DC=berrnd,DC=net"
Setting('LDAP_BIND_DN', ''); // Example value "CN=grocy_bind_account,OU=service_accounts,DC=local,DC=berrnd,DC=net"
Setting('LDAP_BIND_PW', ''); // Password for the above account
Setting('LDAP_USER_FILTER', ''); // Example value "(OU=grocy_users)"
Setting('LDAP_UID_ATTR', ''); // Windows AD: "sAMAccountName", OpenLDAP: "uid", GLAuth: "cn"
// Default permissions for new users
// the array needs to contain the technical/constant names
// see the file controllers/Users/User.php for possible values
// See the file controllers/Users/User.php for possible values
Setting('DEFAULT_PERMISSIONS', ['ADMIN']);
// Default user settings
// These settings can be changed per user, here the defaults
// are defined which are used when the user has not changed the setting so far
// "1D" (=> Code128) or "2D" (=> DataMatrix)
Setting('GROCYCODE_TYPE', '2D');
// Night mode related
DefaultUserSetting('night_mode_enabled', false); // If night mode is enabled always
DefaultUserSetting('auto_night_mode_enabled', false); // If night mode is enabled automatically when inside a given time range (see the two settings below)
DefaultUserSetting('auto_night_mode_time_range_from', '20:00'); // Format HH:mm
DefaultUserSetting('auto_night_mode_time_range_to', '07:00'); // Format HH:mm
DefaultUserSetting('auto_night_mode_time_range_goes_over_midnight', true); // If the time range above goes over midnight
DefaultUserSetting('currently_inside_night_mode_range', false); // If we're currently inside of night mode time range (this is not user configurable, but stored as a user setting because it's evaluated client side to be able to use the client time instead of the maybe different server time)
// Keep screen on settings
DefaultUserSetting('keep_screen_on', false); // Keep the screen always on
DefaultUserSetting('keep_screen_on_when_fullscreen_card', false); // Keep the screen on when a "fullscreen-card" is displayed
// Label printer settings
Setting('LABEL_PRINTER_WEBHOOK', ''); // The URI that Grocy will POST to when asked to print a label
Setting('LABEL_PRINTER_RUN_SERVER', true); // Whether the webhook will be called server- or client-side
Setting('LABEL_PRINTER_PARAMS', ['font_family' => 'Source Sans Pro (Regular)']); // Additional parameters supplied to the webhook
Setting('LABEL_PRINTER_HOOK_JSON', true); // TRUE to use JSON or FALSE to use normal POST request variables
// Stock settings
DefaultUserSetting('product_presets_location_id', -1); // Default location id for new products (-1 means no location is preset)
DefaultUserSetting('product_presets_product_group_id', -1); // Default product group id for new products (-1 means no product group is preset)
DefaultUserSetting('product_presets_qu_id', -1); // Default quantity unit id for new products (-1 means no quantity unit is preset)
DefaultUserSetting('stock_decimal_places_amounts', 4); // Default decimal places allowed for amounts
DefaultUserSetting('stock_decimal_places_prices', 2); // Default decimal places allowed for prices
DefaultUserSetting('stock_due_soon_days', 5);
DefaultUserSetting('stock_default_purchase_amount', 0);
DefaultUserSetting('stock_default_consume_amount', 1);
DefaultUserSetting('stock_default_consume_amount_use_quick_consume_amount', false);
DefaultUserSetting('scan_mode_consume_enabled', false);
DefaultUserSetting('scan_mode_purchase_enabled', false);
DefaultUserSetting('show_icon_on_stock_overview_page_when_product_is_on_shopping_list', true);
DefaultUserSetting('show_purchased_date_on_purchase', false); // Wheter the purchased date should be editable on purchase (defaults to today otherwise)
DefaultUserSetting('show_warning_on_purchase_when_due_date_is_earlier_than_next', true); // Show a warning on purchase when the due date of the purchased product is earlier than the next due date in stock
// Shopping list settings
DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false); // Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default due days" set
DefaultUserSetting('shopping_list_show_calendar', false);
// Thermal printer options
// Thermal printers are receipt printers, not regular printers,
// the printer must support the ESC/POS protocol, see https://github.com/mike42/escpos-php
Setting('TPRINTER_IS_NETWORK_PRINTER', false); // Set to true if it's a network printer
Setting('TPRINTER_PRINT_QUANTITY_NAME', true); // Set to false if you do not want to print the quantity names (related to the shopping list)
Setting('TPRINTER_PRINT_NOTES', true); // Set to false if you do not want to print notes (related to the shopping list)
Setting('TPRINTER_IP', '127.0.0.1'); // IP of the network printer (does only matter if it's a network printer)
Setting('TPRINTER_PORT', 9100); // Port of the network printer (does only matter if it's a network printer)
Setting('TPRINTER_CONNECTOR', '/dev/usb/lp0'); // Printer device (does only matter if you use a locally attached printer)
// For USB on Linux this is often '/dev/usb/lp0', for serial printers it could be similar to '/dev/ttyS0'
// Make sure that the user that runs the webserver has permissions to write to the printer - on Linux add your webserver user to the LP group with usermod -a -G lp www-data
// Recipe settings
DefaultUserSetting('recipe_ingredients_group_by_product_group', false); // Group recipe ingredients by their product group
// Chores settings
DefaultUserSetting('chores_due_soon_days', 5);
// Batteries settings
DefaultUserSetting('batteries_due_soon_days', 5);
// Tasks settings
DefaultUserSetting('tasks_due_soon_days', 5);
// If the page should be automatically reloaded when there was
// an external change
DefaultUserSetting('auto_reload_on_db_change', true);
// Show a clock in the header next to the logo or not
DefaultUserSetting('show_clock_in_header', false);
// Component configuration for Quagga2 - read https://github.com/ericblade/quagga2#configobject for details
// Below is a generic good configuration,
// for an iPhone 7 Plus, halfsample = true, patchsize = small, frequency = 5 yields very good results
DefaultUserSetting('quagga2_numofworkers', 4);
DefaultUserSetting('quagga2_halfsample', false);
DefaultUserSetting('quagga2_patchsize', 'medium');
DefaultUserSetting('quagga2_frequency', 10);
DefaultUserSetting('quagga2_debug', true);
// Feature flags
// grocy was initially about "stock management for your household", many other things
// came and still come by, because they are useful - here you can disable the parts
// which you don't need to have a less cluttered UI
// Here you can disable the parts which you don't need to have a less cluttered UI
// (set the setting to "false" to disable the corresponding part, which should be self explanatory)
Setting('FEATURE_FLAG_STOCK', true);
Setting('FEATURE_FLAG_SHOPPINGLIST', true);
@@ -172,6 +137,7 @@ Setting('FEATURE_FLAG_TASKS', true);
Setting('FEATURE_FLAG_BATTERIES', true);
Setting('FEATURE_FLAG_EQUIPMENT', true);
Setting('FEATURE_FLAG_CALENDAR', true);
Setting('FEATURE_FLAG_LABEL_PRINTER', false);
// Sub feature flags
Setting('FEATURE_FLAG_STOCK_PRICE_TRACKING', true);
@@ -181,8 +147,83 @@ Setting('FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING', true);
Setting('FEATURE_FLAG_STOCK_PRODUCT_FREEZING', true);
Setting('FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_FIELD_NUMBER_PAD', true); // Activate the number pad in due date fields on (supported) mobile browsers
Setting('FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS', true);
Setting('FEATURE_FLAG_RECIPES_MEALPLAN', true);
Setting('FEATURE_FLAG_CHORES_ASSIGNMENTS', true);
Setting('FEATURE_FLAG_THERMAL_PRINTER', false);
// Feature settings
Setting('FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT', true); // When set to true, opened items will be counted as missing for calculating if a product is below its minimum stock amount
Setting('FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA', true); // Enables the torch automaticaly (if the device has one)
Setting('FEATURE_FLAG_DISABLE_BROWSER_BARCODE_CAMERA_SCANNING', false); // Set this to true if you want to disable the ability to scan a barcode via the device camera (Browser API)
Setting('FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA', true); // Enables the torch automatically (if the device has one)
// Default user settings
// These settings can be changed per user and via the UI,
// below are the defaults which are used when the user has not changed the setting so far
// Night mode related
DefaultUserSetting('night_mode', 'follow-system'); // "on" = Night mode is always on ; "off" = Night mode is always off / "follow-system" = System preferred color schema is used
DefaultUserSetting('auto_night_mode_enabled', false); // If night mode is enabled automatically when inside a given time range (see the two settings below)
DefaultUserSetting('auto_night_mode_time_range_from', '20:00'); // Format HH:mm
DefaultUserSetting('auto_night_mode_time_range_to', '07:00'); // Format HH:mm
DefaultUserSetting('auto_night_mode_time_range_goes_over_midnight', true); // If the time range above goes over midnight
DefaultUserSetting('night_mode_enabled_internal', false); // Internal setting if night mode is actually enabled (based on the other settings)
// Generic settings
DefaultUserSetting('auto_reload_on_db_change', false); // If the page should be automatically reloaded when there was an external change
DefaultUserSetting('show_clock_in_header', false); // Show a clock in the header next to the logo or not
DefaultUserSetting('keep_screen_on', false); // If the screen should always be kept on
DefaultUserSetting('keep_screen_on_when_fullscreen_card', false); // If the screen should be kept on when a "fullscreen-card" is displayed
// Stock settings
DefaultUserSetting('product_presets_location_id', -1); // Default location id for new products (-1 means no location is preset)
DefaultUserSetting('product_presets_product_group_id', -1); // Default product group id for new products (-1 means no product group is preset)
DefaultUserSetting('product_presets_qu_id', -1); // Default quantity unit id for new products (-1 means no quantity unit is preset)
DefaultUserSetting('product_presets_default_due_days', 0); // Default due days for new products (-1 means that the product will be never overdue)
DefaultUserSetting('product_presets_treat_opened_as_out_of_stock', true); // Default "Treat opened as out of stock" option for new products
DefaultUserSetting('product_presets_default_stock_label_type', 0); // "Default stock entry label" option for new products (0 = No label, 1 = Single Label, 2 = Label per unit)
DefaultUserSetting('stock_decimal_places_amounts', 4); // Default decimal places allowed for amounts
DefaultUserSetting('stock_decimal_places_prices_input', 2); // Default decimal places allowed for prices (input)
DefaultUserSetting('stock_decimal_places_prices_display', 2); // Default decimal places allowed for prices (display)
DefaultUserSetting('stock_auto_decimal_separator_prices', false); // If the decimal separator should be set automatically for amount inputs
DefaultUserSetting('stock_due_soon_days', 5); // The "expiring soon" days
DefaultUserSetting('stock_default_purchase_amount', 0); // The default amount prefilled on the purchase page
DefaultUserSetting('stock_default_consume_amount', 1); // The default amount prefilled on the consume page
DefaultUserSetting('stock_default_consume_amount_use_quick_consume_amount', false); // If the products quick consume amount should be prefilled on the consume page
DefaultUserSetting('scan_mode_consume_enabled', false); // If scan mode on the consume page is enabled
DefaultUserSetting('scan_mode_purchase_enabled', false); // If scan mode on the purchase page is enabled
DefaultUserSetting('show_icon_on_stock_overview_page_when_product_is_on_shopping_list', true); // When enabled, an icon is shown on the stock overview page (next to the product name) when the prodcut is currently on a shopping list
DefaultUserSetting('stock_overview_show_all_out_of_stock_products', false); // By default the stock overview page lists all products which are currently in stock or below their min. stock amount - when this is enabled, all (active) products are always shown
DefaultUserSetting('show_purchased_date_on_purchase', false); // Whether the purchased date should be editable on purchase (defaults to today otherwise)
DefaultUserSetting('show_warning_on_purchase_when_due_date_is_earlier_than_next', true); // Show a warning on purchase when the due date of the purchased product is earlier than the next due date in stock
// Shopping list settings
DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false); // Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default due days" set
DefaultUserSetting('shopping_list_show_calendar', false); // When enabled, a small (month view) calendar will be shown on the shopping list page
DefaultUserSetting('shopping_list_round_up', false); // When enabled, all quantity amounts on the shopping list are always displayed rounded up to the nearest whole number
DefaultUserSetting('shopping_list_auto_add_below_min_stock_amount', false); // If products should be automatically added to the shopping list when they are below their min. stock amount
DefaultUserSetting('shopping_list_auto_add_below_min_stock_amount_list_id', 1); // When the above setting is enabled, the id of the shopping list to which the products will be added
DefaultUserSetting('shopping_list_print_show_header', true); // Default for the shopping list print option "Show header"
DefaultUserSetting('shopping_list_print_group_by_product_group', true); // Default for the shopping list print option "Group by product group"
DefaultUserSetting('shopping_list_print_layout_type', 'table'); // Default for the shopping list print option "Layout type" (table or list)
// Recipe settings
DefaultUserSetting('recipe_ingredients_group_by_product_group', false); // Group recipe ingredients by their product group
DefaultUserSetting('recipes_show_list_side_by_side', true); // If the recipe should be displayed next to recipe list on the recipes page
DefaultUserSetting('recipes_show_ingredient_checkbox', false); // When enabled, a little checkbox will be shown next to each ingredient to mark it as done
// Chores settings
DefaultUserSetting('chores_due_soon_days', 5); // The "due soon" days
DefaultUserSetting('chores_overview_swap_tracking_buttons', false); // When enabled, the "Track next chore schedule" and "Track chore execution now" buttons/menu items are swapped
// Batteries settings
DefaultUserSetting('batteries_due_soon_days', 5); // The "due soon" days
// Tasks settings
DefaultUserSetting('tasks_due_soon_days', 5); // The "due soon" days
// Calendar settings
DefaultUserSetting('calendar_color_products', '#007bff'); // The event color (hex code) for due products
DefaultUserSetting('calendar_color_tasks', '#28a745'); // The event color (hex code) for due tasks
DefaultUserSetting('calendar_color_chores', '#ffc107'); // The event color (hex code) for due chores
DefaultUserSetting('calendar_color_batteries', '#17a2b8'); // The event color (hex code) for due battery charge cycles
DefaultUserSetting('calendar_color_meal_plan', '#6c757d'); // The event color (hex code) for meal plan items

View File

@@ -3,39 +3,41 @@
namespace Grocy\Controllers;
use LessQL\Result;
use Psr\Http\Message\ResponseInterface as Response;
use Slim\Exception\HttpException;
class BaseApiController extends BaseController
{
const PATTERN_FIELD = '[A-Za-z_][A-Za-z0-9_]+';
const PATTERN_OPERATOR = '!?((>=)|(<=)|=|~|<|>|(§))';
const PATTERN_VALUE = '[A-Za-z\p{L}\p{M}0-9*_.$#^| -\\\]+';
protected $OpenApiSpec = null;
const PATTERN_FIELD = '[A-Za-z_][A-Za-z0-9_]+';
const PATTERN_OPERATOR = '!?(=|~|<|>|(>=)|(<=)|(§))';
const PATTERN_VALUE = '[A-Za-z_0-9.$#^|]+';
public function __construct(\DI\Container $container)
protected function ApiResponse(Response $response, $data, $cache = false)
{
parent::__construct($container);
}
if ($cache)
{
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
}
protected function ApiResponse(\Psr\Http\Message\ResponseInterface $response, $data)
{
$response->getBody()->write(json_encode($data));
return $response;
}
protected function EmptyApiResponse(\Psr\Http\Message\ResponseInterface $response, $status = 204)
protected function EmptyApiResponse(Response $response, $status = 204)
{
return $response->withStatus($status);
}
protected function GenericErrorResponse(\Psr\Http\Message\ResponseInterface $response, $errorMessage, $status = 400)
protected function GenericErrorResponse(Response $response, $errorMessage, $status = 400)
{
return $response->withStatus($status)->withJson([
'error_message' => $errorMessage
]);
}
public function FilteredApiResponse(\Psr\Http\Message\ResponseInterface $response, Result $data, array $query)
public function FilteredApiResponse(Response $response, Result $data, array $query)
{
$data = $this->queryData($data, $query);
return $this->ApiResponse($response, $data);
@@ -48,8 +50,13 @@ class BaseApiController extends BaseController
$data = $this->filter($data, $query['query']);
}
if (isset($query['limit']))
if (isset($query['limit']) || isset($query['offset']))
{
if (!isset($query['limit']))
{
$query['limit'] = -1;
}
$data = $data->limit(intval($query['limit']), intval($query['offset'] ?? 0));
}
@@ -83,7 +90,7 @@ class BaseApiController extends BaseController
preg_match(
'/(?P<field>' . self::PATTERN_FIELD . ')'
. '(?P<op>' . self::PATTERN_OPERATOR . ')'
. '(?P<value>' . self::PATTERN_VALUE . ')/',
. '(?P<value>' . self::PATTERN_VALUE . ')/u',
$q,
$matches
);
@@ -99,7 +106,8 @@ class BaseApiController extends BaseController
$sqlOrNull = ' OR ' . $matches['field'] . ' IS NULL';
}
switch ($matches['op']) {
switch ($matches['op'])
{
case '=':
$data = $data->where($matches['field'] . ' = ?' . $sqlOrNull, $matches['value']);
break;
@@ -127,7 +135,6 @@ class BaseApiController extends BaseController
case '§':
$data = $data->where($matches['field'] . ' REGEXP ?', $matches['value']);
break;
}
}
@@ -143,4 +150,47 @@ class BaseApiController extends BaseController
return $this->OpenApiSpec;
}
private static $htmlPurifierInstance = null;
protected function GetParsedAndFilteredRequestBody($request)
{
if ($request->getHeaderLine('Content-Type') != 'application/json')
{
throw new HttpException($request, 'Bad Content-Type', 400);
}
if (self::$htmlPurifierInstance == null)
{
$htmlPurifierConfig = \HTMLPurifier_Config::createDefault();
$htmlPurifierConfig->set('Cache.SerializerPath', GROCY_DATAPATH . '/viewcache');
$htmlPurifierConfig->set('HTML.Allowed', 'div,b,strong,i,em,u,a[href|title|target],iframe[src|width|height|frameborder],ul,ol,li,p[style],br,span[style],img[style|width|height|alt|src],table[border|width|style],tbody,tr,td,th,blockquote,*[style|class|id],h1,h2,h3,h4,h5,h6');
$htmlPurifierConfig->set('Attr.EnableID', true);
$htmlPurifierConfig->set('HTML.SafeIframe', true);
$htmlPurifierConfig->set('CSS.AllowedProperties', 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align,width,height');
$htmlPurifierConfig->set('URI.AllowedSchemes', ['data' => true, 'http' => true, 'https' => true]);
$htmlPurifierConfig->set('URI.SafeIframeRegexp', '%^.*%'); // Allow any iframe source
$htmlPurifierConfig->set('CSS.MaxImgLength', null);
self::$htmlPurifierInstance = new \HTMLPurifier($htmlPurifierConfig);
}
$requestBody = $request->getParsedBody();
foreach ($requestBody as $key => &$value)
{
// HTMLPurifier removes boolean values (true/false) and arrays, so explicitly keep them
// Maybe also possible through HTMLPurifier config (http://htmlpurifier.org/live/configdoc/plain.html)
if (!is_bool($value) && !is_array($value))
{
$value = self::$htmlPurifierInstance->purify($value);
// Allow some special chars
// Maybe also possible through HTMLPurifier config (http://htmlpurifier.org/live/configdoc/plain.html)
$value = str_replace('&amp;', '&', $value);
$value = str_replace('&gt;', '>', $value);
$value = str_replace('&lt;', '<', $value);
}
}
return $requestBody;
}
}

View File

@@ -11,23 +11,26 @@ use Grocy\Services\ChoresService;
use Grocy\Services\DatabaseService;
use Grocy\Services\FilesService;
use Grocy\Services\LocalizationService;
use Grocy\Services\PrintService;
use Grocy\Services\RecipesService;
use Grocy\Services\SessionService;
use Grocy\Services\StockService;
use Grocy\Services\TasksService;
use Grocy\Services\UserfieldsService;
use Grocy\Services\UsersService;
use DI\Container;
class BaseController
{
protected $AppContainer;
public function __construct(\DI\Container $container)
public function __construct(Container $container)
{
$this->AppContainer = $container;
$this->View = $container->get('view');
}
protected $AppContainer;
protected $View;
protected function getApiKeyService()
{
return ApiKeyService::getInstance();
@@ -93,6 +96,11 @@ class BaseController
return StockService::getInstance();
}
protected function getPrintService()
{
return PrintService::getInstance();
}
protected function getTasksService()
{
return TasksService::getInstance();
@@ -108,22 +116,24 @@ class BaseController
return UsersService::getInstance();
}
protected function render($response, $page, $data = [])
protected function render($response, $viewName, $data = [])
{
$container = $this->AppContainer;
$versionInfo = $this->getApplicationService()->GetInstalledVersion();
$this->View->set('version', $versionInfo->Version);
$this->View->set('releaseDate', $versionInfo->ReleaseDate);
$localizationService = $this->getLocalizationService();
$this->View->set('__t', function (string $text, ...$placeholderValues) use ($localizationService) {
$this->View->set('__t', function (string $text, ...$placeholderValues) use ($localizationService)
{
return $localizationService->__t($text, $placeholderValues);
});
$this->View->set('__n', function ($number, $singularForm, $pluralForm) use ($localizationService) {
return $localizationService->__n($number, $singularForm, $pluralForm);
$this->View->set('__n', function ($number, $singularForm, $pluralForm, $isQu = false) use ($localizationService)
{
return $localizationService->__n($number, $singularForm, $pluralForm, $isQu);
});
$this->View->set('GettextPo', $localizationService->GetPoAsJsonString());
$this->View->set('LocalizationStrings', $localizationService->GetPoAsJsonString());
$this->View->set('LocalizationStringsQu', $localizationService->GetPoAsJsonStringQu());
// TODO: Better handle this generically based on the current language (header in .po file?)
$dir = 'ltr';
@@ -133,7 +143,8 @@ class BaseController
}
$this->View->set('dir', $dir);
$this->View->set('U', function ($relativePath, $isResource = false) use ($container) {
$this->View->set('U', function ($relativePath, $isResource = false) use ($container)
{
return $container->get('UrlManager')->ConstructUrl($relativePath, $isResource);
});
@@ -152,23 +163,35 @@ class BaseController
unset($constants[$constant]);
}
}
$this->View->set('featureFlags', $constants);
if (GROCY_AUTHENTICATED)
{
$this->View->set('permissions', User::PermissionList());
$decimalPlacesAmounts = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'stock_decimal_places_amounts');
if ($decimalPlacesAmounts <= 0)
{
$defaultMinAmount = 1;
}
else
{
$defaultMinAmount = '0.' . str_repeat('0', $decimalPlacesAmounts - 1) . '1';
}
$this->View->set('DEFAULT_MIN_AMOUNT', $defaultMinAmount);
}
return $this->View->render($response, $page, $data);
$this->View->set('viewName', $viewName);
return $this->View->render($response, $viewName, $data);
}
protected function renderPage($response, $page, $data = [])
protected function renderPage($response, $viewName, $data = [])
{
$this->View->set('userentitiesForSidebar', $this->getDatabase()->userentities()->where('show_in_sidebar_menu = 1')->orderBy('name'));
try
{
$usersService = $this->getUsersService();
if (defined('GROCY_USER_ID'))
{
$this->View->set('userSettings', $usersService->GetUserSettings(GROCY_USER_ID));
@@ -183,29 +206,6 @@ class BaseController
// Happens when database is not initialised or migrated...
}
return $this->render($response, $page, $data);
}
private static $htmlPurifierInstance = null;
protected function GetParsedAndFilteredRequestBody($request)
{
if (self::$htmlPurifierInstance == null)
{
self::$htmlPurifierInstance = new \HTMLPurifier(\HTMLPurifier_Config::createDefault());
}
$requestBody = $request->getParsedBody();
foreach ($requestBody as $key => &$value)
{
// HTMLPurifier removes boolean values (true/false), so explicitly keep them
// Maybe also possible through HTMLPurifier config (http://htmlpurifier.org/live/configdoc/plain.html)
if (!is_bool($value))
{
$value = self::$htmlPurifierInstance->purify($value);
}
}
return $requestBody;
return $this->render($response, $viewName, $data);
}
}

View File

@@ -3,10 +3,14 @@
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Grocy\Helpers\WebhookRunner;
use Grocy\Helpers\Grocycode;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class BatteriesApiController extends BaseApiController
{
public function BatteryDetails(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function BatteryDetails(Request $request, Response $response, array $args)
{
try
{
@@ -18,12 +22,12 @@ class BatteriesApiController extends BaseApiController
}
}
public function Current(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Current(Request $request, Response $response, array $args)
{
return $this->FilteredApiResponse($response, $this->getBatteriesService()->GetCurrent(), $request->getQueryParams());
}
public function TrackChargeCycle(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TrackChargeCycle(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_BATTERIES_TRACK_CHARGE_CYCLE);
@@ -32,7 +36,6 @@ class BatteriesApiController extends BaseApiController
try
{
$trackedTime = date('Y-m-d H:i:s');
if (array_key_exists('tracked_time', $requestBody) && IsIsoDateTime($requestBody['tracked_time']))
{
$trackedTime = $requestBody['tracked_time'];
@@ -47,7 +50,7 @@ class BatteriesApiController extends BaseApiController
}
}
public function UndoChargeCycle(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UndoChargeCycle(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_BATTERIES_UNDO_CHARGE_CYCLE);
@@ -62,8 +65,28 @@ class BatteriesApiController extends BaseApiController
}
}
public function __construct(\DI\Container $container)
public function BatteryPrintLabel(Request $request, Response $response, array $args)
{
parent::__construct($container);
try
{
$batteryDetails = (object)$this->getBatteriesService()->GetBatteryDetails($args['batteryId']);
$webhookData = array_merge([
'battery' => $batteryDetails->battery->name,
'grocycode' => (string)(new Grocycode(Grocycode::BATTERY, $args['batteryId'])),
'details' => $batteryDetails,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_RUN_SERVER)
{
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
}
return $this->ApiResponse($response, $webhookData);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}

View File

@@ -2,9 +2,15 @@
namespace Grocy\Controllers;
use Grocy\Helpers\Grocycode;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class BatteriesController extends BaseController
{
public function BatteriesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
use GrocycodeTrait;
public function BatteriesList(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['include_disabled']))
{
@@ -22,12 +28,12 @@ class BatteriesController extends BaseController
]);
}
public function BatteriesSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function BatteriesSettings(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'batteriessettings');
}
public function BatteryEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function BatteryEditForm(Request $request, Response $response, array $args)
{
if ($args['batteryId'] == 'new')
{
@@ -46,37 +52,79 @@ class BatteriesController extends BaseController
}
}
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Journal(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['months']) && filter_var($request->getQueryParams()['months'], FILTER_VALIDATE_INT) !== false)
{
$months = $request->getQueryParams()['months'];
$where = "tracked_time > DATE(DATE('now', 'localtime'), '-$months months')";
}
else
{
// Default 2 years
$where = "tracked_time > DATE(DATE('now', 'localtime'), '-24 months')";
}
if (isset($request->getQueryParams()['battery']) && filter_var($request->getQueryParams()['battery'], FILTER_VALIDATE_INT) !== false)
{
$batteryId = $request->getQueryParams()['battery'];
$where .= " AND battery_id = $batteryId";
}
return $this->renderPage($response, 'batteriesjournal', [
'chargeCycles' => $this->getDatabase()->battery_charge_cycles()->orderBy('tracked_time', 'DESC'),
'batteries' => $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE')
'chargeCycles' => $this->getDatabase()->battery_charge_cycles()->where($where)->orderBy('tracked_time', 'DESC'),
'batteries' => $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('battery_charge_cycles'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('battery_charge_cycles')
]);
}
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Overview(Request $request, Response $response, array $args)
{
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['batteries_due_soon_days'];
$batteries = $this->getDatabase()->batteries()->where('active = 1');
$currentBatteries = $this->getBatteriesService()->GetCurrent();
foreach ($currentBatteries as $currentBattery)
{
if (FindObjectInArrayByPropertyValue($batteries, 'id', $currentBattery->battery_id)->charge_interval_days > 0)
{
if ($currentBattery->next_estimated_charge_time < date('Y-m-d H:i:s'))
{
$currentBattery->due_type = 'overdue';
}
elseif ($currentBattery->next_estimated_charge_time <= date('Y-m-d 23:59:59'))
{
$currentBattery->due_type = 'duetoday';
}
elseif ($nextXDays > 0 && $currentBattery->next_estimated_charge_time <= date('Y-m-d H:i:s', strtotime('+' . $nextXDays . ' days')))
{
$currentBattery->due_type = 'duesoon';
}
}
}
return $this->renderPage($response, 'batteriesoverview', [
'batteries' => $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'current' => $this->getBatteriesService()->GetCurrent(),
'batteries' => $batteries,
'current' => $currentBatteries,
'nextXDays' => $nextXDays,
'userfields' => $this->getUserfieldsService()->GetFields('batteries'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('batteries')
]);
}
public function TrackChargeCycle(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TrackChargeCycle(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'batterytracking', [
'batteries' => $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE')
'batteries' => $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('battery_charge_cycles')
]);
}
public function __construct(\DI\Container $container)
public function BatteryGrocycodeImage(Request $request, Response $response, array $args)
{
parent::__construct($container);
$gc = new Grocycode(Grocycode::BATTERY, $args['batteryId']);
return $this->ServeGrocycodeImage($request, $response, $gc);
}
}

View File

@@ -2,24 +2,36 @@
namespace Grocy\Controllers;
use Grocy\Services\ApiKeyService;
use Eluceo\iCal\Domain\Entity\Calendar;
use Eluceo\iCal\Domain\Entity\Event;
use Eluceo\iCal\Domain\Entity\TimeZone;
use Eluceo\iCal\Domain\ValueObject\Date;
use Eluceo\iCal\Domain\ValueObject\DateTime;
use Eluceo\iCal\Domain\ValueObject\SingleDay;
use Eluceo\iCal\Domain\ValueObject\TimeSpan;
use Eluceo\iCal\Presentation\Factory\CalendarFactory;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class CalendarApiController extends BaseApiController
{
public function Ical(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Ical(Request $request, Response $response, array $args)
{
try
{
$vCalendar = new \Eluceo\iCal\Component\Calendar('grocy');
$events = $this->getCalendarService()->GetEvents();
$minDate = null;
$maxDate = null;
$vCalendar = new Calendar();
$vCalendar->setProductIdentifier('Grocy');
foreach ($events as $event)
{
$date = new \DateTime($event['start']);
$date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
if ($event['date_format'] === 'date')
if (!isset($event['start']) || empty($event['start']))
{
$date->setTime(23, 59, 59);
continue;
}
$description = '';
@@ -28,20 +40,49 @@ class CalendarApiController extends BaseApiController
$description = $event['description'];
}
$vEvent = new \Eluceo\iCal\Component\Event();
$vEvent->setDtStart($date)
->setDtEnd($date)
->setSummary($event['title'])
->setDescription($description)
->setNoTime($event['date_format'] === 'date' || (isset($event['allDay']) && $event['allDay']))
->setUseTimezone(true);
if ($event['date_format'] === 'date' || (isset($event['allDay']) && $event['allDay']))
{
// All-day event
$date = new Date(\DateTimeImmutable::createFromFormat('Y-m-d', substr($event['start'], 0, 10)));
$vEventOccurrence = new SingleDay($date);
$vCalendar->addComponent($vEvent);
$compareDate = \DateTimeImmutable::createFromFormat('Y-m-d', substr($event['start'], 0, 10));
}
else
{
// Time-point event
$start = new DateTime(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $event['start']), true);
$end = new DateTime(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $event['start']), true);
$vEventOccurrence = new TimeSpan($start, $end);
$compareDate = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $event['start']);
}
$vEvent = new Event();
$vEvent->setOccurrence($vEventOccurrence)
->setSummary($event['title'])
->setDescription($description);
$vCalendar->addEvent($vEvent);
if ($minDate == null || $compareDate < $minDate)
{
$minDate = $compareDate;
}
if ($maxDate == null || $compareDate > $maxDate)
{
$maxDate = $compareDate;
}
}
$response->write($vCalendar->render());
if ($minDate != null && $maxDate != null)
{
$vCalendar->addTimeZone(TimeZone::createFromPhpDateTimeZone(new \DateTimeZone(date_default_timezone_get()), $minDate, $maxDate));
}
$response->write((new CalendarFactory())->createCalendar($vCalendar));
$response = $response->withHeader('Content-Type', 'text/calendar; charset=utf-8');
return $response->withHeader('Content-Disposition', 'attachment; filename="grocy.ics"');
return $response->withHeader('Content-Disposition', 'attachment; filename="Grocy.ics"');
}
catch (\Exception $ex)
{
@@ -49,12 +90,12 @@ class CalendarApiController extends BaseApiController
}
}
public function IcalSharingLink(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function IcalSharingLink(Request $request, Response $response, array $args)
{
try
{
return $this->ApiResponse($response, [
'url' => $this->AppContainer->get('UrlManager')->ConstructUrl('/api/calendar/ical?secret=' . $this->getApiKeyService()->GetOrCreateApiKey(\Grocy\Services\ApiKeyService::API_KEY_TYPE_SPECIAL_PURPOSE_CALENDAR_ICAL))
'url' => $this->AppContainer->get('UrlManager')->ConstructUrl('/api/calendar/ical?secret=' . $this->getApiKeyService()->GetOrCreateApiKey(ApiKeyService::API_KEY_TYPE_SPECIAL_PURPOSE_CALENDAR_ICAL))
]);
}
catch (\Exception $ex)
@@ -62,9 +103,4 @@ class CalendarApiController extends BaseApiController
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}

View File

@@ -2,17 +2,15 @@
namespace Grocy\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class CalendarController extends BaseController
{
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Overview(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'calendar', [
'fullcalendarEventSources' => $this->getCalendarService()->GetEvents()
]);
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}

View File

@@ -3,10 +3,14 @@
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Grocy\Helpers\WebhookRunner;
use Grocy\Helpers\Grocycode;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class ChoresApiController extends BaseApiController
{
public function CalculateNextExecutionAssignments(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function CalculateNextExecutionAssignments(Request $request, Response $response, array $args)
{
try
{
@@ -40,7 +44,7 @@ class ChoresApiController extends BaseApiController
}
}
public function ChoreDetails(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ChoreDetails(Request $request, Response $response, array $args)
{
try
{
@@ -52,12 +56,12 @@ class ChoresApiController extends BaseApiController
}
}
public function Current(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Current(Request $request, Response $response, array $args)
{
return $this->FilteredApiResponse($response, $this->getChoresService()->GetCurrent(), $request->getQueryParams());
}
public function TrackChoreExecution(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TrackChoreExecution(Request $request, Response $response, array $args)
{
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
@@ -66,14 +70,18 @@ class ChoresApiController extends BaseApiController
User::checkPermission($request, User::PERMISSION_CHORE_TRACK_EXECUTION);
$trackedTime = date('Y-m-d H:i:s');
if (array_key_exists('tracked_time', $requestBody) && (IsIsoDateTime($requestBody['tracked_time']) || IsIsoDate($requestBody['tracked_time'])))
{
$trackedTime = $requestBody['tracked_time'];
}
$doneBy = GROCY_USER_ID;
$skipped = false;
if (array_key_exists('skipped', $requestBody) && filter_var($requestBody['skipped'], FILTER_VALIDATE_BOOLEAN) !== false)
{
$skipped = $requestBody['skipped'];
}
$doneBy = GROCY_USER_ID;
if (array_key_exists('done_by', $requestBody) && !empty($requestBody['done_by']))
{
$doneBy = $requestBody['done_by'];
@@ -81,10 +89,10 @@ class ChoresApiController extends BaseApiController
if ($doneBy != GROCY_USER_ID)
{
User::checkPermission($request, User::PERMISSION_CHORE_TRACK_EXECUTION_EXECUTION);
User::checkPermission($request, User::PERMISSION_CHORE_TRACK_EXECUTION);
}
$choreExecutionId = $this->getChoresService()->TrackChore($args['choreId'], $trackedTime, $doneBy);
$choreExecutionId = $this->getChoresService()->TrackChore($args['choreId'], $trackedTime, $doneBy, $skipped);
return $this->ApiResponse($response, $this->getDatabase()->chores_log($choreExecutionId));
}
catch (\Exception $ex)
@@ -93,7 +101,7 @@ class ChoresApiController extends BaseApiController
}
}
public function UndoChoreExecution(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UndoChoreExecution(Request $request, Response $response, array $args)
{
try
{
@@ -108,8 +116,48 @@ class ChoresApiController extends BaseApiController
}
}
public function __construct(\DI\Container $container)
public function ChorePrintLabel(Request $request, Response $response, array $args)
{
parent::__construct($container);
try
{
$choreDetails = (object)$this->getChoresService()->GetChoreDetails($args['choreId']);
$webhookData = array_merge([
'chore' => $choreDetails->chore->name,
'grocycode' => (string)(new Grocycode(Grocycode::CHORE, $args['choreId'])),
'details' => $choreDetails,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_RUN_SERVER)
{
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
}
return $this->ApiResponse($response, $webhookData);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function MergeChores(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
try
{
if (filter_var($args['choreIdToKeep'], FILTER_VALIDATE_INT) === false || filter_var($args['choreIdToRemove'], FILTER_VALIDATE_INT) === false)
{
throw new \Exception('Provided {choreIdToKeep} or {choreIdToRemove} is not a valid integer');
}
$this->ApiResponse($response, $this->getChoresService()->MergeChores($args['choreIdToKeep'], $args['choreIdToRemove']));
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}

View File

@@ -2,9 +2,15 @@
namespace Grocy\Controllers;
use Grocy\Helpers\Grocycode;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class ChoresController extends BaseController
{
public function ChoreEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
use GrocycodeTrait;
public function ChoreEditForm(Request $request, Response $response, array $args)
{
$usersService = $this->getUsersService();
$users = $usersService->GetUsersAsDto();
@@ -34,7 +40,7 @@ class ChoresController extends BaseController
}
}
public function ChoresList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ChoresList(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['include_disabled']))
{
@@ -52,28 +58,68 @@ class ChoresController extends BaseController
]);
}
public function ChoresSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ChoresSettings(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'choressettings');
}
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Journal(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['months']) && filter_var($request->getQueryParams()['months'], FILTER_VALIDATE_INT) !== false)
{
$months = $request->getQueryParams()['months'];
$where = "tracked_time > DATE(DATE('now', 'localtime'), '-$months months')";
}
else
{
// Default 1 year
$where = "tracked_time > DATE(DATE('now', 'localtime'), '-12 months')";
}
if (isset($request->getQueryParams()['chore']) && filter_var($request->getQueryParams()['chore'], FILTER_VALIDATE_INT) !== false)
{
$choreId = $request->getQueryParams()['chore'];
$where .= " AND chore_id = $choreId";
}
return $this->renderPage($response, 'choresjournal', [
'choresLog' => $this->getDatabase()->chores_log()->orderBy('tracked_time', 'DESC'),
'choresLog' => $this->getDatabase()->chores_log()->where($where)->orderBy('tracked_time', 'DESC'),
'chores' => $this->getDatabase()->chores()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'users' => $this->getDatabase()->users()->orderBy('username')
'users' => $this->getDatabase()->users()->orderBy('username'),
'userfields' => $this->getUserfieldsService()->GetFields('chores_log'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('chores_log')
]);
}
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Overview(Request $request, Response $response, array $args)
{
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['chores_due_soon_days'];
$chores = $this->getDatabase()->chores()->orderBy('name', 'COLLATE NOCASE');
$currentChores = $this->getChoresService()->GetCurrent();
foreach ($currentChores as $currentChore)
{
if (!empty($currentChore->next_estimated_execution_time))
{
if ($currentChore->next_estimated_execution_time < date('Y-m-d H:i:s'))
{
$currentChore->due_type = 'overdue';
}
elseif ($currentChore->next_estimated_execution_time <= date('Y-m-d 23:59:59'))
{
$currentChore->due_type = 'duetoday';
}
elseif ($nextXDays > 0 && $currentChore->next_estimated_execution_time <= date('Y-m-d H:i:s', strtotime('+' . $nextXDays . ' days')))
{
$currentChore->due_type = 'duesoon';
}
}
}
return $this->renderPage($response, 'choresoverview', [
'chores' => $this->getDatabase()->chores()->orderBy('name', 'COLLATE NOCASE'),
'currentChores' => $this->getChoresService()->GetCurrent(),
'chores' => $chores,
'currentChores' => $currentChores,
'nextXDays' => $nextXDays,
'userfields' => $this->getUserfieldsService()->GetFields('chores'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('chores'),
@@ -81,16 +127,18 @@ class ChoresController extends BaseController
]);
}
public function TrackChoreExecution(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TrackChoreExecution(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'choretracking', [
'chores' => $this->getDatabase()->chores()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'users' => $this->getDatabase()->users()->orderBy('username')
'users' => $this->getDatabase()->users()->orderBy('username'),
'userfields' => $this->getUserfieldsService()->GetFields('chores_log'),
]);
}
public function __construct(\DI\Container $container)
public function ChoreGrocycodeImage(Request $request, Response $response, array $args)
{
parent::__construct($container);
$gc = new Grocycode(Grocycode::CHORE, $args['choreId']);
return $this->ServeGrocycodeImage($request, $response, $gc);
}
}

View File

@@ -2,11 +2,14 @@
namespace Grocy\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class EquipmentController extends BaseController
{
protected $UserfieldsService;
public function EditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function EditForm(Request $request, Response $response, array $args)
{
if ($args['equipmentId'] == 'new')
{
@@ -25,7 +28,7 @@ class EquipmentController extends BaseController
}
}
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Overview(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'equipment', [
'equipment' => $this->getDatabase()->equipment()->orderBy('name', 'COLLATE NOCASE'),
@@ -33,9 +36,4 @@ class EquipmentController extends BaseController
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('equipment')
]);
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}

View File

@@ -2,6 +2,7 @@
namespace Grocy\Controllers;
use DI\Container;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Slim\Exception\HttpException;
@@ -11,17 +12,14 @@ use Throwable;
class ExceptionController extends BaseApiController
{
/**
* @var \Slim\App
*/
private $app;
public function __construct(\Slim\App $app, \DI\Container $container)
public function __construct(\Slim\App $app, Container $container)
{
parent::__construct($container);
$this->app = $app;
}
private $app;
public function __invoke(ServerRequestInterface $request, Throwable $exception, bool $displayErrorDetails, bool $logErrors, bool $logErrorDetails, ?LoggerInterface $logger = null)
{
$response = $this->app->getResponseFactory()->createResponse();
@@ -59,7 +57,10 @@ class ExceptionController extends BaseApiController
if ($exception instanceof HttpNotFoundException)
{
define('GROCY_AUTHENTICATED', false);
if (!defined('GROCY_AUTHENTICATED'))
{
define('GROCY_AUTHENTICATED', false);
}
return $this->renderPage($response->withStatus(404), 'errors/404', [
'exception' => $exception
@@ -74,7 +75,8 @@ class ExceptionController extends BaseApiController
}
return $this->renderPage($response->withStatus(500), 'errors/500', [
'exception' => $exception
'exception' => $exception,
'systemInfo' => $this->getApplicationService()->GetSystemInfo()
]);
}
}

View File

@@ -3,14 +3,22 @@
namespace Grocy\Controllers;
use Grocy\Services\FilesService;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Exception\HttpNotFoundException;
use Slim\Psr7\Stream;
class FilesApiController extends BaseApiController
{
public function DeleteFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function DeleteFile(Request $request, Response $response, array $args)
{
try
{
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
throw new \Exception('Invalid file group');
}
if (IsValidFileName(base64_decode($args['fileName'])))
{
$fileName = base64_decode($args['fileName']);
@@ -20,12 +28,7 @@ class FilesApiController extends BaseApiController
throw new \Exception('Invalid filename');
}
$filePath = $this->getFilesService()->GetFilePath($args['group'], $fileName);
if (file_exists($filePath))
{
unlink($filePath);
}
$this->getFilesService()->DeleteFile($args['group'], $fileName);
return $this->EmptyApiResponse($response);
}
@@ -35,20 +38,24 @@ class FilesApiController extends BaseApiController
}
}
public function ServeFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ServeFile(Request $request, Response $response, array $args)
{
try
{
$fileName = $this->checkFileName($args['fileName']);
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
throw new \Exception('Invalid file group');
}
$fileName = $this->checkFileName($args['fileName']);
$filePath = $this->getFilePath($args['group'], $fileName, $request->getQueryParams());
if (file_exists($filePath))
{
$response->write(file_get_contents($filePath));
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
$response = $response->withHeader('Content-Type', mime_content_type($filePath));
return $response->withHeader('Content-Disposition', 'inline; filename="' . $fileName . '"');
$response = $response->withHeader('Content-Disposition', 'inline; filename="' . $fileName . '"');
return $response->withBody(new Stream(fopen($filePath, 'rb')));
}
else
{
@@ -61,21 +68,25 @@ class FilesApiController extends BaseApiController
}
}
public function ShowFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ShowFile(Request $request, Response $response, array $args)
{
try
{
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
throw new \Exception('Invalid file group');
}
$fileInfo = explode('_', $args['fileName']);
$fileName = $this->checkFileName($fileInfo[1]);
$filePath = $this->getFilePath($args['group'], base64_decode($fileInfo[0]), $request->getQueryParams());
if (file_exists($filePath))
{
$response->write(file_get_contents($filePath));
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
$response = $response->withHeader('Content-Type', mime_content_type($filePath));
return $response->withHeader('Content-Disposition', 'inline; filename="' . $fileName . '"');
$response = $response->withHeader('Content-Disposition', 'inline; filename="' . $fileName . '"');
return $response->withBody(new Stream(fopen($filePath, 'rb')));
}
else
{
@@ -88,14 +99,37 @@ class FilesApiController extends BaseApiController
}
}
public function UploadFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UploadFile(Request $request, Response $response, array $args)
{
try
{
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
throw new \Exception('Invalid file group');
}
$fileName = $this->checkFileName($args['fileName']);
$data = $request->getBody()->getContents();
file_put_contents($this->getFilesService()->GetFilePath($args['group'], $fileName), $data);
$fileHandle = fopen($this->getFilesService()->GetFilePath($args['group'], $fileName), 'xb');
if($fileHandle === false)
{
throw new \Exception("Error while creating file $fileName");
}
// Save the file to disk in chunks of 1 MB
$requestBody = $request->getBody();
while ($data = $requestBody->read(1048576))
{
if (fwrite($fileHandle, $data) === false)
{
throw new \Exception("Error while writing file $fileName");
}
}
if (fclose($fileHandle) === false)
{
throw new \Exception("Error while closing file $fileName");
}
return $this->EmptyApiResponse($response);
}
@@ -105,16 +139,6 @@ class FilesApiController extends BaseApiController
}
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
/**
* @param string $fileName base64-encoded file-name
* @return false|string the decoded file-name
* @throws \Exception if the file-name is invalid.
*/
protected function checkFileName(string $fileName)
{
if (IsValidFileName(base64_decode($fileName)))
@@ -129,16 +153,9 @@ class FilesApiController extends BaseApiController
return $fileName;
}
/**
* @param string $group The group the requested files belongs to.
* @param string $fileName The name of the requested file.
* @param array $queryParams Parameter, e.g. for scaling. Optional.
* @return string
*/
protected function getFilePath(string $group, string $fileName, array $queryParams = [])
{
$forceServeAs = null;
if (isset($queryParams['force_serve_as']) && !empty($queryParams['force_serve_as']))
{
$forceServeAs = $queryParams['force_serve_as'];
@@ -147,14 +164,12 @@ class FilesApiController extends BaseApiController
if ($forceServeAs == FilesService::FILE_SERVE_TYPE_PICTURE)
{
$bestFitHeight = null;
if (isset($queryParams['best_fit_height']) && !empty($queryParams['best_fit_height']) && is_numeric($queryParams['best_fit_height']))
{
$bestFitHeight = $queryParams['best_fit_height'];
}
$bestFitWidth = null;
if (isset($queryParams['best_fit_width']) && !empty($queryParams['best_fit_width']) && is_numeric($queryParams['best_fit_width']))
{
$bestFitWidth = $queryParams['best_fit_width'];

View File

@@ -3,13 +3,33 @@
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Slim\Exception\HttpBadRequestException;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class GenericEntityApiController extends BaseApiController
{
public function AddObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function AddObject(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
if ($args['entity'] == 'shopping_list' || $args['entity'] == 'shopping_lists')
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
}
elseif ($args['entity'] == 'recipes' || $args['entity'] == 'recipes_pos' || $args['entity'] == 'recipes_nestings')
{
User::checkPermission($request, User::PERMISSION_RECIPES);
}
elseif ($args['entity'] == 'meal_plan')
{
User::checkPermission($request, User::PERMISSION_RECIPES_MEALPLAN);
}
elseif ($args['entity'] == 'equipment')
{
User::checkPermission($request, User::PERMISSION_EQUIPMENT);
}
else
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
}
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoEdit($args['entity']))
{
@@ -29,10 +49,16 @@ class GenericEntityApiController extends BaseApiController
$newRow = $this->getDatabase()->{$args['entity']}()->createRow($requestBody);
$newRow->save();
$success = $newRow->isClean();
$newObjectId = $this->getDatabase()->lastInsertId();
// TODO: This should be better done somehow in StockService
if ($args['entity'] == 'products' && boolval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount')))
{
$this->getStockService()->AddMissingProductsToShoppingList($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id'));
}
return $this->ApiResponse($response, [
'created_object_id' => $this->getDatabase()->lastInsertId()
'created_object_id' => $newObjectId
]);
}
catch (\Exception $ex)
@@ -46,9 +72,32 @@ class GenericEntityApiController extends BaseApiController
}
}
public function DeleteObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function DeleteObject(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
if ($args['entity'] == 'shopping_list' || $args['entity'] == 'shopping_lists')
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_DELETE);
}
elseif ($args['entity'] == 'recipes' || $args['entity'] == 'recipes_pos' || $args['entity'] == 'recipes_nestings')
{
User::checkPermission($request, User::PERMISSION_RECIPES);
}
elseif ($args['entity'] == 'meal_plan')
{
User::checkPermission($request, User::PERMISSION_RECIPES_MEALPLAN);
}
elseif ($args['entity'] == 'equipment')
{
User::checkPermission($request, User::PERMISSION_EQUIPMENT);
}
elseif ($args['entity'] == 'api_keys')
{
// Always allowed
}
else
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
}
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoDelete($args['entity']))
{
@@ -58,8 +107,12 @@ class GenericEntityApiController extends BaseApiController
}
$row = $this->getDatabase()->{$args['entity']}($args['objectId']);
if ($row == null)
{
return $this->GenericErrorResponse($response, 'Object not found', 400);
}
$row->delete();
$success = $row->isClean();
return $this->EmptyApiResponse($response);
}
@@ -69,9 +122,28 @@ class GenericEntityApiController extends BaseApiController
}
}
public function EditObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function EditObject(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
if ($args['entity'] == 'shopping_list' || $args['entity'] == 'shopping_lists')
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
}
elseif ($args['entity'] == 'recipes' || $args['entity'] == 'recipes_pos' || $args['entity'] == 'recipes_nestings')
{
User::checkPermission($request, User::PERMISSION_RECIPES);
}
elseif ($args['entity'] == 'meal_plan')
{
User::checkPermission($request, User::PERMISSION_RECIPES_MEALPLAN);
}
elseif ($args['entity'] == 'equipment')
{
User::checkPermission($request, User::PERMISSION_EQUIPMENT);
}
else
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
}
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoEdit($args['entity']))
{
@@ -90,8 +162,18 @@ class GenericEntityApiController extends BaseApiController
}
$row = $this->getDatabase()->{$args['entity']}($args['objectId']);
if ($row == null)
{
return $this->GenericErrorResponse($response, 'Object not found', 400);
}
$row->update($requestBody);
$success = $row->isClean();
// TODO: This should be better done somehow in StockService
if ($args['entity'] == 'products' && boolval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount')))
{
$this->getStockService()->AddMissingProductsToShoppingList($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id'));
}
return $this->EmptyApiResponse($response);
}
@@ -106,66 +188,80 @@ class GenericEntityApiController extends BaseApiController
}
}
public function GetObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetObject(Request $request, Response $response, array $args)
{
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoListing($args['entity']))
{
$userfields = $this->getUserfieldsService()->GetValues($args['entity'], $args['objectId']);
if (count($userfields) === 0)
{
$userfields = null;
}
$object = $this->getDatabase()->{$args['entity']}($args['objectId']);
if ($object == null)
{
return $this->GenericErrorResponse($response, 'Object not found', 404);
}
$object['userfields'] = $userfields;
return $this->ApiResponse($response, $object);
}
else
if (!$this->IsValidExposedEntity($args['entity']) || $this->IsEntityWithNoListing($args['entity']))
{
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
}
$object = $this->getDatabase()->{$args['entity']}($args['objectId']);
if ($object == null)
{
return $this->GenericErrorResponse($response, 'Object not found', 404);
}
// TODO: Handle this somehow more generically
$referencingId = $args['objectId'];
if ($args['entity'] == 'stock')
{
$referencingId = $object->stock_id;
}
$userfields = $this->getUserfieldsService()->GetValues($args['entity'], $referencingId);
if (count($userfields) === 0)
{
$userfields = null;
}
$object['userfields'] = $userfields;
return $this->ApiResponse($response, $object);
}
public function GetObjects(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetObjects(Request $request, Response $response, array $args)
{
$objects = $this->queryData($this->getDatabase()->{$args['entity']}(), $request->getQueryParams());
$allUserfields = $this->getUserfieldsService()->GetAllValues($args['entity']);
foreach ($objects as $object)
if (!$this->IsValidExposedEntity($args['entity']) || $this->IsEntityWithNoListing($args['entity']))
{
$userfields = FindAllObjectsInArrayByPropertyValue($allUserfields, 'object_id', $object->id);
$userfieldKeyValuePairs = null;
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
}
if (count($userfields) > 0)
$objects = $this->queryData($this->getDatabase()->{$args['entity']}(), $request->getQueryParams());
$userfields = $this->getUserfieldsService()->GetFields($args['entity']);
if (count($userfields) > 0)
{
$allUserfieldValues = $this->getUserfieldsService()->GetAllValues($args['entity']);
foreach ($objects as $object)
{
$userfieldKeyValuePairs = null;
foreach ($userfields as $userfield)
{
$userfieldKeyValuePairs[$userfield->name] = $userfield->value;
// TODO: Handle this somehow more generically
$userfieldReference = 'id';
if ($args['entity'] == 'stock')
{
$userfieldReference = 'stock_id';
}
$value = FindObjectInArrayByPropertyValue(FindAllObjectsInArrayByPropertyValue($allUserfieldValues, 'object_id', $object->{$userfieldReference}), 'name', $userfield->name);
if ($value)
{
$userfieldKeyValuePairs[$userfield->name] = $value->value;
}
else
{
$userfieldKeyValuePairs[$userfield->name] = null;
}
}
$object->userfields = $userfieldKeyValuePairs;
}
$object->userfields = $userfieldKeyValuePairs;
}
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoListing($args['entity']))
{
return $this->ApiResponse($response, $objects);
}
else
{
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
}
return $this->ApiResponse($response, $objects);
}
public function GetUserfields(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetUserfields(Request $request, Response $response, array $args)
{
try
{
@@ -177,7 +273,7 @@ class GenericEntityApiController extends BaseApiController
}
}
public function SetUserfields(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function SetUserfields(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
@@ -199,33 +295,28 @@ class GenericEntityApiController extends BaseApiController
}
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
private function IsEntityWithEditRequiresAdmin($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityEditRequiresAdmin->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityEditRequiresAdmin->enum);
}
private function IsEntityWithNoListing($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityNoListing->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityNoListing->enum);
}
private function IsEntityWithNoEdit($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityNoEdit->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityNoEdit->enum);
}
private function IsEntityWithNoDelete($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityNoDelete->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityNoDelete->enum);
}
private function IsValidExposedEntity($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntity->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntity->enum);
}
}

View File

@@ -2,16 +2,19 @@
namespace Grocy\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class GenericEntityController extends BaseController
{
public function UserentitiesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UserentitiesList(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'userentities', [
'userentities' => $this->getDatabase()->userentities()->orderBy('name', 'COLLATE NOCASE')
]);
}
public function UserentityEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UserentityEditForm(Request $request, Response $response, array $args)
{
if ($args['userentityId'] == 'new')
{
@@ -28,7 +31,7 @@ class GenericEntityController extends BaseController
}
}
public function UserfieldEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UserfieldEditForm(Request $request, Response $response, array $args)
{
if ($args['userfieldId'] == 'new')
{
@@ -49,7 +52,7 @@ class GenericEntityController extends BaseController
}
}
public function UserfieldsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UserfieldsList(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'userfields', [
'userfields' => $this->getUserfieldsService()->GetAllFields(),
@@ -57,7 +60,7 @@ class GenericEntityController extends BaseController
]);
}
public function UserobjectEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UserobjectEditForm(Request $request, Response $response, array $args)
{
$userentity = $this->getDatabase()->userentities()->where('name = :1', $args['userentityName'])->fetch();
@@ -80,7 +83,7 @@ class GenericEntityController extends BaseController
}
}
public function UserobjectsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UserobjectsList(Request $request, Response $response, array $args)
{
$userentity = $this->getDatabase()->userentities()->where('name = :1', $args['userentityName'])->fetch();
@@ -91,9 +94,4 @@ class GenericEntityController extends BaseController
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('userentity-' . $args['userentityName'])
]);
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Grocy\Controllers;
use Grocy\Helpers\Grocycode;
use jucksearm\barcode\lib\BarcodeFactory;
use jucksearm\barcode\lib\DatamatrixFactory;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
trait GrocycodeTrait
{
public function ServeGrocycodeImage(Request $request, Response $response, Grocycode $grocycode)
{
$size = $request->getQueryParam('size', null);
if (GROCY_GROCYCODE_TYPE == '2D')
{
$png = (new DatamatrixFactory())->setCode((string)$grocycode)->setSize($size)->getDatamatrixPngData();
}
else
{
$png = (new BarcodeFactory())->setType('C128')->setCode((string)$grocycode)->setHeight($size)->getBarcodePngData();
}
$isDownload = $request->getQueryParam('download', false);
if ($isDownload)
{
$response = $response->withHeader('Content-Type', 'application/octet-stream')
->withHeader('Content-Disposition', 'attachment; filename=Grocycode.png')
->withHeader('Content-Length', strlen($png))
->withHeader('Cache-Control', 'no-cache')
->withHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
}
else
{
$response = $response->withHeader('Content-Type', 'image/png')
->withHeader('Content-Length', strlen($png))
->withHeader('Cache-Control', 'no-cache')
->withHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
}
$response->getBody()->write($png);
return $response;
}
}

View File

@@ -3,29 +3,26 @@
namespace Grocy\Controllers;
use Grocy\Services\SessionService;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class LoginController extends BaseController
{
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
public function LoginPage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function LoginPage(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'login');
}
public function Logout(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Logout(Request $request, Response $response, array $args)
{
$this->getSessionService()->RemoveSession($_COOKIE[SessionService::SESSION_COOKIE_NAME]);
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl('/'));
}
public function ProcessLogin(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProcessLogin(Request $request, Response $response, array $args)
{
$authMiddlewareClass = GROCY_AUTH_CLASS;
if ($authMiddlewareClass::ProcessLogin($this->GetParsedAndFilteredRequestBody($request)))
if ($authMiddlewareClass::ProcessLogin($request->getParsedBody()))
{
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl('/'));
}

View File

@@ -3,30 +3,47 @@
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Grocy\Services\ApiKeyService;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class OpenApiController extends BaseApiController
{
public function ApiKeysList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ApiKeysList(Request $request, Response $response, array $args)
{
$selectedKeyId = -1;
if (isset($request->getQueryParams()['key']) && filter_var($request->getQueryParams()['key'], FILTER_VALIDATE_INT))
{
$selectedKeyId = $request->getQueryParams()['key'];
}
$apiKeys = $this->getDatabase()->api_keys();
if (!User::hasPermissions(User::PERMISSION_ADMIN))
{
$apiKeys = $apiKeys->where('user_id', GROCY_USER_ID);
}
return $this->renderPage($response, 'manageapikeys', [
'apiKeys' => $apiKeys,
'users' => $this->getDatabase()->users()
'users' => $this->getDatabase()->users(),
'selectedKeyId' => $selectedKeyId
]);
}
public function CreateNewApiKey(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function CreateNewApiKey(Request $request, Response $response, array $args)
{
$newApiKey = $this->getApiKeyService()->CreateApiKey();
$description = null;
if (isset($request->getQueryParams()['description']))
{
$description = $request->getQueryParams()['description'];
}
$newApiKey = $this->getApiKeyService()->CreateApiKey(ApiKeyService::API_KEY_TYPE_DEFAULT, $description);
$newApiKeyId = $this->getApiKeyService()->GetApiKeyId($newApiKey);
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl("/manageapikeys?CreatedApiKeyId=$newApiKeyId"));
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl("/manageapikeys?key=$newApiKeyId"));
}
public function DocumentationSpec(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function DocumentationSpec(Request $request, Response $response, array $args)
{
$spec = $this->getOpenApiSpec();
@@ -36,43 +53,60 @@ class OpenApiController extends BaseApiController
$spec->info->description = str_replace('PlaceHolderManageApiKeysUrl', $this->AppContainer->get('UrlManager')->ConstructUrl('/manageapikeys'), $spec->info->description);
$spec->servers[0]->url = $this->AppContainer->get('UrlManager')->ConstructUrl('/api');
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotEditable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
$spec->components->schemas->ExposedEntity_IncludingUserEntities = clone $spec->components->schemas->StringEnumTemplate;
;
foreach ($this->getUserfieldsService()->GetEntities() as $userEntity)
{
if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoEdit->enum))
{
array_push($spec->components->internalSchemas->ExposedEntity_NotIncludingNotEditable->enum, $value);
}
array_push($spec->components->schemas->ExposedEntity_IncludingUserEntities->enum, $userEntity);
}
sort($spec->components->schemas->ExposedEntity_IncludingUserEntities->enum);
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotDeletable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
$spec->components->schemas->ExposedEntity_NotIncludingNotEditable = clone $spec->components->schemas->StringEnumTemplate;
foreach ($spec->components->schemas->ExposedEntity->enum as $value)
{
if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoDelete->enum))
if (!in_array($value, $spec->components->schemas->ExposedEntityNoEdit->enum))
{
array_push($spec->components->internalSchemas->ExposedEntity_NotIncludingNotDeletable->enum, $value);
array_push($spec->components->schemas->ExposedEntity_NotIncludingNotEditable->enum, $value);
}
}
sort($spec->components->schemas->ExposedEntity_NotIncludingNotEditable->enum);
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotListable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
$spec->components->schemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable = clone $spec->components->schemas->StringEnumTemplate;
foreach ($spec->components->schemas->ExposedEntity_IncludingUserEntities->enum as $value)
{
if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoListing->enum))
if (!in_array($value, $spec->components->schemas->ExposedEntityNoEdit->enum))
{
array_push($spec->components->internalSchemas->ExposedEntity_NotIncludingNotListable->enum, $value);
array_push($spec->components->schemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable->enum, $value);
}
}
array_push($spec->components->schemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable->enum, 'stock'); // TODO: Don't hardcode this here - stock entries are normally not editable, but the corresponding Userfields are
sort($spec->components->schemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable->enum);
$spec->components->schemas->ExposedEntity_NotIncludingNotDeletable = clone $spec->components->schemas->StringEnumTemplate;
foreach ($spec->components->schemas->ExposedEntity->enum as $value)
{
if (!in_array($value, $spec->components->schemas->ExposedEntityNoDelete->enum))
{
array_push($spec->components->schemas->ExposedEntity_NotIncludingNotDeletable->enum, $value);
}
}
sort($spec->components->schemas->ExposedEntity_NotIncludingNotDeletable->enum);
$spec->components->schemas->ExposedEntity_NotIncludingNotListable = clone $spec->components->schemas->StringEnumTemplate;
foreach ($spec->components->schemas->ExposedEntity->enum as $value)
{
if (!in_array($value, $spec->components->schemas->ExposedEntityNoListing->enum))
{
array_push($spec->components->schemas->ExposedEntity_NotIncludingNotListable->enum, $value);
}
}
sort($spec->components->schemas->ExposedEntity_NotIncludingNotListable->enum);
return $this->ApiResponse($response, $spec);
}
public function DocumentationUi(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function DocumentationUi(Request $request, Response $response, array $args)
{
return $this->render($response, 'openapiui');
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class PrintApiController extends BaseApiController
{
public function PrintShoppingListThermal(Request $request, Response $response, array $args)
{
try
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST);
$params = $request->getQueryParams();
$listId = 1;
if (isset($params['list']))
{
$listId = $params['list'];
}
$printHeader = true;
if (isset($params['printHeader']))
{
$printHeader = ($params['printHeader'] === 'true');
}
$items = $this->getStockService()->GetShoppinglistInPrintableStrings($listId);
return $this->ApiResponse($response, $this->getPrintService()->printShoppingList($printHeader, $items));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}

View File

@@ -1,70 +1,108 @@
<?php
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
class RecipesApiController extends BaseApiController
{
public function AddNotFulfilledProductsToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$excludedProductIds = null;
if ($requestBody !== null && array_key_exists('excludedProductIds', $requestBody))
{
$excludedProductIds = $requestBody['excludedProductIds'];
}
$this->getRecipesService()->AddNotFulfilledProductsToShoppingList($args['recipeId'], $excludedProductIds);
return $this->EmptyApiResponse($response);
}
public function ConsumeRecipe(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_CONSUME);
try
{
$this->getRecipesService()->ConsumeRecipe($args['recipeId']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function GetRecipeFulfillment(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
if (!isset($args['recipeId']))
{
return $this->FilteredApiResponse($response, $this->getRecipesService()->GetRecipesResolved(), $request->getQueryParams());
}
$recipeResolved = FindObjectInArrayByPropertyValue($this->getRecipesService()->GetRecipesResolved(), 'recipe_id', $args['recipeId']);
if (!$recipeResolved)
{
throw new \Exception('Recipe does not exist');
}
else
{
return $this->ApiResponse($response, $recipeResolved);
}
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}
<?php
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Grocy\Helpers\WebhookRunner;
use Grocy\Helpers\Grocycode;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class RecipesApiController extends BaseApiController
{
public function AddNotFulfilledProductsToShoppingList(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$excludedProductIds = null;
if ($requestBody !== null && array_key_exists('excludedProductIds', $requestBody))
{
$excludedProductIds = $requestBody['excludedProductIds'];
}
$this->getRecipesService()->AddNotFulfilledProductsToShoppingList($args['recipeId'], $excludedProductIds);
return $this->EmptyApiResponse($response);
}
public function ConsumeRecipe(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_CONSUME);
try
{
$this->getRecipesService()->ConsumeRecipe($args['recipeId']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function GetRecipeFulfillment(Request $request, Response $response, array $args)
{
try
{
if (!isset($args['recipeId']))
{
return $this->FilteredApiResponse($response, $this->getRecipesService()->GetRecipesResolved(), $request->getQueryParams());
}
$recipeResolved = FindObjectInArrayByPropertyValue($this->getRecipesService()->GetRecipesResolved(), 'recipe_id', $args['recipeId']);
if (!$recipeResolved)
{
throw new \Exception('Recipe does not exist');
}
else
{
return $this->ApiResponse($response, $recipeResolved);
}
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function CopyRecipe(Request $request, Response $response, array $args)
{
try
{
return $this->ApiResponse($response, [
'created_object_id' => $this->getRecipesService()->CopyRecipe($args['recipeId'])
]);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function RecipePrintLabel(Request $request, Response $response, array $args)
{
try
{
$recipe = $this->getDatabase()->recipes()->where('id', $args['recipeId'])->fetch();
$webhookData = array_merge([
'recipe' => $recipe->name,
'grocycode' => (string)(new Grocycode(Grocycode::RECIPE, $args['recipeId'])),
'details' => $recipe
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_RUN_SERVER)
{
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
}
return $this->ApiResponse($response, $webhookData);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}

View File

@@ -3,16 +3,33 @@
namespace Grocy\Controllers;
use Grocy\Services\RecipesService;
use Grocy\Helpers\Grocycode;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class RecipesController extends BaseController
{
public function MealPlan(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
use GrocycodeTrait;
public function MealPlan(Request $request, Response $response, array $args)
{
$start = date('Y-m-d');
if (isset($request->getQueryParams()['start']) && IsIsoDate($request->getQueryParams()['start']))
{
$start = $request->getQueryParams()['start'];
}
$days = 6;
if (isset($request->getQueryParams()['days']) && filter_var($request->getQueryParams()['days'], FILTER_VALIDATE_INT) !== false)
{
$days = $request->getQueryParams()['days'];
}
$mealPlanWhereTimespan = "day BETWEEN DATE('$start', '-$days days') AND DATE('$start', '+$days days')";
$recipes = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll();
$events = [];
foreach ($this->getDatabase()->meal_plan() as $mealPlanEntry)
foreach ($this->getDatabase()->meal_plan()->where($mealPlanWhereTimespan) as $mealPlanEntry)
{
$recipe = FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id']);
$title = '';
@@ -23,7 +40,6 @@ class RecipesController extends BaseController
}
$productDetails = null;
if ($mealPlanEntry['product_id'] !== null)
{
$productDetails = $this->getStockService()->GetProductDetails($mealPlanEntry['product_id']);
@@ -41,24 +57,33 @@ class RecipesController extends BaseController
];
}
$weekRecipe = $this->getDatabase()->recipes()->where("type = 'mealplan-week' AND name = LTRIM(STRFTIME('%Y-%W', DATE('$start')), '0')")->fetch();
$weekRecipeId = 0;
if ($weekRecipe != null)
{
$weekRecipeId = $weekRecipe->id;
}
return $this->renderPage($response, 'mealplan', [
'fullcalendarEventSources' => $events,
'recipes' => $recipes,
'internalRecipes' => $this->getDatabase()->recipes()->whereNot('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll(),
'recipesResolved' => $this->getRecipesService()->GetRecipesResolved(),
'internalRecipes' => $this->getDatabase()->recipes()->where("id IN (SELECT recipe_id FROM meal_plan_internal_recipe_relation WHERE $mealPlanWhereTimespan) OR id = $weekRecipeId")->fetchAll(),
'recipesResolved' => $this->getRecipesService()->GetRecipesResolved("recipe_id IN (SELECT recipe_id FROM meal_plan_internal_recipe_relation WHERE $mealPlanWhereTimespan) OR recipe_id = $weekRecipeId"),
'products' => $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(),
'mealplanSections' => $this->getDatabase()->meal_plan_sections()->orderBy('sort_number'),
'usedMealplanSections' => $this->getDatabase()->meal_plan_sections()->where("id IN (SELECT section_id FROM meal_plan WHERE $mealPlanWhereTimespan)")->orderBy('sort_number'),
'weekRecipe' => $weekRecipe
]);
}
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Overview(Request $request, Response $response, array $args)
{
$recipes = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name', 'COLLATE NOCASE');
$recipesResolved = $this->getRecipesService()->GetRecipesResolved();
$recipesResolved = $this->getRecipesService()->GetRecipesResolved('recipe_id > 0');
$selectedRecipe = null;
if (isset($request->getQueryParams()['recipe']))
{
$selectedRecipe = $this->getDatabase()->recipes($request->getQueryParams()['recipe']);
@@ -72,29 +97,27 @@ class RecipesController extends BaseController
}
}
$selectedRecipePositionsResolved = null;
$totalCosts = null;
$totalCalories = null;
if ($selectedRecipe)
{
$selectedRecipePositionsResolved = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id = :1 AND is_nested_recipe_pos = 0', $selectedRecipe->id)->orderBy('ingredient_group', 'ASC', 'product_group', 'ASC');
$totalCosts = FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->costs;
$totalCalories = FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->calories;
}
$renderArray = [
$viewData = [
'recipes' => $recipes,
'recipesResolved' => $recipesResolved,
'recipePositionsResolved' => $this->getDatabase()->recipes_pos_resolved()->where('recipe_type', RecipesService::RECIPE_TYPE_NORMAL),
'recipePositionsResolved' => $this->getDatabase()->recipes_pos_resolved()->where('recipe_id', $selectedRecipe->id),
'selectedRecipe' => $selectedRecipe,
'selectedRecipePositionsResolved' => $selectedRecipePositionsResolved,
'products' => $this->getDatabase()->products(),
'quantityUnits' => $this->getDatabase()->quantity_units(),
'userfields' => $this->getUserfieldsService()->GetFields('recipes'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('recipes'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(),
'selectedRecipeTotalCosts' => $totalCosts,
'selectedRecipeTotalCalories' => $totalCalories
'selectedRecipeTotalCalories' => $totalCalories,
'mealplanSections' => $this->getDatabase()->meal_plan_sections()->orderBy('sort_number')
];
if ($selectedRecipe)
@@ -103,28 +126,37 @@ class RecipesController extends BaseController
$includedRecipeIdsAbsolute = [];
$includedRecipeIdsAbsolute[] = $selectedRecipe->id;
foreach ($selectedRecipeSubRecipes as $subRecipe)
{
$includedRecipeIdsAbsolute[] = $subRecipe->id;
}
// TODO: Why not directly use recipes_pos_resolved for all recipe positions here (parent and child)?
// This view already correctly recolves child recipe amounts...
$allRecipePositions = [];
foreach ($includedRecipeIdsAbsolute as $id)
{
$allRecipePositions[$id] = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id = :1 AND is_nested_recipe_pos = 0', $id)->orderBy('ingredient_group', 'ASC', 'product_group', 'ASC');
foreach ($allRecipePositions[$id] as $pos)
{
if ($id != $selectedRecipe->id)
{
$pos2 = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id = :1 AND recipe_pos_id = :2 AND is_nested_recipe_pos = 1', $selectedRecipe->id, $pos->recipe_pos_id)->fetch();
$pos->recipe_amount = $pos2->recipe_amount;
$pos->missing_amount = $pos2->missing_amount;
}
}
}
$renderArray['selectedRecipeSubRecipes'] = $selectedRecipeSubRecipes;
$renderArray['includedRecipeIdsAbsolute'] = $includedRecipeIdsAbsolute;
$renderArray['allRecipePositions'] = $allRecipePositions;
$viewData['selectedRecipeSubRecipes'] = $selectedRecipeSubRecipes;
$viewData['includedRecipeIdsAbsolute'] = $includedRecipeIdsAbsolute;
$viewData['allRecipePositions'] = $allRecipePositions;
}
return $this->renderPage($response, 'recipes', $renderArray);
return $this->renderPage($response, 'recipes', $viewData);
}
public function RecipeEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function RecipeEditForm(Request $request, Response $response, array $args)
{
$recipeId = $args['recipeId'];
@@ -134,16 +166,14 @@ class RecipesController extends BaseController
'mode' => $recipeId == 'new' ? 'create' : 'edit',
'products' => $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units(),
'recipePositionsResolved' => $this->getRecipesService()->GetRecipesPosResolved(),
'recipesResolved' => $this->getRecipesService()->GetRecipesResolved(),
'recipes' => $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name', 'COLLATE NOCASE'),
'recipeNestings' => $this->getDatabase()->recipes_nestings()->where('recipe_id', $recipeId),
'userfields' => $this->getUserfieldsService()->GetFields('recipes'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved()
]);
}
public function RecipePosEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function RecipePosEditForm(Request $request, Response $response, array $args)
{
if ($args['recipePosId'] == 'new')
{
@@ -151,9 +181,10 @@ class RecipesController extends BaseController
'mode' => 'create',
'recipe' => $this->getDatabase()->recipes($args['recipeId']),
'recipePos' => new \stdClass(),
'products' => $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE'),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved()
]);
}
else
@@ -163,19 +194,45 @@ class RecipesController extends BaseController
'recipe' => $this->getDatabase()->recipes($args['recipeId']),
'recipePos' => $this->getDatabase()->recipes_pos($args['recipePosId']),
'products' => $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE'),
'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved()
]);
}
}
public function RecipesSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function RecipesSettings(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'recipessettings');
}
public function __construct(\DI\Container $container)
public function MealPlanSectionEditForm(Request $request, Response $response, array $args)
{
parent::__construct($container);
if ($args['sectionId'] == 'new')
{
return $this->renderPage($response, 'mealplansectionform', [
'mode' => 'create'
]);
}
else
{
return $this->renderPage($response, 'mealplansectionform', [
'mealplanSection' => $this->getDatabase()->meal_plan_sections($args['sectionId']),
'mode' => 'edit'
]);
}
}
public function MealPlanSectionsList(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'mealplansections', [
'mealplanSections' => $this->getDatabase()->meal_plan_sections()->where('id > 0')->orderBy('sort_number')
]);
}
public function RecipeGrocycodeImage(Request $request, Response $response, array $args)
{
$gc = new Grocycode(Grocycode::RECIPE, $args['recipeId']);
return $this->ServeGrocycodeImage($request, $response, $gc);
}
}

View File

@@ -4,10 +4,14 @@ namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Grocy\Services\StockService;
use Grocy\Helpers\WebhookRunner;
use Grocy\Helpers\Grocycode;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class StockApiController extends BaseApiController
{
public function AddMissingProductsToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function AddMissingProductsToShoppingList(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
@@ -31,7 +35,7 @@ class StockApiController extends BaseApiController
}
}
public function AddOverdueProductsToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function AddOverdueProductsToShoppingList(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
@@ -55,7 +59,7 @@ class StockApiController extends BaseApiController
}
}
public function AddExpiredProductsToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function AddExpiredProductsToShoppingList(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
@@ -79,7 +83,7 @@ class StockApiController extends BaseApiController
}
}
public function AddProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function AddProduct(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_PURCHASE);
@@ -98,48 +102,55 @@ class StockApiController extends BaseApiController
}
$bestBeforeDate = null;
if (array_key_exists('best_before_date', $requestBody) && IsIsoDate($requestBody['best_before_date']))
{
$bestBeforeDate = $requestBody['best_before_date'];
}
$purchasedDate = date('Y-m-d');
if (array_key_exists('purchased_date', $requestBody) && IsIsoDate($requestBody['purchased_date']))
{
$purchasedDate = $requestBody['purchased_date'];
}
$price = null;
if (array_key_exists('price', $requestBody) && is_numeric($requestBody['price']))
{
$price = $requestBody['price'];
}
$locationId = null;
if (array_key_exists('location_id', $requestBody) && is_numeric($requestBody['location_id']))
{
$locationId = $requestBody['location_id'];
}
$shoppingLocationId = null;
if (array_key_exists('shopping_location_id', $requestBody) && is_numeric($requestBody['shopping_location_id']))
{
$shoppingLocationId = $requestBody['shopping_location_id'];
}
$transactionType = StockService::TRANSACTION_TYPE_PURCHASE;
if (array_key_exists('transaction_type', $requestBody) && !empty($requestBody['transactiontype']))
if (array_key_exists('transaction_type', $requestBody) && !empty($requestBody['transaction_type']))
{
$transactionType = $requestBody['transactiontype'];
$transactionType = $requestBody['transaction_type'];
}
$transactionId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, $purchasedDate, $price, $locationId, $shoppingLocationId);
$stockLabelType = 0;
if (array_key_exists('stock_label_type', $requestBody) && is_numeric($requestBody['stock_label_type']))
{
$stockLabelType = intval($requestBody['stock_label_type']);
}
$note = null;
if (array_key_exists('note', $requestBody))
{
$note = $requestBody['note'];
}
$transactionId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, $purchasedDate, $price, $locationId, $shoppingLocationId, $unusedTransactionId, $stockLabelType, false, $note);
$args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args);
}
@@ -149,7 +160,7 @@ class StockApiController extends BaseApiController
}
}
public function AddProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function AddProductByBarcode(Request $request, Response $response, array $args)
{
try
{
@@ -162,7 +173,7 @@ class StockApiController extends BaseApiController
}
}
public function AddProductToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function AddProductToShoppingList(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
@@ -172,6 +183,7 @@ class StockApiController extends BaseApiController
$listId = 1;
$amount = 1;
$quId = -1;
$productId = null;
$note = null;
@@ -195,12 +207,17 @@ class StockApiController extends BaseApiController
$note = $requestBody['note'];
}
if (array_key_exists('qu_id', $requestBody) && !empty($requestBody['qu_id']))
{
$quId = $requestBody['qu_id'];
}
if ($productId == null)
{
throw new \Exception('No product id was supplied');
}
$this->getStockService()->AddProductToShoppingList($productId, $amount, $note, $listId);
$this->getStockService()->AddProductToShoppingList($productId, $amount, $quId, $note, $listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -209,7 +226,7 @@ class StockApiController extends BaseApiController
}
}
public function ClearShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ClearShoppingList(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_DELETE);
@@ -218,13 +235,18 @@ class StockApiController extends BaseApiController
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$listId = 1;
if (array_key_exists('list_id', $requestBody) && !empty($requestBody['list_id']) && is_numeric($requestBody['list_id']))
{
$listId = intval($requestBody['list_id']);
}
$this->getStockService()->ClearShoppingList($listId);
$doneOnly = false;
if (array_key_exists('done_only', $requestBody) && filter_var($requestBody['done_only'], FILTER_VALIDATE_BOOLEAN) !== false)
{
$doneOnly = boolval($requestBody['done_only']);
}
$this->getStockService()->ClearShoppingList($listId, $doneOnly);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -233,7 +255,7 @@ class StockApiController extends BaseApiController
}
}
public function ConsumeProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ConsumeProduct(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_CONSUME);
@@ -304,11 +326,23 @@ class StockApiController extends BaseApiController
}
}
public function ConsumeProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ConsumeProductByBarcode(Request $request, Response $response, array $args)
{
try
{
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
if (Grocycode::Validate($args['barcode']))
{
$gc = new Grocycode($args['barcode']);
if ($gc->GetExtraData())
{
$requestBody = $request->getParsedBody();
$requestBody['stock_entry_id'] = $gc->GetExtraData()[0];
$request = $request->withParsedBody($requestBody);
}
}
return $this->ConsumeProduct($request, $response, $args);
}
catch (\Exception $ex)
@@ -317,12 +351,12 @@ class StockApiController extends BaseApiController
}
}
public function CurrentStock(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function CurrentStock(Request $request, Response $response, array $args)
{
return $this->ApiResponse($response, $this->getStockService()->GetCurrentStock());
}
public function CurrentVolatileStock(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function CurrentVolatileStock(Request $request, Response $response, array $args)
{
$nextXDays = 5;
@@ -343,7 +377,7 @@ class StockApiController extends BaseApiController
]);
}
public function EditStockEntry(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function EditStockEntry(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_EDIT);
@@ -362,34 +396,36 @@ class StockApiController extends BaseApiController
}
$bestBeforeDate = null;
if (array_key_exists('best_before_date', $requestBody) && IsIsoDate($requestBody['best_before_date']))
{
$bestBeforeDate = $requestBody['best_before_date'];
}
$price = null;
if (array_key_exists('price', $requestBody) && is_numeric($requestBody['price']))
{
$price = $requestBody['price'];
}
$locationId = null;
if (array_key_exists('location_id', $requestBody) && is_numeric($requestBody['location_id']))
{
$locationId = $requestBody['location_id'];
}
$shoppingLocationId = null;
if (array_key_exists('shopping_location_id', $requestBody) && is_numeric($requestBody['shopping_location_id']))
{
$shoppingLocationId = $requestBody['shopping_location_id'];
}
$transactionId = $this->getStockService()->EditStockEntry($args['entryId'], $requestBody['amount'], $bestBeforeDate, $locationId, $shoppingLocationId, $price, $requestBody['open'], $requestBody['purchased_date']);
$note = null;
if (array_key_exists('note', $requestBody))
{
$note = $requestBody['note'];
}
$transactionId = $this->getStockService()->EditStockEntry($args['entryId'], $requestBody['amount'], $bestBeforeDate, $locationId, $shoppingLocationId, $price, $requestBody['open'], $requestBody['purchased_date'], $note);
$args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args);
}
@@ -399,14 +435,13 @@ class StockApiController extends BaseApiController
}
}
public function ExternalBarcodeLookup(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ExternalBarcodeLookup(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
try
{
$addFoundProduct = false;
if (isset($request->getQueryParams()['add']) && ($request->getQueryParams()['add'] === 'true' || $request->getQueryParams()['add'] === 1))
{
$addFoundProduct = true;
@@ -420,7 +455,7 @@ class StockApiController extends BaseApiController
}
}
public function InventoryProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function InventoryProduct(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_INVENTORY);
@@ -468,7 +503,19 @@ class StockApiController extends BaseApiController
$shoppingLocationId = $requestBody['shopping_location_id'];
}
$transactionId = $this->getStockService()->InventoryProduct($args['productId'], $requestBody['new_amount'], $bestBeforeDate, $locationId, $price, $shoppingLocationId, $purchasedDate);
$stockLabelType = 0;
if (array_key_exists('stock_label_type', $requestBody) && is_numeric($requestBody['stock_label_type']))
{
$stockLabelType = intval($requestBody['stock_label_type']);
}
$note = null;
if (array_key_exists('note', $requestBody))
{
$note = $requestBody['note'];
}
$transactionId = $this->getStockService()->InventoryProduct($args['productId'], $requestBody['new_amount'], $bestBeforeDate, $locationId, $price, $shoppingLocationId, $purchasedDate, $stockLabelType, $note);
$args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args);
}
@@ -478,7 +525,7 @@ class StockApiController extends BaseApiController
}
}
public function InventoryProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function InventoryProductByBarcode(Request $request, Response $response, array $args)
{
try
{
@@ -491,7 +538,7 @@ class StockApiController extends BaseApiController
}
}
public function OpenProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function OpenProduct(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_OPEN);
@@ -532,11 +579,23 @@ class StockApiController extends BaseApiController
}
}
public function OpenProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function OpenProductByBarcode(Request $request, Response $response, array $args)
{
try
{
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
if (Grocycode::Validate($args['barcode']))
{
$gc = new Grocycode($args['barcode']);
if ($gc->GetExtraData())
{
$requestBody = $request->getParsedBody();
$requestBody['stock_entry_id'] = $gc->GetExtraData()[0];
$request = $request->withParsedBody($requestBody);
}
}
return $this->OpenProduct($request, $response, $args);
}
catch (\Exception $ex)
@@ -545,7 +604,7 @@ class StockApiController extends BaseApiController
}
}
public function ProductDetails(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductDetails(Request $request, Response $response, array $args)
{
try
{
@@ -557,7 +616,7 @@ class StockApiController extends BaseApiController
}
}
public function ProductDetailsByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductDetailsByBarcode(Request $request, Response $response, array $args)
{
try
{
@@ -570,7 +629,7 @@ class StockApiController extends BaseApiController
}
}
public function ProductPriceHistory(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductPriceHistory(Request $request, Response $response, array $args)
{
try
{
@@ -582,21 +641,26 @@ class StockApiController extends BaseApiController
}
}
public function ProductStockEntries(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductStockEntries(Request $request, Response $response, array $args)
{
$allowSubproductSubstitution = false;
if (isset($request->getQueryParams()['include_sub_products']) && filter_var($request->getQueryParams()['include_sub_products'], FILTER_VALIDATE_BOOLEAN))
if (isset($request->getQueryParams()['include_sub_products']) && filter_var($request->getQueryParams()['include_sub_products'], FILTER_VALIDATE_BOOLEAN) !== false)
{
$allowSubproductSubstitution = true;
}
return $this->FilteredApiResponse($response, $this->getStockService()->GetProductStockEntries($args['productId'], false, $allowSubproductSubstitution, true), $request->getQueryParams());
return $this->FilteredApiResponse($response, $this->getStockService()->GetProductStockEntries($args['productId'], false, $allowSubproductSubstitution), $request->getQueryParams());
}
public function ProductStockLocations(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function LocationStockEntries(Request $request, Response $response, array $args)
{
return $this->FilteredApiResponse($response, $this->getStockService()->GetLocationStockEntries($args['locationId']), $request->getQueryParams());
}
public function ProductStockLocations(Request $request, Response $response, array $args)
{
$allowSubproductSubstitution = false;
if (isset($request->getQueryParams()['include_sub_products']) && filter_var($request->getQueryParams()['include_sub_products'], FILTER_VALIDATE_BOOLEAN))
if (isset($request->getQueryParams()['include_sub_products']) && filter_var($request->getQueryParams()['include_sub_products'], FILTER_VALIDATE_BOOLEAN) !== false)
{
$allowSubproductSubstitution = true;
}
@@ -604,7 +668,64 @@ class StockApiController extends BaseApiController
return $this->FilteredApiResponse($response, $this->getStockService()->GetProductStockLocations($args['productId'], $allowSubproductSubstitution), $request->getQueryParams());
}
public function RemoveProductFromShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductPrintLabel(Request $request, Response $response, array $args)
{
try
{
$productDetails = (object)$this->getStockService()->GetProductDetails($args['productId']);
$webhookData = array_merge([
'product' => $productDetails->product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productDetails->product->id)),
'details' => $productDetails,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_RUN_SERVER)
{
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
}
return $this->ApiResponse($response, $webhookData);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function StockEntryPrintLabel(Request $request, Response $response, array $args)
{
try
{
$stockEntry = $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch();
$productDetails = (object)$this->getStockService()->GetProductDetails($stockEntry->product_id);
$webhookData = array_merge([
'product' => $productDetails->product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $stockEntry->product_id, [$stockEntry->stock_id])),
'details' => $productDetails,
'stock_entry' => $stockEntry,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $stockEntry->best_before_date;
}
if (GROCY_LABEL_PRINTER_RUN_SERVER)
{
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
}
return $this->ApiResponse($response, $webhookData);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function RemoveProductFromShoppingList(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_DELETE);
@@ -645,7 +766,7 @@ class StockApiController extends BaseApiController
}
}
public function StockBooking(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function StockBooking(Request $request, Response $response, array $args)
{
try
{
@@ -664,12 +785,12 @@ class StockApiController extends BaseApiController
}
}
public function StockEntry(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function StockEntry(Request $request, Response $response, array $args)
{
return $this->ApiResponse($response, $this->getStockService()->GetStockEntry($args['entryId']));
}
public function StockTransactions(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function StockTransactions(Request $request, Response $response, array $args)
{
try
{
@@ -687,7 +808,7 @@ class StockApiController extends BaseApiController
}
}
public function TransferProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TransferProduct(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_TRANSFER);
@@ -732,11 +853,23 @@ class StockApiController extends BaseApiController
}
}
public function TransferProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TransferProductByBarcode(Request $request, Response $response, array $args)
{
try
{
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
if (Grocycode::Validate($args['barcode']))
{
$gc = new Grocycode($args['barcode']);
if ($gc->GetExtraData())
{
$requestBody = $request->getParsedBody();
$requestBody['stock_entry_id'] = $gc->GetExtraData()[0];
$request = $request->withParsedBody($requestBody);
}
}
return $this->TransferProduct($request, $response, $args);
}
catch (\Exception $ex)
@@ -745,7 +878,7 @@ class StockApiController extends BaseApiController
}
}
public function UndoBooking(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UndoBooking(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_EDIT);
@@ -760,7 +893,7 @@ class StockApiController extends BaseApiController
}
}
public function UndoTransaction(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UndoTransaction(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_EDIT);
@@ -775,13 +908,13 @@ class StockApiController extends BaseApiController
}
}
public function MergeProducts(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function MergeProducts(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_EDIT);
try
{
if (!filter_var($args['productIdToKeep'], FILTER_VALIDATE_INT) || !filter_var($args['productIdToRemove'], FILTER_VALIDATE_INT))
if (filter_var($args['productIdToKeep'], FILTER_VALIDATE_INT) === false || filter_var($args['productIdToRemove'], FILTER_VALIDATE_INT) === false)
{
throw new \Exception('Provided {productIdToKeep} or {productIdToRemove} is not a valid integer');
}
@@ -794,9 +927,4 @@ class StockApiController extends BaseApiController
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}

View File

@@ -2,58 +2,102 @@
namespace Grocy\Controllers;
use Grocy\Helpers\Grocycode;
use Grocy\Services\RecipesService;
use DI\Container;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class StockController extends BaseController
{
public function Consume(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
use GrocycodeTrait;
public function __construct(Container $container)
{
parent::__construct($container);
try
{
$externalBarcodeLookupPluginName = $this->getStockService()->GetExternalBarcodeLookupPluginName();
}
catch (\Exception)
{
$externalBarcodeLookupPluginName = '';
}
finally
{
$this->View->set('ExternalBarcodeLookupPluginName', $externalBarcodeLookupPluginName);
}
}
public function Consume(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'consume', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
'products' => $this->getDatabase()->products()->where('active = 1')->where('id IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)')->orderBy('name'),
'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(),
'recipes' => $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved()
]);
}
public function Inventory(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Inventory(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'inventory', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'products' => $this->getDatabase()->products()->where('active = 1 AND no_own_stock = 0')->orderBy('name', 'COLLATE NOCASE'),
'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('stock')
]);
}
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Journal(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['months']) && filter_var($request->getQueryParams()['months'], FILTER_VALIDATE_INT) !== false)
{
$months = $request->getQueryParams()['months'];
$where = "row_created_timestamp > DATE(DATE('now', 'localtime'), '-$months months')";
}
else
{
// Default 6 months
$where = "row_created_timestamp > DATE(DATE('now', 'localtime'), '-6 months')";
}
if (isset($request->getQueryParams()['product']) && filter_var($request->getQueryParams()['product'], FILTER_VALIDATE_INT) !== false)
{
$productId = $request->getQueryParams()['product'];
$where .= " AND product_id = $productId";
}
$usersService = $this->getUsersService();
return $this->renderPage($response, 'stockjournal', [
'stockLog' => $this->getDatabase()->uihelper_stock_journal()->orderBy('row_created_timestamp', 'DESC'),
'stockLog' => $this->getDatabase()->uihelper_stock_journal()->where($where)->orderBy('row_created_timestamp', 'DESC'),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'users' => $usersService->GetUsersAsDto(),
'transactionTypes' => GetClassConstants('\Grocy\Services\StockService', 'TRANSACTION_TYPE_'),
'userfieldsStock' => $this->getUserfieldsService()->GetFields('stock'),
'userfieldValuesStock' => $this->getUserfieldsService()->GetAllValues('stock')
]);
}
public function LocationContentSheet(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function LocationContentSheet(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'locationcontentsheet', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent()
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent(isset($request->getQueryParams()['include_out_of_stock']))
]);
}
public function LocationEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function LocationEditForm(Request $request, Response $response, array $args)
{
if ($args['locationId'] == 'new')
{
@@ -72,35 +116,50 @@ class StockController extends BaseController
}
}
public function LocationsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function LocationsList(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['include_disabled']))
{
$locations = $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE');
}
else
{
$locations = $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
}
return $this->renderPage($response, 'locations', [
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $locations,
'userfields' => $this->getUserfieldsService()->GetFields('locations'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('locations')
]);
}
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Overview(Request $request, Response $response, array $args)
{
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_due_soon_days'];
$userSettings = $usersService->GetUserSettings(GROCY_USER_ID);
$nextXDays = $userSettings['stock_due_soon_days'];
$where = 'is_in_stock_or_below_min_stock = 1';
if (boolval($userSettings['stock_overview_show_all_out_of_stock_products']))
{
$where = '1=1';
}
return $this->renderPage($response, 'stockoverview', [
'currentStock' => $this->getStockService()->GetCurrentStockOverview(),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'currentStock' => $this->getDatabase()->uihelper_stock_current_overview()->where($where),
'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(),
'nextXDays' => $nextXDays,
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
'productGroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
]);
}
public function ProductBarcodesEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductBarcodesEditForm(Request $request, Response $response, array $args)
{
$product = null;
if (isset($request->getQueryParams()['product']))
{
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
@@ -112,9 +171,9 @@ class StockController extends BaseController
'mode' => 'create',
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
'product' => $product,
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('product_barcodes')
]);
}
@@ -124,24 +183,26 @@ class StockController extends BaseController
'mode' => 'edit',
'barcode' => $this->getDatabase()->product_barcodes($args['productBarcodeId']),
'product' => $product,
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('product_barcodes')
]);
}
}
public function ProductEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductEditForm(Request $request, Response $response, array $args)
{
if ($args['productId'] == 'new')
{
return $this->renderPage($response, 'productform', [
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name'),
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunitsStock' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'referencedQuantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'productgroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'products' => $this->getDatabase()->products()->where('parent_product_id IS NULL and active = 1')->orderBy('name', 'COLLATE NOCASE'),
'isSubProductOfOthers' => false,
@@ -154,23 +215,31 @@ class StockController extends BaseController
return $this->renderPage($response, 'productform', [
'product' => $product,
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunitsStock' => $this->getDatabase()->quantity_units()->where('id IN (SELECT to_qu_id FROM cache__quantity_unit_conversions_resolved WHERE product_id = :1) OR NOT EXISTS(SELECT 1 FROM stock_log WHERE product_id = :1)', $product->id)->orderBy('name', 'COLLATE NOCASE'),
'referencedQuantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->where('id IN (SELECT to_qu_id FROM cache__quantity_unit_conversions_resolved WHERE product_id = :1)', $product->id)->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'productgroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'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')
]);
}
}
public function ProductGroupEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductGrocycodeImage(Request $request, Response $response, array $args)
{
$gc = new Grocycode(Grocycode::PRODUCT, $args['productId']);
return $this->ServeGrocycodeImage($request, $response, $gc);
}
public function ProductGroupEditForm(Request $request, Response $response, array $args)
{
if ($args['productGroupId'] == 'new')
{
@@ -189,54 +258,71 @@ class StockController extends BaseController
}
}
public function ProductGroupsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductGroupsList(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['include_disabled']))
{
$productGroups = $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE');
}
else
{
$productGroups = $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
}
return $this->renderPage($response, 'productgroups', [
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
'productGroups' => $productGroups,
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('product_groups'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('product_groups')
]);
}
public function ProductsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ProductsList(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['include_disabled']))
$products = $this->getDatabase()->products();
if (!isset($request->getQueryParams()['include_disabled']))
{
$products = $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE');
$products = $products->where('active = 1');
}
else
if (isset($request->getQueryParams()['only_in_stock']))
{
$products = $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
$products = $products->where('id IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)');
}
if (isset($request->getQueryParams()['only_out_of_stock']))
{
$products = $products->where('id NOT IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)');
}
$products = $products->orderBy('name', 'COLLATE NOCASE');
return $this->renderPage($response, 'products', [
'products' => $products,
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
'productGroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'shoppingLocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
]);
}
public function Purchase(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Purchase(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'purchase', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'products' => $this->getDatabase()->products()->where('active = 1 AND no_own_stock = 0')->orderBy('name', 'COLLATE NOCASE'),
'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('stock')
]);
}
public function QuantityUnitConversionEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function QuantityUnitConversionEditForm(Request $request, Response $response, array $args)
{
$product = null;
if (isset($request->getQueryParams()['product']))
{
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
@@ -254,7 +340,7 @@ class StockController extends BaseController
return $this->renderPage($response, 'quantityunitconversionform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'product' => $product,
'defaultQuUnit' => $defaultQuUnit
]);
@@ -265,14 +351,14 @@ class StockController extends BaseController
'quConversion' => $this->getDatabase()->quantity_unit_conversions($args['quConversionId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'product' => $product,
'defaultQuUnit' => $defaultQuUnit
]);
}
}
public function QuantityUnitEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function QuantityUnitEditForm(Request $request, Response $response, array $args)
{
if ($args['quantityunitId'] == 'new')
{
@@ -299,47 +385,57 @@ class StockController extends BaseController
}
}
public function QuantityUnitPluralFormTesting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function QuantityUnitPluralFormTesting(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'quantityunitpluraltesting', [
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE')
'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE')
]);
}
public function QuantityUnitsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function QuantityUnitsList(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['include_disabled']))
{
$quantityUnits = $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE');
}
else
{
$quantityUnits = $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
}
return $this->renderPage($response, 'quantityunits', [
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $quantityUnits,
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('quantity_units')
]);
}
public function ShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ShoppingList(Request $request, Response $response, array $args)
{
$listId = 1;
if (isset($request->getQueryParams()['list']))
{
$listId = $request->getQueryParams()['list'];
}
return $this->renderPage($response, 'shoppinglist', [
'listItems' => $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId),
'listItems' => $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId)->orderBy('product_name', 'COLLATE NOCASE'),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'missingProducts' => $this->getStockService()->GetMissingProducts(),
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'),
'shoppingLists' => $this->getDatabase()->shopping_lists_view()->orderBy('name', 'COLLATE NOCASE'),
'selectedShoppingListId' => $listId,
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(),
'productUserfields' => $this->getUserfieldsService()->GetFields('products'),
'productUserfieldValues' => $this->getUserfieldsService()->GetAllValues('products'),
'productGroupUserfields' => $this->getUserfieldsService()->GetFields('product_groups'),
'productGroupUserfieldValues' => $this->getUserfieldsService()->GetAllValues('product_groups'),
'userfields' => $this->getUserfieldsService()->GetFields('shopping_list'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('shopping_list')
]);
}
public function ShoppingListEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ShoppingListEditForm(Request $request, Response $response, array $args)
{
if ($args['listId'] == 'new')
{
@@ -358,16 +454,17 @@ class StockController extends BaseController
}
}
public function ShoppingListItemEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ShoppingListItemEditForm(Request $request, Response $response, array $args)
{
if ($args['itemId'] == 'new')
{
return $this->renderPage($response, 'shoppinglistitemform', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(),
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'),
'mode' => 'create',
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('shopping_list')
]);
}
@@ -376,21 +473,24 @@ class StockController extends BaseController
return $this->renderPage($response, 'shoppinglistitemform', [
'listItem' => $this->getDatabase()->shopping_list($args['itemId']),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(),
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'),
'mode' => 'edit',
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('shopping_list')
]);
}
}
public function ShoppingListSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ShoppingListSettings(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'shoppinglistsettings');
return $this->renderPage($response, 'shoppinglistsettings', [
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE')
]);
}
public function ShoppingLocationEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ShoppingLocationEditForm(Request $request, Response $response, array $args)
{
if ($args['shoppingLocationId'] == 'new')
{
@@ -402,76 +502,99 @@ class StockController extends BaseController
else
{
return $this->renderPage($response, 'shoppinglocationform', [
'shoppinglocation' => $this->getDatabase()->shopping_locations($args['shoppingLocationId']),
'shoppingLocation' => $this->getDatabase()->shopping_locations($args['shoppingLocationId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('shopping_locations')
]);
}
}
public function ShoppingLocationsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ShoppingLocationsList(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['include_disabled']))
{
$shoppingLocations = $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE');
}
else
{
$shoppingLocations = $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
}
return $this->renderPage($response, 'shoppinglocations', [
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $shoppingLocations,
'userfields' => $this->getUserfieldsService()->GetFields('shopping_locations'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('shopping_locations')
]);
}
public function StockEntryEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function StockEntryEditForm(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'stockentryform', [
'stockEntry' => $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch(),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE')
'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('stock')
]);
}
public function StockSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function StockEntryGrocycodeImage(Request $request, Response $response, array $args)
{
$stockEntry = $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch();
$gc = new Grocycode(Grocycode::PRODUCT, $stockEntry->product_id, [$stockEntry->stock_id]);
return $this->ServeGrocycodeImage($request, $response, $gc);
}
public function StockEntryGrocycodeLabel(Request $request, Response $response, array $args)
{
$stockEntry = $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch();
return $this->renderPage($response, 'stockentrylabel', [
'stockEntry' => $stockEntry,
'product' => $this->getDatabase()->products($stockEntry->product_id),
]);
}
public function StockSettings(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'stocksettings', [
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE')
'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'productGroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE')
]);
}
public function Stockentries(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Stockentries(Request $request, Response $response, array $args)
{
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_due_soon_days'];
return $this->renderPage($response, 'stockentries', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'stockEntries' => $this->getDatabase()->stock()->orderBy('product_id'),
'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'stockEntries' => $this->getDatabase()->uihelper_stock_entries()->orderBy('product_id'),
'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(),
'nextXDays' => $nextXDays,
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
'userfieldsProducts' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValuesProducts' => $this->getUserfieldsService()->GetAllValues('products'),
'userfieldsStock' => $this->getUserfieldsService()->GetFields('stock'),
'userfieldValuesStock' => $this->getUserfieldsService()->GetAllValues('stock')
]);
}
public function Transfer(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Transfer(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'transfer', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'products' => $this->getDatabase()->products()->where('active = 1')->where('no_own_stock = 0 AND id IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)')->orderBy('name', 'COLLATE NOCASE'),
'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved()
]);
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
public function JournalSummary(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function JournalSummary(Request $request, Response $response, array $args)
{
$entries = $this->getDatabase()->uihelper_stock_journal_summary();
if (isset($request->getQueryParams()['product_id']))
@@ -495,4 +618,24 @@ class StockController extends BaseController
'transactionTypes' => GetClassConstants('\Grocy\Services\StockService', 'TRANSACTION_TYPE_')
]);
}
public function QuantityUnitConversionsResolved(Request $request, Response $response, array $args)
{
$product = null;
if (isset($request->getQueryParams()['product']))
{
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
$quantityUnitConversionsResolved = $this->getDatabase()->cache__quantity_unit_conversions_resolved()->where('product_id', $product->id);
}
else
{
$quantityUnitConversionsResolved = $this->getDatabase()->cache__quantity_unit_conversions_resolved()->where('product_id IS NULL');
}
return $this->renderPage($response, 'quantityunitconversionsresolved', [
'product' => $product,
'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $quantityUnitConversionsResolved
]);
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace Grocy\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class StockReportsController extends BaseController
{
public function Spendings(Request $request, Response $response, array $args)
{
$where = "pph.transaction_type != 'self-production'";
if (isset($request->getQueryParams()['start_date']) && isset($request->getQueryParams()['end_date']) && IsIsoDate($request->getQueryParams()['start_date']) && IsIsoDate($request->getQueryParams()['end_date']))
{
$startDate = $request->getQueryParams()['start_date'];
$endDate = $request->getQueryParams()['end_date'];
$where .= " AND pph.purchased_date BETWEEN '$startDate' AND '$endDate'";
}
else
{
// Default to this month
$where .= " AND pph.purchased_date >= DATE(DATE('now', 'localtime'), 'start of month')";
}
$groupBy = 'product';
if (isset($request->getQueryParams()['group-by']) && in_array($request->getQueryParams()['group-by'], ['product', 'productgroup', 'store']))
{
$groupBy = $request->getQueryParams()['group-by'];
}
if ($groupBy == 'product')
{
if (isset($request->getQueryParams()['product-group']))
{
if ($request->getQueryParams()['product-group'] == 'ungrouped')
{
$where .= ' AND pg.id IS NULL';
}
elseif ($request->getQueryParams()['product-group'] != 'all')
{
$where .= ' AND pg.id = ' . $request->getQueryParams()['product-group'];
}
}
$sql = "
SELECT
p.id AS id,
p.name AS name,
pg.id AS group_id,
pg.name AS group_name,
SUM(pph.amount * pph.price) AS total
FROM products_price_history pph
JOIN products p
ON pph.product_id = p.id
LEFT JOIN product_groups pg
ON p.product_group_id = pg.id
WHERE $where
GROUP BY p.id, p.name, pg.id, pg.name
ORDER BY p.name COLLATE NOCASE
";
}
elseif ($groupBy == 'productgroup')
{
$sql = "
SELECT
pg.id AS id,
pg.name AS name,
SUM(pph.amount * pph.price) AS total
FROM products_price_history pph
JOIN products p
ON pph.product_id = p.id
LEFT JOIN product_groups pg
ON p.product_group_id = pg.id
WHERE $where
GROUP BY pg.id, pg.name
ORDER BY pg.name COLLATE NOCASE
";
}
elseif ($groupBy == 'store')
{
$sql = "
SELECT
sl.id AS id,
sl.name AS name,
SUM(pph.amount * pph.price) AS total
FROM products_price_history pph
JOIN products p
ON pph.product_id = p.id
LEFT JOIN shopping_locations sl
ON pph.shopping_location_id = sl.id
WHERE $where
GROUP BY sl.id, sl.name
ORDER BY sl.NAME COLLATE NOCASE
";
}
return $this->renderPage($response, 'stockreportspendings', [
'metrics' => $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ),
'productGroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'selectedGroup' => isset($request->getQueryParams()['product-group']) ? $request->getQueryParams()['product-group'] : null,
'groupBy' => $groupBy
]);
}
}

View File

@@ -2,9 +2,12 @@
namespace Grocy\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class SystemApiController extends BaseApiController
{
public function GetConfig(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetConfig(Request $request, Response $response, array $args)
{
try
{
@@ -31,19 +34,43 @@ class SystemApiController extends BaseApiController
}
}
public function GetDbChangedTime(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetDbChangedTime(Request $request, Response $response, array $args)
{
return $this->ApiResponse($response, [
'changed_time' => $this->getDatabaseService()->GetDbChangedTime()
]);
}
public function GetSystemInfo(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetSystemInfo(Request $request, Response $response, array $args)
{
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemInfo());
}
public function LogMissingLocalization(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetSystemTime(Request $request, Response $response, array $args)
{
try
{
$offset = 0;
$params = $request->getQueryParams();
if (isset($params['offset']))
{
if (filter_var($params['offset'], FILTER_VALIDATE_INT) === false)
{
throw new \Exception('Query parameter "offset" is not a valid integer');
}
$offset = $params['offset'];
}
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemTime($offset));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function LogMissingLocalization(Request $request, Response $response, array $args)
{
if (GROCY_MODE === 'dev')
{
@@ -61,8 +88,8 @@ class SystemApiController extends BaseApiController
}
}
public function __construct(\DI\Container $container)
public function GetLocalizationStrings(Request $request, Response $response, array $args)
{
parent::__construct($container);
return $this->ApiResponse($response, json_decode($this->getLocalizationService()->GetPoAsJsonString()), true);
}
}

View File

@@ -4,23 +4,26 @@ namespace Grocy\Controllers;
use Grocy\Services\DatabaseMigrationService;
use Grocy\Services\DemoDataGeneratorService;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class SystemController extends BaseController
{
public function About(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function About(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'about', [
'system_info' => $this->getApplicationService()->GetSystemInfo(),
'systemInfo' => $this->getApplicationService()->GetSystemInfo(),
'versionInfo' => $this->getApplicationService()->GetInstalledVersion(),
'changelog' => $this->getApplicationService()->GetChangelog()
]);
}
public function BarcodeScannerTesting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function BarcodeScannerTesting(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'barcodescannertesting');
}
public function Root(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Root(Request $request, Response $response, array $args)
{
// Schema migration is done here
$databaseMigrationService = DatabaseMigrationService::getInstance();
@@ -29,25 +32,34 @@ class SystemController extends BaseController
if (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
{
$demoDataGeneratorService = DemoDataGeneratorService::getInstance();
$demoDataGeneratorService->PopulateDemoData();
$demoDataGeneratorService->PopulateDemoData(isset($request->getQueryParams()['nodemodata']));
}
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl($this->GetEntryPageRelative()));
}
public function __construct(\DI\Container $container)
public function Manifest(Request $request, Response $response, array $args)
{
parent::__construct($container);
$data = explode('#', base64_decode($request->getQueryParams()['data']));
$manifest = [
'name' => 'Grocy ' . $data[0],
'short_name' => 'Grocy ' . $data[0],
'icons' => [[
'src' => './img/icon-1024.png',
'sizes'=> '1024x1024',
'type' => 'image/png'
]],
'start_url' => $data[1],
'background_color' => '#333131',
'theme_color' => '#333131',
'display' => 'standalone'
];
$response->getBody()->write(json_encode($manifest));
return $response->withHeader('Content-Type', 'application/json');
}
/**
* Get the entry page of the application based on the value of the entry page setting.
*
* We fallback to the about page when no entry page is specified or
* when the specified entry page has been disabled.
*
* @return string
*/
private function GetEntryPageRelative()
{
if (defined('GROCY_ENTRY_PAGE'))
@@ -107,7 +119,7 @@ class SystemController extends BaseController
}
// Meal Plan
if ($entryPage === 'mealplan' && constant('GROCY_FEATURE_FLAG_RECIPES'))
if ($entryPage === 'mealplan' && constant('GROCY_FEATURE_FLAG_RECIPES_MEALPLAN'))
{
return '/mealplan';
}

View File

@@ -3,15 +3,17 @@
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class TasksApiController extends BaseApiController
{
public function Current(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Current(Request $request, Response $response, array $args)
{
return $this->FilteredApiResponse($response, $this->getTasksService()->GetCurrent(), $request->getQueryParams());
}
public function MarkTaskAsCompleted(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function MarkTaskAsCompleted(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_TASKS_MARK_COMPLETED);
@@ -35,7 +37,7 @@ class TasksApiController extends BaseApiController
}
}
public function UndoTask(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UndoTask(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_TASKS_UNDO_EXECUTION);
@@ -49,9 +51,4 @@ class TasksApiController extends BaseApiController
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}

View File

@@ -2,10 +2,16 @@
namespace Grocy\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class TasksController extends BaseController
{
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function Overview(Request $request, Response $response, array $args)
{
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['tasks_due_soon_days'];
if (isset($request->getQueryParams()['include_done']))
{
$tasks = $this->getDatabase()->tasks()->orderBy('name', 'COLLATE NOCASE');
@@ -15,29 +21,55 @@ class TasksController extends BaseController
$tasks = $this->getTasksService()->GetCurrent();
}
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['tasks_due_soon_days'];
foreach ($tasks as $task)
{
if (empty($task->due_date))
{
$task->due_type = '';
}
elseif ($task->due_date < date('Y-m-d 23:59:59', strtotime('-1 days')))
{
$task->due_type = 'overdue';
}
elseif ($task->due_date <= date('Y-m-d 23:59:59'))
{
$task->due_type = 'duetoday';
}
elseif ($nextXDays > 0 && $task->due_date <= date('Y-m-d 23:59:59', strtotime('+' . $nextXDays . ' days')))
{
$task->due_type = 'duesoon';
}
}
return $this->renderPage($response, 'tasks', [
'tasks' => $tasks,
'nextXDays' => $nextXDays,
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'),
'taskCategories' => $this->getDatabase()->task_categories()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'users' => $this->getDatabase()->users(),
'userfields' => $this->getUserfieldsService()->GetFields('tasks'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('tasks')
]);
}
public function TaskCategoriesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TaskCategoriesList(Request $request, Response $response, array $args)
{
if (isset($request->getQueryParams()['include_disabled']))
{
$categories = $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE');
}
else
{
$categories = $this->getDatabase()->task_categories()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
}
return $this->renderPage($response, 'taskcategories', [
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'),
'taskCategories' => $categories,
'userfields' => $this->getUserfieldsService()->GetFields('task_categories'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('task_categories')
]);
}
public function TaskCategoryEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TaskCategoryEditForm(Request $request, Response $response, array $args)
{
if ($args['categoryId'] == 'new')
{
@@ -56,13 +88,13 @@ class TasksController extends BaseController
}
}
public function TaskEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TaskEditForm(Request $request, Response $response, array $args)
{
if ($args['taskId'] == 'new')
{
return $this->renderPage($response, 'taskform', [
'mode' => 'create',
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'),
'taskCategories' => $this->getDatabase()->task_categories()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'users' => $this->getDatabase()->users()->orderBy('username'),
'userfields' => $this->getUserfieldsService()->GetFields('tasks')
]);
@@ -72,20 +104,15 @@ class TasksController extends BaseController
return $this->renderPage($response, 'taskform', [
'task' => $this->getDatabase()->tasks($args['taskId']),
'mode' => 'edit',
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'),
'taskCategories' => $this->getDatabase()->task_categories()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'users' => $this->getDatabase()->users()->orderBy('username'),
'userfields' => $this->getUserfieldsService()->GetFields('tasks')
]);
}
}
public function TasksSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function TasksSettings(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'taskssettings');
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}

View File

@@ -8,28 +8,20 @@ use LessQL\Result;
class User
{
const PERMISSION_ADMIN = 'ADMIN';
const PERMISSION_BATTERIES = 'BATTERIES';
const PERMISSION_BATTERIES_TRACK_CHARGE_CYCLE = 'BATTERIES_TRACK_CHARGE_CYCLE';
const PERMISSION_BATTERIES_UNDO_CHARGE_CYCLE = 'BATTERIES_UNDO_CHARGE_CYCLE';
const PERMISSION_CALENDAR = 'CALENDAR';
const PERMISSION_CHORES = 'CHORES';
const PERMISSION_CHORE_TRACK_EXECUTION = 'CHORE_TRACK_EXECUTION';
const PERMISSION_CHORE_UNDO_EXECUTION = 'CHORE_UNDO_EXECUTION';
const PERMISSION_EQUIPMENT = 'EQUIPMENT';
const PERMISSION_MASTER_DATA_EDIT = 'MASTER_DATA_EDIT';
const PERMISSION_RECIPES = 'RECIPES';
const PERMISSION_RECIPES_MEALPLAN = 'RECIPES_MEALPLAN';
const PERMISSION_SHOPPINGLIST = 'SHOPPINGLIST';
const PERMISSION_SHOPPINGLIST_ITEMS_ADD = 'SHOPPINGLIST_ITEMS_ADD';
const PERMISSION_SHOPPINGLIST_ITEMS_DELETE = 'SHOPPINGLIST_ITEMS_DELETE';
const PERMISSION_STOCK = 'STOCK';
const PERMISSION_STOCK_CONSUME = 'STOCK_CONSUME';
const PERMISSION_STOCK_EDIT = 'STOCK_EDIT';
@@ -37,20 +29,20 @@ class User
const PERMISSION_STOCK_OPEN = 'STOCK_OPEN';
const PERMISSION_STOCK_PURCHASE = 'STOCK_PURCHASE';
const PERMISSION_STOCK_TRANSFER = 'STOCK_TRANSFER';
const PERMISSION_TASKS = 'TASKS';
const PERMISSION_TASKS_MARK_COMPLETED = 'TASKS_MARK_COMPLETED';
const PERMISSION_TASKS_UNDO_EXECUTION = 'TASKS_UNDO_EXECUTION';
const PERMISSION_USERS = 'USERS';
const PERMISSION_USERS_CREATE = 'USERS_CREATE';
const PERMISSION_USERS_EDIT = 'USERS_EDIT';
const PERMISSION_USERS_EDIT_SELF = 'USERS_EDIT_SELF';
const PERMISSION_USERS_READ = 'USERS_READ';
/**
* @var \LessQL\Database|null
*/
public function __construct()
{
$this->db = DatabaseService::getInstance()->GetDbConnection();
}
protected $db;
public static function PermissionList()
@@ -59,21 +51,12 @@ class User
return $user->getPermissionList();
}
public function __construct()
{
$this->db = DatabaseService::getInstance()->GetDbConnection();
}
public static function checkPermission($request, string ...$permissions): void
public static function checkPermission($request, string $permission): void
{
$user = new self();
foreach ($permissions as $permission)
if (!$user->hasPermission($permission))
{
if (!$user->hasPermission($permission))
{
throw new PermissionMissingException($request, $permission);
}
throw new PermissionMissingException($request, $permission);
}
}

View File

@@ -3,10 +3,12 @@
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class UsersApiController extends BaseApiController
{
public function AddPermission(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function AddPermission(Request $request, Response $response, array $args)
{
try
{
@@ -29,7 +31,7 @@ class UsersApiController extends BaseApiController
}
}
public function CreateUser(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function CreateUser(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_USERS_CREATE);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
@@ -50,7 +52,7 @@ class UsersApiController extends BaseApiController
}
}
public function DeleteUser(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function DeleteUser(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_USERS_EDIT);
try
@@ -64,7 +66,7 @@ class UsersApiController extends BaseApiController
}
}
public function EditUser(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function EditUser(Request $request, Response $response, array $args)
{
if ($args['userId'] == GROCY_USER_ID)
{
@@ -88,7 +90,7 @@ class UsersApiController extends BaseApiController
}
}
public function GetUserSetting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetUserSetting(Request $request, Response $response, array $args)
{
try
{
@@ -101,7 +103,7 @@ class UsersApiController extends BaseApiController
}
}
public function GetUserSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetUserSettings(Request $request, Response $response, array $args)
{
try
{
@@ -113,7 +115,7 @@ class UsersApiController extends BaseApiController
}
}
public function GetUsers(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function GetUsers(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_USERS_READ);
try
@@ -126,7 +128,7 @@ class UsersApiController extends BaseApiController
}
}
public function CurrentUser(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function CurrentUser(Request $request, Response $response, array $args)
{
try
{
@@ -138,7 +140,7 @@ class UsersApiController extends BaseApiController
}
}
public function ListPermissions(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function ListPermissions(Request $request, Response $response, array $args)
{
try
{
@@ -159,7 +161,7 @@ class UsersApiController extends BaseApiController
}
}
public function SetPermissions(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function SetPermissions(Request $request, Response $response, array $args)
{
try
{
@@ -204,7 +206,7 @@ class UsersApiController extends BaseApiController
}
}
public function SetUserSetting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function SetUserSetting(Request $request, Response $response, array $args)
{
try
{
@@ -219,7 +221,7 @@ class UsersApiController extends BaseApiController
}
}
public function DeleteUserSetting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function DeleteUserSetting(Request $request, Response $response, array $args)
{
try
{
@@ -231,9 +233,4 @@ class UsersApiController extends BaseApiController
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
}

View File

@@ -3,10 +3,12 @@
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class UsersController extends BaseController
{
public function PermissionList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function PermissionList(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_USERS_READ);
return $this->renderPage($response, 'userpermissions', [
@@ -16,7 +18,7 @@ class UsersController extends BaseController
]);
}
public function UserEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UserEditForm(Request $request, Response $response, array $args)
{
if ($args['userId'] == 'new')
{
@@ -46,10 +48,11 @@ class UsersController extends BaseController
}
}
public function UserSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UserSettings(Request $request, Response $response, array $args)
{
return $this->renderPage($response, 'usersettings', [
'languages' => array_filter(scandir(__DIR__ . '/../localization'), function ($item) {
'languages' => array_filter(scandir(__DIR__ . '/../localization'), function ($item)
{
if ($item == '.' || $item == '..')
{
return false;
@@ -60,7 +63,7 @@ class UsersController extends BaseController
]);
}
public function UsersList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
public function UsersList(Request $request, Response $response, array $args)
{
User::checkPermission($request, User::PERMISSION_USERS_READ);
return $this->renderPage($response, 'users', [

Some files were not shown because too many files have changed in this diff Show More