public function actionAdd() { $object = new CDashboardItem(); $object->group_id = CRequest::getInt("id"); $this->setData("object", $object); /** * Соберем необходимые иконки */ $icons = new CArrayList(); $iconSources = new CArrayList(); $dirs = array("actions", "apps", "categories", "devices", "emblems", "emotes", "mimetypes", "places", "status"); foreach ($dirs as $dir) { if ($h = opendir(CORE_CWD . "/images/tango/16x16/" . $dir . "/")) { while ($file = readdir($h)) { if (strpos($file, ".png")) { $iconSources->add($dir . "/" . $file, $dir . "/" . $file); } } closedir($h); } } /** * Теперь исключаем те, которых нет в фаензе */ foreach ($dirs as $dir) { if (file_exists(CORE_CWD . "/images/tango/64x64/" . $dir)) { if ($h = opendir(CORE_CWD . "/images/tango/64x64/" . $dir . "/")) { while ($file = readdir($h)) { if ($iconSources->hasElement($dir . "/" . $file)) { $icons->add($dir . "/" . $file, $dir . "/" . $file); } } closedir($h); } } } /** * Доступные родительские элементы */ $parents = new CArrayList(); foreach (CActiveRecordProvider::getWithCondition(TABLE_DASHBOARD, "group_id = " . CRequest::getInt("id") . " and parent_id = 0")->getItems() as $ar) { $item = new CDashboardItem($ar); $parents->add($item->getId(), $item->title); foreach ($item->children->getItems() as $child) { $parents->add($child->getId(), " - " . $child->title); } } $this->setData("parents", $parents); /** * Генерация меню */ $this->addActionsMenuItem(array("title" => "Назад", "link" => "groupdashboard.php?action=index", "icon" => "actions/edit-undo.png")); /** * Отображение представления */ $this->setData("icons", $icons); $this->renderView("_users/groupdashboard/add.tpl"); }
/** * Ищет термин в указанной таксономии. Если не находит - создает * * @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; }
/** * @param $restrict * @return CArrayList */ public function getIndPlansByYears($restrict = 0) { $result = new CArrayList(); foreach ($this->loads->getItems() as $load) { $year = new CArrayList(); if ($result->hasElement($load->year_id)) { $year = $result->getItem($load->year_id); } $year->add($load->getId(), $load); $result->add($load->year_id, $year); } /** * Если есть ограничение, то все, которые под него не попадают * исключаем из результатов */ if ($restrict > 0) { foreach ($result->getItems() as $year => $load) { if ($year != $restrict) { $result->removeItem($year); } } } return $result; }
/** * Все лабораторные работы, сгруппированные по семестрам * * @return CArrayList */ public function getLabWorks() { $labs = new CArrayList(); /** * @var $module CWorkPlanContentModule * @var $section CWorkPlanContentSection * @var $load CWorkPlanContentSectionLoad * @var $topic CWorkPlanContentSectionLoadTopic */ $loads = new CArrayList(); foreach ($this->modules->getItems() as $module) { foreach ($module->sections->getItems() as $section) { foreach ($section->loads->getItems() as $load) { if ($load->loadType->getAlias() == "labwork") { if ($load->topics->getCount() > 0) { $loads->add($load->getId(), $load); } } } } } foreach ($loads as $load) { $term_id = $load->term_id; $termData = new CArrayList(); if ($labs->hasElement($term_id)) { $termData = $labs->getItem($term_id); } foreach ($load->topics->getItems() as $topic) { $termData->add($topic->getId(), $topic); } $labs->add($term_id, $termData); } return $labs; }
public function actionGetDataForChart() { $data = array(); if (array_key_exists("data", $_POST)) { $data = $_POST["data"]; } // определяем, в каких годах искать $years = new CArrayList(); if (array_key_exists("years", $data)) { foreach ($data['years'] as $item) { $year = CTaxonomyManager::getYear($item); if (!is_null($year)) { $years->add($year->getId(), $year); } } } else { $years->add(CUtils::getCurrentYear()->getId(), CUtils::getCurrentYear()); } // по каким показателям показывать $indexes = new CArrayList(); if (array_key_exists("indexes", $data)) { foreach ($data["indexes"] as $item) { foreach (CRatingManager::getRatingIndexesByName($item)->getItems() as $index) { if ($years->hasElement($index->year_id)) { $indexes->add($index->getId(), $index); } } } } else { foreach ($years->getItems() as $year) { foreach (CRatingManager::getRatingIndexesByYear($year)->getItems() as $index) { $indexes->add($index->getId(), $index); } } } // по каким людям показывать $persons = new CArrayList(); if (array_key_exists("persons", $data)) { foreach ($data["persons"] as $item) { $person = CStaffManager::getPerson($item); if (!is_null($person)) { $persons->add($person->getId(), $person); } } } else { // показывать по всем, у кого показатели есть в указанных годах foreach (CStaffManager::getAllPersons()->getItems() as $person) { foreach ($years->getItems() as $year) { foreach ($person->getRatingIndexesByYear($year)->getItems() as $index) { if ($indexes->hasElement($index->getId())) { $persons->add($person->getId(), $person); } } } } } $res = array(); // начинаем собирать инфу по людям // подписи к осям $axis = array(); $i = 0; foreach ($persons->getItems() as $person) { $i++; $axis[] = $person->getName(); //$axis[] = $i; } // все показатели, которые есть у выбранных людей (id всех показателей) // за все годы $resIndexes = array(); foreach ($persons->getItems() as $person) { foreach ($years->getItems() as $year) { foreach ($person->getRatingIndexesByYear($year)->getItems() as $index) { if ($indexes->hasElement($index->getId())) { $resIndexes[$index->title] = $index->title; } } } } $indicators = array(); // данные по годам // данные должны возвращаться в том же порядке, в котором у нас идут люди foreach ($resIndexes as $key => $value) { foreach ($years->getItems() as $year) { $data = array(); // собираем данные по каждому человеку foreach ($persons->getItems() as $person) { $indexValue = 0; foreach ($person->getRatingIndexesByYear($year)->getItems() as $index) { if ($index->title == $key) { $indexValue = $index->getIndexValue(); } } $data[] = $indexValue; } $indicator = array("name" => $value . " (" . $year->name . ")", "data" => $data, "stack" => $year->name); $indicators[] = $indicator; } } $res["axis"] = $axis; $res["series"] = $indicators; echo json_encode($res); }
public function actionEdit() { $parents = new CArrayList(); foreach (CActiveRecordProvider::getWithCondition(TABLE_DASHBOARD, "user_id = " . CSession::getCurrentUser()->getId() . " and parent_id = 0")->getItems() as $ar) { $item = new CDashboardItem($ar); $parents->add($item->getId(), $item->title); foreach ($item->children->getItems() as $child) { $parents->add($child->getId(), " - " . $child->title); } } $icons = new CArrayList(); $iconSources = new CArrayList(); $dirs = array("actions", "apps", "categories", "devices", "emblems", "emotes", "mimetypes", "places", "status"); foreach ($dirs as $dir) { if ($h = opendir(CORE_CWD . "/images/tango/16x16/" . $dir . "/")) { while ($file = readdir($h)) { if (strpos($file, ".png")) { $iconSources->add($dir . "/" . $file, $dir . "/" . $file); } } closedir($h); } } /** * Теперь исключаем те, которых нет в фаензе */ foreach ($dirs as $dir) { if (file_exists(CORE_CWD . "/images/tango/64x64/" . $dir)) { if ($h = opendir(CORE_CWD . "/images/tango/64x64/" . $dir . "/")) { while ($file = readdir($h)) { if ($iconSources->hasElement($dir . "/" . $file)) { $icons->add($dir . "/" . $file, $dir . "/" . $file); } } closedir($h); } } } $item = CDashboardManager::getDashboardItem(CRequest::getInt("id")); $this->addJSInclude("_core/jDropdown/jquery.dd.js"); $this->addCSSInclude("_core/jDropdown/dd.css"); $this->setData("icons", $icons); $this->setData("parents", $parents); $this->setData("item", $item); $this->renderView("_dashboard/edit.tpl"); }