public function addExerciseAction()
 {
     parent::ajaxEnabled();
     $form = self::getWorkoutsExercisesEditForm();
     $modelWorkoutsExercises = new Model_Workouts_Exercises();
     $modelExercises = new Model_Exercises();
     $workoutId = $this->_getParam('workoutId');
     $workoutId = (int) $workoutId;
     if ($workoutId) {
         $request = $this->getRequest();
         if ($request->isPost()) {
             $post = $request->getPost();
             if ($form->isValid($post)) {
                 $values = $form->getValues();
                 $modelWorkoutsExercises->insert($values);
                 echo Zend_Json::encode(array('success' => 1, 'dialog' => 'btn-addexercisetoworkout-dialog', 'title' => $this->t->_('Success Message'), 'message' => $this->t->_('Exercise was successfully added'), 'icon' => 'success'));
                 exit;
             } else {
                 $error = $form->getErrors();
                 echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Please fill out all required fields'), 'icon' => 'error'));
                 exit;
             }
         }
         $form->setHidden($workoutId);
         $form->setExercises($modelExercises->fetchAll()->toArray());
         $this->view->form = $form;
     } else {
         new vkNgine_Exception('`workoutId` must be provided');
     }
 }
 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 viewWorkoutAction()
 {
     $url = $this->_getParam('url');
     $modelWorkouts = new Model_Workouts();
     $modelExercises = new Model_Exercises();
     $modelWorkoutsExercises = new Model_Workouts_Exercises();
     $exerciseDetail = array();
     foreach ($modelExercises->fetchAll() as $exercise) {
         $exerciseDetail[$exercise['exerciseId']] = $exercise['name'];
         $exerciseDetail[$exercise['exerciseId'] . '-url'] = $exercise['url'];
     }
     $this->view->exerciseDetail = $exerciseDetail;
     $this->view->workoutsExercises = $modelWorkoutsExercises;
     $this->view->workout = $modelWorkouts->fetchAll('url = "' . $url . '" ')->current();
 }