From 4256e5d315280b2c76780e7fdaefa9d621966833 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Fri, 3 Jan 2025 18:25:43 +0000 Subject: [PATCH] Allow user to specify their bmr and override our computation --- index.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 474f295..c7c0429 100644 --- a/index.php +++ b/index.php @@ -98,6 +98,10 @@
+ + +
+ @@ -372,9 +376,9 @@ function getWeeksOfCurrentMonth() { return $weeks; } -function generateMonthPlan($includeWeekends, $is_female, $weight, $height, $age, $activity_level) { +function generateMonthPlan($includeWeekends, $is_female, $weight, $height, $age, $activity_level, $bmr = null) { global $ingredientNutrition, $mealOptionsAndIngredients; - $bmr = calculateBMR($is_female, $weight, $height, $age, $activity_level); + $bmr = is_null($bmr) ? calculateBMR($is_female, $weight, $height, $age, $activity_level) : $bmr; // https://www.healthline.com/nutrition/best-macronutrient-ratio // These ranges are recommended by the Institute of Medicine and are widely accepted in nutritional science. // https://www.nal.usda.gov/programs/fnic @@ -465,6 +469,7 @@ if ($_SERVER['REQUEST_METHOD'] != 'GET' || !isset($_GET['is_female'], $_GET['wei $height = (int) $_GET['height']; $age = (int) $_GET['age']; $activity_level = (float) $_GET['activity_level']; + $bmr = (isset($_GET['bmr']) && !empty($_GET['bmr'])) ? (int) $_GET['bmr'] : null; - echo generateMonthPlan($includeWeekends, $is_female, $weight, $height, $age, $activity_level); + echo generateMonthPlan($includeWeekends, $is_female, $weight, $height, $age, $activity_level, $bmr); }