mirror of
https://github.com/grocy/grocy.git
synced 2025-09-16 17:56:51 +00:00
Compare commits
88 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9cd0e4ab2d | ||
|
6b38cd450f | ||
|
bb60f5f043 | ||
|
e777be4d3b | ||
|
8a71d55f0f | ||
|
b01b49d10c | ||
|
496594d898 | ||
|
1d5e82c341 | ||
|
a9b696f41c | ||
|
e50b1eb359 | ||
|
92e0245387 | ||
|
67d0d3c3d6 | ||
|
23bcbc23e9 | ||
|
085d9a0bc7 | ||
|
368df142cf | ||
|
d38edabb14 | ||
|
4426a10e2e | ||
|
931dc9d243 | ||
|
c5b8893008 | ||
|
c27f41aee4 | ||
|
ef043b38ce | ||
|
bb261f99c4 | ||
|
48ca0f2ac7 | ||
|
b7f0b06684 | ||
|
324487d395 | ||
|
9a8c61497b | ||
|
bc7afe4bdd | ||
|
bb5dcb2434 | ||
|
71b9d11ff5 | ||
|
3e73a44576 | ||
|
dedfe3a854 | ||
|
c4b0ef4d49 | ||
|
339d81318f | ||
|
282ee0885b | ||
|
5833364e51 | ||
|
525f1705d1 | ||
|
5a13cb5ffe | ||
|
e830805443 | ||
|
ca3f28b615 | ||
|
6081b8ee67 | ||
|
7eef4acd81 | ||
|
678579e933 | ||
|
4cc2d39063 | ||
|
14cc153422 | ||
|
f5b5c4c7e1 | ||
|
88b76a52a5 | ||
|
a4a25af460 | ||
|
41a72d11da | ||
|
c8236b101b | ||
|
ef1df0a446 | ||
|
5c4953b9b2 | ||
|
ccaf2411fe | ||
|
bce8bd6b35 | ||
|
66c07887cb | ||
|
be99880ce4 | ||
|
e026609972 | ||
|
3474f55866 | ||
|
f583810d5c | ||
|
419445f5ae | ||
|
c64eb27ca1 | ||
|
f4eb5196f7 | ||
|
9e493430d8 | ||
|
7690eedd70 | ||
|
aaa270a52f | ||
|
6f47a5415c | ||
|
42c1709633 | ||
|
4685ff4145 | ||
|
249b01d7a8 | ||
|
bcbdf58376 | ||
|
7f8540ff4e | ||
|
b52ab91606 | ||
|
7246ac55b6 | ||
|
848931da21 | ||
|
bf4092e746 | ||
|
7cee18c926 | ||
|
e9a4b43268 | ||
|
b1522742cc | ||
|
ecdaaab789 | ||
|
3379942086 | ||
|
12eaa8c074 | ||
|
c6310d636d | ||
|
9bedc6a138 | ||
|
70dbc6018f | ||
|
3afeb44b1d | ||
|
3131b8965e | ||
|
bbc2fc9e42 | ||
|
3b4141eb4d | ||
|
5f826be82c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/public/node_modules
|
||||
/vendor
|
||||
/.release
|
||||
embedded.txt
|
34
README.md
34
README.md
@@ -5,22 +5,27 @@ ERP beyond your fridge
|
||||
Public demo of the latest version → [https://demo.grocy.info](https://demo.grocy.info)
|
||||
|
||||
## 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.
|
||||
|
||||
## What it is about
|
||||
For now my main focus is on stock management, 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 houshold management"-thing. ERP your fridge!
|
||||
|
||||
## How to install
|
||||
Just unpack the [latest release](https://github.com/berrnd/grocy/releases/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.
|
||||
> **NEW**
|
||||
>
|
||||
> 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"...
|
||||
|
||||
Default login is user `admin` with password `admin` - see the `data/config.php` file. Alternatively clone this repository and install Composer and Yarn dependencies manually.
|
||||
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).
|
||||
|
||||
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, 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 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`.
|
||||
|
||||
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');`)
|
||||
@@ -39,10 +44,12 @@ Some fields also allow to select a value by scanning a barcode. It works best wh
|
||||
### Input shorthands for date fields
|
||||
For (productivity) reasons all date (and time) input 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 in proper notation
|
||||
- `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`
|
||||
- `YYYYMMDD` gets expanded to the proper ISO-8601 notation
|
||||
- Example: `20190417` will be converted to `2019-04-17`
|
||||
- `YYYYMMe` or `YYYYMM+` gets expanded to the end of the given month in the given year in proper notation
|
||||
- Example: `201807e` will be converted to `2018-07-31`
|
||||
- `x` gets expanded to `2999-12-31` (which I use for products which never expire)
|
||||
- Down/up arrow keys will increase/decrease the date by one day
|
||||
- Right/left arrow keys will increase/decrease the date by 1 week
|
||||
@@ -59,13 +66,18 @@ 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).
|
||||
|
||||
### 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.
|
||||
|
||||
### 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.
|
||||
|
||||
### 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)).
|
||||
|
||||
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).
|
||||
|
||||
## Screenshots
|
||||
#### Dashboard
|
||||

