/** * Учебные группы по году * * @static * @param CTerm $year * @return CArrayList */ public static function getStudentGroupsByYear(CTerm $year) { $groups = new CArrayList(); foreach (CActiveRecordProvider::getWithCondition(TABLE_STUDENT_GROUPS, "year_id=" . $year->getId(), "name asc")->getItems() as $ar) { $group = new CStudentGroup($ar); $groups->add($group->getId(), $group); self::getCacheGroups()->add($group->getId(), $group); } return $groups; }
/** * @param CTerm $year * @param $alias * @return CRate */ public static function getRateByAliasAndYear(CTerm $year, $alias) { if (!self::getCacheRates()->hasElement($year->getId() . "_" . $alias)) { $q = new CQuery(); $q->select("r.*")->from(TABLE_RATES . " as r")->condition("r.year_id = " . $year->getId() . " AND r.alias='" . $alias . "'"); foreach ($q->execute()->getItems() as $ar) { $rate = new CRate(new CActiveRecord($ar)); self::addToCache($rate); } } return self::getCacheRates()->getItem($year->getId() . "_" . $alias); }
protected function getCacheTerms() { if (is_null($this->_cacheTerms)) { $this->_cacheTerms = new CArrayList(); foreach (CActiveRecordProvider::getAllFromTable($this->getTableName())->getItems() as $ar) { $term = new CTerm($ar); $term->taxonomy_id = $this->getId(); $term->setTable($this->getTableName()); $this->_cacheTerms->add($term->getId(), $term); } } return $this->_cacheTerms; }
/** * Билеты по определенной специальности и за определенный год * * @static * @param CTerm $year * @param CTerm $speciality * @return array */ public static function getTicketsByYearAndSpecialityList(CTerm $year, CTerm $speciality) { $q = "speciality_id=" . $speciality->getId() . " AND year_id=" . $year->getId(); if (!self::getCacheTickets()->hasElement($q)) { $arr = array(); foreach (CActiveRecordProvider::getWithCondition(TABLE_SEB_TICKETS, $q)->getItems() as $ar) { $ticket = new CSEBTicket($ar); $arr[$ticket->getId()] = $ticket->getNumber(); self::getCacheTickets()->add($ticket->getId(), $ticket); } self::getCacheTickets()->add($q, $arr); } return self::getCacheTickets()->getItem($q); }
/** * Ищет термин в указанной таксономии. Если не находит - создает * * @param $taxonomy * @param $key * @return CTerm */ private function getTerm($taxonomyName, $key) { if ($taxonomyName == "education_form") { $forms = new CArrayList(); /** * Пересортируем формы обучения в другом порядке, чтобы ключом * было название */ foreach (CTaxonomyManager::getCacheEducationForms()->getItems() as $form) { $forms->add(mb_strtolower($form->getValue()), $form); } if ($forms->hasElement(mb_strtolower($key))) { $term = $forms->getItem(mb_strtolower($key)); } else { $term = new CTerm(); $term->setTable(TABLE_EDUCATION_FORMS); $term->setValue($key); $term->save(); CTaxonomyManager::getCacheEducationForms()->add($term->getId(), $term); } } elseif ($taxonomyName == "gender") { $genders = new CArrayList(); foreach (CTaxonomyManager::getCacheGenders()->getItems() as $gender) { $genders->add(mb_strtoupper($gender->getValue()), $gender); } if ($genders->hasElement(mb_strtoupper($key))) { $term = $genders->getItem(mb_strtoupper($key)); } } else { $taxonomy = CTaxonomyManager::getTaxonomy($taxonomyName); $term = $taxonomy->getTerm($key); if (is_null($term)) { $term = new CTerm(); $term->taxonomy_id = $taxonomy->getId(); $term->setValue($key); $term->save(); $taxonomy->addTerm($term); } } return $term; }
public function actionImport() { $thisYear = new CArrayList(); // импортируем показатели должностей $index = new CRatingIndex(); $index->title = "Должность"; $index->manager_class = "CTaxonomyManager"; $index->manager_method = "getPosts()"; $index->person_method = "getPost()"; $index->year_id = CUtils::getCurrentYear()->getId(); $index->isMultivalue = 0; $index->save(); $thisYear->add($index->getId(), $index); foreach (CActiveRecordProvider::getAllFromTable("spr_dolzhnost")->getItems() as $item) { $post = CTaxonomyManager::getPostById($item->getItemValue("id")); if (!is_null($post)) { $value = new CRatingIndexValue(); $value->index_id = $index->id; $value->fromTaxonomy = 1; $value->title = $post->getId(); $value->value = $item->getItemValue("rate"); $value->save(); } } // показатели размножаем на все года foreach (CTaxonomyManager::getYearsList() as $key => $value) { $year = CTaxonomyManager::getYear($key); if ($year->getId() !== $index->year_id) { $newIndex = new CRatingIndex(); $newIndex->title = $index->title; $newIndex->manager_class = $index->manager_class; $newIndex->manager_method = $index->manager_method; $newIndex->person_method = $index->person_method; $newIndex->year_id = $year->getId(); $newIndex->isMultivalue = $index->isMultivalue; $newIndex->save(); foreach ($index->getIndexValues()->getItems() as $value) { $newValue = new CRatingIndexValue(); $newValue->index_id = $newIndex->getId(); $newValue->fromTaxonomy = $value->fromTaxonomy; $newValue->title = $value->title; $newValue->value = $value->value; $newValue->save(); } } } // звания $index = new CRatingIndex(); $index->title = "Звание"; $index->manager_class = "CTaxonomyManager"; $index->manager_method = "getTitles()"; $index->year_id = CUtils::getCurrentYear()->getId(); $index->isMultivalue = 0; $index->person_method = "getTitle()"; $index->save(); $thisYear->add($index->getId(), $index); foreach (CActiveRecordProvider::getAllFromTable("spr_zvanie")->getItems() as $item) { $post = CTaxonomyManager::getTitle($item->getItemValue("id")); if (!is_null($post)) { $value = new CRatingIndexValue(); $value->index_id = $index->id; $value->fromTaxonomy = 1; $value->title = $post->getId(); $value->value = $item->getItemValue("rate"); $value->save(); } } // показатели размножаем на все года foreach (CTaxonomyManager::getYearsList() as $key => $value) { $year = CTaxonomyManager::getYear($key); if ($year->getId() !== $index->year_id) { $newIndex = new CRatingIndex(); $newIndex->title = $index->title; $newIndex->manager_class = $index->manager_class; $newIndex->manager_method = $index->manager_method; $newIndex->year_id = $year->getId(); $newIndex->isMultivalue = $index->isMultivalue; $newIndex->person_method = $index->person_method; $newIndex->save(); foreach ($index->getIndexValues()->getItems() as $value) { $newValue = new CRatingIndexValue(); $newValue->index_id = $newIndex->getId(); $newValue->fromTaxonomy = $value->fromTaxonomy; $newValue->title = $value->title; $newValue->value = $value->value; $newValue->save(); } } } // научно-методическая работа $taxonomy = new CTaxonomy(); $taxonomy->name = "Виды научно-методической и учебной работы"; $taxonomy->alias = "scientificWork"; $taxonomy->save(); $index = new CRatingIndex(); $index->title = "Научно-методическая и учебная работа"; $index->manager_class = "CTaxonomyManager"; $index->manager_method = 'getTaxonomy("scientificWork")->getTerms()'; $index->year_id = CUtils::getCurrentYear()->getId(); $index->isMultivalue = 1; $index->save(); $thisYear->add($index->getId(), $index); foreach (CActiveRecordProvider::getAllFromTable("spr_nauch_met_uch_rab")->getItems() as $item) { $term = new CTerm(); $term->taxonomy_id = $taxonomy->getId(); $term->name = $item->getItemValue("name"); $term->save(); $value = new CRatingIndexValue(); $value->index_id = $index->id; $value->fromTaxonomy = 1; $value->title = $term->getId(); $value->value = $item->getItemValue("rate"); $value->save(); } // показатели размножаем на все года foreach (CTaxonomyManager::getYearsList() as $key => $value) { $year = CTaxonomyManager::getYear($key); if ($year->getId() !== $index->year_id) { $newIndex = new CRatingIndex(); $newIndex->title = $index->title; $newIndex->manager_class = $index->manager_class; $newIndex->manager_method = $index->manager_method; $newIndex->year_id = $year->getId(); $newIndex->isMultivalue = $index->isMultivalue; $newIndex->save(); foreach ($index->getIndexValues()->getItems() as $value) { $newValue = new CRatingIndexValue(); $newValue->index_id = $newIndex->getId(); $newValue->fromTaxonomy = $value->fromTaxonomy; $newValue->title = $value->title; $newValue->value = $value->value; $newValue->save(); } } } // вычеты $taxonomy = new CTaxonomy(); $taxonomy->name = "Виды вычетов"; $taxonomy->alias = "takeouts"; $taxonomy->save(); $index = new CRatingIndex(); $index->title = "Вычеты"; $index->manager_class = "CTaxonomyManager"; $index->manager_method = 'getTaxonomy("takeouts")->getTerms()'; $index->year_id = CUtils::getCurrentYear()->getId(); $index->isMultivalue = 1; $index->save(); $thisYear->add($index->getId(), $index); foreach (CActiveRecordProvider::getAllFromTable("spr_vichet")->getItems() as $item) { $term = new CTerm(); $term->taxonomy_id = $taxonomy->getId(); $term->name = $item->getItemValue("name"); $term->save(); $value = new CRatingIndexValue(); $value->index_id = $index->id; $value->fromTaxonomy = 1; $value->title = $term->getId(); $value->value = $item->getItemValue("rate"); $value->save(); } // показатели размножаем на все года foreach (CTaxonomyManager::getYearsList() as $key => $value) { $year = CTaxonomyManager::getYear($key); if ($year->getId() !== $index->year_id) { $newIndex = new CRatingIndex(); $newIndex->title = $index->title; $newIndex->manager_class = $index->manager_class; $newIndex->manager_method = $index->manager_method; $newIndex->year_id = $year->getId(); $newIndex->isMultivalue = $index->isMultivalue; $newIndex->save(); foreach ($index->getIndexValues()->getItems() as $value) { $newValue = new CRatingIndexValue(); $newValue->index_id = $newIndex->getId(); $newValue->fromTaxonomy = $value->fromTaxonomy; $newValue->title = $value->title; $newValue->value = $value->value; $newValue->save(); } } } }
/** * Список вопросов по дисциплине * * @static * @param CTerm $discipline * @return CArrayList */ public static function getQuestionsByDiscipline(CTerm $discipline) { $arr = new CArrayList(); foreach (CActiveRecordProvider::getWithCondition(TABLE_SEB_QUESTIONS, "discipline_id=" . $discipline->getId())->getItems() as $i) { $q = new CSEBQuestion($i); $arr->add($q->getId(), $q); self::getCacheQuestions()->add($q->getId(), $q); } return $arr; }
/** * @param CTerm $year * @return CArrayList */ public function getSABOrdersByYear(CTerm $year) { $result = new CArrayList(); foreach ($this->ordersSAB->getItems() as $order) { if ($year->getId() == $order->year_id) { $result->add($order->getId(), $order); } } return $result; }
/** * Специальность * * @param CTerm $value */ public function setSpeciality(CTerm $value) { $this->_speciality = $value; $this->getRecord()->setItemValue("speciality_id", $value->getId()); }
/** * @param CTerm $value */ public function setYear(CTerm $value) { $this->_year = $value; $this->getRecord()->setItemValue("year_id", $value->getId()); }
/** * Все показатели в указанном году * * @static * @param CTerm $year * @return CArrayList */ public static function getRatingIndexesByYear(CTerm $year) { $res = new CArrayList(); foreach (self::getAllRatingIndexes()->getItems() as $item) { if ($item->year_id == $year->getId()) { $res->add($item->getId(), $item); } } return $res; }
public function setMark(CTerm $mark) { $this->_mark = $mark; $this->getRecord()->setItemValue("mark_id", $mark->getId()); }
/** * Полная инициализация всех словарей таксономии * * @static */ public static function fullInit() { if (!self::$_fullInit) { foreach (self::getCacheTaxonomy()->getItems() as $item) { $item->initTerms(); } foreach (CActiveRecordProvider::getAllFromTable(TABLE_TAXONOMY_TERMS)->getItems() as $item) { $term = new CTerm($item); $taxonomy = $term->getParentTaxonomy(); $taxonomy->addTerm($term); } self::getCachePosts(); self::getCacheTypes(); self::getCacheDisciplines(); } }
public function actionImportTerms() { $arr = CRequest::getArray(CTaxonomy::getClassName()); $taxonomy = CTaxonomyManager::getTaxonomy($arr["id"]); $terms = $arr["terms"]; $terms = explode("\n", $terms); foreach ($terms as $t) { if (trim($t) != "") { $term = new CTerm(); $term->setTaxonomy($taxonomy); $term->setValue($t); $term->save(); } } $this->redirect("index.php?action=index&id=" . $taxonomy->getId()); }