mirror of
				https://github.com/grocy/grocy.git
				synced 2025-11-04 05:15:08 +00:00 
			
		
		
		
	Support dynamic "today" for MEAL_PLAN_FIRST_DAY_OF_WEEK (closes #2205)
This commit is contained in:
		@@ -54,6 +54,7 @@
 | 
			
		||||
### Meal plan
 | 
			
		||||
 | 
			
		||||
- Added a new sub feature flag `FEATURE_FLAG_RECIPES_MEALPLAN` (in `config.php`) to only disable the meal plan if not needed (thanks @webysther)
 | 
			
		||||
- The `config.php` setting `MEAL_PLAN_FIRST_DAY_OF_WEEK` can now be set to `-1` to dynamically start the meal plan week on _today_
 | 
			
		||||
- Fixed that consuming a recipe from the meal plan didn't add its "Produces product"-product to stock (if any)
 | 
			
		||||
- Fixed that the "Put missing products on shopping list"-button in the header (to put all missing products on the shopping list for a whole week) was missing under certain circumstances (related to locale week numbers and turn of the year)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,7 @@ Setting('CALENDAR_SHOW_WEEK_OF_YEAR', true);
 | 
			
		||||
// Set this if you want to have a different start day for the weekly meal plan view,
 | 
			
		||||
// leave empty to use CALENDAR_FIRST_DAY_OF_WEEK (see above)
 | 
			
		||||
// Needs to be a number where Sunday = 0, Monday = 1 and so forth
 | 
			
		||||
// Can also be set to -1 to dynamically start the meal plan week on "today"
 | 
			
		||||
Setting('MEAL_PLAN_FIRST_DAY_OF_WEEK', '');
 | 
			
		||||
 | 
			
		||||
// To keep it simple: grocy does not handle any currency conversions,
 | 
			
		||||
 
 | 
			
		||||
@@ -63,7 +63,7 @@ class ConfigurationValidator
 | 
			
		||||
	private function checkMealplanFirstDayOfWeek()
 | 
			
		||||
	{
 | 
			
		||||
		if (!(GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK == '' ||
 | 
			
		||||
			(is_numeric(GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK) && GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK >= 0 && GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK <= 6)))
 | 
			
		||||
			(is_numeric(GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK) && GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK >= -1 && GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK <= 6)))
 | 
			
		||||
		{
 | 
			
		||||
			throw new EInvalidConfig('Invalid value for MEAL_PLAN_FIRST_DAY_OF_WEEK');
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,11 @@ if (Grocy.CalendarFirstDayOfWeek)
 | 
			
		||||
if (Grocy.MealPlanFirstDayOfWeek)
 | 
			
		||||
{
 | 
			
		||||
	firstDay = Number.parseInt(Grocy.MealPlanFirstDayOfWeek);
 | 
			
		||||
 | 
			
		||||
	if (firstDay == -1)
 | 
			
		||||
	{
 | 
			
		||||
		firstDay = moment().day();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(".calendar").each(function()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user