mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Squashed commit
Updated dependencies Added the possibility to skip chore schedules (closes #1486) Show the meal plan section on the corresponding calendar events (closes #1582) Make it possible to define a time for meal plan sections and use that time for the corresponding calendar events (references #1582) Added a changelog template Make it possible to toggle the meal plan calendar view on bigger screens (closes #1678)
This commit is contained in:
@@ -14,6 +14,11 @@ class ApplicationService extends BaseService
|
||||
$fileName = basename($file);
|
||||
$fileNameParts = explode('_', $fileName);
|
||||
|
||||
if ($fileName == '__TEMPLATE.md')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$fileContent = file_get_contents($file);
|
||||
$version = $fileNameParts[1];
|
||||
$releaseDate = explode('.', $fileNameParts[2])[0];
|
||||
|
@@ -100,48 +100,75 @@ class CalendarService extends BaseService
|
||||
$mealPlanProductEvents = [];
|
||||
if (GROCY_FEATURE_FLAG_RECIPES)
|
||||
{
|
||||
$recipes = $this->getDatabase()->recipes();
|
||||
$mealPlanDayRecipes = $this->getDatabase()->recipes()->where('type', 'mealplan-day');
|
||||
$titlePrefix = $this->getLocalizationService()->__t('Meal plan recipe') . ': ';
|
||||
$mealPlanSections = $this->getDatabase()->meal_plan_sections();
|
||||
|
||||
$recipes = $this->getDatabase()->recipes()->where('type', 'normal');
|
||||
$mealPlanDayRecipes = $this->getDatabase()->meal_plan()->where('type', 'recipe');
|
||||
$titlePrefix = $this->getLocalizationService()->__t('Meal plan recipe') . ': ';
|
||||
foreach ($mealPlanDayRecipes as $mealPlanDayRecipe)
|
||||
{
|
||||
$recipesOfCurrentDay = $this->getDatabase()->recipes_nestings_resolved()->where('recipe_id = :1 AND includes_recipe_id != :1', $mealPlanDayRecipe->id);
|
||||
|
||||
foreach ($recipesOfCurrentDay as $recipeOfCurrentDay)
|
||||
$start = $mealPlanDayRecipe->day;
|
||||
$dateFormat = 'date';
|
||||
$section = FindObjectInArrayByPropertyValue($mealPlanSections, 'id', $mealPlanDayRecipe->section_id);
|
||||
if (!empty($section->time_info))
|
||||
{
|
||||
$mealPlanRecipeEvents[] = [
|
||||
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->includes_recipe_id)->name,
|
||||
'start' => FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->recipe_id)->name,
|
||||
'date_format' => 'date',
|
||||
'description' => $this->UrlManager->ConstructUrl('/mealplan' . '?week=' . FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->recipe_id)->name),
|
||||
'link' => $this->UrlManager->ConstructUrl('/recipes' . '?recipe=' . $recipeOfCurrentDay->includes_recipe_id . '#fullscreen')
|
||||
];
|
||||
$start = $mealPlanDayRecipe->day . ' ' . $section->time_info . ':00';
|
||||
$dateFormat = 'datetime';
|
||||
}
|
||||
|
||||
$titlePrefix2 = '';
|
||||
if (!empty($section->name))
|
||||
{
|
||||
$titlePrefix2 = $section->name . ': ';
|
||||
}
|
||||
|
||||
$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')
|
||||
];
|
||||
}
|
||||
|
||||
$mealPlanDayNotes = $this->getDatabase()->meal_plan()->where('type', 'note');
|
||||
$titlePrefix = $this->getLocalizationService()->__t('Meal plan note') . ': ';
|
||||
|
||||
foreach ($mealPlanDayNotes as $mealPlanDayNote)
|
||||
{
|
||||
$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';
|
||||
}
|
||||
|
||||
$mealPlanNotesEvents[] = [
|
||||
'title' => $titlePrefix . $mealPlanDayNote->note,
|
||||
'start' => $mealPlanDayNote->day,
|
||||
'date_format' => 'date'
|
||||
'start' => $start,
|
||||
'date_format' => $dateFormat
|
||||
];
|
||||
}
|
||||
|
||||
$products = $this->getDatabase()->products();
|
||||
$mealPlanDayProducts = $this->getDatabase()->meal_plan()->where('type', 'product');
|
||||
$titlePrefix = $this->getLocalizationService()->__t('Meal plan product') . ': ';
|
||||
|
||||
foreach ($mealPlanDayProducts as $mealPlanDayProduct)
|
||||
{
|
||||
$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';
|
||||
}
|
||||
|
||||
$mealPlanProductEvents[] = [
|
||||
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($products, 'id', $mealPlanDayProduct->product_id)->name,
|
||||
'start' => $mealPlanDayProduct->day,
|
||||
'date_format' => 'date'
|
||||
'start' => $start,
|
||||
'date_format' => $dateFormat
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -110,8 +110,8 @@ class ChoresService extends BaseService
|
||||
$users = $this->getUsersService()->GetUsersAsDto();
|
||||
|
||||
$chore = $this->getDatabase()->chores($choreId);
|
||||
$choreTrackedCount = $this->getDatabase()->chores_log()->where('chore_id = :1 AND undone = 0', $choreId)->count();
|
||||
$choreLastTrackedTime = $this->getDatabase()->chores_log()->where('chore_id = :1 AND undone = 0', $choreId)->max('tracked_time');
|
||||
$choreTrackedCount = $this->getDatabase()->chores_log()->where('chore_id = :1 AND undone = 0 AND skipped = 0', $choreId)->count();
|
||||
$choreLastTrackedTime = $this->getDatabase()->chores_log()->where('chore_id = :1 AND undone = 0 AND skipped = 0', $choreId)->max('tracked_time');
|
||||
$nextExecutionTime = $this->getDatabase()->chores_current()->where('chore_id', $choreId)->min('next_estimated_execution_time');
|
||||
|
||||
$lastChoreLogRow = $this->getDatabase()->chores_log()->where('chore_id = :1 AND tracked_time = :2 AND undone = 0', $choreId, $choreLastTrackedTime)->fetch();
|
||||
@@ -157,7 +157,7 @@ class ChoresService extends BaseService
|
||||
return $chores;
|
||||
}
|
||||
|
||||
public function TrackChore(int $choreId, string $trackedTime, $doneBy = GROCY_USER_ID)
|
||||
public function TrackChore(int $choreId, string $trackedTime, $doneBy = GROCY_USER_ID, $skipped = false)
|
||||
{
|
||||
if (!$this->ChoreExists($choreId))
|
||||
{
|
||||
@@ -176,10 +176,21 @@ class ChoresService extends BaseService
|
||||
$trackedTime = substr($trackedTime, 0, 10) . ' 00:00:00';
|
||||
}
|
||||
|
||||
if ($skipped)
|
||||
{
|
||||
if ($chore->period_type == self::CHORE_PERIOD_TYPE_MANUALLY)
|
||||
{
|
||||
throw new \Exception('Chores without a schedule can\'t be skipped');
|
||||
}
|
||||
|
||||
$trackedTime = $this->getDatabase()->chores_current()->where('chore_id', $choreId)->min('next_estimated_execution_time');
|
||||
}
|
||||
|
||||
$logRow = $this->getDatabase()->chores_log()->createRow([
|
||||
'chore_id' => $choreId,
|
||||
'tracked_time' => $trackedTime,
|
||||
'done_by_user_id' => $doneBy
|
||||
'done_by_user_id' => $doneBy,
|
||||
'skipped' => BoolToInt($skipped)
|
||||
]);
|
||||
$logRow->save();
|
||||
$lastInsertId = $this->getDatabase()->lastInsertId();
|
||||
|
Reference in New Issue
Block a user