|
||||
|
42
app.php
42
app.php
@@ -6,8 +6,38 @@ use \Psr\Http\Message\ResponseInterface as Response;
|
||||
use \Grocy\Helpers\UrlManager;
|
||||
use \Grocy\Controllers\LoginController;
|
||||
|
||||
// Definitions for embedded mode
|
||||
if (file_exists(__DIR__ . '/embedded.txt'))
|
||||
{
|
||||
define('GROCY_IS_EMBEDDED_INSTALL', true);
|
||||
define('GROCY_DATAPATH', file_get_contents(__DIR__ . '/embedded.txt'));
|
||||
define('GROCY_USER_ID', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
define('GROCY_IS_EMBEDDED_INSTALL', false);
|
||||
define('GROCY_DATAPATH', __DIR__ . '/data');
|
||||
}
|
||||
|
||||
// Definitions for demo mode
|
||||
if (file_exists(GROCY_DATAPATH . '/demo.txt'))
|
||||
{
|
||||
define('GROCY_IS_DEMO_INSTALL', true);
|
||||
if (!defined('GROCY_USER_ID'))
|
||||
{
|
||||
define('GROCY_USER_ID', 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
define('GROCY_IS_DEMO_INSTALL', false);
|
||||
}
|
||||
|
||||
// Load composer dependencies
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
require_once __DIR__ . '/data/config.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
|
||||
|
||||
// Setup base application
|
||||
@@ -18,7 +48,7 @@ $appContainer = new \Slim\Container([
|
||||
],
|
||||
'view' => function($container)
|
||||
{
|
||||
return new \Slim\Views\Blade(__DIR__ . '/views', __DIR__ . '/data/viewcache');
|
||||
return new \Slim\Views\Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
|
||||
},
|
||||
'LoginControllerInstance' => function($container)
|
||||
{
|
||||
@@ -26,7 +56,7 @@ $appContainer = new \Slim\Container([
|
||||
},
|
||||
'UrlManager' => function($container)
|
||||
{
|
||||
return new UrlManager(BASE_URL);
|
||||
return new UrlManager(GROCY_BASE_URL);
|
||||
},
|
||||
'ApiKeyHeaderName' => function($container)
|
||||
{
|
||||
@@ -35,11 +65,7 @@ $appContainer = new \Slim\Container([
|
||||
]);
|
||||
$app = new \Slim\App($appContainer);
|
||||
|
||||
if (PHP_SAPI === 'cli')
|
||||
{
|
||||
$app->add(\pavlakis\cli\CliRequest::class);
|
||||
}
|
||||
|
||||
// Load routes from separate file
|
||||
require_once __DIR__ . '/routes.php';
|
||||
|
||||
$app->run();
|
||||
|
@@ -3,7 +3,6 @@
|
||||
"php": ">=7.2",
|
||||
"slim/slim": "^3.8",
|
||||
"morris/lessql": "^0.3.4",
|
||||
"pavlakis/slim-cli": "^1.0",
|
||||
"rubellum/slim-blade-view": "^0.1.1",
|
||||
"tuupola/cors-middleware": "^0.7.0"
|
||||
},
|
||||
|
231
composer.lock
generated
231
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "131ab83ecb1ea3d1a431cc70b5092448",
|
||||
"content-hash": "c1bc4c17739e9d0ee8b33628f6d4b9a4",
|
||||
"packages": [
|
||||
{
|
||||
"name": "container-interop/container-interop",
|
||||
@@ -154,31 +154,32 @@
|
||||
"request",
|
||||
"response"
|
||||
],
|
||||
"abandoned": "psr/http-factory",
|
||||
"time": "2017-03-24T14:48:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/container",
|
||||
"version": "v5.6.27",
|
||||
"version": "v5.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/container.git",
|
||||
"reference": "1f0757cae8749400aeda730f6438a081fc3c082d"
|
||||
"reference": "b2adca648536dfdfc13c2b93a2d717149794b682"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/container/zipball/1f0757cae8749400aeda730f6438a081fc3c082d",
|
||||
"reference": "1f0757cae8749400aeda730f6438a081fc3c082d",
|
||||
"url": "https://api.github.com/repos/illuminate/container/zipball/b2adca648536dfdfc13c2b93a2d717149794b682",
|
||||
"reference": "b2adca648536dfdfc13c2b93a2d717149794b682",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/contracts": "5.6.*",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"php": "^7.1.3",
|
||||
"psr/container": "~1.0"
|
||||
"psr/container": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.6-dev"
|
||||
"dev-master": "5.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -198,31 +199,31 @@
|
||||
],
|
||||
"description": "The Illuminate Container package.",
|
||||
"homepage": "https://laravel.com",
|
||||
"time": "2018-05-24T13:16:56+00:00"
|
||||
"time": "2018-05-28T08:50:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/contracts",
|
||||
"version": "v5.6.27",
|
||||
"version": "v5.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/contracts.git",
|
||||
"reference": "3dc639feabe0f302f574157a782ede323881a944"
|
||||
"reference": "fd5d68eddfe49647f8354ac4c5f09cb88ccece7a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/contracts/zipball/3dc639feabe0f302f574157a782ede323881a944",
|
||||
"reference": "3dc639feabe0f302f574157a782ede323881a944",
|
||||
"url": "https://api.github.com/repos/illuminate/contracts/zipball/fd5d68eddfe49647f8354ac4c5f09cb88ccece7a",
|
||||
"reference": "fd5d68eddfe49647f8354ac4c5f09cb88ccece7a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"psr/container": "~1.0",
|
||||
"psr/simple-cache": "~1.0"
|
||||
"psr/container": "^1.0",
|
||||
"psr/simple-cache": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.6-dev"
|
||||
"dev-master": "5.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -242,32 +243,32 @@
|
||||
],
|
||||
"description": "The Illuminate Contracts package.",
|
||||
"homepage": "https://laravel.com",
|
||||
"time": "2018-05-11T23:38:58+00:00"
|
||||
"time": "2018-09-05T21:56:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/events",
|
||||
"version": "v5.6.27",
|
||||
"version": "v5.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/events.git",
|
||||
"reference": "b6e73ed40478cef2ef98d5ddb27f333291606cea"
|
||||
"reference": "ada2f80ea8d4a5933ded24f592b7940456a68be0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/events/zipball/b6e73ed40478cef2ef98d5ddb27f333291606cea",
|
||||
"reference": "b6e73ed40478cef2ef98d5ddb27f333291606cea",
|
||||
"url": "https://api.github.com/repos/illuminate/events/zipball/ada2f80ea8d4a5933ded24f592b7940456a68be0",
|
||||
"reference": "ada2f80ea8d4a5933ded24f592b7940456a68be0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/container": "5.6.*",
|
||||
"illuminate/contracts": "5.6.*",
|
||||
"illuminate/support": "5.6.*",
|
||||
"illuminate/container": "5.7.*",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/support": "5.7.*",
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.6-dev"
|
||||
"dev-master": "5.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -287,39 +288,39 @@
|
||||
],
|
||||
"description": "The Illuminate Events package.",
|
||||
"homepage": "https://laravel.com",
|
||||
"time": "2018-02-26T19:00:55+00:00"
|
||||
"time": "2018-07-26T15:27:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/filesystem",
|
||||
"version": "v5.6.27",
|
||||
"version": "v5.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/filesystem.git",
|
||||
"reference": "2677365f61c66fad13ff12a37cd4fa8aaeb048d2"
|
||||
"reference": "2251e31e382ddcbbcb34fddc43e7cc0afa530be8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/filesystem/zipball/2677365f61c66fad13ff12a37cd4fa8aaeb048d2",
|
||||
"reference": "2677365f61c66fad13ff12a37cd4fa8aaeb048d2",
|
||||
"url": "https://api.github.com/repos/illuminate/filesystem/zipball/2251e31e382ddcbbcb34fddc43e7cc0afa530be8",
|
||||
"reference": "2251e31e382ddcbbcb34fddc43e7cc0afa530be8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/contracts": "5.6.*",
|
||||
"illuminate/support": "5.6.*",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/support": "5.7.*",
|
||||
"php": "^7.1.3",
|
||||
"symfony/finder": "~4.0"
|
||||
"symfony/finder": "^4.1"
|
||||
},
|
||||
"suggest": {
|
||||
"league/flysystem": "Required to use the Flysystem local and FTP drivers (~1.0).",
|
||||
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).",
|
||||
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (~1.0).",
|
||||
"league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0).",
|
||||
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (~1.0)."
|
||||
"league/flysystem": "Required to use the Flysystem local and FTP drivers (^1.0).",
|
||||
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
|
||||
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
|
||||
"league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (^1.0).",
|
||||
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0)."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.6-dev"
|
||||
"dev-master": "5.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -339,42 +340,43 @@
|
||||
],
|
||||
"description": "The Illuminate Filesystem package.",
|
||||
"homepage": "https://laravel.com",
|
||||
"time": "2018-07-07T14:54:27+00:00"
|
||||
"time": "2018-08-14T19:42:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/support",
|
||||
"version": "v5.6.27",
|
||||
"version": "v5.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/support.git",
|
||||
"reference": "97ca44c95392ce0a41749fa47b953734d88b94b1"
|
||||
"reference": "3dabc8fe2eebf614ba133fa34a4c160119ec7241"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/support/zipball/97ca44c95392ce0a41749fa47b953734d88b94b1",
|
||||
"reference": "97ca44c95392ce0a41749fa47b953734d88b94b1",
|
||||
"url": "https://api.github.com/repos/illuminate/support/zipball/3dabc8fe2eebf614ba133fa34a4c160119ec7241",
|
||||
"reference": "3dabc8fe2eebf614ba133fa34a4c160119ec7241",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/inflector": "~1.1",
|
||||
"doctrine/inflector": "^1.1",
|
||||
"ext-mbstring": "*",
|
||||
"illuminate/contracts": "5.6.*",
|
||||
"nesbot/carbon": "^1.24.1",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"nesbot/carbon": "^1.26.3",
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"conflict": {
|
||||
"tightenco/collect": "<5.5.33"
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/filesystem": "Required to use the composer class (5.6.*).",
|
||||
"illuminate/filesystem": "Required to use the composer class (5.7.*).",
|
||||
"moontoast/math": "Required to use ordered UUIDs (^1.1).",
|
||||
"ramsey/uuid": "Required to use Str::uuid() (^3.7).",
|
||||
"symfony/process": "Required to use the composer class (~4.0).",
|
||||
"symfony/var-dumper": "Required to use the dd function (~4.0)."
|
||||
"symfony/process": "Required to use the composer class (^4.1).",
|
||||
"symfony/var-dumper": "Required to use the dd function (^4.1)."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.6-dev"
|
||||
"dev-master": "5.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -397,35 +399,35 @@
|
||||
],
|
||||
"description": "The Illuminate Support package.",
|
||||
"homepage": "https://laravel.com",
|
||||
"time": "2018-07-04T01:23:57+00:00"
|
||||
"time": "2018-09-06T13:40:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/view",
|
||||
"version": "v5.6.27",
|
||||
"version": "v5.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/view.git",
|
||||
"reference": "625c35e8942f0ecd467acb8db8daf8449390d559"
|
||||
"reference": "5efdaf61535cfb53024ca1933bb8fa3cb016a4c4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/view/zipball/625c35e8942f0ecd467acb8db8daf8449390d559",
|
||||
"reference": "625c35e8942f0ecd467acb8db8daf8449390d559",
|
||||
"url": "https://api.github.com/repos/illuminate/view/zipball/5efdaf61535cfb53024ca1933bb8fa3cb016a4c4",
|
||||
"reference": "5efdaf61535cfb53024ca1933bb8fa3cb016a4c4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/container": "5.6.*",
|
||||
"illuminate/contracts": "5.6.*",
|
||||
"illuminate/events": "5.6.*",
|
||||
"illuminate/filesystem": "5.6.*",
|
||||
"illuminate/support": "5.6.*",
|
||||
"illuminate/container": "5.7.*",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/events": "5.7.*",
|
||||
"illuminate/filesystem": "5.7.*",
|
||||
"illuminate/support": "5.7.*",
|
||||
"php": "^7.1.3",
|
||||
"symfony/debug": "~4.0"
|
||||
"symfony/debug": "^4.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.6-dev"
|
||||
"dev-master": "5.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -445,7 +447,7 @@
|
||||
],
|
||||
"description": "The Illuminate View package.",
|
||||
"homepage": "https://laravel.com",
|
||||
"time": "2018-07-06T14:55:12+00:00"
|
||||
"time": "2018-09-03T09:36:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "morris/lessql",
|
||||
@@ -552,16 +554,16 @@
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "1.32.0",
|
||||
"version": "1.33.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/briannesbitt/Carbon.git",
|
||||
"reference": "64563e2b9f69e4db1b82a60e81efa327a30ff343"
|
||||
"reference": "55667c1007a99e82030874b1bb14d24d07108413"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/64563e2b9f69e4db1b82a60e81efa327a30ff343",
|
||||
"reference": "64563e2b9f69e4db1b82a60e81efa327a30ff343",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/55667c1007a99e82030874b1bb14d24d07108413",
|
||||
"reference": "55667c1007a99e82030874b1bb14d24d07108413",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -603,7 +605,7 @@
|
||||
"datetime",
|
||||
"time"
|
||||
],
|
||||
"time": "2018-07-05T06:59:26+00:00"
|
||||
"time": "2018-08-07T08:39:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/fast-route",
|
||||
@@ -651,55 +653,6 @@
|
||||
],
|
||||
"time": "2018-02-13T20:26:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pavlakis/slim-cli",
|
||||
"version": "1.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pavlakis/slim-cli.git",
|
||||
"reference": "603933a54e391b3c70c573206cce543b75d8b1db"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pavlakis/slim-cli/zipball/603933a54e391b3c70c573206cce543b75d8b1db",
|
||||
"reference": "603933a54e391b3c70c573206cce543b75d8b1db",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.5|^5.6|^7.0|^7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0",
|
||||
"slim/slim": "^3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"pavlakis\\cli\\tests\\": "tests/phpunit",
|
||||
"pavlakis\\cli\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Antonis Pavlakis",
|
||||
"email": "adoni@pavlakis.info",
|
||||
"homepage": "http://pavlakis.info"
|
||||
}
|
||||
],
|
||||
"description": "Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.",
|
||||
"homepage": "http://github.com/pavlakis/slim-cli",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"framework",
|
||||
"middleware",
|
||||
"slim"
|
||||
],
|
||||
"time": "2017-01-30T22:50:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "philo/laravel-blade",
|
||||
"version": "v3.1",
|
||||
@@ -1214,16 +1167,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
"version": "v4.1.1",
|
||||
"version": "v4.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/debug.git",
|
||||
"reference": "dbe0fad88046a755dcf9379f2964c61a02f5ae3d"
|
||||
"reference": "47ead688f1f2877f3f14219670f52e4722ee7052"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/debug/zipball/dbe0fad88046a755dcf9379f2964c61a02f5ae3d",
|
||||
"reference": "dbe0fad88046a755dcf9379f2964c61a02f5ae3d",
|
||||
"url": "https://api.github.com/repos/symfony/debug/zipball/47ead688f1f2877f3f14219670f52e4722ee7052",
|
||||
"reference": "47ead688f1f2877f3f14219670f52e4722ee7052",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1266,20 +1219,20 @@
|
||||
],
|
||||
"description": "Symfony Debug Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2018-06-08T09:39:36+00:00"
|
||||
"time": "2018-08-03T11:13:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v4.1.1",
|
||||
"version": "v4.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
"reference": "84714b8417d19e4ba02ea78a41a975b3efaafddb"
|
||||
"reference": "e162f1df3102d0b7472805a5a9d5db9fcf0a8068"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/84714b8417d19e4ba02ea78a41a975b3efaafddb",
|
||||
"reference": "84714b8417d19e4ba02ea78a41a975b3efaafddb",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/e162f1df3102d0b7472805a5a9d5db9fcf0a8068",
|
||||
"reference": "e162f1df3102d0b7472805a5a9d5db9fcf0a8068",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1315,20 +1268,20 @@
|
||||
],
|
||||
"description": "Symfony Finder Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2018-06-19T21:38:16+00:00"
|
||||
"time": "2018-07-26T11:24:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "v1.8.0",
|
||||
"version": "v1.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "3296adf6a6454a050679cde90f95350ad604b171"
|
||||
"reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171",
|
||||
"reference": "3296adf6a6454a050679cde90f95350ad604b171",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8",
|
||||
"reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1340,7 +1293,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.8-dev"
|
||||
"dev-master": "1.9-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -1374,20 +1327,20 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2018-04-26T10:06:28+00:00"
|
||||
"time": "2018-08-06T14:22:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v4.1.1",
|
||||
"version": "v4.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/translation.git",
|
||||
"reference": "b6d8164085ee0b6debcd1b7a131fd6f63bb04854"
|
||||
"reference": "fa2182669f7983b7aa5f1a770d053f79f0ef144f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/b6d8164085ee0b6debcd1b7a131fd6f63bb04854",
|
||||
"reference": "b6d8164085ee0b6debcd1b7a131fd6f63bb04854",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/fa2182669f7983b7aa5f1a770d053f79f0ef144f",
|
||||
"reference": "fa2182669f7983b7aa5f1a770d053f79f0ef144f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1443,7 +1396,7 @@
|
||||
],
|
||||
"description": "Symfony Translation Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2018-06-22T08:59:39+00:00"
|
||||
"time": "2018-08-07T12:45:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tuupola/callable-handler",
|
||||
|
@@ -1,9 +1,5 @@
|
||||
<?php
|
||||
|
||||
# Login credentials
|
||||
Setting('HTTP_USER', 'admin');
|
||||
Setting('HTTP_PASSWORD', 'admin');
|
||||
|
||||
# Either "production" or "dev"
|
||||
Setting('MODE', 'production');
|
||||
|
||||
@@ -11,6 +7,11 @@ Setting('MODE', 'production');
|
||||
# one of the other available localization files in the "/localization" directory
|
||||
Setting('CULTURE', 'en');
|
||||
|
||||
# To keep it simpel, 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', '$');
|
||||
|
||||
# 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
|
||||
|
@@ -12,7 +12,7 @@ class BaseController
|
||||
$databaseService = new DatabaseService();
|
||||
$this->Database = $databaseService->GetDbConnection();
|
||||
|
||||
$localizationService = new LocalizationService(CULTURE);
|
||||
$localizationService = new LocalizationService(GROCY_CULTURE);
|
||||
$this->LocalizationService = $localizationService;
|
||||
|
||||
$applicationService = new ApplicationService();
|
||||
|
@@ -44,4 +44,9 @@ class BatteriesApiController extends BaseApiController
|
||||
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function Current(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->ApiResponse($this->BatteriesService->GetCurrent());
|
||||
}
|
||||
}
|
||||
|
@@ -16,22 +16,10 @@ class BatteriesController extends BaseController
|
||||
|
||||
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$nextChargeTimes = array();
|
||||
foreach($this->Database->batteries() as $battery)
|
||||
{
|
||||
$nextChargeTimes[$battery->id] = $this->BatteriesService->GetNextChargeTime($battery->id);
|
||||
}
|
||||
|
||||
$nextXDays = 5;
|
||||
$countDueNextXDays = count(FindAllItemsInArrayByValue($nextChargeTimes, date('Y-m-d', strtotime("+$nextXDays days")), '<'));
|
||||
$countOverdue = count(FindAllItemsInArrayByValue($nextChargeTimes, date('Y-m-d', strtotime('-1 days')), '<'));
|
||||
return $this->AppContainer->view->render($response, 'batteriesoverview', [
|
||||
'batteries' => $this->Database->batteries()->orderBy('name'),
|
||||
'current' => $this->BatteriesService->GetCurrent(),
|
||||
'nextChargeTimes' => $nextChargeTimes,
|
||||
'nextXDays' => $nextXDays,
|
||||
'countDueNextXDays' => $countDueNextXDays - $countOverdue,
|
||||
'countOverdue' => $countOverdue
|
||||
'nextXDays' => 5
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Grocy\Controllers;
|
||||
|
||||
use \Grocy\Services\ApplicationService;
|
||||
use \Grocy\Services\DatabaseMigrationService;
|
||||
|
||||
class CliController extends BaseController
|
||||
{
|
||||
public function RecreateDemo(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$applicationService = new ApplicationService();
|
||||
if ($applicationService->IsDemoInstallation())
|
||||
{
|
||||
$databaseMigrationService = new DatabaseMigrationService();
|
||||
$databaseMigrationService->RecreateDemo();
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,9 +22,15 @@ class HabitsApiController extends BaseApiController
|
||||
$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'];
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->HabitsService->TrackHabit($args['habitId'], $trackedTime);
|
||||
$this->HabitsService->TrackHabit($args['habitId'], $trackedTime, $doneBy);
|
||||
return $this->VoidApiActionResponse($response);
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
@@ -44,4 +50,9 @@ class HabitsApiController extends BaseApiController
|
||||
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function Current(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->ApiResponse($this->HabitsService->GetCurrent());
|
||||
}
|
||||
}
|
||||
|
@@ -16,29 +16,18 @@ class HabitsController extends BaseController
|
||||
|
||||
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$nextHabitTimes = array();
|
||||
foreach($this->Database->habits() as $habit)
|
||||
{
|
||||
$nextHabitTimes[$habit->id] = $this->HabitsService->GetNextHabitTime($habit->id);
|
||||
}
|
||||
|
||||
$nextXDays = 5;
|
||||
$countDueNextXDays = count(FindAllItemsInArrayByValue($nextHabitTimes, date('Y-m-d', strtotime("+$nextXDays days")), '<'));
|
||||
$countOverdue = count(FindAllItemsInArrayByValue($nextHabitTimes, date('Y-m-d', strtotime('-1 days')), '<'));
|
||||
return $this->AppContainer->view->render($response, 'habitsoverview', [
|
||||
'habits' => $this->Database->habits()->orderBy('name'),
|
||||
'currentHabits' => $this->HabitsService->GetCurrentHabits(),
|
||||
'nextHabitTimes' => $nextHabitTimes,
|
||||
'nextXDays' => $nextXDays,
|
||||
'countDueNextXDays' => $countDueNextXDays - $countOverdue,
|
||||
'countOverdue' => $countOverdue
|
||||
'currentHabits' => $this->HabitsService->GetCurrent(),
|
||||
'nextXDays' => 5
|
||||
]);
|
||||
}
|
||||
|
||||
public function TrackHabitExecution(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'habittracking', [
|
||||
'habits' => $this->Database->habits()->orderBy('name')
|
||||
'habits' => $this->Database->habits()->orderBy('name'),
|
||||
'users' => $this->Database->users()->orderBy('username')
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -49,6 +38,15 @@ class HabitsController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
public function Analysis(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'habitsanalysis', [
|
||||
'habitsLog' => $this->Database->habits_log()->orderBy('tracked_time', 'DESC'),
|
||||
'habits' => $this->Database->habits()->orderBy('name'),
|
||||
'users' => $this->Database->users()->orderBy('username')
|
||||
]);
|
||||
}
|
||||
|
||||
public function HabitEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
if ($args['habitId'] == 'new')
|
||||
|
@@ -3,7 +3,6 @@
|
||||
namespace Grocy\Controllers;
|
||||
|
||||
use \Grocy\Services\SessionService;
|
||||
use \Grocy\Services\ApplicationService;
|
||||
use \Grocy\Services\DatabaseMigrationService;
|
||||
use \Grocy\Services\DemoDataGeneratorService;
|
||||
|
||||
@@ -24,11 +23,21 @@ class LoginController extends BaseController
|
||||
$postParams = $request->getParsedBody();
|
||||
if (isset($postParams['username']) && isset($postParams['password']))
|
||||
{
|
||||
if ($postParams['username'] === HTTP_USER && $postParams['password'] === HTTP_PASSWORD)
|
||||
$user = $this->Database->users()->where('username', $postParams['username'])->fetch();
|
||||
$inputPassword = $postParams['password'];
|
||||
|
||||
if ($user !== null && password_verify($inputPassword, $user->password))
|
||||
{
|
||||
$sessionKey = $this->SessionService->CreateSession();
|
||||
$sessionKey = $this->SessionService->CreateSession($user->id);
|
||||
setcookie($this->SessionCookieName, $sessionKey, time() + 31536000); // Cookie expires in 1 year, but session validity is up to SessionService
|
||||
|
||||
if (password_needs_rehash($user->password, PASSWORD_DEFAULT))
|
||||
{
|
||||
$user->update(array(
|
||||
'password' => password_hash($inputPassword, PASSWORD_DEFAULT)
|
||||
));
|
||||
}
|
||||
|
||||
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/'));
|
||||
}
|
||||
else
|
||||
@@ -59,8 +68,7 @@ class LoginController extends BaseController
|
||||
$databaseMigrationService = new DatabaseMigrationService();
|
||||
$databaseMigrationService->MigrateDatabase();
|
||||
|
||||
$applicationService = new ApplicationService();
|
||||
if ($applicationService->IsDemoInstallation())
|
||||
if (GROCY_IS_DEMO_INSTALL)
|
||||
{
|
||||
$demoDataGeneratorService = new DemoDataGeneratorService();
|
||||
$demoDataGeneratorService->PopulateDemoData();
|
||||
|
@@ -35,7 +35,8 @@ class OpenApiController extends BaseApiController
|
||||
public function ApiKeysList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'manageapikeys', [
|
||||
'apiKeys' => $this->Database->api_keys()
|
||||
'apiKeys' => $this->Database->api_keys(),
|
||||
'users' => $this->Database->users()
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -19,4 +19,17 @@ class RecipesApiController extends BaseApiController
|
||||
$this->RecipesService->AddNotFulfilledProductsToShoppingList($args['recipeId']);
|
||||
return $this->VoidApiActionResponse($response);
|
||||
}
|
||||
|
||||
public function ConsumeRecipe(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->RecipesService->ConsumeRecipe($args['recipeId']);
|
||||
return $this->VoidApiActionResponse($response);
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -76,8 +76,9 @@ class RecipesController extends BaseController
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'recipeposform', [
|
||||
'mode' => 'create',
|
||||
'recipe' => $this->Database->recipes($args['recipeId']),
|
||||
'products' => $this->Database->products()->orderBy('name')
|
||||
'recipe' => $this->Database->recipes($args['recipeId']),
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'quantityUnits' => $this->Database->quantity_units()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
else
|
||||
@@ -85,8 +86,9 @@ class RecipesController extends BaseController
|
||||
return $this->AppContainer->view->render($response, 'recipeposform', [
|
||||
'mode' => 'edit',
|
||||
'recipe' => $this->Database->recipes($args['recipeId']),
|
||||
'recipePos' => $this->Database->recipes_pos($args['recipePosId']),
|
||||
'products' => $this->Database->products()->orderBy('name')
|
||||
'recipePos' => $this->Database->recipes_pos($args['recipePosId']),
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'quantityUnits' => $this->Database->quantity_units()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,18 @@ class StockApiController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
public function ProductPriceHistory(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->ApiResponse($this->StockService->GetProductPriceHistory($args['productId']));
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function AddProduct(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$bestBeforeDate = date('Y-m-d');
|
||||
@@ -34,6 +46,12 @@ class StockApiController extends BaseApiController
|
||||
$bestBeforeDate = $request->getQueryParams()['bestbeforedate'];
|
||||
}
|
||||
|
||||
$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']))
|
||||
{
|
||||
@@ -42,7 +60,7 @@ class StockApiController extends BaseApiController
|
||||
|
||||
try
|
||||
{
|
||||
$this->StockService->AddProduct($args['productId'], $args['amount'], $bestBeforeDate, $transactionType);
|
||||
$this->StockService->AddProduct($args['productId'], $args['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price);
|
||||
return $this->VoidApiActionResponse($response);
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
@@ -100,6 +118,24 @@ class StockApiController extends BaseApiController
|
||||
return $this->ApiResponse($this->StockService->GetCurrentStock());
|
||||
}
|
||||
|
||||
public function CurrentVolatilStock(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$nextXDays = 5;
|
||||
if (isset($request->getQueryParams()['expiring_days']) && !empty($request->getQueryParams()['expiring_days']) && is_numeric($request->getQueryParams()['expiring_days']))
|
||||
{
|
||||
$nextXDays = $request->getQueryParams()['expiring_days'];
|
||||
}
|
||||
|
||||
$expiringProducts = $this->StockService->GetExpiringProducts($nextXDays);
|
||||
$expiredProducts = $this->StockService->GetExpiringProducts(-1);
|
||||
$missingProducts = $this->StockService->GetMissingProducts();
|
||||
return $this->ApiResponse(array(
|
||||
'expiring_products' => $expiringProducts,
|
||||
'expired_products' => $expiredProducts,
|
||||
'missing_products' => $missingProducts
|
||||
));
|
||||
}
|
||||
|
||||
public function AddMissingProductsToShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$this->StockService->AddMissingProductsToShoppingList();
|
||||
|
@@ -17,19 +17,13 @@ class StockController extends BaseController
|
||||
|
||||
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$currentStock = $this->StockService->GetCurrentStock();
|
||||
$nextXDays = 5;
|
||||
$countExpiringNextXDays = count(FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d', strtotime('+5 days')), '<'));
|
||||
$countAlreadyExpired = count(FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d', strtotime('-1 days')), '<'));
|
||||
return $this->AppContainer->view->render($response, 'stockoverview', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'currentStock' => $currentStock,
|
||||
'currentStock' => $this->StockService->GetCurrentStock(),
|
||||
'missingProducts' => $this->StockService->GetMissingProducts(),
|
||||
'nextXDays' => $nextXDays,
|
||||
'countExpiringNextXDays' => $countExpiringNextXDays,
|
||||
'countAlreadyExpired' => $countAlreadyExpired
|
||||
'nextXDays' => 5
|
||||
]);
|
||||
}
|
||||
|
||||
|
71
controllers/UsersApiController.php
Normal file
71
controllers/UsersApiController.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Grocy\Controllers;
|
||||
|
||||
use \Grocy\Services\UsersService;
|
||||
|
||||
class UsersApiController extends BaseApiController
|
||||
{
|
||||
public function __construct(\Slim\Container $container)
|
||||
{
|
||||
parent::__construct($container);
|
||||
$this->UsersService = new UsersService();
|
||||
}
|
||||
|
||||
protected $UsersService;
|
||||
|
||||
public function GetUsers(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->ApiResponse($this->UsersService->GetUsersAsDto());
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function CreateUser(\Slim\Http\Request $request, \Slim\Http\Response $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));
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function DeleteUser(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->UsersService->DeleteUser($args['userId']);
|
||||
return $this->ApiResponse(array('success' => true));
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function EditUser(\Slim\Http\Request $request, \Slim\Http\Response $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));
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
30
controllers/UsersController.php
Normal file
30
controllers/UsersController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Grocy\Controllers;
|
||||
|
||||
class UsersController extends BaseController
|
||||
{
|
||||
public function UsersList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'users', [
|
||||
'users' => $this->Database->users()->orderBy('username')
|
||||
]);
|
||||
}
|
||||
|
||||
public function UserEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
if ($args['userId'] == 'new')
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'userform', [
|
||||
'mode' => 'create'
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'userform', [
|
||||
'user' => $this->Database->users($args['userId']),
|
||||
'mode' => 'edit'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
@@ -370,6 +370,173 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/get": {
|
||||
"get": {
|
||||
"description": "Returns all users",
|
||||
"tags": [
|
||||
"User management"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A list of user objects",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/UserDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "A VoidApiActionResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorExampleVoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/create": {
|
||||
"post": {
|
||||
"description": "Creates a new user",
|
||||
"tags": [
|
||||
"User management"
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "A valid user object",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/User"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A VoidApiActionResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/VoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "A VoidApiActionResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorExampleVoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/edit/{userId}": {
|
||||
"post": {
|
||||
"description": "Edits the given user",
|
||||
"tags": [
|
||||
"User management"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "userId",
|
||||
"required": true,
|
||||
"description": "A valid user id",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "A valid user object",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/User"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A VoidApiActionResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/VoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "A VoidApiActionResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorExampleVoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/delete/{userId}": {
|
||||
"get": {
|
||||
"description": "Deletes the given user",
|
||||
"tags": [
|
||||
"User management"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "userId",
|
||||
"required": true,
|
||||
"description": "A valid user id",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A VoidApiActionResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/VoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "A VoidApiActionResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorExampleVoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/stock/add-product/{productId}/{amount}": {
|
||||
"get": {
|
||||
"description": "Adds the the given amount of the given product to stock",
|
||||
@@ -401,7 +568,18 @@
|
||||
"required": false,
|
||||
"description": "The best before date of the product to add, when omitted, the current date is used",
|
||||
"schema": {
|
||||
"type": "date"
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
}
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "price",
|
||||
"required": false,
|
||||
"description": "The price per purchase quantity unit in configured currency",
|
||||
"schema": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -538,7 +716,8 @@
|
||||
"required": false,
|
||||
"description": "The best before date which applies to added products",
|
||||
"schema": {
|
||||
"type": "date"
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -607,6 +786,50 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/stock/get-product-price-history/{productId}": {
|
||||
"get": {
|
||||
"description": "Returns the price history of the given product",
|
||||
"tags": [
|
||||
"Stock"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "productId",
|
||||
"required": true,
|
||||
"description": "A valid product id",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "An array of ProductPriceHistory objects",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ProductPriceHistory"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "A VoidApiActionResponse object (possible errors are: Not existing product)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorExampleVoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/stock/get-current-stock": {
|
||||
"get": {
|
||||
"description": "Returns all products which are currently in stock incl. the next expiring date per product",
|
||||
@@ -621,7 +844,42 @@
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Product"
|
||||
"$ref": "#/components/schemas/CurrentStockResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/stock/get-current-volatil-stock": {
|
||||
"get": {
|
||||
"description": "Returns all products which are expiring soon, are already expired or currently missing",
|
||||
"tags": [
|
||||
"Stock"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "expiring_days",
|
||||
"required": false,
|
||||
"description": "The number of days in which products are considered expiring soon",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"default": 5
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A CurrentVolatilStockResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CurrentVolatilStockResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -752,6 +1010,37 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/recipes/consume-recipe/{recipeId}": {
|
||||
"get": {
|
||||
"description": "Consumes all products of the given recipe",
|
||||
"tags": [
|
||||
"Recipes"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "recipeId",
|
||||
"required": true,
|
||||
"description": "A valid recipe id",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A VoidApiActionResponse object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/VoidApiActionResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/habits/track-habit-execution/{habitId}": {
|
||||
"get": {
|
||||
"description": "Tracks an execution of the given habit",
|
||||
@@ -776,6 +1065,15 @@
|
||||
"schema": {
|
||||
"type": "date-time"
|
||||
}
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "done_by",
|
||||
"required": false,
|
||||
"description": "A valid user id of who executed this habit, when omitted, the currently authenticated user will be used",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -843,6 +1141,29 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/habits/get-current": {
|
||||
"get": {
|
||||
"description": "Returns all habits incl. the next estimated execution time per habit",
|
||||
"tags": [
|
||||
"Habits"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "An array of CurrentHabitResponse objects",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CurrentHabitResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/batteries/track-charge-cycle/{batteryId}": {
|
||||
"get": {
|
||||
"description": "Tracks a charge cycle of the given battery",
|
||||
@@ -865,7 +1186,8 @@
|
||||
"required": false,
|
||||
"description": "The time of when the battery was charged, when omitted, the current time is used",
|
||||
"schema": {
|
||||
"type": "date-time"
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -933,6 +1255,29 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/batteries/get-current": {
|
||||
"get": {
|
||||
"description": "Returns all batteries incl. the next estimated charge time per battery",
|
||||
"tags": [
|
||||
"Batteries"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "An array of CurrentBatteryResponse objects",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CurrentBatteryResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
@@ -1014,6 +1359,9 @@
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"name_plural": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1093,6 +1441,27 @@
|
||||
},
|
||||
"stock_amount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"next_best_before_date": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"last_price": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ProductPriceHistory": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"date": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"price": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1139,6 +1508,13 @@
|
||||
"track_count": {
|
||||
"type": "integer",
|
||||
"description": "How often this habit was tracked so far"
|
||||
},
|
||||
"last_done_by": {
|
||||
"$ref": "#/components/schemas/UserDto"
|
||||
},
|
||||
"next_estimated_execution_time": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1156,6 +1532,10 @@
|
||||
"charge_cycles_count": {
|
||||
"type": "integer",
|
||||
"description": "How often this battery was charged so far"
|
||||
},
|
||||
"next_estimated_charge_time": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1182,6 +1562,55 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"User": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"first_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"row_created_timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"UserDto": {
|
||||
"type": "object",
|
||||
"description": "A user object without the *password* and with an additional *display_name* property",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"first_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"row_created_timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ApiKey": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1407,10 +1836,68 @@
|
||||
"type": "integer"
|
||||
},
|
||||
"best_before_date": {
|
||||
"type": "date",
|
||||
"type": "string",
|
||||
"format": "date",
|
||||
"description": "The next best before date for this product"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CurrentHabitResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"habit_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"last_tracked_time": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next_estimated_execution_time": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "The next estimated execution time of this habit, 2999-12-31 23:59:59 when the given habit has a period_type of manually"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CurrentBatteryResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"battery_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"last_tracked_time": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next_estimated_charge_time": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "The next estimated charge time of this battery, 2999-12-31 23:59:59 when the given battery has no charge_interval_days defined"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CurrentVolatilStockResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"expiring_products": {
|
||||
"type": "array",
|
||||
"items":{
|
||||
"$ref": "#/components/schemas/Product"
|
||||
}
|
||||
},
|
||||
"expired_products": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Product"
|
||||
}
|
||||
},
|
||||
"missing_products": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Product"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"examples": {
|
||||
|
@@ -20,7 +20,7 @@ class UrlManager
|
||||
|
||||
public function ConstructUrl($relativePath, $isResource = false)
|
||||
{
|
||||
if (DISABLE_URL_REWRITING === false || $isResource === true)
|
||||
if (GROCY_DISABLE_URL_REWRITING === false || $isResource === true)
|
||||
{
|
||||
return rtrim($this->BasePath, '/') . $relativePath;
|
||||
}
|
||||
|
@@ -130,8 +130,51 @@ function BoolToString(bool $bool)
|
||||
|
||||
function Setting(string $name, $value)
|
||||
{
|
||||
if (!defined($name))
|
||||
if (!defined('GROCY_' . $name))
|
||||
{
|
||||
define($name, $value);
|
||||
// The content of a $name.txt file in /data/settingoverrides can overwrite the given setting (for embedded mode)
|
||||
$settingOverrideFile = GROCY_DATAPATH . '/settingoverrides/' . $name . '.txt';
|
||||
if (file_exists($settingOverrideFile))
|
||||
{
|
||||
define('GROCY_' . $name, file_get_contents($settingOverrideFile));
|
||||
}
|
||||
else
|
||||
{
|
||||
define('GROCY_' . $name, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GetUserDisplayName($user)
|
||||
{
|
||||
$displayName = '';
|
||||
|
||||
if (empty($user->first_name) && !empty($user->last_name))
|
||||
{
|
||||
$displayName = $user->last_name;
|
||||
}
|
||||
elseif (empty($user->last_name) && !empty($user->first_name))
|
||||
{
|
||||
$displayName = $user->first_name;
|
||||
}
|
||||
elseif (!empty($user->last_name) && !empty($user->first_name))
|
||||
{
|
||||
$displayName = $user->first_name . ' ' . $user->last_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$displayName = $user->username;
|
||||
}
|
||||
|
||||
return $displayName;
|
||||
}
|
||||
|
||||
function Pluralize($number, $singularForm, $pluralForm)
|
||||
{
|
||||
$text = $singularForm;
|
||||
if ($number != 1 && $pluralForm !== null && !empty($pluralForm))
|
||||
{
|
||||
$text = $pluralForm;
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
return array(
|
||||
'Stock overview' => 'Bestand',
|
||||
'#1 products with #2 units in stock' => '#1 Produkte (#2 Einheiten) vorrätig',
|
||||
'#1 products expiring within the next #2 days' => '#1 Produkte laufen innerhalb der nächsten #2 Tage ab',
|
||||
'#1 products are already expired' => '#1 Produkte sind bereits abgelaufen',
|
||||
'#1 products are below defined min. stock amount' => '#1 Produkte sind unter Mindestbestand',
|
||||
@@ -124,7 +123,7 @@ return array(
|
||||
'Added #1 #2 of #3 to stock' => '#1 #2 #3 dem Bestand hinzugefügt',
|
||||
'Stock amount of #1 is now #2 #3' => 'Es sind nun #2 #3 #1 im Bestand',
|
||||
'Tracked execution of habit #1 on #2' => 'Ausführung von #1 am #2 erfasst',
|
||||
'Tracked charge cylce of battery #1 on #2' => 'Ladezyklus für Batterie #1 am #2 erfasst',
|
||||
'Tracked charge cycle of battery #1 on #2' => 'Ladezyklus für Batterie #1 am #2 erfasst',
|
||||
'Consume all #1 which are currently in stock' => 'Verbrauche den kompletten Bestand von #1',
|
||||
'All' => 'Alle',
|
||||
'Track charge cycle of battery #1' => 'Erfasse einen Ladezyklus für Batterie #1',
|
||||
@@ -169,6 +168,54 @@ return array(
|
||||
'Put missing amount on shopping list' => 'Fehlende Menge auf den Einkaufszettel setzen',
|
||||
'Are you sure to put all missing ingredients for recipe "#1" on the shopping list?' => 'Sicher alle fehlenden Zutaten für Rezept "#1" auf die Einkaufsliste zu setzen?',
|
||||
'Added for recipe #1' => 'Hinzugefügt für Rezept #1',
|
||||
'Manage users' => 'Benutzer verwalten',
|
||||
'User' => 'Benutzer',
|
||||
'Users' => 'Benutzer',
|
||||
'Are you sure to delete user "#1"?' => 'Benutzer "#1" wirklich löschen?',
|
||||
'Create user' => 'Benutzer erstellen',
|
||||
'Edit user' => 'Benutzer bearbeiten',
|
||||
'First name' => 'Vorname',
|
||||
'Last name' => 'Nachname',
|
||||
'A username is required' => 'Ein Benutzername ist erforderlich',
|
||||
'Confirm password' => 'Passwort bestätigen',
|
||||
'Passwords do not match' => 'Passwörter stimmen nicht überein',
|
||||
'Change password' => 'Passwort ändern',
|
||||
'Done by' => 'Ausgeführt von',
|
||||
'Last done by' => 'Zuletzt ausgeführt von',
|
||||
'Unknown' => 'Unbekannt',
|
||||
'Filter by habit' => 'Nach Gewohnheit filtern',
|
||||
'Habits analysis' => 'Gewohnheiten Analyse',
|
||||
'0 means suggestions for the next charge cycle are disabled' => '0 bedeutet dass Vorschläge für den nächsten Ladezyklus deaktiviert sind',
|
||||
'Charge cycle interval (days)' => 'Ladezyklusintervall (Tage)',
|
||||
'Last price' => 'Letzter Preis',
|
||||
'Price history' => 'Preisentwicklung',
|
||||
'No price history available' => 'Keine Preisdaten verfügbar',
|
||||
'Price' => 'Preis',
|
||||
'in #1 per purchase quantity unit' => 'in #1 pro Einkaufsmengeneinheit',
|
||||
'The price cannot be lower than #1' => 'Der Preis darf nicht niedriger als #1 sein',
|
||||
'#1 product expires within the next #2 days' => '#1 Produkt läuft innerhalb der nächsten #2 Tage ab',
|
||||
'#1 product is already expired' => '#1 Produkt ist bereits abgelaufen',
|
||||
'#1 product is below defined min. stock amount' => '#1 Produkt ist unter Mindestbestand',
|
||||
'Unit' => 'Einheit',
|
||||
'Units' => 'Einheiten',
|
||||
'#1 habit is due to be done within the next #2 days' => '#1 Gewohnheit steht in den nächsten #2 Tagen an',
|
||||
'#1 habit is overdue to be done' => '#1 Gewohnheit ist überfällig',
|
||||
'#1 battery is due to be charged within the next #2 days' => '#1 Batterie muss in den nächsten #2 Tagen geladen werden',
|
||||
'#1 battery is overdue to be charged' => '#1 Batterie ist überfällig',
|
||||
'#1 unit was automatically added and will apply in addition to the amount entered here' => '#1 Einheit wurde automatisch hinzugefügt und gilt zusätzlich der hier eingegebenen Menge',
|
||||
'in singular form' => 'in der Einzahl',
|
||||
'in plural form' => 'in der Mehrzahl',
|
||||
'Never expires' => 'Läuft nie ab',
|
||||
'This cannot be lower than #1' => 'Dies darf nicht kleiner als #1 sein',
|
||||
'-1 means that this product never expires' => '-1 bedeuet, dass dieses Produkt niemals abläuft',
|
||||
'Quantity unit' => 'Mengeneinheit',
|
||||
'Only check if a single unit is in stock (a different quantity can then be used above)' => 'Nur prüfen, ob eine einzelne Einheit vorrätig ist (eine abweichende Mengeneinheit kann dann oben verwendet werden)',
|
||||
'Are you sure to consume all ingredients needed by recipe "#1" (ingredients marked with "check only if a single unit is in stock" will be ignored)?' => 'Sicher, dass alle Zutaten die vom Rezept "#1" benötigt werden aus dem Bestand entfernt werden sollen (Zutaten markiert mit "nur prüfen, ob eine einzelne Einheit vorrätig ist" werden ignoriert)?',
|
||||
'Removed all ingredients of recipe "#1" from stock' => 'Alle Zutaten, die vom Rezept "#1" benötigt werden, wurdem aus dem Bestand entfernt',
|
||||
'Consume all ingredients needed by this recipe' => 'Alle Zutaten, die von diesem Rezept benötigt werden, aus dem Bestand enternen',
|
||||
'Click to show technical details' => 'Klick um technische Details anzuzeigen',
|
||||
'Error while saving, probably this item already exists' => 'Fehler beim Speichern, möglicherweise existiert das Element bereits',
|
||||
'Error details' => 'Fehlerdetails',
|
||||
|
||||
//Constants
|
||||
'manually' => 'Manuell',
|
||||
@@ -188,11 +235,17 @@ return array(
|
||||
'Tinned food cupboard' => 'Konservenschrank',
|
||||
'Fridge' => 'Kühlschrank',
|
||||
'Piece' => 'Stück',
|
||||
'Pieces' => 'Stücke',
|
||||
'Pack' => 'Packung',
|
||||
'Packs' => 'Packungen',
|
||||
'Glass' => 'Glas',
|
||||
'Glasses' => 'Gläser',
|
||||
'Tin' => 'Dose',
|
||||
'Tins' => 'Dosen',
|
||||
'Can' => 'Becher',
|
||||
'Cans' => 'Becher',
|
||||
'Bunch' => 'Bund',
|
||||
'Bunches' => 'Bunde',
|
||||
'Gummy bears' => 'Gummibärchen',
|
||||
'Crisps' => 'Chips',
|
||||
'Eggs' => 'Eier',
|
||||
@@ -226,5 +279,11 @@ return array(
|
||||
'German' => 'Deutsch',
|
||||
'Italian' => 'Italienisch',
|
||||
'Demo in different language' => 'Demo in anderer Sprache',
|
||||
'This is the note content of the recipe ingredient' => 'Dies ist der Inhalt der Notiz der Zutat'
|
||||
'This is the note content of the recipe ingredient' => 'Dies ist der Inhalt der Notiz der Zutat',
|
||||
'Demo User' => 'Demo Benutzer',
|
||||
'Gram' => 'Gramm',
|
||||
'Grams' => 'Gramm',
|
||||
'Flour' => 'Mehl',
|
||||
'Pancakes' => 'Pfannkuchen',
|
||||
'Sugar' => 'Zucker'
|
||||
);
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
return array(
|
||||
'Stock overview' => 'Dispensa',
|
||||
'#1 products with #2 units in stock' => '#1 prodotti stano per finire(#2 unità)',
|
||||
'#1 products expiring within the next #2 days' => '#1 prodotti scadranno tra #2 giorni',
|
||||
'#1 products are already expired' => '#1 prodotti scaduti',
|
||||
'#1 products are below defined min. stock amount' => '#1 prodotti sotto il limite minimo',
|
||||
@@ -124,7 +123,7 @@ return array(
|
||||
'Added #1 #2 of #3 to stock' => 'Aggiunti #1 #2 di #3',
|
||||
'Stock amount of #1 is now #2 #3' => 'La quantità in dispensa di #1 è ora #2 #3',
|
||||
'Tracked execution of habit #1 on #2' => 'Esecuzione dell\'abitudine #1 registrata il #2',
|
||||
'Tracked charge cylce of battery #1 on #2' => 'Ricarica della batteria #1 effettuata il #2',
|
||||
'Tracked charge cycle of battery #1 on #2' => 'Ricarica della batteria #1 effettuata il #2',
|
||||
'Consume all #1 which are currently in stock' => 'Consuma tutto #1 in dispensa',
|
||||
'All' => 'Tutto',
|
||||
'Track charge cycle of battery #1' => 'Registra la ricarica della batteria #1',
|
||||
@@ -160,11 +159,17 @@ return array(
|
||||
'Tinned food cupboard' => 'Konservenschrank',
|
||||
'Fridge' => 'Kühlschrank',
|
||||
'Piece' => 'Pezzo',
|
||||
'Pieces' => 'Pezzi',
|
||||
'Pack' => 'Pacco',
|
||||
'Packs' => 'Pacchi',
|
||||
'Glass' => 'Bicchiere',
|
||||
'Glasses' => 'Bicchieri',
|
||||
'Tin' => 'Scatola',
|
||||
'Tins' => 'Scatole',
|
||||
'Can' => 'Lattina',
|
||||
'Cans' => 'Lattine',
|
||||
'Bunch' => 'Cespo',
|
||||
'Bunches' => 'Cespi',
|
||||
'Gummy bears' => 'Caramelle',
|
||||
'Crisps' => 'Patatine',
|
||||
'Eggs' => 'Uova',
|
||||
|
@@ -2,14 +2,13 @@
|
||||
|
||||
return array(
|
||||
'Stock overview' => 'Husholdning',
|
||||
'#1 products with #2 units in stock' => '#1 Produkter med #2 i husholdningen',
|
||||
'#1 products expiring within the next #2 days' => '#1 Produkter som går ut på dato innen de neste #2 dagene',
|
||||
'#1 products expiring within the next #2 days' => '#1 Produkt som går ut på dato innen de neste #2 dagene',
|
||||
'#1 products are already expired' => '#1 Produkt som har gått ut på dato',
|
||||
'#1 products are below defined min. stock amount' => '#1 Produkt under minimum husholdningsnivå',
|
||||
'Product' => 'Produkt',
|
||||
'Amount' => 'Antall',
|
||||
'Next best before date' => 'Kommende best før dato',
|
||||
'Logout' => 'Logg Av',
|
||||
'Logout' => 'Logg ut',
|
||||
'Habits overview' => 'Oversikt Husoppgaver',
|
||||
'Batteries overview' => 'Oversikt Batteri',
|
||||
'Purchase' => 'Innkjøp',
|
||||
@@ -17,7 +16,7 @@ return array(
|
||||
'Inventory' => 'Endre Husholdning',
|
||||
'Shopping list' => 'Handleliste',
|
||||
'Habit tracking' => 'Logge Husoppgaver',
|
||||
'Battery tracking' => 'Ladesyklus Batteri',
|
||||
'Battery tracking' => 'Batteri Ladesyklus',
|
||||
'Products' => 'Produkter',
|
||||
'Locations' => 'Lokasjoner',
|
||||
'Quantity units' => 'Forpakning',
|
||||
@@ -31,8 +30,8 @@ return array(
|
||||
'Next planned charge cycle' => 'Neste planlagte ladesyklus',
|
||||
'Best before' => 'Best før',
|
||||
'OK' => 'OK',
|
||||
'Product overview' => 'Oversikt Produkt',
|
||||
'Stock quantity unit' => 'Forpakning i husholdningen',
|
||||
'Product overview' => 'Produkt oversikt',
|
||||
'Stock quantity unit' => 'Forpakningstype i husholdningen',
|
||||
'Stock amount' => 'Husholdning',
|
||||
'Last purchased' => 'Sist kjøpt',
|
||||
'Last used' => 'Sist brukt',
|
||||
@@ -41,9 +40,9 @@ return array(
|
||||
'will be added to the list of barcodes for the selected product on submit' => 'Blir lagt til liste over strekkoder når produkt blir lagt inn.',
|
||||
'New amount' => 'Nytt antall',
|
||||
'Note' => 'Info',
|
||||
'Tracked time' => 'Tid logget',
|
||||
'Tracked time' => 'Tid utført/ ladet',
|
||||
'Habit overview' => 'Oversikt Husoppgave',
|
||||
'Tracked count' => 'Logget',
|
||||
'Tracked count' => 'Antall utførelser/ ladninger',
|
||||
'Battery overview' => 'Batteri Oversikt',
|
||||
'Charge cycles count' => 'Antall ladesykluser',
|
||||
'Create shopping list item' => 'Opprett handelisteoppføring',
|
||||
@@ -54,9 +53,9 @@ return array(
|
||||
'Name' => 'Navn',
|
||||
'Location' => 'Lokasjon',
|
||||
'Min. stock amount' => 'Minimums antall for husholdingen',
|
||||
'QU purchase' => 'QU innkjøp',
|
||||
'QU stock' => 'QU husholdning',
|
||||
'QU factor' => 'QU faktor',
|
||||
'QU purchase' => 'FPK innkjøp',
|
||||
'QU stock' => 'FPK husholdning',
|
||||
'QU factor' => 'FPK faktor',
|
||||
'Description' => 'Beskrivelse',
|
||||
'Create product' => 'Opprett produkt',
|
||||
'Barcode(s)' => 'Strekkode(r)',
|
||||
@@ -67,8 +66,8 @@ return array(
|
||||
'Factor purchase to stock quantity unit' => 'Innkjøpsfaktor for forpakning',
|
||||
'Create location' => 'Opprett lokasjon',
|
||||
'Create quantity unit' => 'Opprett forpakning',
|
||||
'Period type' => 'Periodetype',
|
||||
'Period days' => 'Dager/ Periode',
|
||||
'Period type' => 'Gjentakelse',
|
||||
'Period days' => 'Antall dager for gjentakelse',
|
||||
'Create habit' => 'Opprett husoppgave',
|
||||
'Used in' => 'Brukt',
|
||||
'Create battery' => 'Opprett batteri',
|
||||
@@ -81,7 +80,7 @@ return array(
|
||||
'Manage master data' => 'Administrer masterdata',
|
||||
'This will apply to added products' => 'Dette vil gjelde for produkt som blir lagt til',
|
||||
'never' => 'aldri',
|
||||
'Add products that are below defined min. stock amount' => 'Legg til produkt som er under definert minimums antall for husholdningen',
|
||||
'Add products that are below defined min. stock amount' => 'Legg til produkt som er under minimumsnivå for husholdningen',
|
||||
'For purchases this amount of days will be added to today for the best before date suggestion' => 'For innkjøp vil dette antallet dager legges til bestfør forslaget',
|
||||
'This means 1 #1 purchased will be converted into #2 #3 in stock' => 'Dette betyr at 1 #1 innkjøp vil bli omgjort til #2 #3 husholdning',
|
||||
'Login' => 'Logg inn',
|
||||
@@ -96,7 +95,7 @@ return array(
|
||||
'Create or assign product' => 'Opprett eller tildel til produkt',
|
||||
'Cancel' => 'Avbryt',
|
||||
'Add as new product' => 'Legg til som nytt produkt',
|
||||
'Add as barcode to existing product' => 'Legg til strekkode til allerede eksiterende produkt',
|
||||
'Add as barcode to existing product' => 'Legg til strekkode til allerede eksisterende produkt',
|
||||
'Add as new product and prefill barcode' => 'Legg til som nytt produkt med forhåndsutfylt strekkode',
|
||||
'Are you sure to delete quantity unit "#1"?' => 'Er du sikker du ønsker å slette forpakning "#1"?',
|
||||
'Are you sure to delete product "#1"?' => 'Er du sikker du ønsker å slette produkt "#1"?',
|
||||
@@ -112,10 +111,10 @@ return array(
|
||||
'This means #1 will be added to stock' => 'Dette betyr at #1 vil bli lagt til i husholdningen',
|
||||
'This means #1 will be removed from stock' => 'Dette betyr at #1 vil bli fjernet fra husholdningen',
|
||||
'This means it is estimated that a new execution of this habit is tracked #1 days after the last was tracked' => 'Dette betyr at det er estimert at den nye utførelsen av denne husoppgaven er logget #1 dag etter den sist var logget',
|
||||
'Removed #1 #2 of #3 from stock' => 'Fjernet #1 #2 av #3 fra husholdningen',
|
||||
'Removed #1 #2 of #3 from stock' => 'Fjernet #1 #2 #3 fra husholdningen',
|
||||
'About grocy' => 'Om Grocy',
|
||||
'Close' => 'Lukk',
|
||||
'#1 batteries are due to be charged within the next #2 days' => '#1 Batteri må lades innen de #2 dagene',
|
||||
'#1 batteries are due to be charged within the next #2 days' => '#1 Batteri må lades innen de #2 neste dagene',
|
||||
'#1 batteries are overdue to be charged' => '#1 Batteri har gått over fristen for å bli ladet opp',
|
||||
'#1 habits are due to be done within the next #2 days' => '#1 husoppgaver skal gjøres inne de #2 neste dagene',
|
||||
'#1 habits are overdue to be done' => '#1 husoppgaver har gått over fristen for utførelse',
|
||||
@@ -123,26 +122,26 @@ return array(
|
||||
'Consume #3 #1 of #2' => 'Forbruk #3 #1 #2',
|
||||
'Added #1 #2 of #3 to stock' => '#1 #2 #3 lagt til i husholdningen',
|
||||
'Stock amount of #1 is now #2 #3' => 'Husholdning antall #1 er nå #2 #3',
|
||||
'Tracked execution of habit #1 on #2' => 'Logget utførelse av husoppgave "#1" den #2',
|
||||
'Tracked charge cylce of battery #1 on #2' => 'Logget ladesyklus for batteri #1 og #2',
|
||||
'Tracked execution of habit #1 on #2' => 'Utførte husoppgave "#1" den #2',
|
||||
'Tracked charge cycle of battery #1 on #2' => 'Ladet #1 den #2',
|
||||
'Consume all #1 which are currently in stock' => 'Konsumér alle #1 som er i husholdningen',
|
||||
'All' => 'Alle',
|
||||
'Track charge cycle of battery #1' => 'Logg ladesyklus for batteri #1',
|
||||
'Track execution of habit #1' => 'Logg utførelse av husoppgave #1',
|
||||
'Track charge cycle of battery #1' => '#1 ladet',
|
||||
'Track execution of habit #1' => 'Utfør husoppgave #1',
|
||||
'Filter by location' => 'Filtrér etter lokasjon',
|
||||
'Search' => 'Søk',
|
||||
'Not logged in' => 'Ikke logget inn',
|
||||
'You have to select a product' => 'Du må velge et produkt',
|
||||
'You have to select a habit' => 'Du mpå velge en husoppgaven',
|
||||
'You have to select a habit' => 'Du må velge en husoppgaven',
|
||||
'You have to select a battery' => 'Du må velge et batteri',
|
||||
'A name is required' => 'Et navn kreves',
|
||||
'A name is required' => 'Vennligst fyll inn et navn',
|
||||
'A location is required' => 'En lokasjon kreves',
|
||||
'The amount cannot be lower than #1' => 'Antallet kan ikke være lavere enn #1',
|
||||
'This cannot be negative' => 'Dette kan ikke være negativt',
|
||||
'A quantity unit is required' => 'Forpakning antall/størrelse kreves',
|
||||
'A period type is required' => 'En periodetype kreves',
|
||||
'A best before date is required and must be later than today' => 'En best før dato kreves, denne må være senere enn i dag',
|
||||
'Settings' => 'Instillinger',
|
||||
'Settings' => 'Innstillinger',
|
||||
'This can only be before now' => 'Dette kan kun være før nå',
|
||||
'Calendar' => 'Kalender',
|
||||
'Recipes' => 'Oppskrifter',
|
||||
@@ -153,26 +152,71 @@ return array(
|
||||
'Edit recipe ingredient' => 'Endre ingrediens i oppskrift',
|
||||
'Are you sure to delete recipe "#1"?' => 'Er du sikker du ønsker å slette oppskrift "#1"?',
|
||||
'Are you sure to delete recipe ingredient "#1"?' => 'Er du sikker du ønsker å slette ingrediens "#1" fra oppskriften?',
|
||||
'Are you sure to empty the shopping list?' => 'Er du sikker du ønsker å slette handlelisten??',
|
||||
'Are you sure to empty the shopping list?' => 'Er du sikker du ønsker å slette handlelisten?',
|
||||
'Clear list' => 'Tøm liste',
|
||||
'Requirements fulfilled' => 'Krav oppfylt',
|
||||
'Requirements fulfilled' => 'Har jeg alt jeg trenger for denne oppskriften?',
|
||||
'Put missing products on shopping list' => 'Legg manglende produkter til handlelisten',
|
||||
'Not enough in stock, #1 ingredients missing' => 'Ikke nok i husholdningen, #1 ingrediens mangler',
|
||||
'Not enough in stock, #1 ingredients missing' => 'Ikke nok i husholdningen, #1 ingredienser mangler',
|
||||
'Enough in stock' => 'Nok i husholdningen',
|
||||
'Not enough in stock, #1 ingredients missing but already on the shopping list' => 'Ikke nok i husholdningen, #1 ingrediens mangler, men lagt til i handelisten',
|
||||
'Not enough in stock, #1 ingredients missing but already on the shopping list' => 'Ikke nok i husholdningen, #1 ingrediens mangler, men denne er på handelisten',
|
||||
'Expand to fullscreen' => 'Full skjerm',
|
||||
'Ingredients' => 'Ingrediens',
|
||||
'Preparation' => 'Forberedelse',
|
||||
'Ingredients' => 'Ingredienser',
|
||||
'Preparation' => 'Forberedelse / Slik gjør du',
|
||||
'Recipe' => 'Oppskrift',
|
||||
'Not enough in stock, #1 missing, #2 already on shopping list' => 'Ikke nok i husholdningen, #1 mangler, #2 allerede i handlisten',
|
||||
'Not enough in stock, #1 missing, #2 already on shopping list' => 'Ikke nok i husholdningen, mangler #1, er #2 på handlelisten',
|
||||
'Show notes' => 'Vis notater',
|
||||
'Put missing amount on shopping list' => 'Legg manglende til handlelisten',
|
||||
'Are you sure to put all missing ingredients for recipe "#1" on the shopping list?' => 'Er du sikker du ønsker å legge alle manglende ingredienser til oppskrift "#1"?',
|
||||
'Added for recipe #1' => 'Lagt til oppskrift #1',
|
||||
|
||||
'Added for recipe #1' => 'Lagt til fra oppskrift "#1"',
|
||||
'Manage users' => 'Administrer brukere',
|
||||
'User' => 'Bruker',
|
||||
'Users' => 'Brukere',
|
||||
'Are you sure to delete user "#1"?' => 'Er du sikker på du ønsker å slette bruker, "#1"?',
|
||||
'Create user' => 'Legg til bruker',
|
||||
'Edit user' => 'Endre på bruker',
|
||||
'First name' => 'Fornavn',
|
||||
'Last name' => 'Etternavn',
|
||||
'A username is required' => 'Et brukernavn er nødvendig',
|
||||
'Confirm password' => 'Bekreft passord',
|
||||
'Passwords do not match' => 'Passord er ikke like',
|
||||
'Change password' => 'Endre passord',
|
||||
'Done by' => 'Utført av',
|
||||
'Last done by' => 'Sist utført av',
|
||||
'Unknown' => 'Ukjent',
|
||||
'Filter by habit' => 'Filtrér husoppave',
|
||||
'Habits analysis' => 'Statistikk husoppgaver',
|
||||
'0 means suggestions for the next charge cycle are disabled' => '0 betyr neste ladesyklus er avslått',
|
||||
'Charge cycle interval (days)' => 'Ladesyklysintervall (Dager)',
|
||||
'Last price' => 'Siste pris',
|
||||
'Price history' => 'Prishistorikk',
|
||||
'No price history available' => 'Ingen prishistorikk tilgjengelig',
|
||||
'Price' => 'Pris',
|
||||
'in #1 per purchase quantity unit' => 'I #1 per kjøpt forpakning ',
|
||||
'The price cannot be lower than #1' => 'Prisen kan ikke være lavere enn #1',
|
||||
'#1 product expires within the next #2 days' => '#1 Produkt går ut på dato innen de #2 neste dagene',
|
||||
'#1 product is already expired' => '#1 Produkt er allerede gått ut på dato',
|
||||
'#1 product is below defined min. stock amount' => '#1 Produkt er under minimums husholdningsnivå',
|
||||
'Unit' => 'Enhet',
|
||||
'Units' => 'Enheter',
|
||||
'#1 habit is due to be done within the next #2 days' => '#1 husoppgave skal gjøres inne de #2 neste dagene',
|
||||
'#1 habit is overdue to be done' => '#1 husoppgave har gått over fristen for utførelse',
|
||||
'#1 battery is due to be charged within the next #2 days' => '#1 Batteri må lades innen #2 dager',
|
||||
'#1 battery is overdue to be charged' => '#1 Batteri har gått over fristen for å lades',
|
||||
'#1 unit was automatically added and will apply in addition to the amount entered here' => '#1 enhet ble automatisk lagt til i tillegg til hva som blir skrevet inn her',
|
||||
'in singular form' => 'I entall',
|
||||
'in plural form' => 'I flertall',
|
||||
'Never expires' => 'Går ikke ut på dato',
|
||||
'This cannot be lower than #1' => 'Dette kan ikke være lavere enn #1',
|
||||
'-1 means that this product never expires' => '-1 Betyr at dette produktet aldri går ut på dato',
|
||||
'Quantity unit' => 'Forpakning',
|
||||
'Only check if a single unit is in stock (a different quantity can then be used above)' => 'Huk av hvis du ønsker å bruke mindre enn forpakningsstørrelse i husholdningen',
|
||||
'Are you sure to consume all ingredients needed by recipe "#1" (ingredients marked with "check only if a single unit is in stock" will be ignored)?' => 'Er du sikker du ønsker å forbruke alle ingredienser for "#1" oppskriften? (Ingredienser merket med "bruke mindre enn forpakningsstørrelse i husholdningen" blir ignorert',
|
||||
'Removed all ingredients of recipe "#1" from stock' => 'Fjern alle ingredienser for "#1" oppskriften fra husholdningen.',
|
||||
'Consume all ingredients needed by this recipe' => 'Konsumer alle ingredienser for denne oppskriften',
|
||||
|
||||
//Constants
|
||||
'manually' => 'Manuel',
|
||||
'dynamic-regular' => 'Dynamisk Regulering',
|
||||
'dynamic-regular' => 'Automatisk',
|
||||
|
||||
//Technical component translations
|
||||
'timeago_locale' => 'no',
|
||||
@@ -188,11 +232,17 @@ return array(
|
||||
'Tinned food cupboard' => 'Boksematskapet',
|
||||
'Fridge' => 'Kjøleskapet',
|
||||
'Piece' => 'Ett',
|
||||
'Pieces' => 'Flere',
|
||||
'Pack' => 'Pakke',
|
||||
'Packs' => 'Pakker',
|
||||
'Glass' => 'Glass',
|
||||
'Glasses' => 'Glass',
|
||||
'Tin' => 'Hermetikkboks',
|
||||
'Tins' => 'Hermetikkbokser',
|
||||
'Can' => 'Boks',
|
||||
'Cans' => 'Bokser',
|
||||
'Bunch' => 'Klase',
|
||||
'Bunches' => 'Klaser',
|
||||
'Gummy bears' => 'Vingummibjørner',
|
||||
'Crisps' => 'Chips',
|
||||
'Eggs' => 'Egg',
|
||||
@@ -206,18 +256,18 @@ return array(
|
||||
'Cucumber' => 'Agurk',
|
||||
'Radish' => 'Reddik',
|
||||
'Tomato' => 'Tomat',
|
||||
'Changed towels in the bathroom' => 'Bytt handler på badet',
|
||||
'Changed towels in the bathroom' => 'Bytt handklær på badet',
|
||||
'Cleaned the kitchen floor' => 'Vasket kjøkkengulvet',
|
||||
'Warranty ends' => 'Garanti utgår',
|
||||
'TV remote control' => 'Fjernkontroll for TV',
|
||||
'Alarm clock' => 'Alarm klokke',
|
||||
'Alarm clock' => 'Alarmklokke',
|
||||
'Heat remote control' => 'Fjernkontroll for termostat',
|
||||
'Lawn mowed in the garden' => 'Kuttet gresse i hagen',
|
||||
'Lawn mowed in the garden' => 'Kuttet gresset i hagen',
|
||||
'Some good snacks' => 'Noen gode snacks',
|
||||
'Pizza dough' => 'Pizzadeig',
|
||||
'Sieved tomatoes' => 'Passierte Tomaten',
|
||||
'Sieved tomatoes' => 'Tomatpuré',
|
||||
'Salami' => 'Salami',
|
||||
'Toast' => 'Risted brød',
|
||||
'Toast' => 'Ristet brød',
|
||||
'Minced meat' => 'Kjøttdeig',
|
||||
'Pizza' => 'Pizza',
|
||||
'Spaghetti bolognese' => 'Spaghetti Bolognese',
|
||||
@@ -226,5 +276,11 @@ return array(
|
||||
'German' => 'Tysk',
|
||||
'Italian' => 'Italiensk',
|
||||
'Demo in different language' => 'Demo i annet språk',
|
||||
'This is the note content of the recipe ingredient' => 'Dette er notisen for ingrediensen i oppskriften'
|
||||
'This is the note content of the recipe ingredient' => 'Dette er notisen for ingrediensen i oppskriften',
|
||||
'Demo User' => 'Demo Bruker',
|
||||
'Gram' => 'Gram',
|
||||
'Grams' => 'Gram',
|
||||
'Flour' => 'Mel',
|
||||
'Pancakes' => 'Pannekaker',
|
||||
'Sugar' => 'Sukker'
|
||||
);
|
||||
|
@@ -22,8 +22,9 @@ class ApiKeyAuthMiddleware extends BaseMiddleware
|
||||
$route = $request->getAttribute('route');
|
||||
$routeName = $route->getName();
|
||||
|
||||
if ($this->ApplicationService->IsDemoInstallation())
|
||||
if (GROCY_IS_DEMO_INSTALL || GROCY_IS_EMBEDDED_INSTALL)
|
||||
{
|
||||
define('GROCY_AUTHENTICATED', true);
|
||||
$response = $next($request, $response);
|
||||
}
|
||||
else
|
||||
@@ -45,10 +46,23 @@ class ApiKeyAuthMiddleware extends BaseMiddleware
|
||||
|
||||
if (!$validSession && !$validApiKey)
|
||||
{
|
||||
define('GROCY_AUTHENTICATED', false);
|
||||
$response = $response->withStatus(401);
|
||||
}
|
||||
else
|
||||
elseif ($validApiKey)
|
||||
{
|
||||
$user = $apiKeyService->GetUserByApiKey($request->getHeaderLine($this->ApiKeyHeaderName));
|
||||
define('GROCY_AUTHENTICATED', true);
|
||||
define('GROCY_USER_ID', $user->id);
|
||||
|
||||
$response = $next($request, $response);
|
||||
}
|
||||
elseif ($validSession)
|
||||
{
|
||||
$user = $sessionService->GetUserBySessionKey($_COOKIE[$this->SessionCookieName]);
|
||||
define('GROCY_AUTHENTICATED', true);
|
||||
define('GROCY_USER_ID', $user->id);
|
||||
|
||||
$response = $next($request, $response);
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Grocy\Middleware;
|
||||
|
||||
class CliMiddleware extends BaseMiddleware
|
||||
{
|
||||
public function __invoke(\Slim\Http\Request $request, \Slim\Http\Response $response, callable $next)
|
||||
{
|
||||
if (PHP_SAPI !== 'cli')
|
||||
{
|
||||
$response->write('Please call this only from CLI');
|
||||
return $response->withHeader('Content-Type', 'text/plain')->withStatus(400);
|
||||
}
|
||||
else
|
||||
{
|
||||
$response = $next($request, $response);
|
||||
return $response->withHeader('Content-Type', 'text/plain');
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@
|
||||
namespace Grocy\Middleware;
|
||||
|
||||
use \Grocy\Services\SessionService;
|
||||
use \Grocy\Services\LocalizationService;
|
||||
|
||||
class SessionAuthMiddleware extends BaseMiddleware
|
||||
{
|
||||
@@ -18,23 +19,41 @@ class SessionAuthMiddleware extends BaseMiddleware
|
||||
{
|
||||
$route = $request->getAttribute('route');
|
||||
$routeName = $route->getName();
|
||||
$sessionService = new SessionService();
|
||||
|
||||
if ($routeName === 'root' || $this->ApplicationService->IsDemoInstallation())
|
||||
if ($routeName === 'root')
|
||||
{
|
||||
define('AUTHENTICATED', $this->ApplicationService->IsDemoInstallation());
|
||||
$response = $next($request, $response);
|
||||
}
|
||||
elseif (GROCY_IS_DEMO_INSTALL || GROCY_IS_EMBEDDED_INSTALL)
|
||||
{
|
||||
$user = $sessionService->GetDefaultUser();
|
||||
define('GROCY_AUTHENTICATED', true);
|
||||
define('GROCY_USER_USERNAME', $user->username);
|
||||
|
||||
$response = $next($request, $response);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sessionService = new SessionService();
|
||||
if ((!isset($_COOKIE[$this->SessionCookieName]) || !$sessionService->IsValidSession($_COOKIE[$this->SessionCookieName])) && $routeName !== 'login')
|
||||
{
|
||||
define('AUTHENTICATED', false);
|
||||
define('GROCY_AUTHENTICATED', false);
|
||||
$response = $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/login'));
|
||||
}
|
||||
else
|
||||
{
|
||||
define('AUTHENTICATED', $routeName !== 'login');
|
||||
if ($routeName !== 'login')
|
||||
{
|
||||
$user = $sessionService->GetUserBySessionKey($_COOKIE[$this->SessionCookieName]);
|
||||
define('GROCY_AUTHENTICATED', true);
|
||||
define('GROCY_USER_USERNAME', $user->username);
|
||||
define('GROCY_USER_ID', $user->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
define('GROCY_AUTHENTICATED', false);
|
||||
}
|
||||
|
||||
$response = $next($request, $response);
|
||||
}
|
||||
}
|
||||
|
@@ -3,4 +3,3 @@ AS
|
||||
SELECT product_id, SUM(amount) AS amount, MIN(best_before_date) AS best_before_date
|
||||
FROM stock
|
||||
GROUP BY product_id
|
||||
ORDER BY MIN(best_before_date) ASC
|
||||
|
@@ -3,4 +3,3 @@ AS
|
||||
SELECT habit_id, MAX(tracked_time) AS last_tracked_time
|
||||
FROM habits_log
|
||||
GROUP BY habit_id
|
||||
ORDER BY MAX(tracked_time) DESC
|
||||
|
@@ -3,4 +3,3 @@ AS
|
||||
SELECT battery_id, MAX(tracked_time) AS last_tracked_time
|
||||
FROM battery_charge_cycles
|
||||
GROUP BY battery_id
|
||||
ORDER BY MAX(tracked_time) DESC
|
||||
|
20
migrations/0026.sql
Normal file
20
migrations/0026.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
CREATE TABLE users (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
username TEXT NOT NULL UNIQUE,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
password TEXT NOT NULL,
|
||||
row_created_timestamp DATETIME DEFAULT (datetime('now', 'localtime'))
|
||||
);
|
||||
|
||||
DROP TABLE sessions;
|
||||
|
||||
CREATE TABLE sessions (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
session_key TEXT NOT NULL UNIQUE,
|
||||
user_id INTEGER NOT NULL,
|
||||
expires DATETIME,
|
||||
last_used DATETIME,
|
||||
row_created_timestamp DATETIME DEFAULT (datetime('now', 'localtime'))
|
||||
)
|
||||
|
24
migrations/0027.php
Normal file
24
migrations/0027.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
// This is executed inside DatabaseMigrationService class/context
|
||||
|
||||
$db = $this->DatabaseService->GetDbConnection();
|
||||
|
||||
if (defined('GROCY_HTTP_USER'))
|
||||
{
|
||||
// Migrate old user defined in config file to database
|
||||
$newUserRow = $db->users()->createRow(array(
|
||||
'username' => GROCY_HTTP_USER,
|
||||
'password' => password_hash(GROCY_HTTP_PASSWORD, PASSWORD_DEFAULT)
|
||||
));
|
||||
$newUserRow->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create default user "admin" with password "admin"
|
||||
$newUserRow = $db->users()->createRow(array(
|
||||
'username' => 'admin',
|
||||
'password' => password_hash('admin', PASSWORD_DEFAULT)
|
||||
));
|
||||
$newUserRow->save();
|
||||
}
|
13
migrations/0028.sql
Normal file
13
migrations/0028.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
ALTER TABLE habits_log
|
||||
ADD done_by_user_id;
|
||||
|
||||
DROP TABLE api_keys;
|
||||
|
||||
CREATE TABLE api_keys (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
api_key TEXT NOT NULL UNIQUE,
|
||||
user_id INTEGER NOT NULL,
|
||||
expires DATETIME,
|
||||
last_used DATETIME,
|
||||
row_created_timestamp DATETIME DEFAULT (datetime('now', 'localtime'))
|
||||
);
|
5
migrations/0029.sql
Normal file
5
migrations/0029.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE stock
|
||||
ADD price DECIMAL(15, 2);
|
||||
|
||||
ALTER TABLE stock_log
|
||||
ADD price DECIMAL(15, 2);
|
2
migrations/0030.sql
Normal file
2
migrations/0030.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE quantity_units
|
||||
ADD name_plural TEXT;
|
32
migrations/0031.php
Normal file
32
migrations/0031.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
// This is executed inside DatabaseMigrationService class/context
|
||||
|
||||
use \Grocy\Services\LocalizationService;
|
||||
$localizationService = new LocalizationService(GROCY_CULTURE);
|
||||
|
||||
$db = $this->DatabaseService->GetDbConnection();
|
||||
|
||||
if ($db->quantity_units()->count() === 0)
|
||||
{
|
||||
// Create 2 default quantity units
|
||||
$newRow = $db->quantity_units()->createRow(array(
|
||||
'name' => $localizationService->Localize('Piece'),
|
||||
'name_plural' => $localizationService->Localize('Pieces')
|
||||
));
|
||||
$newRow->save();
|
||||
$newRow = $db->quantity_units()->createRow(array(
|
||||
'name' => $localizationService->Localize('Pack'),
|
||||
'name_plural' => $localizationService->Localize('Packs')
|
||||
));
|
||||
$newRow->save();
|
||||
}
|
||||
|
||||
if ($db->locations()->count() === 0)
|
||||
{
|
||||
// Create a default location
|
||||
$newRow = $db->locations()->createRow(array(
|
||||
'name' => $localizationService->Localize('Fridge')
|
||||
));
|
||||
$newRow->save();
|
||||
}
|
20
migrations/0032.sql
Normal file
20
migrations/0032.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
DROP VIEW stock_current;
|
||||
CREATE VIEW stock_current
|
||||
AS
|
||||
SELECT product_id, SUM(amount) AS amount, MIN(best_before_date) AS best_before_date
|
||||
FROM stock
|
||||
GROUP BY product_id;
|
||||
|
||||
DROP VIEW habits_current;
|
||||
CREATE VIEW habits_current
|
||||
AS
|
||||
SELECT habit_id, MAX(tracked_time) AS last_tracked_time
|
||||
FROM habits_log
|
||||
GROUP BY habit_id;
|
||||
|
||||
DROP VIEW batteries_current;
|
||||
CREATE VIEW batteries_current
|
||||
AS
|
||||
SELECT battery_id, MAX(tracked_time) AS last_tracked_time
|
||||
FROM battery_charge_cycles
|
||||
GROUP BY battery_id;
|
29
migrations/0033.sql
Normal file
29
migrations/0033.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
DROP VIEW habits_current;
|
||||
CREATE VIEW habits_current
|
||||
AS
|
||||
SELECT
|
||||
h.id AS habit_id,
|
||||
MAX(l.tracked_time) AS last_tracked_time,
|
||||
CASE h.period_type
|
||||
WHEN 'manually' THEN '2999-12-31 23:59:59'
|
||||
WHEN 'dynamic-regular' THEN datetime(MAX(l.tracked_time), '+' || CAST(h.period_days AS TEXT) || ' day')
|
||||
END AS next_estimated_execution_time
|
||||
FROM habits h
|
||||
LEFT JOIN habits_log l
|
||||
ON h.id = l.habit_id
|
||||
GROUP BY h.id, h.period_days;
|
||||
|
||||
DROP VIEW batteries_current;
|
||||
CREATE VIEW batteries_current
|
||||
AS
|
||||
SELECT
|
||||
b.id AS battery_id,
|
||||
MAX(l.tracked_time) AS last_tracked_time,
|
||||
CASE WHEN b.charge_interval_days = 0
|
||||
THEN '2999-12-31 23:59:59'
|
||||
ELSE datetime(MAX(l.tracked_time), '+' || CAST(b.charge_interval_days AS TEXT) || ' day')
|
||||
END AS next_estimated_charge_time
|
||||
FROM batteries b
|
||||
LEFT JOIN battery_charge_cycles l
|
||||
ON b.id = l.battery_id
|
||||
GROUP BY b.id, b.charge_interval_days;
|
41
migrations/0034.sql
Normal file
41
migrations/0034.sql
Normal file
@@ -0,0 +1,41 @@
|
||||
ALTER TABLE recipes_pos
|
||||
ADD qu_id INTEGER;
|
||||
|
||||
UPDATE recipes_pos
|
||||
SET qu_id = (SELECT qu_id_stock FROM products where id = product_id);
|
||||
|
||||
CREATE TRIGGER recipes_pos_qu_id_default AFTER INSERT ON recipes_pos
|
||||
BEGIN
|
||||
UPDATE recipes_pos
|
||||
SET qu_id = (SELECT qu_id_stock FROM products where id = product_id)
|
||||
WHERE qu_id IS NULL
|
||||
AND id = NEW.id;
|
||||
END;
|
||||
|
||||
ALTER TABLE recipes_pos
|
||||
ADD only_check_single_unit_in_stock TINYINT NOT NULL DEFAULT 0;
|
||||
|
||||
DROP VIEW recipes_fulfillment;
|
||||
CREATE VIEW recipes_fulfillment
|
||||
AS
|
||||
SELECT
|
||||
r.id AS recipe_id,
|
||||
rp.id AS recipe_pos_id,
|
||||
rp.product_id AS product_id,
|
||||
rp.amount AS recipe_amount,
|
||||
IFNULL(sc.amount, 0) AS stock_amount,
|
||||
CASE WHEN IFNULL(sc.amount, 0) >= CASE WHEN rp.only_check_single_unit_in_stock = 1 THEN 1 ELSE IFNULL(rp.amount, 0) END THEN 1 ELSE 0 END AS need_fulfilled,
|
||||
CASE WHEN IFNULL(sc.amount, 0) - CASE WHEN rp.only_check_single_unit_in_stock = 1 THEN 1 ELSE IFNULL(rp.amount, 0) END < 0 THEN ABS(IFNULL(sc.amount, 0) - CASE WHEN rp.only_check_single_unit_in_stock = 1 THEN 1 ELSE IFNULL(rp.amount, 0) END) ELSE 0 END AS missing_amount,
|
||||
IFNULL(sl.amount, 0) AS amount_on_shopping_list,
|
||||
CASE WHEN IFNULL(sc.amount, 0) + IFNULL(sl.amount, 0) >= CASE WHEN rp.only_check_single_unit_in_stock = 1 THEN 1 ELSE IFNULL(rp.amount, 0) END THEN 1 ELSE 0 END AS need_fulfilled_with_shopping_list,
|
||||
rp.qu_id
|
||||
FROM recipes r
|
||||
JOIN recipes_pos rp
|
||||
ON r.id = rp.recipe_id
|
||||
LEFT JOIN (
|
||||
SELECT product_id, SUM(amount + amount_autoadded) AS amount
|
||||
FROM shopping_list
|
||||
GROUP BY product_id) sl
|
||||
ON rp.product_id = sl.product_id
|
||||
LEFT JOIN stock_current sc
|
||||
ON rp.product_id = sc.product_id;
|
@@ -7,7 +7,7 @@
|
||||
"TagManager": "https://github.com/max-favilli/tagmanager.git#3.0.2",
|
||||
"bootbox": "https://github.com/makeusabrew/bootbox.git#v5.x",
|
||||
"bootstrap": "^4.1.1",
|
||||
"bootstrap-side-navbar": "https://github.com/samrayner/bootstrap-side-navbar.git#1.0.1",
|
||||
"chart.js": "^2.7.2",
|
||||
"datatables.net": "^1.10.19",
|
||||
"datatables.net-bs4": "^1.10.19",
|
||||
"datatables.net-colreorder": "^1.5.1",
|
||||
|
@@ -62,6 +62,20 @@ a.discrete-link:focus {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.form-check-input.is-valid ~ .form-check-label,
|
||||
.was-validated .form-check-input:valid ~ .form-check-label {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* Hide the default up/down arrow buttons for number inputs because we use our own buttons in numberpicker */
|
||||
input[type='number'] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
input::-webkit-outer-spin-button,
|
||||
input::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
/* Navigation style customizations */
|
||||
#mainNav {
|
||||
background-color: #e5e5e5 !important;
|
||||
@@ -70,8 +84,7 @@ a.discrete-link:focus {
|
||||
}
|
||||
|
||||
.navbar-sidenav {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
overflow: hidden;
|
||||
border-top: 2px solid !important;
|
||||
}
|
||||
|
||||
@@ -175,7 +188,12 @@ td {
|
||||
width: auto !important;
|
||||
}
|
||||
|
||||
/* Third party component customizations - Popper.js */
|
||||
.tooltip .arrow {
|
||||
display: none;
|
||||
/* Third party component customizations - Bootstrap Combobox */
|
||||
.typeahead .active {
|
||||
background-color: #e5e5e5;
|
||||
}
|
||||
|
||||
/* Third party component customizations - Popper.js */
|
||||
.tooltip {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
@@ -19,6 +19,16 @@ U = function(relativePath)
|
||||
return Grocy.BaseUrl.replace(/\/$/, '') + relativePath;
|
||||
}
|
||||
|
||||
Pluralize = function(number, singularForm, pluralForm)
|
||||
{
|
||||
var text = singularForm;
|
||||
if (number != 1 && pluralForm !== null && !pluralForm.isEmpty())
|
||||
{
|
||||
text = pluralForm;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
if (!Grocy.ActiveNav.isEmpty())
|
||||
{
|
||||
var menuItem = $('#sidebarResponsive').find("[data-nav-for-page='" + Grocy.ActiveNav + "']");
|
||||
@@ -61,7 +71,12 @@ if (window.localStorage.getItem("sidebar_state") === "collapsed")
|
||||
$.timeago.settings.allowFuture = true;
|
||||
RefreshContextualTimeago = function()
|
||||
{
|
||||
$('time.timeago').timeago();
|
||||
$("time.timeago").each(function()
|
||||
{
|
||||
var element = $(this);
|
||||
var timestamp = element.attr("datetime");
|
||||
element.timeago("update", timestamp);
|
||||
});
|
||||
}
|
||||
RefreshContextualTimeago();
|
||||
|
||||
@@ -153,3 +168,18 @@ Grocy.FrontendHelpers.ValidateForm = function(formId)
|
||||
|
||||
$(form).addClass('was-validated');
|
||||
}
|
||||
|
||||
Grocy.FrontendHelpers.ShowGenericError = function(message, exception)
|
||||
{
|
||||
toastr.error(L(message) + '<br><br>' + L('Click to show technical details'), '', {
|
||||
onclick: function()
|
||||
{
|
||||
bootbox.alert({
|
||||
title: L('Error details'),
|
||||
message: JSON.stringify(exception, null, 4)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
console.error(exception);
|
||||
}
|
||||
|
@@ -7,7 +7,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
|
@@ -7,7 +7,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
@@ -28,16 +32,53 @@ $(document).on('click', '.track-charge-cycle-button', function(e)
|
||||
var trackedTime = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
Grocy.Api.Get('batteries/track-charge-cycle/' + batteryId + '?tracked_time=' + trackedTime,
|
||||
function(result)
|
||||
function()
|
||||
{
|
||||
$('#battery-' + batteryId + '-last-tracked-time').parent().effect('highlight', {}, 500);
|
||||
$('#battery-' + batteryId + '-last-tracked-time').fadeOut(500, function () {
|
||||
$(this).text(trackedTime).fadeIn(500);
|
||||
});
|
||||
$('#battery-' + batteryId + '-last-tracked-time-timeago').attr('datetime', trackedTime);
|
||||
RefreshContextualTimeago();
|
||||
Grocy.Api.Get('batteries/get-battery-details/' + batteryId,
|
||||
function(result)
|
||||
{
|
||||
var batteryRow = $('#battery-' + batteryId + '-row');
|
||||
var nextXDaysThreshold = moment().add($("#info-due-batteries").data("next-x-days"), "days");
|
||||
var now = moment();
|
||||
var nextExecutionTime = moment(result.next_estimated_charge_time);
|
||||
|
||||
toastr.success(L('Tracked charge cylce of battery #1 on #2', batteryName, trackedTime));
|
||||
batteryRow.removeClass("table-warning");
|
||||
batteryRow.removeClass("table-danger");
|
||||
if (nextExecutionTime.isBefore(now))
|
||||
{
|
||||
batteryRow.addClass("table-danger");
|
||||
}
|
||||
else if (nextExecutionTime.isBefore(nextXDaysThreshold))
|
||||
{
|
||||
batteryRow.addClass("table-warning");
|
||||
}
|
||||
|
||||
$('#battery-' + batteryId + '-last-tracked-time').parent().effect('highlight', { }, 500);
|
||||
$('#battery-' + batteryId + '-last-tracked-time').fadeOut(500, function()
|
||||
{
|
||||
$(this).text(trackedTime).fadeIn(500);
|
||||
});
|
||||
$('#battery-' + batteryId + '-last-tracked-time-timeago').attr('datetime', trackedTime);
|
||||
|
||||
if (result.battery.charge_interval_days != 0)
|
||||
{
|
||||
$('#battery-' + batteryId + '-next-charge-time').parent().effect('highlight', { }, 500);
|
||||
$('#battery-' + batteryId + '-next-charge-time').fadeOut(500, function()
|
||||
{
|
||||
$(this).text(result.next_estimated_charge_time).fadeIn(500);
|
||||
});
|
||||
$('#battery-' + batteryId + '-next-charge-time-timeago').attr('datetime', result.next_estimated_charge_time);
|
||||
}
|
||||
|
||||
toastr.success(L('Tracked charge cycle of battery #1 on #2', batteryName, trackedTime));
|
||||
RefreshContextualTimeago();
|
||||
RefreshStatistics();
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -45,3 +86,37 @@ $(document).on('click', '.track-charge-cycle-button', function(e)
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function RefreshStatistics()
|
||||
{
|
||||
var nextXDays = $("#info-due-batteries").data("next-x-days");
|
||||
Grocy.Api.Get('batteries/get-current',
|
||||
function(result)
|
||||
{
|
||||
var dueCount = 0;
|
||||
var overdueCount = 0;
|
||||
var now = moment();
|
||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||
result.forEach(element => {
|
||||
var date = moment(element.next_estimated_charge_time);
|
||||
if (date.isBefore(now))
|
||||
{
|
||||
overdueCount++;
|
||||
}
|
||||
else if (date.isBefore(nextXDaysThreshold))
|
||||
{
|
||||
dueCount++;
|
||||
}
|
||||
});
|
||||
|
||||
$("#info-due-batteries").text(Pluralize(dueCount, L('#1 battery is due to be charged within the next #2 days', dueCount, nextXDays), L('#1 batteries are due to be charged within the next #2 days', dueCount, nextXDays)));
|
||||
$("#info-overdue-batteries").text(Pluralize(overdueCount, L('#1 battery is overdue to be charged', overdueCount), L('#1 batteries are overdue to be charged', overdueCount)));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
RefreshStatistics();
|
||||
|
@@ -11,7 +11,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -35,12 +35,16 @@
|
||||
|
||||
$('#battery_id').on('change', function(e)
|
||||
{
|
||||
var batteryId = $(e.target).val();
|
||||
var input = $('#battery_id_text_input').val().toString();
|
||||
$('#battery_id_text_input').val(input);
|
||||
$('#battery_id').data('combobox').refresh();
|
||||
|
||||
var batteryId = $(e.target).val();
|
||||
if (batteryId)
|
||||
{
|
||||
Grocy.Components.BatteryCard.Refresh(batteryId);
|
||||
$('#tracked_time').find('input').focus();
|
||||
Grocy.FrontendHelpers.ValidateForm('batterytracking-form');
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -7,7 +7,7 @@ Grocy.Components.BatteryCard.Refresh = function(batteryId)
|
||||
{
|
||||
$('#batterycard-battery-name').text(batteryDetails.battery.name);
|
||||
$('#batterycard-battery-used_in').text(batteryDetails.battery.used_in);
|
||||
$('#batterycard-battery-last-charged').text((batteryDetails.last_charged || 'never'));
|
||||
$('#batterycard-battery-last-charged').text((batteryDetails.last_charged || L('never')));
|
||||
$('#batterycard-battery-last-charged-timeago').text($.timeago(batteryDetails.last_charged || ''));
|
||||
$('#batterycard-battery-charge-cycles-count').text((batteryDetails.charge_cycles_count || '0'));
|
||||
|
||||
|
@@ -2,7 +2,7 @@ Grocy.Components.DateTimePicker = { };
|
||||
|
||||
Grocy.Components.DateTimePicker.GetInputElement = function()
|
||||
{
|
||||
return $('.datetimepicker').find('input');
|
||||
return $('.datetimepicker').find('input').not(".form-check-input");
|
||||
}
|
||||
|
||||
Grocy.Components.DateTimePicker.GetValue = function()
|
||||
@@ -14,6 +14,14 @@ Grocy.Components.DateTimePicker.SetValue = function(value)
|
||||
{
|
||||
Grocy.Components.DateTimePicker.GetInputElement().val(value);
|
||||
Grocy.Components.DateTimePicker.GetInputElement().trigger('change');
|
||||
|
||||
// "Click" the shortcut checkbox when the desired value is
|
||||
// not the shortcut value and it is currently set
|
||||
var shortcutValue = $("#datetimepicker-shortcut").data("datetimepicker-shortcut-value");
|
||||
if (value != shortcutValue && $("#datetimepicker-shortcut").is(":checked"))
|
||||
{
|
||||
$("#datetimepicker-shortcut").click();
|
||||
}
|
||||
}
|
||||
|
||||
var startDate = null;
|
||||
@@ -79,7 +87,7 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
||||
var centuryEnd = Number.parseInt(now.getFullYear().toString().substring(0, 2) + '99');
|
||||
var format = Grocy.Components.DateTimePicker.GetInputElement().data('format');
|
||||
var nextInputElement = $(Grocy.Components.DateTimePicker.GetInputElement().data('next-input-selector'));
|
||||
|
||||
|
||||
//If input is empty and any arrow key is pressed, set date to today
|
||||
if (value.length === 0 && (e.keyCode === 38 || e.keyCode === 40 || e.keyCode === 37 || e.keyCode === 39))
|
||||
{
|
||||
@@ -93,7 +101,12 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
||||
}
|
||||
else if (value.length === 4 && !(Number.parseInt(value) > centuryStart && Number.parseInt(value) < centuryEnd))
|
||||
{
|
||||
Grocy.Components.DateTimePicker.SetValue((new Date()).getFullYear().toString() + value);
|
||||
var date = moment((new Date()).getFullYear().toString() + value);
|
||||
if (date.isBefore(moment()))
|
||||
{
|
||||
date.add(1, "year");
|
||||
}
|
||||
Grocy.Components.DateTimePicker.SetValue(date.format(format));
|
||||
nextInputElement.focus();
|
||||
}
|
||||
else if (value.length === 8 && $.isNumeric(value))
|
||||
@@ -101,6 +114,12 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
||||
Grocy.Components.DateTimePicker.SetValue(value.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3'));
|
||||
nextInputElement.focus();
|
||||
}
|
||||
else if (value.length === 7 && $.isNumeric(value.substring(0, 6)) && (value.substring(6, 7).toLowerCase() === "e" || value.substring(6, 7).toLowerCase() === "+"))
|
||||
{
|
||||
var date = moment(value.substring(0, 4) + "-" + value.substring(4, 6) + "-01").endOf("month");
|
||||
Grocy.Components.DateTimePicker.SetValue(date.format(format));
|
||||
nextInputElement.focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
var dateObj = moment(value, format, true);
|
||||
@@ -148,6 +167,14 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
||||
element.setCustomValidity("");
|
||||
}
|
||||
}
|
||||
|
||||
// "Click" the shortcut checkbox when the shortcut value was
|
||||
// entered manually and it is currently not set
|
||||
var shortcutValue = $("#datetimepicker-shortcut").data("datetimepicker-shortcut-value");
|
||||
if (value == shortcutValue && !$("#datetimepicker-shortcut").is(":checked"))
|
||||
{
|
||||
$("#datetimepicker-shortcut").click();
|
||||
}
|
||||
});
|
||||
|
||||
Grocy.Components.DateTimePicker.GetInputElement().on('input', function(e)
|
||||
@@ -160,3 +187,20 @@ $('.datetimepicker').on('update.datetimepicker', function(e)
|
||||
{
|
||||
Grocy.Components.DateTimePicker.GetInputElement().trigger('input');
|
||||
});
|
||||
|
||||
$("#datetimepicker-shortcut").on("click", function()
|
||||
{
|
||||
if (this.checked)
|
||||
{
|
||||
var value = $("#datetimepicker-shortcut").data("datetimepicker-shortcut-value");
|
||||
Grocy.Components.DateTimePicker.SetValue(value);
|
||||
Grocy.Components.DateTimePicker.GetInputElement().attr("readonly", "");
|
||||
$(Grocy.Components.DateTimePicker.GetInputElement().data('next-input-selector')).focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.Components.DateTimePicker.SetValue("");
|
||||
Grocy.Components.DateTimePicker.GetInputElement().removeAttr("readonly");
|
||||
Grocy.Components.DateTimePicker.GetInputElement().focus();
|
||||
}
|
||||
});
|
||||
|
@@ -6,9 +6,10 @@ Grocy.Components.HabitCard.Refresh = function(habitId)
|
||||
function(habitDetails)
|
||||
{
|
||||
$('#habitcard-habit-name').text(habitDetails.habit.name);
|
||||
$('#habitcard-habit-last-tracked').text((habitDetails.last_tracked || 'never'));
|
||||
$('#habitcard-habit-last-tracked').text((habitDetails.last_tracked || L('never')));
|
||||
$('#habitcard-habit-last-tracked-timeago').text($.timeago(habitDetails.last_tracked || ''));
|
||||
$('#habitcard-habit-tracked-count').text((habitDetails.tracked_count || '0'));
|
||||
$('#habitcard-habit-last-done-by').text((habitDetails.last_done_by.display_name || L('Unknown')));
|
||||
|
||||
EmptyElementWhenMatches('#habitcard-habit-last-tracked-timeago', L('timeago_nan'));
|
||||
},
|
||||
|
15
public/viewjs/components/numberpicker.js
Normal file
15
public/viewjs/components/numberpicker.js
Normal file
@@ -0,0 +1,15 @@
|
||||
$(".numberpicker-down-button").unbind('click').on("click", function ()
|
||||
{
|
||||
var inputElement = $(this).parent().parent().find('input[type="number"]')[0];
|
||||
inputElement.stepDown();
|
||||
$(inputElement).trigger('keyup');
|
||||
$(inputElement).trigger('change');
|
||||
});
|
||||
|
||||
$(".numberpicker-up-button").unbind('click').on("click", function()
|
||||
{
|
||||
var inputElement = $(this).parent().parent().find('input[type="number"]')[0];
|
||||
inputElement.stepUp();
|
||||
$(inputElement).trigger('keyup');
|
||||
$(inputElement).trigger('change');
|
||||
});
|
@@ -5,15 +5,25 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function(productDetails)
|
||||
{
|
||||
var stockAmount = productDetails.stock_amount || '0';
|
||||
$('#productcard-product-name').text(productDetails.product.name);
|
||||
$('#productcard-product-stock-amount').text(productDetails.stock_amount || '0');
|
||||
$('#productcard-product-stock-amount').text(stockAmount);
|
||||
$('#productcard-product-stock-qu-name').text(productDetails.quantity_unit_stock.name);
|
||||
$('#productcard-product-stock-qu-name2').text(productDetails.quantity_unit_stock.name);
|
||||
$('#productcard-product-stock-qu-name2').text(Pluralize(stockAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural));
|
||||
$('#productcard-product-last-purchased').text((productDetails.last_purchased || L('never')).substring(0, 10));
|
||||
$('#productcard-product-last-purchased-timeago').text($.timeago(productDetails.last_purchased || ''));
|
||||
$('#productcard-product-last-used').text((productDetails.last_used || L('never')).substring(0, 10));
|
||||
$('#productcard-product-last-used-timeago').text($.timeago(productDetails.last_used || ''));
|
||||
|
||||
if (productDetails.last_price !== null)
|
||||
{
|
||||
$('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price).toLocaleString() + ' ' + Grocy.Currency);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#productcard-product-last-price').text(L('Unknown'));
|
||||
}
|
||||
|
||||
EmptyElementWhenMatches('#productcard-product-last-purchased-timeago', L('timeago_nan'));
|
||||
EmptyElementWhenMatches('#productcard-product-last-used-timeago', L('timeago_nan'));
|
||||
},
|
||||
@@ -22,4 +32,88 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
|
||||
Grocy.Api.Get('stock/get-product-price-history/' + productId,
|
||||
function(priceHistoryDataPoints)
|
||||
{
|
||||
if (priceHistoryDataPoints.length > 0)
|
||||
{
|
||||
$("#productcard-product-price-history-chart").removeClass("d-none");
|
||||
$("#productcard-no-price-data-hint").addClass("d-none");
|
||||
|
||||
Grocy.Components.ProductCard.ReInitPriceHistoryChart();
|
||||
priceHistoryDataPoints.forEach((dataPoint) =>
|
||||
{
|
||||
Grocy.Components.ProductCard.PriceHistoryChart.data.labels.push(moment(dataPoint.date).toDate());
|
||||
|
||||
var dataset = Grocy.Components.ProductCard.PriceHistoryChart.data.datasets[0];
|
||||
dataset.data.push(dataPoint.price);
|
||||
});
|
||||
Grocy.Components.ProductCard.PriceHistoryChart.update();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#productcard-product-price-history-chart").addClass("d-none");
|
||||
$("#productcard-no-price-data-hint").removeClass("d-none");
|
||||
}
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Grocy.Components.ProductCard.ReInitPriceHistoryChart = function()
|
||||
{
|
||||
if (typeof Grocy.Components.ProductCard.PriceHistoryChart !== "undefined")
|
||||
{
|
||||
Grocy.Components.ProductCard.PriceHistoryChart.destroy();
|
||||
}
|
||||
|
||||
var format = 'YYYY-MM-DD';
|
||||
Grocy.Components.ProductCard.PriceHistoryChart = new Chart(document.getElementById("productcard-product-price-history-chart"), {
|
||||
type: "line",
|
||||
data: {
|
||||
labels: [ //Date objects
|
||||
// Will be populated in Grocy.Components.ProductCard.Refresh
|
||||
],
|
||||
datasets: [{
|
||||
data: [
|
||||
// Will be populated in Grocy.Components.ProductCard.Refresh
|
||||
],
|
||||
fill: false,
|
||||
borderColor: '#17a2b8'
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'time',
|
||||
time: {
|
||||
parser: format,
|
||||
round: 'day',
|
||||
tooltipFormat: format,
|
||||
unit: 'day',
|
||||
unitStepSize: 10,
|
||||
displayFormats: {
|
||||
'day': format
|
||||
}
|
||||
},
|
||||
ticks: {
|
||||
autoSkip: true,
|
||||
maxRotation: 0
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}]
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
Grocy.Components.ProductPicker = { };
|
||||
|
||||
Grocy.Components.ProductPicker.GetPicker = function ()
|
||||
Grocy.Components.ProductPicker.GetPicker = function()
|
||||
{
|
||||
return $('#product_id');
|
||||
}
|
||||
@@ -43,7 +43,7 @@ Grocy.Components.ProductPicker.HideCustomError = function()
|
||||
$("#custom-productpicker-error").addClass("d-none");
|
||||
}
|
||||
|
||||
$('.combobox').combobox({
|
||||
$('.product-combobox').combobox({
|
||||
appendId: '_text_input',
|
||||
bsVersion: '4'
|
||||
});
|
||||
|
62
public/viewjs/components/userpicker.js
Normal file
62
public/viewjs/components/userpicker.js
Normal file
@@ -0,0 +1,62 @@
|
||||
Grocy.Components.UserPicker = { };
|
||||
|
||||
Grocy.Components.UserPicker.GetPicker = function()
|
||||
{
|
||||
return $('#user_id');
|
||||
}
|
||||
|
||||
Grocy.Components.UserPicker.GetInputElement = function()
|
||||
{
|
||||
return $('#user_id_text_input');
|
||||
}
|
||||
|
||||
Grocy.Components.UserPicker.GetValue = function()
|
||||
{
|
||||
return $('#user_id').val();
|
||||
}
|
||||
|
||||
Grocy.Components.UserPicker.SetValue = function(value)
|
||||
{
|
||||
Grocy.Components.UserPicker.GetInputElement().val(value);
|
||||
Grocy.Components.UserPicker.GetInputElement().trigger('change');
|
||||
}
|
||||
|
||||
$('.user-combobox').combobox({
|
||||
appendId: '_text_input',
|
||||
bsVersion: '4'
|
||||
});
|
||||
|
||||
var prefillUser = Grocy.Components.UserPicker.GetPicker().parent().data('prefill-by-username').toString();
|
||||
if (typeof prefillUser !== "undefined")
|
||||
{
|
||||
var possibleOptionElement = $("#user_id option[data-additional-searchdata*='" + prefillUser + "']").first();
|
||||
if (possibleOptionElement.length === 0)
|
||||
{
|
||||
possibleOptionElement = $("#user_id option:contains('" + prefillUser + "')").first();
|
||||
}
|
||||
|
||||
if (possibleOptionElement.length > 0)
|
||||
{
|
||||
$('#user_id').val(possibleOptionElement.val());
|
||||
$('#user_id').data('combobox').refresh();
|
||||
$('#user_id').trigger('change');
|
||||
|
||||
var nextInputElement = $(Grocy.Components.UserPicker.GetPicker().parent().data('next-input-selector').toString());
|
||||
nextInputElement.focus();
|
||||
}
|
||||
}
|
||||
|
||||
var prefillUserId = Grocy.Components.UserPicker.GetPicker().parent().data('prefill-by-user-id').toString();
|
||||
if (typeof prefillUserId !== "undefined")
|
||||
{
|
||||
var possibleOptionElement = $("#user_id option[value='" + prefillUserId + "']").first();
|
||||
if (possibleOptionElement.length > 0)
|
||||
{
|
||||
$('#user_id').val(possibleOptionElement.val());
|
||||
$('#user_id').data('combobox').refresh();
|
||||
$('#user_id').trigger('change');
|
||||
|
||||
var nextInputElement = $(Grocy.Components.UserPicker.GetPicker().parent().data('next-input-selector').toString());
|
||||
nextInputElement.focus();
|
||||
}
|
||||
}
|
@@ -11,7 +11,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -7,7 +7,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
|
41
public/viewjs/habitsanalysis.js
Normal file
41
public/viewjs/habitsanalysis.js
Normal file
@@ -0,0 +1,41 @@
|
||||
var habitsAnalysisTable = $('#habits-analysis-table').DataTable({
|
||||
'paginate': false,
|
||||
'order': [[1, 'desc']],
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#habit-filter").on("change", function()
|
||||
{
|
||||
var value = $(this).val();
|
||||
var text = $("#habit-filter option:selected").text();
|
||||
if (value === "all")
|
||||
{
|
||||
text = "";
|
||||
}
|
||||
|
||||
habitsAnalysisTable.column(0).search(text).draw();
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
{
|
||||
var value = $(this).val();
|
||||
if (value === "all")
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
habitsAnalysisTable.search(value).draw();
|
||||
});
|
||||
|
||||
if (typeof GetUriParam("habit") !== "undefined")
|
||||
{
|
||||
$("#habit-filter").val(GetUriParam("habit"));
|
||||
$("#habit-filter").trigger("change");
|
||||
}
|
@@ -7,7 +7,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
@@ -28,16 +32,53 @@ $(document).on('click', '.track-habit-button', function(e)
|
||||
var trackedTime = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
Grocy.Api.Get('habits/track-habit-execution/' + habitId + '?tracked_time=' + trackedTime,
|
||||
function(result)
|
||||
function()
|
||||
{
|
||||
$('#habit-' + habitId + '-last-tracked-time').parent().effect('highlight', {}, 500);
|
||||
$('#habit-' + habitId + '-last-tracked-time').fadeOut(500, function () {
|
||||
$(this).text(trackedTime).fadeIn(500);
|
||||
});
|
||||
$('#habit-' + habitId + '-last-tracked-time-timeago').attr('datetime', trackedTime);
|
||||
RefreshContextualTimeago();
|
||||
Grocy.Api.Get('habits/get-habit-details/' + habitId,
|
||||
function(result)
|
||||
{
|
||||
var habitRow = $('#habit-' + habitId + '-row');
|
||||
var nextXDaysThreshold = moment().add($("#info-due-habits").data("next-x-days"), "days");
|
||||
var now = moment();
|
||||
var nextExecutionTime = moment(result.next_estimated_execution_time);
|
||||
|
||||
toastr.success(L('Tracked execution of habit #1 on #2', habitName, trackedTime));
|
||||
habitRow.removeClass("table-warning");
|
||||
habitRow.removeClass("table-danger");
|
||||
if (nextExecutionTime.isBefore(now))
|
||||
{
|
||||
habitRow.addClass("table-danger");
|
||||
}
|
||||
else if (nextExecutionTime.isBefore(nextXDaysThreshold))
|
||||
{
|
||||
habitRow.addClass("table-warning");
|
||||
}
|
||||
|
||||
$('#habit-' + habitId + '-last-tracked-time').parent().effect('highlight', { }, 500);
|
||||
$('#habit-' + habitId + '-last-tracked-time').fadeOut(500, function()
|
||||
{
|
||||
$(this).text(trackedTime).fadeIn(500);
|
||||
});
|
||||
$('#habit-' + habitId + '-last-tracked-time-timeago').attr('datetime', trackedTime);
|
||||
|
||||
if (result.habit.period_type == "dynamic-regular")
|
||||
{
|
||||
$('#habit-' + habitId + '-next-execution-time').parent().effect('highlight', { }, 500);
|
||||
$('#habit-' + habitId + '-next-execution-time').fadeOut(500, function()
|
||||
{
|
||||
$(this).text(result.next_estimated_execution_time).fadeIn(500);
|
||||
});
|
||||
$('#habit-' + habitId + '-next-execution-time-timeago').attr('datetime', result.next_estimated_execution_time);
|
||||
}
|
||||
|
||||
toastr.success(L('Tracked execution of habit #1 on #2', habitName, trackedTime));
|
||||
RefreshContextualTimeago();
|
||||
RefreshStatistics();
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -45,3 +86,37 @@ $(document).on('click', '.track-habit-button', function(e)
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function RefreshStatistics()
|
||||
{
|
||||
var nextXDays = $("#info-due-habits").data("next-x-days");
|
||||
Grocy.Api.Get('habits/get-current',
|
||||
function(result)
|
||||
{
|
||||
var dueCount = 0;
|
||||
var overdueCount = 0;
|
||||
var now = moment();
|
||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||
result.forEach(element => {
|
||||
var date = moment(element.next_estimated_execution_time);
|
||||
if (date.isBefore(now))
|
||||
{
|
||||
overdueCount++;
|
||||
}
|
||||
else if (date.isBefore(nextXDaysThreshold))
|
||||
{
|
||||
dueCount++;
|
||||
}
|
||||
});
|
||||
|
||||
$("#info-due-habits").text(Pluralize(dueCount, L('#1 habit is due to be done within the next #2 days', dueCount, nextXDays), L('#1 habits are due to be done within the next #2 days', dueCount, nextXDays)));
|
||||
$("#info-overdue-habits").text(Pluralize(overdueCount, L('#1 habit is overdue to be done', overdueCount), L('#1 habits are overdue to be done', overdueCount)));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
RefreshStatistics();
|
||||
|
@@ -7,7 +7,7 @@
|
||||
Grocy.Api.Get('habits/get-habit-details/' + jsonForm.habit_id,
|
||||
function (habitDetails)
|
||||
{
|
||||
Grocy.Api.Get('habits/track-habit-execution/' + jsonForm.habit_id + '?tracked_time=' + Grocy.Components.DateTimePicker.GetValue(),
|
||||
Grocy.Api.Get('habits/track-habit-execution/' + jsonForm.habit_id + '?tracked_time=' + Grocy.Components.DateTimePicker.GetValue() + "&done_by=" + Grocy.Components.UserPicker.GetValue(),
|
||||
function(result)
|
||||
{
|
||||
toastr.success(L('Tracked execution of habit #1 on #2', habitDetails.habit.name, Grocy.Components.DateTimePicker.GetValue()));
|
||||
@@ -34,12 +34,16 @@
|
||||
|
||||
$('#habit_id').on('change', function(e)
|
||||
{
|
||||
var habitId = $(e.target).val();
|
||||
var input = $('#habit_id_text_input').val().toString();
|
||||
$('#habit_id_text_input').val(input);
|
||||
$('#habit_id').data('combobox').refresh();
|
||||
|
||||
var habitId = $(e.target).val();
|
||||
if (habitId)
|
||||
{
|
||||
Grocy.Components.HabitCard.Refresh(habitId);
|
||||
Grocy.Components.DateTimePicker.GetInputElement().focus();
|
||||
Grocy.FrontendHelpers.ValidateForm('habittracking-form');
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -7,7 +7,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
|
@@ -7,7 +7,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
var createdApiKeyId = GetUriParam('CreatedApiKeyId');
|
||||
|
@@ -18,7 +18,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -7,7 +7,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
|
@@ -9,7 +9,13 @@
|
||||
{
|
||||
var amount = jsonForm.amount * productDetails.product.qu_factor_purchase_to_stock;
|
||||
|
||||
Grocy.Api.Get('stock/add-product/' + jsonForm.product_id + '/' + amount + '?bestbeforedate=' + Grocy.Components.DateTimePicker.GetValue(),
|
||||
var price = "";
|
||||
if (!jsonForm.price.toString().isEmpty())
|
||||
{
|
||||
price = parseFloat(jsonForm.price).toFixed(2);
|
||||
}
|
||||
|
||||
Grocy.Api.Get('stock/add-product/' + jsonForm.product_id + '/' + amount + '?bestbeforedate=' + Grocy.Components.DateTimePicker.GetValue() + '&price=' + price,
|
||||
function(result)
|
||||
{
|
||||
var addBarcode = GetUriParam('addbarcodetoselection');
|
||||
@@ -43,6 +49,7 @@
|
||||
else
|
||||
{
|
||||
$('#amount').val(0);
|
||||
$('#price').val('');
|
||||
Grocy.Components.DateTimePicker.SetValue('');
|
||||
Grocy.Components.ProductPicker.SetValue('');
|
||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||
@@ -74,10 +81,21 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
function(productDetails)
|
||||
{
|
||||
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
||||
$('#price').val(productDetails.last_price);
|
||||
|
||||
if (productDetails.product.default_best_before_days.toString() !== '0')
|
||||
{
|
||||
Grocy.Components.DateTimePicker.SetValue(moment().add(productDetails.product.default_best_before_days, 'days').format('YYYY-MM-DD'));
|
||||
if (productDetails.product.default_best_before_days == -1)
|
||||
{
|
||||
if (!$("#datetimepicker-shortcut").is(":checked"))
|
||||
{
|
||||
$("#datetimepicker-shortcut").click();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.Components.DateTimePicker.SetValue(moment().add(productDetails.product.default_best_before_days, 'days').format('YYYY-MM-DD'));
|
||||
}
|
||||
$('#amount').focus();
|
||||
}
|
||||
else
|
||||
|
@@ -11,7 +11,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -7,7 +7,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
|
@@ -23,7 +23,11 @@ var recipesPosTables = $('#recipes-pos-table').DataTable({
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function ()
|
||||
@@ -82,6 +86,7 @@ $(document).on('click', '.recipe-pos-delete-button', function(e)
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(), function() { }, function() { });
|
||||
Grocy.Api.Get('delete-object/recipes_pos/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
@@ -112,6 +117,7 @@ $(document).on('click', '.recipe-pos-order-missing-button', function(e)
|
||||
Grocy.Api.Post('add-object/shopping_list', jsonData,
|
||||
function(result)
|
||||
{
|
||||
Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(), function () { }, function () { });
|
||||
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
||||
},
|
||||
function(xhr)
|
||||
@@ -127,3 +133,33 @@ $(document).on('click', '.recipe-pos-show-note-button', function(e)
|
||||
|
||||
bootbox.alert(note);
|
||||
});
|
||||
|
||||
$(document).on('click', '.recipe-pos-edit-button', function (e)
|
||||
{
|
||||
var recipePosId = $(e.currentTarget).attr('data-recipe-pos-id');
|
||||
|
||||
Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/recipe/' + Grocy.EditObjectId + '/pos/' + recipePosId);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("#recipe-pos-add-button").on("click", function(e)
|
||||
{
|
||||
Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/recipe/' + Grocy.EditObjectId + '/pos/new');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@@ -2,7 +2,7 @@
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
var jsonData = $('#recipe-pos-form').serializeJSON();
|
||||
var jsonData = $('#recipe-pos-form').serializeJSON({ checkboxUncheckedValue: "0" });
|
||||
jsonData.recipe_id = Grocy.EditObjectParentId;
|
||||
console.log(jsonData);
|
||||
if (Grocy.EditMode === 'create')
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -44,7 +44,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function (productDetails)
|
||||
{
|
||||
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
||||
if (!$("#only_check_single_unit_in_stock").is(":checked"))
|
||||
{
|
||||
$("#qu_id").val(productDetails.quantity_unit_stock.id);
|
||||
}
|
||||
$('#amount').focus();
|
||||
Grocy.FrontendHelpers.ValidateForm('recipe-pos-form');
|
||||
},
|
||||
@@ -76,12 +79,12 @@ $('#amount').on('focus', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$('#recipe-pos-form input').keyup(function (event)
|
||||
$('#recipe-pos-form input').keyup(function(event)
|
||||
{
|
||||
Grocy.FrontendHelpers.ValidateForm('recipe-pos-form');
|
||||
});
|
||||
|
||||
$('#recipe-pos-form input').keydown(function (event)
|
||||
$('#recipe-pos-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
@@ -96,3 +99,16 @@ $('#recipe-pos-form input').keydown(function (event)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$("#only_check_single_unit_in_stock").on("click", function()
|
||||
{
|
||||
if (this.checked)
|
||||
{
|
||||
$("#qu_id").removeAttr("disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#qu_id").attr("disabled", "");
|
||||
Grocy.Components.ProductPicker.GetPicker().trigger("change");
|
||||
}
|
||||
});
|
||||
|
@@ -1,13 +1,14 @@
|
||||
var recipesTables = $('#recipes-table').DataTable({
|
||||
'paginate': false,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'order': [[0, 'asc']],
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
},
|
||||
'select': 'single',
|
||||
'initComplete': function()
|
||||
{
|
||||
@@ -32,7 +33,7 @@ $("#search").on("keyup", function()
|
||||
recipesTables.search(value).draw();
|
||||
});
|
||||
|
||||
$(document).on('click', '.recipe-delete-button', function(e)
|
||||
$("#selectedRecipeDeleteButton").on('click', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-recipe-name');
|
||||
var objectId = $(e.currentTarget).attr('data-recipe-id');
|
||||
@@ -104,6 +105,42 @@ $(document).on('click', '.recipe-order-missing-button', function(e)
|
||||
});
|
||||
});
|
||||
|
||||
$("#selectedRecipeConsumeButton").on('click', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-recipe-name');
|
||||
var objectId = $(e.currentTarget).attr('data-recipe-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: L('Are you sure to consume all ingredients needed by recipe "#1" (ingredients marked with "check only if a single unit is in stock" will be ignored)?', objectName),
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: L('Yes'),
|
||||
className: 'btn-success'
|
||||
},
|
||||
cancel: {
|
||||
label: L('No'),
|
||||
className: 'btn-danger'
|
||||
}
|
||||
},
|
||||
callback: function(result)
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Get('recipes/consume-recipe/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
toastr.success(L('Removed all ingredients of recipe "#1" from stock', objectName));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
recipesTables.on('select', function(e, dt, type, indexes)
|
||||
{
|
||||
if (type === 'row')
|
||||
|
@@ -7,7 +7,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
@@ -23,10 +27,15 @@ $("#search").on("keyup", function()
|
||||
|
||||
$(document).on('click', '.shoppinglist-delete-button', function (e)
|
||||
{
|
||||
Grocy.Api.Get('delete-object/shopping_list/' + $(e.currentTarget).attr('data-shoppinglist-id'),
|
||||
var shoppingListItemId = $(e.currentTarget).attr('data-shoppinglist-id');
|
||||
|
||||
Grocy.Api.Get('delete-object/shopping_list/' + shoppingListItemId,
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/shoppinglist');
|
||||
$('#shoppinglistitem-' + shoppingListItemId + '-row').fadeOut(500, function()
|
||||
{
|
||||
$(this).remove();
|
||||
});
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -70,7 +79,10 @@ $(document).on('click', '#clear-shopping-list', function(e)
|
||||
Grocy.Api.Get('stock/clear-shopping-list',
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/shoppinglist');
|
||||
$('#shoppinglist-table tbody tr').fadeOut(500, function()
|
||||
{
|
||||
$(this).remove();
|
||||
});
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -8,7 +8,11 @@
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#location-filter").on("change", function()
|
||||
@@ -41,28 +45,62 @@ $(document).on('click', '.product-consume-button', function(e)
|
||||
var consumeAmount = $(e.currentTarget).attr('data-consume-amount');
|
||||
|
||||
Grocy.Api.Get('stock/consume-product/' + productId + '/' + consumeAmount,
|
||||
function(result)
|
||||
function()
|
||||
{
|
||||
var oldAmount = parseInt($('#product-' + productId + '-amount').text());
|
||||
var newAmount = oldAmount - consumeAmount;
|
||||
if (newAmount === 0)
|
||||
{
|
||||
$('#product-' + productId + '-row').fadeOut(500, function()
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function(result)
|
||||
{
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#product-' + productId + '-amount').parent().effect('highlight', { }, 500);
|
||||
$('#product-' + productId + '-amount').fadeOut(500, function()
|
||||
{
|
||||
$(this).text(newAmount).fadeIn(500);
|
||||
});
|
||||
$('#product-' + productId + '-consume-all-button').attr('data-consume-amount', newAmount);
|
||||
}
|
||||
var productRow = $('#product-' + productId + '-row');
|
||||
var expiringThreshold = moment().add("-" + $("#info-expiring-products").data("next-x-days"), "days");
|
||||
var now = moment();
|
||||
var nextBestBeforeDate = moment(result.next_best_before_date);
|
||||
|
||||
toastr.success(L('Removed #1 #2 of #3 from stock', consumeAmount, productQuName, productName));
|
||||
productRow.removeClass("table-warning");
|
||||
productRow.removeClass("table-danger");
|
||||
if (now.isAfter(nextBestBeforeDate))
|
||||
{
|
||||
productRow.addClass("table-danger");
|
||||
}
|
||||
if (expiringThreshold.isAfter(nextBestBeforeDate))
|
||||
{
|
||||
productRow.addClass("table-warning");
|
||||
}
|
||||
|
||||
var oldAmount = parseInt($('#product-' + productId + '-amount').text());
|
||||
var newAmount = oldAmount - consumeAmount;
|
||||
if (newAmount === 0)
|
||||
{
|
||||
$('#product-' + productId + '-row').fadeOut(500, function()
|
||||
{
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#product-' + productId + '-amount').parent().effect('highlight', { }, 500);
|
||||
$('#product-' + productId + '-amount').fadeOut(500, function()
|
||||
{
|
||||
$(this).text(newAmount).fadeIn(500);
|
||||
});
|
||||
$('#product-' + productId + '-consume-all-button').attr('data-consume-amount', newAmount);
|
||||
|
||||
$('#product-' + productId + '-next-best-before-date').parent().effect('highlight', { }, 500);
|
||||
$('#product-' + productId + '-next-best-before-date').fadeOut(500, function()
|
||||
{
|
||||
$(this).text(result.next_best_before_date).fadeIn(500);
|
||||
});
|
||||
$('#product-' + productId + '-next-best-before-date-timeago').attr('datetime', result.next_best_before_date);
|
||||
}
|
||||
|
||||
toastr.success(L('Removed #1 #2 of #3 from stock', consumeAmount, productQuName, productName));
|
||||
RefreshContextualTimeago();
|
||||
RefreshStatistics();
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -70,3 +108,37 @@ $(document).on('click', '.product-consume-button', function(e)
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function RefreshStatistics()
|
||||
{
|
||||
Grocy.Api.Get('stock/get-current-stock',
|
||||
function(result)
|
||||
{
|
||||
var amountSum = 0;
|
||||
result.forEach(element => {
|
||||
amountSum += parseInt(element.amount);
|
||||
});
|
||||
$("#info-current-stock").text(result.length + " " + Pluralize(result.length, L('Product'), L('Products')) + ", " + amountSum.toString() + " " + Pluralize(amountSum, L('Unit'), L('Units')));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
|
||||
var nextXDays = $("#info-expiring-products").data("next-x-days");
|
||||
Grocy.Api.Get('stock/get-current-volatil-stock?expiring_days=' + nextXDays,
|
||||
function(result)
|
||||
{
|
||||
$("#info-expiring-products").text(Pluralize(result.expiring_products.length, L('#1 product expires within the next #2 days', result.expiring_products.length, nextXDays), L('#1 products expiring within the next #2 days', result.expiring_products.length, nextXDays)));
|
||||
$("#info-expired-products").text(Pluralize(result.expired_products.length, L('#1 product is already expired', result.expired_products.length), L('#1 products are already expired', result.expired_products.length)));
|
||||
$("#info-missing-products").text(Pluralize(result.missing_products.length, L('#1 product is below defined min. stock amount', result.missing_products.length), L('#1 products are below defined min. stock amount', result.missing_products.length)));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
RefreshStatistics();
|
||||
|
73
public/viewjs/userform.js
Normal file
73
public/viewjs/userform.js
Normal file
@@ -0,0 +1,73 @@
|
||||
$('#save-user-button').on('click', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
if (Grocy.EditMode === 'create')
|
||||
{
|
||||
Grocy.Api.Post('users/create', $('#user-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/users');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.Api.Post('users/edit/' + Grocy.EditObjectId, $('#user-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/users');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$('#user-form input').keyup(function (event)
|
||||
{
|
||||
var element = document.getElementById("password_confirm");
|
||||
if ($("#password").val() !== $("#password_confirm").val())
|
||||
{
|
||||
element.setCustomValidity("error");
|
||||
}
|
||||
else
|
||||
{
|
||||
element.setCustomValidity("");
|
||||
}
|
||||
|
||||
Grocy.FrontendHelpers.ValidateForm('user-form');
|
||||
});
|
||||
|
||||
$('#user-form input').keydown(function (event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if (document.getElementById('user-form').checkValidity() === false) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#save-user-button').click();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (GetUriParam("changepw") === "true")
|
||||
{
|
||||
$('#password').focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#username').focus();
|
||||
}
|
||||
|
||||
Grocy.FrontendHelpers.ValidateForm('user-form');
|
62
public/viewjs/users.js
Normal file
62
public/viewjs/users.js
Normal file
@@ -0,0 +1,62 @@
|
||||
var usersTable = $('#users-table').DataTable({
|
||||
'paginate': false,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
'scrollY': false,
|
||||
'colReorder': true,
|
||||
'stateSave': true,
|
||||
'stateSaveParams': function(settings, data)
|
||||
{
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
|
||||
$("#search").on("keyup", function()
|
||||
{
|
||||
var value = $(this).val();
|
||||
if (value === "all")
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
usersTable.search(value).draw();
|
||||
});
|
||||
|
||||
$(document).on('click', '.user-delete-button', function (e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-user-username');
|
||||
var objectId = $(e.currentTarget).attr('data-user-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: L('Are you sure to delete user "#1"?', objectName),
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: L('Yes'),
|
||||
className: 'btn-success'
|
||||
},
|
||||
cancel: {
|
||||
label: L('No'),
|
||||
className: 'btn-danger'
|
||||
}
|
||||
},
|
||||
callback: function(result)
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Get('users/delete/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/users');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
124
routes.php
124
routes.php
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use \Grocy\Middleware\JsonMiddleware;
|
||||
use \Grocy\Middleware\CliMiddleware;
|
||||
use \Grocy\Middleware\SessionAuthMiddleware;
|
||||
use \Grocy\Middleware\ApiKeyAuthMiddleware;
|
||||
use \Tuupola\Middleware\CorsMiddleware;
|
||||
@@ -16,75 +15,93 @@ $app->group('', function()
|
||||
$this->post('/login', 'LoginControllerInstance:ProcessLogin')->setName('login');
|
||||
$this->get('/logout', 'LoginControllerInstance:Logout');
|
||||
|
||||
// User routes
|
||||
$this->get('/users', '\Grocy\Controllers\UsersController:UsersList');
|
||||
$this->get('/user/{userId}', '\Grocy\Controllers\UsersController:UserEditForm');
|
||||
|
||||
// Stock routes
|
||||
$this->get('/stockoverview', 'Grocy\Controllers\StockController:Overview');
|
||||
$this->get('/purchase', 'Grocy\Controllers\StockController:Purchase');
|
||||
$this->get('/consume', 'Grocy\Controllers\StockController:Consume');
|
||||
$this->get('/inventory', 'Grocy\Controllers\StockController:Inventory');
|
||||
|
||||
$this->get('/products', 'Grocy\Controllers\StockController:ProductsList');
|
||||
$this->get('/product/{productId}', 'Grocy\Controllers\StockController:ProductEditForm');
|
||||
|
||||
$this->get('/locations', 'Grocy\Controllers\StockController:LocationsList');
|
||||
$this->get('/location/{locationId}', 'Grocy\Controllers\StockController:LocationEditForm');
|
||||
|
||||
$this->get('/quantityunits', 'Grocy\Controllers\StockController:QuantityUnitsList');
|
||||
$this->get('/quantityunit/{quantityunitId}', 'Grocy\Controllers\StockController:QuantityUnitEditForm');
|
||||
|
||||
$this->get('/shoppinglist', 'Grocy\Controllers\StockController:ShoppingList');
|
||||
$this->get('/shoppinglistitem/{itemId}', 'Grocy\Controllers\StockController:ShoppingListItemEditForm');
|
||||
$this->get('/stockoverview', '\Grocy\Controllers\StockController:Overview');
|
||||
$this->get('/purchase', '\Grocy\Controllers\StockController:Purchase');
|
||||
$this->get('/consume', '\Grocy\Controllers\StockController:Consume');
|
||||
$this->get('/inventory', '\Grocy\Controllers\StockController:Inventory');
|
||||
$this->get('/products', '\Grocy\Controllers\StockController:ProductsList');
|
||||
$this->get('/product/{productId}', '\Grocy\Controllers\StockController:ProductEditForm');
|
||||
$this->get('/locations', '\Grocy\Controllers\StockController:LocationsList');
|
||||
$this->get('/location/{locationId}', '\Grocy\Controllers\StockController:LocationEditForm');
|
||||
$this->get('/quantityunits', '\Grocy\Controllers\StockController:QuantityUnitsList');
|
||||
$this->get('/quantityunit/{quantityunitId}', '\Grocy\Controllers\StockController:QuantityUnitEditForm');
|
||||
$this->get('/shoppinglist', '\Grocy\Controllers\StockController:ShoppingList');
|
||||
$this->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm');
|
||||
|
||||
// Recipe routes
|
||||
$this->get('/recipes', 'Grocy\Controllers\RecipesController:Overview');
|
||||
$this->get('/recipe/{recipeId}', 'Grocy\Controllers\RecipesController:RecipeEditForm');
|
||||
$this->get('/recipe/{recipeId}/pos/{recipePosId}', 'Grocy\Controllers\RecipesController:RecipePosEditForm');
|
||||
$this->get('/recipes', '\Grocy\Controllers\RecipesController:Overview');
|
||||
$this->get('/recipe/{recipeId}', '\Grocy\Controllers\RecipesController:RecipeEditForm');
|
||||
$this->get('/recipe/{recipeId}/pos/{recipePosId}', '\Grocy\Controllers\RecipesController:RecipePosEditForm');
|
||||
|
||||
// Habit routes
|
||||
$this->get('/habitsoverview', 'Grocy\Controllers\HabitsController:Overview');
|
||||
$this->get('/habittracking', 'Grocy\Controllers\HabitsController:TrackHabitExecution');
|
||||
$this->get('/habitsoverview', '\Grocy\Controllers\HabitsController:Overview');
|
||||
$this->get('/habittracking', '\Grocy\Controllers\HabitsController:TrackHabitExecution');
|
||||
$this->get('/habitsanalysis', '\Grocy\Controllers\HabitsController:Analysis');
|
||||
|
||||
$this->get('/habits', 'Grocy\Controllers\HabitsController:HabitsList');
|
||||
$this->get('/habit/{habitId}', 'Grocy\Controllers\HabitsController:HabitEditForm');
|
||||
$this->get('/habits', '\Grocy\Controllers\HabitsController:HabitsList');
|
||||
$this->get('/habit/{habitId}', '\Grocy\Controllers\HabitsController:HabitEditForm');
|
||||
|
||||
// Battery routes
|
||||
$this->get('/batteriesoverview', 'Grocy\Controllers\BatteriesController:Overview');
|
||||
$this->get('/batterytracking', 'Grocy\Controllers\BatteriesController:TrackChargeCycle');
|
||||
$this->get('/batteriesoverview', '\Grocy\Controllers\BatteriesController:Overview');
|
||||
$this->get('/batterytracking', '\Grocy\Controllers\BatteriesController:TrackChargeCycle');
|
||||
|
||||
$this->get('/batteries', 'Grocy\Controllers\BatteriesController:BatteriesList');
|
||||
$this->get('/battery/{batteryId}', 'Grocy\Controllers\BatteriesController:BatteryEditForm');
|
||||
$this->get('/batteries', '\Grocy\Controllers\BatteriesController:BatteriesList');
|
||||
$this->get('/battery/{batteryId}', '\Grocy\Controllers\BatteriesController:BatteryEditForm');
|
||||
|
||||
// Other routes
|
||||
$this->get('/api', 'Grocy\Controllers\OpenApiController:DocumentationUi');
|
||||
$this->get('/manageapikeys', 'Grocy\Controllers\OpenApiController:ApiKeysList');
|
||||
$this->get('/manageapikeys/new', 'Grocy\Controllers\OpenApiController:CreateNewApiKey');
|
||||
// OpenAPI routes
|
||||
$this->get('/api', '\Grocy\Controllers\OpenApiController:DocumentationUi');
|
||||
$this->get('/manageapikeys', '\Grocy\Controllers\OpenApiController:ApiKeysList');
|
||||
$this->get('/manageapikeys/new', '\Grocy\Controllers\OpenApiController:CreateNewApiKey');
|
||||
})->add(new SessionAuthMiddleware($appContainer, $appContainer->LoginControllerInstance->GetSessionCookieName()));
|
||||
|
||||
$app->group('/api', function()
|
||||
{
|
||||
$this->get('/get-openapi-specification', 'Grocy\Controllers\OpenApiController:DocumentationSpec');
|
||||
// OpenAPI
|
||||
$this->get('/get-openapi-specification', '\Grocy\Controllers\OpenApiController:DocumentationSpec');
|
||||
|
||||
$this->get('/get-objects/{entity}', 'Grocy\Controllers\GenericEntityApiController:GetObjects');
|
||||
$this->get('/get-object/{entity}/{objectId}', 'Grocy\Controllers\GenericEntityApiController:GetObject');
|
||||
$this->post('/add-object/{entity}', 'Grocy\Controllers\GenericEntityApiController:AddObject');
|
||||
$this->post('/edit-object/{entity}/{objectId}', 'Grocy\Controllers\GenericEntityApiController:EditObject');
|
||||
$this->get('/delete-object/{entity}/{objectId}', 'Grocy\Controllers\GenericEntityApiController:DeleteObject');
|
||||
// Generic entity interaction
|
||||
$this->get('/get-objects/{entity}', '\Grocy\Controllers\GenericEntityApiController:GetObjects');
|
||||
$this->get('/get-object/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:GetObject');
|
||||
$this->post('/add-object/{entity}', '\Grocy\Controllers\GenericEntityApiController:AddObject');
|
||||
$this->post('/edit-object/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:EditObject');
|
||||
$this->get('/delete-object/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:DeleteObject');
|
||||
|
||||
$this->get('/stock/add-product/{productId}/{amount}', 'Grocy\Controllers\StockApiController:AddProduct');
|
||||
$this->get('/stock/consume-product/{productId}/{amount}', 'Grocy\Controllers\StockApiController:ConsumeProduct');
|
||||
$this->get('/stock/inventory-product/{productId}/{newAmount}', 'Grocy\Controllers\StockApiController:InventoryProduct');
|
||||
$this->get('/stock/get-product-details/{productId}', 'Grocy\Controllers\StockApiController:ProductDetails');
|
||||
$this->get('/stock/get-current-stock', 'Grocy\Controllers\StockApiController:CurrentStock');
|
||||
$this->get('/stock/add-missing-products-to-shoppinglist', 'Grocy\Controllers\StockApiController:AddMissingProductsToShoppingList');
|
||||
$this->get('/stock/clear-shopping-list', 'Grocy\Controllers\StockApiController:ClearShoppingList');
|
||||
$this->get('/stock/external-barcode-lookup/{barcode}', 'Grocy\Controllers\StockApiController:ExternalBarcodeLookup');
|
||||
// Users
|
||||
$this->get('/users/get', '\Grocy\Controllers\UsersApiController:GetUsers');
|
||||
$this->post('/users/create', '\Grocy\Controllers\UsersApiController:CreateUser');
|
||||
$this->post('/users/edit/{userId}', '\Grocy\Controllers\UsersApiController:EditUser');
|
||||
$this->get('/users/delete/{userId}', '\Grocy\Controllers\UsersApiController:DeleteUser');
|
||||
|
||||
$this->get('/recipes/add-not-fulfilled-products-to-shopping-list/{recipeId}', 'Grocy\Controllers\RecipesApiController:AddNotFulfilledProductsToShoppingList');
|
||||
// Stock
|
||||
$this->get('/stock/add-product/{productId}/{amount}', '\Grocy\Controllers\StockApiController:AddProduct');
|
||||
$this->get('/stock/consume-product/{productId}/{amount}', '\Grocy\Controllers\StockApiController:ConsumeProduct');
|
||||
$this->get('/stock/inventory-product/{productId}/{newAmount}', '\Grocy\Controllers\StockApiController:InventoryProduct');
|
||||
$this->get('/stock/get-product-details/{productId}', '\Grocy\Controllers\StockApiController:ProductDetails');
|
||||
$this->get('/stock/get-product-price-history/{productId}', '\Grocy\Controllers\StockApiController:ProductPriceHistory');
|
||||
$this->get('/stock/get-current-stock', '\Grocy\Controllers\StockApiController:CurrentStock');
|
||||
$this->get('/stock/get-current-volatil-stock', '\Grocy\Controllers\StockApiController:CurrentVolatilStock');
|
||||
$this->get('/stock/add-missing-products-to-shoppinglist', '\Grocy\Controllers\StockApiController:AddMissingProductsToShoppingList');
|
||||
$this->get('/stock/clear-shopping-list', '\Grocy\Controllers\StockApiController:ClearShoppingList');
|
||||
$this->get('/stock/external-barcode-lookup/{barcode}', '\Grocy\Controllers\StockApiController:ExternalBarcodeLookup');
|
||||
|
||||
$this->get('/habits/track-habit-execution/{habitId}', 'Grocy\Controllers\HabitsApiController:TrackHabitExecution');
|
||||
$this->get('/habits/get-habit-details/{habitId}', 'Grocy\Controllers\HabitsApiController:HabitDetails');
|
||||
// Recipes
|
||||
$this->get('/recipes/add-not-fulfilled-products-to-shopping-list/{recipeId}', '\Grocy\Controllers\RecipesApiController:AddNotFulfilledProductsToShoppingList');
|
||||
$this->get('/recipes/consume-recipe/{recipeId}', '\Grocy\Controllers\RecipesApiController:ConsumeRecipe');
|
||||
|
||||
// Habits
|
||||
$this->get('/habits/track-habit-execution/{habitId}', '\Grocy\Controllers\HabitsApiController:TrackHabitExecution');
|
||||
$this->get('/habits/get-habit-details/{habitId}', '\Grocy\Controllers\HabitsApiController:HabitDetails');
|
||||
$this->get('/habits/get-current', '\Grocy\Controllers\HabitsApiController:Current');
|
||||
|
||||
$this->get('/batteries/track-charge-cycle/{batteryId}', 'Grocy\Controllers\BatteriesApiController:TrackChargeCycle');
|
||||
$this->get('/batteries/get-battery-details/{batteryId}', 'Grocy\Controllers\BatteriesApiController:BatteryDetails');
|
||||
// Batteries
|
||||
$this->get('/batteries/track-charge-cycle/{batteryId}', '\Grocy\Controllers\BatteriesApiController:TrackChargeCycle');
|
||||
$this->get('/batteries/get-battery-details/{batteryId}', '\Grocy\Controllers\BatteriesApiController:BatteryDetails');
|
||||
$this->get('/batteries/get-current', '\Grocy\Controllers\BatteriesApiController:Current');
|
||||
})->add(new ApiKeyAuthMiddleware($appContainer, $appContainer->LoginControllerInstance->GetSessionCookieName(), $appContainer->ApiKeyHeaderName))
|
||||
->add(JsonMiddleware::class)
|
||||
->add(new CorsMiddleware([
|
||||
@@ -95,8 +112,3 @@ $app->group('/api', function()
|
||||
'credentials' => false,
|
||||
'cache' => 0,
|
||||
]));
|
||||
|
||||
$app->group('/cli', function()
|
||||
{
|
||||
$this->get('/recreatedemo', 'Grocy\Controllers\CliController:RecreateDemo');
|
||||
})->add(CliMiddleware::class);
|
||||
|
@@ -39,6 +39,7 @@ class ApiKeyService extends BaseService
|
||||
|
||||
$apiKeyRow = $this->Database->api_keys()->createRow(array(
|
||||
'api_key' => $newApiKey,
|
||||
'user_id' => GROCY_USER_ID,
|
||||
'expires' => '2999-12-31 23:59:59' // Default is that API keys expire never
|
||||
));
|
||||
$apiKeyRow->save();
|
||||
@@ -57,6 +58,16 @@ class ApiKeyService extends BaseService
|
||||
return $apiKey->id;
|
||||
}
|
||||
|
||||
public function GetUserByApiKey($apiKey)
|
||||
{
|
||||
$apiKeyRow = $this->Database->api_keys()->where('api_key', $apiKey)->fetch();
|
||||
if ($apiKeyRow !== null)
|
||||
{
|
||||
return $this->Database->users($apiKeyRow->user_id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function GenerateApiKey()
|
||||
{
|
||||
return RandomString(50);
|
||||
|
@@ -4,14 +4,6 @@ namespace Grocy\Services;
|
||||
|
||||
class ApplicationService extends BaseService
|
||||
{
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function IsDemoInstallation()
|
||||
{
|
||||
return file_exists(__DIR__ . '/../data/demo.txt');
|
||||
}
|
||||
|
||||
private $InstalledVersion;
|
||||
public function GetInstalledVersion()
|
||||
{
|
||||
|
@@ -11,7 +11,7 @@ class BaseService
|
||||
$this->DatabaseService = new DatabaseService();
|
||||
$this->Database = $this->DatabaseService->GetDbConnection();
|
||||
|
||||
$localizationService = new LocalizationService(CULTURE);
|
||||
$localizationService = new LocalizationService(GROCY_CULTURE);
|
||||
$this->LocalizationService = $localizationService;
|
||||
}
|
||||
|
||||
|
@@ -10,28 +10,6 @@ class BatteriesService extends BaseService
|
||||
return $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
}
|
||||
|
||||
public function GetNextChargeTime(int $batteryId)
|
||||
{
|
||||
if (!$this->BatteryExists($batteryId))
|
||||
{
|
||||
throw new \Exception('Battery does not exist');
|
||||
}
|
||||
|
||||
$battery = $this->Database->batteries($batteryId);
|
||||
$batteryLastLogRow = $this->DatabaseService->ExecuteDbQuery("SELECT * from batteries_current WHERE battery_id = $batteryId LIMIT 1")->fetch(\PDO::FETCH_OBJ);
|
||||
|
||||
if ($battery->charge_interval_days > 0)
|
||||
{
|
||||
return date('Y-m-d H:i:s', strtotime('+' . $battery->charge_interval_days . ' day', strtotime($batteryLastLogRow->last_tracked_time)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return date('2999-12-31 23:59:59');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function GetBatteryDetails(int $batteryId)
|
||||
{
|
||||
if (!$this->BatteryExists($batteryId))
|
||||
@@ -42,11 +20,13 @@ class BatteriesService extends BaseService
|
||||
$battery = $this->Database->batteries($batteryId);
|
||||
$batteryChargeCylcesCount = $this->Database->battery_charge_cycles()->where('battery_id', $batteryId)->count();
|
||||
$batteryLastChargedTime = $this->Database->battery_charge_cycles()->where('battery_id', $batteryId)->max('tracked_time');
|
||||
$nextChargeTime = $this->Database->batteries_current()->where('battery_id', $batteryId)->min('next_estimated_charge_time');
|
||||
|
||||
return array(
|
||||
'battery' => $battery,
|
||||
'last_charged' => $batteryLastChargedTime,
|
||||
'charge_cycles_count' => $batteryChargeCylcesCount
|
||||
'charge_cycles_count' => $batteryChargeCylcesCount,
|
||||
'next_estimated_charge_time' => $nextChargeTime
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -8,21 +8,38 @@ class DatabaseMigrationService extends BaseService
|
||||
{
|
||||
$this->DatabaseService->ExecuteDbStatement("CREATE TABLE IF NOT EXISTS migrations (migration INTEGER NOT NULL PRIMARY KEY UNIQUE, execution_time_timestamp DATETIME DEFAULT (datetime('now', 'localtime')))");
|
||||
|
||||
$migrationFiles = array();
|
||||
$sqlMigrationFiles = array();
|
||||
foreach (new \FilesystemIterator(__DIR__ . '/../migrations') as $file)
|
||||
{
|
||||
$migrationFiles[$file->getBasename('.sql')] = $file->getPathname();
|
||||
if ($file->getExtension() === 'sql')
|
||||
{
|
||||
$sqlMigrationFiles[$file->getBasename('.sql')] = $file->getPathname();
|
||||
}
|
||||
}
|
||||
ksort($migrationFiles);
|
||||
|
||||
foreach($migrationFiles as $migrationNumber => $migrationFile)
|
||||
ksort($sqlMigrationFiles);
|
||||
foreach($sqlMigrationFiles as $migrationNumber => $migrationFile)
|
||||
{
|
||||
$migrationNumber = ltrim($migrationNumber, '0');
|
||||
$this->ExecuteMigrationWhenNeeded($migrationNumber, file_get_contents($migrationFile));
|
||||
$this->ExecuteSqlMigrationWhenNeeded($migrationNumber, file_get_contents($migrationFile));
|
||||
}
|
||||
|
||||
$phpMigrationFiles = array();
|
||||
foreach (new \FilesystemIterator(__DIR__ . '/../migrations') as $file)
|
||||
{
|
||||
if ($file->getExtension() === 'php')
|
||||
{
|
||||
$phpMigrationFiles[$file->getBasename('.php')] = $file->getPathname();
|
||||
}
|
||||
}
|
||||
ksort($phpMigrationFiles);
|
||||
foreach($phpMigrationFiles as $migrationNumber => $migrationFile)
|
||||
{
|
||||
$migrationNumber = ltrim($migrationNumber, '0');
|
||||
$this->ExecutePhpMigrationWhenNeeded($migrationNumber, $migrationFile);
|
||||
}
|
||||
}
|
||||
|
||||
private function ExecuteMigrationWhenNeeded(int $migrationId, string $sql)
|
||||
private function ExecuteSqlMigrationWhenNeeded(int $migrationId, string $sql)
|
||||
{
|
||||
$rowCount = $this->DatabaseService->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = ' . $migrationId)->fetchColumn();
|
||||
if (intval($rowCount) === 0)
|
||||
@@ -31,4 +48,14 @@ class DatabaseMigrationService extends BaseService
|
||||
$this->DatabaseService->ExecuteDbStatement('INSERT INTO migrations (migration) VALUES (' . $migrationId . ')');
|
||||
}
|
||||
}
|
||||
|
||||
private function ExecutePhpMigrationWhenNeeded(int $migrationId, string $phpFile)
|
||||
{
|
||||
$rowCount = $this->DatabaseService->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = ' . $migrationId)->fetchColumn();
|
||||
if (intval($rowCount) === 0)
|
||||
{
|
||||
include $phpFile;
|
||||
$this->DatabaseService->ExecuteDbStatement('INSERT INTO migrations (migration) VALUES (' . $migrationId . ')');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ class DatabaseService
|
||||
{
|
||||
if ($this->DbConnectionRaw == null)
|
||||
{
|
||||
$pdo = new \PDO('sqlite:' . __DIR__ . '/../data/grocy.db');
|
||||
$pdo = new \PDO('sqlite:' . GROCY_DATAPATH . '/grocy.db');
|
||||
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
$this->DbConnectionRaw = $pdo;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ class DemoDataGeneratorService extends BaseService
|
||||
{
|
||||
public function PopulateDemoData()
|
||||
{
|
||||
$localizationService = new LocalizationService(CULTURE);
|
||||
$localizationService = new LocalizationService(GROCY_CULTURE);
|
||||
|
||||
$rowCount = $this->DatabaseService->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = -1')->fetchColumn();
|
||||
if (intval($rowCount) === 0)
|
||||
@@ -16,39 +16,44 @@ class DemoDataGeneratorService extends BaseService
|
||||
$loremIpsum = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.';
|
||||
|
||||
$sql = "
|
||||
INSERT INTO locations (name) VALUES ('{$localizationService->Localize('Pantry')}'); --2
|
||||
INSERT INTO locations (name) VALUES ('{$localizationService->Localize('Candy cupboard')}'); --3
|
||||
INSERT INTO locations (name) VALUES ('{$localizationService->Localize('Tinned food cupboard')}'); --4
|
||||
INSERT INTO locations (name) VALUES ('{$localizationService->Localize('Fridge')}'); --5
|
||||
UPDATE users SET username = '{$localizationService->Localize('Demo User')}' WHERE id = 1;
|
||||
INSERT INTO users (username, password) VALUES ('{$localizationService->Localize('Demo User')} 2', 'x');
|
||||
INSERT INTO users (username, password) VALUES ('{$localizationService->Localize('Demo User')} 3', 'x');
|
||||
INSERT INTO users (username, password) VALUES ('{$localizationService->Localize('Demo User')} 4', 'x');
|
||||
|
||||
INSERT INTO quantity_units (name) VALUES ('{$localizationService->Localize('Piece')}'); --2
|
||||
INSERT INTO quantity_units (name) VALUES ('{$localizationService->Localize('Pack')}'); --3
|
||||
INSERT INTO quantity_units (name) VALUES ('{$localizationService->Localize('Glass')}'); --4
|
||||
INSERT INTO quantity_units (name) VALUES ('{$localizationService->Localize('Tin')}'); --5
|
||||
INSERT INTO quantity_units (name) VALUES ('{$localizationService->Localize('Can')}'); --6
|
||||
INSERT INTO quantity_units (name) VALUES ('{$localizationService->Localize('Bunch')}'); --7
|
||||
INSERT INTO locations (name) VALUES ('{$localizationService->Localize('Pantry')}'); --3
|
||||
INSERT INTO locations (name) VALUES ('{$localizationService->Localize('Candy cupboard')}'); --4
|
||||
INSERT INTO locations (name) VALUES ('{$localizationService->Localize('Tinned food cupboard')}'); --5
|
||||
|
||||
INSERT INTO quantity_units (name, name_plural) VALUES ('{$localizationService->Localize('Glass')}', '{$localizationService->Localize('Glasses')}'); --4
|
||||
INSERT INTO quantity_units (name, name_plural) VALUES ('{$localizationService->Localize('Tin')}', '{$localizationService->Localize('Tins')}'); --5
|
||||
INSERT INTO quantity_units (name, name_plural) VALUES ('{$localizationService->Localize('Can')}', '{$localizationService->Localize('Cans')}'); --6
|
||||
INSERT INTO quantity_units (name, name_plural) VALUES ('{$localizationService->Localize('Bunch')}', '{$localizationService->Localize('Bunches')}'); --7
|
||||
INSERT INTO quantity_units (name, name_plural) VALUES ('{$localizationService->Localize('Gram')}', '{$localizationService->Localize('Grams')}'); --8
|
||||
|
||||
DELETE FROM sqlite_sequence WHERE name = 'products'; --Just to keep IDs in order as mentioned here...
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount) VALUES ('{$localizationService->Localize('Cookies')}', 3, 3, 3, 1, 8); --1
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount) VALUES ('{$localizationService->Localize('Chocolate')}', 3, 3, 3, 1, 8); --2
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount) VALUES ('{$localizationService->Localize('Gummy bears')}', 3, 3, 3, 1, 8); --3
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount) VALUES ('{$localizationService->Localize('Crisps')}', 3, 3, 3, 1, 10); --4
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Eggs')}', 5, 3, 2, 10); --5
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Eggs')}', 2, 3, 2, 10); --5
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Noodles')}', 3, 3, 3, 1); --6
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Pickles')}', 4,4, 4, 1); --7
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Gulash soup')}', 4, 5, 5, 1); --8
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Yogurt')}', 5, 6, 6, 1); --9
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Cheese')}', 5, 3, 3, 1); --10
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Cold cuts')}', 5, 3, 3, 1); --11
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Paprika')}', 5, 2, 2, 1); --12
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Cucumber')}', 5, 2, 2, 1); --13
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Radish')}', 5, 7, 7, 1); --14
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Tomato')}', 5, 2, 2, 1); --15
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Yogurt')}', 2, 6, 6, 1); --9
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Cheese')}', 2, 3, 3, 1); --10
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Cold cuts')}', 2, 3, 3, 1); --11
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Paprika')}', 2, 2, 2, 1); --12
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Cucumber')}', 2, 2, 2, 1); --13
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Radish')}', 2, 7, 7, 1); --14
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Tomato')}', 2, 2, 2, 1); --15
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Pizza dough')}', 3, 3, 3, 1); --16
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Sieved tomatoes')}', 4, 5, 5, 1); --17
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Salami')}', 5, 3, 3, 1); --18
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Salami')}', 2, 3, 3, 1); --18
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Toast')}', 4, 5, 5, 1); --19
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Minced meat')}', 5, 3, 3, 1); --20
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Minced meat')}', 2, 3, 3, 1); --20
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Flour')}', 2, 3, 3, 1); --21
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock) VALUES ('{$localizationService->Localize('Sugar')}', 3, 3, 3, 1); --22
|
||||
|
||||
INSERT INTO shopping_list (note, amount) VALUES ('{$localizationService->Localize('Some good snacks')}', 1);
|
||||
INSERT INTO shopping_list (product_id, amount) VALUES (20, 1);
|
||||
@@ -57,6 +62,7 @@ class DemoDataGeneratorService extends BaseService
|
||||
INSERT INTO recipes (name, description) VALUES ('{$localizationService->Localize('Pizza')}', '{$loremIpsum}'); --1
|
||||
INSERT INTO recipes (name, description) VALUES ('{$localizationService->Localize('Spaghetti bolognese')}', '{$loremIpsum}'); --2
|
||||
INSERT INTO recipes (name, description) VALUES ('{$localizationService->Localize('Sandwiches')}', '{$loremIpsum}'); --3
|
||||
INSERT INTO recipes (name, description) VALUES ('{$localizationService->Localize('Pancakes')}', '{$loremIpsum}'); --4
|
||||
|
||||
INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (1, 16, 1);
|
||||
INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (1, 17, 1);
|
||||
@@ -68,6 +74,9 @@ class DemoDataGeneratorService extends BaseService
|
||||
INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (2, 20, 1);
|
||||
INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (3, 10, 1);
|
||||
INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (3, 11, 1);
|
||||
INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (4, 5, 4);
|
||||
INSERT INTO recipes_pos (recipe_id, product_id, amount, qu_id, only_check_single_unit_in_stock) VALUES (4, 21, 200, 8, 1);
|
||||
INSERT INTO recipes_pos (recipe_id, product_id, amount, qu_id, only_check_single_unit_in_stock) VALUES (4, 22, 200, 8, 1);
|
||||
|
||||
INSERT INTO habits (name, period_type, period_days) VALUES ('{$localizationService->Localize('Changed towels in the bathroom')}', 'manually', 5); --1
|
||||
INSERT INTO habits (name, period_type, period_days) VALUES ('{$localizationService->Localize('Cleaned the kitchen floor')}', 'dynamic-regular', 7); --2
|
||||
@@ -84,19 +93,75 @@ class DemoDataGeneratorService extends BaseService
|
||||
$this->DatabaseService->ExecuteDbStatement($sql);
|
||||
|
||||
$stockService = new StockService();
|
||||
$stockService->AddProduct(3, 5, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(4, 5, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(5, 5, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(6, 5, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(7, 5, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(8, 5, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(9, 5, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(10, 5, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(11, 5, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(12, 5, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(13, 5, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(14, 5, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(15, 5, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE);
|
||||
$stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(21, 1, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(21, 1, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(22, 1, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice());
|
||||
$stockService->AddProduct(22, 1, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice());
|
||||
$stockService->AddMissingProductsToShoppingList();
|
||||
|
||||
$habitsService = new HabitsService();
|
||||
@@ -121,9 +186,8 @@ class DemoDataGeneratorService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
public function RecreateDemo()
|
||||
private function RandomPrice()
|
||||
{
|
||||
unlink(__DIR__ . '/../data/grocy.db');
|
||||
$this->PopulateDemoData();
|
||||
return mt_rand(2 * 100, 25 * 100) / 100;
|
||||
}
|
||||
}
|
||||
|
@@ -7,33 +7,12 @@ class HabitsService extends BaseService
|
||||
const HABIT_TYPE_MANUALLY = 'manually';
|
||||
const HABIT_TYPE_DYNAMIC_REGULAR = 'dynamic-regular';
|
||||
|
||||
public function GetCurrentHabits()
|
||||
public function GetCurrent()
|
||||
{
|
||||
$sql = 'SELECT * from habits_current';
|
||||
return $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
}
|
||||
|
||||
public function GetNextHabitTime(int $habitId)
|
||||
{
|
||||
if (!$this->HabitExists($habitId))
|
||||
{
|
||||
throw new \Exception('Habit does not exist');
|
||||
}
|
||||
|
||||
$habit = $this->Database->habits($habitId);
|
||||
$habitLastLogRow = $this->DatabaseService->ExecuteDbQuery("SELECT * from habits_current WHERE habit_id = $habitId LIMIT 1")->fetch(\PDO::FETCH_OBJ);
|
||||
|
||||
switch($habit->period_type)
|
||||
{
|
||||
case self::HABIT_TYPE_MANUALLY:
|
||||
return date('2999-12-31 23:59:59');
|
||||
case self::HABIT_TYPE_DYNAMIC_REGULAR:
|
||||
return date('Y-m-d H:i:s', strtotime('+' . $habit->period_days . ' day', strtotime($habitLastLogRow->last_tracked_time)));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function GetHabitDetails(int $habitId)
|
||||
{
|
||||
if (!$this->HabitExists($habitId))
|
||||
@@ -44,24 +23,43 @@ class HabitsService extends BaseService
|
||||
$habit = $this->Database->habits($habitId);
|
||||
$habitTrackedCount = $this->Database->habits_log()->where('habit_id', $habitId)->count();
|
||||
$habitLastTrackedTime = $this->Database->habits_log()->where('habit_id', $habitId)->max('tracked_time');
|
||||
$nextExeuctionTime = $this->Database->habits_current()->where('habit_id', $habitId)->min('next_estimated_execution_time');
|
||||
|
||||
$lastHabitLogRow = $this->Database->habits_log()->where('habit_id = :1 AND tracked_time = :2', $habitId, $habitLastTrackedTime)->fetch();
|
||||
$lastDoneByUser = null;
|
||||
if ($lastHabitLogRow !== null && !empty($lastHabitLogRow))
|
||||
{
|
||||
$usersService = new UsersService();
|
||||
$users = $usersService->GetUsersAsDto();
|
||||
$lastDoneByUser = FindObjectInArrayByPropertyValue($users, 'id', $lastHabitLogRow->done_by_user_id);
|
||||
}
|
||||
|
||||
return array(
|
||||
'habit' => $habit,
|
||||
'last_tracked' => $habitLastTrackedTime,
|
||||
'tracked_count' => $habitTrackedCount
|
||||
'tracked_count' => $habitTrackedCount,
|
||||
'last_done_by' => $lastDoneByUser,
|
||||
'next_estimated_execution_time' => $nextExeuctionTime
|
||||
);
|
||||
}
|
||||
|
||||
public function TrackHabit(int $habitId, string $trackedTime)
|
||||
public function TrackHabit(int $habitId, string $trackedTime, $doneBy = GROCY_USER_ID)
|
||||
{
|
||||
if (!$this->HabitExists($habitId))
|
||||
{
|
||||
throw new \Exception('Habit does not exist');
|
||||
}
|
||||
|
||||
$userRow = $this->Database->users()->where('id = :1', $doneBy)->fetch();
|
||||
if ($userRow === null)
|
||||
{
|
||||
throw new \Exception('User does not exist');
|
||||
}
|
||||
|
||||
$logRow = $this->Database->habits_log()->createRow(array(
|
||||
'habit_id' => $habitId,
|
||||
'tracked_time' => $trackedTime
|
||||
'tracked_time' => $trackedTime,
|
||||
'done_by_user_id' => $doneBy
|
||||
));
|
||||
$logRow->save();
|
||||
|
||||
|
@@ -36,7 +36,7 @@ class LocalizationService
|
||||
|
||||
private function LogMissingLocalization(string $culture, string $text)
|
||||
{
|
||||
$file = __DIR__ . "/../data/missing_translations_$culture.json";
|
||||
$file = GROCY_DATAPATH . "/missing_translations_$culture.json";
|
||||
|
||||
$missingTranslations = array();
|
||||
if (file_exists($file))
|
||||
@@ -57,7 +57,7 @@ class LocalizationService
|
||||
|
||||
public function Localize(string $text, ...$placeholderValues)
|
||||
{
|
||||
if (MODE === 'dev')
|
||||
if (GROCY_MODE === 'dev')
|
||||
{
|
||||
if (!array_key_exists($text, $this->StringsDefaultCulture))
|
||||
{
|
||||
|
@@ -2,8 +2,18 @@
|
||||
|
||||
namespace Grocy\Services;
|
||||
|
||||
use \Grocy\Services\StockService;
|
||||
|
||||
class RecipesService extends BaseService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->StockService = new StockService();
|
||||
}
|
||||
|
||||
protected $StockService;
|
||||
|
||||
public function GetRecipesFulfillment()
|
||||
{
|
||||
$sql = 'SELECT * from recipes_fulfillment';
|
||||
@@ -38,4 +48,27 @@ class RecipesService extends BaseService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function ConsumeRecipe($recipeId)
|
||||
{
|
||||
if (!$this->RecipeExists($recipeId))
|
||||
{
|
||||
throw new \Exception('Recipe does not exist');
|
||||
}
|
||||
|
||||
$recipePositions = $this->Database->recipes_pos()->where('recipe_id', $recipeId)->fetchAll();
|
||||
foreach ($recipePositions as $recipePosition)
|
||||
{
|
||||
if ($recipePosition->only_check_single_unit_in_stock == 0)
|
||||
{
|
||||
$this->StockService->ConsumeProduct($recipePosition->product_id, $recipePosition->amount, false, StockService::TRANSACTION_TYPE_CONSUME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function RecipeExists($recipeId)
|
||||
{
|
||||
$recipeRow = $this->Database->recipes()->where('id = :1', $recipeId)->fetch();
|
||||
return $recipeRow !== null;
|
||||
}
|
||||
}
|
||||
|
@@ -33,11 +33,12 @@ class SessionService extends BaseService
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function CreateSession()
|
||||
public function CreateSession($userId)
|
||||
{
|
||||
$newSessionKey = $this->GenerateSessionKey();
|
||||
|
||||
$sessionRow = $this->Database->sessions()->createRow(array(
|
||||
'user_id' => $userId,
|
||||
'session_key' => $newSessionKey,
|
||||
'expires' => date('Y-m-d H:i:s', time() + 2592000) // Default is that sessions expire in 30 days
|
||||
));
|
||||
@@ -51,6 +52,21 @@ class SessionService extends BaseService
|
||||
$this->Database->sessions()->where('session_key', $sessionKey)->delete();
|
||||
}
|
||||
|
||||
public function GetUserBySessionKey($sessionKey)
|
||||
{
|
||||
$sessionRow = $this->Database->sessions()->where('session_key', $sessionKey)->fetch();
|
||||
if ($sessionRow !== null)
|
||||
{
|
||||
return $this->Database->users($sessionRow->user_id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function GetDefaultUser()
|
||||
{
|
||||
return $this->Database->users(1);
|
||||
}
|
||||
|
||||
private function GenerateSessionKey()
|
||||
{
|
||||
return RandomString(50);
|
||||
|
@@ -20,6 +20,12 @@ class StockService extends BaseService
|
||||
return $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
}
|
||||
|
||||
public function GetExpiringProducts(int $days = 5)
|
||||
{
|
||||
$currentStock = $this->GetCurrentStock();
|
||||
return FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d', strtotime("+$days days")), '<');
|
||||
}
|
||||
|
||||
public function GetProductDetails(int $productId)
|
||||
{
|
||||
if (!$this->ProductExists($productId))
|
||||
@@ -31,8 +37,16 @@ class StockService extends BaseService
|
||||
$productStockAmount = $this->Database->stock()->where('product_id', $productId)->sum('amount');
|
||||
$productLastPurchased = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_PURCHASE)->max('purchased_date');
|
||||
$productLastUsed = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->max('used_date');
|
||||
$nextBestBeforeDate = $this->Database->stock()->where('product_id', $productId)->min('best_before_date');
|
||||
$quPurchase = $this->Database->quantity_units($product->qu_id_purchase);
|
||||
$quStock = $this->Database->quantity_units($product->qu_id_stock);
|
||||
|
||||
$lastPrice = null;
|
||||
$lastLogRow = $this->Database->stock_log()->where('product_id = :1 AND transaction_type = :2', $productId, self::TRANSACTION_TYPE_PURCHASE)->orderBy('row_created_timestamp', 'DESC')->limit(1)->fetch();
|
||||
if ($lastLogRow !== null && !empty($lastLogRow))
|
||||
{
|
||||
$lastPrice = $lastLogRow->price;
|
||||
}
|
||||
|
||||
return array(
|
||||
'product' => $product,
|
||||
@@ -40,11 +54,32 @@ class StockService extends BaseService
|
||||
'last_used' => $productLastUsed,
|
||||
'stock_amount' => $productStockAmount,
|
||||
'quantity_unit_purchase' => $quPurchase,
|
||||
'quantity_unit_stock' => $quStock
|
||||
'quantity_unit_stock' => $quStock,
|
||||
'last_price' => $lastPrice,
|
||||
'next_best_before_date' => $nextBestBeforeDate
|
||||
);
|
||||
}
|
||||
|
||||
public function AddProduct(int $productId, int $amount, string $bestBeforeDate, $transactionType)
|
||||
public function GetProductPriceHistory(int $productId)
|
||||
{
|
||||
if (!$this->ProductExists($productId))
|
||||
{
|
||||
throw new \Exception('Product does not exist');
|
||||
}
|
||||
|
||||
$returnData = array();
|
||||
$rows = $this->Database->stock_log()->where('product_id = :1 AND transaction_type = :2', $productId, self::TRANSACTION_TYPE_PURCHASE)->whereNOT('price', null)->orderBy('purchased_date', 'DESC');
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$returnData[] = array(
|
||||
'date' => $row->purchased_date,
|
||||
'price' => $row->price
|
||||
);
|
||||
}
|
||||
return $returnData;
|
||||
}
|
||||
|
||||
public function AddProduct(int $productId, int $amount, string $bestBeforeDate, $transactionType, $purchasedDate, $price)
|
||||
{
|
||||
if (!$this->ProductExists($productId))
|
||||
{
|
||||
@@ -59,9 +94,10 @@ class StockService extends BaseService
|
||||
'product_id' => $productId,
|
||||
'amount' => $amount,
|
||||
'best_before_date' => $bestBeforeDate,
|
||||
'purchased_date' => date('Y-m-d'),
|
||||
'purchased_date' => $purchasedDate,
|
||||
'stock_id' => $stockId,
|
||||
'transaction_type' => $transactionType
|
||||
'transaction_type' => $transactionType,
|
||||
'price' => $price
|
||||
));
|
||||
$logRow->save();
|
||||
|
||||
@@ -69,8 +105,9 @@ class StockService extends BaseService
|
||||
'product_id' => $productId,
|
||||
'amount' => $amount,
|
||||
'best_before_date' => $bestBeforeDate,
|
||||
'purchased_date' => date('Y-m-d'),
|
||||
'purchased_date' => $purchasedDate,
|
||||
'stock_id' => $stockId,
|
||||
'price' => $price
|
||||
));
|
||||
$stockRow->save();
|
||||
|
||||
@@ -116,7 +153,8 @@ class StockService extends BaseService
|
||||
'used_date' => date('Y-m-d'),
|
||||
'spoiled' => $spoiled,
|
||||
'stock_id' => $stockEntry->stock_id,
|
||||
'transaction_type' => $transactionType
|
||||
'transaction_type' => $transactionType,
|
||||
'price' => $stockEntry->price
|
||||
));
|
||||
$logRow->save();
|
||||
|
||||
@@ -133,7 +171,8 @@ class StockService extends BaseService
|
||||
'used_date' => date('Y-m-d'),
|
||||
'spoiled' => $spoiled,
|
||||
'stock_id' => $stockEntry->stock_id,
|
||||
'transaction_type' => $transactionType
|
||||
'transaction_type' => $transactionType,
|
||||
'price' => $stockEntry->price
|
||||
));
|
||||
$logRow->save();
|
||||
|
||||
@@ -165,8 +204,9 @@ class StockService extends BaseService
|
||||
|
||||
if ($newAmount > $productStockAmount)
|
||||
{
|
||||
$productDetails = $this->GetProductDetails($productId);
|
||||
$amountToAdd = $newAmount - $productStockAmount;
|
||||
$this->AddProduct($productId, $amountToAdd, $bestBeforeDate, self::TRANSACTION_TYPE_INVENTORY_CORRECTION);
|
||||
$this->AddProduct($productId, $amountToAdd, $bestBeforeDate, self::TRANSACTION_TYPE_INVENTORY_CORRECTION, date('Y-m-d'), $productDetails['last_price']);
|
||||
}
|
||||
else if ($newAmount < $productStockAmount)
|
||||
{
|
||||
@@ -216,13 +256,13 @@ class StockService extends BaseService
|
||||
|
||||
private function LoadBarcodeLookupPlugin()
|
||||
{
|
||||
$pluginName = defined('STOCK_BARCODE_LOOKUP_PLUGIN') ? STOCK_BARCODE_LOOKUP_PLUGIN : '';
|
||||
$pluginName = defined('GROCY_STOCK_BARCODE_LOOKUP_PLUGIN') ? GROCY_STOCK_BARCODE_LOOKUP_PLUGIN : '';
|
||||
if (empty($pluginName))
|
||||
{
|
||||
throw new \Exception('No barcode lookup plugin defined');
|
||||
}
|
||||
|
||||
$path = __DIR__ . "/../data/plugins/$pluginName.php";
|
||||
$path = GROCY_DATAPATH . "/plugins/$pluginName.php";
|
||||
if (file_exists($path))
|
||||
{
|
||||
require_once $path;
|
||||
|
58
services/UsersService.php
Normal file
58
services/UsersService.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Grocy\Services;
|
||||
|
||||
class UsersService extends BaseService
|
||||
{
|
||||
public function CreateUser(string $username, string $firstName, string $lastName, string $password)
|
||||
{
|
||||
$newUserRow = $this->Database->users()->createRow(array(
|
||||
'username' => $username,
|
||||
'first_name' => $firstName,
|
||||
'last_name' => $lastName,
|
||||
'password' => password_hash($password, PASSWORD_DEFAULT)
|
||||
));
|
||||
$newUserRow->save();
|
||||
}
|
||||
|
||||
public function EditUser(int $userId, string $username, string $firstName, string $lastName, string $password)
|
||||
{
|
||||
if (!$this->UserExists($userId))
|
||||
{
|
||||
throw new \Exception('User does not exist');
|
||||
}
|
||||
|
||||
$user = $this->Database->users($userId);
|
||||
$user->update(array(
|
||||
'username' => $username,
|
||||
'first_name' => $firstName,
|
||||
'last_name' => $lastName,
|
||||
'password' => password_hash($password, PASSWORD_DEFAULT)
|
||||
));
|
||||
}
|
||||
|
||||
public function DeleteUser($userId)
|
||||
{
|
||||
$row = $this->Database->users($userId);
|
||||
$row->delete();
|
||||
}
|
||||
|
||||
public function GetUsersAsDto()
|
||||
{
|
||||
$users = $this->Database->users();
|
||||
$returnUsers = array();
|
||||
foreach ($users as $user)
|
||||
{
|
||||
unset($user->password);
|
||||
$user->display_name = GetUserDisplayName($user);
|
||||
$returnUsers[] = $user;
|
||||
}
|
||||
return $returnUsers;
|
||||
}
|
||||
|
||||
private function UserExists($userId)
|
||||
{
|
||||
$userRow = $this->Database->users()->where('id = :1', $userId)->fetch();
|
||||
return $userRow !== null;
|
||||
}
|
||||
}
|
34
update.sh
Executable file
34
update.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
GROCY_RELEASE_URL=https://releases.grocy.info/latest
|
||||
|
||||
|
||||
echo Start updating grocy
|
||||
|
||||
set -e
|
||||
shopt -s extglob
|
||||
pushd `dirname $0` > /dev/null
|
||||
|
||||
backupBundleFileName="backup-`date +%d-%m-%Y-%H-%M-%S`.tgz"
|
||||
echo Making a backup of the current installation in /data/backups/$backupBundleFileName
|
||||
mkdir -p ./data/backups > /dev/null
|
||||
tar -zcvf ./data/backups/$backupBundleFileName --exclude ./data/backups . > /dev/null
|
||||
find ./data/backups/*.tgz -mtime +60 -type f -delete
|
||||
|
||||
echo Deleting everything except /data and this script
|
||||
rm -rf !(data|update.sh) > /dev/null
|
||||
|
||||
echo Emptying /data/viewcache
|
||||
rm -rf ./data/viewcache/* > /dev/null
|
||||
|
||||
echo Downloading latest release
|
||||
rm -f ./grocy-latest.zip > /dev/null
|
||||
wget $GROCY_RELEASE_URL -q -O ./grocy-latest.zip > /dev/null
|
||||
|
||||
echo Unzipping latest release
|
||||
unzip -o ./grocy-latest.zip > /dev/null
|
||||
rm -f ./grocy-latest.zip > /dev/null
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
echo Finished updating grocy
|
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"Version": "1.14.0",
|
||||
"ReleaseDate": "2018-07-15"
|
||||
"Version": "1.18.1",
|
||||
"ReleaseDate": "2018-09-08"
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@
|
||||
<th>{{ $L('Name') }}</th>
|
||||
<th>{{ $L('Description') }}</th>
|
||||
<th>{{ $L('Used in') }}</th>
|
||||
<th>{{ $L('Charge cycle interval (days)') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -54,6 +55,9 @@
|
||||
<td>
|
||||
{{ $battery->used_in }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $battery->charge_interval_days }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
@@ -12,8 +12,8 @@
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h1>@yield('title')</h1>
|
||||
<p class="btn btn-lg btn-warning no-real-button responsive-button mr-2">{{ $L('#1 batteries are due to be charged within the next #2 days', $countDueNextXDays, $nextXDays) }}</p>
|
||||
<p class="btn btn-lg btn-danger no-real-button responsive-button">{{ $L('#1 batteries are overdue to be charged', $countOverdue) }}</p>
|
||||
<p id="info-due-batteries" data-next-x-days="{{ $nextXDays }}" class="btn btn-lg btn-warning no-real-button responsive-button mr-2"></p>
|
||||
<p id="info-overdue-batteries" class="btn btn-lg btn-danger no-real-button responsive-button"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($current as $curentBatteryEntry)
|
||||
<tr class="@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $nextChargeTimes[$curentBatteryEntry->battery_id] < date('Y-m-d H:i:s')) table-danger @endif">
|
||||
<tr id="battery-{{ $curentBatteryEntry->battery_id }}-row" class="@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $curentBatteryEntry->next_estimated_charge_time < date('Y-m-d H:i:s')) table-danger @elseif(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $curentBatteryEntry->next_estimated_charge_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) table-warning @endif">
|
||||
<td class="fit-content">
|
||||
<a class="btn btn-success btn-sm track-charge-cycle-button" href="#" title="{{ $L('Track charge cycle of battery #1', FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->name) }}"
|
||||
<a class="btn btn-success btn-sm track-charge-cycle-button" href="#" data-toggle="tooltip" title="{{ $L('Track charge cycle of battery #1', FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->name) }}"
|
||||
data-battery-id="{{ $curentBatteryEntry->battery_id }}"
|
||||
data-battery-name="{{ FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->name }}">
|
||||
<i class="fas fa-fire"></i>
|
||||
@@ -54,8 +54,8 @@
|
||||
</td>
|
||||
<td>
|
||||
@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0)
|
||||
{{ $nextChargeTimes[$curentBatteryEntry->battery_id] }}
|
||||
<time class="timeago timeago-contextual" datetime="{{ $nextChargeTimes[$curentBatteryEntry->battery_id] }}"></time>
|
||||
<span id="battery-{{ $curentBatteryEntry->battery_id }}-next-charge-time">{{ $curentBatteryEntry->next_estimated_charge_time }}</span>
|
||||
<time id="battery-{{ $curentBatteryEntry->battery_id }}-next-charge-time-timeago" class="timeago timeago-contextual" datetime="{{ $curentBatteryEntry->next_estimated_charge_time }}"></time>
|
||||
@else
|
||||
...
|
||||
@endif
|
||||
|
@@ -37,6 +37,16 @@
|
||||
<input type="text" class="form-control" id="used_in" name="used_in" value="@if($mode == 'edit'){{ $battery->used_in }}@endif">
|
||||
</div>
|
||||
|
||||
@php if($mode == 'edit') { $value = $battery->charge_interval_days; } else { $value = 0; } @endphp
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'charge_interval_days',
|
||||
'label' => 'Charge cycle interval (days)',
|
||||
'value' => $value,
|
||||
'min' => '0',
|
||||
'hint' => $L('0 means suggestions for the next charge cycle are disabled'),
|
||||
'invalidFeedback' => $L('This cannot be negative')
|
||||
))
|
||||
|
||||
<button id="save-battery-button" type="submit" class="btn btn-success">{{ $L('Save') }}</button>
|
||||
|
||||
</form>
|
||||
|
@@ -4,16 +4,24 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ $id }}">{{ $L($label) }} <span class="small text-muted"><time id="datetimepicker-timeago" class="timeago timeago-contextual"></time>@if(!empty($hint))<br>{{ $L($hint) }}@endif</span></label>
|
||||
<div class="input-group date datetimepicker @if(!empty($additionalCssClasses)){{ $additionalCssClasses }}@endif" id="{{ $id }}" data-target-input="nearest">
|
||||
<input type="text" required class="form-control datetimepicker-input"
|
||||
data-target="#{{ $id }}" data-format="{{ $format }}"
|
||||
data-init-with-now="{{ BoolToString($initWithNow) }}"
|
||||
data-limit-end-to-now="{{ BoolToString($limitEndToNow) }}"
|
||||
data-limit-start-to-now="{{ BoolToString($limitStartToNow) }}"
|
||||
data-next-input-selector="{{ $nextInputSelector }}" />
|
||||
<div class="input-group-append" data-target="#{{ $id }}" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fas fa-calendar"></i></div>
|
||||
<div class="input-group">
|
||||
<div class="input-group date datetimepicker @if(!empty($additionalCssClasses)){{ $additionalCssClasses }}@endif" id="{{ $id }}" data-target-input="nearest">
|
||||
<input type="text" required class="form-control datetimepicker-input"
|
||||
data-target="#{{ $id }}" data-format="{{ $format }}"
|
||||
data-init-with-now="{{ BoolToString($initWithNow) }}"
|
||||
data-limit-end-to-now="{{ BoolToString($limitEndToNow) }}"
|
||||
data-limit-start-to-now="{{ BoolToString($limitStartToNow) }}"
|
||||
data-next-input-selector="{{ $nextInputSelector }}" />
|
||||
<div class="input-group-append" data-target="#{{ $id }}" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fas fa-calendar"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
@if(isset($shortcutValue) && isset($shortcutLabel))
|
||||
<div class="form-check w-100">
|
||||
<input class="form-check-input" type="checkbox" id="datetimepicker-shortcut" data-datetimepicker-shortcut-value="{{ $shortcutValue }}">
|
||||
<label class="form-check-label" for="datetimepicker-shortcut">{{ $L($shortcutLabel) }}</label>
|
||||
</div>
|
||||
@endif
|
||||
<div class="invalid-feedback">{{ $invalidFeedback }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -10,5 +10,6 @@
|
||||
<h3><span id="habitcard-habit-name"></span></h3>
|
||||
<strong>{{ $L('Tracked count') }}:</strong> <span id="habitcard-habit-tracked-count"></span><br>
|
||||
<strong>{{ $L('Last tracked') }}:</strong> <span id="habitcard-habit-last-tracked"></span> <time id="habitcard-habit-last-tracked-timeago" class="timeago timeago-contextual"></time><br>
|
||||
<strong>{{ $L('Last done by') }}:</strong> <span id="habitcard-habit-last-done-by"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
29
views/components/numberpicker.blade.php
Normal file
29
views/components/numberpicker.blade.php
Normal file
@@ -0,0 +1,29 @@
|
||||
@push('componentScripts')
|
||||
<script src="{{ $U('/viewjs/components/numberpicker.js', true) }}?v={{ $version }}"></script>
|
||||
@endpush
|
||||
|
||||
@php if(!isset($value)) { $value = 1; } @endphp
|
||||
@php if(empty($min)) { $min = 0; } @endphp
|
||||
@php if(empty($max)) { $max = 999999; } @endphp
|
||||
@php if(empty($step)) { $step = 1; } @endphp
|
||||
@php if(empty($hint)) { $hint = ''; } @endphp
|
||||
@php if(empty($hintId)) { $hintId = ''; } @endphp
|
||||
@php if(empty($additionalCssClasses)) { $additionalCssClasses = ''; } @endphp
|
||||
@php if(empty($additionalGroupCssClasses)) { $additionalGroupCssClasses = ''; } @endphp
|
||||
@php if(empty($additionalAttributes)) { $additionalAttributes = ''; } @endphp
|
||||
@php if(empty($additionalHtmlElements)) { $additionalHtmlElements = ''; } @endphp
|
||||
|
||||
<div class="form-group {{ $additionalGroupCssClasses }}">
|
||||
<label for="{{ $id }}">{{ $L($label) }} <span id="{{ $hintId }}" class="small text-muted">{{ $hint }}</span></label>
|
||||
<div class="input-group">
|
||||
<input {!! $additionalAttributes !!} type="number" class="form-control numberpicker {{ $additionalCssClasses }}" id="{{ $id }}" name="{{ $id }}" value="{{ $value }}" min="{{ $min }}" max="{{ $max }}" step="{{ $step }}" required>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text numberpicker-up-button"><i class="fas fa-arrow-up"></i></div>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text numberpicker-down-button"><i class="fas fa-arrow-down"></i></div>
|
||||
</div>
|
||||
<div class="invalid-feedback">{{ $invalidFeedback }}</div>
|
||||
</div>
|
||||
{!! $additionalHtmlElements !!}
|
||||
</div>
|
@@ -1,4 +1,5 @@
|
||||
@push('componentScripts')
|
||||
<script src="{{ $U('/node_modules/chart.js/dist/Chart.min.js?v=', true) }}{{ $version }}"></script>
|
||||
<script src="{{ $U('/viewjs/components/productcard.js', true) }}?v={{ $version }}"></script>
|
||||
@endpush
|
||||
|
||||
@@ -11,6 +12,11 @@
|
||||
<strong>{{ $L('Stock quantity unit') }}:</strong> <span id="productcard-product-stock-qu-name"></span><br>
|
||||
<strong>{{ $L('Stock amount') }}:</strong> <span id="productcard-product-stock-amount"></span> <span id="productcard-product-stock-qu-name2"></span><br>
|
||||
<strong>{{ $L('Last purchased') }}:</strong> <span id="productcard-product-last-purchased"></span> <time id="productcard-product-last-purchased-timeago" class="timeago timeago-contextual"></time><br>
|
||||
<strong>{{ $L('Last used') }}:</strong> <span id="productcard-product-last-used"></span> <time id="productcard-product-last-used-timeago" class="timeago timeago-contextual"></time>
|
||||
<strong>{{ $L('Last used') }}:</strong> <span id="productcard-product-last-used"></span> <time id="productcard-product-last-used-timeago" class="timeago timeago-contextual"></time><br>
|
||||
<strong>{{ $L('Last price') }}:</strong> <span id="productcard-product-last-price"></span>
|
||||
|
||||
<h5 class="mt-3">{{ $L('Price history') }}</h5>
|
||||
<canvas id="productcard-product-price-history-chart" class="w-100 d-none"></canvas>
|
||||
<span id="productcard-no-price-data-hint" class="font-italic d-none">{{ $L('No price history available') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -4,10 +4,11 @@
|
||||
|
||||
@php if(empty($disallowAddProductWorkflows)) { $disallowAddProductWorkflows = false; } @endphp
|
||||
@php if(empty($prefillByName)) { $prefillByName = ''; } @endphp
|
||||
@php if(!isset($isRequired)) { $isRequired = true; } @endphp
|
||||
|
||||
<div class="form-group" data-next-input-selector="{{ $nextInputSelector }}" data-disallow-add-product-workflows="{{ BoolToString($disallowAddProductWorkflows) }}" data-prefill-by-name="{{ $prefillByName }}">
|
||||
<label for="product_id">{{ $L('Product') }} <i class="fas fa-barcode"></i><span id="barcode-lookup-disabled-hint" class="small text-muted d-none"> Barcode lookup is disabled</span></label>
|
||||
<select class="form-control combobox" id="product_id" name="product_id" required>
|
||||
<label for="product_id">{{ $L('Product') }} <i class="fas fa-barcode"></i><span id="barcode-lookup-disabled-hint" class="small text-muted d-none"> {{ $L('Barcode lookup is disabled') }}</span></label>
|
||||
<select class="form-control product-combobox" id="product_id" name="product_id" @if($isRequired) required @endif>
|
||||
<option value=""></option>
|
||||
@foreach($products as $product)
|
||||
<option data-additional-searchdata="{{ $product->barcode }}" value="{{ $product->id }}">{{ $product->name }}</option>
|
||||
|
16
views/components/userpicker.blade.php
Normal file
16
views/components/userpicker.blade.php
Normal file
@@ -0,0 +1,16 @@
|
||||
@push('componentScripts')
|
||||
<script src="{{ $U('/viewjs/components/userpicker.js', true) }}?v={{ $version }}"></script>
|
||||
@endpush
|
||||
|
||||
@php if(empty($prefillByUsername)) { $prefillByUsername = ''; } @endphp
|
||||
@php if(empty($prefillByUserId)) { $prefillByUserId = ''; } @endphp
|
||||
|
||||
<div class="form-group" data-next-input-selector="{{ $nextInputSelector }}" data-prefill-by-username="{{ $prefillByUsername }}" data-prefill-by-user-id="{{ $prefillByUserId }}">
|
||||
<label for="user_id">{{ $L($label) }}</label>
|
||||
<select class="form-control user-combobox" id="user_id" name="user_id">
|
||||
<option value=""></option>
|
||||
@foreach($users as $user)
|
||||
<option data-additional-searchdata="{{ $user->username }}" value="{{ $user->id }}">{{ GetUserDisplayName($user) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user