Example #1
0
 public function myRecipes()
 {
     $scope = array('title' => 'Make Fit Real User Area', 'website' => $this->website, 'csrf' => $this->csrf, 'intro-title' => Lang::get('intro-title-diet'));
     $navbar_stuff = $this->navbar_stuff();
     $scope['navbar-stuff'] = $navbar_stuff['stuff'];
     $scope['navbar-links'] = $navbar_stuff['links'];
     $scope['coaching-status'] = MfrUsers::current_status();
     $scope['average-status']['kcals'] = $scope['coaching-status'][2]['value'] / 4;
     $scope['average-status']['protein'] = $scope['coaching-status'][3]['value'] / 4;
     $scope['average-status']['carbs'] = $scope['coaching-status'][4]['value'] / 4;
     $scope['average-status']['fat'] = $scope['coaching-status'][5]['value'] / 4;
     $scope['average-status']['macros'] = $scope['coaching-status'][6]['value'];
     $scope['recipes'] = MfrUserRecipes::allRecipes(Session::get('id'));
     View::render('coaching/user/diet/adapt-from-blog/index.php', $scope);
 }
Example #2
0
 public function organizeRecipe(array $recipe_array, $carbs_per_recipe, $protein_per_recipe, $fat_per_recipe)
 {
     $recipe_num = sizeof($recipe_array);
     $return = array();
     $return['refs'] = array();
     $return['macros'] = array();
     $total['kcals'] = 0;
     $total['protein'] = 0;
     $total['carbs'] = 0;
     $total['fats'] = 0;
     foreach ($recipe_array as $recipe) {
         $recipe_description = $this->calcSingleRecipe($carbs_per_recipe, $protein_per_recipe, $fat_per_recipe, $recipe);
         $tmp_alimentos = array();
         foreach ($recipe_description as $items) {
             foreach ($items as $item) {
                 if (is_array($item)) {
                     array_push($tmp_alimentos, array('name' => $item['name'], 'quantity' => $item['quantity']));
                 }
             }
         }
         $recipe_info = MfrUserRecipes::find($recipe)[0];
         $tmp_ref = array('name' => $recipe_info->name, 'image' => $recipe_info->thumbnail, 'description' => $recipe_info->instructions, 'alimentos' => $tmp_alimentos, 'macros' => array(array('name' => Lang::get('kcals'), 'quantity' => ($recipe_description['macros']['carbs'] + $recipe_description['macros']['protein']) * 4 + $recipe_description['macros']['fats'] * 9), array('name' => Lang::get('protein'), 'quantity' => $recipe_description['macros']['protein']), array('name' => Lang::get('carbs'), 'quantity' => $recipe_description['macros']['carbs']), array('name' => Lang::get('fats'), 'quantity' => $recipe_description['macros']['fats'])));
         $total['kcals'] = $total['kcals'] + ($recipe_description['macros']['carbs'] + $recipe_description['macros']['protein']) * 4 + $recipe_description['macros']['fats'] * 9;
         $total['protein'] = $total['protein'] + $recipe_description['macros']['protein'];
         $total['carbs'] = $total['carbs'] + $recipe_description['macros']['carbs'];
         $total['fats'] = $total['fats'] + $recipe_description['macros']['fats'];
         array_push($return['refs'], $tmp_ref);
     }
     $return['macros'] = array(array('name' => Lang::get('kcals'), 'quantity' => $total['kcals']), array('name' => Lang::get('protein'), 'quantity' => $total['protein']), array('name' => Lang::get('carbs'), 'quantity' => $total['carbs']), array('name' => Lang::get('fats'), 'quantity' => $total['fats']));
     return $return;
 }