コード例 #1
0
 public function indexAction()
 {
     $modelWorkouts = new Model_Workouts();
     $modelDailyDetails = new Public_Model_Daily_Details();
     $modelDailyExercises = new Public_Model_Daily_Exercises();
     $modelMeasurements = new Public_Model_Measurements();
     $statistics = array();
     for ($i = 1; $i <= 4; $i++) {
         $statistics['workouts'] = count($modelWorkouts->fetchAll('userId = ' . $this->user->getId()));
         $statistics['dailydetails'] = count($modelDailyDetails->fetchAll('userId = ' . $this->user->getId()));
         $statistics['dailyexercises'] = count($modelDailyExercises->fetchAll('userId = ' . $this->user->getId()));
         $statistics['measurements'] = count($modelMeasurements->fetchAll('userId = ' . $this->user->getId()));
     }
     $today = date('Y-m-d');
     $milesRan = $modelDailyExercises->fetchAll("type = 'Running' and date = '" . $today . "' and userId =  " . $this->user->getId())->toArray();
     $totalMiles = null;
     foreach ($milesRan as $data) {
         if ($data['miles']) {
             $totalMiles += $data['miles'];
         }
     }
     $statistics['milesRan'] = $totalMiles;
     $dailyIntake = new Public_Model_Daily_Intake();
     $dataDailyIntake = $dailyIntake->fetchMacros($today, $this->user);
     if ($dataDailyIntake) {
         $statistics['caloriesConsumed'] = $dataDailyIntake[$today]['totalCalories'];
     }
     $this->view->statistics = $statistics;
 }
 public function monthlyAction()
 {
     $options = array('month' => $this->_getParam('month'), 'year' => $this->_getParam('year'), 'day' => $this->_getParam('day'));
     $calendar = vkNgine_Calendar::buildMonthly($options);
     $modelWorkouts = new Model_Workouts();
     $workoutDetail = array();
     foreach ($modelWorkouts->fetchAll() as $workout) {
         $workoutDetail[$workout['workoutId']] = $workout['name'];
     }
     $this->view->workoutDetail = $workoutDetail;
     $this->view->links = array('next' => $calendar->nextMonth('object'), 'prev' => $calendar->prevMonth('object'));
     $this->view->calendar = $calendar;
     $start = date('Y-m-d', $calendar->getTimeStamp());
     $end = strtotime(date("Y-m-d", strtotime($start)) . " +1 month");
     $end = date('Y-m-d', $end);
     $modelMeasurements = new Public_Model_Measurements();
     $this->view->otherdata = $modelMeasurements->fetchAll("userId = '" . $this->user->getId() . "' and date >= '" . $start . "' and date < '" . $end . "' ")->toArray();
 }
コード例 #3
0
 public function myMeasurementsAction()
 {
     $modelMeasurements = new Public_Model_Measurements();
     $this->view->measurements = $modelMeasurements->fetchAll("userId = " . $this->user->getId(), "date DESC")->toArray();
 }