public function init()
 {
     parent::init();
 }
 public function manageWorkoutAction()
 {
     parent::ajaxEnabled();
     $id = (int) $this->_getParam('id');
     $modelWorkouts = new Model_Workouts();
     $modelExercises = new Model_Exercises();
     $modelWorkoutsExercises = new Model_Workouts_Exercises();
     $form = self::getManageWorkoutForm();
     $exerciseDetail = array();
     foreach ($modelExercises->fetchAll() as $exercise) {
         $exerciseDetail[$exercise['exerciseId']] = $exercise['name'];
     }
     $this->view->exerciseDetail = $exerciseDetail;
     $this->view->workout = $modelWorkouts->fetch($id);
     $this->view->exercises = $modelWorkoutsExercises;
     $this->view->form = $form;
 }
 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 viewDayDetailAction()
 {
     parent::ajaxEnabled(true);
     $id = $this->_getParam('id');
     $modelDailyDetails = new Public_Model_Daily_Details();
     $this->view->details = $modelDailyDetails->fetchRow('id = ' . $id);
 }