Files
grocy/services/CalendarService.php

203 lines
7.1 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Grocy\Services;
2020-08-31 20:40:31 +02:00
use Grocy\Helpers\UrlManager;
class CalendarService extends BaseService
{
public function __construct()
{
$this->UrlManager = new UrlManager(GROCY_BASE_URL);
}
private $UrlManager;
public function GetEvents()
{
$usersService = $this->getUsersService();
2020-08-31 20:40:31 +02:00
$stockEvents = [];
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
Convert services to singletons and use lazy loading to improve performance (#479) * use singletons to reduce need to recreate the same objects * unable to make the constructor private * comment out debug printing to log file * correct typo of treating self() as a var instead of a function * utilise Localisation service as a singleton * fix errent line that should have been commented * remove phpinfo * correct mistake in stock controller * try storing app in apcu * serialise inside the app closures * get timings for db-changed-time * get timings for db-changed-time * store localisation service in apcu * stor translations in apcu instead of localisation service (due to database connection) * correct syntax error * forgot to uncomment instance map * correct indentation and variable out of scope * more timings for app execution time * try apc caching for views * correct scope for Pot variable * remove additional fopen * correct timings for app build time * correct timings for app object build time * correct timings for app route build time * get timings for routing timings * get more in depth timings for routing loading * fix more in depth timings for routing loading * start investigating session auth middleware creation * start investigating session auth middleware creation * start investigating Login controller time * start investigating Login controller time * in depth look at Logincontroller timings * comment out debug printing * lazily obtain valus for page rendering * correct syntax error * correct scope of variable * correct visibiity of methds inherited from BaseController * missing use for Userfieldsservice * lazy loading of open api spec * lazy loading of users service * lazy loading of batteries service * lazy loading of services in controllers * lazy loading of services in services * correct mistake * fix userservice * fix userservice * fix userfieldservice * fix chores service * fix calendar service * remove Dockerfile used for development * Remove docker compose file used for development * Clean up app.php * remove last diff * Clean up base controller * Clean up controllers * lean up middleware * Clean up and tuen all services into singletons * remove debug from routes.php * remove acpu from localisation * Complete removal of acpu from localisation * fixes for things broken * More fixes following merge * Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var. * fix bug where getUsersService is declared twice * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * Fix all the not working things... * Deleted off-topic files * Deleted off-topic files Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 23:47:47 +07:00
$products = $this->getDatabase()->products();
$titlePrefix = $this->getLocalizationService()->__t('Product due') . ': ';
2020-08-31 20:40:31 +02:00
foreach ($this->getStockService()->GetCurrentStock() as $currentStockEntry)
{
if ($currentStockEntry->amount > 0)
{
2020-08-31 20:40:31 +02:00
$stockEvents[] = [
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->name,
'start' => $currentStockEntry->best_before_date,
'date_format' => 'date',
'link' => $this->UrlManager->ConstructUrl('/stockoverview'),
'color' => $usersService->GetUserSettings(GROCY_USER_ID)['calendar_color_products']
2020-08-31 20:40:31 +02:00
];
}
}
}
2020-08-31 20:40:31 +02:00
$taskEvents = [];
if (GROCY_FEATURE_FLAG_TASKS)
{
Convert services to singletons and use lazy loading to improve performance (#479) * use singletons to reduce need to recreate the same objects * unable to make the constructor private * comment out debug printing to log file * correct typo of treating self() as a var instead of a function * utilise Localisation service as a singleton * fix errent line that should have been commented * remove phpinfo * correct mistake in stock controller * try storing app in apcu * serialise inside the app closures * get timings for db-changed-time * get timings for db-changed-time * store localisation service in apcu * stor translations in apcu instead of localisation service (due to database connection) * correct syntax error * forgot to uncomment instance map * correct indentation and variable out of scope * more timings for app execution time * try apc caching for views * correct scope for Pot variable * remove additional fopen * correct timings for app build time * correct timings for app object build time * correct timings for app route build time * get timings for routing timings * get more in depth timings for routing loading * fix more in depth timings for routing loading * start investigating session auth middleware creation * start investigating session auth middleware creation * start investigating Login controller time * start investigating Login controller time * in depth look at Logincontroller timings * comment out debug printing * lazily obtain valus for page rendering * correct syntax error * correct scope of variable * correct visibiity of methds inherited from BaseController * missing use for Userfieldsservice * lazy loading of open api spec * lazy loading of users service * lazy loading of batteries service * lazy loading of services in controllers * lazy loading of services in services * correct mistake * fix userservice * fix userservice * fix userfieldservice * fix chores service * fix calendar service * remove Dockerfile used for development * Remove docker compose file used for development * Clean up app.php * remove last diff * Clean up base controller * Clean up controllers * lean up middleware * Clean up and tuen all services into singletons * remove debug from routes.php * remove acpu from localisation * Complete removal of acpu from localisation * fixes for things broken * More fixes following merge * Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var. * fix bug where getUsersService is declared twice * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * Fix all the not working things... * Deleted off-topic files * Deleted off-topic files Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 23:47:47 +07:00
$titlePrefix = $this->getLocalizationService()->__t('Task due') . ': ';
2020-08-31 20:40:31 +02:00
foreach ($this->getTasksService()->GetCurrent() as $currentTaskEntry)
{
2020-08-31 20:40:31 +02:00
$taskEvents[] = [
'title' => $titlePrefix . $currentTaskEntry->name,
'start' => $currentTaskEntry->due_date,
'date_format' => 'date',
'link' => $this->UrlManager->ConstructUrl('/tasks'),
'color' => $usersService->GetUserSettings(GROCY_USER_ID)['calendar_color_tasks']
2020-08-31 20:40:31 +02:00
];
}
}
2020-08-31 20:40:31 +02:00
$choreEvents = [];
if (GROCY_FEATURE_FLAG_CHORES)
{
Convert services to singletons and use lazy loading to improve performance (#479) * use singletons to reduce need to recreate the same objects * unable to make the constructor private * comment out debug printing to log file * correct typo of treating self() as a var instead of a function * utilise Localisation service as a singleton * fix errent line that should have been commented * remove phpinfo * correct mistake in stock controller * try storing app in apcu * serialise inside the app closures * get timings for db-changed-time * get timings for db-changed-time * store localisation service in apcu * stor translations in apcu instead of localisation service (due to database connection) * correct syntax error * forgot to uncomment instance map * correct indentation and variable out of scope * more timings for app execution time * try apc caching for views * correct scope for Pot variable * remove additional fopen * correct timings for app build time * correct timings for app object build time * correct timings for app route build time * get timings for routing timings * get more in depth timings for routing loading * fix more in depth timings for routing loading * start investigating session auth middleware creation * start investigating session auth middleware creation * start investigating Login controller time * start investigating Login controller time * in depth look at Logincontroller timings * comment out debug printing * lazily obtain valus for page rendering * correct syntax error * correct scope of variable * correct visibiity of methds inherited from BaseController * missing use for Userfieldsservice * lazy loading of open api spec * lazy loading of users service * lazy loading of batteries service * lazy loading of services in controllers * lazy loading of services in services * correct mistake * fix userservice * fix userservice * fix userfieldservice * fix chores service * fix calendar service * remove Dockerfile used for development * Remove docker compose file used for development * Clean up app.php * remove last diff * Clean up base controller * Clean up controllers * lean up middleware * Clean up and tuen all services into singletons * remove debug from routes.php * remove acpu from localisation * Complete removal of acpu from localisation * fixes for things broken * More fixes following merge * Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var. * fix bug where getUsersService is declared twice * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * Fix all the not working things... * Deleted off-topic files * Deleted off-topic files Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 23:47:47 +07:00
$users = $this->getUsersService()->GetUsersAsDto();
$chores = $this->getDatabase()->chores()->where('active = 1');
Convert services to singletons and use lazy loading to improve performance (#479) * use singletons to reduce need to recreate the same objects * unable to make the constructor private * comment out debug printing to log file * correct typo of treating self() as a var instead of a function * utilise Localisation service as a singleton * fix errent line that should have been commented * remove phpinfo * correct mistake in stock controller * try storing app in apcu * serialise inside the app closures * get timings for db-changed-time * get timings for db-changed-time * store localisation service in apcu * stor translations in apcu instead of localisation service (due to database connection) * correct syntax error * forgot to uncomment instance map * correct indentation and variable out of scope * more timings for app execution time * try apc caching for views * correct scope for Pot variable * remove additional fopen * correct timings for app build time * correct timings for app object build time * correct timings for app route build time * get timings for routing timings * get more in depth timings for routing loading * fix more in depth timings for routing loading * start investigating session auth middleware creation * start investigating session auth middleware creation * start investigating Login controller time * start investigating Login controller time * in depth look at Logincontroller timings * comment out debug printing * lazily obtain valus for page rendering * correct syntax error * correct scope of variable * correct visibiity of methds inherited from BaseController * missing use for Userfieldsservice * lazy loading of open api spec * lazy loading of users service * lazy loading of batteries service * lazy loading of services in controllers * lazy loading of services in services * correct mistake * fix userservice * fix userservice * fix userfieldservice * fix chores service * fix calendar service * remove Dockerfile used for development * Remove docker compose file used for development * Clean up app.php * remove last diff * Clean up base controller * Clean up controllers * lean up middleware * Clean up and tuen all services into singletons * remove debug from routes.php * remove acpu from localisation * Complete removal of acpu from localisation * fixes for things broken * More fixes following merge * Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var. * fix bug where getUsersService is declared twice * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * Fix all the not working things... * Deleted off-topic files * Deleted off-topic files Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 23:47:47 +07:00
$titlePrefix = $this->getLocalizationService()->__t('Chore due') . ': ';
2020-08-31 20:40:31 +02:00
foreach ($this->getChoresService()->GetCurrent() as $currentChoreEntry)
{
$chore = FindObjectInArrayByPropertyValue($chores, 'id', $currentChoreEntry->chore_id);
$assignedToText = '';
if (!empty($currentChoreEntry->next_execution_assigned_to_user_id))
{
Convert services to singletons and use lazy loading to improve performance (#479) * use singletons to reduce need to recreate the same objects * unable to make the constructor private * comment out debug printing to log file * correct typo of treating self() as a var instead of a function * utilise Localisation service as a singleton * fix errent line that should have been commented * remove phpinfo * correct mistake in stock controller * try storing app in apcu * serialise inside the app closures * get timings for db-changed-time * get timings for db-changed-time * store localisation service in apcu * stor translations in apcu instead of localisation service (due to database connection) * correct syntax error * forgot to uncomment instance map * correct indentation and variable out of scope * more timings for app execution time * try apc caching for views * correct scope for Pot variable * remove additional fopen * correct timings for app build time * correct timings for app object build time * correct timings for app route build time * get timings for routing timings * get more in depth timings for routing loading * fix more in depth timings for routing loading * start investigating session auth middleware creation * start investigating session auth middleware creation * start investigating Login controller time * start investigating Login controller time * in depth look at Logincontroller timings * comment out debug printing * lazily obtain valus for page rendering * correct syntax error * correct scope of variable * correct visibiity of methds inherited from BaseController * missing use for Userfieldsservice * lazy loading of open api spec * lazy loading of users service * lazy loading of batteries service * lazy loading of services in controllers * lazy loading of services in services * correct mistake * fix userservice * fix userservice * fix userfieldservice * fix chores service * fix calendar service * remove Dockerfile used for development * Remove docker compose file used for development * Clean up app.php * remove last diff * Clean up base controller * Clean up controllers * lean up middleware * Clean up and tuen all services into singletons * remove debug from routes.php * remove acpu from localisation * Complete removal of acpu from localisation * fixes for things broken * More fixes following merge * Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var. * fix bug where getUsersService is declared twice * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * Fix all the not working things... * Deleted off-topic files * Deleted off-topic files Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 23:47:47 +07:00
$assignedToText = ' (' . $this->getLocalizationService()->__t('assigned to %s', FindObjectInArrayByPropertyValue($users, 'id', $currentChoreEntry->next_execution_assigned_to_user_id)->display_name) . ')';
}
2020-08-31 20:40:31 +02:00
$choreEvents[] = [
'title' => $titlePrefix . $chore->name . $assignedToText,
'start' => $currentChoreEntry->next_estimated_execution_time,
'date_format' => 'datetime',
'link' => $this->UrlManager->ConstructUrl('/choresoverview'),
'allDay' => $chore->track_date_only == 1,
'color' => $usersService->GetUserSettings(GROCY_USER_ID)['calendar_color_chores']
2020-08-31 20:40:31 +02:00
];
}
}
2020-08-31 20:40:31 +02:00
$batteryEvents = [];
if (GROCY_FEATURE_FLAG_BATTERIES)
{
$batteries = $this->getDatabase()->batteries()->where('active = 1');
Convert services to singletons and use lazy loading to improve performance (#479) * use singletons to reduce need to recreate the same objects * unable to make the constructor private * comment out debug printing to log file * correct typo of treating self() as a var instead of a function * utilise Localisation service as a singleton * fix errent line that should have been commented * remove phpinfo * correct mistake in stock controller * try storing app in apcu * serialise inside the app closures * get timings for db-changed-time * get timings for db-changed-time * store localisation service in apcu * stor translations in apcu instead of localisation service (due to database connection) * correct syntax error * forgot to uncomment instance map * correct indentation and variable out of scope * more timings for app execution time * try apc caching for views * correct scope for Pot variable * remove additional fopen * correct timings for app build time * correct timings for app object build time * correct timings for app route build time * get timings for routing timings * get more in depth timings for routing loading * fix more in depth timings for routing loading * start investigating session auth middleware creation * start investigating session auth middleware creation * start investigating Login controller time * start investigating Login controller time * in depth look at Logincontroller timings * comment out debug printing * lazily obtain valus for page rendering * correct syntax error * correct scope of variable * correct visibiity of methds inherited from BaseController * missing use for Userfieldsservice * lazy loading of open api spec * lazy loading of users service * lazy loading of batteries service * lazy loading of services in controllers * lazy loading of services in services * correct mistake * fix userservice * fix userservice * fix userfieldservice * fix chores service * fix calendar service * remove Dockerfile used for development * Remove docker compose file used for development * Clean up app.php * remove last diff * Clean up base controller * Clean up controllers * lean up middleware * Clean up and tuen all services into singletons * remove debug from routes.php * remove acpu from localisation * Complete removal of acpu from localisation * fixes for things broken * More fixes following merge * Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var. * fix bug where getUsersService is declared twice * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * Fix all the not working things... * Deleted off-topic files * Deleted off-topic files Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 23:47:47 +07:00
$titlePrefix = $this->getLocalizationService()->__t('Battery charge cycle due') . ': ';
2020-08-31 20:40:31 +02:00
foreach ($this->getBatteriesService()->GetCurrent() as $currentBatteryEntry)
{
2020-08-31 20:40:31 +02:00
$batteryEvents[] = [
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($batteries, 'id', $currentBatteryEntry->battery_id)->name,
'start' => $currentBatteryEntry->next_estimated_charge_time,
'date_format' => 'datetime',
'link' => $this->UrlManager->ConstructUrl('/batteriesoverview'),
'color' => $usersService->GetUserSettings(GROCY_USER_ID)['calendar_color_batteries']
2020-08-31 20:40:31 +02:00
];
}
}
2020-08-31 20:40:31 +02:00
$mealPlanRecipeEvents = [];
$mealPlanNotesEvents = [];
$mealPlanProductEvents = [];
if (GROCY_FEATURE_FLAG_RECIPES_MEALPLAN)
{
$mealPlanSections = $this->getDatabase()->meal_plan_sections();
2020-02-09 17:27:46 +01:00
$recipes = $this->getDatabase()->recipes()->where('type', 'normal');
$mealPlanDayRecipes = $this->getDatabase()->meal_plan()->where('type', 'recipe');
$titlePrefix = $this->getLocalizationService()->__t('Meal plan recipe') . ': ';
2020-08-31 20:40:31 +02:00
foreach ($mealPlanDayRecipes as $mealPlanDayRecipe)
{
$start = $mealPlanDayRecipe->day;
$dateFormat = 'date';
$section = FindObjectInArrayByPropertyValue($mealPlanSections, 'id', $mealPlanDayRecipe->section_id);
if (!empty($section->time_info))
{
$start = $mealPlanDayRecipe->day . ' ' . $section->time_info . ':00';
$dateFormat = 'datetime';
}
2020-08-31 20:40:31 +02:00
$titlePrefix2 = '';
if (!empty($section->name))
2020-02-09 17:27:46 +01:00
{
$titlePrefix2 = $section->name . ': ';
2020-02-09 17:27:46 +01:00
}
$mealPlanRecipeEvents[] = [
'title' => $titlePrefix . $titlePrefix2 . FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanDayRecipe->recipe_id)->name,
'start' => $start,
'date_format' => $dateFormat,
'description' => $this->UrlManager->ConstructUrl('/mealplan' . '?week=' . $mealPlanDayRecipe->day),
'link' => $this->UrlManager->ConstructUrl('/recipes' . '?recipe=' . $mealPlanDayRecipe->recipe_id . '#fullscreen'),
'color' => $usersService->GetUserSettings(GROCY_USER_ID)['calendar_color_meal_plan']
];
}
Convert services to singletons and use lazy loading to improve performance (#479) * use singletons to reduce need to recreate the same objects * unable to make the constructor private * comment out debug printing to log file * correct typo of treating self() as a var instead of a function * utilise Localisation service as a singleton * fix errent line that should have been commented * remove phpinfo * correct mistake in stock controller * try storing app in apcu * serialise inside the app closures * get timings for db-changed-time * get timings for db-changed-time * store localisation service in apcu * stor translations in apcu instead of localisation service (due to database connection) * correct syntax error * forgot to uncomment instance map * correct indentation and variable out of scope * more timings for app execution time * try apc caching for views * correct scope for Pot variable * remove additional fopen * correct timings for app build time * correct timings for app object build time * correct timings for app route build time * get timings for routing timings * get more in depth timings for routing loading * fix more in depth timings for routing loading * start investigating session auth middleware creation * start investigating session auth middleware creation * start investigating Login controller time * start investigating Login controller time * in depth look at Logincontroller timings * comment out debug printing * lazily obtain valus for page rendering * correct syntax error * correct scope of variable * correct visibiity of methds inherited from BaseController * missing use for Userfieldsservice * lazy loading of open api spec * lazy loading of users service * lazy loading of batteries service * lazy loading of services in controllers * lazy loading of services in services * correct mistake * fix userservice * fix userservice * fix userfieldservice * fix chores service * fix calendar service * remove Dockerfile used for development * Remove docker compose file used for development * Clean up app.php * remove last diff * Clean up base controller * Clean up controllers * lean up middleware * Clean up and tuen all services into singletons * remove debug from routes.php * remove acpu from localisation * Complete removal of acpu from localisation * fixes for things broken * More fixes following merge * Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var. * fix bug where getUsersService is declared twice * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * Fix all the not working things... * Deleted off-topic files * Deleted off-topic files Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 23:47:47 +07:00
$mealPlanDayNotes = $this->getDatabase()->meal_plan()->where('type', 'note');
$titlePrefix = $this->getLocalizationService()->__t('Meal plan note') . ': ';
2020-08-31 20:40:31 +02:00
foreach ($mealPlanDayNotes as $mealPlanDayNote)
2020-02-09 17:27:46 +01:00
{
$start = $mealPlanDayNote->day;
$dateFormat = 'date';
$section = FindObjectInArrayByPropertyValue($mealPlanSections, 'id', $mealPlanDayNote->section_id);
if (!empty($section->time_info))
{
$start = $mealPlanDayNote->day . ' ' . $section->time_info . ':00';
$dateFormat = 'datetime';
}
$titlePrefix2 = '';
if (!empty($section->name))
{
$titlePrefix2 = $section->name . ': ';
}
2020-08-31 20:40:31 +02:00
$mealPlanNotesEvents[] = [
'title' => $titlePrefix . $titlePrefix2 . $mealPlanDayNote->note,
'start' => $start,
'date_format' => $dateFormat,
'link' => $this->UrlManager->ConstructUrl('/mealplan' . '?start=' . $start),
'color' => $usersService->GetUserSettings(GROCY_USER_ID)['calendar_color_meal_plan']
2020-08-31 20:40:31 +02:00
];
2020-02-09 17:27:46 +01:00
}
Convert services to singletons and use lazy loading to improve performance (#479) * use singletons to reduce need to recreate the same objects * unable to make the constructor private * comment out debug printing to log file * correct typo of treating self() as a var instead of a function * utilise Localisation service as a singleton * fix errent line that should have been commented * remove phpinfo * correct mistake in stock controller * try storing app in apcu * serialise inside the app closures * get timings for db-changed-time * get timings for db-changed-time * store localisation service in apcu * stor translations in apcu instead of localisation service (due to database connection) * correct syntax error * forgot to uncomment instance map * correct indentation and variable out of scope * more timings for app execution time * try apc caching for views * correct scope for Pot variable * remove additional fopen * correct timings for app build time * correct timings for app object build time * correct timings for app route build time * get timings for routing timings * get more in depth timings for routing loading * fix more in depth timings for routing loading * start investigating session auth middleware creation * start investigating session auth middleware creation * start investigating Login controller time * start investigating Login controller time * in depth look at Logincontroller timings * comment out debug printing * lazily obtain valus for page rendering * correct syntax error * correct scope of variable * correct visibiity of methds inherited from BaseController * missing use for Userfieldsservice * lazy loading of open api spec * lazy loading of users service * lazy loading of batteries service * lazy loading of services in controllers * lazy loading of services in services * correct mistake * fix userservice * fix userservice * fix userfieldservice * fix chores service * fix calendar service * remove Dockerfile used for development * Remove docker compose file used for development * Clean up app.php * remove last diff * Clean up base controller * Clean up controllers * lean up middleware * Clean up and tuen all services into singletons * remove debug from routes.php * remove acpu from localisation * Complete removal of acpu from localisation * fixes for things broken * More fixes following merge * Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var. * fix bug where getUsersService is declared twice * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * Fix all the not working things... * Deleted off-topic files * Deleted off-topic files Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-03-01 23:47:47 +07:00
$products = $this->getDatabase()->products();
$mealPlanDayProducts = $this->getDatabase()->meal_plan()->where('type', 'product');
$titlePrefix = $this->getLocalizationService()->__t('Meal plan product') . ': ';
2020-08-31 20:40:31 +02:00
foreach ($mealPlanDayProducts as $mealPlanDayProduct)
2020-02-09 17:27:46 +01:00
{
$start = $mealPlanDayProduct->day;
$dateFormat = 'date';
$section = FindObjectInArrayByPropertyValue($mealPlanSections, 'id', $mealPlanDayProduct->section_id);
if (!empty($section->time_info))
{
$start = $mealPlanDayProduct->day . ' ' . $section->time_info . ':00';
$dateFormat = 'datetime';
}
$titlePrefix2 = '';
if (!empty($section->name))
{
$titlePrefix2 = $section->name . ': ';
}
2020-08-31 20:40:31 +02:00
$mealPlanProductEvents[] = [
'title' => $titlePrefix . $titlePrefix2 . FindObjectInArrayByPropertyValue($products, 'id', $mealPlanDayProduct->product_id)->name,
'start' => $start,
'date_format' => $dateFormat,
'link' => $this->UrlManager->ConstructUrl('/mealplan' . '?start=' . $start),
'color' => $usersService->GetUserSettings(GROCY_USER_ID)['calendar_color_meal_plan']
2020-08-31 20:40:31 +02:00
];
2020-02-09 17:27:46 +01:00
}
}
return array_merge($stockEvents, $taskEvents, $choreEvents, $batteryEvents, $mealPlanRecipeEvents, $mealPlanNotesEvents, $mealPlanProductEvents);
}
}