Compare commits

...

704 Commits

Author SHA1 Message Date
Bernd Bestel
cc1d1121d3 Fixed typo (references #697)
(cherry picked from commit 30908f5ba9)
2020-04-04 20:32:02 +02:00
James Addison
71c724ccdd PSR7-decoupled rework of authentication fixup (#697)
(cherry picked from commit ca9354064d)
2020-04-04 20:32:02 +02:00
Bernd Bestel
6e710adb71 Updated version.json
(cherry picked from commit 9a9b4d1000)
2020-04-04 20:32:01 +02:00
Bernd Bestel
6e2b4b116e Added v2.6.2 changelog (hotfix, will be included/changed in the last 5 releases also)
(cherry picked from commit 808745dbfa)
2020-04-04 20:32:01 +02:00
Bernd Bestel
18724d836e Don't return anything in the response body when unauthenticated (fixes #696)
(cherry picked from commit 2778d2ad56)
2020-04-04 20:31:16 +02: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
Bernd Bestel
66571f662f Hotfix (will be included in v2.5.0 release): Don't break image loading when php-gd extension is not installed 2019-09-22 14:48:50 +02:00
Bernd Bestel
e5aebad5d9 Small night mode fix 2019-09-22 13:32:18 +02:00
Bernd Bestel
f3a1489abf Little night mode improvements 2019-09-22 10:26:43 +02:00
Bernd Bestel
6ca694226b Pulled translations from Transifex 2019-09-22 09:49:09 +02:00
Bernd Bestel
5d5cfb1548 Prepared next release 2019-09-22 09:47:58 +02:00
Bernd Bestel
1a7be05e3f Added linuxserver/docker-grocy to README 2019-09-22 09:46:19 +02:00
Bernd Bestel
f7c4662e2b Prevent error message spam when navigating away before the page has completely loaded 2019-09-22 09:36:28 +02:00
Bernd Bestel
4c57bf8b9d Always navigate back to the previous page after saving a product (closes #364) 2019-09-22 09:03:59 +02:00
Bernd Bestel
e5530e2058 Trigger input event after SetValue of datetimepicker (fixes #363) 2019-09-22 08:53:05 +02:00
Bernd Bestel
363dcf448e Give the main page content section an id 2019-09-22 08:35:03 +02:00
Bernd Bestel
d16f3c2daf Optimized demo instance localization & data handling 2019-09-22 08:21:15 +02:00
Bernd Bestel
51e0154101 Try to improve QuaggaJS barcode scanning recognition accuracy (this now closes #362) 2019-09-21 20:46:23 +02:00
Bernd Bestel
fc2a37d3fc Typo... 2019-09-21 20:20:32 +02:00
Bernd Bestel
c32ea087df Added a little barcode scanner testing page (references #362) 2019-09-21 20:01:49 +02:00
Bernd Bestel
4eabee3db7 Typo... 2019-09-21 17:30:33 +02:00
Bernd Bestel
95478cbb18 Updated README.md 2019-09-21 17:26:53 +02:00
Bernd Bestel
d8360993cc Internal change that the demo instances (stable and pre-release) can be served through a single instance for all localizations (references #241) 2019-09-21 15:07:29 +02:00
Bernd Bestel
6e4117526b Improved productcard "never" date display 2019-09-21 13:40:31 +02:00
Bernd Bestel
e4437f5db1 Fixed that "Spoil rate" and "Average shelf life" on the product card was wrong in most cases 2019-09-21 13:30:44 +02:00
Bernd Bestel
b57fd83cb8 Fixed various smaller problems after some testing 2019-09-21 13:08:42 +02:00
Bernd Bestel
327c1f4fb3 Fixed meal plan did not load when a containing recipe was deleted (closes #361) 2019-09-21 09:18:40 +02:00
Bernd Bestel
ab44566890 Small style refinements 2019-09-21 08:38:28 +02:00
Bernd Bestel
d2a841143e Don't show the sidebar on other menus on the login page 2019-09-21 08:28:08 +02:00
Bernd Bestel
d580990b25 Fixed JS errors on the login page 2019-09-21 08:25:32 +02:00
Bernd Bestel
78b658e86e Also the product calories field is not required 2019-09-20 20:19:12 +02:00
Bernd Bestel
051cb816fe Disabled CSS class was applied to calories product field by mistake 2019-09-20 20:17:54 +02:00
Bernd Bestel
91c275e66b Slightly reordered the header of the shopping list page 2019-09-20 20:14:47 +02:00
Bernd Bestel
653098a81e Improved product picture display on the productcard 2019-09-20 20:10:03 +02:00
Bernd Bestel
c228126c3a Added a new field calories for products (closes #268) 2019-09-20 20:06:24 +02:00
Bernd Bestel
1ae5f552d1 Inventory is always possible, also when the produc is not in stock currently (references #327) 2019-09-20 18:26:32 +02:00
Bernd Bestel
63d7f8f36d Typo... 2019-09-20 18:18:43 +02:00
Bernd Bestel
4754cc306a Currently there are no multiple shopping lists output options, so no dropdown button needed (this now closes #245) 2019-09-20 18:13:38 +02:00
Bernd Bestel
339a25d1e3 Added a notes field to shopping lists (references #245) 2019-09-20 18:08:38 +02:00
Bernd Bestel
5a91c86b81 Added an option to print a shopping list (references #245) 2019-09-20 17:40:45 +02:00
Bernd Bestel
292b652437 Updated localizations & improved some special and demo translation string data handling 2019-09-20 16:26:50 +02:00
Bernd Bestel
399ebbe14a Updated dependencies 2019-09-20 14:47:42 +02:00
Bernd Bestel
a95d6be4f4 Added more product actions on the stock overview page (closes #327) 2019-09-20 13:37:53 +02:00
Bernd Bestel
ca9b8d068a Reuse existing routes for the by-barcode API routes and complete them (references #331) 2019-09-20 10:45:58 +02:00
Bernd Bestel
58890f6bec Typo... 2019-09-20 10:35:30 +02:00
Bernd Bestel
9f8216378e Only show the "Test plural forms"-button on the qu edit page when the current language requires more than 2 plural forms (references #261) 2019-09-20 10:33:44 +02:00
Bernd Bestel
d4c76aaa76 Properly show qu plural forms on the product or qu conversion edit page 2019-09-20 10:30:46 +02:00
Bernd Bestel
6ce4e6cb37 An icon is not needed when not showing an userentity in the sidebar menu (references #242) 2019-09-20 10:22:59 +02:00
Bernd Bestel
aa670adefc Added a say-thanks-button on the about page 2019-09-20 10:08:10 +02:00
Bernd Bestel
1d92e6a4ab Updated changelog 2019-09-19 21:44:59 +02:00
Bernd Bestel
e720311572 Fixed hidden price_factor field in recipeposform.blade.php 2019-09-19 21:31:37 +02:00
Bernd Bestel
7c114cfec3 Implemented a price factor option for recipe ingredients (closes #295) 2019-09-19 21:30:24 +02:00
Bernd Bestel
35a409f462 Fixed/refined some things regarding purchase/consume/inventory of products with enabled tare weight handling 2019-09-19 21:10:36 +02:00
Bernd Bestel
412653d67d Small Swagger UI refinements 2019-09-19 19:59:17 +02:00
Bernd Bestel
58a69d650f Added an API endpoint to add/remove products to stock by its barcode (closes #331) 2019-09-19 18:36:46 +02:00
Bernd Bestel
a4d479d047 Also consider opened products for minimum stock amounts (optionally, but by default) (closes #353) 2019-09-19 18:11:03 +02:00
Bernd Bestel
cbf1d1ca40 Implemented stock sub-feature-flags (closes #314) 2019-09-19 17:46:52 +02:00
Bernd Bestel
5e9a7fb7ca Implemented browser barcode scanning (closes #102) 2019-09-19 12:48:02 +02:00
Bernd Bestel
9f18b75526 Auto focus the amount field on the qu plural form testing page (references #261) 2019-09-18 20:27:35 +02:00
Bernd Bestel
346b589534 Make it possible to test quantity unit plural forms (closes #261) 2019-09-18 20:21:09 +02:00
Bernd Bestel
8f798a94d1 Only allow night mode enabled manually or automatically, but not both at the same time (again fixes #71) 2019-09-18 19:43:33 +02:00
Bernd Bestel
991706920f Fixed that datetimepickers not considered the config.php setting CALENDAR_FIRST_DAY_OF_WEEK (closes #334) 2019-09-18 18:46:07 +02:00
Bernd Bestel
ce12202c86 Make it configurable if calendars shows week numbers or not (closes #333) 2019-09-18 18:30:25 +02:00
Bernd Bestel
ca470ed4ee Fixed version display in prerelease mode 2019-09-18 17:27:47 +02:00
Bernd Bestel
2237e2f8f4 Hide userfields form border for custom objects because all fields are userfields... (references #242) 2019-09-18 16:31:00 +02:00
Bernd Bestel
2522b3748c Just name it "fields" not "userfields" for custom objects (references #242) 2019-09-18 16:25:38 +02:00
Bernd Bestel
096fb7a116 Implement custom entities / objects (closes #242) 2019-09-18 16:18:15 +02:00
Bernd Bestel
918f84f568 Lazy load all images to increase page load times (references #275) 2019-09-18 13:59:37 +02:00
Bernd Bestel
d209c0bd22 Automatically downscale pictures to reduce page loading times (closes #275) 2019-09-18 11:04:59 +02:00
Bernd Bestel
ba089a3d79 Also show the stock QU (as on all other places) after a product is selected on the chore edit page (references #279) 2019-09-18 10:08:59 +02:00
Bernd Bestel
3df44697bf Implemented the option to automatically consume a product on tracking a chore execution (closes #279) 2019-09-18 10:02:52 +02:00
Bernd Bestel
e326e69d49 Allow decimal numbers in "Factor purchase to stock quantity unit" when "Allow partial units in stock" is enabled (closes #351) 2019-09-17 20:02:27 +02:00
Bernd Bestel
bbd8e8c1fa Typo... 2019-09-17 19:42:01 +02:00
Bernd Bestel
9b5f3ba7b8 Render product Userfields also on the shopping list (this now closes #258) 2019-09-17 19:39:55 +02:00
Bernd Bestel
0fa0138972 Implemented new Userfield type "Link" (references #258) 2019-09-17 19:33:06 +02:00
Bernd Bestel
6aa278c19c Updated changelog 2019-09-17 19:20:32 +02:00
Bernd Bestel
3fd0f44fe4 Merge pull request #360 from mduret/master
Parse settings provided via environment variables as boolean if needed
2019-09-17 19:15:50 +02:00
Bernd Bestel
0c27157db6 Implemented new Userfield type "Select list" (closes #325) 2019-09-17 19:11:06 +02:00
Bernd Bestel
bbd5ce1dc4 Typo... 2019-09-17 17:54:09 +02:00
Bernd Bestel
0771d58fe7 Fixed that /api/system/db-changed-time always returned the current time 2019-09-17 17:49:58 +02:00
Bernd Bestel
db0c4f78bd Fix some missing OpenAPI documentation (closes #359) 2019-09-17 17:35:13 +02:00
Bernd Bestel
ef8f6b6d42 Updated changelog 2019-09-17 17:24:19 +02:00
Bernd Bestel
4dd804003b Re-apply filter after chore execution on the chores overview page 2019-09-17 17:17:33 +02:00
Bernd Bestel
182d063886 Fixed user filter button on chores overview page (references #253) 2019-09-17 16:58:42 +02:00
Bernd Bestel
bc487b4867 Make it possible to also filter by chore assignments on the chore overview page (references #253) 2019-09-17 16:50:29 +02:00
Mathieu Duret
b5b2f9c5b9 Parse settings provided via environment variables as boolean if needed (https://github.com/grocy/grocy/issues/346) 2019-09-17 16:45:11 +02:00
Bernd Bestel
b5761ae544 Show to whom the chore execution is assigned in calendar events (references #253) 2019-09-17 16:28:11 +02:00
Bernd Bestel
597a9e3d21 Show aggregated product amounts also on the productcard (references #196) 2019-09-17 16:18:00 +02:00
Bernd Bestel
1b19940aba Only cascade changes of stock QU to recipe ingredients which uses the same QU (references #177) 2019-09-17 16:01:30 +02:00
Bernd Bestel
74f9470769 Implemented that chores can be assigned to users (closes #253) 2019-09-17 13:13:26 +02:00
Bernd Bestel
3dcd513094 Fixed new translation strings 2019-09-16 11:02:03 +02:00
Bernd Bestel
a799f2b43f Finished qu unit conversion handling (closes #177) 2019-09-16 09:35:20 +02:00
Bernd Bestel
c532a67884 Started working on qu unit conversion handling (references #177) 2019-09-15 17:06:52 +02:00
Bernd Bestel
6094096675 Started working on qu unit conversion handling (references #177) 2019-09-15 16:40:54 +02:00
Bernd Bestel
30d89f4529 Typo... 2019-09-14 17:38:58 +02:00
Bernd Bestel
a0a0e104b0 Implemented product variations (closes #196) 2019-09-14 17:34:36 +02:00
Bernd Bestel
26ebeec74f Improved date display of "Track date only"-chores (never show the time part for them) 2019-09-14 13:05:36 +02:00
Bernd Bestel
a4454f825a Fixes/changes for pull request #349 2019-08-31 14:08:15 +02:00
Bernd Bestel
6ec3872518 Merge pull request #349 from Forceu/master
Add API call for adding products to shoppinglist
2019-08-31 13:58:10 +02:00
Marc Ole Bulling
d4eb767f1b Add API call for adding products to shoppinglist 2019-08-30 09:21:11 +02:00
Bernd Bestel
afa4165d1c Updated changelog 2019-08-15 14:39:11 +02:00
Bernd Bestel
f9036f0248 Use the summernote editor for product description (closes #288) 2019-08-15 14:35:28 +02:00
Bernd Bestel
257dd644aa Render checkbox Userfields in tables as checkmark (closes #326) 2019-08-15 14:05:33 +02:00
Bernd Bestel
be4b5c81b2 ixed that the delete button not always deleted the currently selected equipment item (fixes #307) 2019-08-15 13:53:30 +02:00
Bernd Bestel
f88ed1ee8a Merge pull request #343 from Forceu/master
API: Return stock amount of 0 instead of null, if product is not in stock
2019-08-13 14:23:27 +02:00
Forceu
411aad2398 Set stock amount to 0 instead of null if product not in stock
Without this the API returns null instead of 0 when queried for product stock amount
2019-08-13 12:20:14 +02:00
Bernd Bestel
7004cf4400 Finished the implementation of "Location Content Sheet" (closes #341) 2019-08-11 09:24:47 +02:00
Bernd Bestel
28716ed96c First draft for printable location content sheets (references #341) 2019-08-10 16:34:29 +02:00
Bernd Bestel
d6e9dc1b59 Allow providing the API key also via a query parameter (closes #329) 2019-08-10 13:30:50 +02:00
Bernd Bestel
19935276e9 Typo... 2019-08-10 13:11:02 +02:00
Bernd Bestel
fa326fdfda Added an API endpoint to search for objects by name (closes #337) 2019-08-10 13:07:08 +02:00
Bernd Bestel
e6020432c6 Add chores due date rollover (closes #340) 2019-08-10 12:44:09 +02:00
Bernd Bestel
12a2c0945e Added the changelog for the next release 2019-08-10 08:33:54 +02:00
Bernd Bestel
cc1c6a6442 Little changes for pull request #338 2019-08-10 08:33:30 +02:00
Bernd Bestel
c757ee3874 Merge pull request #338 from Forceu/master
Add API call to remove an item from the shopping list by productid
2019-08-10 08:04:00 +02:00
Marc Ole Bulling
1e33975a96 Use default best before date when adding product through API 2019-08-04 20:58:11 +02:00
Forceu
1a23eaabf1 Add API call to remove an item from the shopping list by productid
This adds an API call, so a shopping list item can easily be removed

Please note: This is UNTESTED, as I was unable to run the current grocy master commit on my server.
2019-08-04 20:31:47 +02:00
Bernd Bestel
3dbce7547f Fixed "datatables_localization" localization JSON-string (fixes #323) 2019-07-20 15:48:58 +02:00
Bernd Bestel
0bb3e0ae28 Merge pull request #317 from skevas/fix-typo
Fixes typo in update.sh
2019-07-14 15:16:22 +02:00
skevas
8d4a2d0ff9 Fixes typo in update.sh 2019-07-14 13:02:21 +02:00
Bernd Bestel
3234a97b3c Merge pull request #315 from oncleben31/patch-1
Use list title when display a user field form
2019-07-13 08:26:51 +02:00
Oncleben31
b61d569247 Use list title when display a used filed form
To replace the default string `Product group`
2019-07-13 01:34:57 +02:00
Bernd Bestel
0daf0aeb61 Added a hint to the new community contributions section on the website 2019-07-12 13:45:35 +02:00
Bernd Bestel
889f520afb grocy-desktop is not really "NEW" anymore... 2019-07-12 13:42:35 +02:00
Bernd Bestel
c6420a74ba Merge pull request #290 from nielstholenaar/master
Allow possibility to choose custom homepage
2019-07-10 22:14:19 +02:00
Niels Tholenaar
e3f53aaebd Added possible values to entry page config setting 2019-07-10 17:14:25 +02:00
Niels
94e2ec5e15 Merge branch 'master' into master 2019-07-10 15:11:36 +02:00
Niels Tholenaar
0a61ea0fcf Improved entry page resolving to handle disabled features 2019-07-10 15:10:39 +02:00
Bernd Bestel
091145c62c Minor typos... 2019-07-07 20:00:05 +02:00
Bernd Bestel
197b83fee8 Prepared next release 2019-07-07 19:51:40 +02:00
Bernd Bestel
430286ae9e Don't consider a chores executed when the execution was undone 2019-07-07 19:47:05 +02:00
Bernd Bestel
6e3407b157 Always show "Track date only" shore execution times without the time part 2019-07-07 19:38:57 +02:00
Bernd Bestel
13c432b0cf Fixed weekly chores were scheduled on the same day (fixes #304) 2019-07-07 19:19:54 +02:00
Bernd Bestel
4822d9a4b8 Fixed date-only-datetimepicker width 2019-07-07 10:10:20 +02:00
Bernd Bestel
52dd01f313 Fixed that a string was never translated 2019-07-07 09:29:04 +02:00
Bernd Bestel
87976b86d9 Also display price data from inventory corrections, not only purchases (fixes #303) 2019-07-07 09:25:13 +02:00
Bernd Bestel
84e6e253ea Fixed date "never" display on stock overview page (again closes #296) 2019-07-07 09:04:40 +02:00
Bernd Bestel
001d5c5d1d Prepared next release 2019-07-06 20:43:30 +02:00
Bernd Bestel
b4d2e2a20a Added the possibility to undo a task (closes #252) 2019-07-06 20:34:01 +02:00
Bernd Bestel
914dde4609 Added a new config.php setting CALENDAR_FIRST_DAY_OF_WEEK to be able to change the first day of a week used for calendar views (closes #256) 2019-07-06 20:19:21 +02:00
Bernd Bestel
1eb1aa8b11 Added a "consume this recipe"-button to the meal plan (and also a button to consume all recipes for a whole week) (closes #283) 2019-07-06 20:02:40 +02:00
Bernd Bestel
09b23847b5 Added a new config.php setting DISABLE_AUTH to be able to disable authentication / the login screen (closes #246) 2019-07-06 18:29:18 +02:00
Bernd Bestel
8c205941c7 Added that products can now also be consumed as spoiled from the stock overview page (option in the more/context menu per line) (closes #251) 2019-07-06 18:15:53 +02:00
Bernd Bestel
b24683f954 Added the possibility to mark a shopping list item as "done" (closes #257) 2019-07-06 17:56:59 +02:00
Bernd Bestel
e4d26bb8fd Make it possible to switch shopping list items between shopping lists (closes #284) 2019-07-06 17:31:17 +02:00
Bernd Bestel
c6c10c87e4 Improved date display for dates of today and no time
Instead of the hours since midnight now just "Today" will be shown
2019-07-06 17:19:28 +02:00
Bernd Bestel
df529c3c0b Show 2999-12-31 as "Never" everywhere (closes #296) 2019-07-06 15:43:54 +02:00
Bernd Bestel
482a520062 Slightly modified new recipe stock fulfillment API endpoints (references #289) 2019-07-06 15:28:49 +02:00
Bernd Bestel
ddef58e2a9 Merge pull request #289 from Aerex/add-resolved-recipes-endpoint
Add requirement fulfillment recipes endpoint
2019-07-06 15:02:20 +02:00
Bernd Bestel
d34c7b0a87 Created the changelog for the next version 2019-07-06 14:56:56 +02:00
Bernd Bestel
b76e51ba41 Fixed nested recipes costs calculation (fixes #299) 2019-07-06 14:48:46 +02:00
Bernd Bestel
67cfd0ba5f Remove the internal meal plan recipe when removing a meal plan entry (fixes #298) 2019-07-06 13:57:49 +02:00
Bernd Bestel
3fcede0b7c Fix that "Track date only" cannot be tracked <> today (fixes #300) 2019-07-06 13:32:40 +02:00
Bernd Bestel
0c0e8c6957 Fixed the consume success message on stock overview page (fixes #302) 2019-07-06 13:13:38 +02:00
Niels Tholenaar
86f5667039 Allow possibility to choose custom homepage 2019-06-22 16:02:52 +02:00
Aerex
a01a80578c Merge branch 'master' into add-resolved-recipes-endpoint 2019-06-20 23:40:55 -05:00
grocy
7a51fb77b0 feat: Added recipes/requirements route
- feat: Added requirements route to allow clients to access the requirements fulfilments of recipes
2019-06-20 23:11:57 -05:00
Bernd Bestel
511c95070e Minor typos... 2019-06-09 09:34:21 +02:00
Bernd Bestel
eec6270cb7 Prepared next release 2019-06-09 09:30:18 +02:00
Bernd Bestel
7c7c5db28c Fixed that a entered barcode on the product edit page was only saved when "adding" it to the barcodes list by pressing TAB (closes #269) 2019-06-09 09:21:56 +02:00
Bernd Bestel
6b98fa85d3 Improved meal plan entry reference when deleting an entry (references #255) 2019-06-09 09:10:29 +02:00
Bernd Bestel
825be63b93 Fixed single quotes problem in all pickers (fixes #264) 2019-06-09 09:06:44 +02:00
Bernd Bestel
a56f8be19e Fixed page reloads with unsaved form data and "Auto reload on external changes" enabled (fixes #265) 2019-06-09 08:58:46 +02:00
Bernd Bestel
f736c4de44 Added changelog with current changes 2019-06-08 17:03:17 +02:00
Bernd Bestel
56217804b7 Always include en_GB localizations regardless of completion (because there aren't real translations needed, fixes #276) 2019-06-08 16:56:37 +02:00
Bernd Bestel
43710b5062 Properly show the API error when it failed to undo a stock booking (fixes #267) 2019-06-08 16:53:31 +02:00
Bernd Bestel
b1adaa24cf Fix session problem on 32 bit systems when using "stay logged in permanently" (fixes #278) 2019-06-08 16:47:45 +02:00
Bernd Bestel
9e7d62b62d Make sure to hide all tooltips before removing an element (fixes #260) 2019-06-08 16:39:35 +02:00
Bernd Bestel
9f2481a6a8 Fixed an issue when a plural translation is empty/null (can be the case for quantity units, fixes #259) 2019-06-08 16:32:23 +02:00
Bernd Bestel
2b77bc6ae6 Fixed deleting meal plan entries did not work (fixes #255) 2019-06-08 16:30:45 +02:00
Bernd Bestel
91116ee768 Make sure user settings variable is populated always (fixes #277) 2019-06-08 15:54:56 +02:00
Bernd Bestel
167e57ef3f Merge pull request #272 from BlizzWave/patch-23
Update grocy_night_mode.css
2019-05-30 19:42:05 +02:00
Marius Boro
3321bcd683 Update grocy_night_mode.css
Fixed unreadable text
2019-05-30 14:32:27 +02:00
Bernd Bestel
41b8b5d11e Prepared new release 2019-05-16 22:25:46 +02:00
Bernd Bestel
0a4ea6861a Fixed quotes were not escaped properly for contains search in dropdowns (fixes #249) 2019-05-16 22:20:01 +02:00
Bernd Bestel
8f9c3c66f7 Don't load userfieldsform.js when not needed 2019-05-16 22:14:04 +02:00
Bernd Bestel
d412b81eae Hotfix (will be included in v2.4.0 release): Fixed a potential problem when the plural form of a translation (e. g. plural forms for user defined quantity units) is NULL 2019-05-10 21:22:53 +02:00
Bernd Bestel
55e5fd7bf1 Prepared next release 2019-05-10 21:08:42 +02:00
Bernd Bestel
1787690795 Added missing translations string 2019-05-10 21:04:28 +02:00
Bernd Bestel
3eb8b5f381 Pulled translations from Transifex 2019-05-10 21:01:58 +02:00
Bernd Bestel
d8cefeffb7 Added missing translations strings 2019-05-10 20:57:49 +02:00
Bernd Bestel
5da50d1e1e Updated dependencies 2019-05-10 20:56:03 +02:00
Bernd Bestel
de89fee5bb Fixed wrong amount was displayed in popup after consume 2019-05-10 20:43:57 +02:00
Bernd Bestel
338c6c0a9d Added a new userfield type "preset-list" (closes #239) 2019-05-07 21:24:59 +02:00
Bernd Bestel
8504eb9b38 Finished first version of meal planning (for now closes #146) 2019-05-07 19:48:14 +02:00
Bernd Bestel
3f53919ddd Also allow placeholders for plural translations (references #161) 2019-05-07 19:42:35 +02:00
Bernd Bestel
57233dba1a Added first basic version of meal planning (references #146) 2019-05-06 19:38:47 +02:00
Bernd Bestel
e240260f9f Unify translations strings which include an amount + quantity unit (references #161) 2019-05-05 14:31:27 +02:00
Bernd Bestel
dd148a8fc3 Use named arguments for all gettext strings which have more than 1 argument (again closes #161) 2019-05-05 14:13:50 +02:00
Bernd Bestel
153ac61867 Fix deleting user have not worked (fixes #237) 2019-05-04 23:10:01 +02:00
Bernd Bestel
9ef55f1f01 Make it possible to track a chore execution without the time part, only the day 2019-05-04 16:13:05 +02:00
Bernd Bestel
98fcd767b3 Fixed chore edit form - period type hint did not work (references #151) 2019-05-04 15:40:26 +02:00
Bernd Bestel
fe8bb43996 Fixed userfields did not load (references #176) 2019-05-04 15:21:50 +02:00
Bernd Bestel
328d96ed60 Only show plural forms text field on quantity unit edit page when the current language has more than 2 plural forms to prevent confusion (references #161) 2019-05-04 15:15:03 +02:00
Bernd Bestel
970e5edfa3 Fixed an issue with translations string without an placeholder (references #161) 2019-05-04 15:13:01 +02:00
Bernd Bestel
12ba99f649 Added "variable amount" for recipe ingredients (closes #181) 2019-05-04 14:50:15 +02:00
Bernd Bestel
314e434fd1 Updated translations 2019-05-04 13:43:14 +02:00
Bernd Bestel
29f69c92e9 Update OpenAPI object schemas and added more examples (closes #218) 2019-05-04 13:33:44 +02:00
Bernd Bestel
0eb974bd92 Make it possible to customize the default amount for purchase/consume (closes #215) 2019-05-04 13:19:34 +02:00
Bernd Bestel
bcd6dd4b20 Forgot to save a file on the last commit... 2019-05-03 22:18:24 +02:00
Bernd Bestel
6cecb2ca7b Make it possible to enter up to 4 decimal places for price fields (this now closes #225) 2019-05-03 22:15:30 +02:00
Bernd Bestel
bcae9f9292 Added price field on inventory page (for added products) (references #225) 2019-05-03 22:11:20 +02:00
Bernd Bestel
8138dd43ac Added barcode as a column to master data / products page (closes #234) 2019-05-03 21:41:31 +02:00
Bernd Bestel
78a230c5d5 Fixed again a problem with productpicker workflows and disabled URL rewriting (closes #232) 2019-05-03 20:22:48 +02:00
Bernd Bestel
4c2cf4944d Added a feature flag to also be able to hide all stock related UI elements and routes (closes #228) 2019-05-03 20:03:04 +02:00
Bernd Bestel
bd296f8fe1 Fixed a problem where the current stock fulfillment amount is not correctly displayed (references #161) 2019-05-03 19:51:08 +02:00
Bernd Bestel
24680154d8 Properly display/round recipe ingredients amounts (closes #230) 2019-05-03 19:36:27 +02:00
Bernd Bestel
dfd501c515 Don't load or save userfields if there are none (references #176) 2019-05-03 19:29:12 +02:00
Bernd Bestel
dae5bb2b34 Make it possible to filter recipes by stock availability (closes #231) 2019-05-03 19:22:58 +02:00
Bernd Bestel
595171afa5 Properly show and handle that the new amount during inventory cannot equal the current stock amount (this now closes #224) 2019-05-03 19:08:54 +02:00
Bernd Bestel
7fc4992b3a Fixed API response for /api/stock/products/{productId}/inventory when the new amount equals the current stock amount (references #224) 2019-05-03 18:37:02 +02:00
Bernd Bestel
618ff5609f Fixed success message on inventory page showed the previous amount instead of the new one (references #224) 2019-05-03 18:32:59 +02:00
Bernd Bestel
94c6e634b8 Fixed the "Add as barcode to existing product" productpicker workflow failed to add the barcode to the given product (fixes #222) 2019-05-03 18:29:09 +02:00
Bernd Bestel
b310aa55c5 Prevent productpicker workflow modal from being opened twice (fixes #229) 2019-05-02 21:46:15 +02:00
Bernd Bestel
3cf8ebeb89 Fixed product picker workflow URLs were wrong when running grocy in a subdirectory and with disabled URL rewriting (again fixes #219) 2019-05-02 21:33:59 +02:00
Bernd Bestel
ae156ed0e6 Removed accidentally added strings 2019-05-02 20:31:47 +02:00
Bernd Bestel
4912dd56d1 Finished migration to use gettext (this now closes #161) 2019-05-02 20:20:18 +02:00
Bernd Bestel
5d3f248d94 Pulled translations from Transifex (references #161) 2019-05-01 20:38:25 +02:00
Bernd Bestel
9b2dba2397 Migrated (hopefully) all translations to PO/Gettext (references #161) 2019-05-01 20:19:18 +02:00
Bernd Bestel
40b5afe926 Backup current state of LocalizationService.php (references #161)
This will serve as a permanent backup for the migration algorithm used to migrate all current translation files to PO/Gettext
2019-05-01 20:04:06 +02:00
Bernd Bestel
6ceb6e3643 Backup all current translations from Transifex (references #161)
This will serve as a permanent backup of the current translations before migrating them to PO/gettext
2019-05-01 19:34:09 +02:00
Bernd Bestel
a999112a21 Added a link to the new grocy subreddit (references grocy/grocy-website#1) 2019-04-28 21:18:35 +02:00
Bernd Bestel
310cdd7d4c Pulled translations from Transifex 2019-04-28 19:17:31 +02:00
Bernd Bestel
77f094810b Added changelog with current changes for next release 2019-04-28 09:55:43 +02:00
Bernd Bestel
b6b8c76d3a Fixed product picker workflows URLs were wrong when running grocy in a subdirectory (fixes #219) 2019-04-27 15:17:55 +02:00
Bernd Bestel
6442665f6c Just some technical corrections for the new sv_SE translation 2019-04-23 09:49:25 +02:00
Bernd Bestel
04ca6edbd3 Pulled translations from transifex 2019-04-23 09:40:04 +02:00
Bernd Bestel
c5993ad994 Finalize user-defined-fields (closes #176) 2019-04-23 09:06:18 +02:00
Bernd Bestel
72a3f63546 Extended contributing info to use pull requests for changes 2019-04-22 23:13:57 +02:00
Bernd Bestel
eae8536c9b Added contribution info 2019-04-22 22:43:07 +02:00
Bernd Bestel
fc11da3c3f Started working on user-defined-fields for all entities (references #176) 2019-04-22 22:16:35 +02:00
Bernd Bestel
77f3b80540 Implemented daily/weekly/monthly recurrence patterns for chores (closes #151) 2019-04-22 14:01:31 +02:00
Bernd Bestel
d72fe69a17 Show more info in product card (closes #173) 2019-04-22 10:11:58 +02:00
Bernd Bestel
162adeb359 Improve API related changes regarding multiple shopping lists (references #190) 2019-04-22 08:21:57 +02:00
Bernd Bestel
49d16b458d Added missing localization strings 2019-04-20 19:25:59 +02:00
Bernd Bestel
cdd02efcc6 Implemented multiple/named shopping lists (closes #190) 2019-04-20 17:04:40 +02:00
Bernd Bestel
c1674d33b4 Make "next X days" configurable (closes #175) 2019-04-20 15:30:45 +02:00
Bernd Bestel
41988aa1ee Updated version.json 2019-04-06 16:16:44 +02:00
Bernd Bestel
18b8712369 Updated dependencies for next release 2019-04-06 16:13:19 +02:00
Bernd Bestel
42a9d5af2b Pulled translations from Transifex 2019-04-06 16:03:43 +02:00
Bernd Bestel
c4d377ce4e Added new changelog 2019-04-06 16:00:17 +02:00
Bernd Bestel
50a782c8c0 Added missing translation strings 2019-04-06 16:00:02 +02:00
Bernd Bestel
fa6f09679f Made "Disable stock fulfillment checking for this ingredient" a default option per product (closes #182) 2019-04-06 15:42:40 +02:00
Bernd Bestel
25c257bb2c Allow partial minimum stock amount when enabled (closes #203) 2019-04-06 15:27:00 +02:00
Bernd Bestel
0496ae9e00 Added an info for product-add-workflows (closes #192) 2019-04-06 15:15:20 +02:00
Bernd Bestel
45ae386005 Fixed context menu is not visible when the table height is smaller than the menu height (fixes #195) 2019-04-06 14:41:43 +02:00
Bernd Bestel
b6e80580ed Make it possible to provide a different location for added product during inventory (closes #183) 2019-04-05 21:26:44 +02:00
Bernd Bestel
886e272c03 Show product count per group on the product groups page and added a link to the products page filtered by the current product group (closes #174) 2019-04-05 21:08:30 +02:00
Bernd Bestel
40cc0ff280 Revert changes in file public/js/grocy.js of commit "Fixed differences in highlighting for expiring/expired items in header vs table on stock overview page (fixes #198)"
This reverts changes in file public/js/grocy.js of commit 12082b52ab.
2019-04-05 18:59:58 +02:00
Bernd Bestel
3a0bb913d5 Improved form input padding (fixes #180) 2019-04-05 18:50:46 +02:00
Bernd Bestel
12082b52ab Fixed differences in highlighting for expiring/expired items in header vs table on stock overview page (fixes #198) 2019-04-05 18:41:21 +02:00
Bernd Bestel
2d3df2024a Fixed "Mark as open" button is disabled on stock overview page when current stock amount == 1 (fixes #197) 2019-04-05 18:01:21 +02:00
Bernd Bestel
a9c0539305 Updated version.json 2019-03-10 16:29:02 +01:00
Bernd Bestel
5b304c5e97 Added new changelog and update translations 2019-03-10 16:27:34 +01:00
Bernd Bestel
1b26a6277b Make demo product locations a little bit more realistic 2019-03-10 16:18:24 +01:00
Bernd Bestel
353a65d41c Tried to fix inventory form validation again (closes #167) 2019-03-10 16:08:15 +01:00
Bernd Bestel
bfcd05473a Allow best before date on purchase/inventory to be today or in the past, but display a hint when so (closes #172) 2019-03-10 16:02:13 +01:00
Bernd Bestel
3d485d4850 Fixed datetimepicker had no validation message displayed (references #172) 2019-03-10 15:40:19 +01:00
Bernd Bestel
9d02fbc13c Again some changes for the new product-by-barcode API method (references #171) 2019-03-10 14:53:06 +01:00
Bernd Bestel
27ba2bfd55 Fixed display errors when consuming partial amounts from stock overview page (fixes #170) 2019-03-10 14:10:25 +01:00
Bernd Bestel
61f582554f Return a proper API response when booking amount for consume/open is > current stock amount (references #170) 2019-03-10 13:50:28 +01:00
Bernd Bestel
75241fc61f Just some changes for the new product-by-barcode API method (references #171) 2019-03-10 13:43:58 +01:00
Bernd Bestel
91289588b5 Merge pull request #171 from matejdro/barcode_fetch
Add fetch by barcode API method
2019-03-10 13:28:36 +01:00
Matej Drobnič
3f4a5cc0d6 Add fetch by barcode API method 2019-03-10 12:20:31 +01:00
Bernd Bestel
e693460894 Finalized next version 2019-03-09 17:19:02 +01:00
Bernd Bestel
47a6260d27 Show the plural form of stock QU unit when showing purchase to stock conversion factor on purchase page when QU units are different (references #169) 2019-03-09 17:04:34 +01:00
Bernd Bestel
bfd29def8d Show purchase to stock conversion factor on purchase page when QU units are different (closes #169) 2019-03-09 17:00:57 +01:00
Bernd Bestel
cd0ca4a67c Prepared next release 2019-03-09 16:42:46 +01:00
Bernd Bestel
659d60b235 Make it possible to show the changelog directly via /about?tab=changelog 2019-03-09 16:25:23 +01:00
Bernd Bestel
8efcb79ed7 Updated screenshots 2019-03-09 16:18:20 +01:00
Bernd Bestel
5ba55823c9 Clarify that the CURRENCY setting should be the ISO 4217 code of the currency (to work with the JS toLocaleString function) 2019-03-09 16:04:03 +01:00
Bernd Bestel
6de4b120b3 Include changelog as markdown files and show it in the about dialog 2019-03-09 15:54:16 +01:00
Bernd Bestel
8fec262184 Added missing translation strings 2019-03-09 13:14:36 +01:00
Bernd Bestel
bd483ec8b0 Added a context menu to all stock overview page items 2019-03-09 13:11:50 +01:00
Bernd Bestel
4d215edbd0 Clear displayed quantity unit after purchase/consume/inventory bookings 2019-03-09 12:31:45 +01:00
Bernd Bestel
a3d4fd834f Added a small right border to separate button columns in all tables better 2019-03-09 10:49:26 +01:00
Bernd Bestel
2d0c0bf34f Fixed cancel button color in unknown product resolve dialog 2019-03-09 10:41:03 +01:00
Bernd Bestel
0f03420808 Removed unnecessary table column heading for button columns 2019-03-09 10:40:38 +01:00
Bernd Bestel
ba319dc6f1 Fixed equipment page edit/delete button icons were not visible 2019-03-08 22:22:05 +01:00
Bernd Bestel
c10890205c Don't load not existing / not need localization JS files (this now closes #165) 2019-03-08 22:18:42 +01:00
Bernd Bestel
643f6272e4 Fixed file name case sensitivity issue with tagmanager jQuery Plugin (references 165) 2019-03-08 22:13:47 +01:00
Bernd Bestel
cad5e9ef79 Tried to fix inventory form validation (references #167) 2019-03-08 22:03:59 +01:00
Bernd Bestel
01fdfe1a0c Fixed recipe ingredient notes were not displayed on the recipes page 2019-03-07 22:20:08 +01:00
Bernd Bestel
acd1e7337c Prepared next release 2019-03-06 19:38:22 +01:00
Bernd Bestel
3586bf77c3 Added info about Feature Flags 2019-03-06 19:37:55 +01:00
Bernd Bestel
ff886fea61 Fixed termination after first command 2019-03-06 19:29:17 +01:00
Bernd Bestel
5bd00d8be7 Only download at least 90 percent completed translation files from Transifex 2019-03-06 19:25:35 +01:00
Bernd Bestel
9f36a599a4 Changed the about dialog slightly 2019-03-06 19:23:53 +01:00
Bernd Bestel
ff15e81abe Fixed a rounding regarding stock amount comparison when a (scaled) recipe needs a decimal amount (closes #164) 2019-03-06 19:05:32 +01:00
Bernd Bestel
e8b471f572 Fixed termination after first command 2019-03-06 18:42:51 +01:00
Bernd Bestel
2d8ad24887 Implemented that included recipes can have a serving amount (closes #163 and references #127) 2019-03-05 23:45:04 +01:00
Bernd Bestel
45db9ff90c Added scripts for Transifex upload/download & updated translations 2019-03-05 21:22:54 +01:00
Bernd Bestel
c813a6500d Removed embedded binary tools - not needed to be in the repo here 2019-03-05 21:11:15 +01:00
Bernd Bestel
1077149784 Hide the form validation feedback icons introduced in Bootstrap 4.2.0 - a colored border is enough 2019-03-05 20:15:29 +01:00
Bernd Bestel
e08dfb408c Reorganized dev scripts and tools 2019-03-05 19:54:38 +01:00
Bernd Bestel
fcdeda91d9 Show the iCal sharing link instead of directly open it (references #141) 2019-03-05 19:36:14 +01:00
Bernd Bestel
4932b9c6d2 Improved recipe header display on small screens 2019-03-05 19:22:16 +01:00
Bernd Bestel
7f2942d414 Also filter gallery items when searching for recipes (references #147) 2019-03-05 19:17:10 +01:00
Bernd Bestel
3a1c5efcfd Fix gallery tab was not selected by query parameter (references #147) 2019-03-05 18:04:16 +01:00
Bernd Bestel
816eb03147 Added a "recipe gallery" view (closes #147) 2019-03-05 17:59:33 +01:00
Bernd Bestel
8504429f5f Implemented tare weight handling (closes #132) 2019-03-05 17:51:50 +01:00
Bernd Bestel
90291fdbca Added possibility to export the calendar in iCal format (closes #141) 2019-03-04 17:44:48 +01:00
Bernd Bestel
77b0bc675c Varios small UI changes / improve UI consistency 2019-03-04 17:43:12 +01:00
Bernd Bestel
8020f92d6b Track on consume for which recipe it was (closes #64 and references #64) 2019-03-03 18:20:06 +01:00
Bernd Bestel
38825c70da Added missing translations strings & pulled translations from Transifex 2019-03-03 17:01:35 +01:00
Bernd Bestel
bb5daa5f8b Display total cost of recipes based on last purchase prices (closes #128) 2019-03-03 16:33:48 +01:00
Bernd Bestel
8c11d0f15d Add an option per recipe to not check against the shopping list when adding missing recipe ingredients, only against stock (closes #154) 2019-03-03 15:23:39 +01:00
Bernd Bestel
5b544f76a5 Merge pull request #160 from d-Rickyy-b/patch-1
FIX: Typo in config-dist.php
2019-03-03 15:00:29 +01:00
Bernd Bestel
6f93da9b5f Only list missing products in the "recipe put everything on the shopping list"-dialog (references #125) 2019-03-03 14:57:36 +01:00
Bernd Bestel
e9ef7ea6d8 Allow recipe ingredients to be ignored when putting them on the shopping list (closes #125) 2019-03-03 14:49:46 +01:00
Rico
54a23019b8 FIX: Typo in config-dist.php 2019-03-03 14:47:38 +01:00
Bernd Bestel
89ad25c904 Implemented scalable recipes (closes #127) 2019-03-03 13:27:10 +01:00
Bernd Bestel
ee38d626aa Added all application icon variants (closes #159) 2019-03-02 08:56:53 +01:00
Bernd Bestel
40b60bed85 Added apple-touch-icon tag (references #159) 2019-03-01 22:37:15 +01:00
Bernd Bestel
b89643ddb1 Allow different locations per product in stock (closes #124)
Kind of basic for now, a different location can be set on purchase, the filters on the stock overview page handles different locations
2019-03-01 20:25:01 +01:00
Bernd Bestel
32e878afc9 Added feature flags to disable/hide parts not needed (closes #157)
grocy was initally about stock management, so this is always enabled, the rest can be disabled
2019-03-01 19:33:33 +01:00
Bernd Bestel
9974305ad4 Hide relative date when clearing the datetimepicker (this now closes #143) 2019-02-09 14:48:13 +01:00
Bernd Bestel
a3b2d03d68 Fixed datetimepicker only worked once when not selecting a date
References #143
Using a self-patched version of tempusdominus/bootstrap-4 for now, see 2cf725fed9 and tempusdominus/bootstrap-4#34
2019-02-09 14:44:37 +01:00
Bernd Bestel
01e9e3f5ce Move about dialog into separate view and add API endpoint for system info 2019-02-09 13:41:40 +01:00
Bernd Bestel
b5ac319a90 Pull translations from Transifex 2019-02-03 17:02:40 +01:00
Bernd Bestel
ad09630dbe Make it possible to add pictures to recipes (closes #136) 2019-01-26 20:06:01 +01:00
Bernd Bestel
03720940d4 Resize embedded iframes to content height (this should fix #130) 2019-01-26 19:31:41 +01:00
Bernd Bestel
dfc05e0bec Allow optional partial units of products in stock (closes #123) 2019-01-26 14:17:02 +01:00
Bernd Bestel
9e139e2b73 Remove missing translation and improve database migration for #149 2019-01-26 14:12:18 +01:00
Bernd Bestel
5c622b9512 Fix product form was not validated when changing location (fixes #144) 2019-01-26 13:13:38 +01:00
Bernd Bestel
eec3515b6d Don't use a second hidden amount field for shopping list entries which were added by "Add missing products to shopping list" (fixes #149) 2019-01-26 13:09:01 +01:00
Bernd Bestel
276bc94cc6 More improvements on the REST API (references #139) 2019-01-21 22:13:42 +01:00
Bernd Bestel
bfa59dd29c Rework API to be more RESTful (references #139) 2019-01-19 14:51:51 +01:00
Chris Forkner
0ce8d706a6 API - A bit more RESTful (#140)
* Restful routes

* Change public/viewjs to match API routes

* Move the GET and POST together. Fixed Typos. PUT for object/user edits.

* Verb-less Generic Entity Interactions

* Create Grocy.Api.Put

* Create Grocy.Api.Delete

* Fix Volatile Slim Error order in routes and adjust to english noun
2019-01-19 08:37:21 +01:00
Bernd Bestel
98d95f80df Prepared next release 2019-01-10 21:02:11 +01:00
Bernd Bestel
a72afa7174 Forgot to save before pushing last commit... 2019-01-05 21:14:23 +01:00
Bernd Bestel
0d145bbf1e Respect QU purchase factor when adding or comparing recipe ingredients to shopping list entries (fixes #131) 2019-01-05 21:11:36 +01:00
Bernd Bestel
f6cf26009d Better API response when request body is not valid JSON (references #126) 2019-01-05 20:39:22 +01:00
Bernd Bestel
c042657dd8 Fix location edit form (edit did not work) 2019-01-05 20:38:27 +01:00
Bernd Bestel
43c9ab7734 Fixed a problem with newer SQLite versions (references and fixes #133) 2019-01-05 20:28:21 +01:00
Bernd Bestel
f6649d51bd Finalize loading speed improvements for all data tables (this now closes #120)
This is a workaround for now. The tables are still DOM sourced because of too big dependencies between server side rendering and frontend JS code. The tables are initially load while tbody is hidden, this results in a speedup by around 65 %.
2019-01-05 20:06:35 +01:00
Bernd Bestel
2e265ac70a Again some changes for stock overview table loading speed workaround (references #120) 2019-01-05 16:27:26 +01:00
Bernd Bestel
30e54997b2 Workaround to improve stock overview table loading time (references #120) 2019-01-05 14:27:40 +01:00
Bernd Bestel
b9f0470d76 Prepared next release 2018-12-30 09:21:11 +01:00
Bernd Bestel
bdcd176f81 Make config.php settings also available as environment variables (closes #118) 2018-12-23 16:45:16 +01:00
Bernd Bestel
04dacacd73 Pull translations from Transifex for new release 2018-11-27 17:30:40 +01:00
Bernd Bestel
a9502d1ddb Fix wrong translation string 2018-11-26 20:03:14 +01:00
Bernd Bestel
5c25e91984 Add possibility to skip items in "all shopping list items to stock workflow" (closes #116) 2018-11-26 20:02:01 +01:00
Bernd Bestel
02163c4305 Properly refresh opened product amount after consume on stock overview page (fixes #114) 2018-11-26 19:47:07 +01:00
Bernd Bestel
c3731b3200 Sort recipes fulfillment column by amount of missing products (closes #113) 2018-11-26 19:40:29 +01:00
Bernd Bestel
5cdf2c14d3 Fix shopping list edit form - product was not prefilled (fixes #115) 2018-11-26 19:37:17 +01:00
Bernd Bestel
e92d74f5c3 This is v1.23.0 2018-11-24 20:41:45 +01:00
Bernd Bestel
2b3516dadd Pull translations from Transifex 2018-11-24 20:39:42 +01:00
Bernd Bestel
8041dd9c26 Support single quotes in demo data 2018-11-24 20:39:17 +01:00
Bernd Bestel
2f7b78bc40 Update dependencies for next release 2018-11-24 20:18:50 +01:00
Bernd Bestel
61fc6e05f4 Add an agenda view to calendar 2018-11-24 20:18:13 +01:00
Bernd Bestel
367a3e52de Properly sort recipes fulfillment column (closes #113) 2018-11-24 19:59:24 +01:00
Bernd Bestel
a3617cffb8 Small different UI improvements
Show the cursor as pointer on stock overview page while hovering the product name cell to highlight that the productcard can be opened
Show a waiting cursor and disable all form inputs while doing background XHR calls to highlight that the user should wait
Place the search field (to search a table) on all pages to the left most place
2018-11-24 19:40:50 +01:00
Bernd Bestel
ff341d8547 Typo... 2018-11-21 22:17:51 +01:00
Bernd Bestel
01fab6999f Add new demo translation string 2018-11-21 22:16:02 +01:00
Bernd Bestel
b6152ce874 Pull translations from Transifex 2018-11-21 21:54:15 +01:00
Bernd Bestel
ca5df3b217 Hopefully finally fix the navbar scrollbar problems now 2018-11-21 21:36:22 +01:00
Bernd Bestel
dd48be595c Remove "debug" JS output 2018-11-21 19:16:06 +01:00
Bernd Bestel
306d0f7da6 Add "one click shopping list to stock workflow" (closes #110) 2018-11-21 19:08:36 +01:00
Bernd Bestel
c61c37e67a Properly initialize show_clock_in_header user setting control after page reload 2018-11-20 19:34:06 +01:00
Bernd Bestel
f7f90238f2 Show optionally a clock in the header (closes #109) 2018-11-20 19:23:48 +01:00
Bernd Bestel
589ad36855 Remove unneeded translation string 2018-11-18 15:52:48 +01:00
Bernd Bestel
5da24d2d4f Added first version of calendar (closes #42) 2018-11-18 15:39:43 +01:00
Bernd Bestel
f7f2bf3fc0 Various small UI improvements for the shopping list 2018-11-18 14:19:50 +01:00
Bernd Bestel
34d1bdd53f Added missing translation string 2018-11-18 14:15:11 +01:00
Bernd Bestel
e021c93d22 Make clear than picking a specific stock item on consume always means an amount of 1 2018-11-18 13:46:23 +01:00
Bernd Bestel
2ff5faacc0 Prevent opening more products than are unopened in stock 2018-11-18 13:35:21 +01:00
Bernd Bestel
a489190e81 Add some opened products to demo 2018-11-18 13:21:57 +01:00
Bernd Bestel
a403bb687a Show amount of opened products on stock overview page and in product card 2018-11-18 13:17:36 +01:00
Bernd Bestel
5966a3d678 Improve journal UI when undoing a transaction 2018-11-18 12:58:15 +01:00
Bernd Bestel
c71e46191f Optimized stock logic 2018-11-18 12:34:05 +01:00
Bernd Bestel
862fd7c644 Added missing translation string 2018-11-17 19:46:59 +01:00
Bernd Bestel
10ea9c44fd Make it possible to mark a product as opened (closes #86) 2018-11-17 19:39:37 +01:00
Bernd Bestel
816ca6460f Make it possible to pick a specific stock item on consume (closes #62) 2018-11-17 17:51:35 +01:00
Bernd Bestel
b6d60c4e34 Fix datetimepicker did not trigger a change event (fixes #108) 2018-11-17 15:00:51 +01:00
Bernd Bestel
6f67619784 Finish "shopping list to stock workflow" (closes #98) 2018-11-17 14:50:52 +01:00
Bernd Bestel
db0b48e7ae Fix GitHub project links 2018-11-17 12:58:44 +01:00
Bernd Bestel
973f07b360 Add embedded mode (hides menu and so on), maybe need for #98 2018-11-17 12:57:35 +01:00
Bernd Bestel
0f73d849eb Fixed equipment edit button always pointed to the first equipment item (fixes #107) 2018-11-17 08:26:31 +01:00
Bernd Bestel
1a6849ad37 Moved docker related things to https://github.com/grocy/grocy-docker (this now closes #101, thanks @talmai) 2018-11-16 07:58:03 +01:00
Bernd Bestel
8f31f891fd Add a "shopping list item to stock flow" (references #98) 2018-11-14 21:40:17 +01:00
Bernd Bestel
83985e9f21 Migrate translations to use Transifex 2018-11-03 14:29:14 +01:00
Bernd Bestel
04e9ba8e34 Allow fraction numbers for recipe ingredients when not checked against stock and add option to not check stock for a recipe position (closes #105) 2018-11-02 19:53:01 +01:00
Bernd Bestel
960ee919f9 Mention minimum SQLite version (closes #104) 2018-10-29 22:09:44 +01:00
Bernd Bestel
f4534a4bfb Update dependencies for next release 2018-10-27 17:58:05 +02:00
Bernd Bestel
89553b7fa0 Workaround for datepicker problem (fixes #100) 2018-10-27 17:56:53 +02:00
Bernd Bestel
364f6b2051 Add journal and undo UI for stock bookings, chore executions and battery charge cycles (closes #63, closes #97) 2018-10-27 17:26:00 +02:00
Bernd Bestel
fe83e2fa6f Created API endpoints to undo battery charge cycles and chore executions (references #63) 2018-10-27 10:55:30 +02:00
Bernd Bestel
1f3dd58ddf Properly display line breaks of recipe positions and shopping list item notes 2018-10-27 10:39:52 +02:00
Bernd Bestel
da98efa833 Finalize nested recipes / group recipe positions feature (closes #77) 2018-10-27 10:37:31 +02:00
Bernd Bestel
3e6cf545d7 Finalize stock booking undo API (references #63 and #97) 2018-10-27 10:19:06 +02:00
Bernd Bestel
1080c3486c Created first version of an API endpoint to undo stock bookings (references #63 and #97) 2018-10-26 22:28:58 +02:00
Bernd Bestel
cd7b6b686d Fix API keys cannot be deleted (fixes #99) 2018-10-26 20:12:48 +02:00
Bernd Bestel
b84e6da0dd Added recipe position groups (references #77) 2018-10-25 22:45:44 +02:00
Bernd Bestel
fc3a4c6899 Finish first version of nested recipes feature (references #77) 2018-10-25 20:36:29 +02:00
Bernd Bestel
12a2cb0bdf Created basis edit UI for nested recipes (references #77) 2018-10-23 19:36:39 +02:00
Bernd Bestel
57a0864465 Show productcard as a popup on stockoverview page instead of only the product picture (closes #93) 2018-10-22 19:28:59 +02:00
Bernd Bestel
b3da837ede Added link to item edit page for all item cards (product/chore/battery) (references #93) 2018-10-22 19:13:08 +02:00
Bernd Bestel
3de3e03ab3 Created database logic for nested recipes (references #77) 2018-10-21 15:02:52 +02:00
Bernd Bestel
78865a9d3c Fix product groups were empty on product presets page (references #92) 2018-10-20 15:22:32 +02:00
Bernd Bestel
5b3230d63d Properly name the quantity unit field on product presets page (references #92) 2018-10-20 15:18:58 +02:00
Bernd Bestel
04c93d937e Make presets for new products configurable (closes #92) 2018-10-20 14:55:49 +02:00
Bernd Bestel
5318e79f55 Properly pluralize quantity unit in success message on purchase/consume/inventory page 2018-10-20 14:09:19 +02:00
Bernd Bestel
7bf4421d44 Improve best before date comparison on stockoverview page (fixes #87) 2018-10-20 14:04:09 +02:00
Bernd Bestel
366152c049 Next attempt to fix the scroll issue of navigation section (references #90) 2018-10-20 11:25:22 +02:00
Bernd Bestel
70c00e81d9 Cascade changes of stock quantity unit of products to recipe positions (fixes #91) 2018-10-20 11:17:51 +02:00
Talmai Oliveira
f13abf483e Grocy docker patch fix (#94)
fixed:

Warning: Use of undefined constant GROCY_USER_ID - assumed
'GROCY_USER_ID' (this will throw an Error in a future version of PHP) in
/www/controllers/BaseController.php on line 47
2018-10-20 09:07:05 +02:00
Bernd Bestel
0e723a0a9b Fixed reported login problem ("PHP Warning: date() expects parameter 2 to be integer, float given") 2018-10-16 18:21:38 +02:00
Bernd Bestel
4a35477c35 Don't auto reload when database has changed in "fullscreen-card-mode" (fixes #88) 2018-10-13 09:18:16 +02:00
Bernd Bestel
df7d360516 Update screenshots 2018-10-11 10:33:38 +02:00
Bernd Bestel
03eaa6c79f Add possibility to filter by product group on stock overview page 2018-10-06 18:19:31 +02:00
Bernd Bestel
132999ce36 Show the little "product has an image icon" also on products page (references #58) 2018-10-06 18:08:25 +02:00
Bernd Bestel
188407e3c7 Merge branch 'master' of https://github.com/berrnd/grocy 2018-10-06 18:02:30 +02:00
Bernd Bestel
8cf68ade30 Fix missing translation (references #85) 2018-10-06 18:02:13 +02:00
Marius Boro
d62657c698 Better translation (#84)
* Update no.php

* Update no.php

minor fix
2018-10-06 17:57:21 +02:00
Bernd Bestel
3262e534dc Hotfix (will be included in v1.21.0 release): Fixed a syntax error in norwegian localization file 2018-10-06 12:08:44 +02:00
Bernd Bestel
6202e8bda7 Update dependencies for next release 2018-10-06 11:48:47 +02:00
Bernd Bestel
9984e8f218 Small visual/space improvements/changes on recipes and equipment page 2018-10-06 11:43:46 +02:00
Marius Boro
b0c91f6ad1 added missing and updated for new features. (#83) 2018-10-06 09:15:54 +02:00
Marius Boro
9e24586190 Update no.php (#82) 2018-10-06 09:15:40 +02:00
Bernd Bestel
7ba6fc875b Improve responsive embeds (references #25) 2018-10-03 19:05:00 +02:00
Bernd Bestel
3b10906e78 Optimize space around the embedded PDF a little bit (references #25) 2018-10-03 18:04:46 +02:00
Bernd Bestel
ebd24bf30e Use new editor also for recipes 2018-10-03 16:41:21 +02:00
Bernd Bestel
ebd9b1b851 Add possibility to show equipment notes/instruction manuals also in fullscreen mode (references #25) 2018-10-03 16:40:40 +02:00
Bernd Bestel
b242a5de52 Finish equipment / instruction manuals feature (references #25) 2018-10-03 16:11:39 +02:00
Bernd Bestel
81ec011095 Product edit page: Slightly improved styling of barcodes 2018-10-03 13:34:38 +02:00
Bernd Bestel
2a371cc081 Product edit page: Enforce a quantity unit conversion factor > 1 when quantity unit purchase != quantity unit stock 2018-10-03 13:27:36 +02:00
Bernd Bestel
edb986ce24 Added a quick mockup for equipment / instruction manuals (references #25) 2018-10-02 20:03:08 +02:00
Bernd Bestel
f90faca62e Accept only files for product picture file input 2018-10-02 18:33:16 +02:00
Bernd Bestel
6090ac621e Prevent deletion of products with current stock (closes #81) 2018-10-02 18:17:26 +02:00
Bernd Bestel
ae58606d04 Center title in product picture dialog 2018-10-02 18:00:52 +02:00
Bernd Bestel
bb9caf9cc9 Fixed volatil stock logic (fixes #69) 2018-10-02 17:06:21 +02:00
Bernd Bestel
9dd57decdf Finish "pictures for products" features (now closes #58) 2018-10-02 16:48:39 +02:00
Bernd Bestel
f1fc0ee549 Finished first version of "pictures for products" (references #58) 2018-10-01 20:20:50 +02:00
Bernd Bestel
fcdeb33426 Merge branch 'master' of https://github.com/berrnd/grocy 2018-09-30 23:22:45 +02:00
Bernd Bestel
44cd26ae77 Finish first early version of "pictures for products" (references #58) 2018-09-30 23:22:17 +02:00
Marius Boro
04f34ea6b0 Update no.php (#80) 2018-09-30 22:17:15 +02:00
Bernd Bestel
e5fb609c8e Finalize file API (references #58) 2018-09-30 22:16:33 +02:00
Bernd Bestel
c675b534ef Fix missing german translation 2018-09-30 21:41:30 +02:00
Marius Boro
6c74881f95 Update no.php (#79) 2018-09-30 21:40:26 +02:00
Bernd Bestel
756ec319cc Update dependencies for next release 2018-09-30 20:11:24 +02:00
Bernd Bestel
ba2d32be60 Fixes for auto night mode (references #71) 2018-09-30 19:31:03 +02:00
Bernd Bestel
7cc09cec67 The last fix (maybe) for auto night mode handling (references #71) 2018-09-30 18:07:28 +02:00
Bernd Bestel
8b815fce93 Finalize auto night mode feature (references #71) 2018-09-30 18:02:59 +02:00
Bernd Bestel
f1c78659be Optimize user settings 2018-09-30 17:14:04 +02:00
Bernd Bestel
5c79a80f7a Prepared auto night mode configuration option (references #71) 2018-09-30 13:33:21 +02:00
Bernd Bestel
f451e65278 Also log missing localization found in frontend (only when MODE == dev) 2018-09-30 13:02:07 +02:00
Bernd Bestel
176333df5b Save night mode enabled state and apply night mode class to <body> on server side (references #71) 2018-09-30 11:25:07 +02:00
Bernd Bestel
d4227d2e41 Make auto reloading the page on external database changes configurable (closes #74) 2018-09-30 11:17:28 +02:00
Bernd Bestel
0bbd2d9880 Prepare user settings API (references #74 and #71) 2018-09-30 10:47:56 +02:00
Bernd Bestel
b81316bd60 Include products which are not in stock currently but below min. stock amount on stock overview page (fixes #69) 2018-09-30 10:13:37 +02:00
Bernd Bestel
d11dcb38fe Only reload the page on external changes when there is no unsaved form data (fixes #73) 2018-09-30 09:57:42 +02:00
Bernd Bestel
77d82f22dc Fixed scrolling did not work when showing a recipe in fullscreen mode (fixes #76) 2018-09-30 09:41:22 +02:00
Talmai Oliveira
be326a5211 Grocy docker patch (#78)
* typo corrections

* more typos

* initial work towards dockerized version of grocy

* placeholder for future README

* fully working dockerized grocy

* updated final size of docker images
2018-09-30 09:31:16 +02:00
Marius Boro
83624eaf27 Update no.php (#75) 2018-09-30 09:22:30 +02:00
Bernd Bestel
055619d275 Tweaked grocy_night_mode.css slightly (references #71) 2018-09-29 16:35:17 +02:00
Bernd Bestel
cda3dde120 Quick test implementation of night (references #71) 2018-09-29 15:39:16 +02:00
Bernd Bestel
5a0b862d22 v1.19.2 release 2018-09-29 13:45:50 +02:00
Bernd Bestel
bb5fd8360b Fix double form submit when using ENTER (fixes #72) 2018-09-29 13:41:56 +02:00
Marius Boro
d7180bd7b2 Updated no.php (#70)
* Update no.php

* Update no.php
2018-09-27 20:39:11 +02:00
543 changed files with 71679 additions and 4770 deletions

View File

@@ -0,0 +1,16 @@
set projectPath=%~dp0
if %projectPath:~-1%==\ set projectPath=%projectPath:~0,-1%
set projectPath=%projectPath%\..
set releasePath=%projectPath%\.release
mkdir "%releasePath%"
copy "%projectPath%\version.json" versiontemp.json
for /f "tokens=*" %%a in ('jq .Version versiontemp.json --raw-output') do set version=%%a
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 "%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\*

View File

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

View File

@@ -0,0 +1,4 @@
pushd ..
tx pull --all --minimum-perc=80
tx pull --language en_GB
popd

View File

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

View File

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

2
.gitattributes vendored Normal file
View File

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

44
.tx/config Normal file
View File

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

View File

@@ -5,45 +5,60 @@ ERP beyond your fridge
- 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)
## 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.
## Community contributions
See the website for a list of community contributed Add-ons / Tools: [https://grocy.info/#addons](https://grocy.info/#addons)
## Motivation
A household needs to be managed. I did this so far (almost 10 years) with my first self written software (a C# windows forms application) and with a bunch of Excel sheets. The software is a pain to use and Excel is Excel. So I searched for and tried different things for a (very) long time, nothing 100 % fitted, so this is my aim for a "complete houshold 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
> **NEW**
> Checkout grocy-desktop, if you want to run grocy without a webserver just like a normal (windows) desktop application.
>
> There is now grocy-desktop if you want to run grocy without a webserver just like a normal (windows) desktop application.
>
> See https://github.com/berrnd/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"...
> 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"...
Just unpack the [latest release](https://releases.grocy.info/latest) on your PHP (SQLite extension required, currently only tested with PHP 7.2) 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 writable `chown -R www-data:www-data data/`). Default login is user `admin` with password `admin`, please change the password immediately (see user menu).
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).
Alternatively clone this repository and install Composer and Yarn dependencies manually.
If you use nginx as your webserver, please include `try_files $uri /index.php;` in your location block.
If you use nginx as your webserver, please include `try_files $uri /index.php$is_args$query_string;` 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);`).
## 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` (the default from values `config-dist.php` will be used for not in `data/config.php` defined settings). Just to be sure, please empty `data/viewcache`.
See the website for further installation guides and troubleshooting help: https://grocy.info/links
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).
## 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`.
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. There is one file per language in the `localization` directory, if you want to create a translation, it's best to copy `localization/de.php` to a new one (e. g. `localization/it.php`) and translating all strings there. (Language can be changed in `data/config.php`, e. g. `Setting('CULTURE', 'it');`)
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');`)
### Maintaining your own localization
As the German translation will always be the most complete one, for maintaining your localization it would be easiest when you compare your localization with the German one with a diff tool of your choice.
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!
Also any translation which reached a completion level of 80 % will be included in releases.
## Things worth to know
### REST API & data model documentation
See the integrated Swagger UI instance on [/api](https://demo-en.grocy.info/api).
See the integrated Swagger UI instance on [/api](https://demo.grocy.info/api).
### Barcode readers
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.
### Barcode readers & camera scanning
Some fields (with a barcode icon above) also allow to select a value by scanning a barcode. It works best when your barcode reader prefixes every barcode with a letter which is normally not part of a item name (I use a `$`) and sends a `TAB` after a scan.
Additionally it's also possible to use your device camera to scan a barcode by using the camera button on the right side of the corresponding field (powered by [QuaggaJS](https://github.com/serratus/quaggaJS), 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
### 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`
@@ -52,8 +67,10 @@ The following shorthands are available:
- `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
- 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.
@@ -67,27 +84,35 @@ 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).
### 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`)
### 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/berrnd/grocy-desktop)).
When the file `embedded.txt` exists, it must contain a valid and writable path which will be used as the data directory instead of `data` and authentication will be disabled (used in [grocy-desktop](https://github.com/grocy/grocy-desktop)).
In embedded mode, settings can be overridden by text files in `data/settingoverrides`, the file name must be `<SettingName>.txt` (e. g. `BASE_URL.txt`) and the content must be the setting value (normally one single line).
## Contributing / Say thanks
Any help is more than appreciated. Feel free to pick any open unassigned issue and submit a pull request, but please leave a short comment or assign the issue yourself, to avoid working on the same thing.
See https://grocy.info/#say-thanks for more ideas if you just want to say thanks.
## Screenshots
#### Dashboard
![Dashboard](https://github.com/berrnd/grocy/raw/master/publication_assets/dashboard.png "Dashboard")
![Dashboard](https://github.com/grocy/grocy/raw/master/publication_assets/dashboard.png "Dashboard")
#### Purchase - with barcode scan
![Purchase - with barcode scan](https://github.com/berrnd/grocy/raw/master/publication_assets/purchase-with-barcode.gif "purchase-with-barcode")
![Purchase - with barcode scan](https://github.com/grocy/grocy/raw/master/publication_assets/purchase-with-barcode.gif "purchase-with-barcode")
#### Consume - with manual search
![Consume - with manual search](https://github.com/berrnd/grocy/raw/master/publication_assets/consume.gif "consume")
![Consume - with manual search](https://github.com/grocy/grocy/raw/master/publication_assets/consume.gif "consume")
## License
The MIT License (MIT)

94
app.php
View File

@@ -1,10 +1,12 @@
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Container\ContainerInterface as Container;
use Slim\Factory\AppFactory;
use \Grocy\Helpers\UrlManager;
use \Grocy\Controllers\LoginController;
use Grocy\Helpers\UrlManager;
use Grocy\Controllers\LoginController;
// Definitions for embedded mode
if (file_exists(__DIR__ . '/embedded.txt'))
@@ -19,53 +21,61 @@ else
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);
}
// Load composer dependencies
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__ . '/config-dist.php'; // For not in own config defined values we use the default ones
// Definitions for dev/demo/prerelease mode
if (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
{
define('GROCY_USER_ID', 1);
}
// Definitions for disabled authentication mode
if (GROCY_DISABLE_AUTH === true)
{
if (!defined('GROCY_USER_ID'))
{
define('GROCY_USER_ID', 1);
}
}
// 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 Slim\Views\Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
});
$container->set('LoginControllerInstance', function(Container $container)
{
return new LoginController($container, 'grocy_session');
});
$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);
}
// Add default middleware
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, false, false);
$app->run();

View File

@@ -1,13 +0,0 @@
set projectPath=%~dp0
if %projectPath:~-1%==\ set projectPath=%projectPath:~0,-1%
set releasePath=%projectPath%\.release
mkdir "%releasePath%"
for /f "tokens=*" %%a in ('build_tools\jq.exe .Version version.json --raw-output') do set version=%%a
del "%releasePath%\grocy_%version%.zip"
"build_tools\7za.exe" a -r "%releasePath%\grocy_%version%.zip" "%projectPath%\*" -xr!.* -xr!build_tools -xr!build.bat -xr!composer.json -xr!composer.lock -xr!package.json -xr!yarn.lock -xr!publication_assets
"build_tools\7za.exe" a "%releasePath%\grocy_%version%.zip" "%projectPath%\public\.htaccess"
"build_tools\7za.exe" rn "%releasePath%\grocy_%version%.zip" .htaccess public\.htaccess
"build_tools\7za.exe" d "%releasePath%\grocy_%version%.zip" data\*.* data\storage data\viewcache\*

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
- Added a login screen and switched to cookie/session based authentication instead of HTTP-basic-auth

View File

@@ -0,0 +1,2 @@
- New feature: Habit tracking
- Fixed an issue which prevented that the databse is correctly created on unix systems

View File

@@ -0,0 +1,2 @@
- New feature: Rechargeable battery management
- Improved productivity of input forms

View File

@@ -0,0 +1 @@
- Improved sidebar responsiveness

View File

@@ -0,0 +1,2 @@
- Allow to add anything to the shopping list, not only products
- Major project refactoring

View File

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

View File

@@ -0,0 +1,2 @@
- New configuration option "BASE_URL" to define base installation URL (should make subdirectory installations possible, see #3)
- Added some missing translations

View File

@@ -0,0 +1 @@
- Fixed login form didn't respect the configured BASE_URL

View File

@@ -0,0 +1 @@
- Documented the REST API and data model, see the integrated instance of Swagger UI at [/api](https://demo.grocy.info/api)

View File

@@ -0,0 +1 @@
- Added validation of all API requests and improved Swagger/OpenAPI description

View File

@@ -0,0 +1 @@
- Basic features, mainly about a interface to record grocery purchases and consumptions

View File

@@ -0,0 +1 @@
- Added a plugin system for looking up products against external services by barcode, see #6 for reference

View File

@@ -0,0 +1,4 @@
- It's now possible to consume products directly from stock overview with one click
- Added due/overdue info on bateries- and habits overview (like on stock overview)
- Reworked general page layout and improved responsiveness (see #9 and thanks @d-Rickyy-b)
- Translations fixes

View File

@@ -0,0 +1 @@
- Added an option to not use URL rewriting (for webservers which, however, don't support URL rewriting)

View File

@@ -0,0 +1,2 @@
- On the stockoverview it's now possible to filter the products by location
- All dropdowns are now sorted alphabetically

View File

@@ -0,0 +1 @@
- Bug fix for location filtering on stock overview page did not work in all browsers

View File

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

View File

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

View File

@@ -0,0 +1,13 @@
- New feature: **Recipes**
- Organize a list of products, amounts and a description into recipes and see at a glance if everything needed is in stock or put the missing things with one click on the shopping list
- Try it live on the demo page: => https://demo.grocy.info/recipes
- Added norwegian translation (thanks @BlizzWave)
- Demo available at: => https://no.demo.grocy.info
- A lot of small UI improvements
- Columns in tables can now be reordered
- Show a calendar on the shopping list page (useful, at least for me)
- Table column ordering and sorting is now remembered
- Sidebar collapse state is now remembered
- Fixed datetimepicker border
- Keep the parent sidebar menu item expanded if the active page is a sub menu item
- Custom JS/CSS file names have changed [see README](https://github.com/berrnd/grocy#adding-your-own-css-or-js-without-to-have-to-modify-the-application-itself)

View File

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

View File

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

View File

@@ -0,0 +1 @@
- General improvements, the work goes on...

View File

@@ -0,0 +1,4 @@
- Basic product price tracking (can be entered on purchase, a little price history chart is shown in the product card - right side on purchase/consume/etc. pages)
- Proper pluralization of everything (for quantity units you can enter the plural form in master data)
- On all overview pages the statistics shown in the header are now updated when doing changes directly on the page (e. g. consuming a product)
- Lots of small fixes and improvements (form validation, translations - thanks for keeping the norwegian translation always updated @BlizzWave, other small bugs)

View File

@@ -0,0 +1,5 @@
- The complete row is now refreshed on changes on all overview pages
- Added a checkbox to set the "never expires date" in best before date inputs (alternative to shortcut "x")
- Recipes can now have arbitrary quantity units and stock is only checked for one unit then (imagine you have sugar in "Packs" in stock but your recipe "Pancakes" needs 200 grams)
- Added a "consume this recipe button" to remove all ingredients of a recipe from stock with one click
- Other small UI changes/improvements

View File

@@ -0,0 +1 @@
- Some smaller UI bug fixes and enhancements (thanks again for all the testing @BlizzWave)

View File

@@ -0,0 +1,6 @@
- New feature: Tasks / To-do list
- Renamed habits to chores as this is more what it is about
- Products can now be organized in product groups, this group is also used to group the items on the shopping list (you can use this to optimize your way in the supermarket for example)
- Added an option to stay logged in permanently (checkbox on the login page)
- When the database was changed externally, the current page is automatically reloaded when there was no input for at least 50 seconds
- Fixed some minor UI bugs

View File

@@ -0,0 +1,2 @@
- The colored info bars on top of all (overview)pages can now be clicked to filter the table accordingly
- Fixed some minor mostly UI related bugs

View File

@@ -0,0 +1,2 @@
- Important bug fix: All forms were submitted twice when using ENTER instead of the OK/Save button
- Norwegian translation updates (thanks @BlizzWave )

View File

@@ -0,0 +1,3 @@
- New optional "Night Mode" (thanks a lot @BlizzWave, can also be activated automatically by a time range - see the new dropdown menu next to the user menu)
- Docker support (thanks @talmai)
- Fixed some minor UI bugs

View File

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

View File

@@ -0,0 +1,14 @@
- Added a journal for stock bookings, chore executions and battery charge cycles
- => Button in each line on the overview pages or the "Journal" button next to the headline on every overview page
- Added the possibility to undo any stock booking, chore execution and battery charge cycle
- => Button in the success popup while booking a purchase/consume/etc. or on the new journal pages (see above)
- Presets for new products are now configurable
- => "Presets for new products" button next to the headline on the products list page
- Recipes can now be nested (include a recipe into another one)
- Recipe ingredients can now be grouped together which will result in headlines per group in the rendered recipe
- => Group can be set on the recipe position edit page, demo recipe is "Pizza")
- On the stock overview page, the product card is now shown when clicking the product name
- Added option to filter by product group on stock overview page
- When auto reloading on external changes is enabled, the page is not reloaded when there is a fullscreen card active (recipe/equipment instruction manual)
- On the product-/chore-/batterycard there is now a link to the edit page of the corresponding item
- Some other minor bug fixes

View File

@@ -0,0 +1,18 @@
- New feature: "Shopping list to stock workflow"
- Add a single shopping list item or all at once to stock directly from the shopping list
- There are new "stock settings" under settings menu in the top right corner
- You can enable there, that all products which have "Default best before days" set, are added without confirmation in this workflow
- => This means, you can add the whole shopping list to stock with one click, if you want
- Improved stock handling
- On consume, a specific stock item can now be picked
- A stock item can now be marked as "opened" (on the consume page or directly from stock overview, visible in the product card and on the stock overview page)
- New feature: Calendar
- Shows all upcoming product expirations, due chores, due tasks and due battery charge cycles
- New translation: French (thanks all the translators)
- As for all languages, a demo is available at: https://fr.demo.grocy.info
- Small other improvements
- Allow fraction numbers for recipe ingredients when not checked against stock and add an option to not check stock for a recipe position
- The current time can now be shown in the header (see the settings menu next to the user icon)
- Changed: Docker related things are now in a separate repository: https://github.com/grocy/grocy-docker
- Changed: Translations are now managed with Transifex: https://www.transifex.com/grocy/grocy

View File

@@ -0,0 +1 @@
- Form validation and barcode input handling improvements

View File

@@ -0,0 +1,2 @@
- Added a skip button when adding all shopping list items in "Shopping list to stock workflow"
- Fixed some minor UI related bugs

View File

@@ -0,0 +1 @@
- All `config.php` settings can now also be set via environment variables (for [grocy-docker](https://github.com/grocy/grocy-docker))

View File

@@ -0,0 +1,5 @@
- Fixed a SQL error during database migration when using SQLite >= 3.25.2
- Improved data tables loading time
- Location edit form did not work (master data)
- Quantity unit "purchase to stock factor" was not respected when putting a recipe on the shopping list or when comparing the already on the shopping list amount
- Better API response for POST routes when there is no or invalid JSON request body content

View File

@@ -0,0 +1,23 @@
- Breaking change: The API has been completely reworked, please review [the documentation](https://demo.grocy.info/api) before updating when you are using the API
- New feature: Tare weight handling
- An option per product
- Imagine this: You have flour in jars, the jar weighs 500 grams, currently there are 1000 grams in stock, the new weight including the jar is 1100 grams - grocy can now calculate the used amount on consume/purchase/inventory automatically, you only have to enter the weighed amount including the jar (demo product to showcase this "Flour")
- Recipe improvements
- Recipes are now scalable - define per recipe for how much servings it is, change the desired servings on the fly when the recipe is displayed, ingredient amounts are scaled accordingly
- The cost of a recipe is now displayed based on the last purchase price per ingredient (recipe scaling also applies)
- When putting all missing recipe ingredients on the shopping list, it is now possible to ignore certain ingredients (in the popup when clicking the "Put missing items on shopping list" button)
- A new option per recipe to not check against the amount already on the shopping list when putting all missing ingredients on it (by default, only the amount not already on the shopping list is added, when this is enabled, always the whole missing amount will be put on the shopping list)
- On consume, there can now be tracked for which recipe it was, this is also tracked automatically when using the "Consume all ingredients needed by this recipe" button (for future statistical purposes)
- Recipes can now have pictures
- New "gallery view" for recipes (demo available at https://demo.grocy.info/recipes?tab=gallery)
- Stock improvements
- It is now optionally possible to have partial units in stock (option per product)
- On purchase, a different location can now be assigned (imagine you have two freezers, by default you store your pizza there, but sometimes there)
- New translations: (thanks all the translators)
- Spanish (demo available at https://es.demo.grocy.info)
- Turkish (demo available at https://tr.demo.grocy.info)
- Other improvements
- The calendar can now be shared/integrated in iCal format (button in the header on the calendar page)
- Added feature flags to hide/disable certain parts of grocy when you don't use them (for example hide "Chores" and all related UI elements, when you don't use it, see `config-dist.php`)
- Added a "Apple Touch Icon" and a "Web App Manifest" which should improve grocy on mobile devices and also enables "Add to Home screen" on major mobile browsers
- A lot of other minor small and bigger UI improvements

View File

@@ -0,0 +1,10 @@
- Some small UI fixes & improvements
- Recipe ingredient notes were not displayed
- Edit/delete buttons on the equipment page had no icons
- Improved the overview pages "action buttons column" (e. g. hide more rarely used actions behind a context/dropdown menu)
- The "purchase to stock conversion factor" is now displayed on the purchase page when QU units are different (above the amount field)
- Some JS files were not loaded correctly on case sensitive file systems
- The changelog is now included as markdown files (in `/changelog` directory, one file per release with a filename in format `<ReleaseNumber>_<Version>_<ReleaseDateIso>.md`) and shown in the about dialog
- Please review your `CURRENCY` setting in `data/config.php`, see also `config-dist.php` - this should be the ISO 4217 code of the currency to properly work with the JS `toLocaleString` function
- New translation: (thanks all the translators)
- Russian (demo available at https://ru.demo.grocy.info)

View File

@@ -0,0 +1,5 @@
- New API method to get a product by its barcode (`/stock/products/by-barcode/{barcode}`, thanks @matejdro)
- The best before date on the purchase and inventory page can now also be today or earlier, but when so, a short hint is displayed
- Fixed some UI bugs
- When consuming a product with "Allow partial units in stock" enabled from the stock overview page, the displayed amount after the stock booking was wrong
- The inventory form was not validated with certain click paths

View File

@@ -0,0 +1,17 @@
- Stock improvements
- A different location can now also be set during inventory (as for purchases)
- A partial minimum stock amount can now be set when "Allow partial units in stock" is enabled (product option)
- Recipe improvements
- There is now a default per product for "Disable stock fulfillment checking for this ingredient" (ingredient option, default can be defined as a product option)
- Some small UI fixes & improvements
- THe "Mark as open" button on the stock overview page was disabled when the current stock amount was exactly 1
- The number in the "x products expiring within the next 5 days" badge was incorrect for products expiring exactly in 5 days
- On the product groups page there is now a new column which displays the product count per group (+ a link to the products page filtered by that product group)
- Added a message to clarify that in product dropdowns also something unknown can be entered to start a workflow
- Some other small CSS fixes (context menus were not fully displayed when the parent container was to small, improved padding for text inputs)
- As always: Updated translations (thanks all the translators)
### Self promotion
[grocy-desktop](https://github.com/grocy/grocy-desktop) is now also available through the Microsoft Store
<a href="//www.microsoft.com/store/apps/9nwb1trnnksf?cid=storebadge&ocid=badge"><img src="https://assets.windowsphone.com/85864462-9c82-451e-9355-a3d5f874397a/English_get-it-from-MS_InvariantCulture_Default.png" alt="Get it from Microsoft" width="150px" /></a>

View File

@@ -0,0 +1,34 @@
- New feature: Userfields
- Attach any custom field to any entity (Products, Locations, Euqipment, etc.)
- Userfields can have types (Text, Number, Date, etc.)
- Will be shown / can be filled on the edit page of the corresponding entity and will also optionally show in the corresponding tables (inclcudes overview pages)
- => Can be configured under Master data / Userfields
- New feature: Meal planning
- Simple approach for the beginning (more to come): A week view where you can add recipes for each day (new menu entry in the sidebar, below calendar)
- Of course it's also possible to put missing things directly on the shopping list from there, also for a complete week at once
- General improvements
- The "expires soon" or "due soon" days (yelllow bar at the top of each overview page) can now be configured
- => New settings page for each area under the settings icon at the top right
- Stock improvements
- It's now possible to have multiple / named shopping lists
- Automations still use the default shopping list and also the default shopping list cannot be deleted
- More information on the product card like "Spoil rate" or "Average shelf life"
- It's now possible to set a price for added products during inventory
- It's now possible to customize the default amount for purchase/consume (see stock settings under the settings icon on the top right)
- Chores improvements
- New recurrence patterns - chores can now also be "scheduled" to repat daily/weekly/monthly
- It's now possible to track the day of a chore execution only (without the time, option per chore)
- Recipe improvements
- It's now possible to enter a "variable amount" (e. g. if a recipe needs "1 - 2 cups"), the original amount is still used for stock fulfillment checking (if enabled for that recipe ingredient)
- New translations: (thanks all the translators)
- Swedish (demo available at https://sv.demo.grocy.info)
- Polish (demo available at https://pl.demo.grocy.info)
- Internal improvement: Localizations are now handled via gettext, both on server and client side
- Mainly to properly handle languages with more than 2 plural forms
- This involved some string changes which results in a needed (re)translation of about 20 strings (excluding demo data)
- Also applies to quantity units, n-plural forms can be entered on the quantity unit edit page
- It's not required to install the PHP gettext extension, on both, server and client, managed implementations of gettext are used ([oscarotero/Gettext](https://github.com/oscarotero/Gettext) & [oscarotero/gettext-translator](https://github.com/oscarotero/gettext-translator))
- Some other small fixes and improvements
- The "Add as barcode to existing product" productpicker workflow failed to add the barcode to the given product
- Recipes can now be filter by stock availability
- Added a feature flag (`config.php` setting) to also be able to hide all stock related UI elements and routes

View File

@@ -0,0 +1,2 @@
- Fixed a performance problem for loading data tables related to the new Userfields feature
- Fixed that when using single quotes in a product name did not trigger the workflow popup

View File

@@ -0,0 +1,11 @@
- Fixed that deleting meal plan entries did not work
- Fixed a problem that the user settings were not properly initialized for the frontend JS part when not logged only (so potentially affected only the login page)
- Fixed an issue that the shopping list did not load when a plural translation for a quantity unit was missing
- Fixed that tooltips were visible forever when consuming all products on the stock overview page
- Fixed that login did not work when "Stay logged in permanently" was set and grocy runs on a 32-bit system (thanks @matejdro)
- Fixed page reloads when "Auto reload on external changes" is enabled and there is unsaved form data (the detection did not work for forms in modal dialogs, e. g. when adding a entry to the meal plan)
- Fixed (again) that the product picker did not work properly when the product name contains single quotes
- Fixed that a entered barcode on the product edit page was only saved when "adding" it to the barcodes list by pressing `TAB` (is now automatically added to the list also when just leaving the field)
- Improved that errors/messages from the API are shown properly when undoing a stock booking is not possible (stock journal page)
- Improved night mode CSS (done by @BlizzWave, thanks!)
- A new localization for `en_GB` is now always included - nothing is really translated there, it's only about component "translations" that e. g. the first day of the week is correct for calendars

View File

@@ -0,0 +1 @@
- Add possibility to have multiple barcodes per product

View File

@@ -0,0 +1,16 @@
- Fixed the messed up message/toast after consuming a product from the stock overview page
- Fixed that "Track date only" chores were always tracked today, regardless of the given date
- Fixed that the "week costs" were wrong after removing a meal plan entry
- Fixed wrong recipes costs calculation with nested recipes when the base recipe servings are > 1 (also affected the meal plan when adding such a recipe there)
- Fixed consuming recipes did not consume ingredients of the nested recipes
- Improved recipes API - added new endpoints to get stock fulfillment information (thanks @Aerex)
- Improved date display for products that never expires (instead of "2999-12-31" now just "Never" will be shown)
- Improved date display for dates of today and no time (instead of the hours since midnight now just "Today" will be shown)
- Improved shopping list handling
- Items can now be switched between lists (there is a shopping list dropdown on the item edit page)
- Items can now be marked as "done" (new check mark button per item, when clicked, the item will be displayed greyed out, when clicked again the item will be displayed normally again)
- Improved that products can now also be consumed as spoiled from the stock overview page (option in the more/context menu per line)
- Added a "consume this recipe"-button to the meal plan (and also a button to consume all recipes for a whole week)
- Added the possibility to undo a task (new button per task, only visible when task is already completed) and also a corresponding API endpoint
- Added a new `config.php` setting `DISABLE_AUTH` to be able to disable authentication / the login screen, defaults to `false`
- Added a new `config.php` setting `CALENDAR_FIRST_DAY_OF_WEEK` to be able to change the first day of a week used for calendar views (meal plan for example) in the frontend, defaults to locale default

View File

@@ -0,0 +1,6 @@
- Fixed that price data (last price & chart) was not taken from inventory correction bookings, only purchases
- Fixed weekly chores were scheduled on the same day after execution
- Fixed that undone chores were also included in "Last tracked"
- Fixed the date-time-picker width was too narrow sometimes
- Improved that execution dates of "Track date only" chores will never display the time part
- Improved date display for products that never expire (again, there was a display problem after consuming an item on the stock overview page)

View File

@@ -0,0 +1,107 @@
### New feature: Custom entities / objects / lists
- Custom entities are based on Userfields and can be used to add any custom lists you want to have in grocy
- They can have an own menu entry in the sidebar
- => See "Manage master data" -> "Userentities" or try it on the demo: https://demo.grocy.info/userobjects/exampleuserentity
### New feature: Use the device camera for barcode scanning
- Available on any barcode-enabled field (so currently only for picking products) - a new camera button at the right of side the text field
- Implemented using [QuaggaJS](https://github.com/serratus/quaggaJS) - camera stream processing happens totally offline / client-side
- Please note due to browser security restrictions, this only works when serving grocy via a secure connection (`https://`)
- There is also a `config.php` setting `DISABLE_BROWSER_BARCODE_CAMERA_SCANNING` to disable this, if you don't need it at all (defaults to `false`)
- I you have problems that barcodes are not recognized properly, there is a little "barcode scanner testing page" at [/barcodescannertesting](https://demo.grocy.info/barcodescannertesting)
- => 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)
- 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 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 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 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
- `FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING` to disable product opened tracking
- Fixed/refined some things regarding purchase/consume/inventory of products with enabled tare weight handling (nothing was broken, but the success popups may not displayed the correct amount that was posted)
- Fixed that "Spoil rate" and "Average shelf life" on the product card was wrong in most cases
- When going to the product edit page, after saving the product, it will now always return to the previous page
### Shopping list improvements
- Shopping lists now have a notes field (HTML/WYSIWYG editor, just to save some notes per shopping list)
- 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 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 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 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)
### Equipment improvements/fixes
- Fixed that the delete button not always deleted the currently selected equipment item
### Userfield improvements/fixes
- New Userfield type "Select list" for a list of predefined values where a single or also multiple values can then be selected on the entity object
- New Userfield type "Link" - a single-line-textbox where the content will be rendered as a clickable link
- Userfields of type "checkbox" are rendered as a checkmark in tables when checked (instead of "1" as till now)
- Product Userfields are now also rendered on the shopping list (for items which have a product referenced)
- Fixed that the Userfield type "Preset list" had always the caption "Product group" instead of the configured one (thanks @oncleben31)
### General & other improvements/fixes
- Added a new `config.php` setting `CALENDAR_SHOW_WEEK_OF_YEAR` to configure if calendars should show week numbers (defaults to `true`)
- Fixed that date/time pickers not considered the `config.php` setting `CALENDAR_FIRST_DAY_OF_WEEK`
- Improved the handling which entry page to use with disabled feature flags (thanks @nielstholenaar)
- 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 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 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)
### API improvements & non-breaking changes
- New endpoint `/objects/{entity}/search/{searchString}` to search for objects by name (contains search)
- New endpoint `/stock/shoppinglist/add-product` to add a product to a shopping list (thanks @Forceu)
- New endpoint `/stock/shoppinglist/remove-product` to remove a product from a shopping list (thanks @Forceu)
- New endpoint `/chores/executions/calculate-next-assignments` to (re)calculate next user assignments for a single or all chores
- New endpoint `/stock/products/by-barcode/{barcode}/add` to add a product to stock by its barcode
- New endpoint `/stock/products/by-barcode/{barcode}/consume` to remove a product to stock by its barcode
- New endpoint `/stock/products/by-barcode/{barcode}/inventory` to inventory a product by its barcode
- New endpoint `/stock/products/by-barcode/{barcode}/open` to mark a product as opened by its barcode
- New endpoint `/stock/bookings/{bookingId}` to retrieve a single stock booking
- Endpoint `GET /files/{group}/{fileName}` can now also downscale pictures (see API documentation on [/api](https://demo.grocy.info/api))
- When adding a product (through `stock/product/{productId}/add` or `stock/product/{productId}/inventory`) with omitted best before date and if the given product has "Default best before days" set, the best before date is calculated based on that (so far always today was used which is still the case when no date is supplied and also the product has no "Default best before days set) (thanks @Forceu)
- Field `stock_amount` of endpoint `/stock/products/{productId}` now returns `0` instead of `null` when the given product is not in stock (thanks @Forceu)
- Fixed that `/system/db-changed-time` always returned the current time (more or less) due to that that time is the database file modification time and the database is effectively changed on each request because of session information tracking - which now explicitly does not change the database file modification time, so this should work again to determine if any data changes happened
- It's now also possible to provide the API key via a query parameter (same name as the header, so `GROCY-API-KEY`)
#### Say thanks
Because there were some questions about that in the past: If grocy is useful for you, [say thanks](https://grocy.info/#say-thanks)!

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 intial 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 (Brazil) (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,28 @@
### 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
- 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-)
### Recipe fixes
- Fixed a PHP notice on the recipes page when there are no recipes (thanks @mrunkel)
### Calendar fixes
- Fixed that the "Share/Integrate calendar (iCal)" button did not work (thanks @tsia)
### API improvements
- 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)
### General & other improvements
- 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 (thanks @Mik-)
- The light button 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
- Various display/CSS improvements
- 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-)
- Optimized the handling of settings provided by `data/settingoverrides` files (thanks @dacto)

View File

@@ -0,0 +1 @@
- Ready to ERP your fridge!

View File

@@ -0,0 +1 @@
- Added flow to directly add products and barcodes from purchase and inventory view

View File

@@ -0,0 +1,2 @@
* New feature: Shopping list (which is also automatically filled based on defined min. stock amount)
* Small UI changes for better productivity

View File

@@ -0,0 +1 @@
- Added a flow to add a new product with prefilled barcode

View File

@@ -0,0 +1 @@
- Added a favicon and more productivity improvements

View File

@@ -1,10 +1,17 @@
{
"require": {
"php": ">=7.2",
"slim/slim": "^3.8",
"morris/lessql": "^0.3.4",
"slim/slim": "^4.0",
"slim/psr7": "^1.0",
"slim/http": "^1.0",
"php-di/php-di": "^6.0",
"rubellum/slim-blade-view": "^0.1.1",
"tuupola/cors-middleware": "^0.7.0"
"tuupola/cors-middleware": "^1.1",
"morris/lessql": "^0.4.1",
"gettext/gettext": "^4.8",
"eluceo/ical": "^0.16.0",
"erusev/parsedown": "^1.7",
"gumlet/php-image-resize": "^1.9"
},
"autoload": {
"psr-4": {

1457
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +1,52 @@
<?php
# Either "production", "dev" or "prerelease"
# 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"
# 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 filename (without extension) of
# one of the other available localization files in the "/localization" directory
# Either "en" or "de" or the directory name of
# one of the other available localization folders in the "/localization" directory
Setting('CULTURE', 'en');
# To keep it simpel, grocy does not handle any currency conversions,
# 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
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 can be anything (e. g. "USD" OR "$", doesn't matter...)
Setting('CURRENCY', '$');
# so doesn't really matter, but should be the
# ISO 4217 code of the currency ("USD", "EUR", "GBP", etc.)
Setting('CURRENCY', 'USD');
# When running grocy in a subdirectory, this should be set to the relative path, otherwise empty
# Example:
# Webserver root directory = /var/www
# grocy directory = /var/www/grocy
# => BASE_PATH = /grocy
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
# or for example "https://example.com/grocy" when using a subdirectory
Setting('BASE_URL', '/');
# The plugin to use for external barcode lookups,
@@ -22,6 +54,102 @@ Setting('BASE_URL', '/');
# 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, 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
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)
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
# Night mode related
DefaultUserSetting('night_mode_enabled', false); // If night mode is enabled always
DefaultUserSetting('auto_night_mode_enabled', false); // If night mode is enabled automatically when inside a given time range (see the two settings below)
DefaultUserSetting('auto_night_mode_time_range_from', "20:00"); // Format HH:mm
DefaultUserSetting('auto_night_mode_time_range_to', "07:00"); // Format HH:mm
DefaultUserSetting('auto_night_mode_time_range_goes_over_midnight', true); // If the time range above goes over midnight
DefaultUserSetting('currently_inside_night_mode_range', false); // If we're currently inside of night mode time range (this is not user configurable, but stored as a user setting because it's evaluated client side to be able to use the client time instead of the maybe different server time)
# Keep screen on settings
DefaultUserSetting('keep_screen_on', false); // Keep the screen always on
DefaultUserSetting('keep_screen_on_when_fullscreen_card', false); // Keep the screen on when a "fullscreen-card" is displayed
# 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_default_purchase_amount', 0);
DefaultUserSetting('stock_default_consume_amount', 1);
DefaultUserSetting('scan_mode_consume_enabled', false);
DefaultUserSetting('scan_mode_purchase_enabled', false);
# 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 best before days" set
DefaultUserSetting('shopping_list_show_calendar', false);
DefaultUserSetting('shopping_list_disable_auto_compact_view_on_mobile', 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
DefaultUserSetting('batteries_due_soon_days', 5);
# Tasks settings
DefaultUserSetting('tasks_due_soon_days', 5);
# If the page should be automatically reloaded when there was
# an external change
DefaultUserSetting('auto_reload_on_db_change', true);
# Show a clock in the header next to the logo or not
DefaultUserSetting('show_clock_in_header', false);
# 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);
Setting('FEATURE_FLAG_CHORES', true);
Setting('FEATURE_FLAG_TASKS', true);
Setting('FEATURE_FLAG_BATTERIES', true);
Setting('FEATURE_FLAG_EQUIPMENT', true);
Setting('FEATURE_FLAG_CALENDAR', true);
# 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_SHOPPINGLIST_MULTIPLE_LISTS', true);
Setting('FEATURE_FLAG_CHORES_ASSIGNMENTS', true);
# 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

View File

@@ -5,23 +5,36 @@ namespace Grocy\Controllers;
class BaseApiController extends BaseController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->OpenApiSpec = json_decode(file_get_contents(__DIR__ . '/../grocy.openapi.json'));
}
protected $OpenApiSpec;
protected $OpenApiSpec = null;
protected function ApiResponse($data)
protected function getOpenApispec()
{
return json_encode($data);
if($this->OpenApiSpec == null)
{
$this->OpenApiSpec = json_decode(file_get_contents(__DIR__ . '/../grocy.openapi.json'));
}
return $this->OpenApiSpec;
}
protected function VoidApiActionResponse($response, $success = true, $status = 200, $errorMessage = '')
protected function ApiResponse(\Psr\Http\Message\ResponseInterface $response, $data)
{
$response->getBody()->write(json_encode($data));
return $response;
}
protected function EmptyApiResponse(\Psr\Http\Message\ResponseInterface $response, $status = 204)
{
return $response->withStatus($status);
}
protected function GenericErrorResponse(\Psr\Http\Message\ResponseInterface $response, $errorMessage, $status = 400)
{
return $response->withStatus($status)->withJson(array(
'success' => $success,
'error_message' => $errorMessage
));
}

View File

@@ -5,46 +5,167 @@ namespace Grocy\Controllers;
use \Grocy\Services\DatabaseService;
use \Grocy\Services\ApplicationService;
use \Grocy\Services\LocalizationService;
use \Grocy\Services\StockService;
use \Grocy\Services\UsersService;
use \Grocy\Services\UserfieldsService;
use \Grocy\Services\BatteriesService;
use \Grocy\Services\CalendarService;
use \Grocy\Services\SessionService;
use \Grocy\Services\RecipesService;
use \Grocy\Services\TasksService;
use \Grocy\Services\FilesService;
use \Grocy\Services\ChoresService;
use \Grocy\Services\ApiKeyService;
class BaseController
{
public function __construct(\Slim\Container $container) {
$databaseService = new DatabaseService();
$this->Database = $databaseService->GetDbConnection();
$localizationService = new LocalizationService(GROCY_CULTURE);
$this->LocalizationService = $localizationService;
if (GROCY_MODE === 'prerelease')
{
$commitHash = trim(exec('git log --pretty="%h" -n1 HEAD'));
$commitDate = trim(exec('git log --date=iso --pretty="%cd" -n1 HEAD'));
$container->view->set('version', "pre-release-$commitHash");
$container->view->set('releaseDate', \substr($commitDate, 0, 19));
}
else
{
$applicationService = new ApplicationService();
$versionInfo = $applicationService->GetInstalledVersion();
$container->view->set('version', $versionInfo->Version);
$container->view->set('releaseDate', $versionInfo->ReleaseDate);
}
$container->view->set('localizationStrings', $localizationService->GetCurrentCultureLocalizations());
$container->view->set('L', function($text, ...$placeholderValues) use($localizationService)
{
return $localizationService->Localize($text, ...$placeholderValues);
});
$container->view->set('U', function($relativePath, $isResource = false) use($container)
{
return $container->UrlManager->ConstructUrl($relativePath, $isResource);
});
public function __construct(\DI\Container $container) {
$this->AppContainer = $container;
$this->View = $container->get('view');
}
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);
});
$this->View->set('__n', function($number, $singularForm, $pluralForm) use($localizationService)
{
return $localizationService->__n($number, $singularForm, $pluralForm);
});
$this->View->set('GettextPo', $localizationService->GetPoAsJsonString());
$this->View->set('U', function($relativePath, $isResource = false) use($container)
{
return $container->get('UrlManager')->ConstructUrl($relativePath, $isResource);
});
$embedded = false;
if (isset($_GET['embedded']))
{
$embedded = true;
}
$this->View->set('embedded', $embedded);
$constants = get_defined_constants();
foreach ($constants as $constant => $value)
{
if (substr($constant, 0, 19) !== 'GROCY_FEATURE_FLAG_')
{
unset($constants[$constant]);
}
}
$this->View->set('featureFlags', $constants);
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)
{
// Happens when database is not initialised or migrated...
}
return $this->render($response, $page, $data);
}
protected function getDatabaseService()
{
return DatabaseService::getInstance();
}
protected function getDatabase()
{
return $this->getDatabaseService()->GetDbConnection();
}
protected function getLocalizationService()
{
return LocalizationService::getInstance(GROCY_CULTURE);
}
protected function getApplicationservice()
{
return ApplicationService::getInstance();
}
protected function getBatteriesService()
{
return BatteriesService::getInstance();
}
protected function getCalendarService()
{
return CalendarService::getInstance();
}
protected function getSessionService()
{
return SessionService::getInstance();
}
protected function getRecipesService()
{
return RecipesService::getInstance();
}
protected function getStockService()
{
return StockService::getInstance();
}
protected function getTasksService()
{
return TasksService::getInstance();
}
protected function getUsersService()
{
return UsersService::getInstance();
}
protected function getUserfieldsService()
{
return UserfieldsService::getInstance();
}
protected function getApiKeyService()
{
return ApiKeyService::getInstance();
}
protected function getChoresService()
{
return ChoresService::getInstance();
}
protected function getFilesService()
{
return FilesService::getInstance();
}
protected $AppContainer;
protected $Database;
protected $LocalizationService;
}

View File

@@ -2,51 +2,61 @@
namespace Grocy\Controllers;
use \Grocy\Services\BatteriesService;
class BatteriesApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->BatteriesService = new BatteriesService();
}
protected $BatteriesService;
public function TrackChargeCycle(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function TrackChargeCycle(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$trackedTime = date('Y-m-d H:i:s');
if (isset($request->getQueryParams()['tracked_time']) && !empty($request->getQueryParams()['tracked_time']) && IsIsoDateTime($request->getQueryParams()['tracked_time']))
{
$trackedTime = $request->getQueryParams()['tracked_time'];
}
$requestBody = $request->getParsedBody();
try
{
$this->BatteriesService->TrackChargeCycle($args['batteryId'], $trackedTime);
return $this->VoidApiActionResponse($response);
$trackedTime = date('Y-m-d H:i:s');
if (array_key_exists('tracked_time', $requestBody) && IsIsoDateTime($requestBody['tracked_time']))
{
$trackedTime = $requestBody['tracked_time'];
}
$chargeCycleId = $this->getBatteriesService()->TrackChargeCycle($args['batteryId'], $trackedTime);
return $this->ApiResponse($response, $this->getDatabase()->battery_charge_cycles($chargeCycleId));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function BatteryDetails(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function BatteryDetails(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse($this->BatteriesService->GetBatteryDetails($args['batteryId']));
return $this->ApiResponse($response, $this->getBatteriesService()->GetBatteryDetails($args['batteryId']));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function Current(\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)
{
return $this->ApiResponse($this->BatteriesService->GetCurrent());
return $this->ApiResponse($response, $this->getBatteriesService()->GetCurrent());
}
public function UndoChargeCycle(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$this->ApiResponse($response, $this->getBatteriesService()->UndoChargeCycle($args['chargeCycleId']));
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}

View File

@@ -2,55 +2,72 @@
namespace Grocy\Controllers;
use \Grocy\Services\BatteriesService;
class BatteriesController extends BaseController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->BatteriesService = new BatteriesService();
}
protected $BatteriesService;
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)
{
return $this->AppContainer->view->render($response, 'batteriesoverview', [
'batteries' => $this->Database->batteries()->orderBy('name'),
'current' => $this->BatteriesService->GetCurrent(),
'nextXDays' => 5
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['batteries_due_soon_days'];
return $this->renderPage($response, 'batteriesoverview', [
'batteries' => $this->getDatabase()->batteries()->orderBy('name'),
'current' => $this->getBatteriesService()->GetCurrent(),
'nextXDays' => $nextXDays,
'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 TrackChargeCycle(\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, 'batterytracking', [
'batteries' => $this->getDatabase()->batteries()->orderBy('name')
]);
}
public function BatteriesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function BatteriesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'batteries', [
'batteries' => $this->Database->batteries()->orderBy('name')
return $this->renderPage($response, 'batteries', [
'batteries' => $this->getDatabase()->batteries()->orderBy('name'),
'userfields' => $this->getUserfieldsService()->GetFields('batteries'),
'userfieldValues' => $this->getUserfieldsService()->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', [
'mode' => 'create'
return $this->renderPage($response, 'batteryform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('batteries')
]);
}
else
{
return $this->AppContainer->view->render($response, 'batteryform', [
'battery' => $this->Database->batteries($args['batteryId']),
'mode' => 'edit'
return $this->renderPage($response, 'batteryform', [
'battery' => $this->getDatabase()->batteries($args['batteryId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('batteries')
]);
}
}
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'batteriesjournal', [
'chargeCycles' => $this->getDatabase()->battery_charge_cycles()->orderBy('tracked_time', 'DESC'),
'batteries' => $this->getDatabase()->batteries()->orderBy('name')
]);
}
public function BatteriesSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'batteriessettings');
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace Grocy\Controllers;
class CalendarApiController extends BaseApiController
{
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
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();
foreach($events as $event)
{
$date = new \DateTime($event['start']);
$date->setTimezone(date_default_timezone_get());
if ($event['date_format'] === 'date')
{
$date->setTime(23, 59, 59);
}
$vEvent = new \Eluceo\iCal\Component\Event();
$vEvent->setDtStart($date)
->setDtEnd($date)
->setSummary($event['title'])
->setDescription($event['description'])
->setNoTime($event['date_format'] === 'date')
->setUseTimezone(true);
$vCalendar->addComponent($vEvent);
}
$response->write($vCalendar->render());
$response = $response->withHeader('Content-Type', 'text/calendar; charset=utf-8');
return $response->withHeader('Content-Disposition', 'attachment; filename="grocy.ics"');
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function IcalSharingLink(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse($response, array(
'url' => $this->AppContainer->get('UrlManager')->ConstructUrl('/api/calendar/ical?secret=' . $this->getApiKeyService()->GetOrCreateApiKey(ApiKeyService::API_KEY_TYPE_SPECIAL_PURPOSE_CALENDAR_ICAL))
));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Grocy\Controllers;
class CalendarController extends BaseController
{
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'calendar', [
'fullcalendarEventSources' => $this->getCalendarService()->GetEvents()
]);
}
}

View File

@@ -2,57 +2,100 @@
namespace Grocy\Controllers;
use \Grocy\Services\ChoresService;
class ChoresApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->ChoresService = new ChoresService();
}
protected $ChoresService;
public function TrackChoreExecution(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function TrackChoreExecution(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$trackedTime = date('Y-m-d H:i:s');
if (isset($request->getQueryParams()['tracked_time']) && !empty($request->getQueryParams()['tracked_time']) && IsIsoDateTime($request->getQueryParams()['tracked_time']))
{
$trackedTime = $request->getQueryParams()['tracked_time'];
}
$doneBy = GROCY_USER_ID;
if (isset($request->getQueryParams()['done_by']) && !empty($request->getQueryParams()['done_by']))
{
$doneBy = $request->getQueryParams()['done_by'];
}
$requestBody = $request->getParsedBody();
try
{
$this->ChoresService->TrackChore($args['choreId'], $trackedTime, $doneBy);
return $this->VoidApiActionResponse($response);
$trackedTime = date('Y-m-d H:i:s');
if (array_key_exists('tracked_time', $requestBody) && (IsIsoDateTime($requestBody['tracked_time']) || IsIsoDate($requestBody['tracked_time'])))
{
$trackedTime = $requestBody['tracked_time'];
}
$doneBy = GROCY_USER_ID;
if (array_key_exists('done_by', $requestBody) && !empty($requestBody['done_by']))
{
$doneBy = $requestBody['done_by'];
}
$choreExecutionId = $this->getChoresService()->TrackChore($args['choreId'], $trackedTime, $doneBy);
return $this->ApiResponse($response, $this->getDatabase()->chores_log($choreExecutionId));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ChoreDetails(\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)
{
try
{
return $this->ApiResponse($this->ChoresService->GetChoreDetails($args['choreId']));
return $this->ApiResponse($response, $this->getChoresService()->GetChoreDetails($args['choreId']));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function Current(\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)
{
return $this->ApiResponse($this->ChoresService->GetCurrent());
return $this->ApiResponse($response, $this->getChoresService()->GetCurrent());
}
public function UndoChoreExecution(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$this->ApiResponse($response, $this->getChoresService()->UndoChoreExecution($args['executionId']));
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function CalculateNextExecutionAssignments(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$requestBody = $request->getParsedBody();
$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());
}
}
}

View File

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

View File

@@ -0,0 +1,41 @@
<?php
namespace Grocy\Controllers;
class EquipmentController extends BaseController
{
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
protected $UserfieldsService;
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'),
'userfields' => $this->getUserfieldsService()->GetFields('equipment'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('equipment')
]);
}
public function EditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['equipmentId'] == 'new')
{
return $this->renderPage($response, 'equipmentform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('equipment')
]);
}
else
{
return $this->renderPage($response, 'equipmentform', [
'equipment' => $this->getDatabase()->equipment($args['equipmentId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('equipment')
]);
}
}
}

View File

@@ -6,33 +6,117 @@ use \Grocy\Services\FilesService;
class FilesApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->FilesService = new FilesService();
}
protected $FilesService;
public function Upload(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function UploadFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
if (isset($request->getQueryParams()['file_name']) && !empty($request->getQueryParams()['file_name']) && IsValidFileName($request->getQueryParams()['file_name']))
if (IsValidFileName(base64_decode($args['fileName'])))
{
$fileName = $request->getQueryParams()['file_name'];
$fileName = base64_decode($args['fileName']);
}
else
{
throw new \Exception('file_name query parameter missing or contains an invalid filename');
throw new \Exception('Invalid filename');
}
$data = $request->getBody()->getContents();
file_put_contents($this->FilesService->GetFilePath($args['group'], $fileName), $data);
file_put_contents($this->getFilesService()->GetFilePath($args['group'], $fileName), $data);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ServeFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
if (IsValidFileName(base64_decode($args['fileName'])))
{
$fileName = base64_decode($args['fileName']);
}
else
{
throw new \Exception('Invalid filename');
}
$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->getFilesService()->DownscaleImage($args['group'], $fileName, $bestFitHeight, $bestFitWidth);
}
else
{
$filePath = $this->getFilesService()->GetFilePath($args['group'], $fileName);
}
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);
}
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function DeleteFile(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
if (IsValidFileName(base64_decode($args['fileName'])))
{
$fileName = base64_decode($args['fileName']);
}
else
{
throw new \Exception('Invalid filename');
}
$filePath = $this->getFilesService()->GetFilePath($args['group'], $fileName);
if (file_exists($filePath))
{
unlink($filePath);
}
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}

View File

@@ -4,77 +4,168 @@ namespace Grocy\Controllers;
class GenericEntityApiController extends BaseApiController
{
public function GetObjects(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function __construct(\DI\Container $container)
{
if ($this->IsValidEntity($args['entity']))
parent::__construct($container);
}
public function GetObjects(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
{
return $this->ApiResponse($this->Database->{$args['entity']}());
return $this->ApiResponse($response, $this->getDatabase()->{$args['entity']}());
}
else
{
return $this->VoidApiActionResponse($response, false, 400, 'Entity does not exist or is not exposed');
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)
public function GetObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($this->IsValidEntity($args['entity']))
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
{
return $this->ApiResponse($this->Database->{$args['entity']}($args['objectId']));
return $this->ApiResponse($response, $this->getDatabase()->{$args['entity']}($args['objectId']));
}
else
{
return $this->VoidApiActionResponse($response, false, 400, 'Entity does not exist or is not exposed');
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)
public function AddObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($this->IsValidEntity($args['entity']))
{
$newRow = $this->Database->{$args['entity']}()->createRow($request->getParsedBody());
$newRow->save();
$success = $newRow->isClean();
return $this->ApiResponse(array('success' => $success));
$requestBody = $request->getParsedBody();
try
{
if ($requestBody === null)
{
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
$newRow = $this->getDatabase()->{$args['entity']}()->createRow($requestBody);
$newRow->save();
$success = $newRow->isClean();
return $this->ApiResponse($response, array(
'created_object_id' => $this->getDatabase()->lastInsertId()
));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
else
{
return $this->VoidApiActionResponse($response, false, 400, 'Entity does not exist or is not exposed');
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
}
}
public function EditObject(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function EditObject(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($this->IsValidEntity($args['entity']))
{
$row = $this->Database->{$args['entity']}($args['objectId']);
$row->update($request->getParsedBody());
$success = $row->isClean();
return $this->ApiResponse(array('success' => $success));
$requestBody = $request->getParsedBody();
try
{
if ($requestBody === null)
{
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
$row = $this->getDatabase()->{$args['entity']}($args['objectId']);
$row->update($requestBody);
$success = $row->isClean();
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
else
{
return $this->VoidApiActionResponse($response, false, 400, 'Entity does not exist or is not exposed');
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
}
}
public function DeleteObject(\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']))
{
$row = $this->Database->{$args['entity']}($args['objectId']);
$row = $this->getDatabase()->{$args['entity']}($args['objectId']);
$row->delete();
$success = $row->isClean();
return $this->ApiResponse(array('success' => $success));
return $this->EmptyApiResponse($response);
}
else
{
return $this->VoidApiActionResponse($response, false, 400, 'Entity does not exist or is not exposed');
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function SearchObjects(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
{
try
{
return $this->ApiResponse($response, $this->getDatabase()->{$args['entity']}()->where('name LIKE ?', '%' . $args['searchString'] . '%'));
}
catch (\PDOException $ex)
{
return $this->GenericErrorResponse($response, 'The given entity has no field "name"');
}
}
else
{
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
}
}
public function GetUserfields(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse($response, $this->getUserfieldsService()->GetValues($args['entity'], $args['objectId']));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function SetUserfields(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
try
{
if ($requestBody === null)
{
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
$this->getUserfieldsService()->SetValues($args['entity'], $args['objectId'], $requestBody);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
private function IsValidEntity($entity)
{
return in_array($entity, $this->OpenApiSpec->components->internalSchemas->ExposedEntity->enum);
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntity->enum);
}
private function IsEntityWithPreventedListing($entity)
{
return !in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityButNoListing->enum);
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace Grocy\Controllers;
class GenericEntityController extends BaseController
{
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
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 UserentitiesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'userentities', [
'userentities' => $this->getDatabase()->userentities()->orderBy('name')
]);
}
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'])
]);
}
public function UserfieldEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['userfieldId'] == 'new')
{
return $this->renderPage($response, 'userfieldform', [
'mode' => 'create',
'userfieldTypes' => $this->getUserfieldsService()->GetFieldTypes(),
'entities' => $this->getUserfieldsService()->GetEntities()
]);
}
else
{
return $this->renderPage($response, 'userfieldform', [
'mode' => 'edit',
'userfield' => $this->getUserfieldsService()->GetField($args['userfieldId']),
'userfieldTypes' => $this->getUserfieldsService()->GetFieldTypes(),
'entities' => $this->getUserfieldsService()->GetEntities()
]);
}
}
public function UserentityEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['userentityId'] == 'new')
{
return $this->renderPage($response, 'userentityform', [
'mode' => 'create'
]);
}
else
{
return $this->renderPage($response, 'userentityform', [
'mode' => 'edit',
'userentity' => $this->getDatabase()->userentities($args['userentityId'])
]);
}
}
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'])
]);
}
}
}

View File

@@ -2,35 +2,28 @@
namespace Grocy\Controllers;
use \Grocy\Services\SessionService;
use \Grocy\Services\DatabaseMigrationService;
use \Grocy\Services\DemoDataGeneratorService;
class LoginController extends BaseController
{
public function __construct(\Slim\Container $container, string $sessionCookieName)
public function __construct(\DI\Container $container, string $sessionCookieName)
{
parent::__construct($container);
$this->SessionService = new SessionService();
$this->SessionCookieName = $sessionCookieName;
}
protected $SessionService;
protected $SessionCookieName;
public function ProcessLogin(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ProcessLogin(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$postParams = $request->getParsedBody();
if (isset($postParams['username']) && isset($postParams['password']))
{
$user = $this->Database->users()->where('username', $postParams['username'])->fetch();
$user = $this->getDatabase()->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, time() + 31220640000); // Cookie expires in 999 years, but session validity is up to SessionService
$sessionKey = $this->getSessionService()->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))
{
@@ -39,43 +32,28 @@ class LoginController extends BaseController
));
}
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/'));
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'));
}
}
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)
public function LoginPage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'login');
return $this->renderPage($response, 'login');
}
public function Logout(\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)
{
$this->SessionService->RemoveSession($_COOKIE[$this->SessionCookieName]);
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/'));
}
public function Root(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
// Schema migration is done here
$databaseMigrationService = new DatabaseMigrationService();
$databaseMigrationService->MigrateDatabase();
if (GROCY_IS_DEMO_INSTALL)
{
$demoDataGeneratorService = new DemoDataGeneratorService();
$demoDataGeneratorService->PopulateDemoData();
}
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/stockoverview'));
$this->getSessionService()->RemoveSession($_COOKIE[$this->SessionCookieName]);
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl('/'));
}
public function GetSessionCookieName()

View File

@@ -2,48 +2,42 @@
namespace Grocy\Controllers;
use \Grocy\Services\ApplicationService;
use \Grocy\Services\ApiKeyService;
class OpenApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->ApiKeyService = new ApiKeyService();
}
protected $ApiKeyService;
public function DocumentationUi(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function DocumentationUi(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'openapiui');
return $this->render($response, 'openapiui');
}
public function DocumentationSpec(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function DocumentationSpec(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$applicationService = new ApplicationService();
$applicationService = $this->getApplicationService();
$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');
$this->getOpenApiSpec()->info->version = $versionInfo->Version;
$this->getOpenApiSpec()->info->description = str_replace('PlaceHolderManageApiKeysUrl', $this->AppContainer->get('UrlManager')->ConstructUrl('/manageapikeys'), $this->getOpenApiSpec()->info->description);
$this->getOpenApiSpec()->servers[0]->url = $this->AppContainer->get('UrlManager')->ConstructUrl('/api');
return $this->ApiResponse($this->OpenApiSpec);
return $this->ApiResponse($response, $this->getOpenApiSpec());
}
public function ApiKeysList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ApiKeysList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'manageapikeys', [
'apiKeys' => $this->Database->api_keys(),
'users' => $this->Database->users()
return $this->renderPage($response, 'manageapikeys', [
'apiKeys' => $this->getDatabase()->api_keys(),
'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"));
}
}

View File

@@ -2,34 +2,62 @@
namespace Grocy\Controllers;
use \Grocy\Services\RecipesService;
class RecipesApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->RecipesService = new RecipesService();
}
protected $RecipesService;
public function AddNotFulfilledProductsToShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function AddNotFulfilledProductsToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$this->RecipesService->AddNotFulfilledProductsToShoppingList($args['recipeId']);
return $this->VoidApiActionResponse($response);
$requestBody = $request->getParsedBody();
$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(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ConsumeRecipe(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$this->RecipesService->ConsumeRecipe($args['recipeId']);
return $this->VoidApiActionResponse($response);
$this->getRecipesService()->ConsumeRecipe($args['recipeId']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
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->ApiResponse($response, $this->getRecipesService()->GetRecipesResolved());
}
$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());
}
}
}

View File

@@ -6,90 +6,161 @@ use \Grocy\Services\RecipesService;
class RecipesController extends BaseController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->RecipesService = new RecipesService();
}
protected $RecipesService;
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)
{
$recipes = $this->Database->recipes()->orderBy('name');
$recipes = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name');
$recipesResolved = $this->getRecipesService()->GetRecipesResolved();
$selectedRecipe = null;
$selectedRecipePositions = null;
$selectedRecipePositionsResolved = null;
if (isset($request->getQueryParams()['recipe']))
{
$selectedRecipe = $this->Database->recipes($request->getQueryParams()['recipe']);
$selectedRecipePositions = $this->Database->recipes_pos()->where('recipe_id', $request->getQueryParams()['recipe']);
$selectedRecipe = $this->getDatabase()->recipes($request->getQueryParams()['recipe']);
$selectedRecipePositionsResolved = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id = :1 AND is_nested_recipe_pos = 0', $request->getQueryParams()['recipe'])->orderBy('ingredient_group', 'ASC', 'product_group', 'ASC');
}
else
{
foreach ($recipes as $recipe)
{
$selectedRecipe = $recipe;
$selectedRecipePositions = $this->Database->recipes_pos()->where('recipe_id', $recipe->id);
$selectedRecipePositionsResolved = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id = :1 AND is_nested_recipe_pos = 0', $recipe->id)->orderBy('ingredient_group', 'ASC', 'product_group', 'ASC');
break;
}
}
return $this->AppContainer->view->render($response, 'recipes', [
$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')->fetchAll();
$selectedRecipeSubRecipesPositions = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id = :1', $selectedRecipe->id)->orderBy('ingredient_group', 'ASC', 'product_group', 'ASC')->fetchAll();
$includedRecipeIdsAbsolute = array();
$includedRecipeIdsAbsolute[] = $selectedRecipe->id;
foreach($selectedRecipeSubRecipes as $subRecipe)
{
$includedRecipeIdsAbsolute[] = $subRecipe->id;
}
return $this->renderPage($response, 'recipes', [
'recipes' => $recipes,
'recipesFulfillment' => $this->RecipesService->GetRecipesFulfillment(),
'recipesSumFulfillment' => $this->RecipesService->GetRecipesSumFulfillment(),
'recipesResolved' => $recipesResolved,
'recipePositionsResolved' => $this->getDatabase()->recipes_pos_resolved()->where('recipe_type', RecipesService::RECIPE_TYPE_NORMAL),
'selectedRecipe' => $selectedRecipe,
'selectedRecipePositions' => $selectedRecipePositions,
'products' => $this->Database->products(),
'quantityunits' => $this->Database->quantity_units()
'selectedRecipePositionsResolved' => $selectedRecipePositionsResolved,
'products' => $this->getDatabase()->products(),
'quantityUnits' => $this->getDatabase()->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->getUserfieldsService()->GetFields('recipes'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('recipes'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
]);
}
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()->createRow(array(
'name' => $this->LocalizationService->Localize('New recipe')
$newRecipe = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->createRow(array(
'name' => $this->getLocalizationService()->__t('New recipe')
));
$newRecipe->save();
$recipeId = $this->Database->lastInsertId();
$recipeId = $this->getDatabase()->lastInsertId();
}
return $this->AppContainer->view->render($response, 'recipeform', [
'recipe' => $this->Database->recipes($recipeId),
'recipePositions' => $this->Database->recipes_pos()->where('recipe_id', $recipeId),
return $this->renderPage($response, 'recipeform', [
'recipe' => $this->getDatabase()->recipes($recipeId),
'recipePositions' => $this->getDatabase()->recipes_pos()->where('recipe_id', $recipeId),
'mode' => 'edit',
'products' => $this->Database->products(),
'quantityunits' => $this->Database->quantity_units(),
'recipesFulfillment' => $this->RecipesService->GetRecipesFulfillment(),
'recipesSumFulfillment' => $this->RecipesService->GetRecipesSumFulfillment()
'products' => $this->getDatabase()->products()->orderBy('name'),
'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'),
'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']),
'products' => $this->Database->products()->orderBy('name'),
'quantityUnits' => $this->Database->quantity_units()->orderBy('name')
'recipe' => $this->getDatabase()->recipes($args['recipeId']),
'recipePos' => new \stdClass(),
'products' => $this->getDatabase()->products()->orderBy('name'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'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')
'recipe' => $this->getDatabase()->recipes($args['recipeId']),
'recipePos' => $this->getDatabase()->recipes_pos($args['recipePosId']),
'products' => $this->getDatabase()->products()->orderBy('name'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
]);
}
}
public function RecipesSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'recipessettings');
}
public function MealPlan(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$recipes = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll();
$events = array();
foreach($this->getDatabase()->meal_plan() 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[] = array(
'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()->whereNot('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll(),
'recipesResolved' => $this->getRecipesService()->GetRecipesResolved(),
'products' => $this->getDatabase()->products()->orderBy('name'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
]);
}
}

View File

@@ -6,119 +6,384 @@ use \Grocy\Services\StockService;
class StockApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->StockService = new StockService();
}
protected $StockService;
public function ProductDetails(\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
{
return $this->ApiResponse($this->StockService->GetProductDetails($args['productId']));
return $this->ApiResponse($response, $this->getStockService()->GetProductDetails($args['productId']));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ProductPriceHistory(\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
{
return $this->ApiResponse($this->StockService->GetProductPriceHistory($args['productId']));
$productId = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->ApiResponse($response, $this->getStockService()->GetProductDetails($productId));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function AddProduct(\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)
{
$bestBeforeDate = date('Y-m-d');
if (isset($request->getQueryParams()['bestbeforedate']) && !empty($request->getQueryParams()['bestbeforedate']) && IsIsoDate($request->getQueryParams()['bestbeforedate']))
try
{
$bestBeforeDate = $request->getQueryParams()['bestbeforedate'];
return $this->ApiResponse($response, $this->getStockService()->GetProductPriceHistory($args['productId']));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
$price = null;
if (isset($request->getQueryParams()['price']) && !empty($request->getQueryParams()['price']) && is_numeric($request->getQueryParams()['price']))
{
$price = $request->getQueryParams()['price'];
}
$transactionType = StockService::TRANSACTION_TYPE_PURCHASE;
if (isset($request->getQueryParams()['transactiontype']) && !empty($request->getQueryParams()['transactiontype']))
{
$transactionType = $request->getQueryParams()['transactiontype'];
}
public function AddProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
try
{
$this->StockService->AddProduct($args['productId'], $args['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price);
return $this->VoidApiActionResponse($response);
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'];
}
$transactionType = StockService::TRANSACTION_TYPE_PURCHASE;
if (array_key_exists('transaction_type', $requestBody) && !empty($requestBody['transactiontype']))
{
$transactionType = $requestBody['transactiontype'];
}
$bookingId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price, $locationId);
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ConsumeProduct(\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)
{
$spoiled = false;
if (isset($request->getQueryParams()['spoiled']) && !empty($request->getQueryParams()['spoiled']) && $request->getQueryParams()['spoiled'] == '1')
try
{
$spoiled = true;
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->AddProduct($request, $response, $args);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
$transactionType = StockService::TRANSACTION_TYPE_CONSUME;
if (isset($request->getQueryParams()['transactiontype']) && !empty($request->getQueryParams()['transactiontype']))
{
$transactionType = $request->getQueryParams()['transactiontype'];
}
public function EditStockEntry(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
try
{
$this->StockService->ConsumeProduct($args['productId'], $args['amount'], $spoiled, $transactionType);
return $this->VoidApiActionResponse($response);
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'];
}
$bookingId = $this->getStockService()->EditStockEntry($args['entryId'], $requestBody['amount'], $bestBeforeDate, $locationId, $price, $requestBody['open'], $requestBody['purchased_date']);
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function InventoryProduct(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function TransferProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$bestBeforeDate = date('Y-m-d');
if (isset($request->getQueryParams()['bestbeforedate']) && !empty($request->getQueryParams()['bestbeforedate']) && IsIsoDate($request->getQueryParams()['bestbeforedate']))
{
$bestBeforeDate = $request->getQueryParams()['bestbeforedate'];
}
$requestBody = $request->getParsedBody();
try
{
$this->StockService->InventoryProduct($args['productId'], $args['newAmount'], $bestBeforeDate);
return $this->VoidApiActionResponse($response);
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'];
}
$bookingId = $this->getStockService()->TransferProduct($args['productId'], $requestBody['amount'], $requestBody['location_id_from'], $requestBody['location_id_to'], $specificStockEntryId);
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function CurrentStock(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function TransferProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->ApiResponse($this->StockService->GetCurrentStock());
try
{
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->TransferProduct($request, $response, $args);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function CurrentVolatilStock(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ConsumeProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
$result = null;
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');
}
$spoiled = false;
if (array_key_exists('spoiled', $requestBody))
{
$spoiled = $requestBody['spoiled'];
}
$transactionType = StockService::TRANSACTION_TYPE_CONSUME;
if (array_key_exists('transaction_type', $requestBody) && !empty($requestBody['transactiontype']))
{
$transactionType = $requestBody['transactiontype'];
}
$specificStockEntryId = 'default';
if (array_key_exists('stock_entry_id', $requestBody) && !empty($requestBody['stock_entry_id']))
{
$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->getStockService()->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId, $locationId);
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
}
catch (\Exception $ex)
{
$result = $this->GenericErrorResponse($response, $ex->getMessage());
}
return $result;
}
public function ConsumeProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->ConsumeProduct($request, $response, $args);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function InventoryProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
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('new_amount', $requestBody))
{
throw new \Exception('An new amount is required');
}
$bestBeforeDate = null;
if (array_key_exists('best_before_date', $requestBody) && IsIsoDate($requestBody['best_before_date']))
{
$bestBeforeDate = $requestBody['best_before_date'];
}
$locationId = null;
if (array_key_exists('location_id', $requestBody) && is_numeric($requestBody['location_id']))
{
$locationId = $requestBody['location_id'];
}
$price = null;
if (array_key_exists('price', $requestBody) && is_numeric($requestBody['price']))
{
$price = $requestBody['price'];
}
$bookingId = $this->getStockService()->InventoryProduct($args['productId'], $requestBody['new_amount'], $bestBeforeDate, $locationId, $price);
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function InventoryProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->InventoryProduct($request, $response, $args);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function OpenProduct(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$requestBody = $request->getParsedBody();
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');
}
$specificStockEntryId = 'default';
if (array_key_exists('stock_entry_id', $requestBody) && !empty($requestBody['stock_entry_id']))
{
$specificStockEntryId = $requestBody['stock_entry_id'];
}
$bookingId = $this->getStockService()->OpenProduct($args['productId'], $requestBody['amount'], $specificStockEntryId);
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function OpenProductByBarcode(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
return $this->OpenProduct($request, $response, $args);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function CurrentStock(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->ApiResponse($response, $this->getStockService()->GetCurrentStock());
}
public function CurrentVolatileStock(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$nextXDays = 5;
if (isset($request->getQueryParams()['expiring_days']) && !empty($request->getQueryParams()['expiring_days']) && is_numeric($request->getQueryParams()['expiring_days']))
@@ -126,29 +391,137 @@ class StockApiController extends BaseApiController
$nextXDays = $request->getQueryParams()['expiring_days'];
}
$expiringProducts = $this->StockService->GetExpiringProducts($nextXDays);
$expiredProducts = $this->StockService->GetExpiringProducts(-1);
$missingProducts = $this->StockService->GetMissingProducts();
return $this->ApiResponse(array(
$expiringProducts = $this->getStockService()->GetExpiringProducts($nextXDays, true);
$expiredProducts = $this->getStockService()->GetExpiringProducts(-1);
$missingProducts = $this->getStockService()->GetMissingProducts();
return $this->ApiResponse($response, 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 AddMissingProductsToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$this->StockService->AddMissingProductsToShoppingList();
return $this->VoidApiActionResponse($response);
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->getStockService()->AddMissingProductsToShoppingList($listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ClearShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ClearShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$this->StockService->ClearShoppingList();
return $this->VoidApiActionResponse($response);
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->getStockService()->ClearShoppingList($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)
public function AddProductToShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$requestBody = $request->getParsedBody();
$listId = 1;
$amount = 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 ($productId == null)
{
throw new \Exception("No product id was supplied");
}
$this->getStockService()->AddProductToShoppingList($productId, $amount, $note, $listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function RemoveProductFromShoppingList(\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->getStockService()->RemoveProductFromShoppingList($productId, $amount, $listId);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function ExternalBarcodeLookup(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
@@ -158,11 +531,96 @@ class StockApiController extends BaseApiController
$addFoundProduct = true;
}
return $this->ApiResponse($this->StockService->ExternalBarcodeLookup($args['barcode'], $addFoundProduct));
return $this->ApiResponse($response, $this->getStockService()->ExternalBarcodeLookup($args['barcode'], $addFoundProduct));
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function UndoBooking(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
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)
{
try
{
$this->ApiResponse($response, $this->getStockService()->UndoTransaction($args['transactionId']));
return $this->EmptyApiResponse($response);
}
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))
{
$allowSubproductSubstitution = true;
}
return $this->ApiResponse($response, $this->getStockService()->GetProductStockEntries($args['productId'], false, $allowSubproductSubstitution));
}
public function ProductStockLocations(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->ApiResponse($response, $this->getStockService()->GetProductStockLocations($args['productId']));
}
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 StockBooking(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$stockLogRow = $this->getDatabase()->stock_log($args['bookingId']);
if ($stockLogRow === null)
{
throw new \Exception('Stock booking does not exist');
}
return $this->ApiResponse($response, $stockLogRow);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
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());
}
}
}

View File

@@ -2,184 +2,364 @@
namespace Grocy\Controllers;
use \Grocy\Services\StockService;
class StockController extends BaseController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->StockService = new StockService();
}
protected $StockService;
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)
{
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(),
'missingProducts' => $this->StockService->GetMissingProducts(),
'nextXDays' => 5
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
return $this->renderPage($response, 'stockoverview', [
'products' => $this->getDatabase()->products()->orderBy('name'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'currentStock' => $this->getStockService()->GetCurrentStock(true),
'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(),
'missingProducts' => $this->getStockService()->GetMissingProducts(),
'nextXDays' => $nextXDays,
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
]);
}
public function Purchase(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Stockentries(\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')
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
return $this->renderPage($response, 'stockentries', [
'products' => $this->getDatabase()->products()->orderBy('name'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'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 Consume(\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->AppContainer->view->render($response, 'consume', [
'products' => $this->Database->products()->orderBy('name')
return $this->renderPage($response, 'purchase', [
'products' => $this->getDatabase()->products()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->orderBy('name')
]);
}
public function Inventory(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Consume(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'inventory', [
'products' => $this->Database->products()->orderBy('name')
return $this->renderPage($response, 'consume', [
'products' => $this->getDatabase()->products()->orderBy('name'),
'recipes' => $this->getDatabase()->recipes()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->orderBy('name')
]);
}
public function ShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function Transfer(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->AppContainer->view->render($response, 'shoppinglist', [
'listItems' => $this->Database->shopping_list(),
'products' => $this->Database->products()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'missingProducts' => $this->StockService->GetMissingProducts(),
'productGroups' => $this->Database->product_groups()->orderBy('name')
return $this->renderPage($response, 'transfer', [
'products' => $this->getDatabase()->products()->orderBy('name'),
'recipes' => $this->getDatabase()->recipes()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->orderBy('name')
]);
}
public function ProductsList(\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, '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')
return $this->renderPage($response, 'inventory', [
'products' => $this->getDatabase()->products()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->orderBy('name')
]);
}
public function LocationsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function StockEntryEditForm(\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')
return $this->renderPage($response, 'stockentryform', [
'stockEntry' => $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch(),
'products' => $this->getDatabase()->products()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->orderBy('name')
]);
}
public function ProductGroupsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ShoppingList(\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')
$listId = 1;
if (isset($request->getQueryParams()['list']))
{
$listId = $request->getQueryParams()['list'];
}
return $this->renderPage($response, 'shoppinglist', [
'listItems' => $this->getDatabase()->shopping_list()->where('shopping_list_id = :1', $listId),
'products' => $this->getDatabase()->products()->orderBy('name'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'missingProducts' => $this->getStockService()->GetMissingProducts(),
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
'selectedShoppingListId' => $listId,
'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 ProductsList(\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')
return $this->renderPage($response, 'products', [
'products' => $this->getDatabase()->products()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
]);
}
public function ProductEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
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'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name')
]);
}
public function LocationsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'locations', [
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'userfields' => $this->getUserfieldsService()->GetFields('locations'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('locations')
]);
}
public function ProductGroupsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'productgroups', [
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
'products' => $this->getDatabase()->products()->orderBy('name'),
'userfields' => $this->getUserfieldsService()->GetFields('product_groups'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('product_groups')
]);
}
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'),
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('quantity_units')
]);
}
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'),
return $this->renderPage($response, 'productform', [
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'products' => $this->getDatabase()->products()->where('parent_product_id IS NULL')->orderBy('name'),
'isSubProductOfOthers' => false,
'mode' => 'create'
]);
}
else
{
return $this->AppContainer->view->render($response, 'productform', [
'product' => $this->Database->products($args['productId']),
'locations' => $this->Database->locations()->orderBy('name'),
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
'productgroups' => $this->Database->product_groups()->orderBy('name'),
'mode' => 'edit'
$product = $this->getDatabase()->products($args['productId']);
return $this->renderPage($response, 'productform', [
'product' => $product,
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name'),
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'products' => $this->getDatabase()->products()->where('id != :1 AND parent_product_id IS NULL', $product->id)->orderBy('name'),
'isSubProductOfOthers' => $this->getDatabase()->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
'mode' => 'edit',
'quConversions' => $this->getDatabase()->quantity_unit_conversions()
]);
}
}
public function LocationEditForm(\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)
{
if ($args['locationId'] == 'new')
{
return $this->AppContainer->view->render($response, 'locationform', [
'mode' => 'create'
return $this->renderPage($response, 'locationform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('locations')
]);
}
else
{
return $this->AppContainer->view->render($response, 'locationform', [
'location' => $this->Database->locations($args['locationId']),
'mode' => 'edit'
return $this->renderPage($response, 'locationform', [
'location' => $this->getDatabase()->locations($args['locationId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('locations')
]);
}
}
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', [
'mode' => 'create'
return $this->renderPage($response, 'productgroupform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
]);
}
else
{
return $this->AppContainer->view->render($response, 'productgroupform', [
'group' => $this->Database->product_groups($args['productGroupId']),
'mode' => 'edit'
return $this->renderPage($response, 'productgroupform', [
'group' => $this->getDatabase()->product_groups($args['productGroupId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
]);
}
}
public function QuantityUnitEditForm(\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)
{
if ($args['quantityunitId'] == 'new')
{
return $this->AppContainer->view->render($response, 'quantityunitform', [
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 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()->orderBy('name'),
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
'mode' => 'create'
]);
}
else
{
return $this->AppContainer->view->render($response, 'quantityunitform', [
'quantityunit' => $this->Database->quantity_units($args['quantityunitId']),
return $this->renderPage($response, 'shoppinglistitemform', [
'listItem' => $this->getDatabase()->shopping_list($args['itemId']),
'products' => $this->getDatabase()->products()->orderBy('name'),
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
'mode' => 'edit'
]);
}
}
public function ShoppingListItemEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function ShoppingListEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['itemId'] == 'new')
if ($args['listId'] == 'new')
{
return $this->AppContainer->view->render($response, 'shoppinglistform', [
'products' => $this->Database->products()->orderBy('name'),
return $this->renderPage($response, 'shoppinglistform', [
'mode' => 'create'
]);
}
else
{
return $this->AppContainer->view->render($response, 'shoppinglistform', [
'listItem' => $this->Database->shopping_list($args['itemId']),
'products' => $this->Database->products()->orderBy('name'),
return $this->renderPage($response, 'shoppinglistform', [
'shoppingList' => $this->getDatabase()->shopping_lists($args['listId']),
'mode' => 'edit'
]);
}
}
public function ShoppingListSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'shoppinglistsettings');
}
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'stockjournal', [
'stockLog' => $this->getDatabase()->stock_log()->orderBy('row_created_timestamp', 'DESC'),
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'products' => $this->getDatabase()->products()->orderBy('name'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name')
]);
}
public function LocationContentSheet(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'locationcontentsheet', [
'products' => $this->getDatabase()->products()->orderBy('name'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent()
]);
}
public function QuantityUnitConversionEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$product = null;
if (isset($request->getQueryParams()['product']))
{
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
}
$defaultQuUnit = null;
if (isset($request->getQueryParams()['qu-unit']))
{
$defaultQuUnit = $this->getDatabase()->quantity_units($request->getQueryParams()['qu-unit']);
}
if ($args['quConversionId'] == 'new')
{
return $this->renderPage($response, 'quantityunitconversionform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'product' => $product,
'defaultQuUnit' => $defaultQuUnit
]);
}
else
{
return $this->renderPage($response, 'quantityunitconversionform', [
'quConversion' => $this->getDatabase()->quantity_unit_conversions($args['quConversionId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
'product' => $product,
'defaultQuUnit' => $defaultQuUnit
]);
}
}
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')
]);
}
}

View File

@@ -2,22 +2,40 @@
namespace Grocy\Controllers;
use \Grocy\Services\DatabaseService;
class SystemApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->DatabaseService = new DatabaseService();
}
protected $DatabaseService;
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, array(
'changed_time' => $this->getDatabaseService()->GetDbChangedTime()
));
}
public function LogMissingLocalization(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if (GROCY_MODE === 'dev')
{
try
{
$requestBody = $request->getParsedBody();
$this->getLocalizationService()->CheckAndAddMissingTranslationToPot($requestBody['text']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}
public function GetSystemInfo(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemInfo());
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace Grocy\Controllers;
use \Grocy\Services\DatabaseMigrationService;
use \Grocy\Services\DemoDataGeneratorService;
class SystemController extends BaseController
{
public function __construct(\DI\Container $container)
{
parent::__construct($container);
}
public function Root(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
// Schema migration is done here
$databaseMigrationService = DatabaseMigrationService::getInstance();
$databaseMigrationService->MigrateDatabase();
if (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
{
$demoDataGeneratorService = DemoDataGeneratorService::getInstance();
$demoDataGeneratorService->PopulateDemoData();
}
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl($this->GetEntryPageRelative()));
}
/**
* Get the entry page of the application based on the value of the entry page setting.
*
* We fallback to the about page when no entry page is specified or
* when the specified entry page has been disabled.
*
* @return string
*/
private function GetEntryPageRelative()
{
if (defined('GROCY_ENTRY_PAGE')) {
$entryPage = constant('GROCY_ENTRY_PAGE');
} else {
$entryPage = 'stock';
}
// Stock
if ($entryPage === 'stock' && constant('GROCY_FEATURE_FLAG_STOCK')) {
return '/stockoverview';
}
// Shoppinglist
if ($entryPage === 'shoppinglist' && constant('GROCY_FEATURE_FLAG_SHOPPINGLIST')) {
return '/shoppinglist';
}
// Recipes
if ($entryPage === 'recipes' && constant('GROCY_FEATURE_FLAG_RECIPES')) {
return '/recipes';
}
// Chores
if ($entryPage === 'chores' && constant('GROCY_FEATURE_FLAG_CHORES')) {
return '/choresoverview';
}
// Tasks
if ($entryPage === 'tasks' && constant('GROCY_FEATURE_FLAG_TASKS')) {
return '/tasks';
}
// Batteries
if ($entryPage === 'batteries' && constant('GROCY_FEATURE_FLAG_BATTERIES')) {
return '/batteriesoverview';
}
if ($entryPage === 'equipment' && constant('GROCY_FEATURE_FLAG_EQUIPMENT')) {
return '/equipment';
}
// 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(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'about', [
'system_info' => $this->getApplicationService()->GetSystemInfo(),
'changelog' => $this->getApplicationService()->GetChangelog()
]);
}
public function BarcodeScannerTesting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'barcodescannertesting');
}
}

View File

@@ -2,39 +2,49 @@
namespace Grocy\Controllers;
use \Grocy\Services\TasksService;
class TasksApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\Container $container)
{
parent::__construct($container);
$this->TasksService = new TasksService();
}
protected $TasksService;
public function Current(\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)
{
return $this->ApiResponse($this->TasksService->GetCurrent());
return $this->ApiResponse($response, $this->getTasksService()->GetCurrent());
}
public function MarkTaskAsCompleted(\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)
{
$doneTime = date('Y-m-d H:i:s');
if (isset($request->getQueryParams()['done_time']) && !empty($request->getQueryParams()['done_time']) && IsIsoDateTime($request->getQueryParams()['done_time']))
{
$doneTime = $request->getQueryParams()['done_time'];
}
$requestBody = $request->getParsedBody();
try
{
$this->TasksService->MarkTaskAsCompleted($args['taskId'], $doneTime);
return $this->VoidApiActionResponse($response);
$doneTime = date('Y-m-d H:i:s');
if (array_key_exists('done_time', $requestBody) && IsIsoDateTime($requestBody['done_time']))
{
$doneTime = $requestBody['done_time'];
}
$this->getTasksService()->MarkTaskAsCompleted($args['taskId'], $doneTime);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function UndoTask(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$this->getTasksService()->UndoTask($args['taskId']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}

View File

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

View File

@@ -2,70 +2,98 @@
namespace Grocy\Controllers;
use \Grocy\Services\UsersService;
class UsersApiController extends BaseApiController
{
public function __construct(\Slim\Container $container)
public function __construct(\DI\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 GetUsers(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
return $this->ApiResponse($this->UsersService->GetUsersAsDto());
return $this->ApiResponse($response, $this->getUsersService()->GetUsersAsDto());
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
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();
try
{
$this->UsersService->CreateUser($requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
return $this->ApiResponse(array('success' => true));
if ($requestBody === null)
{
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
}
$this->getUsersService()->CreateUser($requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
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)
{
try
{
$this->UsersService->DeleteUser($args['userId']);
return $this->ApiResponse(array('success' => true));
$this->getUsersService()->DeleteUser($args['userId']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
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();
try
{
$this->UsersService->EditUser($args['userId'], $requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
return $this->ApiResponse(array('success' => true));
$this->getUsersService()->EditUser($args['userId'], $requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
public function GetUserSetting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
{
$value = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, $args['settingKey']);
return $this->ApiResponse($response, array('value' => $value));
}
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 = $request->getParsedBody();
$value = $this->getUsersService()->SetUserSetting(GROCY_USER_ID, $args['settingKey'], $requestBody['value']);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)
{
return $this->GenericErrorResponse($response, $ex->getMessage());
}
}
}

View File

@@ -4,25 +4,25 @@ namespace Grocy\Controllers;
class UsersController extends BaseController
{
public function UsersList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
public function UsersList(\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')
return $this->renderPage($response, 'users', [
'users' => $this->getDatabase()->users()->orderBy('username')
]);
}
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', [
return $this->renderPage($response, 'userform', [
'mode' => 'create'
]);
}
else
{
return $this->AppContainer->view->render($response, 'userform', [
'user' => $this->Database->users($args['userId']),
return $this->renderPage($response, 'userform', [
'user' => $this->getDatabase()->users($args['userId']),
'mode' => 'edit'
]);
}

View File

@@ -1,2 +0,0 @@
*
!.gitignore

File diff suppressed because it is too large Load Diff

View File

@@ -82,16 +82,26 @@ function SumArrayValue($array, $propertyName)
$sum = 0;
foreach($array as $object)
{
$sum += $object->{$propertyName};
$sum += floatval($object->{$propertyName});
}
return $sum;
}
function GetClassConstants($className)
function GetClassConstants($className, $prefix = null)
{
$r = new ReflectionClass($className);
return $r->getConstants();
$constants = $r->getConstants();
if ($prefix === null)
{
return $constants;
}
else
{
$matchingKeys = preg_grep('!^' . $prefix . '!', array_keys($constants));
return array_intersect_key($constants, array_flip($matchingKeys));
}
}
function RandomString($length, $allowedChars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
@@ -138,6 +148,21 @@ function Setting(string $name, $value)
{
define('GROCY_' . $name, file_get_contents($settingOverrideFile));
}
elseif (getenv('GROCY_' . $name) !== false) // An environment variable with the same name and prefix GROCY_ overwrites the given setting
{
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));
}
}
else
{
define('GROCY_' . $name, $value);
@@ -145,6 +170,17 @@ function Setting(string $name, $value)
}
}
global $GROCY_DEFAULT_USER_SETTINGS;
$GROCY_DEFAULT_USER_SETTINGS = array();
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;
}
}
function GetUserDisplayName($user)
{
$displayName = '';
@@ -169,22 +205,34 @@ function GetUserDisplayName($user)
return $displayName;
}
function Pluralize($number, $singularForm, $pluralForm)
{
$text = $singularForm;
if ($number != 1 && $pluralForm !== null && !empty($pluralForm))
{
$text = $pluralForm;
}
return $text;
}
function IsValidFileName($fileName)
{
if(preg_match('#^[a-z0-9]+\.[a-z]+?$#i', $fileName))
if(preg_match('=^[^/?*;:{}\\\\]+\.[^/?*;:{}\\\\]+$=', $fileName))
{
return true;
}
return false;
}
function IsJsonString($text)
{
json_decode($text);
return (json_last_error() == JSON_ERROR_NONE);
}
function string_starts_with($haystack, $needle)
{
return (substr($haystack, 0, strlen($needle)) === $needle);
}
function string_ends_with($haystack, $needle)
{
$length = strlen($needle);
if ($length == 0)
{
return true;
}
return (substr($haystack, -$length) === $needle);
}

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