Compare commits

...

1043 Commits

Author SHA1 Message Date
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
Bernd Bestel
e3504464e5 Don't enforce barcodes to be unique (fixes #1205) 2020-12-22 11:32:26 +01:00
Bernd Bestel
94e4ee0659 Pulled translations from Transifex 2020-12-22 10:31:06 +01:00
Bernd Bestel
f1ddd4a57e Fixed JS error 2020-12-22 10:23:26 +01:00
Bernd Bestel
5c8ed05f68 Use dynamic barcode types (references #1133) 2020-12-22 10:20:31 +01:00
Bernd Bestel
a333ccbb78 Optimizes demo data 2020-12-22 10:12:37 +01:00
Bernd Bestel
00c8934046 Use better confirm dialog 2020-12-22 10:05:06 +01:00
Bernd Bestel
efb5f97ed4 Optimized README formatting 2020-12-22 09:58:36 +01:00
Bernd Bestel
ab29233f07 Added a head line on the shopping list print options dialog 2020-12-21 21:42:21 +01:00
Bernd Bestel
c1dd145b81 Clarified that database migrations are supposed to work between releases 2020-12-21 21:29:52 +01:00
Bernd Bestel
c1ac9e8a45 Optimized/clarified new "Hide product from stock overview" option (references #906) 2020-12-21 20:43:10 +01:00
Bernd Bestel
694b78f72a Optimized GROCY_FEATURE_FLAG_STOCK handling (closes #966) 2020-12-21 20:13:49 +01:00
Bernd Bestel
7478d9bb38 Removed RTL CSS handling (not needed until we have full RTL support) 2020-12-21 19:36:20 +01:00
Bernd Bestel
e866035f05 Removed unused code 2020-12-21 19:27:04 +01:00
Bernd Bestel
cf299a3d0b Optimized file save/delete handling 2020-12-21 19:16:14 +01:00
Bernd Bestel
5953e42d70 Updated icons 2020-12-21 19:04:48 +01:00
Bernd Bestel
d83271655c Fixed purchase success message amount 2020-12-21 18:27:12 +01:00
Bernd Bestel
bb5bcb9cbe Changelog wording 2020-12-21 18:09:03 +01:00
Bernd Bestel
431a2ab9f7 Added new Userfield type "Link (with title)" (closes #790) 2020-12-21 17:57:48 +01:00
Bernd Bestel
e97fccd03a Optimized shopping list header 2020-12-21 16:29:39 +01:00
Bernd Bestel
f0d99a5714 Fixed API key deletion was not possible (fixes #1203) 2020-12-21 16:20:12 +01:00
Bernd Bestel
e62994eb4a Fixed not required field initialization when GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING is disabled (references #1202 ) 2020-12-21 10:52:40 +01:00
Bernd Bestel
01306bc1ae Fixed product barcodes table display when FEATURE_FLAG_STOCK_PRICE_TRACKING is disabled (fixes #1202) 2020-12-21 09:54:20 +01:00
Bernd Bestel
360f25ec44 Make the new user picture a little bigger (references #1158) 2020-12-21 09:49:40 +01:00
Bernd Bestel
3b1f8cba70 Moved the new copy/merge products buttons in a dropdown menu 2020-12-21 09:30:19 +01:00
Bernd Bestel
2b13102299 Implemented Userfields for users (closes #1159) 2020-12-20 22:16:58 +01:00
Bernd Bestel
8f1ce607f7 Implemented user pictures (closes #1158) 2020-12-20 22:08:50 +01:00
Bernd Bestel
3f718eab60 Remove accidentally added localization strings 2020-12-20 21:00:48 +01:00
Bernd Bestel
c9b5e14473 Make it possible to merge products (closes #243) 2020-12-20 20:58:22 +01:00
Bernd Bestel
dadf93a94c Merge used libraries for Barcode/QR-Code generation 2020-12-20 19:53:28 +01:00
Bernd Bestel
1d16021404 Show barcode as barcode-image on shopping list (closes #1133) 2020-12-20 19:31:12 +01:00
Bernd Bestel
b2f555400c Fixed database migration error handling
(Error page was not shown properly)
2020-12-20 16:52:13 +01:00
Robert Resch
6ec3743d12 fix missing > (#1201) 2020-12-20 16:02:33 +01:00
Bernd Bestel
df7653f4e5 Optimized barcode concatenation handling 2020-12-20 16:00:14 +01:00
Bernd Bestel
3fb55b706b Refresh chore-/batterycard after tracking 2020-12-20 15:04:46 +01:00
Bernd Bestel
6eaee0c6f9 Fixed number display for quick consume buttons 2020-12-20 15:02:22 +01:00
Bernd Bestel
580598b817 Fixed max consume amount was not set 2020-12-20 15:01:59 +01:00
Bernd Bestel
a5326aa95c Improve API stock action endpoint response (closes #769) 2020-12-20 14:43:07 +01:00
Bernd Bestel
cef3086a63 Pulled translations from Transifex 2020-12-20 13:03:06 +01:00
Bernd Bestel
b2d7003335 Performance optimizations 2020-12-20 10:44:19 +01:00
Bernd Bestel
76e4a1578c Added Default store as a column to the shopping list (closes #957) 2020-12-20 10:26:02 +01:00
Bernd Bestel
268b8e87d7 Make it possible to hide chores/batteries (closes #1069) 2020-12-20 10:19:44 +01:00
Bernd Bestel
31dbb95c58 Typo 2020-12-20 00:04:44 +01:00
Bernd Bestel
832141a718 Made the shopping list print view configurable (closes #740) 2020-12-19 23:57:33 +01:00
Bernd Bestel
77e842a736 Fixed shopping list print button when FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS was disabled (references #1199) 2020-12-19 23:00:07 +01:00
Bernd Bestel
f5e0709913 Added columns for last price on shopping list (closes #410) 2020-12-19 17:55:49 +01:00
Bernd Bestel
7f24ffc484 Clarify string 2020-12-19 17:38:04 +01:00
Bernd Bestel
250b308d5d Support -1 for "Default due days after freezing" (closes #846) 2020-12-19 17:32:47 +01:00
Bernd Bestel
362b3f8508 Added min. stock amount column to stock overview (closes #856) 2020-12-19 17:25:13 +01:00
Bernd Bestel
3ad5f2cac5 Added a note field to product barcodes (closes #962) 2020-12-19 17:20:54 +01:00
Bernd Bestel
5421dfb6b2 Make the chore assignment type "Random" more random (closes #674) 2020-12-19 17:15:18 +01:00
Bernd Bestel
9d7ca55109 Typo 2020-12-19 17:09:48 +01:00
Bernd Bestel
1b864f990b Updated screenshots 2020-12-19 17:08:08 +01:00
Bernd Bestel
17d0821bae Typo 2020-12-19 15:42:39 +01:00
Bernd Bestel
cd57b00a18 Prepared next release 2020-12-19 15:32:32 +01:00
Bernd Bestel
1da51cde67 Reviewed config-dist.php 2020-12-19 15:00:31 +01:00
Bernd Bestel
063e4c214b Reviewed README 2020-12-19 14:53:51 +01:00
Bernd Bestel
ea888fffb7 Updated unmanaged dependencies 2020-12-19 14:28:32 +01:00
Bernd Bestel
796e35d60b Removed unneeded dependency 2020-12-19 14:19:26 +01:00
Bernd Bestel
b53f3bcef1 Updated dependencies 2020-12-19 14:18:01 +01:00
Bernd Bestel
574d17fa52 General UI review/test 2020-12-19 14:03:28 +01:00
Bernd Bestel
7ef5bc6f77 Add some more columns (hidden by default) (references https://github.com/grocy/grocy/issues/1058#issuecomment-744059155) 2020-12-19 10:51:07 +01:00
Bernd Bestel
eb4a748da3 Consume opened products first (closes #1183) 2020-12-19 10:28:35 +01:00
Bernd Bestel
44cdd42062 he_IL localization can't be released before #984 is done 2020-12-17 17:42:27 +01:00
Bernd Bestel
cc2ea93313 Make DataTable row groups collapsible everywhere (references #1189) 2020-12-17 17:41:31 +01:00
Bernd Bestel
b5fc64cf5d Fixed DataTables numeric/datetime sorting (fixes #1085) 2020-12-17 17:33:24 +01:00
Bernd Bestel
bbad049880 Forgot to save... 2020-12-17 16:54:26 +01:00
Bernd Bestel
9572652a8a Fixed total price for tare weight handling enabled products (fixes #1196) 2020-12-17 16:50:15 +01:00
Bernd Bestel
bb6ef5511d Fixed API equals/not equals filter comparison (fixes #1182) 2020-12-16 21:52:24 +01:00
Bernd Bestel
13b18ef410 Removed unused localization string 2020-12-16 21:40:12 +01:00
Bernd Bestel
0bd9a1dc4b Added changelog for #1189 2020-12-16 18:21:21 +01:00
Robert Resch
07ff28da39 Add row group customization (#1189)
* Add row group customization

* fix rowGroup state loading

* activate rowGroup for all datatables

* add reset button

* reload page done on success callback

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-12-16 18:18:03 +01:00
Bernd Bestel
d9a3c5169e Fixed product copy source / default value prefilling handling (fixes #1179) 2020-12-16 17:51:05 +01:00
Bernd Bestel
1567b9d9d9 Added missing localization strings 2020-12-16 17:48:30 +01:00
Bernd Bestel
25f5f98b75 Fixed undoing a consume transaction of an opened item added it back to stock unopened (fixes #1191) 2020-12-16 17:44:51 +01:00
Bernd Bestel
2e01ecbe58 Enforce product nesting level also for the API 2020-12-16 17:37:44 +01:00
Bernd Bestel
4c7318acd7 Added changelog for #1190 2020-12-16 17:28:39 +01:00
PhyberApex
596a7ccd36 Removing of resize event (#1190)
* Removing of resize event

Hey,

I removed that resize event as it get's thrown every time you scroll on a mobile device. Which prevented me from actually viewing the list view of the calender on mobile devices.

Let me know if you think it is still needed tho!

~Cheers

* Update calendar.js

Now it only get's called once :)

* Update mealplan.js

Same thing here as in calendar.js

* Update calendar.js

Removed redundant variable
2020-12-16 17:26:39 +01:00
Dominic Zedler
54e4d3217c Correct typo in changelog (#1177) 2020-12-12 15:52:44 +01:00
Bernd Bestel
bfbaa7e9d5 Expose stock and stock_current_locations also via generic entity interaction API endpoints (no edit) (closes #1147) 2020-12-12 10:59:36 +01:00
Bernd Bestel
59aad1c180 Added REGEXP operator for API query filter (closes #1174) 2020-12-12 10:44:27 +01:00
Bernd Bestel
d3883ba93a Reorganized API exposed entities 2020-12-12 10:10:21 +01:00
Bernd Bestel
f07a21b00b Added missing API query filter info 2020-12-11 19:36:29 +01:00
Bernd Bestel
51a95814e0 Handle null in API filter (closes #1173) 2020-12-11 19:32:08 +01:00
dependabot[bot]
24c9f31caf Bump ini from 1.3.5 to 1.3.7 (#1172)
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-11 18:18:44 +01:00
Bernd Bestel
672c4d33bf Added basic RTL support (reference #984) 2020-12-11 18:06:32 +01:00
Bernd Bestel
9e824a7afc Pulled translations from Transifex 2020-12-11 17:41:55 +01:00
Bernd Bestel
4b1766ead0 Return default user setting if not configured for API endpoint /user/settings/{settingKey} (fixes #1169) 2020-12-10 18:02:24 +01:00
Bernd Bestel
48aa9fd138 Added an API endpoint to get the authenticated user (closes #1165) 2020-12-09 21:16:49 +01:00
Bernd Bestel
fda8411ab3 Support descending ordering in generic API filter (closes #1167) 2020-12-09 21:04:04 +01:00
Bernd Bestel
19802bc122 Fixed localization string 2020-12-07 19:55:31 +01:00
Bernd Bestel
cf34df5e3f Squashed commit
Fixed some localization strings
Reviewed/optimized product deletion handling
Add option to hide products from the stock overview page (closes #906)
Prefill default_due_days also on the inventory page (closes #591)
Added DataTables accent chinese-string plugin (closes #872)
Show costs and calories per recipe ingredient (closes #1072)
Fixed user permission saving (fixes #1099)
User permissions should not have an effect for demo mode (closes #972)
Handle QU conversion when consuming a substituation (child) product (fixes #1118)
Consume/open any child product when the parent product is not in stock (closes #899)
Added a retry camera barcode scanning button to product picker workflow (closes #736)
2020-12-07 19:48:33 +01:00
Bernd Bestel
2bdb6ab2d4 Use the products "Quick consume amount" optionally also on the consume page (closes #1148) 2020-12-04 18:16:58 +01:00
Bernd Bestel
8ec7e9923c Fixed productcard aggregated amount was in wrong line 2020-11-19 18:41:09 +01:00
Bernd Bestel
166748788b Added an include_sub_products parameter to the API endpoint /stock/products/{productId}/locations 2020-11-19 18:37:16 +01:00
Bernd Bestel
211239a5d3 Fixed /stock/products/{productId}/entries endpoint query parameter include_sub_products did not work (however) 2020-11-19 18:28:16 +01:00
Bernd Bestel
631831e1e4 Use custom demo DB path suffix also for storage (references #395) 2020-11-19 12:24:26 +01:00
Bernd Bestel
f9d566c55c Support custom DB path suffixes for demo mode (closes #395) 2020-11-18 19:42:05 +01:00
Bernd Bestel
bbdc372dcf Use total price for product_barcodes.last_price (references #1131) 2020-11-17 22:06:52 +01:00
Bernd Bestel
2b4d8a7cc5 Load userobject forms in dialogs 2020-11-17 21:18:05 +01:00
Bernd Bestel
639ffe13f5 Reverted 41067b23bb because that's not needed (references #1049 and #958) 2020-11-17 21:10:26 +01:00
Bernd Bestel
7ef970a09f Forgot to save... 2020-11-17 21:05:55 +01:00
Bernd Bestel
604629ed5e Added a button to download equipment instruction manuals (closes #833) 2020-11-17 21:01:45 +01:00
Bernd Bestel
d2d09cf928 Removed dragscroll dependency (fixes #1135, references #1115) 2020-11-17 20:50:04 +01:00
Bernd Bestel
e32d12699e Properly initialize sort_number on the Userfield edit form (references #1134) 2020-11-17 20:28:26 +01:00
Bernd Bestel
5634abed82 Use transactions for database migrations 2020-11-17 20:22:38 +01:00
Bernd Bestel
6270f39688 Make Userfields reorderable (closes #1134) 2020-11-17 20:12:45 +01:00
Bernd Bestel
887526c727 Squashed commit
Fixed number input min/max amount handling
Only (auto) save valid user inputs
More filters on the stock journal pages
Save the last price per used barcode and preselect that as a total price on purchase if not empty (closes #1131)
Don't apply conversions for only_check_single_unit_in_stock ingredients (fixes #1120)
Render shopping list userfields (closes #1052)
Fixed Focus when adding included recipes (closes #1019)
Order all base objects with NOCASE (closes #1086)
2020-11-17 19:11:02 +01:00
Bernd Bestel
1316c1f25f Don't colorize validated custom checkboxes/radios 2020-11-16 22:33:24 +01:00
Bernd Bestel
8733ae17e7 Forgot to save before last commit... 2020-11-16 22:30:51 +01:00
Bernd Bestel
512ef745da Don't expose uihelper views via the API / allow to get stock_log via generic entity interaction endpoints (no edit) 2020-11-16 22:18:37 +01:00
Bernd Bestel
e85b21384f Remove "Allow partial units in stock" product option / unify number input validation messages 2020-11-16 17:10:41 +01:00
Bernd Bestel
95fc6a6faa Fixed RefreshLocaleNumberInput 2020-11-15 23:03:12 +01:00
Bernd Bestel
7b4edf3147 Adapt shopping list add expired products for #851 2020-11-15 22:38:21 +01:00
Bernd Bestel
1bbd7787d8 More proper number formatting 2020-11-15 22:29:47 +01:00
Bernd Bestel
293880c874 Typo 2020-11-15 20:30:50 +01:00
Bernd Bestel
948bf0a9c4 Removed unused localization string 2020-11-15 20:08:45 +01:00
Bernd Bestel
c62fa8c203 Changelog formatting fixes 2020-11-15 20:05:10 +01:00
Bernd Bestel
b393998601 Distinguish expiry/best before dates (closes #851) 2020-11-15 19:53:44 +01:00
Bernd Bestel
1d50d5dd22 Rmove unique constraint on tasks.name (closes #1001) 2020-11-15 16:19:55 +01:00
Bernd Bestel
9a7196b761 Make it possible to copy products (closes #571) 2020-11-15 16:05:25 +01:00
Bernd Bestel
7d7f9bf07a Changed default label of dialog close button 2020-11-15 15:28:50 +01:00
Bernd Bestel
3fc3bdd34c Make the help icons a little not so prominent 2020-11-15 15:23:47 +01:00
Bernd Bestel
6eef19dfc6 Fixed DataTables state load when there are no settings saved 2020-11-15 15:20:50 +01:00
Bernd Bestel
9942a2dbab Use new style also on the login page 2020-11-15 15:17:13 +01:00
Bernd Bestel
3568fd9dcb Added a "error info copy & paste" text box on the 500 error page 2020-11-15 15:12:15 +01:00
Bernd Bestel
22e9e4e311 Forgot to save... 2020-11-15 14:59:54 +01:00
Bernd Bestel
dd8fa5ff66 Save DataTable states server side 2020-11-15 14:58:35 +01:00
Bernd Bestel
6866109b97 Add clear filter button to stock entries page + mobile view optimizations (this now closes #1129) 2020-11-15 14:48:48 +01:00
Bernd Bestel
7bf973dd32 Fix stock entries page dropdown menu overflow (references #1129) 2020-11-15 14:30:00 +01:00
Bernd Bestel
4b342dbd43 Improved number input initial value decimal handling 2020-11-15 14:15:09 +01:00
Bernd Bestel
1d1642b464 Make the quick consume buttons on the stock overview page configurable per product (closes #613) 2020-11-15 09:57:45 +01:00
Bernd Bestel
17ae7e3d0c Added a tooltip what scan mode is 2020-11-15 09:27:07 +01:00
Bernd Bestel
3b73df57e5 Unify tooltips 2020-11-15 09:22:05 +01:00
Bernd Bestel
185627af7d Fixed table filters 2020-11-15 09:21:54 +01:00
Bernd Bestel
d1846b76ff Fixed parent product selection (fixes #1128) 2020-11-15 09:12:14 +01:00
Bernd Bestel
f85b89d4fa Show a warning on purchase when purchased best before date is < in stock (closes #948) 2020-11-14 23:15:34 +01:00
Bernd Bestel
db5c9ce3e8 stockentryform amount doesn't need to handle tare weight 2020-11-14 22:54:29 +01:00
Bernd Bestel
28276191cc Don't allow tare weight handling enabled products to be opened (closes #770) 2020-11-14 22:51:06 +01:00
Bernd Bestel
62c9c285ba Document API changes in grocy.openapi.json (closes #969) 2020-11-14 21:26:16 +01:00
fipwmaqzufheoxq92ebc
491b74efa8 Fix is_aggregate_amount always 0 on stock_current (#1127)
* Fix is_aggregate_amount always 0

* Restore performance indexes from #927

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-11-14 16:41:45 +01:00
Bernd Bestel
1d6e279b07 Added missing changelog (references #801) 2020-11-14 12:44:50 +01:00
Bernd Bestel
6e867cafbd Unify/remove used icons 2020-11-14 11:59:49 +01:00
Bernd Bestel
bb985c09ba Fixed purchase/inventory embedded mode initial input focus handling 2020-11-14 11:53:35 +01:00
Bernd Bestel
1fbda392c2 Fixed product edit page returnto handling 2020-11-14 11:49:46 +01:00
Bernd Bestel
c00411da81 Prevent qu_id_stock change after first purchase also via a trigger (for the API) (references #801) 2020-11-14 11:37:01 +01:00
Bernd Bestel
62997d39bc Removde the /objects/{entity}/search API endpoint, added the new filter capabilities to /objects/{entity} (references #985) 2020-11-14 11:27:13 +01:00
Bernd Bestel
16b17b25a4 Reordered input fields 2020-11-14 11:07:36 +01:00
Bernd Bestel
b267295e86 Fixed product picker workflows 2020-11-14 11:05:36 +01:00
Bernd Bestel
71f6b38cb2 Fixed chore edit page QU hint 2020-11-13 19:03:25 +01:00
Bernd Bestel
c45e5d1794 Trigger cascade_change_qu_id_stock is not longer needed 2020-11-13 19:01:01 +01:00
Bernd Bestel
ed2239c1f6 Wording correction 2020-11-13 17:58:46 +01:00
Bernd Bestel
96b86c230c Use sensible decimal amounts 2020-11-13 17:45:09 +01:00
Bernd Bestel
42f70b04e7 Also show the price hint for single unit prices when purchase QU != stock QU 2020-11-13 17:43:28 +01:00
Bernd Bestel
b0b3322266 Also relate the shopping list amount to QU stock 2020-11-13 17:30:57 +01:00
Bernd Bestel
ab68a51ba7 Recipe edit page fixes 2020-11-13 15:46:44 +01:00
Bernd Bestel
fa3a4ed688 Fixed productamountpicker initial converted amount was undefined 2020-11-12 22:47:00 +01:00
Bernd Bestel
1056252117 Typo 2020-11-12 21:41:21 +01:00
Bernd Bestel
c360cbec4c UI strings/tooltips/basic handling review/optimizations 2020-11-12 21:35:10 +01:00
Bernd Bestel
c121c0483a Fixed missing error message when trying to create a duplicate product 2020-11-12 13:09:46 +01:00
Bernd Bestel
ea9722bfa4 Fixed undefined variable warnings on product edit page 2020-11-12 13:08:50 +01:00
Bernd Bestel
6f3a3f62af Typo 2020-11-11 22:39:24 +01:00
Bernd Bestel
0c8b6c55c1 Added total calories as a column to stock overview (references #1058) 2020-11-11 22:38:01 +01:00
Bernd Bestel
0a600d3277 Fix hide/view columns dialog did not work on pages with more than 1 table (references #1058) 2020-11-11 22:28:05 +01:00
Bernd Bestel
c3e59d21b9 Only number picker help hint when not empty 2020-11-11 22:17:01 +01:00
Bernd Bestel
11f65629e3 Fixed number picker help hint 2020-11-11 22:09:26 +01:00
Bernd Bestel
7c8a17ce78 Add calories as a column to stock overview (references #1058) 2020-11-11 22:06:01 +01:00
Bernd Bestel
e7491fd8d1 Restored missing trigger after products table reorg (references #801) 2020-11-11 21:44:03 +01:00
Bernd Bestel
0245a925b7 Make it possible to hide columns (closes #1058)
Hide new overview page columns by default
2020-11-11 21:11:17 +01:00
Bernd Bestel
b15740bded Fixed dropdown menu in tables overflow 2020-11-11 20:14:16 +01:00
Bernd Bestel
e3ab943fe7 Use the custom-file-pickers also for the new file and image userfields 2020-11-11 18:49:08 +01:00
Bernd Bestel
9c81fc890b Simplified "checkboxUncheckedValue" handling 2020-11-11 17:34:37 +01:00
Bernd Bestel
9949f30c2b Unify hint texts 2020-11-10 22:01:23 +01:00
Bernd Bestel
06f345324f Fied wrong/missing product picker hint on product edit page 2020-11-10 21:59:19 +01:00
Bernd Bestel
8c8a51c06e Typo 2020-11-10 21:51:45 +01:00
Bernd Bestel
d816be6908 Use the proper plural QU form in productamountpicker 2020-11-10 21:41:12 +01:00
Bernd Bestel
d863e33343 Made the sidebar items a little smaller 2020-11-10 21:35:01 +01:00
Bernd Bestel
7f600bd8d9 Don't add the destination QU multiple time in productamountpicker 2020-11-10 21:19:51 +01:00
Bernd Bestel
4959e9e732 Fixed purchase page initial amount validation 2020-11-10 21:19:28 +01:00
Bernd Bestel
3831cb37b3 Fixed DateTimePicker2 contextual time 2020-11-10 20:57:49 +01:00
Bernd Bestel
0c17666cef Fixed default consume/purchase amount behaviour 2020-11-10 20:53:16 +01:00
Bernd Bestel
8c54131921 Fix is_aggregated_amount of stock_current did not work anymore 2020-11-10 20:11:43 +01:00
Bernd Bestel
62e8d88adb Reviewed changelog 2020-11-10 18:50:04 +01:00
Bernd Bestel
5d4aab063f Removed unused localization strings 2020-11-10 18:17:28 +01:00
Bernd Bestel
68eeb07e5f Test/review/rework (and hopefully finalized) new price handling 2020-11-10 18:11:33 +01:00
Bernd Bestel
33a6a28208 Also use the productamountpicker on the shopping list item page (refernces #1015) 2020-11-09 22:15:25 +01:00
Bernd Bestel
8400175f1d Improved productamountpicker stock amount display 2020-11-09 21:55:49 +01:00
Bernd Bestel
b6f4cfa851 Also use the productamountpicker for inventory (refernces #1015) 2020-11-09 21:51:55 +01:00
Bernd Bestel
ad3b91ef98 Improved form spacing 2020-11-09 21:30:22 +01:00
Bernd Bestel
44eb74ca52 Updated changelog 2020-11-09 19:28:58 +01:00
Bernd Bestel
8bd157ca9d Use producamountpicker "everywhere" (closes #1015) 2020-11-09 19:25:46 +01:00
Bernd Bestel
5f920e2cc6 Start product picker workflows also by TAB 2020-11-08 22:36:55 +01:00
Bernd Bestel
40283609b5 Product / QU form refinements 2020-11-08 22:13:36 +01:00
Bernd Bestel
4c399392eb Fixed recipes page when there are no recipes 2020-11-08 21:44:39 +01:00
Bernd Bestel
0134535a5e Fix/workaround for undfined constant GROCY_LOCALE 2020-11-08 21:37:43 +01:00
Bernd Bestel
ea5b3dcd51 UI test/review 2020-11-08 19:51:56 +01:00
Bernd Bestel
3e3321bf11 UI test/review 2020-11-08 19:00:12 +01:00
Bernd Bestel
d82fd09fba UI test/review 2020-11-08 15:09:10 +01:00
Bernd Bestel
7d237867b5 Updated changelog about the new clear filter button 2020-11-07 15:01:10 +01:00
Bernd Bestel
7324c14516 Added changelog for #1115 2020-11-07 14:59:09 +01:00
4lloyd
76cbf796b6 [WIP] Simplified overviews on mobile (#1115)
* Simplified stock overview on mobile.

* Stock table horizontally scrollable

* Use the new mobile views for all pages (except the shopping list page, use the existing special handling there for now)
And add a clear filter button to all pages

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-11-07 14:53:45 +01:00
Bernd Bestel
9aa9bd1cc7 Typo 2020-10-31 20:25:04 +01:00
Bernd Bestel
ec12b50cde Use GitHub issue templates 2020-10-31 20:23:44 +01:00
Bernd Bestel
2d4db25308 Use GitHub issue templates 2020-10-31 20:18:02 +01:00
Bernd Bestel
7b32d1d8a4 More compact page headers / streamlined new page design for all pages 2020-10-31 18:37:10 +01:00
Bernd Bestel
18617dc9fb Fixed undefined variable warning 2020-10-31 16:29:12 +01:00
Bernd Bestel
eec203700a Added changelog for #1111 2020-10-31 16:26:30 +01:00
kriddles
de85cb9e04 limit to normal recipes (#1111) 2020-10-31 16:25:33 +01:00
kriddles
cb3978cdbd AddProduct Fix (#1110) 2020-10-31 16:24:49 +01:00
Bernd Bestel
fca4b3bb10 Added changelog for #1109 2020-10-31 16:22:51 +01:00
Benoit Anastay
5303952be1 Unit stock name in the mealplan (#1109)
Stock name instead of purchase name
2020-10-31 16:15:26 +01:00
kriddles
af0a7dc2be delete double (#1108) 2020-10-29 21:37:54 +01:00
Bernd Bestel
7d175563ca Fixed stock overview status filter (fixes #1080) 2020-10-29 17:32:21 +01:00
Bernd Bestel
351e236353 Fixed initial state of user permission checkbox tree (fixes #1099) 2020-10-29 17:19:48 +01:00
Bernd Bestel
286c326768 Added missing localization string 2020-10-29 17:11:49 +01:00
Bernd Bestel
fb032ef721 Added changelog for #1103 2020-10-29 17:11:24 +01:00
kriddles
64a2f5b25e dialogs for shopping list (#1103) 2020-10-29 17:09:35 +01:00
Bernd Bestel
1563870021 Added changelog for #1102 2020-10-29 17:05:29 +01:00
kriddles
9bbcdafab9 Add purchased date to inventory (#1102)
* Add purchased date to inventory

* Clarify stock settings label

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-10-29 17:04:34 +01:00
kriddles
fb17c57dd3 inventory fix for quFactorPurchaseToStock - defaults to product details (#1081) 2020-10-26 10:10:10 +01:00
fipwmaqzufheoxq92ebc
7ef9ffe041 Fixes #1092: Repair QR-Codes for API-Keys (#1093) 2020-10-25 08:42:58 +01:00
Bernd Bestel
be18d59735 Fixed minimum for two number inputs (fixes 1083#) 2020-10-21 18:14:24 +02:00
Bernd Bestel
31fcdf377a Implemented LDAP authentication support (closes #305) 2020-10-20 21:43:58 +02:00
Bernd Bestel
def61eee6e Typo 2020-10-20 20:38:19 +02:00
Bernd Bestel
45236b2af2 Added changelog/new translation strings for #1078 and #1079 2020-10-20 20:16:57 +02:00
kriddles
ff254f8db2 stock entries button on product card (#1079) 2020-10-20 20:14:25 +02:00
kriddles
57aa6499eb display productCard when clicking item on shopping list (#1078) 2020-10-20 20:14:11 +02:00
Bernd Bestel
438cc08b98 Added changelog/new translation strings for #1077 2020-10-20 20:12:04 +02:00
kriddles
46e8123477 Allow price up to 4 decimals instead of 2 (#1077)
* Allow price to be 4 decimals

* remove logging

* Finalize custom decimal places by user setting

* Typo

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-10-20 20:08:54 +02:00
Bernd Bestel
9e982979c3 Allow 4 decimals for all amount inputs (this now closes #998) 2020-10-19 20:25:42 +02:00
Bernd Bestel
80beff2cae Fixed price input decimals, started reviewing all number inputs (fixes #1076, references #998) 2020-10-19 20:03:26 +02:00
Bernd Bestel
6e1e90984f Typo 2020-10-19 18:41:16 +02:00
Bernd Bestel
94214b867a More authentication refactoring to also provide "plugable" credentials handling (references #921, needed for #305) 2020-10-19 18:38:12 +02:00
Bernd Bestel
9f88dd3af3 Fixed login did not work 2020-10-19 17:19:13 +02:00
Bernd Bestel
a2b2f26628 Delete stock_log rows for not existing products in migration 0103 (fixes #1002) 2020-10-18 15:52:52 +02:00
Bernd Bestel
f93261404b Fixed by PHP-CS-Fixer broken formattings 2020-10-18 15:08:09 +02:00
Bernd Bestel
9115645e19 Fixed consuming tare weight handling enabled products on the stock entries page (fixes #988) 2020-10-18 14:51:32 +02:00
Bernd Bestel
196d304de6 Disable opening of tare weight handling enabled products also on the stock entries page (same as for the stock overview page, references #988) 2020-10-18 14:48:21 +02:00
Bernd Bestel
80cf68aeaa Allow no product for shopping list items & always in-/decrement by 1 when using the number input arrow buttons (fixes #964) 2020-10-18 14:27:23 +02:00
Bernd Bestel
7e08224c75 Fixed tooltip/model z-index (fixes #1065) 2020-10-18 14:13:39 +02:00
Bernd Bestel
ccd2caa44c Fixed GetProductIdFromBarcode returned wrong id & use default qu_factor_purchase_to_stock when not provided when adding products to stock (fixes #1068) 2020-10-18 14:09:54 +02:00
kriddles
f7a1634442 typo (#1062) 2020-10-18 13:57:10 +02:00
John M. Harris, Jr
2958ccfc14 Fix night mode (#1067)
This fixes a few lines of white when in night mode.

This change was done from a tablet, I can redo this commit properly on a computer when I get back home if needed. This just really annoyed me ;)
2020-10-18 13:54:33 +02:00
Bernd Bestel
ab1611081e Typo 2020-10-17 11:25:56 +02:00
Bernd Bestel
5ed7a0ca53 Don't strip boolean values (references #996, fixes #1055) 2020-10-17 11:15:31 +02:00
Bernd Bestel
e24f3143b5 Changelog/little naming changes/fixes/new translations strings for #1056 2020-10-17 11:03:47 +02:00
kriddles
cd65195532 add purchased date to purchase (#1056) 2020-10-17 10:54:10 +02:00
Bernd Bestel
235b96d17f Fixed recipe ingredient initial QU (fixes #1060) 2020-10-17 10:52:25 +02:00
kriddles
758a8d9708 fix for price and total price (#1057)
* fix for price and total price

* product card clarity
2020-10-15 19:55:58 +02:00
Bernd Bestel
17d296d173 Added changelog for #1045 2020-10-15 19:48:25 +02:00
kriddles
5ae36e6ba8 Value information (#1045)
* viewjs stockoverview: add total value to stock overview

* view stockoverview.blade: add Value column

* refresh stockOverview value column

* Removed the total units info

* Properly format the total stock value number

* Added new localization strings

* Resolved merge conflict

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-10-15 19:46:27 +02:00
Bernd Bestel
56d79d7db8 Added changelog for #996 2020-10-14 23:11:00 +02:00
kriddles
96c6faf208 fix expiring filter (#1051) 2020-10-14 22:59:58 +02:00
Bernd Bestel
08644f95bf Revert "Excape HTML (where needed, for bootbox) (references #996)"
This reverts commit 0df2590de2.

Revert "Excape shopping list item notes (references #996)"

This reverts commit 0624b0df59.
2020-10-14 22:58:26 +02:00
Bernd Bestel
c11001467b Sanitize user input on all API routes (references #996) 2020-10-14 22:49:29 +02:00
Bernd Bestel
7b8438bfa2 Added new localization strings for #1049 2020-10-14 18:03:49 +02:00
Bernd Bestel
1420952f29 Added changelog for #1049 2020-10-14 18:03:27 +02:00
fipwmaqzufheoxq92ebc
a85998dd40 Improvements (#1049)
* Fixes #1035: Check available amount after filtering by stock_entry_id

* Fixes #1036: Remove stock-related buttons/options from Shopping-list  if FEATURE_FLAG_STOCK is disabled

* Fixes #1010: Repair recipe-picture upload.

* Fixes #958: Disable auto-reload of equipments-page.

* Fix uncaught exception in locationpicker.js

* Fixes #761 and #762: Add "Remove exact amount" for products with tare weight handling and use it for recipe-consumption.

* Fixes #1048: Repair product-group-filter on "Master Data"/Products

* Renamed variable

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-10-14 17:48:37 +02:00
Bernd Bestel
a66a4d0c22 Fix missing property warnings (references #1025) 2020-10-12 17:50:33 +02:00
Bernd Bestel
e91bc0b01b Revert "Make sure that the view products_last_purchased always returns a row per product, also for not in stock items (references #801)"
This reverts commit 0a3e85dab4.

Revert "Make sure that the views products_average_price and products_oldest_stock_unit_price always returns a row per product, also for not in stock items (references #801)"

This reverts commit 939b98e470.
2020-10-12 17:31:38 +02:00
Bernd Bestel
9c92ec4748 Added changelog for #1026 2020-10-04 15:25:18 +02:00
Bernd Bestel
e60ef77b7b Applied formatting rules for by #1026 changed files 2020-10-04 15:22:51 +02:00
SourceFactory.at
617b25bda8 added button to add expired products to shoppinglist (#1026)
* added button to add expired products to shoppinglist

* Localizations are managed via Transifex

Revert "added button to add expired products to shoppinglist"

This reverts commit ad1ab5d6a0.

* Revert unnecessary change

* Reuse existing function (GetExpiringProducts) to get expired products

Co-authored-by: Mario Klug <mario.klug@sourcefactory.at>
Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-10-04 15:20:34 +02:00
Bernd Bestel
49588508bb Added changelog for #1018 2020-10-04 15:03:27 +02:00
Bernd Bestel
931e4b7e9a Applied formatting rules for by #1018 changed files 2020-10-04 15:02:08 +02:00
fipwmaqzufheoxq92ebc
b03e43b708 Ui fixes (#1018)
* Fixes #1005. Recipes: filter by stock-status in gallery

* Fixes #1017. Productform: Remove "Store"-Header from barcode-table if FEATURE_FLAG_STOCK_PRICE_TRACKING is not set.

* Fixed typo

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-10-04 15:00:34 +02:00
Bernd Bestel
4b5b7bcb19 Applied formatting rules for by #1000 changed files 2020-09-14 11:20:29 +02:00
Bernd Bestel
64c050fc0d Added changelog for #1000 2020-09-14 11:16:44 +02:00
fipwmaqzufheoxq92ebc
5056ca9397 Some bug fixes. (#1000)
* Fix #997. Remove datetimepicker if FEATURE_FLAG_STOCK_BEST_BEFORE_DATE is not set.

* datetimepicker: Fix that SetValue did not set the value if "shortcut-checkbox" (e.g. "never expires") was checked.

* Use parent div as clickable area for checkboxes in dropdowns

* Fix nightmode-enable

* Fix possibly undefined variables in CalendarService.php

* Fix undefined variable in GenericEntityApiController.php

* Fix "Trying to access property barcodes on non-object" in productpicker

* Fix undefined "hintId" in shoppinglocationpicker

* Fix undefined variables in locationpicker.blade.php
2020-09-14 11:15:11 +02:00
Bernd Bestel
0624b0df59 Excape shopping list item notes (references #996) 2020-09-08 18:25:42 +02:00
Bernd Bestel
0df2590de2 Excape HTML (where needed, for bootbox) (references #996) 2020-09-08 18:10:30 +02:00
Bernd Bestel
22434c85f0 Applied formatting rules for by #995 changed files 2020-09-08 17:52:35 +02:00
Bernd Bestel
61cfddb1e7 Added changelog for #995 2020-09-08 17:50:49 +02:00
Maximilian Bosch
34ffdb2b4b Adds a few small frontend fixes (#995)
* Add a few instructions to the readme on how to get `grocy` running locally

* Fix toggle for header-clock

I'm not 100% sure why, but with this change, the listener which calls
`CheckHeaderClockEnabled` will be invoked *before* the listener which
persists the setting.

If the setting is persisted before that, the clock doesn't show up when
enabling it in the settings-menu and appears/disappears in the exact
opposite way the setting is true/false.

* Allow replacing a product picture when removing it at first

Right now, a preview image of a product doesn't get updated when
pressing the delete-button at first and adding a new image the
upload-form which can be quite confusing for an end-user.

This patch allows to delete an image and add a new one in one go.

* Add `Save & return` button to product form

Same concept as for recipes: when pressing this button, the user will
stay at the form's site after saving.

* Removed unneeded class

* Revert "Add a few instructions to the readme on how to get `grocy` running locally"

This reverts commit 6ffad1d3c7.

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-09-08 17:46:37 +02:00
Bernd Bestel
38bb205a55 Fixed error when starting fresh / without existing database file (references #976) 2020-09-07 08:32:04 +02:00
Bernd Bestel
5b05254816 Fixed iCal sharing API route was always unauthenticated (fixes #993, references #921) 2020-09-07 08:30:08 +02:00
Bernd Bestel
3f1135713a Fixed string concat (fixes #994, references #985) 2020-09-07 08:16:05 +02:00
Bernd Bestel
6adac0588a Applied formatting rules for by #989 changed files 2020-09-06 13:31:54 +02:00
Bernd Bestel
f68e96a235 Added changelog for #989 2020-09-06 13:26:36 +02:00
fipwmaqzufheoxq92ebc
0454c128f0 Stock-Journal: API, Summary, Done By (#989)
* Stockjournal: Add "Done by"

* Add API for Stock-Journal

* Add "Journal-Summary"

* Use ALTER TABLE

* Moved the "Jounral summary" button to the stock journal page

* Changed icon & context menu position for new stock journal summary page

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-09-06 13:18:51 +02:00
Bernd Bestel
7498d8f13d Applied formatting rules for by #986 changed files 2020-09-06 10:10:30 +02:00
Bernd Bestel
d0a7756a67 Added changelog for #986 2020-09-06 10:08:08 +02:00
fipwmaqzufheoxq92ebc
85a95f1973 Apikeys (#986)
* Add QR-Code for API-Url/Key

* Show only API-Keys for current user

* Allow only admin users to create custom API-Keys

* Use a managed package of qrcode-generator instead of a copy of the JS file

* Reuse existing localization string (API key)

* Center QR-Code in popups

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-09-06 10:00:49 +02:00
dependabot[bot]
40f379b761 Bump bl from 4.0.2 to 4.0.3 (#987)
Bumps [bl](https://github.com/rvagg/bl) from 4.0.2 to 4.0.3.
- [Release notes](https://github.com/rvagg/bl/releases)
- [Commits](https://github.com/rvagg/bl/compare/v4.0.2...v4.0.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-03 15:57:12 +02:00
Bernd Bestel
836bcc82e5 Applied PHP-CS-Fixer rules 2020-09-01 21:29:47 +02:00
Bernd Bestel
3da8904cba Switch to use PHP-CS-Fixer to format PHP files 2020-09-01 21:22:50 +02:00
Bernd Bestel
0ed1813bee Added changelog for #985 2020-09-01 20:17:23 +02:00
fipwmaqzufheoxq92ebc
32a4f81f62 Filtering of API-Results (#985)
* Add FilteredApiResponse

* Use FilteredApiResponse for Generic-Entity-Search

* Use FilteredApiResponse for Recipe-Fullfillment

* Use FilteredApiResponse for GetUsers

* Use FilteredApiResponse for current Tasks

* Use FilteredApiResponse for ProductStockEntries & ProductStockLocations

* Use FilteredApiResponse for current chores

* Use FilteredApiResponse for batteries-current

* Fix missing highlighting of "< X days"

* Keep to use existing views

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-09-01 19:59:40 +02:00
Bernd Bestel
60f3d900e8 Display "Track date only"-chores as all-day also in iCal API endpoint (references #941) 2020-09-01 19:32:28 +02:00
Bernd Bestel
2bc3b53c63 Remove phpfmt again, doesn't really work well... 2020-09-01 19:27:37 +02:00
Bernd Bestel
ae590fa910 Also return Userfields for Userobjects (endpoint /objects/{entity}) (fixes #979) 2020-08-31 22:32:56 +02:00
Bernd Bestel
ad4f8a19af Removed the barcodes column from the products list as we don't have that field there anymore 2020-08-31 22:13:02 +02:00
Bernd Bestel
d4c5da2173 Applied PHP formatting rules 2020-08-31 20:40:31 +02:00
Bernd Bestel
33325d5560 Applied .blade.php formatting rules 2020-08-31 20:32:50 +02:00
Bernd Bestel
ea9ba0b2be Typo 2020-08-31 20:21:46 +02:00
Bernd Bestel
7e2574eb73 Added changelog for #977 2020-08-31 20:12:28 +02:00
fipwmaqzufheoxq92ebc
07beee93a9 Add user-field-type "file" (#977)
* Add user-field-type "file"

* Add userfield-type "picture"

* Also limit image height on userfieldsform

* Prevent empty userfields (cause warnings in tables after deleting a file)

* Show files in dialogs

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-31 20:07:46 +02:00
Bernd Bestel
318db53818 Typo 2020-08-31 19:22:08 +02:00
Bernd Bestel
a995ce0538 Added changelog for #976 2020-08-31 19:19:05 +02:00
fipwmaqzufheoxq92ebc
6f8ad9b76e Locales: use http-accept-language or cookie (#976)
* Locales: use http-accept-language or "language"-cookie

* Add user-setting "locale"

Rename CULTURE to DEFAULT_LOCALE

* Use LocaleMiddleware also in dev mode

* CORS: don't require authentication on OPTIONS

* Use a standard user-settings-control and start a new generic user settings page, not a separate page for the locale setting

* Fixed (broken by myself) link-return handling

* Clarify language settings

* Removed unneeded files

* Better user settings icon

* Added localization hints

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-31 19:11:51 +02:00
Bernd Bestel
4a030b7ffc Added editor.insertSpaces setting 2020-08-31 08:50:55 +02:00
Bernd Bestel
5c101e6750 Use phpfmt to format .php files 2020-08-30 22:52:35 +02:00
Bernd Bestel
2f00d673a7 Also format .blade.php files by default VSCode formatting rules 2020-08-30 22:08:17 +02:00
Bernd Bestel
9cea0c77cd Applied VSCode JS formatting settings 2020-08-30 12:18:16 +02:00
Bernd Bestel
e0e3212f13 Added VSCode JS formatting settings 2020-08-30 12:16:23 +02:00
Bernd Bestel
747660d909 Return API exceptions with proper content type 2020-08-29 19:29:24 +02:00
Bernd Bestel
e93f58916e Forgot some entries in permission_hierarchy... 2020-08-29 19:24:19 +02:00
fipwmaqzufheoxq92ebc
17094f56eb Run database-Migrations in right order (#973) 2020-08-29 19:15:02 +02:00
Bernd Bestel
0f499c69d9 Fixed .pot file syntax error 2020-08-29 18:34:05 +02:00
Bernd Bestel
86300b7025 Refined permissions by existing feature structure (closes #971, references #960) 2020-08-29 18:31:28 +02:00
Bernd Bestel
a8395cb748 Fixed undefined constants warning on the 404 error page 2020-08-29 17:12:31 +02:00
Bernd Bestel
22384aaa2e Error page style improvements 2020-08-29 16:58:06 +02:00
Bernd Bestel
3b0d29bed0 Applied EditorConfig settings to all files 2020-08-29 16:41:27 +02:00
Bernd Bestel
2c966c77fd Added an EditorConfig file 2020-08-29 16:10:05 +02:00
kriddles
22ca427ca9 Include location and shopping_location_id when opening products (#965) 2020-08-29 12:26:36 +02:00
Bernd Bestel
32cd928460 Added changelog for #960 2020-08-29 12:22:53 +02:00
fipwmaqzufheoxq92ebc
b7d1b21f1d [WIP] Implemented basic permissions (#960)
* Add permissions to Database & add "User"-classes

* Add UI & API for Permissions, protect "User"-(Api)-Controller with new permissions.

* Add some permissions.

* Add permission localization

* Add error handling.

* Error pages: only redirect on 404

* ExceptionController: return JSON-Response on api-routes

* Rename PRODUCT_ADD to PRODUCT_PURCHASE

* Move translation to new file

* Fix checkboxes stay selected on reload.

* Remove configurable User-implementation

* Remove MASTER_DATA_READ

* Disable buttons the user isn't allowed to use.

* Add default permissions for new users

* When migration to permissions, everyone starts as ADMIN

* Permission-Localization: add to transifex & LocalizationService

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-29 12:05:32 +02:00
Bernd Bestel
f28697e5b4 Added a "Clear filter" button on the stock overview page (closes #879) 2020-08-25 20:20:51 +02:00
Bernd Bestel
0417b73cb5 Show if a consume booking was spoiled on the stock journal page (closes #953) 2020-08-25 19:51:54 +02:00
Bernd Bestel
71a6cbef2d First try on stock overview page: Make filter row more compact 2020-08-25 19:45:54 +02:00
Bernd Bestel
471a8665d0 Remove the new help icons where not needed and translate help text 2020-08-25 19:28:44 +02:00
Bernd Bestel
4058925f40 Handle edited stock entries in GetProductPriceHistory (fixes #913) 2020-08-25 19:09:47 +02:00
Bernd Bestel
0b98504371 Don't hide the product row on the stock overview page if there are still child products in stock 2020-08-25 18:15:34 +02:00
Bernd Bestel
4db373b272 Fixed parent product amount aggregation (fixes #878) 2020-08-25 18:13:26 +02:00
Bernd Bestel
3b564294e3 Allow decimal amounts in general for the shopping list 2020-08-24 20:25:50 +02:00
Bernd Bestel
ece880ea44 Don't round up missing amounts and allow decimal numbers (fixes #758) 2020-08-24 20:16:21 +02:00
Bernd Bestel
9d04d81744 Use correct amount for the success popup on the consume page (fixes #766) 2020-08-24 19:06:33 +02:00
Bernd Bestel
5c62377ba6 Don't trigger row select event on first column (fixes #791) 2020-08-24 18:42:32 +02:00
Bernd Bestel
a569048a3a Validate form after changing the QU on the recipe ingredient edit page (fixes #907) 2020-08-24 18:32:50 +02:00
Bernd Bestel
95ca6f6354 Display "Track date only"-chores as all-day events on the calendar (fixes #941) 2020-08-24 18:27:40 +02:00
Bernd Bestel
c8c540970d Added missing localization string 2020-08-24 18:16:49 +02:00
Bernd Bestel
fa32258553 Only reload "Disable stock fulfillment checking for this ingredient" by the products default when creating a recipe ingredient (fixes #910) 2020-08-24 18:16:32 +02:00
Bernd Bestel
4d38614671 Reload recipe page after add/edit an ingredient (fixes #803) 2020-08-24 18:02:46 +02:00
Bernd Bestel
2c151fb4de Do an exact search for product group and location filters on the stock overview pages (fixes #778) 2020-08-24 17:57:43 +02:00
Bernd Bestel
e039db22f5 Don't prefill for empty prices when editing a stock entry (fixes #961) 2020-08-24 17:42:41 +02:00
Bernd Bestel
a6db08943c Streamline naming 2020-08-22 19:09:36 +02:00
Bernd Bestel
e3ff16c66a Downgrade animate.css, upgrade to v4 needs customizations 2020-08-22 18:25:59 +02:00
Bernd Bestel
fdb419fe55 Fixed errors while populating demo data 2020-08-22 17:59:42 +02:00
Bernd Bestel
0a3e85dab4 Make sure that the view products_last_purchased always returns a row per product, also for not in stock items (references #801)
Otherwise there are errors when getting product details for currently not in stock items...
2020-08-22 17:50:08 +02:00
Bernd Bestel
939b98e470 Make sure that the views products_average_price and products_oldest_stock_unit_price always returns a row per product, also for not in stock items (references #801)
Otherwise there are errors when getting product details for currently not in stock items...
2020-08-22 10:06:37 +02:00
Bernd Bestel
ffec1134a3 Added changelog for #959 2020-08-22 10:05:10 +02:00
fipwmaqzufheoxq92ebc
923e027a4b Some bug fixes. (#959)
* Fixes #956. Return 404 for missing objects in GenericEntityApiController.php

* Fixes #936 and #943. Include Products that expire today in /stock/volatile and "Expiring soon"-sum on stockoverview

* Fixes #881. Remove items of deleted shopping lists.

* Fixes #875. Prevent infinite nested recipes.

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-22 09:58:25 +02:00
Bernd Bestel
cf9bb87f6e Upgraded to Quagga2 (again) (closes #799, also references #844) 2020-08-19 20:04:17 +02:00
Bernd Bestel
04bbad2167 Added changelog for #844 2020-08-19 19:56:24 +02:00
Andre Monteiro
b8cd5cd0b5 Additional configuration options for Quagga2 (#844) 2020-08-19 19:52:04 +02:00
Bernd Bestel
2cd3779d82 Added changelog for #855 2020-08-19 19:49:32 +02:00
Michał Przybyś
f8c6e81dcb Fix grocy/grocy#834 (#855)
* Fix grocy/grocy#834

* stock_missing_products_including_opened didn't take the opened amount in HAVING clauses

* Resolved merge conflicts

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-19 19:46:25 +02:00
Bernd Bestel
31c412a28c Typo 2020-08-19 19:31:52 +02:00
Bernd Bestel
41359137dc Added changelog for #921 2020-08-19 19:29:39 +02:00
fipwmaqzufheoxq92ebc
d60d981fd1 Refactor Authentication and add proxy-authentication (#921)
* Refactor Authentication-Middlewares

* Add Proxy-Authentication

* Disable "Logout" & "Manage Users" when using ProxyAuth

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-19 19:23:13 +02:00
Bernd Bestel
5b475d9307 Added changelog for #876 2020-08-18 19:46:38 +02:00
Matthias B
88949dc3e4 Make product amount picker locale independent (#876)
Since the value of $('#amount') will be written to the database it should not be locale dependent. This code also limits the result to a maximum of 4 digits but always uses a dot as decimal separator.
2020-08-18 19:43:50 +02:00
Bernd Bestel
e4d0978f5d Merge branch 'master' of https://github.com/grocy/grocy 2020-08-18 19:37:10 +02:00
Bernd Bestel
f88401a44a Added changelog for #933 2020-08-18 19:36:45 +02:00
fipwmaqzufheoxq92ebc
e7af74f550 use last Chore-Log when determining the next assigned person (#933) 2020-08-18 19:34:19 +02:00
Bernd Bestel
295f360306 Added changelog for #927 2020-08-18 19:30:00 +02:00
fipwmaqzufheoxq92ebc
42dc55625a Improve Performance (#927)
* Stock-Overview: Reduce amount of database queries and FindObjectInArray()-calls

* Speed-up stock_current by improving products_resolved and creating indices.

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-18 19:23:37 +02:00
Bernd Bestel
7510c677f1 Added changelog for #880 2020-08-18 18:30:35 +02:00
duck
7e276289e0 WIP: Fix typo on "Consumed Amount" localization string (#880)
* Fix typo on localization string in strings.pot

Should be "Consumed Amount"

* Remove typo Consumed Amount string in locationcontentsheet template
2020-08-18 18:28:39 +02:00
Bernd Bestel
273811fdc1 Updated dependencies 2020-08-18 18:27:58 +02:00
Bernd Bestel
a93a3e1df1 Added changelog for #939 2020-08-18 18:15:50 +02:00
Stefan Haller
623fce6c08 Run multi instances by making GROCY_DATAPATH customizable (#939)
Previously the data directory was fixed to the GROCY_DATAPATH constant.

This commit allows overriding the default GROCY_DATAPATH location by the
FastCGI parameter `GROCY_DATAPATH`. Relative paths are modified and get
rooted at the top level grocy installation directory.

The previous behaviour is preserved in case the new parameter is absent.

The following example nginx config snippet shows how to run multiple
instances.

```nginx
server {
    location /instance1/ {
        alias /var/www/grocy/;
        set $instance instance1;
        try_files $uri @grocy;
    }

    location /instane2/ {
        alias /var/www/grocy/;
        set $instance instance2;
        try_files $uri @grocy;
    }

    location @grocy {
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME index.php;
        fastcgi_param GROCY_DATAPATH data/$instance;
    }
}
```
2020-08-18 18:10:26 +02:00
Bernd Bestel
68dcd02d00 Revert "Fix base path computation when running in subdirectory (#945)" (#954)
This reverts commit 6cd874f3ba.
2020-08-18 18:01:50 +02:00
Stefan Haller
6cd874f3ba Fix base path computation when running in subdirectory (#945) 2020-08-18 17:57:35 +02:00
Bernd Bestel
b6b6f903ab Added more changelog for #801 2020-08-18 11:49:25 +02:00
Bernd Bestel
144ca094e6 Typo 2020-08-17 22:13:53 +02:00
Bernd Bestel
da05cbffc0 Added changelog for #801 2020-08-17 22:12:39 +02:00
kriddles
e8845fe2e8 Qu factor purchase to stock & Product Barcode Details (#801)
* Puchase add qu_factor_to_stock

* qu_factor_purchase_to_stock for stock edit

* product barcodes with QU and Stores

* remove product barcode tags

* migrations/0103 add value and factor_puchase_amount to stock_current and stock_current_location_content

* Remove unused method

* StockService#GetProductDetails: include stock_value

* productcard: include stock_value

* Add Purchase Factor to Stock Overview

* update demo data with stock qu_factor_purchase_to_stock

* recipes_pos_resolved update

* avg_price and oldest_price in product details

* add average price to product card

* hint for recipe costs not included if not in stock

* Round value and factor_purchas_amount. Include currency for stock value

* Add factor_purchase_amount to product card stock amount

* Allow editing qu_factor_purchase_to_stock for stock entries

* fix update qu_factor_purchase_to_stock for Transfers

* Add barcode to existing product update to add to product_barcodes table

* Add barcode to new product workflow update to add to product_barcodes table

* *** Price now saved as 1 QU to stock in stock tables ***

* remove column product barcode and use product_barcodes

* Allow products to be deactivated instead of deleted

* Embedded barcode and qu-conversion with page reload on change

* Save current product barcode into new product_barcodes table

* Embedded popup for product group add/edit

* barcode scanner added to product barcodes input

* Edit product qu_stock is unavailable after first purchase

* StockOverview: Filters break when columns are reordered so for now just disable colReorder

* view stockoverview.blade: display product_group column

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-17 21:47:33 +02:00
Bernd Bestel
d1e395b45e Added the Korean translation (closes #903) 2020-08-17 18:22:42 +02:00
Bernd Bestel
7f461bfa51 Added the Greek translation (closes #952) 2020-08-17 18:07:05 +02:00
Bernd Bestel
cadf61d641 Pulled translations from Transifex 2020-08-17 17:57:40 +02:00
Bernd Bestel
f6852e82b2 Website link has changed (references grocy/grocy-website#15) 2020-07-28 20:15:42 +02:00
Bernd Bestel
98f214e9f1 Added changelog for #826 2020-05-03 20:28:04 +02:00
Germs2004
f25902214f Change ellipsis to dash (#826)
An ellipsis in software often implies that the element is clickable to get more information.  Changing that to a simple dash symbol makes it more clear that the value is simply undefined and is not a clickable element.
2020-05-03 20:25:27 +02:00
Bernd Bestel
1e07a2dc2e Added changelog for #806 2020-04-29 19:55:56 +02:00
Marc Ole Bulling
a9dc5deaaa Added SQLite check for #805 (#806)
* Added SQLite check

* Moved check behind Extensions check

* Changed to SqlitePDO
2020-04-29 19:54:05 +02:00
Shadow
86b7cfed29 Fixed (#802)
Reordered days for better readability.
2020-04-27 18:11:32 +02:00
Bernd Bestel
fc9e2927f9 Added changelog for #796 2020-04-26 17:30:21 +02:00
kriddles
45c14723b0 Fix Product Shopping Location Prefill for Edits (#796) 2020-04-26 17:28:02 +02:00
Bernd Bestel
d72fd565ca Changelog and little adjustments for #800 2020-04-26 17:26:32 +02:00
Shadow
6c3c2d5384 #570 Added fix for weekly chores with multiple days (#800) 2020-04-26 17:14:54 +02:00
Bernd Bestel
37054475c2 Little adjustments and changelog for #795 2020-04-24 18:06:57 +02:00
Bernd Bestel
9e824e1845 Little adjustments and changelog for #788 2020-04-24 17:51:48 +02:00
Zack Arnett
f076b0d0c6 Recipe updates (#795) 2020-04-24 17:41:57 +02:00
kriddles
385e7287fe Create Inverse QU Conversions (#788) 2020-04-24 17:41:50 +02:00
Bernd Bestel
60f321d9c2 Added changelog for #793 2020-04-23 20:51:34 +02:00
Marc Ole Bulling
49e5eda30f Make GetUriParam work with special characters (eg. "&") (#793) 2020-04-23 20:48:48 +02:00
Bernd Bestel
5833bb1e8f Added changelog for #784 2020-04-22 18:05:05 +02:00
Zack Arnett
29b4672346 Link to respective page on Calendar Event Click (#784)
* Link to Page on calendar event click

* Undo my Prettier Changes.. Oops
2020-04-22 18:03:05 +02:00
Bernd Bestel
fbb8999513 Fixes and changelog for #767 2020-04-22 18:00:25 +02:00
Bernd Bestel
1ea26cadcc Merge branch 'master' of https://github.com/grocy/grocy 2020-04-22 17:38:37 +02:00
kriddles
9a921cfc86 Purchase Price Hints (#767)
* productcard update last price with per qu purchase name

* Purchase price hints

* purchase set default to 2999-12-31 if not best before date tracking

* purchase- move amount above best buy date and focus amount after product selection
2020-04-22 17:38:24 +02:00
Bernd Bestel
16b9e2c30a Return Access-Control-Allow-Origin for all API (content) requests (references #681) 2020-04-22 17:36:20 +02:00
Bernd Bestel
5e6a9dd443 Return status code 204 for CORS OPTIONS requests (references #681) 2020-04-21 21:15:45 +02:00
Bernd Bestel
53a0a2f4e1 Also allow just all headers and request methods for CORS OPTIONS requests (references #681) 2020-04-21 21:09:49 +02:00
Bernd Bestel
98f2276e17 Send just * for Access-Control-Allow-Origin header in CORS OPTIONS requests (again closes #681) 2020-04-21 21:05:32 +02:00
Zack Arnett
7fb76df33a Recipe Pages UI updates (#776)
* Recipe updates

* Add help text icon
2020-04-21 08:18:09 +02:00
Bernd Bestel
f4b70e9ae3 Fixed product edit page barcodes field tab handling (fixes #764) 2020-04-19 15:01:58 +02:00
Bernd Bestel
8cbfd5fedb Added changelog for #763 2020-04-19 14:56:29 +02:00
tsia
eb190537e9 Fixed Timezone in CalendarApiController (#763)
`PHP Warning:  DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /var/www/grocy/controllers/CalendarApiController.php on line 22`
2020-04-19 14:55:08 +02:00
Bernd Bestel
0e2a067e30 Added changelog for #753 2020-04-19 14:53:33 +02:00
Zack Arnett
4629df17b4 Cosmetic Update (#753)
* UI changes

* New (header) style was missing on some pages

* Added/changed new localization strings

* Unify page titles / apply .title class everywhere

* Reduce spacing below page title

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-04-19 14:51:02 +02:00
Bernd Bestel
59650728a2 Make sure to include /data/.htaccess in release ZIPs 2020-04-17 20:12:06 +02:00
Bernd Bestel
743395ff93 Pulled translations from Transifex 2020-04-17 20:07:15 +02:00
Bernd Bestel
6931d2a764 Prepared next release 2020-04-17 20:07:01 +02:00
Bernd Bestel
356cdf4991 Fixed pre requisite checker paths (fixes #748) 2020-04-17 19:57:22 +02:00
Bernd Bestel
b4a480aa37 Downgrade / use QuggaJS again instead of Quagga2 (fixes #749) 2020-04-17 19:48:11 +02:00
James Addison
b2dbc64f29 Remove NodeJS dependency check (#745) 2020-04-17 08:24:02 +02:00
Bernd Bestel
1cb0ba5e68 Pulled translations from Transifex 2020-04-16 19:21:20 +02:00
Bernd Bestel
d4fefa846b Hotfix (will be included in the v2.7.0 release): Downgraded jQuery (fixes #743) 2020-04-16 19:14:26 +02:00
Bernd Bestel
7121e814b0 Updated dependencies 2020-04-16 18:22:38 +02:00
Bernd Bestel
70a1704bc2 Pulled translations from Transifex 2020-04-16 18:12:50 +02:00
Bernd Bestel
629b3c0706 Prepared next release 2020-04-16 18:05:45 +02:00
Bernd Bestel
db3021e475 Revert "Use a route cache file (speed optimization)"
This reverts commit 59cd4dbac4.
2020-04-14 09:02:48 +02:00
Bernd Bestel
e897570968 Only adjust the camera barcode scanning live stream picture size once (fixes #734) 2020-04-13 22:34:52 +02:00
Bernd Bestel
2e625f330d Little style changes and changelog for #733 2020-04-13 22:30:35 +02:00
Michael Frikke Madsen
a6030798c7 Add camera picker button (#733)
* Add camera picker button

* Remove button and nested dialog - make it a select
- Also make Cancel button gray again
2020-04-13 22:07:38 +02:00
Bernd Bestel
71770540f6 Fixed stock overview page did not load when GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING is disabled (references #673) 2020-04-13 21:56:24 +02:00
Bernd Bestel
59cd4dbac4 Use a route cache file (speed optimization) 2020-04-13 21:26:34 +02:00
Bernd Bestel
6f4769a7b3 Make product groups on the shopping list collapsible (closes #604) 2020-04-13 19:11:13 +02:00
Bernd Bestel
1390c65864 Show optionally an icon on the stock overview page if the product is already on the shopping list (closes #708) 2020-04-13 18:47:41 +02:00
Bernd Bestel
840b35b30d Add tooltips to shopping list item buttons (closes #572) 2020-04-13 18:26:53 +02:00
Bernd Bestel
886721e972 Fixed consuming tare weight handling enabled products from the stock overview page (fixes #731) 2020-04-13 17:29:00 +02:00
Bernd Bestel
1686fcca8e Fixed that product-opened-actions had no transaction_id in stock_log (fixes #732) 2020-04-13 17:04:59 +02:00
Bernd Bestel
7d9bad58b5 Added changes of #601 to grocy.openapi.json 2020-04-13 16:57:06 +02:00
Bernd Bestel
25be604b31 Also return userfields in generic object(s) GET API routes (closes #601) 2020-04-13 16:52:34 +02:00
Bernd Bestel
87e68523e5 Typo... 2020-04-13 16:27:36 +02:00
Bernd Bestel
858315ed3f Added DataTables accent neutralise plugin (closes #654) 2020-04-13 16:27:02 +02:00
Bernd Bestel
f36d9c46ed Make Quagga2 setting "numOfWorkers" adjustable (closes #713) 2020-04-13 16:14:43 +02:00
Bernd Bestel
45d96cb60f Use Quagga2 instead of QuaggaJS (closes #579) 2020-04-13 16:08:46 +02:00
Bernd Bestel
10f890ef89 Added a camera-barcode-scanner-button to the barcodes field on the product edit page (closes #723) 2020-04-13 15:55:27 +02:00
Bernd Bestel
c6e06ab07c Fix weekday order for next chore execution calculation for weekly chores (fixes #570) 2020-04-13 15:16:38 +02:00
Bernd Bestel
9a93c32d3c Fix total price amount relation on purchase (fixes #722) 2020-04-13 14:52:13 +02:00
Bernd Bestel
1fc802c30e Typo/duplicated function (references #718) 2020-04-13 10:41:37 +02:00
Bernd Bestel
42e6a8ef94 Added new API endpoints to get all user and config settings (closes #718) 2020-04-13 10:35:20 +02:00
Bernd Bestel
b971375881 Reimplemented CORS handling (fixes #681) 2020-04-13 10:00:29 +02:00
Bernd Bestel
855b24c515 Fix consume page form validation limits for the amount input when tare weight handling is enabled (fixes #727) 2020-04-12 21:41:04 +02:00
Bernd Bestel
b62d3b02e6 Only add not empty translation strings to POT in DEV mode 2020-04-12 20:31:30 +02:00
Bernd Bestel
0327188125 Optimize datetimepicker form validation events (fixes #726) 2020-04-12 18:41:23 +02:00
Bernd Bestel
73b3ad3b4c Unify wording 2020-04-12 18:32:32 +02:00
Bernd Bestel
152d3b7005 Respect QU conversions when aggregating parent product stock amounts (fixes #615) 2020-04-12 18:29:44 +02:00
Bernd Bestel
5b314351dd Don't show disabled product options (fixes #724) 2020-04-12 15:59:08 +02:00
Bernd Bestel
7b39bc995c Fixed update.sh line endings (fixes #705) 2020-04-12 15:42:25 +02:00
Bernd Bestel
c562e09073 Dummy change to fix line endings (references #705) 2020-04-12 15:40:11 +02:00
Bernd Bestel
8cfd3e19ba Typo... 2020-04-12 15:34:27 +02:00
Bernd Bestel
81e6530ddc Always set number inputs in browser locale format (fixes #610) 2020-04-12 15:33:36 +02:00
Bernd Bestel
86ef36d76a Don't ignore the decimal part when editing a stock entry (fixes #616) 2020-04-12 15:22:36 +02:00
Bernd Bestel
1d4b6a0a24 Updated README.md 2020-04-12 14:49:53 +02:00
Bernd Bestel
d907bca3cb Include userfields when printing a shopping list (fixes #719) 2020-04-12 14:39:11 +02:00
Bernd Bestel
3356b07342 Always show models / overlay everything else (fixes #628) 2020-04-12 14:34:50 +02:00
Bernd Bestel
615de378ba Don't load demo_data strings in production setups 2020-04-12 14:22:18 +02:00
Bernd Bestel
0f3a3887a2 Fixed that best before dates were displayed on the stock overview and stock entries page even with disabled GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING (fixes #673) 2020-04-12 14:17:52 +02:00
Bernd Bestel
390af436ab Fixed that the stock entries page was broken when there were product userfields defined with enabled "Show as column in tables" (fixes #677) 2020-04-12 14:13:28 +02:00
Bernd Bestel
4e5e191b22 Fixed the conversion factor hint on the purchase page (fixes #625) 2020-04-12 14:09:38 +02:00
Bernd Bestel
6867057b6e Clarify button tooltips on the stock entries page (closes #621) 2020-04-12 14:02:24 +02:00
Bernd Bestel
9dbd6a68c4 Don't change the displayed QU to the products stock QU when "Only check if a single unit is in stock" is set when editing a recipe ingredient (fixes #606) 2020-04-12 13:55:26 +02:00
James Addison
4f8ef2859e Fixup: paths for localization file existence checks (#710) 2020-04-09 08:29:44 +02:00
Mik-
a6dd794ce8 Add missing form validation on presetting QU id stock (#704) 2020-04-07 16:37:30 +02:00
Bernd Bestel
6b75decd4a Added roadmap section 2020-04-07 13:54:10 +02:00
Bernd Bestel
2334b010fd Added roadmap section 2020-04-07 13:48:55 +02:00
Bernd Bestel
1cb3128042 Added changelog for #703 2020-04-07 11:46:07 +02:00
Shane Kerr
cc012c7348 Create the backup tarball explicitly before invoking tar (#703)
When grocy is installed on a btrfs file system, the tar command
fails if the tarball is not created first.
2020-04-07 11:43:54 +02:00
Bernd Bestel
bfb46494cf Added new at least 80 % complete localizations 2020-04-05 08:41:08 +02:00
Bernd Bestel
4072dfd26f Use default strings if any of the minor translation files is not available 2020-04-05 08:40:42 +02:00
Bernd Bestel
769a13aa31 Added a default .htaccess file for the data directory 2020-04-05 08:39:57 +02:00
Bernd Bestel
2924502878 Added info about the new release branch 2020-04-04 20:42:12 +02:00
Bernd Bestel
30908f5ba9 Fixed typo (references #697) 2020-04-03 18:55:48 +02:00
James Addison
ca9354064d PSR7-decoupled rework of authentication fixup (#697) 2020-04-03 18:45:40 +02:00
Bernd Bestel
9a9b4d1000 Updated version.json 2020-04-03 18:35:46 +02:00
Bernd Bestel
808745dbfa Added v2.6.2 changelog (hotfix, will be included/changed in the last 5 releases also) 2020-04-03 18:34:00 +02:00
Bernd Bestel
2778d2ad56 Don't return anything in the response body when unauthenticated (fixes #696) 2020-04-03 18:22:05 +02:00
Bernd Bestel
11bf89e13a Added changelog for #688 2020-04-02 08:39:25 +02:00
Mik-
1aa788b6c2 Preset the stock qu with the purchase qu on new products. (#688) 2020-04-02 08:36:20 +02:00
Mik-
7200f2c17f Fix errors with disabled feature flag STOCK_PRICE_TRACKING (#687)
fixes #685
2020-04-02 08:34:43 +02:00
Bernd Bestel
746203b82d Allow any used HTTP request method for CORS (references #681) 2020-03-31 17:53:34 +02:00
tsia
8e82525732 fix api endpoint url in comment (#676) 2020-03-29 18:15:27 +02:00
Bernd Bestel
f092c8b10d Added changelog for #675 2020-03-29 14:29:38 +02:00
Mik-
f66a4c9631 Camera barcode scanner enhancements (#675)
* Disable torch button, if not supported

* Allow toggling torch

* Don't exceed the screen width with camera window

* Disable torch button, if not supported

* Allow toggling torch

* Don't exceed the screen width with camera window

* Allow toggling torch

* Disable torch button, if not supported

* Allow toggling torch

* Don't exceed the screen width with camera window

* Allow toggling torch

* Allow toggling torch

* Don't exceed the screen width with camera window

* Remove toggling of torch, as it's not working
and add resize of video to fit in viewport hieght

* Add feature to always turn on the torch in camera scanner.

* Fix feature flag name

Co-authored-by: Michael Neuendorf <neuendorf@gonicus.de>
2020-03-29 14:25:04 +02:00
Bernd Bestel
caf7127c13 Added changelog for #672 2020-03-27 19:32:25 +01:00
kriddles
2fee4b45ff set default store for product, purchase set last store purchased if available or use product default (#672) 2020-03-27 19:27:40 +01:00
Bernd Bestel
d509f9add0 Added changelog for #669 2020-03-27 17:46:08 +01:00
tsia
81d84d93e2 fixed missing class error in CalendarApiController (#669) 2020-03-27 17:44:29 +01:00
Bernd Bestel
646f638111 Added changelog for #668 2020-03-27 14:32:30 +01:00
Marc Ole Bulling
9a27b8e3a5 Added amount value for locations api (#668) 2020-03-27 14:29:26 +01:00
Bernd Bestel
d7738aa1ec Added some demo data to showcase the new price tracking per store feature (references #658) 2020-03-25 20:56:33 +01:00
Bernd Bestel
4f40b40fe0 Fixed migration (references #658) 2020-03-25 20:39:19 +01:00
Bernd Bestel
7b737590ea Added changelog for #657 2020-03-25 20:32:37 +01:00
Mik-
f3b504b7de Optionally use number pad input in best-before-date fields on mobile Chrome (#657)
* Add missing translation for de

* Add option to set best-before-date field input-type to number
This allows faster input in mobile devices

* Fix datetimepicker with inputmode

* Fix datatimepicker with numeric input

* Add missing translation for de

* Add option to set best-before-date field input-type to number
This allows faster input in mobile devices

* Fix datetimepicker with inputmode

* Fix datatimepicker with numeric input

* Use more precise name for number pad option

* Update localization/de/strings.po

Co-Authored-By: Bernd Bestel <bernd@berrnd.de>

* Fix merge conflict

* Fix merge conflict try 2

Co-authored-by: Michael Neuendorf <neuendorf@gonicus.de>
Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-25 20:26:54 +01:00
Bernd Bestel
2619d03cc0 Added changelog for #658 2020-03-25 20:12:38 +01:00
Bernd Bestel
305f5b67e4 Name shopping locations "Stores" on the frontend (references #658) 2020-03-25 20:09:28 +01:00
Bernd Bestel
5214a775ed Fix stock entries page rendering problem when FEATURE_FLAG_STOCK_PRICE_TRACKING is set to false (references #658) 2020-03-25 20:02:59 +01:00
Bernd Bestel
2d00f6f84a Immediately show the changed shopping location after edit on the stock entries page (references #658) 2020-03-25 20:00:52 +01:00
Bernd Bestel
06f65594de Fix stock entries page error when there is no shopping location (references #658) 2020-03-25 19:53:00 +01:00
Bernd Bestel
c3d4be352d Fix product card chart rendering error when there is no shopping location (references #658) 2020-03-25 19:49:10 +01:00
Immae
a45317aea1 Add shopping location for price tracking (#658) 2020-03-25 19:34:56 +01:00
dacto
573b6ece89 Process Settings from environment and settingoverrides values the same: (#660)
* fixes handling strings representing bools from settingoverrides .txt files
  * trailing newline characters are now stripped
2020-03-25 19:30:16 +01:00
Bernd Bestel
22eaeee572 Added changelog for #660 2020-03-25 19:29:30 +01:00
Bernd Bestel
375865d80e Changelog and some small changes for #639 2020-03-22 18:02:19 +01:00
Marc Ole Bulling
3fc14db5d5 Check if all dependencies are installed (#639)
* Added check if all dependencies are installed and config.php/config-dist.php exists

* Also check for php modules

* Uncomment code that was accidentally disabled for debug purposes
2020-03-22 17:55:23 +01:00
Bernd Bestel
dcfd9d848d Added changelog for #637 / #638 2020-03-22 09:27:49 +01:00
Marc Runkel
03eee1329c Fix recipes page (#638)
* My config

* Add check to see if any recipe is selected

* Add check to see if a recipe is actually selected

Co-authored-by: Marc Runkel <marc.runkel@plusforta.de>
2020-03-22 09:24:49 +01:00
Bernd Bestel
03566d0644 Added changelog for #633 / #629 2020-03-21 15:56:59 +01:00
Mik-
71b62d5708 629 Make ellipsis menu in stock overview more responsive (#633)
* Make popup menues in table rows responsive

* Move "consum all" button to ellipsis menu on small devices
2020-03-21 15:52:51 +01:00
Bernd Bestel
eb3c0f9397 Typo... 2020-03-06 21:46:14 +01:00
Bernd Bestel
40034ed7bd Prepared next release 2020-03-06 21:29:37 +01:00
Bernd Bestel
c67a5bf77d Updated dependencies 2020-03-06 21:28:36 +01:00
Bernd Bestel
9f6daac010 Added new demo data localization string 2020-03-06 21:23:31 +01:00
Bernd Bestel
e0f71aa308 Pulled translations from Transifex 2020-03-06 21:14:50 +01:00
Bernd Bestel
f1496894b5 Fixed adding new chores did not work (references #479) 2020-03-06 21:01:41 +01:00
Bernd Bestel
48dc8e45ba Fixed localization string (references #588) 2020-03-06 20:58:01 +01:00
Bernd Bestel
f440604007 Fixed Location Content Sheet product ordering (fixes #590) 2020-03-06 20:56:11 +01:00
Bernd Bestel
5cfe7cf34d Fixed that the recipe page was reloaded when expanding a collapsed row on mobile (fixes #589) 2020-03-06 20:51:09 +01:00
Bernd Bestel
e2bb3a7d00 Changelog & little changes for #592 2020-03-06 20:46:27 +01:00
DarienFord
b0ddc026f8 Added chore name when getting list of all chores. (#592) 2020-03-06 20:43:38 +01:00
Bernd Bestel
8be14768df Added new config.php setting for subdirectory base path (closes #568) 2020-03-06 20:41:00 +01:00
Bernd Bestel
c73ce21ef5 Removed selective/basepath (references #568) 2020-03-06 20:33:36 +01:00
Bernd Bestel
c38c519b18 Fixed that images did not work after merging #479 2020-03-01 19:48:08 +01:00
Bernd Bestel
fc131f5598 Little changes and changelog for #574 2020-03-01 17:58:10 +01:00
Radim Kabeláč
51cd81422e Button to Flashlight ON in Barcodescanner (#574)
* Button to Flash lights ON in barcodereader

Only to ON, not OFF (you can Cancel)

* First documentation files for ReadThedoc

* Delete index.md

* Delete mkdocs.yml

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 17:53:28 +01:00
Bernd Bestel
14c9c045e7 Added changelog for #479 2020-03-01 17:50:34 +01:00
zebardy
1a5f3ce926 Convert services to singletons and use lazy loading to improve performance (#479)
* use singletons to reduce need to recreate the same objects

* unable to make the constructor private

* comment out debug printing to log file

* correct typo of treating self() as a var instead of a function

* utilise Localisation service as a singleton

* fix errent line that should have been commented

* remove phpinfo

* correct mistake in stock controller

* try storing app in apcu

* serialise inside the app closures

* get timings for db-changed-time

* get timings for db-changed-time

* store localisation service in apcu

* stor translations in apcu instead of localisation service (due to database connection)

* correct syntax error

* forgot to uncomment instance map

* correct indentation and variable out of scope

* more timings for app execution time

* try apc caching for views

* correct scope for Pot variable

* remove additional fopen

* correct timings for app build time

* correct timings for app object build time

* correct timings for app route build time

* get timings for routing timings

* get more in depth timings for routing loading

* fix more in depth timings for routing loading

* start investigating session auth middleware creation

* start investigating session auth middleware creation

* start investigating Login controller time

* start investigating Login controller time

* in depth look at Logincontroller timings

* comment out debug printing

* lazily obtain valus for page rendering

* correct syntax error

* correct scope of variable

* correct visibiity of methds inherited from BaseController

* missing use for Userfieldsservice

* lazy loading of open api spec

* lazy loading of users service

* lazy loading of batteries service

* lazy loading of services in controllers

* lazy loading of services in services

* correct mistake

* fix userservice

* fix userservice

* fix userfieldservice

* fix chores service

* fix calendar service

* remove Dockerfile used for development

* Remove docker compose file used for development

* Clean up app.php

* remove last diff

* Clean up base controller

* Clean up controllers

* lean up middleware

* Clean up and tuen all services into singletons

* remove debug from routes.php

* remove acpu from localisation

* Complete removal of acpu from localisation

* fixes for things broken

* More fixes following merge

* Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var.

* fix bug where getUsersService is declared twice

* bug fixes following merge

* bug fixes following merge

* bug fixes following merge

* bug fixes following merge

* bug fixes following merge

* Fix all the not working things...

* Deleted off-topic files

* Deleted off-topic files

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 17:47:47 +01:00
Bernd Bestel
2b1dc7756d Added new demo localization string 2020-02-24 13:44:23 +01:00
Bernd Bestel
de20699580 Updated recommended nginx try_files directive 2020-02-13 22:29:05 +01:00
Bernd Bestel
c58b396a55 Try 1 to fix the problem after Slim Framework 4 upgrade when running grocy in a subdirectory 2020-02-13 22:10:39 +01:00
Bernd Bestel
5dd78aa19a Remove accidentally added function 2020-02-11 19:36:15 +01:00
Bernd Bestel
3c4264c3a0 Reload the meal plan after consuming a recipe 2020-02-11 19:24:34 +01:00
Bernd Bestel
d4fa1a64c2 Upgrade Slim Framework to v4 (closes #561) 2020-02-11 17:42:03 +01:00
Bernd Bestel
d56aebc9b8 Don't crash when @stack['componentScripts'] is empty and properly format the output 2020-02-10 21:20:21 +01:00
Bernd Bestel
c266b53ff1 Added an ugly hack to prevent including the same component JS file multiple times 2020-02-10 20:21:52 +01:00
Bernd Bestel
a32206834b Make product card recipe ingredient indentation dynamic (references #556) 2020-02-10 19:30:49 +01:00
Bernd Bestel
aa787e765e Changelog, small changes and added missing localization strings for #556 2020-02-10 18:24:15 +01:00
kriddles
c5f38689fa Include product_group in recipe ingredient list (#556)
* Include product_group in recipe ingredient list

* Delete 0098.sql

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-02-10 18:04:57 +01:00
Bernd Bestel
6b8169a1f1 Changelog and small changes for #557) 2020-02-10 18:00:42 +01:00
kriddles
898ea26139 Recipe Overview recipePositionsResolved should only include normal recipes (#557) 2020-02-10 17:56:52 +01:00
Bernd Bestel
49edd011b4 Changelog and small fixes for #545 2020-02-09 21:50:56 +01:00
kriddles
7638254f14 Mealplan - use mealplan recipe_servings when consuming and adding missing recipe ingredients (#545) 2020-02-09 21:43:31 +01:00
Bernd Bestel
472c083bca Little changes, changelog and added missing localization strings for #555 2020-02-09 21:16:47 +01:00
kriddles
7be2d94cf7 View base servings on recipecard (#555) 2020-02-09 21:08:11 +01:00
Bernd Bestel
5a65f37f4a Little wording change/fix 2020-02-09 21:03:11 +01:00
Bernd Bestel
540ae2627a Changelog & small changes for #554 2020-02-09 21:01:29 +01:00
kriddles
2c0f7f0883 Default initial recipe add for mealplan to use recipe's base_servings (#554) 2020-02-09 20:57:25 +01:00
Bernd Bestel
97095d6e68 Typo... 2020-02-09 17:33:02 +01:00
Bernd Bestel
785dd30724 Fixed that the wrong FEATURE_FLAG was used (references #552) 2020-02-09 17:28:49 +01:00
Bernd Bestel
1953a26d7f Changelog and small changes for #552) 2020-02-09 17:27:46 +01:00
kriddles
13f99ad5f2 CalendarService reflect config options for GetEvents (#552) 2020-02-09 17:22:54 +01:00
Bernd Bestel
ba4dfa30a7 Added changelog 2020-02-09 17:17:30 +01:00
Bernd Bestel
62dae64a88 Make meal plan entries editable (references #545) 2020-02-09 17:15:13 +01:00
Bernd Bestel
0359003e09 Little changes for #551 2020-02-09 15:36:03 +01:00
Marc Ole Bulling
a0ab5c5e94 Add option to disable automatic switching to compact shoppinglist view on mobile devices (#551) 2020-02-09 15:25:54 +01:00
Bernd Bestel
e9f55de987 Fixed FullCalendar height was not calculated dynamically (fixes #549) 2020-02-09 15:24:05 +01:00
Bernd Bestel
3af5bd8e29 Scoll to the recipe card after selecting a recipe on mobile devices (closes #547) 2020-02-09 15:11:38 +01:00
Bernd Bestel
06fe308f31 Fixed recipeposform initial product quantity unit was not set 2020-02-04 20:04:48 +01:00
Bernd Bestel
35388b798c We don't need rounded borders on card headers 2020-02-04 19:51:39 +01:00
Bernd Bestel
35eb976706 Don't show nested-resolved recipe ingredients of the selected recipe 2020-02-04 19:49:09 +01:00
Bernd Bestel
a5277224f5 Reworked recipe card (fixes #543) 2020-02-04 19:48:00 +01:00
Bernd Bestel
fcfe62f4d3 Further optimize spacing to waste less space 2020-02-03 21:45:15 +01:00
Bernd Bestel
171d6af5e1 We don't need that switch-button, a native Boostrap button is enough and less disturbing 2020-02-03 21:21:42 +01:00
Bernd Bestel
58cff18b03 Improved the meal plan add-dialogs (closes #540) 2020-02-03 20:04:22 +01:00
Leroy Förster
b4a759c0fc Use full width for compact shopping list (#541)
I had luck with not enforcing any width, not even 100% and removed the
padding an margin overrides from the shoppinglist.js

I also tested it on a real Android device to be really sure.
2020-02-03 08:48:37 +01:00
Bernd Bestel
b9e32a9795 Fixed contextual time ago display was missing (references #513) 2020-02-02 17:55:35 +01:00
Bernd Bestel
9e519e0841 Annotate variable ingredient amounts (closes #530) 2020-02-02 17:26:32 +01:00
Bernd Bestel
ba1272ced8 Made the navbar a little smaller 2020-02-02 17:16:02 +01:00
Bernd Bestel
3ca6982c39 Don't show and use scan mode in embedded mode (dialogs) 2020-02-02 13:13:18 +01:00
Bernd Bestel
890663bf63 Fixed the "Shopping list to stock workflow" with disabled FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING (fixes #537) 2020-02-02 13:01:31 +01:00
Bernd Bestel
5effa0c103 Fixed recipeposform edit when "Only check if a single unit is in stock" is set (again closes #535) 2020-02-02 12:33:48 +01:00
Bernd Bestel
7235d9c0c9 Next try to fix scrolling issues on shopping list compact view (again closes #453) 2020-02-02 12:01:47 +01:00
Bernd Bestel
ad9f336035 Fix new recipe creation when reloading the /recipes/new page (fixes #536) 2020-02-01 18:16:44 +01:00
Bernd Bestel
23efe0c87a Added an option to hide the calendar on the shopping list (closes #531) 2020-02-01 12:55:12 +01:00
Bernd Bestel
683ea0984c Further optimized shopping list compact view (references #453) 2020-02-01 12:35:06 +01:00
Bernd Bestel
debb29ddaa Fixed recipeposform edit when "Only check if a single unit is in stock" is set (fixes #535) 2020-02-01 09:03:30 +01:00
Bernd Bestel
55c5501d96 Optimized recipeposform input ordering (closes #533) 2020-02-01 08:59:37 +01:00
Bernd Bestel
b8c6ac6905 Fixed location_id handling when FEATURE_FLAG_STOCK_LOCATION_TRACKING is disabled (fixes #532) 2020-01-31 21:27:51 +01:00
Bernd Bestel
170c7627fd Only apply fullscreen-no-gutters class when a fullscreen-card is displayed (references #453) 2020-01-31 18:17:39 +01:00
Bernd Bestel
72e18ed0a4 Show the shopping list notes field in compact view (references #453) 2020-01-31 17:58:47 +01:00
Bernd Bestel
6d4a15d372 Improve shopping list compact view (references #453) 2020-01-31 17:52:03 +01:00
Bernd Bestel
ce3b30f601 Prepared next release 2020-01-31 08:51:16 +01:00
Bernd Bestel
fcd421d17b Pulled translations from Transifex 2020-01-31 08:47:50 +01:00
Bernd Bestel
d4367808a2 Include 80 % complete translations in releases 2020-01-30 07:32:09 +01:00
Bernd Bestel
28e3f6226f Added the new hungarian translation 2020-01-30 07:30:46 +01:00
Bernd Bestel
caa4edf7e3 Added new demo_data localization string 2020-01-29 11:26:24 +01:00
Bernd Bestel
0e0c58542e Added the slovak localization 2020-01-29 11:19:43 +01:00
Bernd Bestel
15b4f2ede3 Added new demo_data localization string 2020-01-28 22:30:09 +01:00
Bernd Bestel
da92ac40c4 Always save the recipe before leaving/reloading the page (this now closes #520) 2020-01-28 21:04:59 +01:00
Bernd Bestel
eaacca61c2 Order product picker list by name on the recipe edit page (references #520) 2020-01-28 20:58:35 +01:00
Bernd Bestel
8d490351d0 Replaced jQuery UI by Animate.css (better, faster, lighter) 2020-01-28 19:27:18 +01:00
kriddles
6f549bdf3a Battery fix (#519)
* bugfix variable name

* Typo: curent->current
2020-01-28 08:44:25 +01:00
Bernd Bestel
a64b35e9d4 Made the sidebar menu items a little smaller 2020-01-27 22:34:48 +01:00
Bernd Bestel
0e41500a63 Properly check for any boolean value query parameter 2020-01-27 22:20:20 +01:00
Bernd Bestel
5d83ec7967 Typo 2020-01-27 22:17:19 +01:00
Bernd Bestel
e84c7063d3 Consume any subproduct when consuming a recipe ingredient which is not in stock (fixes #446) 2020-01-27 22:14:11 +01:00
Bernd Bestel
dceed6759a Added missing localization string 2020-01-27 20:23:05 +01:00
Bernd Bestel
0c0604c693 Properly space/divide userentities in the newly arranged sidebar 2020-01-27 20:22:49 +01:00
Bernd Bestel
4124b2eee8 Updated dashboard screenshot 2020-01-27 19:21:10 +01:00
Bernd Bestel
4c1c971f6d Rename /stockedit and /stockdetail to match the "naming conventions" (references #421) 2020-01-27 19:19:09 +01:00
Bernd Bestel
40730328b8 Updated README.md 2020-01-27 19:07:13 +01:00
Bernd Bestel
05aceb72ae Squashed commit
- Only refresh contextual number/datetime info/formatting where needed (closes #513)
- Also refresh correlated stock journal entries on undo (closes #471)
- Prefill "New amount" with the current stock amount on the inventory page (closes #434)
- Ensure that the location_id of the stock and stock_log tables is never empty after migration 95 (references #421)
- Load initial values of the /stockedit form server side to improve loading performance (references #421)
- Use more or less the same input ordering as on the purchase page for the /stockedit page (references #421)
- Also display the "Compact view" button on the shopping list page when FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS is disabled (references #453)
- Ensure that the currently active sidebar menu item is visible
- Optimized sidebar menu item grouping/spacing
- Properly order the API documentation route groups and put the "by-barcode" routes into a separate group
- Updated dependencies
- Pulled translations from Transifex
- Prepared changelog for next release
2020-01-27 19:00:49 +01:00
Bernd Bestel
9221d787a5 How many units are in stock doesn't really mean anything... 2020-01-26 21:18:09 +01:00
Bernd Bestel
4cc31a87e0 Added changelog RSS feed info to changelog 2020-01-26 21:03:32 +01:00
Bernd Bestel
2764bb680c Changed some localization strings 2020-01-26 20:13:15 +01:00
Bernd Bestel
71a57c9dcb Implement "Free products" (closes #426) 2020-01-26 20:01:30 +01:00
Bernd Bestel
f09ba08549 Typo... (references #517) 2020-01-26 18:02:12 +01:00
Bernd Bestel
430cd05278 Break long mealplan notes (fixes #517) 2020-01-26 18:00:29 +01:00
Bernd Bestel
a8f43a1d45 Added a quick video demo to showcase the new "Scan mode" feature 2020-01-26 16:43:46 +01:00
Bernd Bestel
bad19721db Make the scan mode switch-buttons a little bigger 2020-01-26 15:44:09 +01:00
Bernd Bestel
c7bcb9984a Implemented "Scan mode" 2020-01-26 15:35:01 +01:00
Bernd Bestel
7a048136c6 Added missing localization strings 2020-01-26 13:40:26 +01:00
kriddles
ac1be1e90f 450 updates (#518)
* prevent seeing undefinde if no recipes

* disable weekRecipeConsume if weekCosts are zero

* reword title

* Add meal plan notes and products to Calendar
2020-01-26 08:50:44 +01:00
Bernd Bestel
0ef9b2fdb7 Added a new setting to be able to start the meal plan on a different weekday (closes #429) 2020-01-25 20:01:40 +01:00
Bernd Bestel
d64a1a546c Finalize products on meal plan feature (references #450) 2020-01-25 19:42:46 +01:00
Bernd Bestel
98f70d1525 Finalize products on meal plan feature (references #450) 2020-01-25 18:36:54 +01:00
Bernd Bestel
aa97a8c301 Finalize products on meal plan feature (references #450) 2020-01-25 18:34:03 +01:00
kriddles
3762c1f799 450 consume meal plan product (#514)
* typo

* mealplan product consume
2020-01-25 18:02:50 +01:00
Bernd Bestel
e111d07f4e Added the ability to directly add products to the meal plan (closes #450) 2020-01-25 11:51:00 +01:00
Bernd Bestel
061f4da041 Don't try to switch twice to shopping list compact mode on mobile (references #453) 2020-01-25 08:49:17 +01:00
Bernd Bestel
3cbeea7d95 Added an option to filter for only undone items on the shopping list (closes #452) 2020-01-24 22:26:36 +01:00
Bernd Bestel
ad54253d72 Added a compact view for shopping list (for mobile shopping) (closes #453) 2020-01-24 22:05:08 +01:00
Bernd Bestel
fd5a72264d Meal plan recipe and notes also fit into one table (references #477) 2020-01-23 21:57:47 +01:00
Bernd Bestel
6663551a66 A day can have multiple meal plan notes (references #477) 2020-01-23 21:01:35 +01:00
Bernd Bestel
8d7f985b59 Make it possible to add notes to meal plan (days) (closes #477) 2020-01-23 20:59:19 +01:00
Bernd Bestel
594dc0858b Make sure that Grocy.CurrentUrlRelative is set without the query string (fixes #509) 2020-01-23 20:12:38 +01:00
Bernd Bestel
d7c7e0f53c Added missing localization string 2020-01-23 20:05:57 +01:00
Bernd Bestel
469dcefc7a Don't show not listable entites in Swagger UI (fixes #510) 2020-01-23 20:05:44 +01:00
Bernd Bestel
b4997abf75 Reload the page if a stock row cannot be found by id (references #506) 2020-01-23 19:13:35 +01:00
Bernd Bestel
99d4b05a3c Make purchased date on /stockedit editable / Dirty workaround for 2 datetimepickers on the same page (references #506) 2020-01-23 18:58:05 +01:00
kriddles
3baffcfe7b typo (#511) 2020-01-23 09:34:17 +01:00
Bernd Bestel
a9d235d9ce Added missing localization string 2020-01-22 22:36:21 +01:00
Bernd Bestel
6300a8fd09 Typo... 2020-01-22 22:36:01 +01:00
Bernd Bestel
ec2551d263 Little refinements for #507 2020-01-22 21:17:04 +01:00
kriddles
ef9f28d154 421 (#507)
* refactor to be stock/entry/{entryId}

* Allow recipeform add productworkflow

* on document ready stockdetail filter based on ProductPicker

* openDate fixes for undo

* RefreshStockDetailRow refresh location-id
2020-01-22 21:08:49 +01:00
Bernd Bestel
101355cae2 Added day summary (costs and calories) to the meal plan (closes #502) 2020-01-21 22:44:04 +01:00
Bernd Bestel
ca6c2b0af8 Also show calories per serving on the meal plan (references #502) 2020-01-21 22:02:53 +01:00
Bernd Bestel
5793f6b041 Fixed that meal plan week costs were missing for weeks 1 - 9 2020-01-21 21:54:22 +01:00
Bernd Bestel
22c978c8dc Preselect the default serving size when adding a nested recipe (closes #500) 2020-01-21 21:42:52 +01:00
Bernd Bestel
6f035fd64d Allow decimal numbers for the kcal field (closes #492) 2020-01-21 21:31:42 +01:00
Bernd Bestel
5cdfd30852 Added changelog for #501 2020-01-21 20:49:25 +01:00
Bernd Bestel
0816359867 Some refinements for #501 2020-01-21 20:45:34 +01:00
kriddles
3a36bdaf45 recipes can create products (#501) 2020-01-21 20:20:26 +01:00
Bernd Bestel
c22496ca7c Fixed /stockedit opened checkbox (references #506) 2020-01-21 20:04:33 +01:00
Bernd Bestel
f543a3a472 Fixed and optimized some things related to #421 (& some more cleanup) 2020-01-21 17:30:09 +01:00
Bernd Bestel
17e5c04bf9 Added changelog for #503 2020-01-19 09:53:58 +01:00
Bernd Bestel
d0036e8034 Tried to simplify #503 (also references #487) 2020-01-19 09:52:23 +01:00
Grégory SACRE
61a45c030f Feature request : api/stock can return detailed products #487 (#503)
The response of the call '/api/stock' now returns a new attribute
('product') which contains the details of the related product.
2020-01-19 09:14:07 +01:00
Bernd Bestel
cd522220ce Added changelog for #491 2020-01-17 18:15:45 +01:00
kriddles
7c2320e978 refresh productcard on save (#495) 2020-01-17 18:13:43 +01:00
Bernd Bestel
5de563f2c9 Added changelog for #489 2020-01-17 18:08:54 +01:00
kriddles
cdbfc3c3db productcard.js check null location (#494) 2020-01-17 18:06:33 +01:00
kriddles
2a608c41e9 Stock detail updates (#493)
* Fix spelling

* stockdetail refresh with location name

* Stock updates

* change stock_row_id to id

* fix stockdetail refresh rows after clicking undo

* fix stockdetail consume spoiled
2020-01-17 17:54:34 +01:00
Bernd Bestel
d4bec3bd10 Added a "keep screen on" option using NoSleep.js (closes #427) 2020-01-05 10:03:02 +01:00
Bernd Bestel
485eb262f9 Show some more info when camera access is not possible (closes #437) 2020-01-05 09:20:58 +01:00
Bernd Bestel
a8cf5ae9ab Handle demo mode via a setting instead of checking the existence of a file (closes #484) 2020-01-05 09:11:11 +01:00
Bernd Bestel
539334f5ee Fixed the response type description of the /stock/volatile API endpoint (fixes #460) 2020-01-03 15:03:03 +01:00
Bernd Bestel
e515f21d3b Fixed DataTables earch / don't search the first column with buttons/menus (fixes #440) 2020-01-03 14:18:56 +01:00
Bernd Bestel
6345e69922 Fixed tare weight handling min. amount on purchase was not calculated based on the products qu_factor_purchase_to_stock (fixes #457) 2020-01-03 14:10:43 +01:00
Bernd Bestel
8e26bd2c31 Allow partial units during inventory (fixes #459) 2020-01-03 13:55:14 +01:00
Bernd Bestel
675bf25927 Allow empty date(time) inputs when the field is not required (fixes #462( 2020-01-03 13:50:10 +01:00
Bernd Bestel
0be672aa48 Fixed that when FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS was set to false, the shopping list appeared empty after some actions (fixes #428) 2020-01-03 13:35:48 +01:00
Bernd Bestel
8da13ab22b Added changelog for #476 2019-12-21 12:38:15 +01:00
kriddles
36e8484046 Recipe form updates (#476)
* recipePosForm - hide when embeded productcard

* recipeposform: remove prefillByName for productPicker

* recipeform add data-product-id

* recipeposform cleanup extra clicks

* recipeform: bootbox the recipe pos edit button

* recipeform: bootbox the recipe pos add button

* recipeposform postMessage back

* recipeform reload if IngredientsChanged

* Fix page reload for new recipes (URL = /recipe/new)

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2019-12-21 12:36:02 +01:00
Bernd Bestel
2a361a9f72 Forgot to save strings.pot... 2019-12-19 20:11:34 +01:00
Bernd Bestel
bf81d8a794 Added changelog for #469 2019-12-19 20:10:21 +01:00
kriddles
e89832c3aa Check for Price Tracking in mealplan.js (#469) 2019-12-19 20:07:13 +01:00
Bernd Bestel
d617a72397 Again small localization string changes (references #421) 2019-12-19 20:03:27 +01:00
Bernd Bestel
b02e43aea8 Added changelog for #421 2019-12-19 20:00:47 +01:00
kriddles
6c7420ea08 Stock Service Updates (#421)
* viewjs consume: implement location and update stock specific

* Transfer Products

* services StockService#GetProductStockEntriesByLocation: add method

* services StockService#AddProduct: check for stock and locations

* services StockService: include location_id

* services StockService#LocationExists: add method

* services StockService#UndoBooking: fix based on stockRow

* Reimplement StockServer->TransferProduct (one loop for the whole action to preserve stock_id)

* Ensure that the location_id is never NULL in the stock and stock_log table (checked by an INSERT trigger, sets the products default location if empty)

* Only consider stock amount at the given location on consume, if supplied

* Restore more/old display text for "specific stock entry"

* Don't allow transfering tare weight enabled products

* Various small changes (code style, missing OpenAPI endpoint, remove location_id null checking)

* Updated translations strings

* Added transaction_id and correlation_id to stock_log entries to group them together

* ProductCard - location to default location label change

* Also undo correlated bookings on undo

* Added API endpoints for listing and undoing transactions and use them on purchase/consume/inventory/stockoverview

* Initial Stock detail page

* Allow Undo for Tranfers

* Price step to .01

* Some localization string changes & fixes
2019-12-19 19:48:36 +01:00
Bernd Bestel
0be1994c02 Added changelog for #456 and #458 2019-12-08 20:53:28 +01:00
beetle442002
275db21740 ExternalBarcodeLookup (#458)
* Changed line 173 to /stock/barcodes/external-lookup/{barcode} fixes grocy/grocy#456

* Changed line 173 to /stock/barcodes/external-lookup/{barcode} fixes grocy/grocy#456 and I changed grocy.openapi.json to reflect the change
2019-12-08 20:46:37 +01:00
Bernd Bestel
709afac1af Proper pt-br localization/demo 2019-11-26 11:13:14 +01:00
Bernd Bestel
9bd43cf67a Added the Portuguese translation files 2019-11-13 14:47:23 +01:00
Bernd Bestel
e493abf784 Dummy change to force-commit file (references #412) 2019-11-02 08:45:40 +01:00
Bernd Bestel
62b85cda0e Dummy change to force-commit file (references #412) 2019-11-02 08:45:30 +01:00
Bernd Bestel
7b0fdfe62e Renormalize line endings (closes #412) 2019-11-02 08:42:49 +01:00
Bernd Bestel
5d42cc15a6 Added a .gitattributes file (references #412) 2019-11-02 08:40:03 +01:00
Bernd Bestel
da2c8d48ac Changelog and code optimizations for pull request #420 2019-10-19 10:33:46 +02:00
Marc Ole Bulling
a0fc06f6ed Add GET parameter to close window after product creation (#420)
* Add GET parameter to close window after product creation

PR for issue #419

This only works when the window was opened by Javascript (eg. from a third party plugin like Barcode Buddy)

* Added flow if window closing fails

If the window could not be closed, the normal flow continues
Added comments

* Made GET parameter case insensitive
2019-10-19 10:26:18 +02:00
Bernd Bestel
e133508814 Delay DataTables search by 200ms (references #424) 2019-10-15 19:59:14 +02:00
Bernd Bestel
9e1804252e Centralize default DataTables init settings (references #424) 2019-10-15 19:38:51 +02:00
Lewis Juggins
1b0308f39d Improve mobile performance on stock overview (#424) 2019-10-15 19:24:23 +02:00
Lewis Juggins
9ba66aeac2 Rename location to "Default location" on product page (#416)
* Rename location to default location on product page

* Move resource
2019-10-12 14:27:15 +02:00
Bernd Bestel
3328c789d4 Fixed that the meal plan menu item was not visible when the calendar was disabled (through feature flags) (closes #415) 2019-10-12 10:35:47 +02:00
Bernd Bestel
68dc1bc1f9 Added changelog for #417 2019-10-12 10:25:39 +02:00
Bernd Bestel
21b9c1a8aa Always use the proper URL for meal plan links in iCal calendar export (references #417) 2019-10-12 10:22:17 +02:00
kriddles
c6ae8cc348 Calendar descriptions (iCal export) (#417)
* controllers CalendarApiController: setDescription for events

* services CalendarService: include link to mealplan in calendar descriptions
2019-10-12 10:16:06 +02:00
Bernd Bestel
744fd03633 Added a note that browser barcode scanning only works when served via a secure connection (closes #411) 2019-10-06 11:51:46 +02:00
Bernd Bestel
d994551f75 Pulled translations from Transifex 2019-10-05 13:15:54 +02:00
Bernd Bestel
ed4d292b23 Prepared next release 2019-10-05 13:14:28 +02:00
Bernd Bestel
700db9ae00 Added a new sub feature flag FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS 2019-10-05 13:10:56 +02:00
Bernd Bestel
ff92e8235f Added missing translation string (source language) 2019-10-04 11:27:59 +02:00
Bernd Bestel
ba6bfa6a2c Added a chore period type "yearly" (closes #407) 2019-10-04 11:24:51 +02:00
Bernd Bestel
28b23fd313 Implemented chore period intervals to have more flexible schedules (closes #312) 2019-10-04 11:14:11 +02:00
Bernd Bestel
554ac104f8 Added missing translation string 2019-10-04 10:31:06 +02:00
Bernd Bestel
039ed54a58 Optimized nested recipe resolving / prevent infinite nested recipes 2019-10-04 10:30:30 +02:00
Bernd Bestel
5d98140843 Added input shorthands for date fields to increase/decrease the date by 1 month/year (closes #405) 2019-10-02 16:06:44 +02:00
Bernd Bestel
420e4b933f Don't display QU conversions for other products on the product edit page (fixes #400) 2019-10-02 15:53:36 +02:00
Bernd Bestel
901b345714 Fixed/workaround for recipes_nestings_resolved view when recipe count > 100 (fixes #403) 2019-10-01 15:34:20 +02:00
Bernd Bestel
35b569c832 Pulled translations from Transifex 2019-09-28 13:27:20 +02:00
Bernd Bestel
d81fe4777c Prepared next release 2019-09-28 13:23:50 +02:00
Bernd Bestel
95208f5582 Updated unmanaged dependencies (font) 2019-09-28 08:53:59 +02:00
Bernd Bestel
dea2ffeaaf Added a "clear" button above the new notes field on the shopping list page 2019-09-28 08:48:58 +02:00
Bernd Bestel
e548caabb1 Formatting... 2019-09-27 17:32:52 +02:00
Bernd Bestel
2b0f5d8d84 Only do a product by barcode lookup if there is actually any input 2019-09-27 17:27:45 +02:00
Bernd Bestel
e9f2edea75 Optimize the initial state of the barcode scanner start button if the input element is disabled and make sure it does nothing, if the button is enabled however but the input element is disabled 2019-09-27 17:24:44 +02:00
Bernd Bestel
1b9a3c7f57 Fix that the barcode scanner start button overlaps everything 2019-09-27 17:03:50 +02:00
Bernd Bestel
2636456461 Show the journal of the product/chore/battery cards in a dialog 2019-09-27 16:54:40 +02:00
Bernd Bestel
81f6b58fe4 Added a button to jump to the journal on the product/chore/battery card 2019-09-27 14:19:06 +02:00
Bernd Bestel
9ba4585143 Reduce console.log spam 2019-09-27 14:08:24 +02:00
Bernd Bestel
4aa575e0e8 Display just "unlimited" on the product card for the average shelf life if it is > 200 years 2019-09-27 14:04:44 +02:00
Bernd Bestel
765f908966 Make it possible to provide the purchase price also as a total price (closes #390) 2019-09-27 13:50:16 +02:00
Bernd Bestel
9527305311 Userobjects list page print optimizations (closes #396) 2019-09-27 13:23:10 +02:00
Bernd Bestel
9d52f82bc2 Updated changelog for pull request #397 2019-09-27 08:35:15 +02:00
DeeeeLAN
6522aca30e Fixed navigation menu and full screen recipe smooth scrolling on iOS (#397)
* fixed barcode button on iOS and made nicer on the desktop

* fixed indentation

* fixed indentation

* fixed recipe ingredient layout issue in safari

* fixed navigation menu and full screen recipe smooth scrolling on iOS
2019-09-27 08:33:08 +02:00
Bernd Bestel
e59a35c6d1 Also refresh the parent product on sub product actions on the stock overview page (closes #394) 2019-09-27 08:30:08 +02:00
Bernd Bestel
cc2bf68f31 Fixed row highlighting after product actions on the stock overview page 2019-09-27 08:12:37 +02:00
Bernd Bestel
654d00dd67 Again corrections for #384) 2019-09-26 20:56:19 +02:00
Bernd Bestel
cf2e6f1039 Added a sub feature flag to disable chore assignments when not needed 2019-09-26 17:20:25 +02:00
Bernd Bestel
cf3217ada4 Fixed expired products count on stock overview page (fixes #392) 2019-09-26 16:42:59 +02:00
Bernd Bestel
21503c26d2 Use properly formatted numbers "everywhere" (partly references #389) 2019-09-26 15:25:30 +02:00
Bernd Bestel
7369603d78 Added missing localization string 2019-09-26 14:55:31 +02:00
Bernd Bestel
41e93d2c50 Little night mode improvements 2019-09-26 14:13:30 +02:00
Bernd Bestel
b39866bda2 Immediately refresh the QU conversion hint on key presses on the product edit page 2019-09-26 13:59:41 +02:00
Bernd Bestel
b8f9d09afc Don't remove products from stock overview on consuming all and the product has a min. stock amount & show it again on undo 2019-09-26 13:55:42 +02:00
Bernd Bestel
a2b6d9ae39 Various small UI refinements 2019-09-26 13:14:24 +02:00
Bernd Bestel
45d3c25b21 Again optimizations for #384 2019-09-26 13:13:49 +02:00
Bernd Bestel
2809cc1454 Typo... 2019-09-26 12:45:35 +02:00
Bernd Bestel
02f30d141e Reviewed/optimized last changes (references #384) 2019-09-26 12:43:00 +02:00
DeeeeLAN
c5927a10f3 fixed recipe ingredient layout issue in safari (#387)
* fixed barcode button on iOS and made nicer on the desktop

* fixed indentation

* fixed indentation

* fixed recipe ingredient layout issue in safari
2019-09-26 11:42:30 +02:00
Bernd Bestel
828ab8eba0 Allow accumulating min. stock amounts on parent product level (closes #384) 2019-09-26 10:36:49 +02:00
Bernd Bestel
75f8ecfad2 Updated the changelog and config-dist.php for #383) 2019-09-25 13:11:20 +02:00
Lewis Juggins
fd14083443 Support meal plan as default page (#383)
* Support meal plan as default page

* Update SystemController.php
2019-09-25 13:08:41 +02:00
Bernd Bestel
04808eaa66 Include the server timezone in iCal calendar export (closes #379) 2019-09-25 09:52:32 +02:00
Bernd Bestel
53f0893f55 Fix unit conversion handling (factor of destination qu is always 1) (fixes #382) 2019-09-25 09:32:06 +02:00
Bernd Bestel
2eb3d8fe47 Updated changelog for #378 / #380 2019-09-25 09:16:43 +02:00
DeeeeLAN
c0d79b1518 Fixed #378 (#380)
* fixed barcode button on iOS and made nicer on the desktop

* fixed indentation

* fixed indentation
2019-09-25 09:00:36 +02:00
Bernd Bestel
5351828e79 Reuse existing shopping list items when adding products from the stock overview page (closes #375) 2019-09-24 18:27:50 +02:00
Bernd Bestel
b0c7958891 Updated the changelog for #376 2019-09-24 15:53:48 +02:00
Marc Ole Bulling
f444d3e095 Fixed API call AddProductToShoppingList (#376)
$productId->id was undefined, therefore all items added to the shopping list with the API call had a null entry for "product_id"
2019-09-24 15:50:35 +02:00
Bernd Bestel
d8be254ff3 Link /barcodescannertesting page in settings menu 2019-09-24 10:43:10 +02:00
Bernd Bestel
49b26bd375 Return a Cache-Control header for files served via the API 2019-09-24 10:38:41 +02:00
Bernd Bestel
50e829f270 Hide the recipe interaction buttons when displayed as a fullscreen card (as the dialogs would be behind the fullscreen card) 2019-09-24 10:28:42 +02:00
Bernd Bestel
3b29110500 Never show close buttons in modal dialogs, this is not needed 2019-09-24 10:24:47 +02:00
Bernd Bestel
e727a38071 Improved the responsiveness of the "Create or assign product" dialog 2019-09-24 10:19:23 +02:00
Bernd Bestel
099ac7e75a Use exact matches for product barcode lookups (closes #366) 2019-09-24 09:52:05 +02:00
Bernd Bestel
53c56cc1cb Include meal plan recipes in the calendar (closes #368) 2019-09-24 09:40:56 +02:00
Bernd Bestel
2a9f927a13 Improved responsiveness of /mealplan and /calendar (closes #372 and closes #373) 2019-09-24 09:21:57 +02:00
Bernd Bestel
6bb9d2c51d Some little changes for pull request #369 (also references #367) 2019-09-24 08:35:30 +02:00
Bernd Bestel
ca719072c9 Merge branch 'master' of https://github.com/grocy/grocy 2019-09-24 08:14:07 +02:00
kriddles
66f61ec1ad public mealplan: add fullscreen recipe in popup (#369) 2019-09-24 08:13:42 +02:00
Bernd Bestel
cc500c50ff Fixed some types in the last changelog 2019-09-24 08:08:52 +02:00
Bernd Bestel
eef844d42e Optimized dropdown caret position a little bit 2019-09-23 20:19:53 +02:00
Bernd Bestel
e92843a9bf Added new demo strings 2019-09-23 13:21:02 +02:00
616 changed files with 98857 additions and 14292 deletions

View File

@@ -10,7 +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 -xr!publication_assets
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
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 a "%releasePath%\grocy_%version%.zip" "%projectPath%\data\.htaccess"
7za rn "%releasePath%\grocy_%version%.zip" .htaccess data\.htaccess

View File

@@ -1,4 +1,11 @@
pushd ..
tx pull --all --minimum-perc=90
tx pull --language en_GB
tx pull --all --minimum-perc=70 --force
tx pull --language en_GB --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
copy /Y localization\en\chore_period_types.po localization\en_GB\chore_period_types.po
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

8
.editorconfig Normal file
View File

@@ -0,0 +1,8 @@
root = true
[*]
indent_style = tab
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
* text=auto
*.sh text eol=lf

13
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,13 @@
---
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 describe the bug as detailed as possible, provide the steps how to reproduce it and maybe attach screenshots where useful.
Please also check if your bug was maybe already fixed by searching closed issues here or by trying to reproduce your problem on the [pre-release demo](https://demo-prerelease.grocy.info/) (use a *private demo instance* if you want to make your example persistent).

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

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

View File

@@ -0,0 +1,11 @@
---
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.

BIN
.github/publication_assets/chores.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
.github/publication_assets/mealplan.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

BIN
.github/publication_assets/stock.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

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

@@ -0,0 +1,95 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude(['vendor'])
->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,
'multiline_whitespace_before_semicolons' => false,
'single_quote' => true,
// 'blank_line_after_opening_tag' => true,
// 'blank_line_before_return' => true,
'braces' => [
'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' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'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_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")
->setUsingCache(false)
->setFinder($finder)
;

View File

@@ -42,3 +42,15 @@ 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]
file_filter = localization/<lang>/locales.po
source_file = localization/locales.pot
source_lang = en
type = PO

18
.vscode/settings.json vendored
View File

@@ -1,3 +1,17 @@
{
"phpserver.relativePath": "public"
}
"phpserver.relativePath": "public",
"editor.formatOnType": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.insertSpaces": false,
"javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
"javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
"javascript.preferences.quoteStyle": "double",
"blade.format.enable": true,
"html.format.wrapAttributes": "force",
"html.format.wrapLineLength": 0,
"php-cs-fixer.formatHtml": true,
"php-cs-fixer.autoFixBySemicolon": true,
"php-cs-fixer.onsave": true,
}

112
README.md
View File

@@ -1,76 +1,102 @@
# grocy
ERP beyond your fridge
<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>
<h4>grocy is a web-based self-hosted groceries & household management solution for your home<br>Created by <a href="https://github.com/berrnd">@berrnd</a></h4>
</div>
-----
## Give it a try
- Public demo of the latest stable version &rarr; [https://demo.grocy.info](https://demo.grocy.info)
- Public demo of the latest pre-release version (current master branch) &rarr; [https://demo-prerelease.grocy.info](https://demo-prerelease.grocy.info)
- 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)
## Getting in touch
There is the [r/grocy subreddit](https://www.reddit.com/r/grocy) to connect with other grocy users. 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 an issue in the [issue tracker](https://github.com/grocy/grocy/issues) here.
## 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.
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/new/choose) here.
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.
## Community contributions
See the website for a list of community contributed Add-ons / Tools: [https://grocy.info/#addons](https://grocy.info/#addons)
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!
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!
## How to install
> Checkout grocy-desktop, if you want to run grocy without a webserver just like a normal (windows) 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.
>
> See https://github.com/grocy/grocy-desktop or directly download the [latest release](https://releases.grocy.info/latest-desktop) - the installation is nothing more than just clicking 2 times "next"...
> Directly download the [latest release](https://releases.grocy.info/latest-desktop) - the installation is nothing more than just clicking 2 times "next".
Just unpack the [latest release](https://releases.grocy.info/latest) on your PHP (SQLite (3.8.3 or higher) extension required, currently only tested with PHP 7.3) enabled webserver (webservers root should point to the `public` directory), copy `config-dist.php` to `data/config.php`, edit it to your needs, ensure that the `data` directory is writable and you're ready to go, (to make it writable, maybe use `chown -R www-data:www-data data/`). Default login is user `admin` with password `admin`, please change the password immediately (see user menu).
See [https://grocy.info/links](https://grocy.info/links) for some installation guides and troubleshooting help.
Alternatively clone this repository and install Composer and Yarn dependencies manually.
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`)
- &rarr; Default login is user `admin` with password `admin`, please change the password immediately (user menu at the top right corner)
- _Currently everything is only tested against (means 100 % works with) PHP 8.0 with SQLite 3.27.2_
If you use nginx as your webserver, please include `try_files $uri /index.php;` in your location block.
If, however, your webserver does not support URL rewriting, set `DISABLE_URL_REWRITING` in `data/config.php` (`Setting('DISABLE_URL_REWRITING', true);`).
See the website for further installation guides and troubleshooting help: https://grocy.info/links
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.
## 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.
## 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`.
- 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)
- Empty the `data/viewcache` directory
- Visit the main route once to apply database migrations ([see below](https://github.com/grocy/grocy#database-migrations))
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.
(Language can be changed in `data/config.php`, e. g. `Setting('CULTURE', 'it');`)
The [pre-release demo](https://demo-prerelease.grocy.info) is available for any translation which is at least 80 % 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!
You can easily help translating grocy on [Transifex](https://www.transifex.com/grocy/grocy/dashboard/) 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.
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 % ([`strings` resource](https://www.transifex.com/grocy/grocy/strings/)) will be included in releases.
_RTL languages are unfortunately not yet supported._
## Things worth to know
### REST API & data model documentation
### REST API
See the integrated Swagger UI instance on [/api](https://demo.grocy.info/api).
### Barcode readers & camera scanning
Some fields 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.
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 [QuaggaJS](https://github.com/serratus/quaggaJS), totally offline / client-side camera stream processing). 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 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
_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._
### Input shorthands for date fields
For (productivity) reasons all date (and time) input fields use the ISO-8601 format regardless of localization.
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 `2021-05-17`
- `YYYYMMDD` gets expanded to the proper ISO-8601 notation
- Example: `20190417` will be converted to `2019-04-17`
- Example: `20210417` will be converted to `2021-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 never expire)
- Down/up arrow keys will increase/decrease the date by one day
- Example: `202107e` will be converted to `2021-07-31`
- `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 "Add as new **p**roduct" can be "pressed" by using the `P` key on your keyboard.
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.
@@ -80,15 +106,17 @@ There is no plugin included for any service, see the reference implementation in
### 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._
### 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 file `data/demo.txt` exists, 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.
### 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)).
@@ -100,15 +128,21 @@ Any help is more than appreciated. Feel free to pick any open unassigned issue a
See https://grocy.info/#say-thanks for more ideas 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.
## Screenshots
#### Dashboard
![Dashboard](https://github.com/grocy/grocy/raw/master/publication_assets/dashboard.png "Dashboard")
#### Stock overview
![Stock overview](https://github.com/grocy/grocy/raw/master/.github/publication_assets/stock.png "Stock overview")
#### Purchase - with barcode scan
![Purchase - with barcode scan](https://github.com/grocy/grocy/raw/master/publication_assets/purchase-with-barcode.gif "purchase-with-barcode")
#### Shopping List
![Shopping List](https://github.com/grocy/grocy/raw/master/.github/publication_assets/shoppinglist.png "Shopping List")
#### Consume - with manual search
![Consume - with manual search](https://github.com/grocy/grocy/raw/master/publication_assets/consume.gif "consume")
#### Meal Plan
![Meal Plan](https://github.com/grocy/grocy/raw/master/.github/publication_assets/mealplan.png "Meal Plan")
#### Chores overview
![Chores overview](https://github.com/grocy/grocy/raw/master/.github/publication_assets/chores.png "Chores overview")
## License
The MIT License (MIT)

136
app.php
View File

@@ -1,37 +1,11 @@
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use \Grocy\Helpers\UrlManager;
use \Grocy\Controllers\LoginController;
// Definitions for embedded mode
if (file_exists(__DIR__ . '/embedded.txt'))
{
define('GROCY_IS_EMBEDDED_INSTALL', true);
define('GROCY_DATAPATH', file_get_contents(__DIR__ . '/embedded.txt'));
define('GROCY_USER_ID', 1);
}
else
{
define('GROCY_IS_EMBEDDED_INSTALL', false);
define('GROCY_DATAPATH', __DIR__ . '/data');
}
// Definitions for demo mode
if (file_exists(GROCY_DATAPATH . '/demo.txt'))
{
define('GROCY_IS_DEMO_INSTALL', true);
if (!defined('GROCY_USER_ID'))
{
define('GROCY_USER_ID', 1);
}
}
else
{
define('GROCY_IS_DEMO_INSTALL', false);
}
use Grocy\Controllers\LoginController;
use Grocy\Helpers\UrlManager;
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';
@@ -39,6 +13,23 @@ require_once __DIR__ . '/vendor/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);
}
// Definitions for disabled authentication mode
if (GROCY_DISABLE_AUTH === true)
@@ -49,32 +40,67 @@ if (GROCY_DISABLE_AUTH === true)
}
}
// 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
if (!file_exists(GROCY_DATAPATH . '/viewcache'))
{
mkdir(GROCY_DATAPATH . '/viewcache');
}
// Setup base application
$appContainer = new \Slim\Container([
'settings' => [
'displayErrorDetails' => true,
'determineRouteBeforeAppMiddleware' => true
],
'view' => function($container)
{
return new \Slim\Views\Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
},
'LoginControllerInstance' => function($container)
{
return new LoginController($container, 'grocy_session');
},
'UrlManager' => function($container)
{
return new UrlManager(GROCY_BASE_URL);
},
'ApiKeyHeaderName' => function($container)
{
return 'GROCY-API-KEY';
}
]);
$app = new \Slim\App($appContainer);
AppFactory::setContainer(new DI\Container());
$app = AppFactory::create();
$container = $app->getContainer();
$container->set('view', function (Container $container) {
return new Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
});
$container->set('UrlManager', function (Container $container) {
return new UrlManager(GROCY_BASE_URL);
});
$container->set('ApiKeyHeaderName', function (Container $container) {
return 'GROCY-API-KEY';
});
// Load routes from separate file
require_once __DIR__ . '/routes.php';
// Set base path if defined
if (!empty(GROCY_BASE_PATH))
{
$app->setBasePath(GROCY_BASE_PATH);
}
if (GROCY_MODE === 'production' || GROCY_MODE === 'dev')
{
$app->add(new \Grocy\Middleware\LocaleMiddleware($container));
}
else
{
define('GROCY_LOCALE', GROCY_DEFAULT_LOCALE);
}
$authMiddlewareClass = GROCY_AUTH_CLASS;
$app->add(new $authMiddlewareClass($container, $app->getResponseFactory()));
// Add default middleware
$app->addRoutingMiddleware();
$errorMiddleware = $app->addErrorMiddleware(true, false, false);
$errorMiddleware->setDefaultErrorHandler(
new \Grocy\Controllers\ExceptionController($app, $container)
);
$app->add(new CorsMiddleware($app->getResponseFactory()));
ob_clean(); // No response output before here
$app->run();

View File

@@ -8,30 +8,30 @@
- 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://`)
- 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 barcocdes are not recognized properly, there is a little "barcode scanner testing page" at [/barcodescannertesting](https://demo.grocy.info/barcodescannertesting)
- 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)
- => Quick video demo: https://www.youtube.com/watch?v=Y5YH6IJFnfc
### Stock improvements/fixes
- Products can now have variations (nested products)
- Define the parent product for a product on the product edit page (only one level is possible, means a product which is used as a parent product in another product, cannot have a parent product itself)
- Parent and sub products can have stock (both are regular products, no difference from that side)
- On the stock overview page the aggregated amount is displayed next to the amount (sigma sign)
- On the stock overview page, the aggregated amount is displayed next to the amount (sigma sign)
- When a recipe needs a parent product, the need is also fulfilled when enough sub product(s) are in stock
- 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)
- Stock overview page improvements
- Options in the more/context-menu to directly open the purchase/consume/inventory pages prefilled with the current product in an popup/dialog
- 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
- Option in the more/context-menu to search for recipes containing the current product
- It's now possible to undo stock bookings ("Undo"-button in the success message, like it was already possible on the purchase/consume/inventory pages)
- Improved that on any stock changes the corresponding product table row is properly refreshed
- New `config.php` setting `FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT` to configure if opened products should be considered for minimum stock amounts (defaults to `true`, so opened products will now be considered missing by default - please change this setting if you want the old behaviour)
- New `config.php` setting `FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT` to configure if opened products should be considered for minimum stock amounts (defaults to `true`, so opened products will now be considered missing by default - please change this setting if you want the old behavior)
- The product description now can have formattings (HTML/WYSIWYG editor like for recipes)
- Products now have a new field for calories (kcal, per stock quantity unit)
- "Factor purchase to stock quantity unit" (product option) can now also be a decimal number when "Allow partial units in stock" is enabled
- New "Sub feature flags" in `config.php` to disable some sub-features (hide the corresponding UI elements) if you don't need them (all new feature flags default to `true`, so no changed behaviour when not configured)
- New "Sub feature flags" in `config.php` to disable some sub-features (hide the corresponding UI elements) if you don't need them (all new feature flags default to `true`, so no changed behavior when not configured)
- `FEATURE_FLAG_STOCK_PRICE_TRACKING` to disable product price tracking
- `FEATURE_FLAG_STOCK_LOCATION_TRACKING` to disable product location tracking
- `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` to disable product best before date tracking
@@ -45,17 +45,17 @@
- Shopping lists can now be printed (new button next to the add/delete shopping list button)
### Recipe improvements
- Based on the new linked quantity units, recipe ingredients can now use any product related unit, the amount is calculated according to the cnoversion factor of the unit relation
- Based on the new linked quantity units, recipe ingredients can now use any product related unit, the amount is calculated according to the conversion factor of the unit relation
- Based on the new calories field per product, the calories per recipe are now shown based on the selected servings (in the header, next to the costs)
- New option "price factor" per recipe ingredient (defaults to `1`) - the resulting costs of the recipe ingredient will be multiplied by that factor
- Use this for example for spices in combination with "Only check if a single unit is in stock" to not take the full price of a pack of pepper into account for a recipe
- The search field on the recipe overview page now also searches for product names of recipe ingredients (means it's possible to search an recipe by a product name)
- Fixed a problem where the meal plan did not load when a recipe, which was already added to a the meal plan, was deleted
- The search field on the recipe overview page now also searches for product names of recipe ingredients (means it's possible to search a recipe by a product name)
- Fixed a problem where the meal plan did not load when a recipe, which was already added to the meal plan, was deleted
### Chores improvements
- Chores can now be assigned to users
- Option per chore, different "assignment types" like "Random", "Who least did first", etc.
- On the chores overview page the list can be filterd to only show chores assigned to the currently logged in user (or to any other user)
- On the chores overview page, the list can be filtered to only show chores assigned to the currently logged in user (or to any other user)
- New option "Due date rollover" per chore which means the chore can never be overdue, the due date will shift forward each day when due
- New option "Consume product on chore execution" per chore to automatically consume a product when a chore execution is tracked
- When tracking an execution from the chores overview page, filters are re-applied afterwards (means when you have filtered the page to only show overdue chores and after the execution the chore is not overdue anymore, it will now be immediately hidden)
@@ -77,13 +77,13 @@
- Boolean settings provided via environment variables (so the strings `true` and `false`) are now parsed correctly (thanks @mduret)
- All uploaded pictures (currently for products and recipes) are now automatically downscaled to the appropriate size when serving them to improve page load times (this requires the `php-gd` extension, if not installed, images will not be downscaled)
- It's now possible to test plural forms of quantity units (button on the quantity unit edit page, only visible if the current language requires more than 2 plural forms)
- On the login page no menus and the sidebar is now hidden
- On the login page the sidebar an all top-navbar menus is now hidden
- New translations: (thanks all the translators)
- Danish (demo available at https://da.demo.grocy.info)
- Dutch (demo available at https://nl.demo.grocy.info)
- Internal change for how the localizations for the demo instances are handled
- For the pre-release demo now all currently supported languages are available (was already the case for the stable demo)
- Additionally all language files which reached the completion limit of 80 % will now be automatically pulled from Transifex 10 minutes past every hour (to have a kind of instant preview of changed tranlsations)
- Additionally all language files which reached the completion limit of 80 % will now be automatically pulled from Transifex 10 minutes past every hour (to have a kind of instant preview of changed translations)
- The URLs have changed, I'll try to keep all existing URLs redirecting properly for a long time
- If you want to link to the demo, please only use https://demo.grocy.info (stable demo) or https://demo-prerelease.grocy.info (current master branch demo)

View File

@@ -0,0 +1,37 @@
### Stock improvements/fixes
- Fixed that barcode lookups now compare the whole barcode, not parts of it (e. g. when you have two products with the barcodes `$1` and `$10` and scan `$1` maybe the product of `$10` was found till now)
- 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)
- 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)
### Shopping list improvements
- When adding a product to the shopping list from the new context/more menu from the stock overview page and if the product is already on the shopping list, the amount of that entry will be updated acccordingly instead of adding a new (double) shopping list item
- Added a "clear" button above the new notes field on the shopping list page to quickly clear the notes field with one click
### Recipe improvements/fixes
- Fixed a problem regarding quantity unit conversion handling for recipe ingredients of products with no unit relations, but only a different purchase/stock quantity unit
- It's now possible to display a recipe directly from the meal plan (new "eye button") (thanks @kriddles)
- Improved the responsiveness of the meal plan and calendar page by automatically switching to a day calendar view on smaller screens (thanks for the idea @kriddles)
### Chores improvements
- There is now a new sub feature flag `FEATURE_FLAG_CHORES_ASSIGNMENTS` to disable chore assignments if you don't need them (defaults to `true`, so no changed behavior when not configured)
### Calendar improvements
- The calendar now also contains all planned recipes from the meal plan on the corresponding day
- Improved that dates in the iCal calendar export now include the server timezone
### Custom lists/fields improvements
- Optimized the custom lists page that it can be printed properly (search field etc. is hidden when printing the page)
### General & other improvements/fixes
- Fixed that the browser barcode scanner button was not clickable on iOS Safari & other small styles fixes/improvements for iOS Safari (thanks @DeeeeLAN)
- It's now also possible to set the meal plan page as the default/entry page (`config.php` setting `ENTRY_PAGE`) (thanks @lwis)
- Some UI detail-refinements
- In the header of the product-/chore-/battery-card there is now also a button to directly jump to the journal of the current product/chore/battery
### API improvements/fixes
- The API Endpoint `GET /files/{group}/{fileName}` now also returns a `Cache-Control` header (defaults fixed to 30 days) to further increase page load times
- Fixed that the API endpoint `/stock/shoppinglist/add-product` failed when a product should be added which was not already on the shopping list (thanks @Forceu)

View File

@@ -0,0 +1,15 @@
### Stock fixes
- Fixed that product specific quantity unit conversions (product overrides) were also displayed on the product edit page of other products with the same stock quantity unit
### Recipe fixes
- Fixed that recipes were displayed without ingredients if the total recipe count was > 100
### Shopping list improvements
- Added a new sub feature flag `FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS` to disable multiple shopping lists if you only need one (defaults to `true`, so no changed behavior when not configured)
### Chores improvements
- Added a new period type "yearly" (for yearly schedules)
- Added a "period interval" option per chore to have more flexible schedules (possible for the daily/weekly/monthly/yearly schedules, means "schedule this chore only every x days/weeks/months" to have for example biweekly schedules)
### General & other improvements
- New Input shorthands for date fields to increase/decrease the date by 1 month/year (shift + arrow keys, see the full list [here](https://github.com/grocy/grocy#input-shorthands-for-date-fields))

View File

@@ -0,0 +1,85 @@
### 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
- 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
- The amount will always be filled with `1` after changing/scanning a product
- If all fields could be automatically populated (means for purchase the product has a default best before date set), the transaction is automatically submitted
- If not, a warning is displayed and you can fill in the missing information
- 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
- 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 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 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 "Add as barcode to existing product" workflow did not work twice when not switching the page inbetween
### Shopping list improvements/fixes
- Added a compact view to have a better shopping list for shopping trips (new button "Compact view" in the header, additionally this is automatically enabled on mobile devices / when screen width is < 768 px)
- It's now possible to filter for only undone (not striked through) items (new option in the "Filter by status" dropdown)
- Fixed that when `FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS` was set to `false`, the shopping list appeared empty after some actions
### Recipe improvements
- When consuming a recipe and if an ingredient is not in stock, but that product has any subproduct which is in stock, this gets now consumed (before consuming was not possible in that case)
- When adding or editing a recipe ingredient, a dialog is now used instead of switching between pages (thanks @kriddles)
### Meal plan improvements/fixes
- It's now possible to add notes per day (in the dropdown of the add button in the header of each day column)
- It's now possible to products directly (also in the dropdown of the add button in the header of each day column, maybe useful in combination with the new "Self produced products" feature)
- Added that the calories per serving are now also shown
- Added that the total costs and calories per day are displayed in the header of each day column
- Added a new `config.php` setting `MEAL_PLAN_FIRST_DAY_OF_WEEK` which can be used to start the meal plan on a different day (defaults to `CALENDAR_FIRST_DAY_OF_WEEK`, so no changed behavior when not configured)
- Fixed that when `FEATURE_FLAG_STOCK_PRICE_TRACKING` was set to `false`, prices were still shown (thanks @kriddles)
- Fixed that the week costs were missing for the weeks 1 - 9 of a year
### Calendar improvements
- Improved that meal plan events in the iCal calendar export now contain a link to the appropriate meal plan week in the body of the event (thanks @kriddles)
### Task fixes
- Fixed that a due date was required when editing an existing task
### API improvements/fixes
- The endpoint `/stock` now includes also the product object itself (new field/property `product`) (thanks @gsacre)
- The endpoint `/stock/products/{productId}/entries` can now include stock entries of child products (if the given product is a parent product and in addition to the ones of the given product) - new query parameter `include_sub_products` (defaults to `false` so no changed behavior when not supplied)
- New endpoints for the new stock transfer & stock entry edit capabilities
- Fixed that the route `/stock/barcodes/external-lookup/{barcode}` did not work, because the `barcode` argument was expected as a route argument but the route was missing it (thanks @Mikhail5555 and @beetle442002)
- Fixed the response type description of the `/stock/volatile` endpoint
### General & other improvements/fixes
- It's now possible to keep the screen on always or when a "fullscreen-card" (e. g. used for recipes) is displayed
- New user options in the display settings menu in the top right corner (defaults to disabled)
- Slightly optimized table loading & search performance (thanks @lwis)
- Added that the currently active sidebar menu item is always in view
- Reordered the sidebar menu items a little bit, grouped them by borders and made them a little smaller to waste less space
- Changed/removed some animations (and replaced jQuery UI by [Animate.css](https://daneden.github.io/animate.css/)) to improve responsiveness
- Fixed that also the first column (where in most tables only buttons/menus are displayed) in tables was searched when using the general search field
- Fixed that the meal plan menu entry (sidebar) was not visible when the calendar was disabled (`FEATURE_FLAG_CALENDAR`) (thanks @lwis)
- For integration: If a `GET` parameter `closeAfterCreation` is passed to the product edit page, the window will be closed on save (due to Browser restrictions, this only works when the window was opened from JavaScript) (thanks @Forceu)
- Fixed that the `update.sh` file had wrong line endings (DOS instead of Unix)
- Internal change: Demo mode is now handled via the setting `MODE` instead of checking the existence of the file `data/demo.txt`
- There is now a RSS feed for the changelog, subscribe to get notified about new releases: https://grocy.info/changelog/feed
- New translations: (thanks all the translators)
- Hungarian (demo available at https://hu.demo.grocy.info)
- Portuguese (Brazil) (demo available at https://pt-br.demo.grocy.info)
- Slovak (demo available at https://sk.demo.grocy.info)

View File

@@ -0,0 +1,49 @@
## !! Important notice
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`
- Fixed that products on the Location Content Sheet were not ordered by the product name
### Shopping list improvements/fixes
- Added an option to hide the month-calendar (in the shopping list settings / top right corner settings menu) (defaults to disabled, so please enable this option if you still want to have the month-calendar on the shopping list)
- Optimized the new compact view (there was a little too much white space at the sides of the page)
- Added an option to not switch to the new compact view on mobile devices automatically (in the shopping list settings / top right corner settings menu) (defaults to `false`, so no changed behavior when not configured) (thanks @Forceu)
- Fixed that the "Shopping list to stock workflow" did not work when `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` was set to `false`
### Recipe improvements/fixes
- Optimized the ordering of the inputs on the recipe ingredient edit page (moved "Only check if a single unit is in stock" before the amount)
- Variable ingredient amounts are now marked accordingly on the renedered recipe
- After selecting a recipe on mobile devices, the page now automatically scrolls to the recipe card
- Added the recipes base servings to be displayed on the recipe card and properly named the servings column in the recipes list/table (thanks @kriddles)
- Added that recipe ingredients can now also be displayed grouped by the products product group (additionally to the ingredient group, new option in the recipes settings / top right corner settings menu) (defaults to `false`, so no changed behavior when not configured) (thanks @kriddles)
- Fixed that when editing a recipe ingredient which had "Only check if a single unit is in stock" set, not any quantity unit could be picked and the amount stayed empty
- Fixed that when reloading the "new recipe"-page (or when it gets auto-reloaded due to "Auto reload on external changes" is enabled), for each reload a new recipe was created
- Fixed that the recipe "fullscreen card" was not correctly displayed
- Fixed that nested recipes showed all ingredients of the nested recipes twice
- Fixed that when displaying or consuming a recipe from the meal plan the serving amount was maybe wrong (was the one from the recipe instead the one from the meal plan entry) (thanks @kriddles)
- Fixed that the stock fulfillment counts on the recipe card were maybe wrong if that recipe was also added to the meal plan (thanks @kriddles)
- Fixed that the recipe page was reloaded when expanding a collapsed row on mobile (thanks @Mikhail5555)
### Meal plan improvements
- Improved that all add-dialogs can be submitted by using `ENTER` and that the next input is automatically selected after selecting a recipe/product
- Added an edit button to all types of meal plan entries
- When adding a recipe, the serving amount is now prefilled with the one of the selected recipe (thanks @kriddles)
- Fixed that the meal plan not used the full height on mobile devices
### Calendar fixes
- Fixed to only include events when the corresponding feature flag is enabled (e. g. don't show expiring products when `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` is set to `false`) (thanks @kriddles)
- Fixed that the calendar not used the full height on mobile devices
### API improvements/fixes
- The endpoint `/chores` now also includes the chore name (new field `chore_name`) (thanks @DarienFord)
### General & other improvements/fixes
- Big backend performance improvements (thanks @zebardy)
- Added a button to enable the device flash light on the camera barcode scanner popup (thanks @radim-ek)
- Optimized the top navbar height and overall spacing to waste less space
- Replaced the scan-mode-switch-button by a native button because it's less disturbing
- Fixed that the "contextual time ago" of date/time pickers was not displayed
- New translations: (thanks all the translators)
- Czech (demo available at https://cs.demo.grocy.info)
- Portuguese (Portugal) (demo available at https://pt-pt.demo.grocy.info)

View File

@@ -0,0 +1 @@
Security fix (see [#696](https://github.com/grocy/grocy/issues/696))

View File

@@ -0,0 +1,66 @@
### 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)
- => The price history chart on the product card shows a line per store
- (Thanks @immae and @kriddles)
### Stock improvements/fixes
- When creating a new product, the "QU id stock" is now preset by the "QU id purchase" (because most of the time that's most probably the same) (thanks @Mik-)
- Clarified the row-button colors and toolips on the stock entries page
- Added a camera-barcode-scanning-button to the barcode(s) field on the product edit page to be able to also scan barcodes by the device camera there
- Added a new option (stock settings / top right corner settings menu) to show an icon on the stock overview if the product is already on the shopping list (next to the amount) (defaults to enabled)
- Fixed that the aggregated parent product amount (displayed on the stock overview page and on the product card) did not respect quantity unit conversions when the parent/sub products had different stock quantity units (the unit conversion needs to be globally defined, or as an override on the sub product)
- Fixed the conversion factor hint to display also decimal places on the purchase page (only displayed when the product has a different purchase/stock quantity unit)
- Fixed that the stock entries page was broken when there were product userfields defined with enabled "Show as column in tables"
- Fixed that best before dates were displayed on the stock overview and stock entries page even with disabled `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING`
- Fixed that when editing a stock entry and setting a decimal amount, the decimal part was ignored (only possible when the product option "Allow partial units in stock" is enabled)
- Fixed that "Default best before days" and "Default best before days after opened" on the product edit page were always shown regardless of the feature flags `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` and `FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING`
- Fixed that the form validation limits for the amount input and products with enabled tare weight handling were wrong
- Fixed that the price was saved wrong for products with a different purchase/stock quantity unit when using "Total price" on purchase (resulted for example in wrong recipe costs)
- Fixed that undoing "product-opened"-actions was not possible
- Fixed/improved consuming from the stock overview page for products with enabled tare weight handling ("consume 1" button is now disabled for such products, "consume all" works again)
### Shopping list improvements/fixes
- It's now possible to collapse/expand the product group sections (by clicking on the grey group header)
- Fixed that the "shopping list to stock workflow"-dialog was not visible in compact view
- Fixed that when printing the shopping list, configured userfields were not included
### Recipe fixes
- Fixed that when editing an ingredient with "Only check if a single unit is in stock" set, the quantity unit was always set to the products stock quantity unit regardless if a different one was selected for that ingredient
- Fixed a PHP notice on the recipes page when there are no recipes (thanks @mrunkel)
### Chores fixes
- Fixed that weekly chores, where the next execution should be in the same week, were scheduled always for the next week only
### Calendar fixes
- Fixed that the "Share/Integrate calendar (iCal)" button did not work (thanks @tsia)
### API improvements/fixes
- New endpoint `/user/settings` to get all user settings of the currently logged in user (key/value pairs)
- New endpoint `/system/config` to get all config settings (`config.php`) (key/value pairs)
- The endpoint `/stock/products/{productId}/locations` now also returns the current stock amount of the product in that loctation (new field/property `amount`) (thanks @Forceu)
- The endpoints `/objects/{entity}` and `/objects/{entity}/{objectId}` now also include/return userfields of the object(s) (new field/property `userfields` per object, key/value pairs or `null`, when the object has no userfields)
- Fixed that CORS was broken (there was no response to preflight OPTIONS requests)
### General & other improvements/fixes
- Optimized that sometimes the corresponding form was not validated when selecting a date from the datetimepicker
- New `config.php` setting `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_FIELD_NUMBER_PAD` which activates the number pad for best-before-date fields on (supported) mobile browsers (useful because of [shorthands](https://github.com/grocy/grocy#input-shorthands-for-date-fields)) (defaults to `true`) (thanks @Mik-)
- Enhancements for the camera barcode scanner
- Torch / light improvements (thanks @Mik-)
- The light button is only displayed when the device has a flash light
- New `config.php` setting `FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA` to always enable the flash light automatically
- It's now possible to change the camera when the device has more than one (dropdown in the camera scanning dialog, only visible if there is more than one camera available) (thanks @MichaelMadsen)
- Replaced [QuaggaJS](https://github.com/serratus/quaggaJS) (seems to be unmaintained) by [Quagga2](https://github.com/ericblade/quagga2)
- New user setting `quagga2_numofworkers` (`config.php`) to make the Quagga2 setting "numOfWorkers" adjustable (defaults to `4`)
- Various display/CSS improvements (thanks @Mik-)
- Prerequisites (PHP extensions, critical files/folders) will now be checked and properly reported if there are problems (thanks @Forceu)
- Improved the the overview pages on mobile devices (main column was hidden) (thanks @Mik-)
- The general search field now searches accent insensitive (and table sorting is also accent insensitive)
- Fixed that all number inputs are always prefilled in the browser locale number format
- Optimized the handling of settings provided by `data/settingoverrides` files (thanks @dacto)
- Optimized the update script (`update.sh`) to create the backup tar archive before writing to it (was a problem on Btrfs file systems) (thanks @shane-kerr)
- Fixed (again) that the `update.sh` file had wrong line endings (DOS instead of Unix)
- New translations: (thanks all the translators)
- Japanese (demo available at https://ja.demo.grocy.info)
- Chinese (Taiwan) (demo available at https://zh-tw.demo.grocy.info)

View File

@@ -0,0 +1,2 @@
- Fixed that camera barcode scanning was broken
- Fixed that the new prerequisites check handled things incorrectly in Docker images and in embedded mode

View File

@@ -0,0 +1,279 @@
> ⚠️ The major version bump is due to breaking API changes, please see below if you use the API
> ⚠️⚠️ 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 in [README mentioned](https://github.com/grocy/grocy#how-to-install) minimum runtime requirement, any future release will only be tested against a reasonable recent runtime (currently 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
- 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
- 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
- Creating API keys on the "Manage API keys"-page (top right corner settings menu) now requires the `ADMIN` permission
- Other users only see their API keys on that page
- (Thanks @fipwmaqzufheoxq92ebc for the initial work on this)
### 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)
- 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)
- (Thanks @fipwmaqzufheoxq92ebc for the initial work on this)
### Stock improvements/fixes
- Changes about best before dates: It's now possible to distinguish between best before dates and expiration dates:
- New product option "Due date type" (defaults to "Best before date")
- Wording changes:
- All current places where "Best before date" was used now use "Due date"
- Products with `Due date type = Best before date` (so all existing products) are "due" or "overdue" (they don't "expire" or are "expired")
- Products with `Due date type = Expiration date` (new option) can "expire" or are "expired"
- Color changes:
- Products which are due soon or expire soon are (still) highlighted in yellow
- Products which are overdue are highlighted in grey (there is also a new filter button on the stock overview page for them)
- Products which are expired (new option) are highlighted in red
- When creating a quantity unit conversion it's now possible to automatically create the inverse conversion (thanks @kriddles)
- The product option "Allow partial units in stock" was removed, partial amounts are now possible by default for all products
- On purchase there is now a warning shown, when the due date of the purchased product is earlier than the next due date in stock (enabled by default, can be disabled by a new stock setting (top right corner settings menu))
- The amount to be used for the "quick consume/open buttons" on the stock overview page can now be configured per product (new product option "Quick consume amount", defaults to 1)
- This "Quick consume amount" can optionally also be used as the default on the consume page (new stock setting / top right corner settings menu)
- 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)
- 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)
- 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
- It's now tracked who made a stock change (currently logged in user, visible on the stock journal page) (thanks @fipwmaqzufheoxq92ebc)
- Product edit page improvements ("Save & continue" button, deleting and adding a product picuture is now possible in one go) (thanks @Ma27)
- For products with tare weight handling enabled, it's now optionally possible to consume a fixed/exact amount (just like for "normal" products) in case you don't want to weigh the whole container this time (new checkbox on the consume page) (thanks @fipwmaqzufheoxq92ebc)
- The stock overview page now also shows the value - new column and also the total value in the header (thanks @kriddles)
- It's now possible to set a custom purchased date on purchase (new field on the purchase and inventory page, hidden by default - enable it by a new stock setting (top right corner settings menu)) (thanks @kriddles)
- The decimal places for all amount and price inputs can now be configured (stock settings / top right corner settings menu, default for amounts is `4`, for prices `2`)
- When clicking the product name on the shopping list, the product card will now be displayed (like on the stock overview page) (thanks @kriddles)
- On the product card there is now also a button to jump directly to the stock entries of the corresponding product (thanks @kriddles)
- The product picker workflows can now also be started by `ENTER` (additionally to `TAB`)
- Added a "retry camera barcode scan" button (button with camera icon, shortcut `C`) to the product picker workflow dialog
- Added more filters on the stock journal page
- Added a grouped/summarized stock journal (new button "Journal summary" at the top of the stock journal page) (thanks @fipwmaqzufheoxq92ebc)
- Provides an overview of summarized transactions per product, transaction type and user + summarized amount
- The product option "Default due days after freezing" now also supports `-1` (like the option "Default due days") to set the product to "never due" on freezing
- Fixed that changing the products "Factor purchase to stock quantity unit" not longer messes up historical prices (which results for example in wrong recipe costs) (thanks @kriddles)
- Fixed that when adding products through a product picker workflow and when the created products contains special characters, the product was not preselected on the previous page (thanks @Forceu)
- Fixed that when editing a product the default store was not visible / always empty regardless if the product had one set (thanks @kriddles)
- Fixed that `FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT` (option to configure if opened products should be considered for minimum stock amounts) was not handled correctly (thanks @teddybeermaniac)
- Fixed that the "Due soon" sum (yellow filter button) on the stock overview page didn't include products which are due today (thanks @fipwmaqzufheoxq92ebc)
- Fixed that the shopping cart icon on the stock overview page was also shown if the product was on an already deleted shopping list (if enabled) (thanks @fipwmaqzufheoxq92ebc)
- Fixed that when editing a stock entry without a price, the price field was prefilled with `1`
- Fixed that the location & product groups filter on the stock overview page used a contains search instead of an exact search
- Fixed that the amount on the success popup was wrong when consuming a product with "Tare weight handling" enabled
- Fixed that the aggregated amount of parent products was wrong on the stock overview page when the child products had not the same stock quantity units
- Fixed that edited stock entries were not considered for the price history chart on the product card
- Fixed that `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` is set to `false`, the purchase page validation failed (thanks @fipwmaqzufheoxq92ebc)
- Fixed that consuming (and editing the amount of) products with enabled tare weight handling did not work on the stock entries page
- Fixed that the recipes dropdown on the consume page also displayed internal recipes (thanks @kriddles)
- Fixed that opening tare weight handling enabled products is prevented via the UI and the API (as this makes no sense)
- Fixed that undoing a consume transaction of an opened item added it back to stock unopened
- 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)
- 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)
- Fixed that "Add products that are below defined min. stock amount" always rounded up the missing amount to an integral number, this now allows decimal numbers
### Recipe improvements/fixes
- It's now possible to print recipes (button next to the recipe title) (thanks @zsarnett)
- Changed that recipe costs are now based on the costs of the products picked by the default consume rule ("Opened first, then first due first, then first in first out") (thanks @kriddles)
- Recipe costs were based on the last purchase price per product before, so this now better reflects the current real costs
- Improved the recipe add workflow (a recipe called "New recipe" is now not automatically created when starting to add a recipe) (thanks @zsarnett)
- On the recipe page, the calories and costs per ingredient are now shown to get a better overview of how much each ingredient contributed
- Fixed that images on the recipe gallery view were not scaled correctly on larger screens (thanks @zsarnett)
- Fixed that decimal ingredient amounts maybe resulted in wrong conversions or truncated decimal places if your locale does not use a dot as the decimal separator (thanks @m-byte)
- Fixed that a recipe cannot be included in itself (because this will cause an infinite loop) (thanks @fipwmaqzufheoxq92ebc)
- Fixed that when editing a recipe ingredient the checkbox "Disable stock fulfillment checking for this ingredient" was not initaliased with the saved value
- Fixed that the status filter ("Enough in stock", etc.) on the recipes page did not filter recipes on the gallery tab (thanks @fipwmaqzufheoxq92ebc)
- Fixed that consuming a recipe ingredient with tare weight handling enabled consumed a wrong amount (thanks @fipwmaqzufheoxq92ebc)
- Fixed that consuming a parent product recipe ingredient did not consider quantity unit conversion when effectively consuming a child product
### Meal plan fixes
- Fixed that for products the quantity unit purchase was displayed instead of the products quantity unit stock (thanks @BenoitAnastay)
### Chores improvements/fixes
- Chores can now be disabled to keep the history/journal, but hide it everywhere, without deleting it (new chore option "Active", deleting a chore now explicitly also deletes its journal and all other references)
- Changed that not assigned chores on the chores overview page display now just a dash instead of an ellipsis in the "Assigned to" column to make this more clear (thanks @Germs2004)
- The assignment type "Random" now don't prevents anymore that the last user will be assigned next
- Fixed (again) that weekly chores, where the next execution should be in the same week, were scheduled (not) always (but sometimes) for the next week only (thanks @shadow7412)
- Fixed that the assignment type "In alphabetic order" did not work correctly (the last person in the list was always assigned next once reached) (thanks @fipwmaqzufheoxq92ebc)
### Equipment improvements
- There is now a button to download the instruction manual (next to the "expand to fullscreen"-button)
### Calendar improvements/fixes
- Events are now links to the corresponding page (thanks @zsarnett)
- Fixed a PHP warning when using the "Share/Integrate calendar (iCal)" button (thanks @tsia)
- Fixed that "Track date only"-chores were always displayed at 12am (are now displayed as all-day events)
- Fixed that it was not possible to switch to an other view than the default one on mobile (thanks @PhyberApex)
### Tasks improvements
- Tasks don't need to unique anymore (name field)
### Batteries improvements
- Batteries can now be disabled to keep the history/journal, but hide it everywhere, without deleting it (new battery option "Active", deleting a battery now explicitly also deletes its journal and all other references)
### Userfield improvements/fixes
- New Userfield type "File" to attach any file, will be rendered as a link to the file in tables (if enabled) (thanks @fipwmaqzufheoxq92ebc)
- New Userfield type "Picture" to attach a picture, the picture will be rendered (small) in tables (if enabled) (thanks @fipwmaqzufheoxq92ebc)
- New Userfield type "Link (with title)" - a link with a title (two input fields), so that the title is rendered in tables (if enabled) instead of the link itself
- Userfields can now be reordered on the input form (new field "Sort number" per Userfield, fields will be ordered by that number, if any)
- Users can now also have Userfields
### General & other improvements/fixes
- UI refresh / style improvements (thanks @zsarnett for the idea and initial work on this)
- Improved mobile views (thanks @4lloyd for the idea and initial work on this)
- The buttons on the top of each page and the filter row is now collapsed (use the ellipsis/filter button to show them, this also superseded the shopping list compact view)
- Tables are horizontally scrollable (instead of collapsing columns which don't fit)
- All tables are now customizable (new little eye icon on the top left corner on each table)
- Table columns be shown/hidden
- There are also new columns on some pages, hidden by default
- Stock overview: Value, Product group, Calories, Last purchased, Last price, Min. stock amount
- Products list: Default store
- Shopping list: Last price (Unit), Last price (Total), Default store, Barcodes (as scannable code-image)
- Row grouping can be customized to use any available column (thanks @edenhaus)
- Table states (visible columns, sorting, column order and so on) are now saved server side (in user settings) means that this stays the same when using different browsers
- Dialogs are now used everywhere where appropriate instead of jumping between pages (for example when adding/editing shopping list items)
- Added a "Clear filter"-button on all pages (with filters) to quickly reset applied filters
- Users can now have a picture (will then be shown next to the current user name instead of the generic user icon)
- Prefilled number inputs now use sensible decimal places (max. the configured decimals while hiding trailing zeros where appropriate, means if you never use partial amounts for a product, you'll never see decimals for it)
- Improved / more precise validation messages for number inputs
- Optimized what's hidden when `GROCY_FEATURE_FLAG_STOCK` is disabled
- 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)
- 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)
- Additionally, the language is now also auto-guessed based on the browser locale (HTTP-Header `Accept-Language`)
- The `config.php` option `CULTURE` was renamed to `DEFAULT_LOCALE`
- So the used language is based on (in that order)
- The user setting
- If not set, then based on browser locale
- If no matching localizaton was found, `DEFAULT_LOCALE` from `config.php` is used
- Performance improvements (page loading time) of the stock overview page (thanks @fipwmaqzufheoxq92ebc)
- The prerequisites checker now also checks for the minimum required SQLite version (thanks @Forceu)
- Replaced (again, added before in v2.7.0, then reverted in v2.7.1 due to some problems) [QuaggaJS](https://github.com/serratus/quaggaJS) (seems to be unmaintained) by [Quagga2](https://github.com/ericblade/quagga2)
- More `config.php` settings (see the section `Component configuration for Quagga2`) to tweak Quagga2 (this is the component used for device camera for barcode scanning) (thanks @andrelam)
- Some localization string fixes (thanks @duckfullstop)
- Better error pages
- Fixed that numeric and date-time sorting of table columns did not work correctly
- Fixed that XSS / HTML injection was possible through some user input fields (low severity / not really a problem as this could not be abused unauthenticated)
- New translations: (thanks all the translators)
- Greek (demo available at https://el.demo.grocy.info)
- Korean (demo available at https://ko.demo.grocy.info)
- Chinese (China) (demo available at https://zh-cn.demo.grocy.info)
- Tamil (demo available at https://ta.demo.grocy.info)
- Finnish (demo available at https://fi.demo.grocy.info)
### API improvements/fixes
- ⚠️ **Breaking changes**:
- 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 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`
- The field `expiring_products` was renamed to `due_products`
- The field `expired_products` now only contains expired products (so them with `Due date type = Expiration date`)
- The new field `overdue_products` contains only overdue products (so them with `Due date type = Best before date`)
- The following endpoints now return all bookings of the transaction (so the response is now an array, was before a single stock booking - and a random one if the transaction affected multiple stock entries)
- PUT `/stock/entry/{entryId}`
- POST `/stock/products/{productId}/add`
- POST `/stock/products/{productId}/consume`
- POST `/stock/products/{productId}/transfer`
- POST `/stock/products/{productId}/inventory`
- POST `/stock/products/{productId}/open`
- POST `/stock/products/by-barcode/{barcode}/add`
- POST `/stock/products/by-barcode/{barcode}/consume`
- POST `/stock/products/by-barcode/{barcode}/transfer`
- POST `/stock/products/by-barcode/{barcode}/inventory`
- POST `/stock/products/by-barcode/{barcode}/open`
- (The response is the same as if you would fetch the stock transaction via `/stock/transactions/{transactionId}`)
- For better integration (apps), it's now possible to show a QR-Code for API keys (thanks @fipwmaqzufheoxq92ebc)
- New QR-Code button on the "Manage API keys"-page (top right corner settings menu), the QR-Codes contains `<API-Url>|<API-Key>`
- And on the calendar page when using the button "Share/Integrate calendar (iCal)", there the QR-Codes contains the Share-URL (which is displayed in the textbox above)
- The output of the following endpoints can now be filtered (by any field), ordered and paginated (thanks for the initial work on this @fipwmaqzufheoxq92ebc)
- `/objects/{entity}`
- `/stock/products/{productId}/entries`
- `/stock/products/{productId}/locations`
- `/recipes/fulfillment`
- `/users`
- `/tasks`
- `/chores`
- `/batteries`
- There are 4 new (optional) query parameters to utilize that
- `order` The field to order by (use the separator `:` to specify the sort order - `asc` or `desc`, defaults to `asc` when omitted)
- `limit` The maximum number of objects to return
- `offset` The number of objects to skip
- `query[]` An array of conditions, each of them is a string in the form of `<field><condition><value>`, where
- `<field>` is a field name
- `<condition>` is a comparison operator, one of
- `=` equal
- `!=` not equal
- `~` LIKE
- `!~` not LIKE
- `<` less
- `>` greater
- `<=` less or equal
- `>=` 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 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
- New endpoint POST `/stock/products/{productIdToKeep}/merge/{productIdToRemove}` for the new product merging feature mentioned above
- The following entities are now also available via the endpoint `/objects/{entity}` (only listing, no edit)
- `stock_log` (the stock journal)
- `stock` (the "raw" stock entries)
- `stock_current_locations` (info how much of each product is currently stored at which location)
- Performance improvements of the `/stock/products/*` endpoints (thanks @fipwmaqzufheoxq92ebc)
- The endpoint `/stock/products/{productId}/locations` now also has an optional query parameter `include_sub_products` to optionally also return locations of sub products of the given product
- The following endpoints now have an optional request body parameter `allow_subproduct_substitution` to consume/open any child product when the given product is a parent product and currently not in stock
- `/stock/products/{productId}/consume`
- `/stock/products/by-barcode/{barcode}/consume`
- `/stock/products/{productId}/open`
- `/stock/products/by-barcode/{barcode}/open`
- Fixed that the endpoint `/objects/{entity}/{objectId}` always returned successfully, even when the given object not exists (now returns `404` when the object is not found) (thanks @fipwmaqzufheoxq92ebc)
- Fixed that the endpoint `/stock/volatile` didn't include products which are due today (thanks @fipwmaqzufheoxq92ebc)
- Fixed that the endpoint `/objects/{entity}` did not include Userfields for Userentities (so the effective endpoint `/objects/userobjects`)
- Fixed that the endpoint `/stock/consume` returned the response code `200` and an empty response body when `stock_entry_id` was set (consuming a specific stock entry) but invalid (now returns the response code `400`) (thanks @fipwmaqzufheoxq92ebc)
- Fixed that the endpoint `/user/settings/{settingKey}` didn't return the default setting if it was not configured for the current user (same behavior as the endpoint `/user/settings` now)
- Endpoint `/calendar/ical`: Fixed that "Track date only"-chores were always set to happen at 12am (are treated as all-day events now)
- Fixed (again) that CORS was broken

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 in [README mentioned](https://github.com/grocy/grocy#how-to-install) minimum runtime requirement, any future release will only be tested against a reasonable recent runtime (currently 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,127 @@
> ⚠️ The following PHP extensions are now additionally required: `json`, `intl`, `zlib`
> ⚠️ PHP 8 is now supported and from now on the only tested runtime version (although currently PHP 7.2 should still work).
### 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 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" productpicker 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

@@ -1,14 +1,20 @@
{
"require": {
"php": ">=7.2",
"slim/slim": "^3.12.2",
"morris/lessql": "^0.4.1",
"rubellum/slim-blade-view": "^0.1.1",
"tuupola/cors-middleware": "^1.0.0",
"eluceo/ical": "^0.15.1",
"erusev/parsedown": "^1.7.3",
"gettext/gettext": "^4.6.3",
"gumlet/php-image-resize": "^1.9.2"
"php": "^8.0",
"slim/slim": "^4.0",
"slim/psr7": "^1.0",
"slim/http": "^1.0",
"php-di/php-di": "^6.0",
"berrnd/slim-blade-view": "^1.0.0",
"morris/lessql": "^1.0",
"gettext/gettext": "^4.8",
"eluceo/ical": "^2.2.0",
"erusev/parsedown": "^1.7",
"gumlet/php-image-resize": "^2.0",
"ezyang/htmlpurifier": "^4.13",
"interficieis/php-barcode": "^2.0.2",
"guzzlehttp/guzzle": "^7.0",
"mike42/escpos-php": "^3.0"
},
"autoload": {
"psr-4": {
@@ -20,5 +26,8 @@
"files": [
"helpers/extensions.php"
]
},
"config": {
"platform-check": false
}
}

2916
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,114 +1,201 @@
<?php
# Settings can also be overwritten in two ways
#
# 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
# An environment variable with the same name as the setting and prefix "GROCY_"
# so for example "GROCY_BASE_URL"
#
# Third priority
# The settings defined here below
// Settings can also be overwritten in two ways
//
// 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
// An environment variable with the same name as the setting and prefix "GROCY_"
// so for example "GROCY_BASE_URL"
//
// Third priority
// The settings defined here below
# Either "production", "dev", "demo" or "prerelease"
# ("demo" and "prerelease" is reserved to be used only on the offical demo instances)
// Either "production", "dev", "demo" or "prerelease"
// When not "production", authentication will be disabled and
// demo data will be populated during database migrations
Setting('MODE', 'production');
# Either "en" or "de" or the directory name of
# one of the other available localization folders in the "/localization" directory
Setting('CULTURE', 'en');
// Either "en" or "de" or the directory name of
// one of the other available localization folders in the "/localization" directory
Setting('DEFAULT_LOCALE', 'en');
# This is used to define the first day of a week for calendar views in the frontend,
# leave empty to use the locale default
# Needs to be a number where Sunday = 0, Monday = 1 and so forth
// This is used to define the first day of a week for calendar views in the frontend,
// 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', '');
# If calendars should show week numbers
// If calendars should show week numbers
Setting('CALENDAR_SHOW_WEEK_OF_YEAR', true);
# To keep it simple: grocy does not handle any currency conversions,
# this here is used to format all money values,
# so doesn't matter really matter, but should be the
# ISO 4217 code of the currency ("USD", "EUR", "GBP", etc.)
// 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
// ISO 4217 code of the currency ("USD", "EUR", "GBP", etc.)
Setting('CURRENCY', 'USD');
# The base url of your installation,
# should be just "/" when running directly under the root of a (sub)domain
# or for example "https://example.com/grocy" when using a subdirectory
// 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
// => BASE_PATH = /grocy
// Example without URL Rewriting support:
// Root URL = https://example.com/grocy/public/index.php/
// => BASE_PATH = /grocy/public/index.php
Setting('BASE_PATH', '');
// The base URL of your installation,
// should be just "/" when running directly under the root of a (sub)domain
// or for example "https://example.com/grocy" when using a subdirectory
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
// 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');
# If, however, your webserver does not support URL rewriting, set this to true
// 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,
# this needs to be one of the following values:
# stock, shoppinglist, recipes, chores, tasks, batteries, equipment, calendar
// 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');
# Set this to true if you want to disable authentication / the login screen,
# places where user context is needed will then use the default (first existing) user
// Set this to true if you want to disable authentication / the login screen,
// places where user context is needed will then use the default (first existing) user
Setting('DISABLE_AUTH', false);
# Set this to true if you want to disable the ability to scan a barcode via the device camera (Browser API)
// Either "Grocy\Middleware\DefaultAuthMiddleware", "Grocy\Middleware\ReverseProxyAuthMiddleware"
// 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');
// LDAP options when using LdapAuthMiddleware
Setting('LDAP_ADDRESS', ''); // Example value "ldap://vm-dc2019.local.berrnd.net"
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"
// 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', '');
# 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
// Default permissions for new users
// the array needs to contain the technical/constant names
// see the file controllers/Users/User.php for possible values
Setting('DEFAULT_PERMISSIONS', ['ADMIN']);
# Night mode related
// 1D (=> Code128) or 2D (=> DataMatrix)
Setting('GROCYCODE_TYPE', '1D');
// Label printer settings
// This is the URI that grocy will POST to when asked to print a label
Setting('LABEL_PRINTER_WEBHOOK', '');
// This setting decides whether the webhook will be called server- or clientside
// If the machine grocy runs on has a network connection to the host the webhook receiver is on, this is probably a good idea
// If, for example, grocy runs in the cloud and your printer daemon runs locally to you, set this to false to let your browser call the webhook instead
Setting('LABEL_PRINTER_RUN_SERVER', true);
// Additional parameters supplied to the webhook
Setting('LABEL_PRINTER_PARAMS', ['font_family' => 'Source Sans Pro (Regular)']);
// TRUE to use JSON or FALSE to use normal POST request variables
Setting('LABEL_PRINTER_HOOK_JSON', 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
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
// 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
// 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_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)
# Stock settings
// 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
// 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_expring_soon_days', 5);
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_auto_decimal_separator_prices', false);
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); // 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
# Chores settings
// 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);
// 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
// Batteries settings
DefaultUserSetting('batteries_due_soon_days', 5);
# Tasks settings
// 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);
// If the page should be automatically reloaded when there was an external change
DefaultUserSetting('auto_reload_on_db_change', false);
# Show a clock in the header next to the logo or not
// Show a clock in the header next to the logo or not
DefaultUserSetting('show_clock_in_header', false);
# Shopping list to stock workflow:
# Automatically do the booking using the last price and the amount
# of the shopping list item, if the product has "Default best before days" set
DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', 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
# (set the setting to "false" to disable the corresponding part, which should be self explanatory)
// 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
// (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);
Setting('FEATURE_FLAG_RECIPES', true);
@@ -117,14 +204,19 @@ 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
// Sub feature flags
Setting('FEATURE_FLAG_STOCK_PRICE_TRACKING', true);
Setting('FEATURE_FLAG_STOCK_LOCATION_TRACKING', true);
Setting('FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING', true);
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_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 false, opened products will not be considered for minimum stock amounts
// 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 automatically (if the device has one)

View File

@@ -2,31 +2,147 @@
namespace Grocy\Controllers;
use LessQL\Result;
class BaseApiController extends BaseController
{
const PATTERN_FIELD = '[A-Za-z_][A-Za-z0-9_]+';
public function __construct(\Slim\Container $container)
const PATTERN_OPERATOR = '!?(=|~|<|>|(>=)|(<=)|(§))';
const PATTERN_VALUE = '[A-Za-z\p{L}\p{M}*_0-9.$#^| -]+';
protected $OpenApiSpec = null;
protected function ApiResponse(\Psr\Http\Message\ResponseInterface $response, $data, $cache = false)
{
parent::__construct($container);
$this->OpenApiSpec = json_decode(file_get_contents(__DIR__ . '/../grocy.openapi.json'));
if ($cache)
{
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
}
$response->getBody()->write(json_encode($data));
return $response;
}
protected $OpenApiSpec;
protected function ApiResponse($data)
{
return json_encode($data);
}
protected function EmptyApiResponse($response, $status = 204)
protected function EmptyApiResponse(\Psr\Http\Message\ResponseInterface $response, $status = 204)
{
return $response->withStatus($status);
}
protected function GenericErrorResponse($response, $errorMessage, $status = 400)
protected function GenericErrorResponse(\Psr\Http\Message\ResponseInterface $response, $errorMessage, $status = 400)
{
return $response->withStatus($status)->withJson(array(
return $response->withStatus($status)->withJson([
'error_message' => $errorMessage
));
]);
}
public function FilteredApiResponse(\Psr\Http\Message\ResponseInterface $response, Result $data, array $query)
{
$data = $this->queryData($data, $query);
return $this->ApiResponse($response, $data);
}
protected function queryData(Result $data, array $query)
{
if (isset($query['query']))
{
$data = $this->filter($data, $query['query']);
}
if (isset($query['limit']))
{
$data = $data->limit(intval($query['limit']), intval($query['offset'] ?? 0));
}
if (isset($query['order']))
{
$parts = explode(':', $query['order']);
if (count($parts) == 1)
{
$data = $data->orderBy($parts[0]);
}
else
{
if ($parts[1] != 'asc' && $parts[1] != 'desc')
{
throw new \Exception('Invalid sort order ' . $parts[1]);
}
$data = $data->orderBy($parts[0], $parts[1]);
}
}
return $data;
}
protected function filter(Result $data, array $query): Result
{
foreach ($query as $q)
{
$matches = [];
preg_match(
'/(?P<field>' . self::PATTERN_FIELD . ')'
. '(?P<op>' . self::PATTERN_OPERATOR . ')'
. '(?P<value>' . self::PATTERN_VALUE . ')/u',
$q,
$matches
);
if (!array_key_exists('field', $matches) || !array_key_exists('op', $matches) || !array_key_exists('value', $matches))
{
throw new \Exception('Invalid query');
}
$sqlOrNull = '';
if (strtolower($matches['value']) == 'null')
{
$sqlOrNull = ' OR ' . $matches['field'] . ' IS NULL';
}
switch ($matches['op']) {
case '=':
$data = $data->where($matches['field'] . ' = ?' . $sqlOrNull, $matches['value']);
break;
case '!=':
$data = $data->where($matches['field'] . ' != ?' . $sqlOrNull, $matches['value']);
break;
case '~':
$data = $data->where($matches['field'] . ' LIKE ?', '%' . $matches['value'] . '%');
break;
case '!~':
$data = $data->where($matches['field'] . ' NOT LIKE ?', '%' . $matches['value'] . '%');
break;
case '<':
$data = $data->where($matches['field'] . ' < ?', $matches['value']);
break;
case '>':
$data = $data->where($matches['field'] . ' > ?', $matches['value']);
break;
case '>=':
$data = $data->where($matches['field'] . ' >= ?', $matches['value']);
break;
case '<=':
$data = $data->where($matches['field'] . ' <= ?', $matches['value']);
break;
case '§':
$data = $data->where($matches['field'] . ' REGEXP ?', $matches['value']);
break;
}
}
return $data;
}
protected function getOpenApispec()
{
if ($this->OpenApiSpec == null)
{
$this->OpenApiSpec = json_decode(file_get_contents(__DIR__ . '/../grocy.openapi.json'));
}
return $this->OpenApiSpec;
}
}

View File

@@ -2,46 +2,153 @@
namespace Grocy\Controllers;
use \Grocy\Services\DatabaseService;
use \Grocy\Services\ApplicationService;
use \Grocy\Services\LocalizationService;
use \Grocy\Services\UsersService;
use Grocy\Controllers\Users\User;
use Grocy\Services\ApiKeyService;
use Grocy\Services\ApplicationService;
use Grocy\Services\BatteriesService;
use Grocy\Services\CalendarService;
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;
class BaseController
{
public function __construct(\Slim\Container $container) {
$databaseService = new DatabaseService();
$this->Database = $databaseService->GetDbConnection();
$localizationService = new LocalizationService(GROCY_CULTURE);
$this->LocalizationService = $localizationService;
public function __construct(\DI\Container $container)
{
$this->AppContainer = $container;
$this->View = $container->get('view');
}
$applicationService = new ApplicationService();
$versionInfo = $applicationService->GetInstalledVersion();
$container->view->set('version', $versionInfo->Version);
$container->view->set('releaseDate', $versionInfo->ReleaseDate);
protected $AppContainer;
$container->view->set('__t', function(string $text, ...$placeholderValues) use($localizationService)
protected function getApiKeyService()
{
return ApiKeyService::getInstance();
}
protected function getApplicationservice()
{
return ApplicationService::getInstance();
}
protected function getBatteriesService()
{
return BatteriesService::getInstance();
}
protected function getCalendarService()
{
return CalendarService::getInstance();
}
protected function getChoresService()
{
return ChoresService::getInstance();
}
protected function getDatabase()
{
return $this->getDatabaseService()->GetDbConnection();
}
protected function getDatabaseService()
{
return DatabaseService::getInstance();
}
protected function getFilesService()
{
return FilesService::getInstance();
}
protected function getLocalizationService()
{
if (!defined('GROCY_LOCALE'))
{
define('GROCY_LOCALE', GROCY_DEFAULT_LOCALE);
}
return LocalizationService::getInstance(GROCY_LOCALE);
}
protected function getRecipesService()
{
return RecipesService::getInstance();
}
protected function getSessionService()
{
return SessionService::getInstance();
}
protected function getStockService()
{
return StockService::getInstance();
}
protected function getPrintService()
{
return PrintService::getInstance();
}
protected function getTasksService()
{
return TasksService::getInstance();
}
protected function getUserfieldsService()
{
return UserfieldsService::getInstance();
}
protected function getUsersService()
{
return UsersService::getInstance();
}
protected function render($response, $page, $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) {
return $localizationService->__t($text, $placeholderValues);
});
$container->view->set('__n', function($number, $singularForm, $pluralForm) use($localizationService)
{
$this->View->set('__n', function ($number, $singularForm, $pluralForm) use ($localizationService) {
return $localizationService->__n($number, $singularForm, $pluralForm);
});
$container->view->set('GettextPo', $localizationService->GetPoAsJsonString());
$this->View->set('LocalizationStrings', $localizationService->GetPoAsJsonString());
$container->view->set('U', function($relativePath, $isResource = false) use($container)
// TODO: Better handle this generically based on the current language (header in .po file?)
$dir = 'ltr';
if (GROCY_LOCALE == 'he_IL')
{
return $container->UrlManager->ConstructUrl($relativePath, $isResource);
$dir = 'rtl';
}
$this->View->set('dir', $dir);
$this->View->set('U', function ($relativePath, $isResource = false) use ($container) {
return $container->get('UrlManager')->ConstructUrl($relativePath, $isResource);
});
$embedded = false;
if (isset($container->request->getQueryParams()['embedded']))
if (isset($_GET['embedded']))
{
$embedded = true;
}
$container->view->set('embedded', $embedded);
$this->View->set('embedded', $embedded);
$constants = get_defined_constants();
foreach ($constants as $constant => $value)
@@ -51,20 +158,40 @@ class BaseController
unset($constants[$constant]);
}
}
$container->view->set('featureFlags', $constants);
$container->view->set('userentitiesForSidebar', $this->Database->userentities()->where('show_in_sidebar_menu = 1')->orderBy('name'));
try
$this->View->set('featureFlags', $constants);
if (GROCY_AUTHENTICATED)
{
$usersService = new UsersService();
if (defined('GROCY_USER_ID'))
$this->View->set('permissions', User::PermissionList());
$decimalPlacesAmounts = intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'stock_decimal_places_amounts'));
if ($decimalPlacesAmounts <= 0)
{
$container->view->set('userSettings', $usersService->GetUserSettings(GROCY_USER_ID));
$defaultMinAmount = 1;
}
else
{
$container->view->set('userSettings', null);
$defaultMinAmount = '0.' . str_repeat('0', $decimalPlacesAmounts - 1) . '1';
}
$this->View->set('DEFAULT_MIN_AMOUNT', $defaultMinAmount);
}
return $this->View->render($response, $page, $data);
}
protected function renderPage($response, $page, $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));
}
else
{
$this->View->set('userSettings', null);
}
}
catch (\Exception $ex)
@@ -72,10 +199,44 @@ class BaseController
// Happens when database is not initialised or migrated...
}
$this->AppContainer = $container;
return $this->render($response, $page, $data);
}
protected $AppContainer;
protected $Database;
protected $LocalizationService;
private static $htmlPurifierInstance = null;
protected function GetParsedAndFilteredRequestBody($request)
{
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[width|height|alt|src],table[border|width|style],tbody,tr,td,th,blockquote,*[style|class|id]');
$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');
$htmlPurifierConfig->set('URI.AllowedSchemes', ['data' => true, 'http' => true, 'https' => true]);
$htmlPurifierConfig->set('URI.SafeIframeRegexp', '%^.*%'); // Allow any iframe source
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
if (!is_array($value))
{
$value = str_replace('&amp;', '&', $value);
}
}
return $requestBody;
}
}

View File

@@ -2,21 +2,34 @@
namespace Grocy\Controllers;
use \Grocy\Services\BatteriesService;
use Grocy\Controllers\Users\User;
use Grocy\Helpers\WebhookRunner;
use Grocy\Helpers\Grocycode;
class BatteriesApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function BatteryDetails(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->BatteriesService = new BatteriesService();
try
{
return $this->ApiResponse($response, $this->getBatteriesService()->GetBatteryDetails($args['batteryId']));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
protected $BatteriesService;
public function TrackChargeCycle(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Current(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
return $this->FilteredApiResponse($response, $this->getBatteriesService()->GetCurrent(), $request->getQueryParams());
}
public function TrackChargeCycle(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_BATTERIES_TRACK_CHARGE_CYCLE);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
@@ -26,8 +39,8 @@ class BatteriesApiController extends BaseApiController
$trackedTime = $requestBody['tracked_time'];
}
$chargeCycleId = $this->BatteriesService->TrackChargeCycle($args['batteryId'], $trackedTime);
return $this->ApiResponse($this->Database->battery_charge_cycles($chargeCycleId));
$chargeCycleId = $this->getBatteriesService()->TrackChargeCycle($args['batteryId'], $trackedTime);
return $this->ApiResponse($response, $this->getDatabase()->battery_charge_cycles($chargeCycleId));
}
catch (\Exception $ex)
{
@@ -35,28 +48,13 @@ class BatteriesApiController extends BaseApiController
}
}
public function BatteryDetails(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function UndoChargeCycle(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_BATTERIES_UNDO_CHARGE_CYCLE);
try
{
return $this->ApiResponse($this->BatteriesService->GetBatteryDetails($args['batteryId']));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function Current(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->ApiResponse($this->BatteriesService->GetCurrent());
}
public function UndoChargeCycle(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
try
{
$this->ApiResponse($this->BatteriesService->UndoChargeCycle($args['chargeCycleId']));
$this->ApiResponse($response, $this->getBatteriesService()->UndoChargeCycle($args['chargeCycleId']));
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -64,4 +62,28 @@ class BatteriesApiController extends BaseApiController
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function BatteryPrintLabel(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$battery = $this->getDatabase()->batteries()->where('id', $args['batteryId'])->fetch();
$webhookData = array_merge([
'battery' => $battery->name,
'grocycode' => (string)(new Grocycode(Grocycode::BATTERY, $args['batteryId'])),
], 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,81 +2,103 @@
namespace Grocy\Controllers;
use \Grocy\Services\BatteriesService;
use \Grocy\Services\UsersService;
use \Grocy\Services\UserfieldsService;
use Grocy\Helpers\Grocycode;
class BatteriesController extends BaseController
{
public function __construct(\Slim\Container $container)
use GrocycodeTrait;
public function BatteriesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->BatteriesService = new BatteriesService();
$this->UserfieldsService = new UserfieldsService();
}
if (isset($request->getQueryParams()['include_disabled']))
{
$batteries = $this->getDatabase()->batteries()->orderBy('name', 'COLLATE NOCASE');
}
else
{
$batteries = $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
}
protected $BatteriesService;
protected $UserfieldsService;
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$usersService = new UsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['batteries_due_soon_days'];
return $this->AppContainer->view->render($response, 'batteriesoverview', [
'batteries' => $this->Database->batteries()->orderBy('name'),
'current' => $this->BatteriesService->GetCurrent(),
'nextXDays' => $nextXDays,
'userfields' => $this->UserfieldsService->GetFields('batteries'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('batteries')
return $this->renderPage($response, 'batteries', [
'batteries' => $batteries,
'userfields' => $this->getUserfieldsService()->GetFields('batteries'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('batteries')
]);
}
public function TrackChargeCycle(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function BatteriesSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'batterytracking', [
'batteries' => $this->Database->batteries()->orderBy('name')
]);
return $this->renderPage($response, 'batteriessettings');
}
public function BatteriesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'batteries', [
'batteries' => $this->Database->batteries()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('batteries'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('batteries')
]);
}
public function BatteryEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function BatteryEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['batteryId'] == 'new')
{
return $this->AppContainer->view->render($response, 'batteryform', [
return $this->renderPage($response, 'batteryform', [
'mode' => 'create',
'userfields' => $this->UserfieldsService->GetFields('batteries')
'userfields' => $this->getUserfieldsService()->GetFields('batteries')
]);
}
else
{
return $this->AppContainer->view->render($response, 'batteryform', [
'battery' => $this->Database->batteries($args['batteryId']),
return $this->renderPage($response, 'batteryform', [
'battery' => $this->getDatabase()->batteries($args['batteryId']),
'mode' => 'edit',
'userfields' => $this->UserfieldsService->GetFields('batteries')
'userfields' => $this->getUserfieldsService()->GetFields('batteries')
]);
}
}
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'batteriesjournal', [
'chargeCycles' => $this->Database->battery_charge_cycles()->orderBy('tracked_time', 'DESC'),
'batteries' => $this->Database->batteries()->orderBy('name')
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()->where($where)->orderBy('tracked_time', 'DESC'),
'batteries' => $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE')
]);
}
public function BatteriesSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'batteriessettings');
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['batteries_due_soon_days'];
return $this->renderPage($response, 'batteriesoverview', [
'batteries' => $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'current' => $this->getBatteriesService()->GetCurrent(),
'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)
{
return $this->renderPage($response, 'batterytracking', [
'batteries' => $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE')
]);
}
public function BatteryGrocycodeImage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$gc = new Grocycode(Grocycode::BATTERY, $args['batteryId']);
return $this->ServeGrocycodeImage($request, $response, $gc);
}
}

View File

@@ -2,41 +2,59 @@
namespace Grocy\Controllers;
use \Grocy\Services\CalendarService;
use \Grocy\Services\ApiKeyService;
use Eluceo\iCal\Domain\Entity\Calendar;
use Eluceo\iCal\Domain\Entity\Event;
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;
class CalendarApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
{
parent::__construct($container);
$this->CalendarService = new CalendarService();
$this->ApiKeyService = new ApiKeyService();
}
protected $CalendarService;
protected $ApiKeyService;
public function Ical(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Ical(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$vCalendar = new \Eluceo\iCal\Component\Calendar('grocy');
$events = $this->getCalendarService()->GetEvents();
$events = $this->CalendarService->GetEvents();
foreach($events as $event)
$vCalendar = new Calendar();
foreach ($events as $event)
{
$vEvent = new \Eluceo\iCal\Component\Event();
$vEvent->setDtStart(new \DateTime($event['start']))
->setDtEnd(new \DateTime($event['start']))
if (!isset($event['start']))
{
continue;
}
$description = '';
if (isset($event['description']))
{
$description = $event['description'];
}
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);
}
else
{
// Time-point event
$start = new DateTime(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $event['start']), false);
$end = new DateTime(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $event['start']), false);
$vEventOccurrence = new TimeSpan($start, $end);
}
$vEvent = new Event();
$vEvent->setOccurrence($vEventOccurrence)
->setSummary($event['title'])
->setNoTime($event['date_format'] === 'date')
->setUseUtc(false);
$vCalendar->addComponent($vEvent);
->setDescription($description);
$vCalendar->addEvent($vEvent);
}
$response->write($vCalendar->render());
$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"');
}
@@ -46,13 +64,13 @@ class CalendarApiController extends BaseApiController
}
}
public function IcalSharingLink(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function IcalSharingLink(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse(array(
'url' => $this->AppContainer->UrlManager->ConstructUrl('/api/calendar/ical?secret=' . $this->ApiKeyService->GetOrCreateApiKey(ApiKeyService::API_KEY_TYPE_SPECIAL_PURPOSE_CALENDAR_ICAL))
));
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))
]);
}
catch (\Exception $ex)
{

View File

@@ -2,22 +2,12 @@
namespace Grocy\Controllers;
use \Grocy\Services\CalendarService;
class CalendarController extends BaseController
{
public function __construct(\Slim\Container $container)
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->CalendarService = new CalendarService();
}
protected $CalendarService;
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'calendar', [
'fullcalendarEventSources' => $this->CalendarService->GetEvents()
return $this->renderPage($response, 'calendar', [
'fullcalendarEventSources' => $this->getCalendarService()->GetEvents()
]);
}
}

View File

@@ -2,24 +2,71 @@
namespace Grocy\Controllers;
use \Grocy\Services\ChoresService;
use Grocy\Controllers\Users\User;
use Grocy\Helpers\WebhookRunner;
use Grocy\Helpers\Grocycode;
class ChoresApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function CalculateNextExecutionAssignments(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->ChoresService = new ChoresService();
try
{
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$choreId = null;
if (array_key_exists('chore_id', $requestBody) && !empty($requestBody['chore_id']) && is_numeric($requestBody['chore_id']))
{
$choreId = intval($requestBody['chore_id']);
}
if ($choreId === null)
{
$chores = $this->getDatabase()->chores();
foreach ($chores as $chore)
{
$this->getChoresService()->CalculateNextExecutionAssignment($chore->id);
}
}
else
{
$this->getChoresService()->CalculateNextExecutionAssignment($choreId);
}
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
protected $ChoresService;
public function TrackChoreExecution(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ChoreDetails(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
try
{
return $this->ApiResponse($response, $this->getChoresService()->GetChoreDetails($args['choreId']));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function Current(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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)
{
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
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'])))
{
@@ -32,8 +79,13 @@ class ChoresApiController extends BaseApiController
$doneBy = $requestBody['done_by'];
}
$choreExecutionId = $this->ChoresService->TrackChore($args['choreId'], $trackedTime, $doneBy);
return $this->ApiResponse($this->Database->chores_log($choreExecutionId));
if ($doneBy != GROCY_USER_ID)
{
User::checkPermission($request, User::PERMISSION_CHORE_TRACK_EXECUTION);
}
$choreExecutionId = $this->getChoresService()->TrackChore($args['choreId'], $trackedTime, $doneBy);
return $this->ApiResponse($response, $this->getDatabase()->chores_log($choreExecutionId));
}
catch (\Exception $ex)
{
@@ -41,28 +93,13 @@ class ChoresApiController extends BaseApiController
}
}
public function ChoreDetails(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function UndoChoreExecution(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse($this->ChoresService->GetChoreDetails($args['choreId']));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
User::checkPermission($request, User::PERMISSION_CHORE_UNDO_EXECUTION);
public function Current(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->ApiResponse($this->ChoresService->GetCurrent());
}
public function UndoChoreExecution(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
try
{
$this->ApiResponse($this->ChoresService->UndoChoreExecution($args['executionId']));
$this->ApiResponse($response, $this->getChoresService()->UndoChoreExecution($args['executionId']));
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -71,32 +108,23 @@ class ChoresApiController extends BaseApiController
}
}
public function CalculateNextExecutionAssignments(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ChorePrintLabel(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$requestBody = $request->getParsedBody();
$chore = $this->getDatabase()->chores()->where('id', $args['choreId'])->fetch();
$choreId = null;
if (array_key_exists('chore_id', $requestBody) && !empty($requestBody['chore_id']) && is_numeric($requestBody['chore_id']))
$webhookData = array_merge([
'chore' => $chore->name,
'grocycode' => (string)(new Grocycode(Grocycode::CHORE, $args['choreId'])),
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_RUN_SERVER)
{
$choreId = intval($requestBody['chore_id']);
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
}
if ($choreId === null)
{
$chores = $this->Database->chores();
foreach ($chores as $chore)
{
$this->ChoresService->CalculateNextExecutionAssignment($chore->id);
}
}
else
{
$this->ChoresService->CalculateNextExecutionAssignment($choreId);
}
return $this->EmptyApiResponse($response);
return $this->ApiResponse($response, $webhookData);
}
catch (\Exception $ex)
{

View File

@@ -2,95 +2,120 @@
namespace Grocy\Controllers;
use \Grocy\Services\ChoresService;
use \Grocy\Services\UsersService;
use \Grocy\Services\UserfieldsService;
use Grocy\Helpers\Grocycode;
class ChoresController extends BaseController
{
public function __construct(\Slim\Container $container)
use GrocycodeTrait;
public function ChoreEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->ChoresService = new ChoresService();
$this->UserfieldsService = new UserfieldsService();
}
protected $ChoresService;
protected $UserfieldsService;
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$usersService = new UsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['chores_due_soon_days'];
return $this->AppContainer->view->render($response, 'choresoverview', [
'chores' => $this->Database->chores()->orderBy('name'),
'currentChores' => $this->ChoresService->GetCurrent(),
'nextXDays' => $nextXDays,
'userfields' => $this->UserfieldsService->GetFields('chores'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('chores'),
'users' => $usersService->GetUsersAsDto()
]);
}
public function TrackChoreExecution(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'choretracking', [
'chores' => $this->Database->chores()->orderBy('name'),
'users' => $this->Database->users()->orderBy('username')
]);
}
public function ChoresList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'chores', [
'chores' => $this->Database->chores()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('chores'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('chores')
]);
}
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'choresjournal', [
'choresLog' => $this->Database->chores_log()->orderBy('tracked_time', 'DESC'),
'chores' => $this->Database->chores()->orderBy('name'),
'users' => $this->Database->users()->orderBy('username')
]);
}
public function ChoreEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$usersService = new UsersService();
$usersService = $this->getUsersService();
$users = $usersService->GetUsersAsDto();
if ($args['choreId'] == 'new')
{
return $this->AppContainer->view->render($response, 'choreform', [
return $this->renderPage($response, 'choreform', [
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_PERIOD_TYPE_'),
'mode' => 'create',
'userfields' => $this->UserfieldsService->GetFields('chores'),
'userfields' => $this->getUserfieldsService()->GetFields('chores'),
'assignmentTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_ASSIGNMENT_TYPE_'),
'users' => $users,
'products' => $this->Database->products()->orderBy('name')
'products' => $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE')
]);
}
else
{
return $this->AppContainer->view->render($response, 'choreform', [
'chore' => $this->Database->chores($args['choreId']),
return $this->renderPage($response, 'choreform', [
'chore' => $this->getDatabase()->chores($args['choreId']),
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_PERIOD_TYPE_'),
'mode' => 'edit',
'userfields' => $this->UserfieldsService->GetFields('chores'),
'userfields' => $this->getUserfieldsService()->GetFields('chores'),
'assignmentTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_ASSIGNMENT_TYPE_'),
'users' => $users,
'products' => $this->Database->products()->orderBy('name')
'products' => $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE')
]);
}
}
public function ChoresSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ChoresList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'choressettings');
if (isset($request->getQueryParams()['include_disabled']))
{
$chores = $this->getDatabase()->chores()->orderBy('name', 'COLLATE NOCASE');
}
else
{
$chores = $this->getDatabase()->chores()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
}
return $this->renderPage($response, 'chores', [
'chores' => $chores,
'userfields' => $this->getUserfieldsService()->GetFields('chores'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('chores')
]);
}
public function ChoresSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'choressettings');
}
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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()->where($where)->orderBy('tracked_time', 'DESC'),
'chores' => $this->getDatabase()->chores()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'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)
{
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['chores_due_soon_days'];
return $this->renderPage($response, 'choresoverview', [
'chores' => $this->getDatabase()->chores()->orderBy('name', 'COLLATE NOCASE'),
'currentChores' => $this->getChoresService()->GetCurrent(),
'nextXDays' => $nextXDays,
'userfields' => $this->getUserfieldsService()->GetFields('chores'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('chores'),
'users' => $usersService->GetUsersAsDto()
]);
}
public function TrackChoreExecution(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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'),
'userfields' => $this->getUserfieldsService()->GetFields('chores_log'),
]);
}
public function ChoreGrocycodeImage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$gc = new Grocycode(Grocycode::CHORE, $args['choreId']);
return $this->ServeGrocycodeImage($request, $response, $gc);
}
}

View File

@@ -2,43 +2,35 @@
namespace Grocy\Controllers;
use \Grocy\Services\UserfieldsService;
class EquipmentController extends BaseController
{
public function __construct(\Slim\Container $container)
{
parent::__construct($container);
$this->UserfieldsService = new UserfieldsService();
}
protected $UserfieldsService;
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'equipment', [
'equipment' => $this->Database->equipment()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('equipment'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('equipment')
]);
}
public function EditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function EditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['equipmentId'] == 'new')
{
return $this->AppContainer->view->render($response, 'equipmentform', [
return $this->renderPage($response, 'equipmentform', [
'mode' => 'create',
'userfields' => $this->UserfieldsService->GetFields('equipment')
'userfields' => $this->getUserfieldsService()->GetFields('equipment')
]);
}
else
{
return $this->AppContainer->view->render($response, 'equipmentform', [
'equipment' => $this->Database->equipment($args['equipmentId']),
return $this->renderPage($response, 'equipmentform', [
'equipment' => $this->getDatabase()->equipment($args['equipmentId']),
'mode' => 'edit',
'userfields' => $this->UserfieldsService->GetFields('equipment')
'userfields' => $this->getUserfieldsService()->GetFields('equipment')
]);
}
}
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'equipment', [
'equipment' => $this->getDatabase()->equipment()->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('equipment'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('equipment')
]);
}
}

View File

@@ -0,0 +1,84 @@
<?php
namespace Grocy\Controllers;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Slim\Exception\HttpException;
use Slim\Exception\HttpForbiddenException;
use Slim\Exception\HttpNotFoundException;
use Throwable;
class ExceptionController extends BaseApiController
{
public function __construct(\Slim\App $app, \DI\Container $container)
{
parent::__construct($container);
$this->app = $app;
}
/**
* @var \Slim\App
*/
private $app;
public function __invoke(ServerRequestInterface $request, Throwable $exception, bool $displayErrorDetails, bool $logErrors, bool $logErrorDetails, ?LoggerInterface $logger = null)
{
$response = $this->app->getResponseFactory()->createResponse();
$isApiRoute = string_starts_with($request->getUri()->getPath(), '/api/');
if (!defined('GROCY_AUTHENTICATED'))
{
define('GROCY_AUTHENTICATED', false);
}
if ($isApiRoute)
{
$status = 500;
if ($exception instanceof HttpException)
{
$status = $exception->getCode();
}
$data = [
'error_message' => $exception->getMessage()
];
if ($displayErrorDetails)
{
$data['error_details'] = [
'stack_trace' => $exception->getTraceAsString(),
'file' => $exception->getFile(),
'line' => $exception->getLine()
];
}
return $this->ApiResponse($response->withStatus($status)->withHeader('Content-Type', 'application/json'), $data);
}
if ($exception instanceof HttpNotFoundException)
{
if (!defined('GROCY_AUTHENTICATED'))
{
define('GROCY_AUTHENTICATED', false);
}
return $this->renderPage($response->withStatus(404), 'errors/404', [
'exception' => $exception
]);
}
if ($exception instanceof HttpForbiddenException)
{
return $this->renderPage($response->withStatus(403), 'errors/403', [
'exception' => $exception
]);
}
return $this->renderPage($response->withStatus(500), 'errors/500', [
'exception' => $exception,
'system_info' => $this->getApplicationService()->GetSystemInfo()
]);
}
}

View File

@@ -2,22 +2,20 @@
namespace Grocy\Controllers;
use \Grocy\Services\FilesService;
use Grocy\Services\FilesService;
use Slim\Exception\HttpNotFoundException;
class FilesApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
{
parent::__construct($container);
$this->FilesService = new FilesService();
}
protected $FilesService;
public function UploadFile(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function DeleteFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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']);
@@ -27,8 +25,7 @@ class FilesApiController extends BaseApiController
throw new \Exception('Invalid filename');
}
$data = $request->getBody()->getContents();
file_put_contents($this->FilesService->GetFilePath($args['group'], $fileName), $data);
$this->getFilesService()->DeleteFile($args['group'], $fileName);
return $this->EmptyApiResponse($response);
}
@@ -38,81 +35,80 @@ class FilesApiController extends BaseApiController
}
}
public function ServeFile(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ServeFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
if (IsValidFileName(base64_decode($args['fileName'])))
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
$fileName = base64_decode($args['fileName']);
}
else
{
throw new \Exception('Invalid filename');
throw new \Exception('Invalid file group');
}
$forceServeAs = null;
if (isset($request->getQueryParams()['force_serve_as']) && !empty($request->getQueryParams()['force_serve_as']))
{
$forceServeAs = $request->getQueryParams()['force_serve_as'];
}
if ($forceServeAs == FilesService::FILE_SERVE_TYPE_PICTURE)
{
$bestFitHeight = null;
if (isset($request->getQueryParams()['best_fit_height']) && !empty($request->getQueryParams()['best_fit_height']) && is_numeric($request->getQueryParams()['best_fit_height']))
{
$bestFitHeight = $request->getQueryParams()['best_fit_height'];
}
$bestFitWidth = null;
if (isset($request->getQueryParams()['best_fit_width']) && !empty($request->getQueryParams()['best_fit_width']) && is_numeric($request->getQueryParams()['best_fit_width']))
{
$bestFitWidth = $request->getQueryParams()['best_fit_width'];
}
$filePath = $this->FilesService->DownscaleImage($args['group'], $fileName, $bestFitHeight, $bestFitWidth);
}
else
{
$filePath = $this->FilesService->GetFilePath($args['group'], $fileName);
}
$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 . '"');
}
else
{
return $this->GenericErrorResponse($response, 'File not found', 404);
throw new HttpNotFoundException($request, 'File not found');
}
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
throw new HttpNotFoundException($request, $ex->getMessage(), $ex);
}
}
public function DeleteFile(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ShowFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
if (IsValidFileName(base64_decode($args['fileName'])))
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
$fileName = base64_decode($args['fileName']);
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 . '"');
}
else
{
throw new \Exception('Invalid filename');
throw new HttpNotFoundException($request, 'File not found');
}
}
catch (\Exception $ex)
{
throw new HttpNotFoundException($request, $ex->getMessage(), $ex);
}
}
public function UploadFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
throw new \Exception('Invalid file group');
}
$filePath = $this->FilesService->GetFilePath($args['group'], $fileName);
if (file_exists($filePath))
{
unlink($filePath);
}
$fileName = $this->checkFileName($args['fileName']);
$data = $request->getBody()->getContents();
file_put_contents($this->getFilesService()->GetFilePath($args['group'], $fileName), $data);
return $this->EmptyApiResponse($response);
}
@@ -121,4 +117,61 @@ class FilesApiController extends BaseApiController
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
/**
* @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)))
{
$fileName = base64_decode($fileName);
}
else
{
throw new \Exception('Invalid filename');
}
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'];
}
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'];
}
$filePath = $this->getFilesService()->DownscaleImage($group, $fileName, $bestFitHeight, $bestFitWidth);
}
else
{
$filePath = $this->getFilesService()->GetFilePath($group, $fileName);
}
return $filePath;
}
}

View File

@@ -2,47 +2,23 @@
namespace Grocy\Controllers;
use \Grocy\Services\UserfieldsService;
use Grocy\Controllers\Users\User;
use Slim\Exception\HttpBadRequestException;
class GenericEntityApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function AddObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->UserfieldsService = new UserfieldsService();
}
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
protected $UserfieldsService;
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoEdit($args['entity']))
{
if ($this->IsEntityWithEditRequiresAdmin($args['entity']))
{
User::checkPermission($request, User::PERMISSION_ADMIN);
}
public function GetObjects(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
{
return $this->ApiResponse($this->Database->{$args['entity']}());
}
else
{
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
}
}
public function GetObject(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
{
return $this->ApiResponse($this->Database->{$args['entity']}($args['objectId']));
}
else
{
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
}
}
public function AddObject(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
if ($this->IsValidEntity($args['entity']))
{
$requestBody = $request->getParsedBody();
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
@@ -51,12 +27,13 @@ class GenericEntityApiController extends BaseApiController
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
$newRow = $this->Database->{$args['entity']}()->createRow($requestBody);
$newRow = $this->getDatabase()->{$args['entity']}()->createRow($requestBody);
$newRow->save();
$success = $newRow->isClean();
return $this->ApiResponse(array(
'created_object_id' => $this->Database->lastInsertId()
));
return $this->ApiResponse($response, [
'created_object_id' => $this->getDatabase()->lastInsertId()
]);
}
catch (\Exception $ex)
{
@@ -69,11 +46,46 @@ class GenericEntityApiController extends BaseApiController
}
}
public function EditObject(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function DeleteObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($this->IsValidEntity($args['entity']))
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoDelete($args['entity']))
{
$requestBody = $request->getParsedBody();
if ($this->IsEntityWithEditRequiresAdmin($args['entity']))
{
User::checkPermission($request, User::PERMISSION_ADMIN);
}
$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);
}
else
{
return $this->GenericErrorResponse($response, 'Invalid entity');
}
}
public function EditObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoEdit($args['entity']))
{
if ($this->IsEntityWithEditRequiresAdmin($args['entity']))
{
User::checkPermission($request, User::PERMISSION_ADMIN);
}
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
@@ -82,9 +94,15 @@ class GenericEntityApiController extends BaseApiController
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
$row = $this->Database->{$args['entity']}($args['objectId']);
$row = $this->getDatabase()->{$args['entity']}($args['objectId']);
if ($row == null)
{
return $this->GenericErrorResponse($response, 'Object not found', 400);
}
$row->update($requestBody);
$success = $row->isClean();
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -98,33 +116,25 @@ class GenericEntityApiController extends BaseApiController
}
}
public function DeleteObject(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function GetObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($this->IsValidEntity($args['entity']))
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoListing($args['entity']))
{
$row = $this->Database->{$args['entity']}($args['objectId']);
$row->delete();
$success = $row->isClean();
return $this->EmptyApiResponse($response);
}
else
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
$userfields = $this->getUserfieldsService()->GetValues($args['entity'], $args['objectId']);
if (count($userfields) === 0)
{
$userfields = null;
}
public function SearchObjects(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
{
try
$object = $this->getDatabase()->{$args['entity']}($args['objectId']);
if ($object == null)
{
return $this->ApiResponse($this->Database->{$args['entity']}()->where('name LIKE ?', '%' . $args['searchString'] . '%'));
}
catch (\PDOException $ex)
{
return $this->GenericErrorResponse($response, 'The given entity has no field "name"');
return $this->GenericErrorResponse($response, 'Object not found', 404);
}
$object['userfields'] = $userfields;
return $this->ApiResponse($response, $object);
}
else
{
@@ -132,11 +142,48 @@ class GenericEntityApiController extends BaseApiController
}
}
public function GetUserfields(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function GetObjects(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if (!$this->IsValidExposedEntity($args['entity']) || $this->IsEntityWithNoListing($args['entity']))
{
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
}
$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)
{
$value = FindObjectInArrayByPropertyValue(FindAllObjectsInArrayByPropertyValue($allUserfieldValues, 'object_id', $object->id), 'name', $userfield->name);
if ($value)
{
$userfieldKeyValuePairs[$userfield->name] = $value->value;
}
else
{
$userfieldKeyValuePairs[$userfield->name] = null;
}
}
$object->userfields = $userfieldKeyValuePairs;
}
}
return $this->ApiResponse($response, $objects);
}
public function GetUserfields(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse($this->UserfieldsService->GetValues($args['entity'], $args['objectId']));
return $this->ApiResponse($response, $this->getUserfieldsService()->GetValues($args['entity'], $args['objectId']));
}
catch (\Exception $ex)
{
@@ -144,9 +191,11 @@ class GenericEntityApiController extends BaseApiController
}
}
public function SetUserfields(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function SetUserfields(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
@@ -155,7 +204,7 @@ class GenericEntityApiController extends BaseApiController
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
$this->UserfieldsService->SetValues($args['entity'], $args['objectId'], $requestBody);
$this->getUserfieldsService()->SetValues($args['entity'], $args['objectId'], $requestBody);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -164,13 +213,28 @@ class GenericEntityApiController extends BaseApiController
}
}
private function IsValidEntity($entity)
private function IsEntityWithEditRequiresAdmin($entity)
{
return in_array($entity, $this->OpenApiSpec->components->internalSchemas->ExposedEntity->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityEditRequiresAdmin->enum);
}
private function IsEntityWithPreventedListing($entity)
private function IsEntityWithNoListing($entity)
{
return in_array($entity, $this->OpenApiSpec->components->internalSchemas->ExposedEntitiesPreventListing->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityNoListing->enum);
}
private function IsEntityWithNoEdit($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityNoEdit->enum);
}
private function IsEntityWithNoDelete($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityNoDelete->enum);
}
private function IsValidExposedEntity($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntity->enum);
}
}

View File

@@ -2,103 +2,93 @@
namespace Grocy\Controllers;
use \Grocy\Services\UserfieldsService;
class GenericEntityController extends BaseController
{
public function __construct(\Slim\Container $container)
public function UserentitiesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->UserfieldsService = new UserfieldsService();
}
protected $UserfieldsService;
public function UserfieldsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'userfields', [
'userfields' => $this->UserfieldsService->GetAllFields(),
'entities' => $this->UserfieldsService->GetEntities()
return $this->renderPage($response, 'userentities', [
'userentities' => $this->getDatabase()->userentities()->orderBy('name', 'COLLATE NOCASE')
]);
}
public function UserentitiesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'userentities', [
'userentities' => $this->Database->userentities()->orderBy('name')
]);
}
public function UserobjectsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$userentity = $this->Database->userentities()->where('name = :1', $args['userentityName'])->fetch();
return $this->AppContainer->view->render($response, 'userobjects', [
'userentity' => $userentity,
'userobjects' => $this->Database->userobjects()->where('userentity_id = :1', $userentity->id),
'userfields' => $this->UserfieldsService->GetFields('userentity-' . $args['userentityName']),
'userfieldValues' => $this->UserfieldsService->GetAllValues('userentity-' . $args['userentityName'])
]);
}
public function UserfieldEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
if ($args['userfieldId'] == 'new')
{
return $this->AppContainer->view->render($response, 'userfieldform', [
'mode' => 'create',
'userfieldTypes' => $this->UserfieldsService->GetFieldTypes(),
'entities' => $this->UserfieldsService->GetEntities()
]);
}
else
{
return $this->AppContainer->view->render($response, 'userfieldform', [
'mode' => 'edit',
'userfield' => $this->UserfieldsService->GetField($args['userfieldId']),
'userfieldTypes' => $this->UserfieldsService->GetFieldTypes(),
'entities' => $this->UserfieldsService->GetEntities()
]);
}
}
public function UserentityEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function UserentityEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['userentityId'] == 'new')
{
return $this->AppContainer->view->render($response, 'userentityform', [
return $this->renderPage($response, 'userentityform', [
'mode' => 'create'
]);
}
else
{
return $this->AppContainer->view->render($response, 'userentityform', [
return $this->renderPage($response, 'userentityform', [
'mode' => 'edit',
'userentity' => $this->Database->userentities($args['userentityId'])
'userentity' => $this->getDatabase()->userentities($args['userentityId'])
]);
}
}
public function UserobjectEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function UserfieldEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$userentity = $this->Database->userentities()->where('name = :1', $args['userentityName'])->fetch();
if ($args['userobjectId'] == 'new')
if ($args['userfieldId'] == 'new')
{
return $this->AppContainer->view->render($response, 'userobjectform', [
'userentity' => $userentity,
return $this->renderPage($response, 'userfieldform', [
'mode' => 'create',
'userfields' => $this->UserfieldsService->GetFields('userentity-' . $args['userentityName'])
'userfieldTypes' => $this->getUserfieldsService()->GetFieldTypes(),
'entities' => $this->getUserfieldsService()->GetEntities()
]);
}
else
{
return $this->AppContainer->view->render($response, 'userobjectform', [
'userentity' => $userentity,
return $this->renderPage($response, 'userfieldform', [
'mode' => 'edit',
'userobject' => $this->Database->userobjects($args['userobjectId']),
'userfields' => $this->UserfieldsService->GetFields('userentity-' . $args['userentityName'])
'userfield' => $this->getUserfieldsService()->GetField($args['userfieldId']),
'userfieldTypes' => $this->getUserfieldsService()->GetFieldTypes(),
'entities' => $this->getUserfieldsService()->GetEntities()
]);
}
}
public function UserfieldsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'userfields', [
'userfields' => $this->getUserfieldsService()->GetAllFields(),
'entities' => $this->getUserfieldsService()->GetEntities()
]);
}
public function UserobjectEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$userentity = $this->getDatabase()->userentities()->where('name = :1', $args['userentityName'])->fetch();
if ($args['userobjectId'] == 'new')
{
return $this->renderPage($response, 'userobjectform', [
'userentity' => $userentity,
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('userentity-' . $args['userentityName'])
]);
}
else
{
return $this->renderPage($response, 'userobjectform', [
'userentity' => $userentity,
'mode' => 'edit',
'userobject' => $this->getDatabase()->userobjects($args['userobjectId']),
'userfields' => $this->getUserfieldsService()->GetFields('userentity-' . $args['userentityName'])
]);
}
}
public function UserobjectsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$userentity = $this->getDatabase()->userentities()->where('name = :1', $args['userentityName'])->fetch();
return $this->renderPage($response, 'userobjects', [
'userentity' => $userentity,
'userobjects' => $this->getDatabase()->userobjects()->where('userentity_id = :1', $userentity->id),
'userfields' => $this->getUserfieldsService()->GetFields('userentity-' . $args['userentityName']),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('userentity-' . $args['userentityName'])
]);
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Grocy\Controllers;
use Grocy\Helpers\Grocycode;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use jucksearm\barcode\lib\BarcodeFactory;
use jucksearm\barcode\lib\DatamatrixFactory;
trait GrocycodeTrait
{
public function ServeGrocycodeImage(ServerRequestInterface $request, ResponseInterface $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

@@ -2,69 +2,31 @@
namespace Grocy\Controllers;
use \Grocy\Services\SessionService;
use \Grocy\Services\DatabaseMigrationService;
use \Grocy\Services\DemoDataGeneratorService;
use Grocy\Services\SessionService;
class LoginController extends BaseController
{
public function __construct(\Slim\Container $container, string $sessionCookieName)
public function LoginPage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->SessionService = new SessionService();
$this->SessionCookieName = $sessionCookieName;
return $this->renderPage($response, 'login');
}
protected $SessionService;
protected $SessionCookieName;
public function ProcessLogin(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Logout(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$postParams = $request->getParsedBody();
if (isset($postParams['username']) && isset($postParams['password']))
$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)
{
$authMiddlewareClass = GROCY_AUTH_CLASS;
if ($authMiddlewareClass::ProcessLogin($this->GetParsedAndFilteredRequestBody($request)))
{
$user = $this->Database->users()->where('username', $postParams['username'])->fetch();
$inputPassword = $postParams['password'];
$stayLoggedInPermanently = $postParams['stay_logged_in'] == 'on';
if ($user !== null && password_verify($inputPassword, $user->password))
{
$sessionKey = $this->SessionService->CreateSession($user->id, $stayLoggedInPermanently);
setcookie($this->SessionCookieName, $sessionKey, PHP_INT_SIZE == 4 ? PHP_INT_MAX : PHP_INT_MAX>>32); // Cookie expires never, but session validity is up to SessionService
if (password_needs_rehash($user->password, PASSWORD_DEFAULT))
{
$user->update(array(
'password' => password_hash($inputPassword, PASSWORD_DEFAULT)
));
}
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/'));
}
else
{
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/login?invalid=true'));
}
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl('/'));
}
else
{
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/login?invalid=true'));
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl('/login?invalid=true'));
}
}
public function LoginPage(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'login');
}
public function Logout(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$this->SessionService->RemoveSession($_COOKIE[$this->SessionCookieName]);
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/'));
}
public function GetSessionCookieName()
{
return $this->SessionCookieName;
}
}

View File

@@ -2,48 +2,87 @@
namespace Grocy\Controllers;
use \Grocy\Services\ApplicationService;
use \Grocy\Services\ApiKeyService;
use Grocy\Controllers\Users\User;
class OpenApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function ApiKeysList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->ApiKeyService = new ApiKeyService();
}
protected $ApiKeyService;
public function DocumentationUi(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'openapiui');
}
public function DocumentationSpec(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$applicationService = new ApplicationService();
$versionInfo = $applicationService->GetInstalledVersion();
$this->OpenApiSpec->info->version = $versionInfo->Version;
$this->OpenApiSpec->info->description = str_replace('PlaceHolderManageApiKeysUrl', $this->AppContainer->UrlManager->ConstructUrl('/manageapikeys'), $this->OpenApiSpec->info->description);
$this->OpenApiSpec->servers[0]->url = $this->AppContainer->UrlManager->ConstructUrl('/api');
return $this->ApiResponse($this->OpenApiSpec);
}
public function ApiKeysList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'manageapikeys', [
'apiKeys' => $this->Database->api_keys(),
'users' => $this->Database->users()
$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()
]);
}
public function CreateNewApiKey(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function CreateNewApiKey(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$newApiKey = $this->ApiKeyService->CreateApiKey();
$newApiKeyId = $this->ApiKeyService->GetApiKeyId($newApiKey);
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl("/manageapikeys?CreatedApiKeyId=$newApiKeyId"));
$newApiKey = $this->getApiKeyService()->CreateApiKey();
$newApiKeyId = $this->getApiKeyService()->GetApiKeyId($newApiKey);
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl("/manageapikeys?CreatedApiKeyId=$newApiKeyId"));
}
public function DocumentationSpec(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$spec = $this->getOpenApiSpec();
$applicationService = $this->getApplicationService();
$versionInfo = $applicationService->GetInstalledVersion();
$spec->info->version = $versionInfo->Version;
$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->schemas->ExposedEntity_IncludingUserEntities = clone $spec->components->schemas->ExposedEntity;
foreach ($this->getUserfieldsService()->GetEntities() as $userEntity)
{
array_push($spec->components->schemas->ExposedEntity_IncludingUserEntities->enum, $userEntity);
}
$spec->components->schemas->ExposedEntity_NotIncludingNotEditable = clone $spec->components->schemas->StringEnumTemplate;
foreach ($spec->components->schemas->ExposedEntity->enum as $value)
{
if (!in_array($value, $spec->components->schemas->ExposedEntityNoEdit->enum))
{
array_push($spec->components->schemas->ExposedEntity_NotIncludingNotEditable->enum, $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->schemas->ExposedEntityNoEdit->enum))
{
array_push($spec->components->schemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable->enum, $value);
}
}
$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);
}
}
$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);
}
}
return $this->ApiResponse($response, $spec);
}
public function DocumentationUi(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->render($response, 'openapiui');
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
use Grocy\Services\StockService;
class PrintApiController extends BaseApiController
{
public function PrintShoppingListThermal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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,68 +1,79 @@
<?php
namespace Grocy\Controllers;
use \Grocy\Services\RecipesService;
class RecipesApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
{
parent::__construct($container);
$this->RecipesService = new RecipesService();
}
protected $RecipesService;
public function AddNotFulfilledProductsToShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$requestBody = $request->getParsedBody();
$excludedProductIds = null;
if ($requestBody !== null && array_key_exists('excludedProductIds', $requestBody))
{
$excludedProductIds = $requestBody['excludedProductIds'];
}
$this->RecipesService->AddNotFulfilledProductsToShoppingList($args['recipeId'], $excludedProductIds);
return $this->EmptyApiResponse($response);
}
public function ConsumeRecipe(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
try
{
$this->RecipesService->ConsumeRecipe($args['recipeId']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function GetRecipeFulfillment(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
try
{
if(!isset($args['recipeId']))
{
return $this->ApiResponse($this->RecipesService->GetRecipesResolved());
}
$recipeResolved = FindObjectInArrayByPropertyValue($this->RecipesService->GetRecipesResolved(), 'recipe_id', $args['recipeId']);
if(!$recipeResolved)
{
throw new \Exception('Recipe does not exist');
}
else
{
return $this->ApiResponse($recipeResolved);
}
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}
<?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 CopyRecipe(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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());
}
}
}

View File

@@ -2,162 +2,218 @@
namespace Grocy\Controllers;
use \Grocy\Services\RecipesService;
use \Grocy\Services\UserfieldsService;
use Grocy\Services\RecipesService;
class RecipesController extends BaseController
{
public function __construct(\Slim\Container $container)
public function MealPlan(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->RecipesService = new RecipesService();
$this->UserfieldsService = new UserfieldsService();
$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') AND DATE('$start', '+$days days')";
$recipes = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll();
$events = [];
foreach ($this->getDatabase()->meal_plan()->where($mealPlanWhereTimespan) as $mealPlanEntry)
{
$recipe = FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id']);
$title = '';
if ($recipe !== null)
{
$title = $recipe->name;
}
$productDetails = null;
if ($mealPlanEntry['product_id'] !== null)
{
$productDetails = $this->getStockService()->GetProductDetails($mealPlanEntry['product_id']);
}
$events[] = [
'id' => $mealPlanEntry['id'],
'title' => $title,
'start' => $mealPlanEntry['day'],
'date_format' => 'date',
'recipe' => json_encode($recipe),
'mealPlanEntry' => json_encode($mealPlanEntry),
'type' => $mealPlanEntry['type'],
'productDetails' => json_encode($productDetails)
];
}
return $this->renderPage($response, 'mealplan', [
'fullcalendarEventSources' => $events,
'recipes' => $recipes,
'internalRecipes' => $this->getDatabase()->recipes()->where("id IN (SELECT recipe_id FROM meal_plan_internal_recipe_relation WHERE $mealPlanWhereTimespan)")->fetchAll(),
'recipesResolved' => $this->getRecipesService()->GetRecipesResolved2("recipe_id IN (SELECT recipe_id FROM meal_plan_internal_recipe_relation WHERE $mealPlanWhereTimespan)"),
'products' => $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->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')
]);
}
protected $RecipesService;
protected $UserfieldsService;
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if (isset($request->getQueryParams()['include-internal']))
{
$recipes = $this->Database->recipes()->orderBy('name');
}
else
{
$recipes = $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name');
}
$recipesResolved = $this->RecipesService->GetRecipesResolved();
$recipes = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name', 'COLLATE NOCASE');
$recipesResolved = $this->getRecipesService()->GetRecipesResolved('recipe_id > 0');
$selectedRecipe = null;
$selectedRecipePositionsResolved = null;
if (isset($request->getQueryParams()['recipe']))
{
$selectedRecipe = $this->Database->recipes($request->getQueryParams()['recipe']);
$selectedRecipePositionsResolved = $this->Database->recipes_pos_resolved()->where('recipe_id', $request->getQueryParams()['recipe'])->orderBy('ingredient_group');
$selectedRecipe = $this->getDatabase()->recipes($request->getQueryParams()['recipe']);
}
else
{
foreach ($recipes as $recipe)
{
$selectedRecipe = $recipe;
$selectedRecipePositionsResolved = $this->Database->recipes_pos_resolved()->where('recipe_id', $recipe->id)->orderBy('ingredient_group');
break;
}
}
$selectedRecipeSubRecipes = $this->Database->recipes()->where('id IN (SELECT includes_recipe_id FROM recipes_nestings_resolved WHERE recipe_id = :1 AND includes_recipe_id != :1)', $selectedRecipe->id)->orderBy('name')->fetchAll();
$selectedRecipeSubRecipesPositions = $this->Database->recipes_pos_resolved()->where('recipe_id = :1', $selectedRecipe->id)->orderBy('ingredient_group')->fetchAll();
$includedRecipeIdsAbsolute = array();
$includedRecipeIdsAbsolute[] = $selectedRecipe->id;
foreach($selectedRecipeSubRecipes as $subRecipe)
$totalCosts = null;
$totalCalories = null;
if ($selectedRecipe)
{
$includedRecipeIdsAbsolute[] = $subRecipe->id;
$totalCosts = FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->costs;
$totalCalories = FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->calories;
}
return $this->AppContainer->view->render($response, 'recipes', [
$renderArray = [
'recipes' => $recipes,
'recipesResolved' => $recipesResolved,
'recipePositionsResolved' => $this->Database->recipes_pos_resolved(),
'recipePositionsResolved' => $this->getDatabase()->recipes_pos_resolved()->where('recipe_type', RecipesService::RECIPE_TYPE_NORMAL),
'selectedRecipe' => $selectedRecipe,
'selectedRecipePositionsResolved' => $selectedRecipePositionsResolved,
'products' => $this->Database->products(),
'quantityUnits' => $this->Database->quantity_units(),
'selectedRecipeSubRecipes' => $selectedRecipeSubRecipes,
'selectedRecipeSubRecipesPositions' => $selectedRecipeSubRecipesPositions,
'includedRecipeIdsAbsolute' => $includedRecipeIdsAbsolute,
'selectedRecipeTotalCosts' => FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->costs,
'selectedRecipeTotalCalories' => FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->calories,
'userfields' => $this->UserfieldsService->GetFields('recipes'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('recipes'),
'quantityUnitConversionsResolved' => $this->Database->quantity_unit_conversions_resolved()
]);
'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(),
'selectedRecipeTotalCosts' => $totalCosts,
'selectedRecipeTotalCalories' => $totalCalories
];
if ($selectedRecipe)
{
$selectedRecipeSubRecipes = $this->getDatabase()->recipes()->where('id IN (SELECT includes_recipe_id FROM recipes_nestings_resolved WHERE recipe_id = :1 AND includes_recipe_id != :1)', $selectedRecipe->id)->orderBy('name', 'COLLATE NOCASE')->fetchAll();
$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;
}
return $this->renderPage($response, 'recipes', $renderArray);
}
public function RecipeEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function RecipeEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$recipeId = $args['recipeId'];
if ($recipeId == 'new')
{
$newRecipe = $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->createRow(array(
'name' => $this->LocalizationService->__t('New recipe')
));
$newRecipe->save();
$recipeId = $this->Database->lastInsertId();
}
return $this->AppContainer->view->render($response, 'recipeform', [
'recipe' => $this->Database->recipes($recipeId),
'recipePositions' => $this->Database->recipes_pos()->where('recipe_id', $recipeId),
'mode' => 'edit',
'products' => $this->Database->products(),
'quantityunits' => $this->Database->quantity_units(),
'recipePositionsResolved' => $this->RecipesService->GetRecipesPosResolved(),
'recipesResolved' => $this->RecipesService->GetRecipesResolved(),
'recipes' => $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name'),
'recipeNestings' => $this->Database->recipes_nestings()->where('recipe_id', $recipeId),
'userfields' => $this->UserfieldsService->GetFields('recipes'),
'quantityUnitConversionsResolved' => $this->Database->quantity_unit_conversions_resolved()
return $this->renderPage($response, 'recipeform', [
'recipe' => $this->getDatabase()->recipes($recipeId),
'recipePositions' => $this->getDatabase()->recipes_pos()->where('recipe_id', $recipeId),
'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()
]);
}
public function RecipePosEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function RecipePosEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['recipePosId'] == 'new')
{
return $this->AppContainer->view->render($response, 'recipeposform', [
return $this->renderPage($response, 'recipeposform', [
'mode' => 'create',
'recipe' => $this->Database->recipes($args['recipeId']),
'recipe' => $this->getDatabase()->recipes($args['recipeId']),
'recipePos' => new \stdClass(),
'products' => $this->Database->products()->orderBy('name'),
'quantityUnits' => $this->Database->quantity_units()->orderBy('name'),
'quantityUnitConversionsResolved' => $this->Database->quantity_unit_conversions_resolved()
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
]);
}
else
{
return $this->AppContainer->view->render($response, 'recipeposform', [
return $this->renderPage($response, 'recipeposform', [
'mode' => 'edit',
'recipe' => $this->Database->recipes($args['recipeId']),
'recipePos' => $this->Database->recipes_pos($args['recipePosId']),
'products' => $this->Database->products()->orderBy('name'),
'quantityUnits' => $this->Database->quantity_units()->orderBy('name'),
'quantityUnitConversionsResolved' => $this->Database->quantity_unit_conversions_resolved()
'recipe' => $this->getDatabase()->recipes($args['recipeId']),
'recipePos' => $this->getDatabase()->recipes_pos($args['recipePosId']),
'products' => $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
]);
}
}
public function MealPlan(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function RecipesSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$recipes = $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll();
return $this->renderPage($response, 'recipessettings');
}
$events = array();
foreach($this->Database->meal_plan() as $mealPlanEntry)
public function MealPlanSectionEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['sectionId'] == 'new')
{
$recipe = FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id']);
$title = '';
if ($recipe !== null)
{
$title = $recipe->name;
}
$events[] = array(
'id' => $mealPlanEntry['id'],
'title' => $title,
'start' => $mealPlanEntry['day'],
'date_format' => 'date',
'recipe' => json_encode($recipe),
'mealPlanEntry' => json_encode($mealPlanEntry)
);
return $this->renderPage($response, 'mealplansectionform', [
'mode' => 'create'
]);
}
else
{
return $this->renderPage($response, 'mealplansectionform', [
'mealplanSection' => $this->getDatabase()->meal_plan_sections($args['sectionId']),
'mode' => 'edit'
]);
}
}
return $this->AppContainer->view->render($response, 'mealplan', [
'fullcalendarEventSources' => $events,
'recipes' => $recipes,
'internalRecipes' => $this->Database->recipes()->whereNot('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll(),
'recipesResolved' => $this->RecipesService->GetRecipesResolved()
public function MealPlanSectionsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'mealplansections', [
'mealplanSections' => $this->getDatabase()->meal_plan_sections()->where('id > 0')->orderBy('sort_number')
]);
}
}

View File

@@ -2,23 +2,30 @@
namespace Grocy\Controllers;
use \Grocy\Services\StockService;
use Grocy\Controllers\Users\User;
use Grocy\Services\StockService;
use Grocy\Helpers\WebhookRunner;
use Grocy\Helpers\Grocycode;
class StockApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function AddMissingProductsToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->StockService = new StockService();
}
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
protected $StockService;
public function ProductDetails(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
try
{
return $this->ApiResponse($this->StockService->GetProductDetails($args['productId']));
$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()->AddMissingProductsToShoppingList($listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
@@ -26,12 +33,23 @@ class StockApiController extends BaseApiController
}
}
public function ProductDetailsByBarcode(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function AddOverdueProductsToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
try
{
$productId = $this->StockService->GetProductIdFromBarcode($args['barcode']);
return $this->ApiResponse($this->StockService->GetProductDetails($productId));
$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()->AddOverdueProductsToShoppingList($listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
@@ -39,11 +57,23 @@ class StockApiController extends BaseApiController
}
}
public function ProductPriceHistory(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function AddExpiredProductsToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
try
{
return $this->ApiResponse($this->StockService->GetProductPriceHistory($args['productId']));
$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()->AddExpiredProductsToShoppingList($listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
@@ -51,9 +81,11 @@ class StockApiController extends BaseApiController
}
}
public function AddProduct(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function AddProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
User::checkPermission($request, User::PERMISSION_STOCK_PURCHASE);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
@@ -68,31 +100,56 @@ 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['transactiontype']))
{
$transactionType = $requestBody['transactiontype'];
}
$runPrinterWebhook = false;
if (array_key_exists('print_stock_label', $requestBody) && intval($requestBody['print_stock_label']))
{
$runPrinterWebhook = intval($requestBody['print_stock_label']);
}
$bookingId = $this->StockService->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price, $locationId);
return $this->ApiResponse($this->Database->stock_log($bookingId));
$transactionId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, $purchasedDate, $price, $locationId, $shoppingLocationId, $unusedTransactionId, $runPrinterWebhook);
$args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args);
}
catch (\Exception $ex)
{
@@ -100,11 +157,11 @@ class StockApiController extends BaseApiController
}
}
public function AddProductByBarcode(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function AddProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$args['productId'] = $this->StockService->GetProductIdFromBarcode($args['barcode']);
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->AddProduct($request, $response, $args);
}
catch (\Exception $ex)
@@ -113,9 +170,88 @@ class StockApiController extends BaseApiController
}
}
public function ConsumeProduct(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function AddProductToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_ADD);
try
{
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$listId = 1;
$amount = 1;
$quId = -1;
$productId = null;
$note = null;
if (array_key_exists('list_id', $requestBody) && !empty($requestBody['list_id']) && is_numeric($requestBody['list_id']))
{
$listId = intval($requestBody['list_id']);
}
if (array_key_exists('product_amount', $requestBody) && !empty($requestBody['product_amount']) && is_numeric($requestBody['product_amount']))
{
$amount = intval($requestBody['product_amount']);
}
if (array_key_exists('product_id', $requestBody) && !empty($requestBody['product_id']) && is_numeric($requestBody['product_id']))
{
$productId = intval($requestBody['product_id']);
}
if (array_key_exists('note', $requestBody) && !empty($requestBody['note']))
{
$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, $quId, $note, $listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ClearShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_DELETE);
try
{
$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);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ConsumeProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_CONSUME);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
@@ -136,7 +272,7 @@ class StockApiController extends BaseApiController
}
$transactionType = StockService::TRANSACTION_TYPE_CONSUME;
if (array_key_exists('transaction_type', $requestBody) && !empty($requestBody['transactiontype']))
if (array_key_exists('transaction_type', $requestBody) && !empty($requestBody['transactiontype']))
{
$transactionType = $requestBody['transactiontype'];
}
@@ -147,14 +283,34 @@ class StockApiController extends BaseApiController
$specificStockEntryId = $requestBody['stock_entry_id'];
}
$locationId = null;
if (array_key_exists('location_id', $requestBody) && !empty($requestBody['location_id']) && is_numeric($requestBody['location_id']))
{
$locationId = $requestBody['location_id'];
}
$recipeId = null;
if (array_key_exists('recipe_id', $requestBody) && is_numeric($requestBody['recipe_id']))
{
$recipeId = $requestBody['recipe_id'];
}
$bookingId = $this->StockService->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId);
return $this->ApiResponse($this->Database->stock_log($bookingId));
$consumeExact = false;
if (array_key_exists('exact_amount', $requestBody))
{
$consumeExact = $requestBody['exact_amount'];
}
$allowSubproductSubstitution = false;
if (array_key_exists('allow_subproduct_substitution', $requestBody))
{
$allowSubproductSubstitution = $requestBody['allow_subproduct_substitution'];
}
$transactionId = null;
$transactionId = $this->getStockService()->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId, $locationId, $transactionId, $allowSubproductSubstitution, $consumeExact);
$args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args);
}
catch (\Exception $ex)
{
@@ -162,11 +318,23 @@ class StockApiController extends BaseApiController
}
}
public function ConsumeProductByBarcode(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ConsumeProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$args['productId'] = $this->StockService->GetProductIdFromBarcode($args['barcode']);
$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)
@@ -175,9 +343,114 @@ class StockApiController extends BaseApiController
}
}
public function InventoryProduct(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function CurrentStock(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
return $this->ApiResponse($response, $this->getStockService()->GetCurrentStock());
}
public function CurrentVolatileStock(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$nextXDays = 5;
if (isset($request->getQueryParams()['due_soon_days']) && !empty($request->getQueryParams()['due_soon_days']) && is_numeric($request->getQueryParams()['due_soon_days']))
{
$nextXDays = $request->getQueryParams()['due_soon_days'];
}
$dueProducts = $this->getStockService()->GetDueProducts($nextXDays, true);
$overdueProducts = $this->getStockService()->GetDueProducts(-1);
$expiredProducts = $this->getStockService()->GetExpiredProducts();
$missingProducts = $this->getStockService()->GetMissingProducts();
return $this->ApiResponse($response, [
'due_products' => $dueProducts,
'overdue_products' => $overdueProducts,
'expired_products' => $expiredProducts,
'missing_products' => $missingProducts
]);
}
public function EditStockEntry(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_EDIT);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
if ($requestBody === null)
{
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
if (!array_key_exists('amount', $requestBody))
{
throw new \Exception('An amount is required');
}
$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']);
$args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ExternalBarcodeLookup(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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;
}
return $this->ApiResponse($response, $this->getStockService()->ExternalBarcodeLookup($args['barcode'], $addFoundProduct));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function InventoryProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_INVENTORY);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
@@ -197,6 +470,12 @@ class StockApiController extends BaseApiController
$bestBeforeDate = $requestBody['best_before_date'];
}
$purchasedDate = null;
if (array_key_exists('purchased_date', $requestBody) && IsIsoDate($requestBody['purchased_date']))
{
$purchasedDate = $requestBody['purchased_date'];
}
$locationId = null;
if (array_key_exists('location_id', $requestBody) && is_numeric($requestBody['location_id']))
{
@@ -209,8 +488,15 @@ class StockApiController extends BaseApiController
$price = $requestBody['price'];
}
$bookingId = $this->StockService->InventoryProduct($args['productId'], $requestBody['new_amount'], $bestBeforeDate, $locationId, $price);
return $this->ApiResponse($this->Database->stock_log($bookingId));
$shoppingLocationId = null;
if (array_key_exists('shopping_location_id', $requestBody) && is_numeric($requestBody['shopping_location_id']))
{
$shoppingLocationId = $requestBody['shopping_location_id'];
}
$transactionId = $this->getStockService()->InventoryProduct($args['productId'], $requestBody['new_amount'], $bestBeforeDate, $locationId, $price, $shoppingLocationId, $purchasedDate);
$args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args);
}
catch (\Exception $ex)
{
@@ -218,11 +504,11 @@ class StockApiController extends BaseApiController
}
}
public function InventoryProductByBarcode(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function InventoryProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$args['productId'] = $this->StockService->GetProductIdFromBarcode($args['barcode']);
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->InventoryProduct($request, $response, $args);
}
catch (\Exception $ex)
@@ -231,9 +517,11 @@ class StockApiController extends BaseApiController
}
}
public function OpenProduct(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function OpenProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
User::checkPermission($request, User::PERMISSION_STOCK_OPEN);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
@@ -253,8 +541,16 @@ class StockApiController extends BaseApiController
$specificStockEntryId = $requestBody['stock_entry_id'];
}
$bookingId = $this->StockService->OpenProduct($args['productId'], $requestBody['amount'], $specificStockEntryId);
return $this->ApiResponse($this->Database->stock_log($bookingId));
$allowSubproductSubstitution = false;
if (array_key_exists('allow_subproduct_substitution', $requestBody))
{
$allowSubproductSubstitution = $requestBody['allow_subproduct_substitution'];
}
$transactionId = null;
$transactionId = $this->getStockService()->OpenProduct($args['productId'], $requestBody['amount'], $specificStockEntryId, $transactionId, $allowSubproductSubstitution);
$args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args);
}
catch (\Exception $ex)
{
@@ -262,11 +558,11 @@ class StockApiController extends BaseApiController
}
}
public function OpenProductByBarcode(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function OpenProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$args['productId'] = $this->StockService->GetProductIdFromBarcode($args['barcode']);
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->OpenProduct($request, $response, $args);
}
catch (\Exception $ex)
@@ -275,43 +571,11 @@ class StockApiController extends BaseApiController
}
}
public function CurrentStock(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->ApiResponse($this->StockService->GetCurrentStock());
}
public function CurrentVolatilStock(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$nextXDays = 5;
if (isset($request->getQueryParams()['expiring_days']) && !empty($request->getQueryParams()['expiring_days']) && is_numeric($request->getQueryParams()['expiring_days']))
{
$nextXDays = $request->getQueryParams()['expiring_days'];
}
$expiringProducts = $this->StockService->GetExpiringProducts($nextXDays, true);
$expiredProducts = $this->StockService->GetExpiringProducts(-1);
$missingProducts = $this->StockService->GetMissingProducts();
return $this->ApiResponse(array(
'expiring_products' => $expiringProducts,
'expired_products' => $expiredProducts,
'missing_products' => $missingProducts
));
}
public function AddMissingProductsToShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProductDetails(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$requestBody = $request->getParsedBody();
$listId = 1;
if (array_key_exists('list_id', $requestBody) && !empty($requestBody['list_id']) && is_numeric($requestBody['list_id']))
{
$listId = intval($requestBody['list_id']);
}
$this->StockService->AddMissingProductsToShoppingList($listId);
return $this->EmptyApiResponse($response);
return $this->ApiResponse($response, $this->getStockService()->GetProductDetails($args['productId']));
}
catch (\Exception $ex)
{
@@ -319,20 +583,12 @@ class StockApiController extends BaseApiController
}
}
public function ClearShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProductDetailsByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$requestBody = $request->getParsedBody();
$listId = 1;
if (array_key_exists('list_id', $requestBody) && !empty($requestBody['list_id']) && is_numeric($requestBody['list_id']))
{
$listId = intval($requestBody['list_id']);
}
$this->StockService->ClearShoppingList($listId);
return $this->EmptyApiResponse($response);
$productId = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->ApiResponse($response, $this->getStockService()->GetProductDetails($productId));
}
catch (\Exception $ex)
{
@@ -340,24 +596,116 @@ class StockApiController extends BaseApiController
}
}
public function AddItemToShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProductPriceHistory(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$requestBody = $request->getParsedBody();
return $this->ApiResponse($response, $this->getStockService()->GetProductPriceHistory($args['productId']));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ProductStockEntries(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$allowSubproductSubstitution = false;
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());
}
public function ProductStockLocations(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$allowSubproductSubstitution = false;
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()->GetProductStockLocations($args['productId'], $allowSubproductSubstitution), $request->getQueryParams());
}
public function ProductPrintLabel(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$product = $this->getDatabase()->products()->where('id', $args['productId'])->fetch();
$webhookData = array_merge([
'product' => $product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $product->id)),
], 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(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$stockEntry = $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch();
$product = $this->getDatabase()->products()->where('id', $stockEntry->product_id)->fetch();
$webhookData = array_merge([
'product' => $product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $stockEntry->product_id, [$stockEntry->stock_id])),
], 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(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST_ITEMS_DELETE);
try
{
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$listId = 1;
$amount = 1;
$productId = null;
if (array_key_exists('list_id', $requestBody) && !empty($requestBody['list_id']) && is_numeric($requestBody['list_id']))
{
$listId = intval($requestBody['list_id']);
}
if (array_key_exists('product_amount', $requestBody) && !empty($requestBody['product_amount']) && is_numeric($requestBody['product_amount']))
{
$amount = intval($requestBody['product_amount']);
}
if (array_key_exists('product_id', $requestBody) && !empty($requestBody['product_id']) && is_numeric($requestBody['product_id']))
{
$productId = intval($requestBody['product_id']);
@@ -365,10 +713,10 @@ class StockApiController extends BaseApiController
if ($productId == null)
{
throw new \Exception("No product id was supplied");
throw new \Exception('No product id was supplied');
}
$this->StockService->AddProductToShoppingList($productId, $amount, $listId);
$this->getStockService()->RemoveProductFromShoppingList($productId, $amount, $listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -377,90 +725,161 @@ class StockApiController extends BaseApiController
}
}
public function RemoveItemFromShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function StockBooking(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$requestBody = $request->getParsedBody();
$listId = 1;
$amount = 1;
$productId = null;
if (array_key_exists('list_id', $requestBody) && !empty($requestBody['list_id']) && is_numeric($requestBody['list_id']))
{
$listId = intval($requestBody['list_id']);
}
if (array_key_exists('product_amount', $requestBody) && !empty($requestBody['product_amount']) && is_numeric($requestBody['product_amount']))
{
$amount = intval($requestBody['product_amount']);
}
if (array_key_exists('product_id', $requestBody) && !empty($requestBody['product_id']) && is_numeric($requestBody['product_id']))
{
$productId = intval($requestBody['product_id']);
}
if ($productId == null)
{
throw new \Exception("No product id was supplied");
}
$this->StockService->RemoveProductFromShoppingList($productId, $amount, $listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ExternalBarcodeLookup(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
try
{
$addFoundProduct = false;
if (isset($request->getQueryParams()['add']) && ($request->getQueryParams()['add'] === 'true' || $request->getQueryParams()['add'] === 1))
{
$addFoundProduct = true;
}
return $this->ApiResponse($this->StockService->ExternalBarcodeLookup($args['barcode'], $addFoundProduct));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function UndoBooking(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
try
{
$this->ApiResponse($this->StockService->UndoBooking($args['bookingId']));
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ProductStockEntries(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->ApiResponse($this->StockService->GetProductStockEntries($args['productId']));
}
public function StockBooking(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
try
{
$stockLogRow = $this->Database->stock_log($args['bookingId']);
$stockLogRow = $this->getDatabase()->stock_log($args['bookingId']);
if ($stockLogRow === null)
{
throw new \Exception('Stock booking does not exist');
}
return $this->ApiResponse($stockLogRow);
return $this->ApiResponse($response, $stockLogRow);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function StockEntry(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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)
{
try
{
$transactionRows = $this->getDatabase()->stock_log()->where('transaction_id = :1', $args['transactionId'])->fetchAll();
if (count($transactionRows) === 0)
{
throw new \Exception('No transaction was found by the given transaction id');
}
return $this->ApiResponse($response, $transactionRows);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function TransferProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_TRANSFER);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
if ($requestBody === null)
{
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
if (!array_key_exists('amount', $requestBody))
{
throw new \Exception('An amount is required');
}
if (!array_key_exists('location_id_from', $requestBody))
{
throw new \Exception('A transfer from location is required');
}
if (!array_key_exists('location_id_to', $requestBody))
{
throw new \Exception('A transfer to location is required');
}
$specificStockEntryId = 'default';
if (array_key_exists('stock_entry_id', $requestBody) && !empty($requestBody['stock_entry_id']))
{
$specificStockEntryId = $requestBody['stock_entry_id'];
}
$transactionId = $this->getStockService()->TransferProduct($args['productId'], $requestBody['amount'], $requestBody['location_id_from'], $requestBody['location_id_to'], $specificStockEntryId);
$args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function TransferProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function UndoBooking(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_EDIT);
try
{
$this->ApiResponse($response, $this->getStockService()->UndoBooking($args['bookingId']));
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function UndoTransaction(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_EDIT);
try
{
$this->ApiResponse($response, $this->getStockService()->UndoTransaction($args['transactionId']));
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function MergeProducts(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_STOCK_EDIT);
try
{
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');
}
$this->ApiResponse($response, $this->getStockService()->MergeProducts($args['productIdToKeep'], $args['productIdToRemove']));
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{

View File

@@ -2,331 +2,538 @@
namespace Grocy\Controllers;
use \Grocy\Services\StockService;
use \Grocy\Services\UsersService;
use \Grocy\Services\UserfieldsService;
use Grocy\Helpers\Grocycode;
use Grocy\Services\RecipesService;
class StockController extends BaseController
{
use GrocycodeTrait;
public function __construct(\Slim\Container $container)
public function Consume(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->StockService = new StockService();
$this->UserfieldsService = new UserfieldsService();
}
protected $StockService;
protected $UserfieldsService;
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$usersService = new UsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
return $this->AppContainer->view->render($response, 'stockoverview', [
'products' => $this->Database->products()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'locations' => $this->Database->locations()->orderBy('name'),
'currentStock' => $this->StockService->GetCurrentStock(),
'currentStockLocations' => $this->StockService->GetCurrentStockLocations(),
'missingProducts' => $this->StockService->GetMissingProducts(),
'nextXDays' => $nextXDays,
'productGroups' => $this->Database->product_groups()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('products'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
return $this->renderPage($response, 'consume', [
'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()
]);
}
public function Purchase(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Inventory(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'purchase', [
'products' => $this->Database->products()->orderBy('name'),
'locations' => $this->Database->locations()->orderBy('name')
return $this->renderPage($response, 'inventory', [
'products' => $this->getDatabase()->products()->where('active = 1')->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()
]);
}
public function Consume(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'consume', [
'products' => $this->Database->products()->orderBy('name'),
'recipes' => $this->Database->recipes()->orderBy('name')
]);
}
public function Inventory(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'inventory', [
'products' => $this->Database->products()->orderBy('name'),
'locations' => $this->Database->locations()->orderBy('name')
]);
}
public function ShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$listId = 1;
if (isset($request->getQueryParams()['list']))
if (isset($request->getQueryParams()['months']) && filter_var($request->getQueryParams()['months'], FILTER_VALIDATE_INT) !== false)
{
$listId = $request->getQueryParams()['list'];
$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')";
}
return $this->AppContainer->view->render($response, 'shoppinglist', [
'listItems' => $this->Database->shopping_list()->where('shopping_list_id = :1', $listId),
'products' => $this->Database->products()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'missingProducts' => $this->StockService->GetMissingProducts(),
'productGroups' => $this->Database->product_groups()->orderBy('name'),
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
'selectedShoppingListId' => $listId,
'userfields' => $this->UserfieldsService->GetFields('products'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
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()->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_')
]);
}
public function ProductsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function LocationContentSheet(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'products', [
'products' => $this->Database->products()->orderBy('name'),
'locations' => $this->Database->locations()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'productGroups' => $this->Database->product_groups()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('products'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
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()
]);
}
public function StockSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function LocationEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'stocksettings', [
'locations' => $this->Database->locations()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'productGroups' => $this->Database->product_groups()->orderBy('name')
]);
if ($args['locationId'] == 'new')
{
return $this->renderPage($response, 'locationform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('locations')
]);
}
else
{
return $this->renderPage($response, 'locationform', [
'location' => $this->getDatabase()->locations($args['locationId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('locations')
]);
}
}
public function LocationsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function LocationsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'locations', [
'locations' => $this->Database->locations()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('locations'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('locations')
return $this->renderPage($response, 'locations', [
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('locations'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('locations')
]);
}
public function ProductGroupsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'productgroups', [
'productGroups' => $this->Database->product_groups()->orderBy('name'),
'products' => $this->Database->products()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('product_groups'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('product_groups')
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_due_soon_days'];
return $this->renderPage($response, 'stockoverview', [
'currentStock' => $this->getStockService()->GetCurrentStockOverview(),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(),
'nextXDays' => $nextXDays,
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
]);
}
public function QuantityUnitsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProductBarcodesEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'quantityunits', [
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('quantity_units'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('quantity_units')
]);
$product = null;
if (isset($request->getQueryParams()['product']))
{
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
}
if ($args['productBarcodeId'] == 'new')
{
return $this->renderPage($response, 'productbarcodeform', [
'mode' => 'create',
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
'product' => $product,
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('product_barcodes')
]);
}
else
{
return $this->renderPage($response, 'productbarcodeform', [
'mode' => 'edit',
'barcode' => $this->getDatabase()->product_barcodes($args['productBarcodeId']),
'product' => $product,
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('product_barcodes')
]);
}
}
public function ProductEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProductEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['productId'] == 'new')
{
return $this->AppContainer->view->render($response, 'productform', [
'locations' => $this->Database->locations()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'productgroups' => $this->Database->product_groups()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('products'),
'products' => $this->Database->products()->where('parent_product_id IS NULL')->orderBy('name'),
return $this->renderPage($response, 'productform', [
'locations' => $this->getDatabase()->locations()->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'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'products' => $this->getDatabase()->products()->where('parent_product_id IS NULL and active = 1')->orderBy('name', 'COLLATE NOCASE'),
'isSubProductOfOthers' => false,
'mode' => 'create'
]);
}
else
{
$product = $this->Database->products($args['productId']);
$product = $this->getDatabase()->products($args['productId']);
return $this->AppContainer->view->render($response, 'productform', [
'product' => $product,
'locations' => $this->Database->locations()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'productgroups' => $this->Database->product_groups()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('products'),
'products' => $this->Database->products()->where('id != :1 AND parent_product_id IS NULL', $product->id)->orderBy('name'),
'isSubProductOfOthers' => $this->Database->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
return $this->renderPage($response, 'productform', [
'product' => $product,
'locations' => $this->getDatabase()->locations()->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'),
'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->Database->quantity_unit_conversions()
'quConversions' => $this->getDatabase()->quantity_unit_conversions(),
'productBarcodeUserfields' => $this->getUserfieldsService()->GetFields('product_barcodes'),
'productBarcodeUserfieldValues' => $this->getUserfieldsService()->GetAllValues('product_barcodes')
]);
}
}
public function LocationEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProductGrocycodeImage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['locationId'] == 'new')
{
return $this->AppContainer->view->render($response, 'locationform', [
'mode' => 'create',
'userfields' => $this->UserfieldsService->GetFields('locations')
]);
}
else
{
return $this->AppContainer->view->render($response, 'locationform', [
'location' => $this->Database->locations($args['locationId']),
'mode' => 'edit',
'userfields' => $this->UserfieldsService->GetFields('locations')
]);
}
$gc = new Grocycode(Grocycode::PRODUCT, $args['productId']);
return $this->ServeGrocycodeImage($request, $response, $gc);
}
public function ProductGroupEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProductGroupEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['productGroupId'] == 'new')
{
return $this->AppContainer->view->render($response, 'productgroupform', [
return $this->renderPage($response, 'productgroupform', [
'mode' => 'create',
'userfields' => $this->UserfieldsService->GetFields('product_groups')
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
]);
}
else
{
return $this->AppContainer->view->render($response, 'productgroupform', [
'group' => $this->Database->product_groups($args['productGroupId']),
return $this->renderPage($response, 'productgroupform', [
'group' => $this->getDatabase()->product_groups($args['productGroupId']),
'mode' => 'edit',
'userfields' => $this->UserfieldsService->GetFields('product_groups')
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
]);
}
}
public function QuantityUnitEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProductGroupsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['quantityunitId'] == 'new')
{
return $this->AppContainer->view->render($response, 'quantityunitform', [
'mode' => 'create',
'userfields' => $this->UserfieldsService->GetFields('quantity_units'),
'pluralCount' => $this->LocalizationService->GetPluralCount(),
'pluralRule' => $this->LocalizationService->GetPluralDefinition()
]);
}
else
{
$quantityUnit = $this->Database->quantity_units($args['quantityunitId']);
return $this->AppContainer->view->render($response, 'quantityunitform', [
'quantityUnit' => $quantityUnit,
'mode' => 'edit',
'userfields' => $this->UserfieldsService->GetFields('quantity_units'),
'pluralCount' => $this->LocalizationService->GetPluralCount(),
'pluralRule' => $this->LocalizationService->GetPluralDefinition(),
'defaultQuConversions' => $this->Database->quantity_unit_conversions()->where('from_qu_id = :1 AND product_id IS NULL', $quantityUnit->id),
'quantityUnits' => $this->Database->quantity_units()
]);
}
}
public function ShoppingListItemEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
if ($args['itemId'] == 'new')
{
return $this->AppContainer->view->render($response, 'shoppinglistitemform', [
'products' => $this->Database->products()->orderBy('name'),
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
'mode' => 'create'
]);
}
else
{
return $this->AppContainer->view->render($response, 'shoppinglistitemform', [
'listItem' => $this->Database->shopping_list($args['itemId']),
'products' => $this->Database->products()->orderBy('name'),
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
'mode' => 'edit'
]);
}
}
public function ShoppingListEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
if ($args['listId'] == 'new')
{
return $this->AppContainer->view->render($response, 'shoppinglistform', [
'mode' => 'create'
]);
}
else
{
return $this->AppContainer->view->render($response, 'shoppinglistform', [
'shoppingList' => $this->Database->shopping_lists($args['listId']),
'mode' => 'edit'
]);
}
}
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'stockjournal', [
'stockLog' => $this->Database->stock_log()->orderBy('row_created_timestamp', 'DESC'),
'products' => $this->Database->products()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name')
return $this->renderPage($response, 'productgroups', [
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
'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 LocationContentSheet(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProductsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'locationcontentsheet', [
'products' => $this->Database->products()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'locations' => $this->Database->locations()->orderBy('name'),
'currentStockLocationContent' => $this->StockService->GetCurrentStockLocationContent()
$products = $this->getDatabase()->products();
if (!isset($request->getQueryParams()['include_disabled']))
{
$products = $products->where('active = 1');
}
if (isset($request->getQueryParams()['only_in_stock']))
{
$products = $products->where('id 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'),
'shoppingLocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
]);
}
public function QuantityUnitConversionEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Purchase(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'purchase', [
'products' => $this->getDatabase()->products()->where('active = 1')->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()
]);
}
public function QuantityUnitConversionEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$product = null;
if (isset($request->getQueryParams()['product']))
{
$product = $this->Database->products($request->getQueryParams()['product']);
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
}
$defaultQuUnit = null;
if (isset($request->getQueryParams()['qu-unit']))
{
$defaultQuUnit = $this->Database->quantity_units($request->getQueryParams()['qu-unit']);
$defaultQuUnit = $this->getDatabase()->quantity_units($request->getQueryParams()['qu-unit']);
}
if ($args['quConversionId'] == 'new')
{
return $this->AppContainer->view->render($response, 'quantityunitconversionform', [
return $this->renderPage($response, 'quantityunitconversionform', [
'mode' => 'create',
'userfields' => $this->UserfieldsService->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'product' => $product,
'defaultQuUnit' => $defaultQuUnit
]);
}
else
{
return $this->AppContainer->view->render($response, 'quantityunitconversionform', [
'quConversion' => $this->Database->quantity_unit_conversions($args['quConversionId']),
return $this->renderPage($response, 'quantityunitconversionform', [
'quConversion' => $this->getDatabase()->quantity_unit_conversions($args['quConversionId']),
'mode' => 'edit',
'userfields' => $this->UserfieldsService->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'product' => $product,
'defaultQuUnit' => $defaultQuUnit
]);
}
}
public function QuantityUnitPluralFormTesting(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function QuantityUnitEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'quantityunitpluraltesting', [
'quantityUnits' => $this->Database->quantity_units()->orderBy('name')
if ($args['quantityunitId'] == 'new')
{
return $this->renderPage($response, 'quantityunitform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
'pluralCount' => $this->getLocalizationService()->GetPluralCount(),
'pluralRule' => $this->getLocalizationService()->GetPluralDefinition()
]);
}
else
{
$quantityUnit = $this->getDatabase()->quantity_units($args['quantityunitId']);
return $this->renderPage($response, 'quantityunitform', [
'quantityUnit' => $quantityUnit,
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
'pluralCount' => $this->getLocalizationService()->GetPluralCount(),
'pluralRule' => $this->getLocalizationService()->GetPluralDefinition(),
'defaultQuConversions' => $this->getDatabase()->quantity_unit_conversions()->where('from_qu_id = :1 AND product_id IS NULL', $quantityUnit->id),
'quantityUnits' => $this->getDatabase()->quantity_units()
]);
}
}
public function QuantityUnitPluralFormTesting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'quantityunitpluraltesting', [
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE')
]);
}
public function QuantityUnitsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'quantityunits', [
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'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)
{
$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),
'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'),
'selectedShoppingListId' => $listId,
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'productUserfields' => $this->getUserfieldsService()->GetFields('products'),
'productUserfieldValues' => $this->getUserfieldsService()->GetAllValues('products'),
'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)
{
if ($args['listId'] == 'new')
{
return $this->renderPage($response, 'shoppinglistform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('shopping_lists')
]);
}
else
{
return $this->renderPage($response, 'shoppinglistform', [
'shoppingList' => $this->getDatabase()->shopping_lists($args['listId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('shopping_lists')
]);
}
}
public function ShoppingListItemEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['itemId'] == 'new')
{
return $this->renderPage($response, 'shoppinglistitemform', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'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(),
'userfields' => $this->getUserfieldsService()->GetFields('shopping_list')
]);
}
else
{
return $this->renderPage($response, 'shoppinglistitemform', [
'listItem' => $this->getDatabase()->shopping_list($args['itemId']),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'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(),
'userfields' => $this->getUserfieldsService()->GetFields('shopping_list')
]);
}
}
public function ShoppingListSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'shoppinglistsettings');
}
public function ShoppingLocationEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['shoppingLocationId'] == 'new')
{
return $this->renderPage($response, 'shoppinglocationform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('shopping_locations')
]);
}
else
{
return $this->renderPage($response, 'shoppinglocationform', [
'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)
{
return $this->renderPage($response, 'shoppinglocations', [
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'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)
{
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')
]);
}
public function StockEntryGrocycodeImage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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')
]);
}
public function Stockentries(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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'),
'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(),
'nextXDays' => $nextXDays,
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
]);
}
public function Transfer(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'transfer', [
'products' => $this->getDatabase()->products()->where('active = 1')->where('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()
]);
}
public function JournalSummary(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$entries = $this->getDatabase()->uihelper_stock_journal_summary();
if (isset($request->getQueryParams()['product_id']))
{
$entries = $entries->where('product_id', $request->getQueryParams()['product_id']);
}
if (isset($request->getQueryParams()['user_id']))
{
$entries = $entries->where('user_id', $request->getQueryParams()['user_id']);
}
if (isset($request->getQueryParams()['transaction_type']))
{
$entries = $entries->where('transaction_type', $request->getQueryParams()['transaction_type']);
}
$usersService = $this->getUsersService();
return $this->renderPage($response, 'stockjournalsummary', [
'entries' => $entries,
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'users' => $usersService->GetUsersAsDto(),
'transactionTypes' => GetClassConstants('\Grocy\Services\StockService', 'TRANSACTION_TYPE_')
]);
}
}

View File

@@ -2,48 +2,91 @@
namespace Grocy\Controllers;
use \Grocy\Services\DatabaseService;
use \Grocy\Services\ApplicationService;
class SystemApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function GetConfig(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->DatabaseService = new DatabaseService();
$this->ApplicationService = new ApplicationService();
try
{
$constants = get_defined_constants();
// Some GROCY_* constants are not really config settings and therefore should not be exposed
unset($constants['GROCY_AUTHENTICATED'], $constants['GROCY_DATAPATH'], $constants['GROCY_IS_EMBEDDED_INSTALL'], $constants['GROCY_USER_ID']);
$returnArray = [];
foreach ($constants as $constant => $value)
{
if (substr($constant, 0, 6) === 'GROCY_')
{
$returnArray[substr($constant, 6)] = $value;
}
}
return $this->ApiResponse($response, $returnArray);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
protected $DatabaseService;
protected $ApplicationService;
public function GetDbChangedTime(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function GetDbChangedTime(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->ApiResponse(array(
'changed_time' => $this->DatabaseService->GetDbChangedTime()
));
return $this->ApiResponse($response, [
'changed_time' => $this->getDatabaseService()->GetDbChangedTime()
]);
}
public function LogMissingLocalization(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function GetSystemInfo(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemInfo());
}
public function GetSystemTime(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $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(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if (GROCY_MODE === 'dev')
{
try
{
$requestBody = $request->getParsedBody();
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$this->LocalizationService->CheckAndAddMissingTranslationToPot($requestBody['text']);
$this->getLocalizationService()->CheckAndAddMissingTranslationToPot($requestBody['text']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}
}
public function GetSystemInfo(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function GetLocalizationStrings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->ApiResponse($this->ApplicationService->GetSystemInfo());
return $this->ApiResponse($response, json_decode($this->getLocalizationService()->GetPoAsJsonString()), true);
}
}

View File

@@ -2,33 +2,37 @@
namespace Grocy\Controllers;
use \Grocy\Services\ApplicationService;
use \Grocy\Services\DatabaseMigrationService;
use \Grocy\Services\DemoDataGeneratorService;
use Grocy\Services\DatabaseMigrationService;
use Grocy\Services\DemoDataGeneratorService;
class SystemController extends BaseController
{
protected $ApplicationService;
public function __construct(\Slim\Container $container)
public function About(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->ApplicationService = new ApplicationService();
return $this->renderPage($response, 'about', [
'system_info' => $this->getApplicationService()->GetSystemInfo(),
'changelog' => $this->getApplicationService()->GetChangelog()
]);
}
public function Root(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function BarcodeScannerTesting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'barcodescannertesting');
}
public function Root(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
// Schema migration is done here
$databaseMigrationService = new DatabaseMigrationService();
$databaseMigrationService = DatabaseMigrationService::getInstance();
$databaseMigrationService->MigrateDatabase();
if (GROCY_IS_DEMO_INSTALL)
if (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
{
$demoDataGeneratorService = new DemoDataGeneratorService();
$demoDataGeneratorService = DemoDataGeneratorService::getInstance();
$demoDataGeneratorService->PopulateDemoData();
}
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl($this->GetEntryPageRelative()));
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl($this->GetEntryPageRelative()));
}
/**
@@ -41,64 +45,68 @@ class SystemController extends BaseController
*/
private function GetEntryPageRelative()
{
if (defined('GROCY_ENTRY_PAGE')) {
if (defined('GROCY_ENTRY_PAGE'))
{
$entryPage = constant('GROCY_ENTRY_PAGE');
} else {
}
else
{
$entryPage = 'stock';
}
// Stock
if ($entryPage === 'stock' && constant('GROCY_FEATURE_FLAG_STOCK')) {
if ($entryPage === 'stock' && constant('GROCY_FEATURE_FLAG_STOCK'))
{
return '/stockoverview';
}
// Shoppinglist
if ($entryPage === 'shoppinglist' && constant('GROCY_FEATURE_FLAG_SHOPPINGLIST')) {
if ($entryPage === 'shoppinglist' && constant('GROCY_FEATURE_FLAG_SHOPPINGLIST'))
{
return '/shoppinglist';
}
// Recipes
if ($entryPage === 'recipes' && constant('GROCY_FEATURE_FLAG_RECIPES')) {
if ($entryPage === 'recipes' && constant('GROCY_FEATURE_FLAG_RECIPES'))
{
return '/recipes';
}
// Chores
if ($entryPage === 'chores' && constant('GROCY_FEATURE_FLAG_CHORES')) {
if ($entryPage === 'chores' && constant('GROCY_FEATURE_FLAG_CHORES'))
{
return '/choresoverview';
}
// Tasks
if ($entryPage === 'tasks' && constant('GROCY_FEATURE_FLAG_TASKS')) {
if ($entryPage === 'tasks' && constant('GROCY_FEATURE_FLAG_TASKS'))
{
return '/tasks';
}
// Batteries
if ($entryPage === 'batteries' && constant('GROCY_FEATURE_FLAG_BATTERIES')) {
if ($entryPage === 'batteries' && constant('GROCY_FEATURE_FLAG_BATTERIES'))
{
return '/batteriesoverview';
}
if ($entryPage === 'equipment' && constant('GROCY_FEATURE_FLAG_EQUIPMENT')) {
if ($entryPage === 'equipment' && constant('GROCY_FEATURE_FLAG_EQUIPMENT'))
{
return '/equipment';
}
// Calendar
if ($entryPage === 'calendar' && constant('GROCY_FEATURE_FLAG_CALENDAR')) {
if ($entryPage === 'calendar' && constant('GROCY_FEATURE_FLAG_CALENDAR'))
{
return '/calendar';
}
// Meal Plan
if ($entryPage === 'mealplan' && constant('GROCY_FEATURE_FLAG_RECIPES'))
{
return '/mealplan';
}
return '/about';
}
public function About(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'about', [
'system_info' => $this->ApplicationService->GetSystemInfo(),
'changelog' => $this->ApplicationService->GetChangelog()
]);
}
public function BarcodeScannerTesting(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'barcodescannertesting');
}
}

View File

@@ -2,36 +2,31 @@
namespace Grocy\Controllers;
use \Grocy\Services\TasksService;
use Grocy\Controllers\Users\User;
class TasksApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function Current(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
parent::__construct($container);
$this->TasksService = new TasksService();
return $this->FilteredApiResponse($response, $this->getTasksService()->GetCurrent(), $request->getQueryParams());
}
protected $TasksService;
public function Current(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function MarkTaskAsCompleted(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->ApiResponse($this->TasksService->GetCurrent());
}
User::checkPermission($request, User::PERMISSION_TASKS_MARK_COMPLETED);
public function MarkTaskAsCompleted(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$requestBody = $request->getParsedBody();
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
$doneTime = date('Y-m-d H:i:s');
if (array_key_exists('done_time', $requestBody) && IsIsoDateTime($requestBody['done_time']))
{
$doneTime = $requestBody['done_time'];
}
$this->TasksService->MarkTaskAsCompleted($args['taskId'], $doneTime);
$this->getTasksService()->MarkTaskAsCompleted($args['taskId'], $doneTime);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -40,11 +35,13 @@ class TasksApiController extends BaseApiController
}
}
public function UndoTask(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function UndoTask(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_TASKS_UNDO_EXECUTION);
try
{
$this->TasksService->UndoTask($args['taskId']);
$this->getTasksService()->UndoTask($args['taskId']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)

View File

@@ -2,99 +2,85 @@
namespace Grocy\Controllers;
use \Grocy\Services\TasksService;
use \Grocy\Services\UsersService;
use \Grocy\Services\UserfieldsService;
class TasksController extends BaseController
{
public function __construct(\Slim\Container $container)
{
parent::__construct($container);
$this->TasksService = new TasksService();
$this->UserfieldsService = new UserfieldsService();
}
protected $TasksService;
protected $UserfieldsService;
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if (isset($request->getQueryParams()['include_done']))
{
$tasks = $this->Database->tasks()->orderBy('name');
$tasks = $this->getDatabase()->tasks()->orderBy('name', 'COLLATE NOCASE');
}
else
{
$tasks = $this->TasksService->GetCurrent();
$tasks = $this->getTasksService()->GetCurrent();
}
$usersService = new UsersService();
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['tasks_due_soon_days'];
return $this->AppContainer->view->render($response, 'tasks', [
return $this->renderPage($response, 'tasks', [
'tasks' => $tasks,
'nextXDays' => $nextXDays,
'taskCategories' => $this->Database->task_categories()->orderBy('name'),
'users' => $this->Database->users(),
'userfields' => $this->UserfieldsService->GetFields('tasks'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('tasks')
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'),
'users' => $this->getDatabase()->users(),
'userfields' => $this->getUserfieldsService()->GetFields('tasks'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('tasks')
]);
}
public function TaskEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function TaskCategoriesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['taskId'] == 'new')
{
return $this->AppContainer->view->render($response, 'taskform', [
'mode' => 'create',
'taskCategories' => $this->Database->task_categories()->orderBy('name'),
'users' => $this->Database->users()->orderBy('username'),
'userfields' => $this->UserfieldsService->GetFields('tasks')
]);
}
else
{
return $this->AppContainer->view->render($response, 'taskform', [
'task' => $this->Database->tasks($args['taskId']),
'mode' => 'edit',
'taskCategories' => $this->Database->task_categories()->orderBy('name'),
'users' => $this->Database->users()->orderBy('username'),
'userfields' => $this->UserfieldsService->GetFields('tasks')
]);
}
}
public function TaskCategoriesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'taskcategories', [
'taskCategories' => $this->Database->task_categories()->orderBy('name'),
'userfields' => $this->UserfieldsService->GetFields('task_categories'),
'userfieldValues' => $this->UserfieldsService->GetAllValues('task_categories')
return $this->renderPage($response, 'taskcategories', [
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'),
'userfields' => $this->getUserfieldsService()->GetFields('task_categories'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('task_categories')
]);
}
public function TaskCategoryEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function TaskCategoryEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['categoryId'] == 'new')
{
return $this->AppContainer->view->render($response, 'taskcategoryform', [
return $this->renderPage($response, 'taskcategoryform', [
'mode' => 'create',
'userfields' => $this->UserfieldsService->GetFields('task_categories')
'userfields' => $this->getUserfieldsService()->GetFields('task_categories')
]);
}
else
{
return $this->AppContainer->view->render($response, 'taskcategoryform', [
'category' => $this->Database->task_categories($args['categoryId']),
return $this->renderPage($response, 'taskcategoryform', [
'category' => $this->getDatabase()->task_categories($args['categoryId']),
'mode' => 'edit',
'userfields' => $this->UserfieldsService->GetFields('task_categories')
'userfields' => $this->getUserfieldsService()->GetFields('task_categories')
]);
}
}
public function TasksSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function TaskEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'taskssettings');
if ($args['taskId'] == 'new')
{
return $this->renderPage($response, 'taskform', [
'mode' => 'create',
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'),
'users' => $this->getDatabase()->users()->orderBy('username'),
'userfields' => $this->getUserfieldsService()->GetFields('tasks')
]);
}
else
{
return $this->renderPage($response, 'taskform', [
'task' => $this->getDatabase()->tasks($args['taskId']),
'mode' => 'edit',
'taskCategories' => $this->getDatabase()->task_categories()->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)
{
return $this->renderPage($response, 'taskssettings');
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Grocy\Controllers\Users;
use Psr\Http\Message\ServerRequestInterface;
use Slim\Exception\HttpForbiddenException;
use Throwable;
class PermissionMissingException extends HttpForbiddenException
{
public function __construct(ServerRequestInterface $request, string $permission, ?Throwable $previous = null)
{
parent::__construct($request, 'Permission missing: ' . $permission, $previous);
}
}

128
controllers/Users/User.php Normal file
View File

@@ -0,0 +1,128 @@
<?php
namespace Grocy\Controllers\Users;
use Grocy\Services\DatabaseService;
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';
const PERMISSION_STOCK_INVENTORY = 'STOCK_INVENTORY';
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';
public function __construct()
{
$this->db = DatabaseService::getInstance()->GetDbConnection();
}
/**
* @var \LessQL\Database|null
*/
protected $db;
public static function PermissionList()
{
$user = new self();
return $user->getPermissionList();
}
public static function checkPermission($request, string ...$permissions): void
{
$user = new self();
foreach ($permissions as $permission)
{
if (!$user->hasPermission($permission))
{
throw new PermissionMissingException($request, $permission);
}
}
}
public function getPermissionList()
{
return $this->db->uihelper_user_permissions()->where('user_id', GROCY_USER_ID);
}
public function hasPermission(string $permission): bool
{
return $this->getPermissions()->where('permission_name', $permission)->fetch() !== null;
}
public static function hasPermissions(string ...$permissions)
{
$user = new self();
foreach ($permissions as $permission)
{
if (!$user->hasPermission($permission))
{
return false;
}
}
return true;
}
protected function getPermissions(): Result
{
return $this->db->user_permissions_resolved()->where('user_id', GROCY_USER_ID);
}
}

View File

@@ -2,23 +2,26 @@
namespace Grocy\Controllers;
use \Grocy\Services\UsersService;
use Grocy\Controllers\Users\User;
class UsersApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
{
parent::__construct($container);
$this->UsersService = new UsersService();
}
protected $UsersService;
public function GetUsers(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function AddPermission(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse($this->UsersService->GetUsersAsDto());
User::checkPermission($request, User::PERMISSION_ADMIN);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$this->getDatabase()->user_permissions()->createRow([
'user_id' => $args['userId'],
'permission_id' => $requestBody['permission_id']
])->save();
return $this->EmptyApiResponse($response);
}
catch (\Slim\Exception\HttpSpecializedException $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage(), $ex->getCode());
}
catch (\Exception $ex)
{
@@ -26,9 +29,10 @@ class UsersApiController extends BaseApiController
}
}
public function CreateUser(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function CreateUser(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
User::checkPermission($request, User::PERMISSION_USERS_CREATE);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
@@ -37,7 +41,7 @@ class UsersApiController extends BaseApiController
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
$this->UsersService->CreateUser($requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
$this->getUsersService()->CreateUser($requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password'], $requestBody['picture_file_name']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -46,11 +50,12 @@ class UsersApiController extends BaseApiController
}
}
public function DeleteUser(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function DeleteUser(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_USERS_EDIT);
try
{
$this->UsersService->DeleteUser($args['userId']);
$this->getUsersService()->DeleteUser($args['userId']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -59,13 +64,22 @@ class UsersApiController extends BaseApiController
}
}
public function EditUser(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function EditUser(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
if ($args['userId'] == GROCY_USER_ID)
{
User::checkPermission($request, User::PERMISSION_USERS_EDIT_SELF);
}
else
{
User::checkPermission($request, User::PERMISSION_USERS_EDIT);
}
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
try
{
$this->UsersService->EditUser($args['userId'], $requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
$this->getUsersService()->EditUser($args['userId'], $requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password'], $requestBody['picture_file_name']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
@@ -74,12 +88,12 @@ class UsersApiController extends BaseApiController
}
}
public function GetUserSetting(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function GetUserSetting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$value = $this->UsersService->GetUserSetting(GROCY_USER_ID, $args['settingKey']);
return $this->ApiResponse(array('value' => $value));
$value = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, $args['settingKey']);
return $this->ApiResponse($response, ['value' => $value]);
}
catch (\Exception $ex)
{
@@ -87,13 +101,129 @@ class UsersApiController extends BaseApiController
}
}
public function SetUserSetting(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function GetUserSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse($response, $this->getUsersService()->GetUserSettings(GROCY_USER_ID));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function GetUsers(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_USERS_READ);
try
{
return $this->FilteredApiResponse($response, $this->getUsersService()->GetUsersAsDto(), $request->getQueryParams());
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function CurrentUser(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse($response, $this->getUsersService()->GetUsersAsDto()->where('id', GROCY_USER_ID));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ListPermissions(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
User::checkPermission($request, User::PERMISSION_ADMIN);
return $this->ApiResponse(
$response,
$this->getDatabase()->user_permissions()->where('user_id', $args['userId'])
);
}
catch (\Slim\Exception\HttpSpecializedException $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage(), $ex->getCode());
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function SetPermissions(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
User::checkPermission($request, User::PERMISSION_ADMIN);
$requestBody = $request->getParsedBody();
$db = $this->getDatabase();
$db->user_permissions()
->where('user_id', $args['userId'])
->delete();
$value = $this->UsersService->SetUserSetting(GROCY_USER_ID, $args['settingKey'], $requestBody['value']);
$perms = [];
if (GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
{
// For demo mode always all users have and keep the ADMIN permission
$perms[] = [
'user_id' => $args['userId'],
'permission_id' => 1
];
}
else
{
foreach ($requestBody['permissions'] as $perm_id)
{
$perms[] = [
'user_id' => $args['userId'],
'permission_id' => $perm_id
];
}
}
$db->insert('user_permissions', $perms, 'batch');
return $this->EmptyApiResponse($response);
}
catch (\Slim\Exception\HttpSpecializedException $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage(), $ex->getCode());
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function SetUserSetting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$value = $this->getUsersService()->SetUserSetting(GROCY_USER_ID, $args['settingKey'], $requestBody['value']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function DeleteUserSetting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$value = $this->getUsersService()->DeleteUserSetting(GROCY_USER_ID, $args['settingKey']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)

View File

@@ -2,29 +2,71 @@
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
class UsersController extends BaseController
{
public function UsersList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function PermissionList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'users', [
'users' => $this->Database->users()->orderBy('username')
User::checkPermission($request, User::PERMISSION_USERS_READ);
return $this->renderPage($response, 'userpermissions', [
'user' => $this->getDatabase()->users($args['userId']),
'permissions' => $this->getDatabase()->uihelper_user_permissions()
->where('parent IS NULL')->where('user_id', $args['userId'])
]);
}
public function UserEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function UserEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['userId'] == 'new')
{
return $this->AppContainer->view->render($response, 'userform', [
'mode' => 'create'
User::checkPermission($request, User::PERMISSION_USERS_CREATE);
return $this->renderPage($response, 'userform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('users')
]);
}
else
{
return $this->AppContainer->view->render($response, 'userform', [
'user' => $this->Database->users($args['userId']),
'mode' => 'edit'
if ($args['userId'] == GROCY_USER_ID)
{
User::checkPermission($request, User::PERMISSION_USERS_EDIT_SELF);
}
else
{
User::checkPermission($request, User::PERMISSION_USERS_EDIT);
}
return $this->renderPage($response, 'userform', [
'user' => $this->getDatabase()->users($args['userId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('users'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('users')
]);
}
}
public function UserSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'usersettings', [
'languages' => array_filter(scandir(__DIR__ . '/../localization'), function ($item) {
if ($item == '.' || $item == '..')
{
return false;
}
return is_dir(__DIR__ . '/../localization/' . $item);
})
]);
}
public function UsersList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
User::checkPermission($request, User::PERMISSION_USERS_READ);
return $this->renderPage($response, 'users', [
'users' => $this->getDatabase()->users()->orderBy('username'),
'userfields' => $this->getUserfieldsService()->GetFields('users'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('users')
]);
}
}

1
data/.htaccess Normal file
View File

@@ -0,0 +1 @@
Deny from all

View File

@@ -1,6 +1,6 @@
<?php
use \Grocy\Helpers\BaseBarcodeLookupPlugin;
use Grocy\Helpers\BaseBarcodeLookupPlugin;
/*
This class must extend BaseBarcodeLookupPlugin (in namespace \Grocy\Helpers)
@@ -14,7 +14,7 @@ class DemoBarcodeLookupPlugin extends BaseBarcodeLookupPlugin
/*
To try it:
Call the API function at /api/stock/external-barcode-lookup/{barcode}
Call the API function at /api/stock/barcodes/external-lookup/{barcode}
When you also add ?add=true as a query parameter to the API call,
on a successful lookup the product is added to the database and in the output
@@ -55,24 +55,24 @@ class DemoBarcodeLookupPlugin extends BaseBarcodeLookupPlugin
*/
protected function ExecuteLookup($barcode)
{
if ($barcode === 'x') // Demonstration when nothing is found
{
if ($barcode === 'x')
{ // Demonstration when nothing is found
return null;
}
elseif ($barcode === 'e') // Demonstration when an error occurred
{
elseif ($barcode === 'e')
{ // Demonstration when an error occurred
throw new \Exception('This is the error message from the plugin...');
}
else
{
return array(
return [
'name' => 'LookedUpProduct_' . RandomString(5),
'location_id' => $this->Locations[0]->id,
'qu_id_purchase' => $this->QuantityUnits[0]->id,
'qu_id_stock' => $this->QuantityUnits[0]->id,
'qu_factor_purchase_to_stock' => 1,
'barcode' => $barcode
);
];
}
}
}

66
docs/grocycode.md Normal file
View File

@@ -0,0 +1,66 @@
grocycode
==========
grocycode is, in essence, a simple way to reference to arbitrary grocy entities.
Each grocycode includes a magic, an entitiy identifier, an id and an ordered set of extra data.
It is supported to be entered anywhere grocy expects one to read a barcode, but can also reference
grocy-internal properties like specific stock entries, or specific batteries.
Serialization
----
There are three mandatory parts in a grocycode:
1. The magic `grcy`
2. An entity identifer matching the regular expression `[a-z]+` (that is, lowercase english alphabet without any fancy accents, minimum length 1 character).
3. An object identifer matching the regular expression `[0-9]+`
Optionally, any number of further data without format restrictions besides not containing any double colons [0] may be appended.
These parts are then linearly appended, seperated by a double colon `:`.
Entity Identifers
----
Currently, there are three different entity types defined:
- `p` for Products
- `b` for Batteries
- `c` for Chores
Example
----
In this example, we encode a *Product* with ID *13*, which results in `grcy:p:13` when serialized.
Product grocycodes
----
Product grocycodes extend the data format to include an optional stock id, thus may reference a specific stock entry directly.
Example: `grcy:p:13:60bf8b5244b04`
Battery grocycodes
----
Currently, Battery grocycodes do not define any extra fields.
Chore grocycodes
----
Currently, Chore grocycodes do not define any extra fields.
Visual Encoding
----
Grocy uses DataMatrix 2D (or alternatively Code128 1D) Barcodes to encode grocycodes into a visual representation. In principle, there is no problem with using
other encoding formats like QR codes; however DataMatrix uses less space for the same information and redundancy and is a bit
easier read by 2D barcode scanners, especially on non-flat surfaces.
You can pick up cheap-ish used scanners from ebay (about 45€ in germany). Make sure to set them to the correct keyboard emulation,
so that the double colons get entered correctly.
Notes
---
[0]: Obviously, it needs to be encoded into some usable visual representation and then read. So probably you only want to encode stuff that can be typed on a keyboard.

40
docs/label-printing.md Normal file
View File

@@ -0,0 +1,40 @@
Label printing
====
To enable label printing, set `FEATURE_FLAG_LABEL_PRINTER` to `true`in your `config.php`. You also need to provide a webhook target that is responsible for printing.
Why webhook?
---
Label printers come in all shapes and forms, and your particular one is probably not the one used by the author of this feature. Also, grocy may does not have a
direct connection to a local label printer (e.g. grocy is hosted in a cloud vps). Thus, a lightweight implementation is provided by grocy: whenever something
should print, a POST request to a configured URL is made. The target then is responsible for label printing.
Reference implementation
---
The webhook was developed and tested against a Brother QL-600 label printer, using endless 62mm label paper. The webhook provider implementation was
implemented into [a fork of brother_ql_web](https://github.com/mistressofjellyfish/brother_ql_web).
Webhook request
---
Requests can be configured to be sent server-side (that is, from the machine hosting grocy through GuzzleHttp) or by an AJAX request directly from the browser.
The latter is neccesary for situations where the grocy hosting machine cannot reach your label printer, however server-side requests are a bit faster and
tend to be more stable.
Both methods fire this request upon printing:
```
POST /your/printing/api/endpoint HTTP/1.1
product=<productname>&grocycode=grocy:x:xxx&due_date=DD:%2021-06-09&...
```
If specified, the request body may also be JSON encoded, however the fields stay the same.
Additional POST parameters (like the font to use) may be supplied in `config.php`. Keep in mind that these config values will be distributed to all clients on all requests
if the webhook is configured to run client-side.
The webhook receiver is required to layout and print the resulting label.

File diff suppressed because it is too large Load Diff

View File

@@ -11,9 +11,8 @@ abstract class BaseBarcodeLookupPlugin
}
protected $Locations;
protected $QuantityUnits;
abstract protected function ExecuteLookup($barcode);
protected $QuantityUnits;
final public function Lookup($barcode)
{
@@ -29,20 +28,22 @@ abstract class BaseBarcodeLookupPlugin
{
throw new \Exception('Plugin output must be an associative array');
}
if (!IsAssociativeArray($pluginOutput)) // $pluginOutput is at least an indexed array here
{
if (!IsAssociativeArray($pluginOutput))
{ // $pluginOutput is at least an indexed array here
throw new \Exception('Plugin output must be an associative array');
}
// Check for minimum needed properties
$minimunNeededProperties = array(
$minimunNeededProperties = [
'name',
'location_id',
'qu_id_purchase',
'qu_id_stock',
'qu_factor_purchase_to_stock',
'barcode'
);
];
foreach ($minimunNeededProperties as $prop)
{
if (!array_key_exists($prop, $pluginOutput))
@@ -59,16 +60,19 @@ abstract class BaseBarcodeLookupPlugin
{
throw new \Exception("Location $locationId is not a valid location id");
}
$quIdPurchase = $pluginOutput['qu_id_purchase'];
if (FindObjectInArrayByPropertyValue($this->QuantityUnits, 'id', $quIdPurchase) === null)
{
throw new \Exception("Location $quIdPurchase is not a valid quantity unit id");
}
$quIdStock = $pluginOutput['qu_id_stock'];
if (FindObjectInArrayByPropertyValue($this->QuantityUnits, 'id', $quIdStock) === null)
{
throw new \Exception("Location $quIdStock is not a valid quantity unit id");
}
$quFactor = $pluginOutput['qu_factor_purchase_to_stock'];
if (empty($quFactor) || !is_numeric($quFactor))
{
@@ -77,4 +81,6 @@ abstract class BaseBarcodeLookupPlugin
return $pluginOutput;
}
abstract protected function ExecuteLookup($barcode);
}

View File

@@ -0,0 +1,84 @@
<?php
class EInvalidConfig extends Exception
{
}
class ConfigurationValidator
{
public function validateConfig()
{
self::checkMode();
self::checkDefaultLocale();
self::checkCurrencyFormat();
self::checkFirstDayOfWeek();
self::checkEntryPage();
self::checkMealplanFirstDayOfWeek();
self::checkAutoNightModeRange();
}
private function checkMode()
{
$allowedModes = ['production', 'dev', 'demo', 'prerelease'];
if (!in_array(GROCY_MODE, $allowedModes))
{
throw new EInvalidConfig('Invalid mode "' . GROCY_MODE . '" set, only ' . implode(', ', $allowedModes) . ' allowed');
}
}
private function checkDefaultLocale()
{
if (!file_exists(__DIR__ . '/../localization/' . GROCY_DEFAULT_LOCALE))
{
throw new EInvalidConfig('Invalid locale "' . GROCY_DEFAULT_LOCALE . '" set, locale needs to exist in folder localization');
}
}
private function checkFirstDayOfWeek()
{
if (!(GROCY_CALENDAR_FIRST_DAY_OF_WEEK == '' ||
(is_numeric(GROCY_CALENDAR_FIRST_DAY_OF_WEEK) && GROCY_CALENDAR_FIRST_DAY_OF_WEEK >= 0 && GROCY_CALENDAR_FIRST_DAY_OF_WEEK <= 6)))
{
throw new EInvalidConfig('Invalid value for CALENDAR_FIRST_DAY_OF_WEEK');
}
}
private function checkCurrencyFormat()
{
if (!(preg_match('/^([A-z]){3}$/', GROCY_CURRENCY)))
{
throw new EInvalidConfig('CURRENCY is not in ISO 4217 format (three letter code)');
}
}
private function checkEntryPage()
{
$allowedPages = ['stock', 'shoppinglist', 'recipes', 'chores', 'tasks', 'batteries', 'equipment', 'calendar', 'mealplan'];
if (!in_array(GROCY_ENTRY_PAGE, $allowedPages))
{
throw new EInvalidConfig('Invalid entry page "' . GROCY_ENTRY_PAGE . '" set, only ' . implode(', ', $allowedPages) . ' allowed');
}
}
private function checkMealplanFirstDayOfWeek()
{
if (!(GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK == '' ||
(is_numeric(GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK) && GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK >= 0 && GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK <= 6)))
{
throw new EInvalidConfig('Invalid value for MEAL_PLAN_FIRST_DAY_OF_WEEK');
}
}
private function checkAutoNightModeRange()
{
global $GROCY_DEFAULT_USER_SETTINGS;
if (!(preg_match('/^(?:2[0-3]|[01][0-9]):[0-5][0-9]$/', $GROCY_DEFAULT_USER_SETTINGS['auto_night_mode_time_range_from'])))
{
throw new EInvalidConfig('auto_night_mode_time_range_from is not in HH:mm format (' . $GROCY_DEFAULT_USER_SETTINGS['auto_night_mode_time_range_from'] . ')');
}
if (!(preg_match('/^(?:2[0-3]|[01][0-9]):[0-5][0-9]$/', $GROCY_DEFAULT_USER_SETTINGS['auto_night_mode_time_range_to'])))
{
throw new EInvalidConfig('auto_night_mode_time_range_to is not in HH:mm format (' . $GROCY_DEFAULT_USER_SETTINGS['auto_night_mode_time_range_to'] . ')');
}
}
}

146
helpers/Grocycode.php Normal file
View File

@@ -0,0 +1,146 @@
<?php
namespace Grocy\Helpers;
/**
* A class that abstracts grocycode.
*
* grocycode is a simple, easily serializable format to reference
* stuff within grocy. It consists of n (n ≥ 3) double-colon seperated parts:
*
* 1. The magic `grcy`
* 2. A type identifer, must match `[a-z]+` (i.e. only lowercase ascii, minimum length 1 character)
* 3. An object id
* 4. Any number of further data fields, double-colon seperated.
*
* @author Katharina Bogad <katharina@hacked.xyz>
*/
class Grocycode
{
public const PRODUCT = 'p';
public const BATTERY = 'b';
public const CHORE = 'c';
public const MAGIC = 'grcy';
/**
* Constructs a new instance of the Grocycode class.
*
* Because php doesn't support overloading, this is a proxy
* to either setFromCode($code) or setFromData($type, $id, $extra_data = []).
*/
public function __construct(...$args)
{
$argc = count($args);
if ($argc == 1)
{
$this->setFromCode($args[0]);
return;
}
elseif ($argc == 2 || $argc == 3)
{
if ($argc == 2)
{
$args[] = [];
}
$this->setFromData($args[0], $args[1], $args[2]);
return;
}
throw new \Exception('No suitable overload found.');
}
/**
* An array that registers all valid grocycode types. Register yours here by appending to this array.
*/
public static $Items = [self::PRODUCT, self::BATTERY, self::CHORE];
private $type;
private $id;
private $extra_data = [];
/**
* Validates a grocycode.
*
* Returns true, if a supplied $code is a valid grocycode, false otherwise.
*
* @return bool
*/
public static function Validate(string $code)
{
try
{
$gc = new self($code);
return true;
}
catch (\Exception $e)
{
return false;
}
}
public function GetId()
{
return $this->id;
}
public function GetExtraData()
{
return $this->extra_data;
}
public function GetType()
{
return $this->type;
}
public function __toString(): string
{
$arr = array_merge([self::MAGIC, $this->type, $this->id], $this->extra_data);
return implode(':', $arr);
}
/**
* Parses a grocycode.
*/
private function setFromCode($code)
{
$parts = array_reverse(explode(':', $code));
if (array_pop($parts) != self::MAGIC)
{
throw new \Exception('Not a grocycode');
}
if (!in_array($this->type = array_pop($parts), self::$Items))
{
throw new \Exception('Unknown grocycode type');
}
$this->id = array_pop($parts);
$this->extra_data = array_reverse($parts);
}
/**
* Constructs a grocycode from data.
*/
private function setFromData($type, $id, $extra_data = [])
{
if (!is_array($extra_data))
{
throw new \Exception('Extra data must be array of string');
}
if (!in_array($type, self::$Items))
{
throw new \Exception('Unknown grocycode type');
}
$this->type = $type;
$this->id = $id;
$this->extra_data = $extra_data;
}
}

View File

@@ -0,0 +1,77 @@
<?php
class ERequirementNotMet extends Exception
{
}
const REQUIRED_PHP_EXTENSIONS = ['fileinfo', 'pdo_sqlite', 'gd', 'ctype', 'json', 'intl', 'zlib', 'mbstring',
// These are core extensions, so normally can't be missing, but seems to be the case, however, on FreeBSD
'filter', 'iconv', 'tokenizer'
];
const REQUIRED_SQLITE_VERSION = '3.9.0';
class PrerequisiteChecker
{
public function checkRequirements()
{
self::checkForConfigFile();
self::checkForConfigDistFile();
self::checkForComposer();
self::checkForPhpExtensions();
self::checkForSqliteVersion();
}
private function checkForComposer()
{
if (!file_exists(__DIR__ . '/../vendor/autoload.php'))
{
throw new ERequirementNotMet('/vendor/autoload.php not found. Have you run Composer?');
}
}
private function checkForConfigDistFile()
{
if (!file_exists(__DIR__ . '/../config-dist.php'))
{
throw new ERequirementNotMet('config-dist.php not found. Please do not remove this file.');
}
}
private function checkForConfigFile()
{
if (!file_exists(GROCY_DATAPATH . '/config.php'))
{
throw new ERequirementNotMet('config.php in data directory (' . GROCY_DATAPATH . ') not found. Have you copied config-dist.php to the data directory and renamed it to config.php?');
}
}
private function checkForPhpExtensions()
{
$loadedExtensions = get_loaded_extensions();
foreach (REQUIRED_PHP_EXTENSIONS as $extension)
{
if (!in_array($extension, $loadedExtensions))
{
throw new ERequirementNotMet("PHP module '{$extension}' not installed, but required.");
}
}
}
private function checkForSqliteVersion()
{
$sqliteVersion = self::getSqlVersionAsString();
if (version_compare($sqliteVersion, REQUIRED_SQLITE_VERSION, '<'))
{
throw new ERequirementNotMet('SQLite ' . REQUIRED_SQLITE_VERSION . ' is required, however you are running ' . $sqliteVersion);
}
}
private function getSqlVersionAsString()
{
$dbh = new PDO('sqlite::memory:');
return $dbh->query('select sqlite_version()')->fetch()[0];
}
}

View File

@@ -24,8 +24,8 @@ class UrlManager
{
return rtrim($this->BasePath, '/') . $relativePath;
}
else // Is not a resource and URL rewriting is disabled
{
else
{ // Is not a resource and URL rewriting is disabled
return rtrim($this->BasePath, '/') . '/index.php' . $relativePath;
}
}
@@ -37,6 +37,6 @@ class UrlManager
$_SERVER['HTTPS'] = 'on';
}
return (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
}
}

48
helpers/WebhookRunner.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace Grocy\Helpers;
use GuzzleHttp\Client;
use GuzzleHttp\ExceptionRequestException;
use Psr\Http\Message\ResponseInterface;
class WebhookRunner
{
public function __construct()
{
$this->client = new Client(['timeout' => 2.0]);
}
private $client;
public function run($url, $args, $json = false)
{
$reqArgs = [];
if ($json)
{
$reqArgs = ['json' => $args];
}
else
{
$reqArgs = ['form_params' => $args];
}
try
{
file_put_contents('php://stderr', 'Running Webhook: ' . $url . "\n" . print_r($reqArgs, true));
$this->client->request('POST', $url, $reqArgs);
}
catch (RequestException $e)
{
file_put_contents('php://stderr', 'Webhook failed: ' . $url . "\n" . $e->getMessage());
}
}
public function runAll($urls, $args)
{
foreach ($urls as $url)
{
$this->run($url, $args);
}
}
}

View File

@@ -2,9 +2,9 @@
function FindObjectInArrayByPropertyValue($array, $propertyName, $propertyValue)
{
foreach($array as $object)
foreach ($array as $object)
{
if($object->{$propertyName} == $propertyValue)
if ($object->{$propertyName} == $propertyValue)
{
return $object;
}
@@ -15,26 +15,26 @@ function FindObjectInArrayByPropertyValue($array, $propertyName, $propertyValue)
function FindAllObjectsInArrayByPropertyValue($array, $propertyName, $propertyValue, $operator = '==')
{
$returnArray = array();
foreach($array as $object)
$returnArray = [];
foreach ($array as $object)
{
switch($operator)
switch ($operator)
{
case '==':
if($object->{$propertyName} == $propertyValue)
if ($object->{$propertyName} == $propertyValue)
{
$returnArray[] = $object;
}
break;
case '>':
if($object->{$propertyName} > $propertyValue)
if ($object->{$propertyName} > $propertyValue)
{
$returnArray[] = $object;
}
break;
case '<':
if($object->{$propertyName} < $propertyValue)
if ($object->{$propertyName} < $propertyValue)
{
$returnArray[] = $object;
}
@@ -47,26 +47,28 @@ function FindAllObjectsInArrayByPropertyValue($array, $propertyName, $propertyVa
function FindAllItemsInArrayByValue($array, $value, $operator = '==')
{
$returnArray = array();
foreach($array as $item)
$returnArray = [];
foreach ($array as $item)
{
switch($operator)
switch ($operator)
{
case '==':
if($item == $value)
if ($item == $value)
{
$returnArray[] = $item;
}
break;
case '>':
if($item > $value)
if ($item > $value)
{
$returnArray[] = $item;
}
break;
case '<':
if($item < $value)
if ($item < $value)
{
$returnArray[] = $item;
}
@@ -80,9 +82,9 @@ function FindAllItemsInArrayByValue($array, $value, $operator = '==')
function SumArrayValue($array, $propertyName)
{
$sum = 0;
foreach($array as $object)
foreach ($array as $object)
{
$sum += $object->{$propertyName};
$sum += floatval($object->{$propertyName});
}
return $sum;
@@ -138,30 +140,43 @@ function BoolToString(bool $bool)
return $bool ? 'true' : 'false';
}
function BoolToInt(bool $bool)
{
return $bool ? 1 : 0;
}
function ExternalSettingValue(string $value)
{
$tvalue = rtrim($value, "\r\n");
$lvalue = strtolower($tvalue);
if ($lvalue === 'true')
{
return true;
}
elseif ($lvalue === 'false')
{
return false;
}
return $tvalue;
}
function Setting(string $name, $value)
{
if (!defined('GROCY_' . $name))
{
// The content of a $name.txt file in /data/settingoverrides can overwrite the given setting (for embedded mode)
$settingOverrideFile = GROCY_DATAPATH . '/settingoverrides/' . $name . '.txt';
if (file_exists($settingOverrideFile))
{
define('GROCY_' . $name, file_get_contents($settingOverrideFile));
define('GROCY_' . $name, ExternalSettingValue(file_get_contents($settingOverrideFile)));
}
elseif (getenv('GROCY_' . $name) !== false) // An environment variable with the same name and prefix GROCY_ overwrites the given setting
elseif (getenv('GROCY_' . $name) !== false)
{
if (strtolower(getenv('GROCY_' . $name)) === "true")
{
define('GROCY_' . $name, true);
}
elseif (strtolower(getenv('GROCY_' . $name)) === "false")
{
define('GROCY_' . $name, false);
}
else
{
define('GROCY_' . $name, getenv('GROCY_' . $name));
}
// An environment variable with the same name and prefix GROCY_ overwrites the given setting
define('GROCY_' . $name, ExternalSettingValue(getenv('GROCY_' . $name)));
}
else
{
@@ -171,10 +186,11 @@ function Setting(string $name, $value)
}
global $GROCY_DEFAULT_USER_SETTINGS;
$GROCY_DEFAULT_USER_SETTINGS = array();
$GROCY_DEFAULT_USER_SETTINGS = [];
function DefaultUserSetting(string $name, $value)
{
global $GROCY_DEFAULT_USER_SETTINGS;
if (!array_key_exists($name, $GROCY_DEFAULT_USER_SETTINGS))
{
$GROCY_DEFAULT_USER_SETTINGS[$name] = $value;
@@ -207,7 +223,7 @@ function GetUserDisplayName($user)
function IsValidFileName($fileName)
{
if(preg_match('=^[^/?*;:{}\\\\]+\.[^/?*;:{}\\\\]+$=', $fileName))
if (preg_match('=^[^/?*;:{}\\\\]+\.[^/?*;:{}\\\\]+$=', $fileName))
{
return true;
}
@@ -229,6 +245,7 @@ function string_starts_with($haystack, $needle)
function string_ends_with($haystack, $needle)
{
$length = strlen($needle);
if ($length == 0)
{
return true;

View File

@@ -26,3 +26,6 @@ msgstr ""
msgid "monthly"
msgstr ""
msgid "yearly"
msgstr ""

View File

@@ -0,0 +1,30 @@
#
# Translators:
# Radim Kabeláč <radim.ekk@gmail.com>, 2020
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-09-17 10:45+0000\n"
"Last-Translator: Radim Kabeláč <radim.ekk@gmail.com>, 2020\n"
"Language-Team: Czech (https://www.transifex.com/grocy/teams/93189/cs/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: cs\n"
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n <= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
"X-Domain: grocy/chore_assignment_types\n"
msgid "no-assignment"
msgstr "bez-přiřazení"
msgid "who-least-did-first"
msgstr "poslední-je-první"
msgid "random"
msgstr "náhodně"
msgid "in-alphabetical-order"
msgstr "řazení-podle-abecedy"

View File

@@ -0,0 +1,37 @@
#
# Translators:
# Tomas Reznicek <tomas.reznicek@gmail.com>, 2019
# Michal Petříček <michal@petricek.org>, 2019
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Michal Petříček <michal@petricek.org>, 2019\n"
"Language-Team: Czech (https://www.transifex.com/grocy/teams/93189/cs/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: cs\n"
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n <= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
"X-Domain: grocy/chore_types\n"
msgid "manually"
msgstr "Manuální"
msgid "dynamic-regular"
msgstr "Dynamický"
msgid "daily"
msgstr "Denní"
msgid "weekly"
msgstr "Týdně"
msgid "monthly"
msgstr "Měsíčně"
msgid "yearly"
msgstr "Ročně"

View File

@@ -0,0 +1,51 @@
#
# Translators:
# Tomas Reznicek <tomas.reznicek@gmail.com>, 2019
# Radim Kabeláč <radim.ekk@gmail.com>, 2020
# Bernd Bestel <bernd@berrnd.de>, 2020
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2020\n"
"Language-Team: Czech (https://www.transifex.com/grocy/teams/93189/cs/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: cs\n"
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n <= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
"X-Domain: grocy/component_translations\n"
msgid "timeago_locale"
msgstr "cs"
msgid "timeago_nan"
msgstr "před NaN lety"
msgid "moment_locale"
msgstr "cs"
msgid "datatables_localization"
msgstr ""
"{\"sEmptyTable\":\"Tabulka neobsahuje žádná data\",\"sInfo\":\"Zobrazuji "
"_START_ až _END_ z celkem _TOTAL_ záznamů\",\"sInfoEmpty\":\"Zobrazuji 0 až "
"0 z 0 záznamů\",\"sInfoFiltered\":\"(filtrováno z celkem _MAX_ "
"záznamů)\",\"sInfoPostFix\":\"\",\"sInfoThousands\":\" "
"\",\"sLengthMenu\":\"Zobraz záznamů "
"_MENU_\",\"sLoadingRecords\":\"Načítám...\",\"sProcessing\":\"Provádím...\",\"sSearch\":\"Hledat:\",\"sZeroRecords\":\"Žádné"
" záznamy nebyly "
"nalezeny\",\"oPaginate\":{\"sFirst\":\"První\",\"sLast\":\"Poslední\",\"sNext\":\"Další\",\"sPrevious\":\"Předchozí\"},\"oAria\":{\"sSortAscending\":\":"
" aktivujte pro řazení sloupce vzestupně\",\"sSortDescending\":\": aktivujte "
"pro řazení sloupce sestupně\"}}"
msgid "summernote_locale"
msgstr "cs-CZ"
msgid "fullcalendar_locale"
msgstr "cs"
msgid "bootstrap-select_locale"
msgstr "cs_CZ"

View File

@@ -0,0 +1,411 @@
#
# Translators:
# Michal Petříček <michal@petricek.org>, 2019
# Ondřej Suk <ondra.suk.55@gmail.com>, 2020
# Radim Kabeláč <radim.ekk@gmail.com>, 2020
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Radim Kabeláč <radim.ekk@gmail.com>, 2020\n"
"Language-Team: Czech (https://www.transifex.com/grocy/teams/93189/cs/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: cs\n"
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n <= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
"X-Domain: grocy/demo_data\n"
msgid "Cookies"
msgstr "Sušenky"
msgid "Chocolate"
msgstr "Čokoláda"
msgid "Pantry"
msgstr "Spíž"
msgid "Candy cupboard"
msgstr "Skříňka s cukrovím"
msgid "Tinned food cupboard"
msgstr "Skříňka s konzervami"
msgid "Fridge"
msgstr "Lednička"
msgid "Piece"
msgid_plural "Pieces"
msgstr[0] "Kus"
msgstr[1] "Kusů"
msgstr[2] "Kusů"
msgstr[3] "Kusů"
msgid "Pack"
msgid_plural "Packs"
msgstr[0] "Balení"
msgstr[1] "Balení"
msgstr[2] "Balení"
msgstr[3] "Balení"
msgid "Glass"
msgid_plural "Glasses"
msgstr[0] "Sklenice"
msgstr[1] "Sklenic"
msgstr[2] "Sklenic"
msgstr[3] "Sklenic"
msgid "Tin"
msgid_plural "Tins"
msgstr[0] "Plechovka"
msgstr[1] "Plechovek"
msgstr[2] "Plechovek"
msgstr[3] "Plechovek"
msgid "Can"
msgid_plural "Cans"
msgstr[0] "Konzerva"
msgstr[1] "Konzerv"
msgstr[2] "Konzerv"
msgstr[3] "Konzerv"
msgid "Bunch"
msgid_plural "Bunches"
msgstr[0] "Svazek"
msgstr[1] "Svazky"
msgstr[2] "Svazků"
msgstr[3] "Svazků"
msgid "Gummy bears"
msgstr "Gumoví medvídci"
msgid "Crisps"
msgstr "Brambůrky"
msgid "Eggs"
msgstr "Vajíčka"
msgid "Noodles"
msgstr "Nudle"
msgid "Pickles"
msgstr "Kyselé okurky"
msgid "Gulash soup"
msgstr "Gulášová polévka"
msgid "Yogurt"
msgstr "Jogurt"
msgid "Cheese"
msgstr "Sýr"
msgid "Cold cuts"
msgstr "Uzeniny"
msgid "Paprika"
msgstr "Paprika"
msgid "Cucumber"
msgstr "Okurka"
msgid "Radish"
msgstr "Ředkev"
msgid "Tomato"
msgstr "Rajče"
msgid "Changed towels in the bathroom"
msgstr "Vyměněny ručníky v koupeně"
msgid "Cleaned the kitchen floor"
msgstr "Vytřena podlaha v kuchyni"
msgid "Warranty ends"
msgstr "Záruka končí"
msgid "TV remote control"
msgstr "Dálkový ovladač k TV"
msgid "Alarm clock"
msgstr "Budík"
msgid "Heat remote control"
msgstr "Dálkové ovládání k topení"
msgid "Lawn mowed in the garden"
msgstr "Posekán trávník na zahradě"
msgid "Some good snacks"
msgstr "Nějaké dobroty"
msgid "Pizza dough"
msgstr "Těsto na pizzu"
msgid "Sieved tomatoes"
msgstr "Drcená rajčata"
msgid "Salami"
msgstr "Salám"
msgid "Toast"
msgstr "Toust"
msgid "Minced meat"
msgstr "Mleté maso"
msgid "Pizza"
msgstr "Pizza"
msgid "Spaghetti bolognese"
msgstr "Boloňské špagety"
msgid "Sandwiches"
msgstr "Sendviče"
msgid "English"
msgstr "Angličtina"
msgid "German"
msgstr "Němčina"
msgid "Italian"
msgstr "Italština"
msgid "This is the note content of the recipe ingredient"
msgstr "Toto je poznámka u suroviny receptu"
msgid "Demo User"
msgstr "Demo uživatel"
msgid "Gram"
msgid_plural "Grams"
msgstr[0] "Gram"
msgstr[1] "Gramů"
msgstr[2] "Gramů"
msgstr[3] "Gramů"
msgid "Flour"
msgstr "Mouka"
msgid "Pancakes"
msgstr "Palačinky"
msgid "Sugar"
msgstr "Cukr"
msgid "Home"
msgstr "Domov"
msgid "Life"
msgstr "Život"
msgid "Projects"
msgstr "Projekty"
msgid "Repair the garage door"
msgstr "Opravit garážová vrata"
msgid "Fork and improve grocy"
msgstr "Forknout a vylepšit grocy"
msgid "Find a solution for what to do when I forget the door keys"
msgstr "Najít řešení situace, když si zapomenu klíče od domova"
msgid "Sweets"
msgstr "Sladkosti"
msgid "Bakery products"
msgstr "Pečivo"
msgid "Tinned food"
msgstr "Konzervované potraviny"
msgid "Butchery products"
msgstr "Maso a uzeniny"
msgid "Vegetables/Fruits"
msgstr "Ovoce a zelenina"
msgid "Refrigerated products"
msgstr "Chlazené potraviny"
msgid "Coffee machine"
msgstr "Kávovar"
msgid "Dishwasher"
msgstr "Myčka nádobí"
msgid "Liter"
msgstr "Litr"
msgid "Liters"
msgstr "Litry"
msgid "Bottle"
msgstr "Láhev"
msgid "Bottles"
msgstr "Láhve"
msgid "Milk"
msgstr "Mléko"
msgid "Chocolate sauce"
msgstr "Čokoládová poleva"
msgid "Milliliters"
msgstr "Mililitry"
msgid "Milliliter"
msgstr "Mililitr"
msgid "Bottom"
msgstr "Dno"
msgid "Topping"
msgstr "Poleva"
msgid "French"
msgstr "Francouzština"
msgid "Turkish"
msgstr "Turečtina"
msgid "Spanish"
msgstr "Španělština"
msgid "Russian"
msgstr "Ruština"
msgid "The thing which happens on the 5th of every month"
msgstr "Událost opakující se 5. den každý měsíc"
msgid "The thing which happens daily"
msgstr "Událost opakující se každý den"
msgid "The thing which happens on Mondays and Wednesdays"
msgstr "Událost opakující se každé pondělí a středu"
msgid "Swedish"
msgstr "Švédština"
msgid "Polish"
msgstr "Polština"
msgid "Milk Chocolate"
msgstr "Mléčná čokoláda"
msgid "Dark Chocolate"
msgstr "Hořká čokoláda"
msgid "Slice"
msgid_plural "Slices"
msgstr[0] "Plátek"
msgstr[1] "Plátky"
msgstr[2] "Plátky"
msgstr[3] "Plátky"
msgid "Example userentity"
msgstr "Příklad uživatelské entity"
msgid "This is an example user entity..."
msgstr "Toto je ukázková položka uživatelské entity"
msgid "Custom field"
msgstr "Vlastní pole"
msgid "Example field value..."
msgstr "Příklad hodnoty pole..."
msgid "Waffle rolls"
msgstr "Oplatky"
msgid "Danish"
msgstr "Dánština"
msgid "Dutch"
msgstr "Holandština"
msgid "Norwegian"
msgstr "Norština"
msgid "Demo"
msgstr "Demo"
msgid "Stable version"
msgstr "Stabilní verze"
msgid "Preview version"
msgstr "Preview verze"
msgid "current release"
msgstr "aktuální vydání"
msgid "not yet released"
msgstr "zatím nevydáno"
msgid "Portuguese (Brazil)"
msgstr "Portugalština (Brazílie)"
msgid "This is a note"
msgstr "Toto je poznámka"
msgid "Freezer"
msgstr "Mrazák"
msgid "Hungarian"
msgstr "Maďarština"
msgid "Slovak"
msgstr "Slovenština"
msgid "Czech"
msgstr "Čeština"
msgid "Portuguese (Portugal)"
msgstr "Portugalština (Portugalsko)"
# Use a in your country well known supermarket name
msgid "DemoSupermarket1"
msgstr "UkazkovyObchod1"
# Use a in your country well known supermarket name
msgid "DemoSupermarket2"
msgstr "UkazkovyObchod2"
msgid "Japanese"
msgstr "Japonština"
msgid "Chinese (Taiwan)"
msgstr "Čínština (Tchaj-wan)"
msgid "Greek"
msgstr "Řečtina"
msgid "Korean"
msgstr "Korejština"
msgid "Chinese (China)"
msgstr "Čínština (Čína)"
msgid "Hebrew (Israel)"
msgstr "Hebrejsky (Izraeil)"
msgid "Tamil"
msgstr ""
msgid "Finnish"
msgstr "Finsky"
msgid "Breakfast"
msgstr ""
msgid "Lunch"
msgstr ""
msgid "Dinner"
msgstr ""

123
localization/cs/locales.po Normal file
View File

@@ -0,0 +1,123 @@
#
# Translators:
# Radim Kabeláč <radim.ekk@gmail.com>, 2020
# Jarda Tesar <intossh@gmail.com>, 2021
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2020-08-31 19:11+0000\n"
"Last-Translator: Jarda Tesar <intossh@gmail.com>, 2021\n"
"Language-Team: Czech (https://www.transifex.com/grocy/teams/93189/cs/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: cs\n"
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n <= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
"X-Domain: grocy/locales\n"
# Czech
msgid "cs"
msgstr "Čeština"
# Danish
msgid "da"
msgstr "Dánština"
# German
msgid "de"
msgstr "Němčina"
# Greek
msgid "el_GR"
msgstr "Řečtina"
# English
msgid "en"
msgstr "Angličtina"
# English (Great Britain)
msgid "en_GB"
msgstr "Angličtina (Britská)"
# Spanish
msgid "es"
msgstr "Španělština"
# French
msgid "fr"
msgstr "Francouzština"
# Hungarian
msgid "hu"
msgstr "Maďarština"
# Italian
msgid "it"
msgstr "Italština"
# Japanese
msgid "ja"
msgstr "Japonština"
# Korean
msgid "ko_KR"
msgstr "Korejština"
# Dutch
msgid "nl"
msgstr "Nizozemština"
# Norwegian
msgid "no"
msgstr "Norština"
# Polish
msgid "pl"
msgstr "Polština"
# Portuguese (Brazil)
msgid "pt_BR"
msgstr "Portugalština (Brazílie)"
# Portuguese (Portugal)
msgid "pt_PT"
msgstr "Portugalština (Portugalsko)"
# Russian
msgid "ru"
msgstr "Ruština"
# Slovak
msgid "sk_SK"
msgstr "Slovenština"
# Swedish
msgid "sv_SE"
msgstr "Švédština"
# Turkish
msgid "tr"
msgstr "Turečtina"
# Chinese (Taiwan)
msgid "zh_TW"
msgstr "Čínština (Tradiční)"
# Chinese (China)
msgid "zh_CN"
msgstr "Čínština (Zjednodušená)"
# Hebrew (Israel)
msgid "he_IL"
msgstr "Hebrejština"
# Tamil
msgid "ta"
msgstr "Tamilština"
# Finnish
msgid "fi"
msgstr "Finština"

View File

@@ -0,0 +1,139 @@
#
# Translators:
# Radim Kabeláč <radim.ekk@gmail.com>, 2020
# Jarda Tesar <intossh@gmail.com>, 2021
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2020-08-29 16:33+0000\n"
"Last-Translator: Jarda Tesar <intossh@gmail.com>, 2021\n"
"Language-Team: Czech (https://www.transifex.com/grocy/teams/93189/cs/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: cs\n"
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n <= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
"X-Domain: grocy/permissions\n"
# All permissions
msgid "ADMIN"
msgstr "ADMINISTRATOR"
# Create users
msgid "USERS_CREATE"
msgstr "UZIVATELE_VYTVORIT"
# Edit users (including passwords)
msgid "USERS_EDIT"
msgstr "UZIVATELE_EDITACE"
# Show users
msgid "USERS_READ"
msgstr "UZIVATEL_CTENI"
# Edit own user data / change own password
msgid "USERS_EDIT_SELF"
msgstr "UZIVATELE_EDITOVAT_SEBE"
# Undo charge cycle
msgid "BATTERIES_UNDO_CHARGE_CYCLE"
msgstr "BATERIE_VRACENI_NABIJECI_CYKLUS"
# Track charge cycle
msgid "BATTERIES_TRACK_CHARGE_CYCLE"
msgstr "BATERIE_SLEDOVANI_NABIJECI_CYKLUS"
# Track execution
msgid "CHORE_TRACK_EXECUTION"
msgstr "POVINNOST_SLEDOVANI_VYKONANI"
# Undo execution
msgid "CHORE_UNDO_EXECUTION"
msgstr "POVINNOST_VYKONANI_VRACENI"
# Edit master data
msgid "MASTER_DATA_EDIT"
msgstr "ZAKLADNI_DATA_EDIT"
# Undo execution
msgid "TASKS_UNDO_EXECUTION"
msgstr "UKOL_VYKONANI_VRACENI"
# Mark completed
msgid "TASKS_MARK_COMPLETED"
msgstr "UKOLY_OZNACIT_HOTOVO"
# Edit stock entries
msgid "STOCK_EDIT"
msgstr "ZASOBY_EDITACE"
# Transfer
msgid "STOCK_TRANSFER"
msgstr "PREVOD_ZASOB"
# Inventory
msgid "STOCK_INVENTORY"
msgstr "ZASOBA_INVENTAR"
# Consume
msgid "STOCK_CONSUME"
msgstr "ZASOBY_SPOTREBOVAT"
# Open products
msgid "STOCK_OPEN"
msgstr "ZASOBY_OTEVRIT"
# Purchase
msgid "STOCK_PURCHASE"
msgstr "ZASOBA_NAKUP"
# Add items
msgid "SHOPPINGLIST_ITEMS_ADD"
msgstr "NAKUPNISEZNAM_POLOZKA_PRIDANO"
# Remove items
msgid "SHOPPINGLIST_ITEMS_DELETE"
msgstr "NAKUPNISEZNAM_POLOZKA_SMAZANO"
# User management
msgid "USERS"
msgstr "UZIVATEL"
# Stock
msgid "STOCK"
msgstr "ZASOBA"
# Shopping list
msgid "SHOPPINGLIST"
msgstr "NAKUPNISEZNAM"
# Chores
msgid "CHORES"
msgstr "POVINOSTI"
# Batteries
msgid "BATTERIES"
msgstr "BATERIE"
# Tasks
msgid "TASKS"
msgstr "UKOL"
# Recipes
msgid "RECIPES"
msgstr "RECEPTY"
# Equipment
msgid "EQUIPMENT"
msgstr "VYBAVENI"
# Calendar
msgid "CALENDAR"
msgstr "KALENDAR"
# Meal plan
msgid "RECIPES_MEALPLAN"
msgstr "RECEPTY_STRAVOVACIPLANY"

View File

@@ -0,0 +1,48 @@
#
# Translators:
# Tomas Reznicek <tomas.reznicek@gmail.com>, 2019
# Michal Franc, 2020
# Ondřej Suk <ondra.suk.55@gmail.com>, 2020
# Radim Kabeláč <radim.ekk@gmail.com>, 2020
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Radim Kabeláč <radim.ekk@gmail.com>, 2020\n"
"Language-Team: Czech (https://www.transifex.com/grocy/teams/93189/cs/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: cs\n"
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n <= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
"X-Domain: grocy/stock_transaction_types\n"
msgid "purchase"
msgstr "Nákup"
msgid "transfer_from"
msgstr "Převod z"
msgid "transfer_to"
msgstr "Převod do"
msgid "consume"
msgstr "Spotřeba"
msgid "inventory-correction"
msgstr "Úprava zásoby"
msgid "product-opened"
msgstr "Otevření balení"
msgid "stock-edit-old"
msgstr "zasoba-editace-stary"
msgid "stock-edit-new"
msgstr "zasoba-editace-novy"
msgid "self-production"
msgstr "vlastni-produkce"

2505
localization/cs/strings.po Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,72 @@
#
# Translators:
# Tomas Reznicek <tomas.reznicek@gmail.com>, 2019
# Michal Franc, 2020
# Radim Kabeláč <radim.ekk@gmail.com>, 2020
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:43+0000\n"
"Last-Translator: Radim Kabeláč <radim.ekk@gmail.com>, 2020\n"
"Language-Team: Czech (https://www.transifex.com/grocy/teams/93189/cs/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: cs\n"
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n <= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
"X-Domain: grocy/userfield_types\n"
# Text (single line)
msgid "text-single-line"
msgstr "Text (jeden řádek)"
# Text (multi line)
msgid "text-multi-line"
msgstr "Text (více řádků)"
# Number (integral)
msgid "number-integral"
msgstr "Celé číslo"
# Number (decimal)
msgid "number-decimal"
msgstr "Číslo s desetinami"
# Date (without time)
msgid "date"
msgstr "Datum"
# Date & time
msgid "datetime"
msgstr "Datum a čas"
# Checkbox
msgid "checkbox"
msgstr "Zaškrtávací políčko"
# Select list (a single item can be selected)
msgid "preset-list"
msgstr "Seznam"
# Select list (multiple items can be selected)
msgid "preset-checklist"
msgstr "Zaškrtávací seznam"
# Link
msgid "link"
msgstr "Odkaz"
# Link (with title)
msgid "link-with-title"
msgstr ""
# File
msgid "file"
msgstr "soubor"
# Image
msgid "image"
msgstr "obrazek"

View File

@@ -1,5 +1,7 @@
#
# Translators:
# Troels Siggaard <troels@siggaard.com>, 2019
# klavslund <klavslund@gmail.com>, 2021
#
msgid ""
msgstr ""
@@ -7,7 +9,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-09-17 10:45+0000\n"
"Last-Translator: Troels Siggaard <troels@siggaard.com>, 2019\n"
"Last-Translator: klavslund <klavslund@gmail.com>, 2021\n"
"Language-Team: Danish (https://www.transifex.com/grocy/teams/93189/da/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -20,7 +22,7 @@ msgid "no-assignment"
msgstr "ingen-tildeling"
msgid "who-least-did-first"
msgstr "hvem-mindst-gjorde-først"
msgstr "hvem-gjorde-mindst-først"
msgid "random"
msgstr "tilfældig"

View File

@@ -1,5 +1,8 @@
#
# Translators:
# Troels Siggaard <troels@siggaard.com>, 2019
# Rasmus Bojsen <rasmus@bojsen.cn>, 2019
# Brian Moos Lindberg <brian@blueeel.dk>, 2019
#
msgid ""
msgstr ""
@@ -7,7 +10,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Troels Siggaard <troels@siggaard.com>, 2019\n"
"Last-Translator: Brian Moos Lindberg <brian@blueeel.dk>, 2019\n"
"Language-Team: Danish (https://www.transifex.com/grocy/teams/93189/da/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -20,7 +23,7 @@ msgid "manually"
msgstr "manuelt"
msgid "dynamic-regular"
msgstr "gentagende-dynamisk"
msgstr "dynamisk-regelmæssig"
msgid "daily"
msgstr "daglig"
@@ -30,3 +33,6 @@ msgstr "ugentlig"
msgid "monthly"
msgstr "månedlig"
msgid "yearly"
msgstr "årlig"

View File

@@ -1,3 +1,4 @@
#
# Translators:
# Bernd Bestel <bernd@berrnd.de>, 2019
#

View File

@@ -1,6 +1,11 @@
#
# Translators:
# dark159123 <r.j.hansen@protonmail.com>, 2019
# Troels Siggaard <troels@siggaard.com>, 2019
# Rasmus Bojsen <rasmus@bojsen.cn>, 2019
# Brian Moos Lindberg <brian@blueeel.dk>, 2019
# Mihai Marinescu <mihai@marinescu.dk>, 2020
# klavslund <klavslund@gmail.com>, 2021
#
msgid ""
msgstr ""
@@ -8,7 +13,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Troels Siggaard <troels@siggaard.com>, 2019\n"
"Last-Translator: klavslund <klavslund@gmail.com>, 2021\n"
"Language-Team: Danish (https://www.transifex.com/grocy/teams/93189/da/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -37,8 +42,8 @@ msgstr "Køleskab"
msgid "Piece"
msgid_plural "Pieces"
msgstr[0] "Styk"
msgstr[1] "Stykker"
msgstr[0] "stk"
msgstr[1] "stk"
msgid "Pack"
msgid_plural "Packs"
@@ -81,7 +86,7 @@ msgid "Pickles"
msgstr "Syltede agurker"
msgid "Gulash soup"
msgstr "Gulash"
msgstr "Gullashsuppe"
msgid "Yogurt"
msgstr "Yoghurt"
@@ -161,14 +166,11 @@ msgstr "Tysk"
msgid "Italian"
msgstr "Italiensk"
msgid "Demo in different language"
msgstr "Demo på et andet sprog"
msgid "This is the note content of the recipe ingredient"
msgstr "Dette er indholdet af opskrift-ingrediensens notefeltet"
msgid "Demo User"
msgstr "Demo Bruger"
msgstr "Demo bruger"
msgid "Gram"
msgid_plural "Grams"
@@ -218,7 +220,7 @@ msgid "Vegetables/Fruits"
msgstr "Frugt og grønt"
msgid "Refrigerated products"
msgstr "Køleskabsprodukter"
msgstr "Køleskabsvarer"
msgid "Coffee machine"
msgstr "Kaffemaskine"
@@ -284,27 +286,113 @@ msgid "Polish"
msgstr "Polsk"
msgid "Milk Chocolate"
msgstr ""
msgstr "Mælkechokolade"
msgid "Dark Chocolate"
msgstr ""
msgstr "Mørk chokolade"
msgid "Slice"
msgid_plural "Slices"
msgstr[0] ""
msgstr[1] ""
msgstr[0] "Skive"
msgstr[1] "Skiver"
msgid "Example userentity"
msgstr ""
msgstr "Eksempel-brugerenhed"
msgid "This is an example user entity..."
msgstr ""
msgstr "Dette er en eksempel-brugerenhed..."
msgid "Custom field"
msgstr ""
msgstr "Brugerdefineret felt"
msgid "Example field value..."
msgstr ""
msgstr "Eksempel-feltværdi..."
msgid "Waffle rolls"
msgstr "Vaffelruller"
msgid "Danish"
msgstr "Dansk"
msgid "Dutch"
msgstr "Hollandsk"
msgid "Norwegian"
msgstr "Norsk"
msgid "Demo"
msgstr "Demo"
msgid "Stable version"
msgstr "Stabil version"
msgid "Preview version"
msgstr "Forhåndsvisningsversion"
msgid "current release"
msgstr "aktuel udgivelse"
msgid "not yet released"
msgstr "Ikke frigivet endnu"
msgid "Portuguese (Brazil)"
msgstr "Portugisisk (Brasilien)"
msgid "This is a note"
msgstr "Denne er en note"
msgid "Freezer"
msgstr "Fryser"
msgid "Hungarian"
msgstr "Ungarsk"
msgid "Slovak"
msgstr "Slovakisk"
msgid "Czech"
msgstr "Tjekkisk"
msgid "Portuguese (Portugal)"
msgstr "Portugisisk (Portugal)"
# Use a in your country well known supermarket name
msgid "DemoSupermarket1"
msgstr "Netto"
# Use a in your country well known supermarket name
msgid "DemoSupermarket2"
msgstr "Fakta"
msgid "Japanese"
msgstr "Japansk"
msgid "Chinese (Taiwan)"
msgstr "Kinesisk (Taiwan)"
msgid "Greek"
msgstr "Græsk"
msgid "Korean"
msgstr "Koreansk"
msgid "Chinese (China)"
msgstr "Kinesisk"
msgid "Hebrew (Israel)"
msgstr "Hebraisk"
msgid "Tamil"
msgstr "Tamilsk"
msgid "Finnish"
msgstr "Finsk"
msgid "Breakfast"
msgstr ""
msgid "Lunch"
msgstr ""
msgid "Dinner"
msgstr ""

122
localization/da/locales.po Normal file
View File

@@ -0,0 +1,122 @@
#
# Translators:
# klavslund <klavslund@gmail.com>, 2021
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2020-08-31 19:11+0000\n"
"Last-Translator: klavslund <klavslund@gmail.com>, 2021\n"
"Language-Team: Danish (https://www.transifex.com/grocy/teams/93189/da/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: da\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Domain: grocy/locales\n"
# Czech
msgid "cs"
msgstr "cs"
# Danish
msgid "da"
msgstr "da"
# German
msgid "de"
msgstr "de"
# Greek
msgid "el_GR"
msgstr "el_GR"
# English
msgid "en"
msgstr "en"
# English (Great Britain)
msgid "en_GB"
msgstr "en_GB"
# Spanish
msgid "es"
msgstr "es"
# French
msgid "fr"
msgstr "fr"
# Hungarian
msgid "hu"
msgstr "hu"
# Italian
msgid "it"
msgstr "it"
# Japanese
msgid "ja"
msgstr "ja"
# Korean
msgid "ko_KR"
msgstr "ko_KR"
# Dutch
msgid "nl"
msgstr "nl"
# Norwegian
msgid "no"
msgstr "no"
# Polish
msgid "pl"
msgstr "pl"
# Portuguese (Brazil)
msgid "pt_BR"
msgstr "pt_BR"
# Portuguese (Portugal)
msgid "pt_PT"
msgstr "pt_PT"
# Russian
msgid "ru"
msgstr "ru"
# Slovak
msgid "sk_SK"
msgstr "sk_SK"
# Swedish
msgid "sv_SE"
msgstr "sv_SE"
# Turkish
msgid "tr"
msgstr "tr"
# Chinese (Taiwan)
msgid "zh_TW"
msgstr "zh_TW"
# Chinese (China)
msgid "zh_CN"
msgstr "zh_CN"
# Hebrew (Israel)
msgid "he_IL"
msgstr "he_IL"
# Tamil
msgid "ta"
msgstr "ta"
# Finnish
msgid "fi"
msgstr "fi"

View File

@@ -0,0 +1,139 @@
#
# Translators:
# Mihai Marinescu <mihai@marinescu.dk>, 2020
# klavslund <klavslund@gmail.com>, 2021
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2020-08-29 16:33+0000\n"
"Last-Translator: klavslund <klavslund@gmail.com>, 2021\n"
"Language-Team: Danish (https://www.transifex.com/grocy/teams/93189/da/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: da\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Domain: grocy/permissions\n"
# All permissions
msgid "ADMIN"
msgstr "ADMIN"
# Create users
msgid "USERS_CREATE"
msgstr "USERS_CREATE"
# Edit users (including passwords)
msgid "USERS_EDIT"
msgstr "USERS_EDIT"
# Show users
msgid "USERS_READ"
msgstr "USERS_READ"
# Edit own user data / change own password
msgid "USERS_EDIT_SELF"
msgstr "USERS_EDIT_SELF"
# Undo charge cycle
msgid "BATTERIES_UNDO_CHARGE_CYCLE"
msgstr "BATTERIES_UNDO_CHARGE_CYCLE"
# Track charge cycle
msgid "BATTERIES_TRACK_CHARGE_CYCLE"
msgstr "BATTERIES_TRACK_CHARGE_CYCLE"
# Track execution
msgid "CHORE_TRACK_EXECUTION"
msgstr "CHORE_TRACK_EXECUTION"
# Undo execution
msgid "CHORE_UNDO_EXECUTION"
msgstr "CHORE_UNDO_EXECUTION"
# Edit master data
msgid "MASTER_DATA_EDIT"
msgstr "MASTER_DATA_EDIT"
# Undo execution
msgid "TASKS_UNDO_EXECUTION"
msgstr "TASKS_UNDO_EXECUTION"
# Mark completed
msgid "TASKS_MARK_COMPLETED"
msgstr "TASKS_MARK_COMPLETED"
# Edit stock entries
msgid "STOCK_EDIT"
msgstr "STOCK_EDIT"
# Transfer
msgid "STOCK_TRANSFER"
msgstr "STOCK_TRANSFER"
# Inventory
msgid "STOCK_INVENTORY"
msgstr "STOCK_INVENTORY"
# Consume
msgid "STOCK_CONSUME"
msgstr "STOCK_CONSUME"
# Open products
msgid "STOCK_OPEN"
msgstr "STOCK_OPEN"
# Purchase
msgid "STOCK_PURCHASE"
msgstr "STOCK_PURCHASE"
# Add items
msgid "SHOPPINGLIST_ITEMS_ADD"
msgstr "SHOPPINGLIST_ITEMS_ADD"
# Remove items
msgid "SHOPPINGLIST_ITEMS_DELETE"
msgstr "SHOPPINGLIST_ITEMS_DELETE"
# User management
msgid "USERS"
msgstr "BRUGERE"
# Stock
msgid "STOCK"
msgstr "BEHOLDNING"
# Shopping list
msgid "SHOPPINGLIST"
msgstr "INDKØBSLISTE"
# Chores
msgid "CHORES"
msgstr "GØREMÅL"
# Batteries
msgid "BATTERIES"
msgstr "BATTERIER"
# Tasks
msgid "TASKS"
msgstr "OPGAVER"
# Recipes
msgid "RECIPES"
msgstr "OPSKRIFTER"
# Equipment
msgid "EQUIPMENT"
msgstr "UDSTYR"
# Calendar
msgid "CALENDAR"
msgstr "KALENDER"
# Meal plan
msgid "RECIPES_MEALPLAN"
msgstr "RECIPES_MEALPLAN"

View File

@@ -1,5 +1,8 @@
#
# Translators:
# Troels Siggaard <troels@siggaard.com>, 2019
# Brian Moos Lindberg <brian@blueeel.dk>, 2019
# Mihai Marinescu <mihai@marinescu.dk>, 2020
#
msgid ""
msgstr ""
@@ -7,7 +10,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Troels Siggaard <troels@siggaard.com>, 2019\n"
"Last-Translator: Mihai Marinescu <mihai@marinescu.dk>, 2020\n"
"Language-Team: Danish (https://www.transifex.com/grocy/teams/93189/da/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -19,6 +22,12 @@ msgstr ""
msgid "purchase"
msgstr "køb"
msgid "transfer_from"
msgstr "flyt_fra"
msgid "transfer_to"
msgstr "flyt_til"
msgid "consume"
msgstr "forbrug"
@@ -27,3 +36,12 @@ msgstr "beholdningsrettelse"
msgid "product-opened"
msgstr "produkt-åbnet"
msgid "stock-edit-old"
msgstr "lager-redigering-gammel"
msgid "stock-edit-new"
msgstr "lager-redigering-ny"
msgid "self-production"
msgstr "selvproduktion"

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,16 @@
#
# Translators:
# Brian Moos Lindberg <brian@blueeel.dk>, 2019
# Mihai Marinescu <mihai@marinescu.dk>, 2020
# klavslund <klavslund@gmail.com>, 2021
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:43+0000\n"
"Last-Translator: klavslund <klavslund@gmail.com>, 2021\n"
"Language-Team: Danish (https://www.transifex.com/grocy/teams/93189/da/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -13,23 +19,54 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Domain: grocy/userfield_types\n"
# Text (single line)
msgid "text-single-line"
msgstr ""
msgstr "tekst-enkelt-linje"
# Text (multi line)
msgid "text-multi-line"
msgstr ""
msgstr "tekst-flere-linjer"
# Number (integral)
msgid "number-integral"
msgstr ""
msgstr "tal-heltal"
# Number (decimal)
msgid "number-decimal"
msgstr ""
msgstr "tal-decimal"
# Date (without time)
msgid "date"
msgstr ""
msgstr "dato"
# Date & time
msgid "datetime"
msgstr ""
msgstr "datotid"
# Checkbox
msgid "checkbox"
msgstr ""
msgstr "afkrydsningsfelt"
# Select list (a single item can be selected)
msgid "preset-list"
msgstr "forudindstillet-liste"
# Select list (multiple items can be selected)
msgid "preset-checklist"
msgstr "forudindstillet-tjekliste"
# Link
msgid "link"
msgstr "link"
# Link (with title)
msgid "link-with-title"
msgstr "link-med-overskrift"
# File
msgid "file"
msgstr "fil"
# Image
msgid "image"
msgstr "billede"

View File

@@ -1,5 +1,6 @@
#
# Translators:
# Bernd Bestel <bernd@berrnd.de>, 2019
# Bernd Bestel <bernd@berrnd.de>, 2021
#
msgid ""
msgstr ""
@@ -7,7 +8,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-09-17 10:45+0000\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2019\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2021\n"
"Language-Team: German (https://www.transifex.com/grocy/teams/93189/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"

View File

@@ -1,5 +1,6 @@
#
# Translators:
# Bernd Bestel <bernd@berrnd.de>, 2019
# Bernd Bestel <bernd@berrnd.de>, 2021
#
msgid ""
msgstr ""
@@ -7,7 +8,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2019\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2021\n"
"Language-Team: German (https://www.transifex.com/grocy/teams/93189/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -30,3 +31,6 @@ msgstr "Wöchentlich"
msgid "monthly"
msgstr "Monatlich"
msgid "yearly"
msgstr "Jährlich"

View File

@@ -1,3 +1,4 @@
#
# Translators:
# Bernd Bestel <bernd@berrnd.de>, 2019
#

View File

@@ -1,5 +1,6 @@
#
# Translators:
# Bernd Bestel <bernd@berrnd.de>, 2019
# Bernd Bestel <bernd@berrnd.de>, 2021
#
msgid ""
msgstr ""
@@ -7,7 +8,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2019\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2021\n"
"Language-Team: German (https://www.transifex.com/grocy/teams/93189/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -160,9 +161,6 @@ msgstr "Deutsch"
msgid "Italian"
msgstr "Italienisch"
msgid "Demo in different language"
msgstr "Demo in anderer Sprache"
msgid "This is the note content of the recipe ingredient"
msgstr "Dies ist der Inhalt der Notiz der Zutat"
@@ -313,3 +311,83 @@ msgstr "Dänisch"
msgid "Dutch"
msgstr "Niederländisch"
msgid "Norwegian"
msgstr "Norwegisch"
msgid "Demo"
msgstr "Demo"
msgid "Stable version"
msgstr "Stabile Version"
msgid "Preview version"
msgstr "Vorschauversion"
msgid "current release"
msgstr "aktuelles Release"
msgid "not yet released"
msgstr "noch nicht freigegeben"
msgid "Portuguese (Brazil)"
msgstr "Portugiesisch (Brasilien)"
msgid "This is a note"
msgstr "Dies ist eine Notiz"
msgid "Freezer"
msgstr "Gefrierschrank"
msgid "Hungarian"
msgstr "Ungarisch"
msgid "Slovak"
msgstr "Slowakisch"
msgid "Czech"
msgstr "Tschechisch"
msgid "Portuguese (Portugal)"
msgstr "Portugiesisch (Portugal)"
# Use a in your country well known supermarket name
msgid "DemoSupermarket1"
msgstr "Aldi"
# Use a in your country well known supermarket name
msgid "DemoSupermarket2"
msgstr "Rewe"
msgid "Japanese"
msgstr "Japanisch"
msgid "Chinese (Taiwan)"
msgstr "Chinesisch (Taiwan)"
msgid "Greek"
msgstr "Griechisch"
msgid "Korean"
msgstr "Koreanisch"
msgid "Chinese (China)"
msgstr "Chinesisch (China)"
msgid "Hebrew (Israel)"
msgstr "Hebräisch (Israel)"
msgid "Tamil"
msgstr "Tamil"
msgid "Finnish"
msgstr "Finnisch"
msgid "Breakfast"
msgstr "Frühstück"
msgid "Lunch"
msgstr "Mittagessen"
msgid "Dinner"
msgstr "Abendessen"

122
localization/de/locales.po Normal file
View File

@@ -0,0 +1,122 @@
#
# Translators:
# Bernd Bestel <bernd@berrnd.de>, 2020
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2020-08-31 19:11+0000\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2020\n"
"Language-Team: German (https://www.transifex.com/grocy/teams/93189/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Domain: grocy/locales\n"
# Czech
msgid "cs"
msgstr "Tschechisch"
# Danish
msgid "da"
msgstr "Dänisch"
# German
msgid "de"
msgstr "de"
# Greek
msgid "el_GR"
msgstr "Griechisch"
# English
msgid "en"
msgstr "de"
# English (Great Britain)
msgid "en_GB"
msgstr "Englisch (Großbritannien)"
# Spanish
msgid "es"
msgstr "Spanisch"
# French
msgid "fr"
msgstr "Französisch"
# Hungarian
msgid "hu"
msgstr "Ungarisch "
# Italian
msgid "it"
msgstr "Italienisch"
# Japanese
msgid "ja"
msgstr "Japanisch"
# Korean
msgid "ko_KR"
msgstr "Koreanisch"
# Dutch
msgid "nl"
msgstr "Niederländisch"
# Norwegian
msgid "no"
msgstr "Norwegisch"
# Polish
msgid "pl"
msgstr "Polnisch"
# Portuguese (Brazil)
msgid "pt_BR"
msgstr "Portugiesisch (Brasilien)"
# Portuguese (Portugal)
msgid "pt_PT"
msgstr "Portugiesisch (Portugal)"
# Russian
msgid "ru"
msgstr "Russisch"
# Slovak
msgid "sk_SK"
msgstr "Slowakisch"
# Swedish
msgid "sv_SE"
msgstr "Schwedisch"
# Turkish
msgid "tr"
msgstr "Türkisch"
# Chinese (Taiwan)
msgid "zh_TW"
msgstr "Chinesisch (Taiwan)"
# Chinese (China)
msgid "zh_CN"
msgstr "Chinesisch (China)"
# Hebrew (Israel)
msgid "he_IL"
msgstr "Hebräisch (Israel)"
# Tamil
msgid "ta"
msgstr "Tamil"
# Finnish
msgid "fi"
msgstr "Finnisch"

View File

@@ -0,0 +1,139 @@
#
# Translators:
# @RubenKelevra <ruben@freifunk-nrw.de>, 2021
# Bernd Bestel <bernd@berrnd.de>, 2021
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2020-08-29 16:33+0000\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2021\n"
"Language-Team: German (https://www.transifex.com/grocy/teams/93189/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Domain: grocy/permissions\n"
# All permissions
msgid "ADMIN"
msgstr "Alle Berechtigungen"
# Create users
msgid "USERS_CREATE"
msgstr "Benutzer erstellen"
# Edit users (including passwords)
msgid "USERS_EDIT"
msgstr "Benutzer bearbeiten (inklusive Passwörter)"
# Show users
msgid "USERS_READ"
msgstr "Benutzer anzeigen"
# Edit own user data / change own password
msgid "USERS_EDIT_SELF"
msgstr "Eigene Benutzerdaten bearbeiten / eigenes Passwort ändern"
# Undo charge cycle
msgid "BATTERIES_UNDO_CHARGE_CYCLE"
msgstr "Ladezyklus rückgängig machen"
# Track charge cycle
msgid "BATTERIES_TRACK_CHARGE_CYCLE"
msgstr "Ladezyklus erfassen"
# Track execution
msgid "CHORE_TRACK_EXECUTION"
msgstr "Ausführung erfassen"
# Undo execution
msgid "CHORE_UNDO_EXECUTION"
msgstr "Ausführung rückgängig machen"
# Edit master data
msgid "MASTER_DATA_EDIT"
msgstr "Stammdaten bearbeiten"
# Undo execution
msgid "TASKS_UNDO_EXECUTION"
msgstr "Ausführung rückgängig machen"
# Mark completed
msgid "TASKS_MARK_COMPLETED"
msgstr "Als erledigt markieren"
# Edit stock entries
msgid "STOCK_EDIT"
msgstr "Bestandseinträge bearbeiten"
# Transfer
msgid "STOCK_TRANSFER"
msgstr "Umlagern"
# Inventory
msgid "STOCK_INVENTORY"
msgstr "Inventur"
# Consume
msgid "STOCK_CONSUME"
msgstr "Verbrauch"
# Open products
msgid "STOCK_OPEN"
msgstr "Produkt als geöffnet markieren"
# Purchase
msgid "STOCK_PURCHASE"
msgstr "Einkauf"
# Add items
msgid "SHOPPINGLIST_ITEMS_ADD"
msgstr "Eintrag hinzufügen"
# Remove items
msgid "SHOPPINGLIST_ITEMS_DELETE"
msgstr "Eintrag entfernen"
# User management
msgid "USERS"
msgstr "Benutzerverwaltung"
# Stock
msgid "STOCK"
msgstr "Bestand"
# Shopping list
msgid "SHOPPINGLIST"
msgstr "Einkaufszettel"
# Chores
msgid "CHORES"
msgstr "Hausarbeiten"
# Batteries
msgid "BATTERIES"
msgstr "Batterien"
# Tasks
msgid "TASKS"
msgstr "Aufgaben"
# Recipes
msgid "RECIPES"
msgstr "Rezepte"
# Equipment
msgid "EQUIPMENT"
msgstr "Ausstattung"
# Calendar
msgid "CALENDAR"
msgstr "Kalender"
# Meal plan
msgid "RECIPES_MEALPLAN"
msgstr "Speiseplan"

View File

@@ -1,5 +1,6 @@
#
# Translators:
# Bernd Bestel <bernd@berrnd.de>, 2019
# Bernd Bestel <bernd@berrnd.de>, 2020
#
msgid ""
msgstr ""
@@ -7,7 +8,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-01T17:59:17+00:00\n"
"PO-Revision-Date: 2019-05-01 17:42+0000\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2019\n"
"Last-Translator: Bernd Bestel <bernd@berrnd.de>, 2020\n"
"Language-Team: German (https://www.transifex.com/grocy/teams/93189/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -19,6 +20,12 @@ msgstr ""
msgid "purchase"
msgstr "Einkauf"
msgid "transfer_from"
msgstr "Umlagerung von"
msgid "transfer_to"
msgstr "Umlagerung nach"
msgid "consume"
msgstr "Verbrauch"
@@ -27,3 +34,12 @@ msgstr "Inventur-Korrektur"
msgid "product-opened"
msgstr "Produkt geöffnet"
msgid "stock-edit-old"
msgstr "Bestandseintrag bearbeitet (alte Werte)"
msgid "stock-edit-new"
msgstr "Bestandseintrag bearbeitet (neue Werte)"
msgid "self-production"
msgstr "Eigenproduktion"

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