/**
  * Подписант билета
  *
  * @return CPerson
  */
 public function getSigner()
 {
     if (is_null($this->_signer)) {
         $this->_signer = CStaffManager::getPersonById($this->getRecord()->getItemValue("signer_id"));
     }
     return $this->_signer;
 }
 public function actionWizardCompleted()
 {
     $speciality = CTaxonomyManager::getCacheSpecialities()->getItem(CRequest::getInt("speciality_id"));
     $year = CTaxonomyManager::getCacheYears()->getItem(CRequest::getInt("year_id"));
     $protocol = CProtocolManager::getDepProtocol(CRequest::getInt("protocol_id"));
     $signer = CStaffManager::getPersonById(CRequest::getInt("signer_id"));
     $disciplines = new CArrayList();
     foreach (CRequest::getArray("discipline") as $i) {
         $disciplines->add($disciplines->getCount(), CDisciplinesManager::getDiscipline($i));
     }
     // бегаем по циклу столько раз, сколько нам билетов нужно
     for ($i = 1; $i <= CRequest::getInt("count"); $i++) {
         $ticket = CFactory::createSebTicket();
         $ticket->setSpeciality($speciality);
         $ticket->setYear($year);
         $ticket->setProtocol($protocol);
         $ticket->setSigner($signer);
         $ticket->setNumber($i);
         foreach ($disciplines->getItems() as $disc) {
             if ($disc->getQuestions()->getCount() == 0) {
                 break;
             }
             $question = $disc->getQuestions()->getShuffled()->getFirstItem();
             $disc->getQuestions()->removeItem($question->getId());
             $ticket->addQuestion($question);
         }
         $ticket->save();
     }
     $this->redirect("?action=index");
 }
 public function actionView()
 {
     $group = CStaffManager::getStudentGroup(CRequest::getInt("id"));
     $this->addActionsMenuItem(array(array("title" => "Назад", "link" => WEB_ROOT . "_modules/_student_groups/public.php?action=index", "icon" => "actions/edit-undo.png")));
     $this->setData("group", $group);
     $this->renderView("__public/_student_groups/view.tpl");
 }
 public function actionDelete()
 {
     $object = CStaffManager::getPersonPaper(CRequest::getInt("id"));
     $person = $object->kadri_id;
     $object->remove();
     $this->redirect("index.php?action=edit&id=" . $person);
 }
 /**
  * Ресурс
  */
 public function setResourceId()
 {
     $this->getRecord()->setItemValue("resource_id", CRequest::getInt("resource_id"));
     if ($this->getType() == "kadri") {
         $this->_resource = CStaffManager::getPersonById($this->getResourceId());
     }
 }
 public function actionGetViewData()
 {
     $result = array();
     // комиссии по защите дипломов. показываем только комиссии этого года
     foreach (CActiveRecordProvider::getWithCondition(TABLE_SAB_COMMISSIONS, "year_id=" . CUtils::getCurrentYear()->getId())->getItems() as $ar) {
         $comm = new CSABCommission($ar);
         $value = $comm->title;
         if (!is_null($comm->manager)) {
             $value .= " " . $comm->manager->getName();
         }
         if (!is_null($comm->secretar)) {
             $value .= " (" . $comm->secretar->getName() . ")";
         }
         $diplom = CStaffManager::getDiplom(CRequest::getInt("diplom_id"));
         if (!is_null($diplom)) {
             $cnt = 0;
             foreach ($comm->diploms->getItems() as $d) {
                 if (strtotime($diplom->date_act) == strtotime($d->date_act)) {
                     $cnt++;
                 }
             }
             $value .= " " . $cnt;
         }
         $result[$comm->getId()] = $value;
     }
     return $result;
 }
 public function actionSave()
 {
     $quest = new CQuestion();
     $quest->setAttributes(CRequest::getArray($quest::getClassName()));
     if ($quest->validate()) {
         if (!CSession::isAuth()) {
             $user = "";
         } else {
             $user = CStaffManager::getUser(CSession::getCurrentUser()->getId())->getName();
         }
         $quest->contact_info .= " " . $user . '; ip ' . $_SERVER["REMOTE_ADDR"];
         if ($quest->answer_text != '') {
             $quest->datetime_answ = date("Y-d-m H:i:s", time());
         }
         $quest->save();
         if ($this->continueEdit()) {
             $this->redirect("?action=edit&id=" . $quest->getId());
         } else {
             $this->redirect(WEB_ROOT);
         }
         return true;
     }
     $this->setData("quest", $quest);
     $this->renderView("__public/_question_add/edit.tpl");
 }
 public function import(CFormModel $source)
 {
     $data = $source->getData();
     $markIds = array();
     $isFirstRow = true;
     foreach ($data as $row) {
         if ($isFirstRow) {
             // это первая строка - в не идентификаторы оценок
             $isFirstRow = false;
             $markIds = $row;
         } else {
             // это все остальные строки - здесь уже студенты
             $student = CStaffManager::getStudent($row[0]);
             if (!is_null($student)) {
                 $isFirstCol = true;
                 foreach ($row as $id => $cell) {
                     if (!$isFirstCol) {
                         if ($cell != "") {
                             // если не пустая, то берем дисциплину
                             $subjectId = $markIds[$id];
                             $subject = CTaxonomyManager::getDiscipline($subjectId);
                             if (!is_null($subject)) {
                                 // если дисциплина есть, то происходит маппинг оценок
                                 $marks = array("2" => "4", "3" => "3", "4" => "2", "5" => "1");
                                 // создаем запись об оценке
                                 $activity = new CStudentActivity();
                                 $activity->subject_id = $subject->getId();
                                 $activity->kadri_id = $source->person;
                                 $activity->student_id = $student->getId();
                                 $activity->date_act = date("Y-m-d", strtotime($source->created));
                                 if (mb_strlen($cell) == 2 || strlen($cell) == 2) {
                                     // это курсовой
                                     $cell = mb_substr($cell, 0, 1);
                                     $activity->study_act_id = 43;
                                     if (array_key_exists($cell, $marks)) {
                                         $activity->study_mark = $marks[$cell];
                                     }
                                 } elseif (array_key_exists($cell, $marks)) {
                                     // это экзамен
                                     $activity->study_act_id = 1;
                                     $activity->study_mark = $marks[$cell];
                                 } else {
                                     // это зачет
                                     $activity->study_act_id = 2;
                                     $activity->study_mark = 5;
                                 }
                                 $activity->save();
                             }
                         }
                     } else {
                         // пропускаем первую ячейку - в ней идентификатор студента
                         $isFirstCol = false;
                     }
                 }
             }
         }
     }
     return true;
 }
 /**
  * @return CPerson
  */
 public function getUser()
 {
     $users = CStaffManager::getUser($this->user_id);
     if (!is_null($users)) {
         $user = $users->getPerson();
     }
     return $user;
 }
 public function actionEdit()
 {
     $child = CStaffManager::getPersonChild(CRequest::getInt("id"));
     $child->birth_date = date("d.m.Y", strtotime($child->birth_date));
     $this->addJSInclude(JQUERY_UI_JS_PATH);
     $this->addCSSInclude(JQUERY_UI_CSS_PATH);
     $this->setData("child", $child);
     $this->renderView("_staff/child/edit.tpl");
 }
 /**
  * Получить всех студентов учебной группы
  */
 public function actionGetStudentsByGroup()
 {
     $group = CRequest::getInt("group");
     $res = array();
     foreach (CStaffManager::getStudentGroup($group)->getStudents()->getItems() as $student) {
         $res[$student->getId()] = $student->getName();
     }
     echo json_encode($res);
 }
 /**
  * Группа, к которой студент относится
  *
  * @return CStudentGroup
  */
 public function getGroup()
 {
     if (is_null($this->_group)) {
         if (array_key_exists("group_id", $this->getRecord()->getItems())) {
             $this->_group = CStaffManager::getStudentGroup($this->getRecord()->getItemValue("group_id"));
         }
     }
     return $this->_group;
 }
 public function actionManageMembers()
 {
     $group = CStaffManager::getUserGroup(CRequest::getInt("id"));
     $this->addJSInclude("_core/jquery-ui-1.8.20.custom.min.js");
     $this->addCSSInclude("_core/jUI/jquery-ui-1.8.2.custom.css");
     $this->addJSInclude("_core/dialogs/personSelector.js");
     $this->setData("group", $group);
     $this->renderView("_acl_manager/groups/manageMembers.tpl");
 }
