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 trainingsAction()
 {
     $personId = $this->_getParam('personid');
     $cards = new Rp_Db_Table_Ach_Cards();
     $card = $cards->findByPersonIdAndPeriod($personId, date('Y'));
     $months = new Rp_Db_Table_Months();
     $respons = new Rp_Db_Table_Ach_Trainings_Respons();
     $groupsMethods = new Rp_Db_Table_Ach_Trainings_GroupsMethods();
     $view = $this->initView();
     $view->trainings = $card->fetchTrainings();
     $view->months = $months->fetchNames();
     $view->respons = $respons->fetchNames();
     $view->groupsMethods = $groupsMethods->toArrayNames();
 }