public function indexAction() { parent::init(); $view = Zend_Registry::get('view'); $view->headTitle($this->t->_('Dashboard')); $modelUsers = new Model_Users(); $modelExercises = new Model_Exercises(); $modelWorkouts = new Model_Workouts(); $this->view->users = count($modelUsers->fetchAll()); $this->view->exercises = count($modelExercises->fetchAll()); $this->view->workouts = count($modelWorkouts->fetchAll()); }
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(); }
public function addSelectedExercisesAction() { parent::ajaxEnabled(true); $exerciseIds = $this->_getParam('exerciseIds'); $modelWorkouts = new Model_Workouts(); $modelWorkoutsExercises = new Model_Workouts_Exercises(); $form = self::getAddSelectedExercisesForm(); $request = $this->getRequest(); if ($request->isPost()) { $post = $request->getPost(); if ($form->isValid($post)) { $values = $form->getValues(); $exerciseIdsArray = explode(',', $exerciseIds); unset($values['exerciseIds']); foreach ($exerciseIdsArray as $exerciseId) { $values['exerciseId'] = $exerciseId; $modelWorkoutsExercises->insert($values); } echo Zend_Json::encode(array('success' => 1)); exit; } else { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Please fill out all required fields'), 'icon' => 'error')); exit; } } $form->setWorkouts($modelWorkouts->fetchAll('userId = ' . $this->user->getId())->toArray()); $form->setHidden($exerciseIds); $this->view->form = $form; }
public function deleteWorkoutAction() { $id = $this->_getParam('id'); $modelWorkouts = new Model_Workouts(); $modelWorkoutsExercises = new Model_Workouts_Exercises(); $modelWorkouts->delete($id); $modelWorkoutsExercises->delete(' workoutId = ' . $id); exit; }
public function viewDetailAction() { parent::ajaxEnabled(true); $id = $this->_getParam('id'); $modelDailyExercises = new Public_Model_Daily_Exercises(); $modelWorkouts = new Model_Workouts(); $modelWorkoutsExercises = new Model_Workouts_Exercises(); $modelExercises = new Model_Exercises(); $detail = $modelDailyExercises->fetchRow('id = ' . $id)->toArray(); $this->view->workoutExercises = $modelWorkoutsExercises->fetchAll('workoutId = ' . $detail['workoutId'] . ' and day = ' . $detail['workoutDay'], 'order ASC')->toArray(); $this->view->workoutDetail = $modelWorkouts->fetch($detail['workoutId']); $this->view->exercises = $modelExercises; $this->view->detail = $detail; }
public function deleteAction() { $modelWorkouts = new Model_Workouts(); $modelWorkoutsExercises = new Model_Workouts_Exercises(); $workoutId = $this->_getParam('workoutId'); $workoutsInfo = $modelWorkouts->fetch($workoutId); $modelWorkouts->delete($workoutId); $modelWorkoutsExercises->delete(' workoutId = ' . $workoutId); echo Zend_Json::encode(array('success' => 1, 'itemId' => $workoutId, 'rowId' => 'workout-', 'title' => $this->t->_('Success Message'), 'message' => sprintf($this->t->_('%s was successfully deleted'), $workoutsInfo->name), 'icon' => 'success')); exit; }