function add()
 {
     $this->loadModel(TEAM);
     $d['teams'] = $this->Team->findList(array(), 'team');
     if (empty($d['teams'])) {
         $this->logger->LogError($this->request->controller, $this->request->action, $_SESSION['User']->login, BackendTranslate::getLabel('no_category'));
         $this->Session->setAlert(BackendTranslate::getLabel('no_category'), DANGER);
         $this->redirect('cockpit/team/add');
     }
     $this->set($d);
     if ($this->request->data) {
         $this->loadModel(CALENDAR);
         $this->request->data->dayofgame = dateUndoConvert($this->request->data->dayofgame);
         $id = $this->Calendar->save($this->request->data);
         if (!is_numeric($id)) {
             $_SESSION['data'] = $this->request->data;
             $this->logger->LogError($this->request->controller, $this->request->action, $_SESSION[USER]->login, BackendTranslate::getLabel(DB) . '/id:' . $id);
             $this->Session->setAlert(BackendTranslate::getLabel(DB) . $id, DANGER);
             $this->redirect('cockpit/calendar/add');
             return false;
         }
         $this->logger->LogInfo($this->request->controller, $this->request->action, $_SESSION[USER]->login, BackendTranslate::getLabel('added') . '/id:' . $id);
         $this->Session->setAlert(BackendTranslate::getLabel('added'), SUCCESS);
         $this->redirect('cockpit/calendar/add');
     } else {
         if (isset($_SESSION['data'])) {
             $this->request->data = $_SESSION['data'];
             unset($_SESSION['data']);
         }
     }
 }
Exemple #2
0
 function add()
 {
     if ($this->request->data) {
         $this->loadModel(TIP);
         $this->request->data->publication = dateUndoConvert($this->request->data->publication);
         $id = $this->Tip->save($this->request->data);
         if (!is_numeric($id)) {
             $_SESSION['data'] = $this->request->data;
             $this->logger->LogError($this->request->controller, $this->request->action, $_SESSION[USER]->login, ErrorsTranslate::getLabel(DB) . '/id:' . $id);
             $this->Session->setAlert(ErrorsTranslate::getLabel(DB) . $id, DANGER);
             $this->redirect('cockpit/tip/add');
             return false;
         }
         $this->logger->LogInfo($this->request->controller, $this->request->action, $_SESSION[USER]->login, TipTranslate::getLabel('added') . '/id:' . $id);
         $this->Session->setAlert(TipTranslate::getLabel('added'), SUCCESS);
         $this->redirect('cockpit/tip/add');
     } else {
         if (isset($_SESSION['data'])) {
             $this->request->data = $_SESSION['data'];
             unset($_SESSION['data']);
         }
     }
 }