/**
  * Вставляет новую строку в таблицу целей проф. развития.
  * При отсутствии в массиве данных значения идентификатора 
  * руководителя метод в качестве этого значения устанавливает 
  * значение идентификатора физ. лица пользователя.
  *
  * @param array $data Массив пар "поле => значение".
  * 
  * @return mixed Значение первичного ключа вставленной строки.
  */
 public function insert(array $data)
 {
     if (empty($data['manager_id'])) {
         $data['manager_id'] = Rp_User::getInstance()->getPersonId();
     }
     return parent::insert($data);
 }
Пример #2
0
 /**
  * Обновляет строки таблицы бизнес-целей.
  * При отсутствии в массиве данных значения идентификатора 
  * руководителя метод в качестве этого значения устанавливает 
  * значение идентификатора физ. лица пользователя 
  * (для несогласованных строк).
  *
  * @param array        $data  Массив пар "поле => значение".
  * 
  * @param array|string $where Условие отбора строк.
  * Если $where является числом, то будет обновлена строка, 
  * значение первичного ключа которой равно $where.
  * 
  * @return int Количество обновленных строк.
  */
 public function update(array $data, $where)
 {
     if (empty($data['manager_id']) && !is_numeric($data['status'])) {
         $data['manager_id'] = Rp_User::getInstance()->getPersonId();
     }
     return parent::update($data, $where);
 }
 public function indexAction()
 {
     $request = $this->getRequest();
     $cards = new Rp_Db_Table_Ach_Cards();
     $id = $request->getParam('id', null);
     if ($id !== null) {
         $card = $cards->find($id)->current();
         if (empty($card)) {
             throw new Exception('Карточка достижений с указанным идентификатором не найдена.');
         }
     } else {
         $personId = $request->getParam('personid', null);
         $period = $request->getParam('period', date('Y'));
         $card = $cards->findByPersonIdAndPeriod($personId, $period);
     }
     $user = Rp_User::getInstance();
     $emp = $card->getEmployee();
     $person = $emp->getPerson();
     $periods = range(2006, date('Y') + 1);
     $periods = array_combine($periods, $periods);
     $statuses = new Rp_Db_Table_Ach_Cards_Statuses();
     $status = $statuses->find($card->status_id)->current();
     $months = new Rp_Db_Table_Months();
     $ratings = new Rp_Db_Table_Ach_Ratings();
     $trainsGroupsMethods = new Rp_Db_Table_Ach_Trainings_GroupsMethods();
     $trainsRespons = new Rp_Db_Table_Ach_Trainings_Respons();
     $careerFlags = new Rp_Db_Table_Ach_Cards_CareerFlags();
     $view = $this->initView();
     $view->title = Rp::getTitle(array($person->fullname, "Карточка достижений {$card->period}"));
     $view->emp = $emp;
     $view->person = $person;
     $view->user = $user;
     $view->userRole = $this->_getUserRole($card, $user);
     $view->card = $card;
     $view->periods = $periods;
     $view->status = $status;
     $view->tasks = $card->fetchTasks();
     $view->personalTasks = $card->fetchPersonalTasks();
     $view->competences = $card->fetchCompetences();
     $view->personalCompetences = $card->fetchPersonalCompetences();
     $view->trainings = $card->fetchTrainings();
     $view->personalTrainings = $card->fetchPersonalTrainings();
     $view->approvals = new Achievs_ApprovalsModel($card);
     $view->months = $months->fetchNames();
     $view->ratings = $ratings->fetchNames();
     $view->rate_weights = $ratings->fetchWeights();
     $view->rate_name_weights = $ratings->fetchNameWeights();
     $view->trainsGroupsMethods = $trainsGroupsMethods->toArrayNames();
     $view->trainsGroupsMethodsActual = $trainsGroupsMethods->toArrayNamesWithoutDisabled();
     $view->trainsRespons = $trainsRespons->fetchNames();
     $view->careerFlags = $careerFlags->fetchNames();
     $view->count_func = count($emp->getFuncManagers()->getCol('person_id'));
     $view->emails = $this->_getEmails($card, $user);
     $view->tab = isset($_SESSION['tab']) ? $_SESSION['tab'] : 'tasks';
 }
 public function userAction()
 {
     $user = Rp_User::getInstance();
     $userData = array('personId' => $user->getPersonId(), 'fullname' => $user->getPerson()->fullname, 'subposts' => array(), 'viewposts' => array());
     if ($user->isCurrent()) {
         $treePost = $user->getTreePost();
         $userData['subposts'] = $treePost->findChildPosts(true)->toArray();
         $userData['viewposts'] = $treePost->findViewedPosts(true)->toArray();
     }
     $view = $this->initView();
     $view->user = Zend_Json_Encoder::encode($userData);
 }
 public function indexAction()
 {
     $request = $this->getRequest();
     $authtype = Rp_Auth_Adapter_DbTable::AUTH_TRANSPARENT;
     $username = basename($request->getServer('AUTH_USER', NULL));
     $password = '';
     if ($_POST or isset($_GET['force_auth'])) {
         $authtype = Rp_Auth_Adapter_DbTable::AUTH_FORM;
         $username = $request->getPost('username', NULL);
         $password = $request->getPost('password', NULL);
     }
     $message = '';
     if ($username) {
         try {
             $auth = Zend_Auth::getInstance();
             $adapter = new Rp_Auth_Adapter_DbTable($username, $password, $authtype);
             $result = $auth->authenticate($adapter);
             if ($result->isValid()) {
                 $row = $adapter->getResultRowObject('id');
                 Rp_User::setInstance($row->id);
                 $user = Rp_User::getInstance();
                 $appointments = new Rp_Db_View_Appointments();
                 $log = new Rp_Db_Table_Logon();
                 if (!isset($_SESSION['user_id'])) {
                     $logon = array();
                     $logon['session_id'] = session_id();
                     $logon['user_id'] = $user->getPerson()->id;
                     $logon['userfullname'] = $user->getPerson()->fullname;
                     $logon['userpost'] = current($appointments->fetchNames($user->getEmployee()->appointment_id));
                     $logon['date_logon'] = date("m.d.y H:i:s");
                     $logon['ip'] = $_SERVER['REMOTE_ADDR'];
                     $logon['version'] = $_SERVER['HTTP_USER_AGENT'];
                     $log->insert($logon);
                     $_SESSION['user_id'] = $user->getPerson()->id;
                 }
                 $this->_forward('index', 'index');
                 return;
             } elseif ($result->getCode() != Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) {
                 $message = implode("\n", $result->getMessages());
             } elseif ($authtype == Rp_Auth_Adapter_DbTable::AUTH_FORM) {
                 $message = 'ѕользователь с указанным сочетанием логин/пароль не найден.';
             }
         } catch (Exception $e) {
             $message = $e->getMessage();
         }
     }
     $view = $this->initView();
     $view->title = Rp::getTitle('јвторизаци¤');
     $view->message = $message;
 }
 public function integratedBlock()
 {
     $xhtml = array();
     $user = Rp_User::getInstance();
     $user_id = $user->getPersonId();
     $companies = new Rp_Db_View_Companies();
     $departments = new Rp_Db_View_Departments();
     $employees = new Rp_Db_View_Employees();
     $appointments = new Rp_Db_View_Appointments();
     $integrated = new Rp_Db_View_IntegratedPersons();
     $integrate_note = "";
     $kol = 0;
     $xhtml[] = "<div class='caption_int'>Совмещенные должности</div>\r\n\r\n\t\t\t\t\t\t\t<table class='integrate_table'>\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<td width='30px' align='center'><b>№</b></td>\r\n\t\t\t\t\t\t\t\t\t<td align='center'><b>Компания</b></td>\r\n\t\t\t\t\t\t\t\t\t<td align='center'><b>Полный путь</b></td>\r\n\t\t\t\t\t\t\t\t\t<td align='center'><b>Должность</b></td>\r\n\t\t\t\t\t\t\t\t</tr>";
     //		if ($user_id < 90000000)
     switch ($user->persg) {
         case 2:
         case 3:
         case 7:
         case 8:
         case 'S':
             $person_id = $integrated->fetchPersonID($user_id);
             $refer_id = $integrated->fetchRefID($person_id[0]);
             $employee = $employees->findByPersonId($person_id[0])->current();
             $company = current($companies->fetchNames($employee->company_id));
             $department = current($departments->fetchNames($employee->department_id));
             $appointment = current($appointments->fetchNames($employee->appointment_id));
             $full_path = $employee->getPerson()->FullPath;
             $integrate_note = "<div class='integrate_note'>* основное место работы</div>";
             $xhtml[] = "<tr style='color: blue;'>\r\n\t\t\t\t\t\t\t\t\t<td align='center'>" . ++$kol . "*</td>\r\n\t\t\t\t\t\t\t\t\t<td><a href='#' style='color: blue;' onclick='forwardIntegratePerson(" . $person_id[0] . ")'>" . $company . "</a></td>\r\n\t\t\t\t\t\t\t\t\t<td><a href='#' style='color: blue;' onclick='forwardIntegratePerson(" . $person_id[0] . ")'>" . $full_path . "</a></td>\r\n\t\t\t\t\t\t\t\t\t<td><a href='#' style='color: blue;' onclick='forwardIntegratePerson(" . $person_id[0] . ")'>" . $appointment . "</a></td>\r\n\t\t\t\t\t\t\t</tr>";
             break;
         default:
             $refer_id = $integrated->fetchRefID($user_id);
             break;
     }
     foreach ($refer_id as $item) {
         if ($user_id == $item) {
             continue;
         } else {
             $employee = $employees->findByPersonId($item)->current();
             $company = current($companies->fetchNames($employee->company_id));
             $department = current($departments->fetchNames($employee->department_id));
             $appointment = current($appointments->fetchNames($employee->appointment_id));
             $full_path = $employee->getPerson()->FullPath;
             $xhtml[] = "<tr>\r\n\t\t\t\t\t\t\t\t<td align='center'>" . ++$kol . "</td>\r\n\t\t\t\t\t\t\t\t<td><a  style='color: black;' href='#' onclick='forwardIntegratePerson(" . $item . ")'>" . $company . "</a></td>\r\n\t\t\t\t\t\t\t\t<td><a  style='color: black;' href='#' onclick='forwardIntegratePerson(" . $item . ")'>" . $full_path . "</a></td>\r\n\t\t\t\t\t\t\t\t<td><a  style='color: black;' href='#' onclick='forwardIntegratePerson(" . $item . ")'>" . $appointment . "</a></td>\r\n\t\t\t\t\t\t\t</tr>";
         }
     }
     $xhtml[] = "</table>" . $integrate_note . "<br><br>";
     return implode($xhtml);
 }
 public function saveAction()
 {
     $request = $this->getRequest();
     $training = $request->getPost('training');
     $notes = $request->getPost('notes', array());
     $newNote = $request->getPost('newNote');
     $tableNotes = new Rp_Db_Table_Ach_Trainings_Notes();
     foreach ($notes as $id => $note) {
         $tableNotes->update($note, $id);
     }
     if (trim($newNote['text']) != '') {
         $newNote['training_id'] = $training['id'];
         $newNote['author_id'] = Rp_User::getInstance()->person_id;
         $tableNotes->insert($newNote);
     }
     $this->_redirect('/card/achievs-training-notes/index/trainId/' . $training['id']);
 }
 public function menuAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id', null);
     if ($id == 'people' or $id == 'subpeople' or $id == 'funcpeople') {
         $user = Rp_User::getInstance();
         // получаем объект пользовател¤
         $treePost = $user->getEmployee()->getTreePost();
         // получаем должность сотрудника в дереве должностей
         // если мы нажали на просмотр непосредственных подчиненных, то получаем id непоср. подчиненных,  в противном случае ищем id подчиненных подчиненных
         $postIds = ($id == 'people' or $id == 'funcpeople') ? $treePost->id : $treePost->findChildPosts()->getCol('id');
         $func = $id == 'funcpeople' ? TRUE : FALSE;
         $params = array('postIds' => $postIds, 'showEmps' => FALSE, 'showSubEmps' => TRUE, 'func' => $func);
         $this->_forward('index', 'employees', null, $params);
         return;
     }
     $this->_forward('index', 'empty');
 }
 public function indexAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id', null);
     Rp_User::setInstance($id);
     $user = Rp_User::getInstance();
     $employees = new Rp_Db_View_Employees();
     $employee_first = $employees->findByPersonId($_SESSION['user_id'])->current();
     $person_first = $employee_first->getPerson();
     $employee = $employees->findByPersonId($id)->current();
     $person = $employee->getPerson();
     if ($person_first->fullname != $person->fullname) {
         $this->_forward('error', 'error');
         return;
     }
     $this->_forward('index', 'index');
     return;
 }
 public function saveAction()
 {
     $request = $this->getRequest();
     $task = $request->getPost('task');
     $is_personal = $request->getPost('is_personal');
     $notes = $request->getPost('notes', array());
     $newNote = $request->getPost('newNote');
     $tableNotes = new Rp_Db_Table_Ach_Tasks_Notes();
     foreach ($notes as $id => $note) {
         $tableNotes->update($note, $id);
     }
     if (trim($newNote['text']) != '') {
         $newNote['task_id'] = $task['id'];
         $newNote['author_id'] = Rp_User::getInstance()->person_id;
         $newNote['is_personal'] = $is_personal;
         $tableNotes->insert($newNote);
     }
     $this->_redirect('/card/achievs-task-notes/index/taskid/' . $task['id'] . '/is_personal/' . $is_personal);
 }
 public function indexAction()
 {
     $personId = $this->_getParam('personid');
     $cards = new Rp_Db_Table_Ach_Cards();
     $card = $cards->findByPersonIdAndPeriod($personId, date('Y'));
     $employee = $card->getEmployee();
     $user = Rp_User::getInstance();
     $managersIds = $employee->getManagers()->getCol('person_id');
     $func_managersIds = $employee->getFuncManagers()->getCol('person_id');
     $count_func = count($employee->getFuncManagers()->getCol('person_id'));
     $columnNotes = '';
     if (in_array($user->person_id, $managersIds)) {
         $columnNotes = 'MNG';
     }
     if (in_array($user->person_id, $func_managersIds)) {
         $columnNotes = 'FUNC';
     }
     $view = $this->initView();
     $view->person = $employee->getPerson();
     $view->tasks = $card->fetchTasks();
     $view->trainings = $card->fetchTrainings();
     $view->columnNotes = $columnNotes;
     $view->count_func = $count_func;
 }
 public function indexAction()
 {
     $user = Rp_User::getInstance();
     $view = $this->initView();
     $view->title = Rp::getTitle('Справка');
 }
Пример #13
0
 /**
  * Возвращает объект сотрудника.
  *
  * @return Rp_Db_View_Row_Employee
  * @throws Exception
  */
 public function getEmployee()
 {
     if (empty(self::$_employee)) {
         $employees = new Rp_Db_View_Employees();
         $employee = $employees->findByPersonId($this->_personId)->current();
         if (empty($employee)) {
             throw new Exception('Объект сотрудника не установлен.');
         }
         self::$_employee = $employee;
     }
     return self::$_employee;
 }