Esempio n. 1
0
 public function save($data)
 {
     if ($data['id'] > 0) {
         $modelExecutors = new Executors();
         if (is_array($data['executors']) && count($data['executors']) > 0) {
             $modelExecutors->setWhere(array('projects_id' => $data['id']));
             $modelExecutors->delete();
             foreach ($data['executors'] as $item) {
                 $modelExecutors->insert(array('users_id' => $item, 'projects_id' => $data['id']));
             }
         } else {
             $modelExecutors->setWhere(array('projects_id' => $data['id']));
             $modelExecutors->delete();
         }
         unset($data['executors']);
         $this->update($data, array('id' => $data['id']));
     } else {
         if ($data['id'] == 0) {
             $session = SessionRegistry::instance();
             $data['initiator'] = $session->getCurrentUser()->id;
             $data['date_added'] = date('Y-m-d');
             $data['project_status_id'] = 1;
             $data['id'] = $this->insert($data);
         }
     }
     return $data['id'];
 }
Esempio n. 2
0
 public function endTasksInWork()
 {
     $session = SessionRegistry::instance();
     $user = $session->getCurrentUser();
     $tasksModel = new Tasks();
     $userTasks = $tasksModel->getMyTasks($user);
     foreach ($userTasks as $task) {
         $this->endWork($task['id']);
     }
 }
Esempio n. 3
0
 public function __construct()
 {
     $this->view = new View();
     $this->config = ApplicationRegistry::instance();
     $this->request = RequestRegistry::getRequest();
     $this->session = SessionRegistry::instance();
     $error = $this->request->getProperty('app_error');
     if (is_null($this->session->getCurrentUser()) && $this->request->getProperty('controller') != 'login' && is_null($error)) {
         $this->redirect('/login/');
     } elseif (is_null($this->session->getCurrentUser()) && !is_null($error) && !$error instanceof \App\library\exceptions\LoginException) {
         $this->redirect('/login/');
     }
 }
Esempio n. 4
0
 public function save($data)
 {
     if ($data['id'] > 0) {
         $this->update($data, array('id' => $data['id']));
     } else {
         if ($data['id'] == 0) {
             if (!isset($data['initiator'])) {
                 $session = SessionRegistry::instance();
                 $data['initiator'] = (int) $session->getCurrentUser()->id;
             }
             $data['date_added'] = date('Y-m-d');
             $data['task_status_id'] = 1;
             $data['executors_id'] = isset($data['executors_id']) ? $data['executors_id'] : 0;
             $data['id'] = $this->insert($data);
         }
     }
     return $data['id'];
 }
Esempio n. 5
0
 public function __construct()
 {
     $this->config = ApplicationRegistry::instance();
     $this->request = RequestRegistry::getRequest();
     $this->session = SessionRegistry::instance();
 }