public function actionWizardCompleted() { $sign_date = CRequest::getString("sign_date"); $chairman = CStaffManager::getPersonById(CRequest::getInt("chairman_id")); $master = CStaffManager::getPersonById(CRequest::getInt("master_id")); $members = new CArrayList(); foreach (CRequest::getArray("members") as $m) { $member = CStaffManager::getPersonById($m); $members->add($member->getId(), $member); } CProtocolManager::getAllSebProtocols(); // на студента по протоколу foreach (CRequest::getArray("student") as $key => $value) { $student = CStaffManager::getStudent($key); $ticket = CSEBTicketsManager::getTicket($value['ticket_id']); $mark = CTaxonomyManager::getMark($value['mark_id']); $questions = $value['questions']; $protocol = CFactory::createSebProtocol(); $protocol->setSignDate($sign_date); $protocol->setStudent($student); $protocol->setChairman($chairman); $protocol->setTicket($ticket); $protocol->setMark($mark); $protocol->setQuestions($questions); $protocol->setBoarMaster($master); $protocol->setSpeciality($student->getSpeciality()); foreach ($members->getItems() as $member) { $protocol->addMember($member); } $protocol->setNumber(CProtocolManager::getAllSebProtocols()->getCount() + 1); $protocol->save(); CProtocolManager::getCacheSebProtocols()->add($protocol->getId(), $protocol); } $this->redirect("?action=index"); }
/** * Получение данных модели по идентификатору */ private function actionJSONGet() { // получим название класса модели, которую надо пользователю $modelClass = CRequest::getString("model"); // идентификатор $id = CRequest::getInt("id"); // создадим объект, посмотрим, в какой таблице он весь живет /** * @var $model CActiveModel */ $model = new $modelClass(); // проверим, может не реализует нужный интерфейс if (!is_a($model, "IJSONSerializable")) { throw new Exception("Класс " . $modelClass . " не реализует интерфейс IJSONSerializable"); } $modelTable = $model->getRecord()->getTable(); // получим из этой таблицы объект $ar = CActiveRecordProvider::getById($modelTable, $id); if (is_null($ar)) { echo json_encode(null); return; } // создадим новый объект указанного типа /** * @var $model IJSONSerializable */ $model = new $modelClass($ar); // получим json объект модели $jsonObj = $model->toJsonObject(); // добавим к json-объекту перевод $jsonObj->_translation = CCoreObjectsManager::getAttributeLabels($model); // сразу добавим штатную валидацию // может, чуть позже, пока нет echo json_encode($jsonObj); }
public function actionIndex() { $set = new CRecordSet(false); $query = new CQuery(); $set->setQuery($query); $query->select("t.*")->from(TABLE_NMS_PROTOCOL . " as t")->order('STR_TO_DATE(date_text, "%d.%m.%Y") desc'); if (CRequest::getString("order") == "date_text") { $direction = "asc"; if (CRequest::getString("direction") == "desc") { $direction = "desc"; } $query->order('STR_TO_DATE(date_text, "%d.%m.%Y") ' . $direction); } $objects = new CArrayList(); foreach ($set->getPaginated()->getItems() as $ar) { $object = new CNMSProtocol($ar); $objects->add($object->getId(), $object); } $this->setData("objects", $objects); $this->setData("paginator", $set->getPaginator()); /** * Генерация меню */ $this->addActionsMenuItem(array("title" => "Добавить протокол", "link" => "index.php?action=add", "icon" => "actions/list-add.png")); /** * Отображение представления */ $this->renderView("_protocols_nms/protocol/index.tpl"); }
public function actionAutosave() { if (CRequest::getInt("id") !== 0) { $help = CHelpManager::getHelp(CRequest::getInt("id")); if (!is_null($help)) { $help->content = CRequest::getString("content", $help::getClassName()); $help->save(); } } }
public function __construct() { if (!CSession::isAuth()) { if (!in_array(CRequest::getString("action"), $this->allowedAnonymous)) { $this->redirectNoAccess(); } } $this->_smartyEnabled = true; $this->setPageTitle("Подсистема архивирования"); parent::__construct(); }
public function __construct() { if (!CSession::isAuth()) { if (!in_array(CRequest::getString("action"), $this->allowedAnonymous)) { $this->redirectNoAccess(); } } $this->_smartyEnabled = true; $this->setPageTitle("Управление таблицами доступа"); parent::__construct(); }
/** * @return CArrayList */ public static function getCommissions() { $res = new CArrayList(); $ids = CRequest::getString("id"); $ids = explode(":", $ids); foreach ($ids as $id) { $comm = self::getCommission($id); if (!is_null($comm)) { $res->add($comm->getId(), $comm); } } return $res; }
/** * Сохранение отправленных данных */ public function actionSave() { $taxonomy = CTaxonomyManager::getTaxonomy(CRequest::getInt("taxonomy_id")); $term = CFactory::createTerm(); $term->setTaxonomy($taxonomy); $term->setValue(CRequest::getString("name")); $term->setAlias(CRequest::getString("alias")); if (CRequest::getInt("id") != 0) { $term->setId(CRequest::getInt("id")); } $term->save(); $this->redirect("?action=index&id=" . $taxonomy->getId()); }
public function actionSearch() { $res = array(); $term = CRequest::getString("query"); /** * Поиск по ФИО сотрудника */ $query = new CQuery(); $query->select("distinct(person.id) as id, person.fio as name")->from(TABLE_PERSON . " as person")->condition("person.fio like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "person.id", "value" => $item["id"], "label" => $item["name"], "class" => "CPerson"); } echo json_encode($res); }
public function actionSearch() { $res = array(); $term = CRequest::getString("query"); /** * Ищем группу по названию */ $query = new CQuery(); $query->select("st_group.id, st_group.name")->from(TABLE_STUDENT_GROUPS . " as st_group")->condition("LCASE(st_group.name) like '%" . mb_strtolower($term) . "%' and st_group.year_id =" . CUtils::getCurrentYear()->id)->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "id", "value" => $item["id"], "label" => $item["name"], "class" => "CStudentGroup"); } echo json_encode($res); }
/** * Массив ключ-значение сотрудников с указанными ролями */ public function actionGetStaffWithRoles() { // получаем из POST-запроса роли $res = array(); $roles = new CArrayList(); foreach (explode(",", CRequest::getString("roles")) as $val) { $roles->add($val, $val); } $persons = CStaffManager::getPersonsWithTypes($roles); foreach ($persons->getItems() as $person) { $res[$person->getId()] = $person->getName(); } echo json_encode($res); }
/** * Обновление данных об оргструктуре аяксом через * перетаскивание */ public function actionAjaxUpdate() { if (!CSession::isAuth()) { return true; } $sourceId = CRequest::getString("source"); $destId = CRequest::getString("destination"); $sourceId = substr($sourceId, strpos($sourceId, "_") + 1); $destId = substr($destId, strpos($destId, "_") + 1); $child = CStaffManager::getPersonById($sourceId); $parent = CStaffManager::getPersonById($destId); $child->setManager($parent); $child->save(); $this->renderView(AJAX_VIEW); }
public function __construct() { if (!CSession::isAuth()) { $action = CRequest::getString("action"); if ($action == "") { $action = "index"; } if (!in_array($action, $this->allowedAnonymous)) { $this->redirectNoAccess(); } } $this->_smartyEnabled = true; $this->setPageTitle("Вопросы преподавателям и другим пользователям портала"); parent::__construct(); }
public function actionSave() { if (CRequest::getInt("id") == 0) { $q = CFactory::createSebQuestion(); } else { $q = CSEBQuestionsManager::getQuestion(CRequest::getInt("id")); } $discipline = CTaxonomyManager::getCacheDisciplines()->getItem(CRequest::getInt("discipline_id")); $speciality = CTaxonomyManager::getCacheSpecialities()->getItem(CRequest::getInt("speciality_id")); $q->setDiscipline($discipline); $q->setSpeciality($speciality); $q->setText(CRequest::getString("question")); $q->save(); $this->redirect("?action=index"); }
public function __construct() { if (!CSession::isAuth()) { $action = CRequest::getString("action"); if ($action == "") { $action = "index"; } if (!in_array($action, $this->allowedAnonymous)) { $this->redirectNoAccess(); } } $this->_smartyEnabled = true; $this->setPageTitle("Рейтинг преподавателей по публикациям"); parent::__construct(); }
public function __construct() { if (!CSession::isAuth()) { $action = CRequest::getString("action"); if ($action == "") { $action = "index"; } if (!in_array($action, $this->allowedAnonymous)) { $this->redirectNoAccess(); } } $this->_smartyEnabled = true; $this->setPageTitle("Управление семестрами"); parent::__construct(); }
public function actionSearch() { $res = array(); $term = CRequest::getString("query"); /** * Сначала поищем по названию группы */ $query = new CQuery(); $query->select("distinct(page.id) as id, page.title as name")->from(TABLE_PAGES . " as page")->condition("page.title like '%" . $term . "%'")->limit(0, 5); if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->condition("page.title like '%" . $term . "%' AND page.user_id_insert = " . CSession::getCurrentUser()->getId()); } foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "id", "value" => $item["id"], "label" => $item["name"], "class" => "CPage"); } echo json_encode($res); }
/** * Сохранение меню */ public function actionSave() { if (!CSession::isAuth()) { $this->redirectNoAccess(); } if (CRequest::getInt("id") == 0) { $menu = CFactory::createMenu(); } else { $menu = CMenuManager::getMenu(CRequest::getInt("id")); } $menu->setName(CRequest::getString("name")); $menu->setAlias(CRequest::getString("alias")); $menu->setDescription(CRequest::getString("description")); $menu->setPublished(CRequest::getInt("published") == 1); $menu->save(); $this->redirect("?action=index"); }
public function __construct() { if (!CSession::isAuth()) { $action = CRequest::getString("action"); if ($action == "") { $action = "index"; } if (!in_array($action, $this->allowedAnonymous)) { $this->redirectNoAccess(); } } else { if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_NO_ACCESS) { $this->redirectNoAccess(); } } $this->_smartyEnabled = true; $this->setPageTitle("Новости портала кафедры АСУ"); parent::__construct(); }
public function actionImport() { $providerClass = CRequest::getString("provider"); /** * @var $provider IImportProvider */ $provider = new $providerClass(); $providerModel = $provider->getImportModel(); $providerModel->setAttributes(CRequest::getArray($providerModel::getClassName())); if ($providerModel->validate()) { if ($provider->import($providerModel)) { $this->redirect("?action=complete"); } return true; } $formView = "_import/providers/" . get_class($provider) . "/" . $provider->getImportFormName(); $this->setData("formView", $formView); $this->setData("form", $providerModel); $this->setData("provider", get_class($provider)); $this->renderView("_import/home/form.tpl"); }
public function actionSearch() { $res = array(); $term = CRequest::getString("query"); /** * Поиск по названию */ $query = new CQuery(); $query->select("distinct(year.id) as id, year.name as name")->from(TABLE_YEARS . " as year")->condition("year.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "year.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTimeIntervals"); } /** * Поиск по дате начала года */ $query = new CQuery(); $query->select("distinct(year.id) as id, year.date_start as name")->from(TABLE_YEARS . " as year")->condition("year.date_start like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "year.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTimeIntervals"); } /** * Поиск по дате окончания года */ $query = new CQuery(); $query->select("distinct(year.id) as id, year.date_end as name")->from(TABLE_YEARS . " as year")->condition("year.date_end like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "year.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTimeIntervals"); } /** * Поиск по комментарию */ $query = new CQuery(); $query->select("distinct(year.id) as id, year.comment as name")->from(TABLE_YEARS . " as year")->condition("year.comment like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "year.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTimeIntervals"); } echo json_encode($res); }
public function __construct() { // инициализируем бин if (CRequest::getString("beanId") != "") { self::$_statefullBeanId = CRequest::getString("beanId"); } // если пришли параметры инициализации бина - инициализируем бин if (is_array(CRequest::getArray("beanData"))) { $params = CRequest::getArray("beanData"); foreach ($params as $key => $value) { self::getStatefullBean()->add($key, $value); } } // если нет параметра запуска флоу, то ведем себя как обычный контроллер if (CRequest::getString("flow") == "") { parent::__construct(); return true; } // костыль, чтобы не допустить повторной инициализации для // флоу-контроллеров if (self::$_alreadyInstantiated) { return true; } // включим смарти, нельзя без него $this->_smartyEnabled = true; // передаем управление другому объекту $controllerClass = CRequest::getString("targetClass"); $controllerMethod = "action" . CRequest::getString("targetMethod"); // если не указано хотябы одно, то это конец if ($controllerClass == "" || $controllerMethod == "") { return true; } self::$_alreadyInstantiated = true; self::$_useFlowController = true; $controller = new $controllerClass(); $controller->{$controllerMethod}(); }
public function actionSearch() { $res = array(); $term = CRequest::getString("query"); /** * Поиск по ФИО */ $query = new CQuery(); $query->select("person.id as id, person.fio as name")->from(TABLE_PERSON . " as person")->condition("person.fio like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "person.id", "value" => $item["id"], "label" => $item["name"], "class" => "CPerson"); } /** * Поиск по типу участия на кафедре */ $query = new CQuery(); $query->select("types.person_type_id as id, person_types.name as name")->from(TABLE_PERSON_BY_TYPES . " as types")->innerJoin(TABLE_TYPES . " as person_types", "types.person_type_id = person_types.id")->condition("person_types.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "types.person_type_id", "value" => $item["id"], "label" => $item["name"], "class" => "CTerm"); } /** * Поиск по полу */ $query = new CQuery(); $query->select("pol.id as id, pol.name as name")->from(TABLE_GENDERS . " as pol")->condition("pol.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "pol.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTerm"); } /** * Поиск по роли на кафедре */ $query = new CQuery(); $query->select("term.id as id, term.name as name")->from(TABLE_TAXONOMY_TERMS . " as term")->innerJoin(TABLE_TAXONOMY . " as taxonomy", "term.taxonomy_id = taxonomy.id AND taxonomy.alias='department_roles'")->condition("term.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "term.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTerm"); } /** * Поиск по семейному положению */ $query = new CQuery(); $query->select("fam_st.id as id, fam_st.name as name")->from(TABLE_FAMILY_STATUS . " as fam_st")->condition("fam_st.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "fam_st.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTerm"); } /** * Поиск по иностранному языку */ $query = new CQuery(); $query->select("lang.id as id, lang.name as name")->from(TABLE_LANGUAGES . " as lang")->condition("lang.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "lang.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTerm"); } /** * Поиск по должности */ $query = new CQuery(); $query->select("post.id as id, post.name as name")->from(TABLE_POSTS . " as post")->condition("post.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "post.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTerm"); } /** * Поиск по званию */ $query = new CQuery(); $query->select("zvanie.id as id, zvanie.name as name")->from(TABLE_TITLES . " as zvanie")->condition("zvanie.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "zvanie.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTerm"); } /** * Поиск по ученой степени */ $query = new CQuery(); $query->select("stepen.id as id, stepen.name as name")->from(TABLE_DEGREES . " as stepen")->condition("stepen.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "stepen.id", "value" => $item["id"], "label" => $item["name"], "class" => "CTerm"); } /** * Полнотекстовый поиск по остальным полям */ $fields = array("passp_seria", "passp_nomer", "date_rogd", "INN", "insurance_num", "add_work", "tel_work", "add_home", "tel_home", "e_mail", "site", "ekspert_spec", "ekspert_kluch_slova", "nagradi", "primech", "add_contact"); foreach ($fields as $field) { $query = new CQuery(); $query->select("person.id as id, person." . $field . " as name")->from(TABLE_PERSON . " as person")->condition("person." . $field . " like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "person.id", "value" => $item["id"], "label" => $item["name"], "class" => "CPerson"); } } echo json_encode($res); }
public function actionSearch() { $res = array(); $term = CRequest::getString("query"); /** * Поиск по названию дисциплины */ $query = new CQuery(); $query->select("distinct(subject.id) as id, subject.name as name")->from(TABLE_DISCIPLINES . " as subject")->innerJoin(TABLE_LIBRARY_DOCUMENTS . " as doc", "doc.subj_id = subject.id")->condition("subject.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "type" => 1); } /** * По фамилии преподавателя */ $query = new CQuery(); $query->select("distinct(user.id) as id, person.fio as name")->from(TABLE_PERSON . " as person")->condition("person.fio like '%" . $term . "%'")->innerJoin(TABLE_USERS . " as user", "person.id = user.kadri_id")->innerJoin(TABLE_LIBRARY_DOCUMENTS . " as doc", "doc.user_id = user.id")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "type" => 2); } /** * По файлу */ $query = new CQuery(); $query->select("distinct(file.nameFolder) as id, file.browserFile as name")->from(TABLE_LIBRARY_FILES . " as file")->condition("file.browserFile like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "type" => 3); } echo json_encode($res); }
public function actionSearchDiplom() { $res = array(); $term = CRequest::getString("term"); /** * Поиск по теме диплома в таблице с дипломами */ $query = new CQuery(); $query->select("diplom.*")->from(TABLE_DIPLOMS . " as diplom")->condition("diplom.dipl_name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $diplom = new CDiplom(new CActiveRecord($item)); if (!is_null($diplom->student)) { $res[] = array("label" => $diplom->student->getName() . " (" . $diplom->dipl_name . ")", "value" => $diplom->student->getName() . " (" . $diplom->dipl_name . ")", "object_id" => $item["id"], "filter" => "diplom"); } } /** * Поиск по фамилии студента */ $query = new CQuery(); $query->select("diplom.*")->from(TABLE_DIPLOMS . " as diplom")->innerJoin(TABLE_STUDENTS . " as student", "diplom.student_id = student.id")->condition("student.fio like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $diplom = new CDiplom(new CActiveRecord($item)); if (!is_null($diplom->student)) { $res[] = array("label" => $diplom->student->getName() . " (" . $diplom->dipl_name . ")", "value" => $diplom->student->getName() . " (" . $diplom->dipl_name . ")", "object_id" => $item["id"], "filter" => "diplom"); } } echo json_encode($res); }
public function execute($contextObject) { /** * @var $bean CStatefullBean */ $bean = CApp::getApp()->beans->getStatefullBean(CRequest::getString("beanId")); $persons = new CArrayList(); foreach ($bean->getItem("id")->getItems() as $person_id) { $person = CStaffManager::getPerson($person_id); if (!is_null($person)) { $persons->add($person->getId(), $person); } } /** * Отфильтруем нужные планы */ $targetPlans = new CArrayList(); /** * @var $person CPerson */ foreach ($persons->getItems() as $person) { foreach ($person->getIndPlansByYears($bean->getItem("year_id"))->getItems() as $year_id => $plans) { foreach ($plans->getItems() as $plan) { if (in_array($plan->type, $bean->getItem("types")->getItems())) { $targetPlans->add($plan->getId(), $plan); } } } } $month = $bean->getItem("month"); $month = $month->getFirstItem(); $result = array(); /** * @var $plan CIndPlanPersonLoad */ foreach ($targetPlans->getItems() as $plan) { $row = array(); $row[0] = ""; $row[1] = ""; $row[2] = ""; $row[3] = ""; $row[4] = ""; // план на семестр if (!array_key_exists(5, $row)) { $row[5] = 0; } $preparedData = array(); $table = $plan->getStudyLoadTable()->getTable(); foreach ($table as $r) { if ($plan->isSeparateContract()) { // если есть бюджет-контракт, то суммируем их $preparedRow = array(); $preparedRow[0] = $r[0]; for ($i = 1; $i <= 17; $i++) { $preparedRow[$i] = $r[$i * 2] + $r[$i * 2 - 1]; } $preparedData[] = $preparedRow; } else { // нет разделения на бюджет-контракт, копируем $preparedData[] = $r; } } if (in_array($month, array(2, 3, 4, 5, 6))) { foreach ($preparedData as $preparedRow) { $row[5] += $preparedRow[1]; } } else { foreach ($preparedData as $preparedRow) { $row[5] += $preparedRow[8]; } } $rows = array(6 => 0, 7 => 1, 8 => 2, 9 => -1, 10 => 4, 11 => -1, 12 => 14, 13 => 3, 14 => 5, 15 => 6, 16 => 7, 17 => 8, 18 => 9, 19 => 10, 20 => 15, 21 => 16); foreach ($rows as $target => $source) { if (!array_key_exists($target, $row)) { $row[$target] = 0; } if ($source != -1) { $row[$target] += $preparedData[$source][$month]; } } if (!array_key_exists(22, $row)) { $row[22] = 0; } for ($i = 6; $i <= 21; $i++) { $row[22] += $row[$i]; } $result[] = $row; } $sum = array(); $sum[0] = "Итог"; for ($i = 1; $i <= 4; $i++) { $sum[$i] = ""; } for ($i = 5; $i <= 22; $i++) { if (!array_key_exists($i, $sum)) { $sum[$i] = 0; } foreach ($result as $item) { $sum[$i] += $item[$i]; } } $total = array($sum); return $total; }
/** * Большой поиск по всему-всему-всему */ public function actionSearch() { $term = CRequest::getString("term"); $res = array(); /** * Поищем сначала преподавателей. 5 будет достаточно за один раз */ $query = new CQuery(); $query->select("distinct(person.id) as id, person.fio as name")->from(TABLE_STUDENTS_ACTIVITY . " as activity")->innerJoin(TABLE_PERSON . " as person", "activity.kadri_id = person.id")->condition("person.fio like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "type" => 1); } /** * Теперь поищем дисциплины */ $query = new CQuery(); $query->select("distinct(subject.id) as id, subject.name as name")->from(TABLE_STUDENTS_ACTIVITY . " as activity")->innerJoin(TABLE_DISCIPLINES . " as subject", "activity.subject_id = subject.id")->condition("subject.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "type" => 2); } /** * Теперь ищем группы */ $query = new CQuery(); $query->select("distinct(st_group.id) as id, st_group.name as name")->from(TABLE_STUDENTS_ACTIVITY . " as activity")->innerJoin(TABLE_STUDENTS . " as student", "student.id = activity.student_id")->innerJoin(TABLE_STUDENT_GROUPS . " as st_group", "student.group_id = st_group.id")->condition("st_group.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "type" => 3); } /** * А теперь из студентов */ $query = new CQuery(); $query->select("distinct(student.id) as id, student.fio as name, st_group.name as group_name")->from(TABLE_STUDENTS_ACTIVITY . " as activity")->innerJoin(TABLE_STUDENTS . " as student", "student.id = activity.student_id")->leftJoin(TABLE_STUDENT_GROUPS . " as st_group", "st_group.id = student.group_id")->condition("student.fio like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"] . " (" . $item["group_name"] . ")", "value" => $item["name"] . " (" . $item["group_name"] . ")", "object_id" => $item["id"], "type" => 4); } /** * Студенты по номеру зачетки * 0000118 */ $query = new CQuery(); $query->select("distinct(student.id) as id, student.fio as name, student.stud_num as stud_num")->from(TABLE_STUDENTS_ACTIVITY . " as activity")->innerJoin(TABLE_STUDENTS . " as student", "student.id = activity.student_id")->condition("student.stud_num like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"] . " (" . $item["stud_num"] . ")", "value" => $item["name"] . " (" . $item["stud_num"] . ")", "object_id" => $item["id"], "type" => 4); } /** * А еще виды контроля */ $query = new CQuery(); $query->select("distinct(control.id) as id, control.name as name")->from(TABLE_STUDENTS_ACTIVITY . " as activity")->innerJoin(TABLE_STUDENTS_CONTROL_TYPES . " as control", "control.id = activity.study_act_id")->condition("control.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "type" => 5); } echo json_encode($res); }
public function actionSearch() { $res = array(); $term = CRequest::getString("query"); /** * Поиск по наименованию практики */ $query = new CQuery(); $query->select("distinct(pract.id) as id, pract.name as name")->from(TABLE_PRACTICE_PLACES . " as pract")->condition("pract.name like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "type" => 1); } /** * Поиск по комментарию */ $query = new CQuery(); $query->select("distinct(pract.id) as id, pract.comment as comment")->from(TABLE_PRACTICE_PLACES . " as pract")->condition("pract.comment like '%" . $term . "%'")->limit(0, 5); foreach ($query->execute()->getItems() as $item) { $res[] = array("label" => $item["comment"], "value" => $item["comment"], "object_id" => $item["id"], "type" => 2); } echo json_encode($res); }
public function actionSearch() { $res = array(); $term = CRequest::getString("term"); /** * Полнотекстовый поиск по текстовым полям */ $fields = array("date", "num", "title", "text", "comment"); $query = new CQuery(); $query->select("o.*")->from(TABLE_USATU_ORDERS . " as o")->condition("MATCH (" . implode($fields, ", ") . ") AGAINST ('" . $term . "')")->limit(0, 5); $objects = new CArrayList(); foreach ($query->execute()->getItems() as $ar) { $object = new COrderUsatu(new CActiveRecord($ar)); $objects->add($object->getId(), $object); } foreach ($objects->getItems() as $object) { foreach ($fields as $field) { if (strpos($object->{$field}, $term) !== false) { $labels = $object->attributeLabels(); if (array_key_exists($field, $labels)) { $label = $labels[$field]; } else { $label = $field; } $res[] = array("label" => $object->getName() . " (" . $label . ": " . $object->{$field} . ")", "value" => $object->getName() . " (" . $label . ": " . $object->{$field} . ")", "object_id" => $object->getId(), "filter" => "order"); } } } echo json_encode($res); }
public function actionSubscribe() { $val = CRequest::getString("value"); // сначала удаляем if (!is_null(CSession::getCurrentUser()->getSubscription())) { CSession::getCurrentUser()->getSubscription()->remove(); } // теперь создадим, если нужно if ($val == "true") { $s = new CSubscription(); $s->user_id = CSession::getCurrentUser()->getId(); $s->save(); } }