public function addGoalFormSucceeded($form, $values) { $data = $this->model->get($values->id); if ($data && $data->works == 0 && ($this->user->isInRole("administrator") || $this->user->id == $data->user_id)) { try { $this->model->addGoal($values->id, $values->description); } catch (Exception $e) { $this->flashMessage("Přidání cíle se nepodařilo.", "danger"); } } else { $this->flashMessage("Cíl nelze přidat.", "danger"); } if (!$this->isAjax()) { $this->redirect('this'); } else { $this->template->goals = $this->model->getGoals($values->id); $this->invalidateControl('goalList'); $this->invalidateControl('goalForm'); $this->invalidateControl('flashMessages'); $form->setValues(array(), TRUE); } }
public function addGoalFormSucceeded($form, $values) { $data = $this->model->get($values->id); if ($this->checkAvailability($data)) { $this->flashMessage("Cíl nelze přidat.", "danger"); return; } try { $this->model->addGoal($values->id, $values->description); } catch (Exception $e) { $this->flashMessage("Přidání cíle se nepodařilo.", "danger"); } if ($this->isAjax()) { $this->template->goals = $this->model->getGoals($values->id); $this->redrawControl('goalList'); $this->redrawControl('goalForm'); $this->redrawControl('flashMessages'); $form->setValues(array(), TRUE); return; } $this->redirect('this'); }