public function refreshDashboardAction() { $mode = $this->_getParam('mode'); $today = date('Y-m-d'); switch ($mode) { case 'today': $date = $today; break; case 'yesterday': $date = date('Y-m-d', strtotime($today . '-1 day')); break; case 'tomorrow': $date = date('Y-m-d', strtotime($today . '+1 day')); break; case 'last7days': $date1 = date('Y-m-d', strtotime($today . '-7 days')); $date2 = $today; break; case 'last30days': $date1 = date('Y-m-d', strtotime($today . '-30 days')); $date2 = $today; break; case 'thismonth': $date = null; break; case 'lastmonth': $date = null; break; } $modelDailyExercises = new Public_Model_Daily_Exercises(); $dailyIntake = new Public_Model_Daily_Intake(); if (isset($date1) && isset($date2)) { $milesRan = $modelDailyExercises->fetchAll("type = 'Running' and date between '" . $date1 . "' and '" . $date2 . "' and userId = " . $this->user->getId())->toArray(); $daysWithGym = $modelDailyExercises->fetchDaysWithOrWoutGym($date1, $date2, $this->user); } else { $dataDailyIntake = $dailyIntake->fetchMacros($date, $this->user); $milesRan = $modelDailyExercises->fetchAll("type = 'Running' and date = '" . $date . "' and userId = " . $this->user->getId())->toArray(); if (isset($dataDailyIntake[$date]['totalCalories'])) { $statistics['caloriesConsumed'] = $dataDailyIntake[$date]['totalCalories']; } } $totalMiles = null; foreach ($milesRan as $data) { if ($data['miles']) { $totalMiles += $data['miles']; } } $statistics['milesRan'] = $totalMiles; $this->view->statistics = $statistics; $this->_helper->layout->disableLayout(); }
public function viewDayAction() { parent::ajaxEnabled(); $date = $this->_getParam('date'); $modelDailyExercises = new Public_Model_Daily_Exercises(); $modelWorkouts = new Model_Workouts(); $modelWorkoutsExercises = new Model_Workouts_Exercises(); $modelDailyDetails = new Public_Model_Daily_Details(); $workoutDetail = array(); foreach ($modelWorkouts->fetchAll() as $workout) { $workoutDetail[$workout['workoutId']] = $workout['name']; } $this->view->dailyDetails = $modelDailyDetails->fetchAll("date = '" . $date . "' and userId = " . $this->user->getId() . " and type = 'SUPPLEMENT' ")->toArray(); $this->view->workoutExercises = $modelWorkoutsExercises; $this->view->workoutDetail = $workoutDetail; $this->view->detail = $modelDailyExercises->fetchAll("date = '" . $date . "' and workoutId != 0 and userId = " . $this->user->getId())->toArray(); $this->view->detail2 = $modelDailyExercises->fetchAll("date = '" . $date . "' and workoutId = 0 and userId = " . $this->user->getId())->toArray(); $this->view->param = $this->_getAllParams(); }