Exemple #14
0
 /**
  * @return CPerson
  */
 public function getAuthor()
 {
     if (is_null($this->_author)) {
         $user = CStaffManager::getUser($this->user_id_insert);
         if (!is_null($user)) {
             $this->_author = $user->getPerson();
         }
     }
     return $this->_author;
 }
 /**
  * Получатель
  *
  * @return CPerson|null
  */
 public function getRecipient()
 {
     if (is_null($this->_recipient)) {
         $user = CStaffManager::getUser($this->to_user_id);
         if (!is_null($user)) {
             $this->_recipient = $user->getPerson();
         }
     }
     return $this->_recipient;
 }
 public function actionView()
 {
     $person = CStaffManager::getPerson(CRequest::getInt("id"));
     $year = CRequest::getInt("year");
     /**
      * Формируем меню
      */
     $this->addActionsMenuItem(array(array("title" => "Назад", "link" => "load.php?action=index", "icon" => "actions/edit-undo.png"), array("title" => "Добавить", "link" => "load.php?action=add&id=" . $person->getId() . "&year=" . $year, "icon" => "actions/list-add.png"), array("title" => "Печать по шаблону", "link" => "#", "icon" => "devices/printer.png", "template" => "formset_individual_plan")));
     $this->setData("person", $person);
     $this->renderView("_individual_plan/load/view.tpl");
 }
 public function validate()
 {
     if (!parent::validate()) {
         return parent::validate();
     }
     $user = CStaffManager::getUser($this->credential);
     if (is_null($user)) {
         $this->getValidationErrors()->add("credential", "Пользователя с указанными данными не существует");
         return false;
     }
     return true;
 }
 /**
  * Все студенты группы.
  * Отсортированы по ФИО
  *
  * @return CArrayList
  */
 public function getStudents()
 {
     if (is_null($this->_students)) {
         $this->_students = new CArrayList();
         foreach (CActiveRecordProvider::getWithCondition(TABLE_STUDENTS, "group_id=" . $this->getId(), "fio asc")->getItems() as $item) {
             $student = new CStudent($item);
             $this->_students->add($student->getId(), $student);
             CStaffManager::getCacheStudents()->add($student->getId(), $student);
         }
     }
     return $this->_students;
 }
 /**
  * Объект сотрудника текущего пользователя
  *
  * @static
  * @return CPerson
  */
 public static function getCurrentPerson()
 {
     if (is_null(self::$_person)) {
         if (self::isAuth()) {
             $person = CStaffManager::getPersonById(self::getPersonId());
             if (!is_null($person)) {
                 self::$_person = $person;
             }
         }
     }
     return self::$_person;
 }
 public function actionGetIndividualPlansByYear()
 {
     $person = CStaffManager::getPerson(self::getStatefullBean()->getItem("id"));
     $plans = $person->getIndPlansByYears(CRequest::getInt("year"));
     $types = array();
     foreach ($plans->getItems() as $year => $plan) {
         foreach ($plan->getItems() as $type) {
             $types[$type->getId()] = $type->type;
         }
     }
     echo json_encode($types);
 }
 /**
  * Пользователи, которые ведут дисциплину из этой папки
  *
  * @return CArrayList|null
  */
 public function getUsers()
 {
     if (is_null($this->_users)) {
         $this->_users = new CArrayList();
         foreach (CActiveRecordProvider::getWithCondition(TABLE_LIBRARY_DOCUMENTS, "subj_id = " . $this->getDiscipline()->getId())->getItems() as $ar) {
             $user = CStaffManager::getUser($ar->getItemValue("user_id"));
             if (!is_null($user)) {
                 $this->_users->add($user->getId(), $user);
             }
         }
     }
     return $this->_users;
 }
 public function getYears()
 {
     $person = CStaffManager::getPerson($this->_bean->getItem("id"));
     $plans = $person->getIndPlansByYears();
     $years = array();
     foreach ($plans->getItems() as $year => $plan) {
         $year = CTaxonomyManager::getYear($year);
         if (!is_null($year)) {
             $years[$year->getId()] = $year->getValue();
         }
     }
     return $years;
 }
 public function actionIndex()
 {
     $persons = new CArrayList();
     if (CRequest::getInt("year") == 0) {
         $year = CUtils::getCurrentYear();
     } else {
         $year = CTaxonomyManager::getYear(CRequest::getInt("year"));
     }
     foreach (CStaffManager::getAllPersons()->getItems() as $person) {
         if ($person->getPublications($year)->getCount() > 0) {
             $persons->add($person->id, $person);
         }
     }
     $this->addActionsMenuItem(array(array("title" => "Назад", "link" => "index.php", "icon" => "actions/edit-undo.png")));
     $this->setData("year", $year);
     $this->setData("persons", $persons);
     $this->renderView("_rating_publications/person/index.tpl");
 }
 /**
  * Роли, которые связаны с данной группой
  *
  * @return CArrayList
  */
 public function getRoles()
 {
     if (is_null($this->_roles)) {
         $this->_roles = new CArrayList();
         if (!is_null($this->getId())) {
             foreach (CActiveRecordProvider::getWithCondition(TABLE_USER_GROUP_HAS_ROLES, "user_group_id=" . $this->getId())->getItems() as $ar) {
                 $role = CStaffManager::getUserRole($ar->getItemValue("task_id"));
                 if (!is_null($role)) {
                     $role->level = $ar->getItemValue("task_rights_id");
                     if ($role->level == ACCESS_LEVEL_NO_ACCESS) {
                         $role->level = ACCESS_LEVEL_READ_OWN_ONLY;
                     }
                     $this->_roles->add($role->getId(), $role);
                 }
             }
         }
     }
     return $this->_roles;
 }
 public function import(CFormModel $source)
 {
     $data = $source->getData();
     $isFirstRow = true;
     foreach ($data as $row) {
         if ($isFirstRow) {
             // это первая строка - id студента и рег. номер
             $isFirstRow = false;
         } else {
             // это все остальные строки - здесь уже студенты
             $student = CStaffManager::getStudent($row[0]);
             if (!is_null($student)) {
                 $diplom = CStaffManager::getDiplomByStudent($row[0]);
                 foreach ($row as $id => $cell) {
                     $diplom->student_id = $student->getId();
                     $diplom->diplom_regnum = $row[1];
                     $diplom->diplom_issuedate = date("d/m/Y", strtotime($source->created));
                     $diplom->save();
                 }
             }
         }
     }
     return true;
 }
 public function actionRemoveDiplom()
 {
     $diplom = CStaffManager::getDiplom(CRequest::getInt("diplom_id"));
     if (!is_null($diplom)) {
         $diplom->gak_num = 0;
         $diplom->save();
     }
 }
 public function actionDelete()
 {
     $person = CStaffManager::getPerson(CRequest::getInt("id"));
     $person->remove();
     $this->redirect("?action=index");
 }
 /**
  * Сама обработка студентов
  *
  * @param array $source
  */
 private function processStudent(array $source)
 {
     /**
      * Попробуем искать студента. Искать будем по ФИО
      */
     $fio = $source[1] . " " . $source[2] . " " . $source[3];
     $student = CStaffManager::getStudent($fio);
     /**
      * Если студент был, то хорошо, если не был, то создаем
      * и добавляем в список добавленных
      */
     if (is_null($student)) {
         $student = new CStudent();
         $student->fio = $fio;
         $added = new CArrayList();
         if ($this->getResults()->hasElement("Добавлен")) {
             $added = $this->getResults()->getItem("Добавлен");
         }
         $added->add($student->getName(), $student->getName());
         $this->getResults()->add("Добавлен", $added);
     }
     $updated = new CArrayList();
     if ($this->getResults()->hasElement("Обновлен")) {
         $updated = $this->getResults()->getItem("Обновлен");
     }
     $fields = new CArrayList();
     if ($updated->hasElement($student->getName())) {
         $fields = $updated->getItem($student->getName());
     }
     /**
      * Теперь у нас есть студент. В любом случае есть))
      * Проверяем, может что-то не совпадает
      */
     $needSave = false;
     /**
      * Год окончания школы
      */
     if ($source[4] !== "") {
         if (mb_strtolower($student->year_school_end) !== mb_strtolower($source[4])) {
             $needSave = true;
             $student->year_school_end = $source[4];
             $fields->add("Год окончания предыдущего образовательно учреждения", $source[4]);
         }
     }
     /**
      * Предыдущее образовательное учреждение
      */
     if ($source[5] !== "") {
         if (is_null($student->primaryEducation)) {
             $needSave = true;
             $term = $this->getTerm("primary_education", $source[5]);
             $student->primary_education_type_id = $term->getId();
             $fields->add("Предыдущее образовательно учреждение", $source[5]);
         } elseif (mb_strtolower($student->primaryEducation->getValue()) !== mb_strtolower($source[5])) {
             $needSave = true;
             $term = $this->getTerm("primary_education", $source[5]);
             $student->primary_education_type_id = $term->getId();
             $fields->add("Предыдущее образовательно учреждение", $source[5]);
         }
     }
     /**
      * Год поступления в вуз
      */
     if ($source[6] !== "") {
         if (mb_strtolower($student->year_university_start) !== $source[6]) {
             $needSave = true;
             $student->year_university_start = $source[6];
             $fields->add("Год поступления в ВУЗ", $source[6]);
         }
     }
     /**
      * Форма обучения, на которую поступал
      */
     if ($source[7] !== "") {
         if (is_null($student->secondaryEducationStartType)) {
             $needSave = true;
             $term = $this->getTerm("education_form", $source[7]);
             $student->education_form_start = $term->getId();
             $fields->add("Форма обучения, на которую поступали", $source[7]);
         } elseif (mb_strtolower($student->secondaryEducationStartType->getValue()) !== mb_strtolower($source[7])) {
             $needSave = true;
             $term = $this->getTerm("education_form", $source[7]);
             $student->education_form_start = $term->getId();
             $fields->add("Форма обучения, на которую поступали", $source[7]);
         }
     }
     /**
      * Форма обучения, которую заканчивает
      */
     if ($source[8] !== "") {
         if (is_null($student->secondaryEducationEndType)) {
             $needSave = true;
             $term = $this->getTerm("education_form", $source[8]);
             $student->education_form_end = $term->getId();
             $fields->add("Форма обучения, которую заканчивает", $source[8]);
         } elseif (mb_strtolower($student->secondaryEducationEndType->getValue()) !== mb_strtolower($source[8])) {
             $needSave = true;
             $term = $this->getTerm("education_form", $source[8]);
             $student->education_form_end = $term->getId();
             $fields->add("Форма обучения, которую заканчивает", $source[8]);
         }
     }
     /**
      * Пол
      */
     if ($source[9] !== "") {
         if (is_null($student->gender)) {
             $needSave = true;
             $term = $this->getTerm("gender", $source[9]);
             $student->gender_id = $term->getId();
             $fields->add("Пол", $source[9]);
         } elseif (mb_strtolower($student->gender->getValue()) !== mb_strtolower($source[9])) {
             $needSave = true;
             $term = $this->getTerm("gender", $source[9]);
             $student->gender_id = $term->getId();
             $fields->add("Пол", $source[9]);
         }
     }
     /**
      * Номер телефона
      */
     if ($source[10] !== "") {
         if (mb_strtoupper($student->telephone) !== mb_strtoupper($source[10])) {
             $needSave = true;
             $student->telephone = $source[10];
             $fields->add("Телефон", $source[10]);
         }
     }
     /**
      * Место текущей работы
      */
     if ($source[11] !== "") {
         if (mb_strtoupper($student->work_current) !== mb_strtoupper($source[11])) {
             $needSave = true;
             $student->work_current = $source[11];
             $fields->add("Место текущей работы", $source[11]);
         }
     }
     /**
      * Примечания
      */
     if ($source[12] !== "") {
         if (mb_strtoupper($student->comment) !== mb_strtoupper($source[12])) {
             $needSave = true;
             $student->comment = $source[12];
             $fields->add("Примечание", $source[12]);
         }
     }
     /**
      * Номер группы
      */
     if ($source[13] !== "") {
         $source[13] = str_replace(" ", "-", $source[13]);
         $group = CStaffManager::getStudentGroup($source[13]);
         if (is_null($student->getGroup())) {
             if (!is_null($group)) {
                 $student->group_id = $group->getId();
                 $needSave = true;
                 $fields->add("Группа", $source[13]);
             }
         } elseif (mb_strtoupper($student->getGroup()->getName()) !== mb_strtoupper($source[13])) {
             if (!is_null($group)) {
                 $student->group_id = $group->getId();
                 $needSave = true;
                 $fields->add("Группа", $source[13]);
             }
         }
     }
     /**
      * Место предполагаемой работы
      */
     if ($source[14] !== "") {
         if (mb_strtoupper($student->work_proposed) !== mb_strtoupper($source[14])) {
             $needSave = true;
             $student->work_proposed = $source[14];
             $fields->add("Место предполагаемой работы", $source[14]);
         }
     }
     if ($needSave) {
         $student->save();
     }
     $updated->add($student->getName(), $fields);
     $this->getResults()->add("Обновлен", $updated);
 }
 public function actionGetObject($id)
 {
     return CStaffManager::getStudent($id);
 }
 public function actionDelete()
 {
     $group = CStaffManager::getStudentGroup(CRequest::getInt("id"));
     $group->remove();
     $this->redirect("?action=index");
 }