Example #1
0
 private function needSetPassword(Application $app, Database $db, \DBMappers\EmpItem $empMapper)
 {
     if ($app->isAuthorized()) {
         $empItem = $empMapper->getById($app->getEmpId(), $db);
         if ($empItem->isPasswordEqual(null) && $this->controllerName != EMPLOYEE_CONTROLLER && $this->controllerName != LOGIN_CONTROLLER) {
             $app->setStateRedirect(EMPLOYEE_URL . '/edit/' . $empItem->getId());
             return true;
         }
     }
     return false;
 }
Example #2
0
 public static function MakeCrossingMessage(array $crossings, \DBMappers\EmpItem $empMapper, \Core\Database $db)
 {
     $message = 'Can\'t add appointment, it crosses existing appointments: ';
     foreach ($crossings as $cross) {
         $empItem = $empMapper->getById($cross->getEmpId(), $db);
         $message .= $empItem->getName();
         $message .= ' ' . $cross->getTimeStart()->format('M-j-Y H:i');
         $message .= '-' . $cross->getTimeEnd()->format('H:i') . ';';
     }
     return $message;
 }
Example #3
0
 public function act($urlParameters, \Core\Http $http, \Core\Application $app, \Core\Database $db, \DBMappers\EmpItem $empItemMapper)
 {
     if ($app->isAuthorized()) {
         $empItem = $empItemMapper->getById($app->getEmpId(), $db);
         if ($empItem->isPasswordEqual(null)) {
             $app->setStateRedirect(EMPLOYEE_URL . '/edit/' . $empItem->getId());
         } else {
             $app->setStateRedirect(BROWSE_URL);
         }
     } else {
         $app->setStateRedirect(LOGIN_URL);
     }
 }
Example #4
0
 public function render(array $appData, $templateName, \Core\Database $db, \Core\Registry $registry, \DBMappers\EmpItem $empMapper)
 {
     $emp_list = $empMapper->getAll($db);
     $item_list = array();
     $site_root = $registry->get(REG_SITE_ROOT);
     foreach ($emp_list as $emp) {
         $item = array();
         $item['emp'] = $emp;
         $item['remove_link'] = $site_root . EMPLOYEE_URL . '/remove/' . $emp->getId();
         $item['edit_link'] = $site_root . EMPLOYEE_URL . '/edit/' . $emp->getId();
         $item_list[] = $item;
     }
     return (new \Utility\Template())->parse($templateName, array('item_list' => $item_list, 'emp_msg' => isset($appData['emp_msg']) ? $appData['emp_msg'] : '', 'emp_add_link' => $site_root . EMPLOYEE_URL . '/add'));
 }
Example #5
0
 public function render(array $appData, $templateName, \Core\Application $app, \Core\Database $db, \DBMappers\RoomItem $roomMapper, \DBMappers\EmpItem $empMapper)
 {
     $current_room = $app->getCurrentRoom();
     if ($current_room === false) {
         $rooms = $roomMapper->getAll($db);
         $app->setCurrentRoom($rooms[0]->getId());
         $current_room = $app->getCurrentRoom();
     }
     $roomItem = $roomMapper->getById($current_room, $db);
     $emps = $empMapper->getAll($db);
     if (isset($appData['book_crossings'])) {
         $message = 'Can\'t add appointment, it crosses existing appointments: ';
         foreach ($appData['book_crossings'] as $cross) {
             $empItem = $empMapper->getById($cross->getEmpId(), $db);
             $message .= $empItem->getName();
             $message .= ' ' . $cross->getTimeStart()->format('M-j-Y H:i');
             $message .= '-' . $cross->getTimeEnd()->format('H:i') . ';';
         }
     }
     return (new \Utility\Template())->parse($templateName, array('book_hour_mode' => $app->getHourMode(), 'book_room_name' => $roomItem->getRoomName(), 'book_emps' => $emps, 'book_values' => isset($appData['book_values']) ? $appData['book_values'] : null, 'book_errors' => isset($appData['book_errors']) ? $appData['book_errors'] : null));
 }
Example #6
0
 public function act($urlParameters, \Core\Http $http, \Core\Application $app, \Core\Database $db, \DBMappers\EmpItem $empMapper)
 {
     $app->reopenSession();
     if (isset($http->post()['login'])) {
         $loginValue = $http->post()['login'];
         //error_log("\nPOST:" . print_r($http->post(), true), 3, 'my_errors.txt');
         $empItem = $empMapper->getByLogin($loginValue, $db);
         if (!$empItem) {
             $this->setWrongLoginState($app, $loginValue);
             return;
         }
         if (!$empItem->isPasswordEqual($http->post()['password'])) {
             $this->setWrongLoginState($app, $loginValue);
             return;
         }
         $app->setAuthorized($empItem->getId(), $empItem->isAdmin(), $empItem->getFirstDay(), $empItem->getHourMode());
         $app->setStateRedirect(BROWSE_URL);
     } else {
         $app->setStateLogin(array());
     }
 }
Example #7
0
 public function render(array $appData, $templateName, \Core\Registry $registry, \Core\Database $db, \DBMappers\EmpItem $empMapper)
 {
     $emps = $empMapper->getAll($db);
     return (new \Utility\Template())->parse($templateName, array('details_errors' => $appData['details_errors'], 'details_values' => $appData['details_values'], 'is_chain' => $appData['is_chain'], 'details_emps' => $emps, 'can_modify' => $appData['can_modify'], 'site_root' => $registry->get(REG_SITE_ROOT), 'appointment_id' => $appData['details_appointment']->getId()));
 }
Example #8
0
 public function remove($urlParameters, \Core\Http $http, \Core\Application $app, \Core\Database $db, \DBMappers\EmpItem $empMapper)
 {
     if (!$app->isAdmin() || $http->getRequestMethod() != 'POST') {
         $app->setMessage('You cannot manage employees.');
         $app->setStateRedirect(BROWSE_URL);
     } else {
         if (isset($urlParameters[0])) {
             $empItem = $empMapper->getById($urlParameters[0], $db);
             $empMapper->remove($empItem->getId(), $db);
             $app->setMessage('Employee ' . $empItem->getName() . ' removed successfully.');
             $app->setStateRedirect(EMPLOYEE_LIST_URL);
         } else {
             $app->setMessage('Employee id not set');
             $app->setStateRedirect(EMPLOYEE_LIST_URL);
         }
     }
 }