public function save()
 {
     parent::save();
     /**
      * У сотрудников, которых нет приказов по
      * ГАК в году комиссии автоматически устанавливается
      * приказ от комиссии
      */
     if ($this->order_id !== 0) {
         $persons = new CArrayList();
         foreach ($this->members->getItems() as $person) {
             $persons->add($person->getId(), $person);
         }
         if (!is_null($this->manager)) {
             $persons->add($this->manager->getId(), $this->manager);
         }
         foreach ($persons->getItems() as $person) {
             if (is_null($person->getSABOrdersByYear($this->year))) {
                 $ar = new CActiveRecord(array("id" => null, "person_id" => $person->getId(), "year_id" => $this->year->getId(), "order_id" => $this->order_id));
                 $ar->setTable(TABLE_SAB_PERSON_ORDERS);
                 $ar->insert();
             }
         }
     }
 }
 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");
 }
 public function execute($contextObject)
 {
     $result = 0;
     if (!is_null($contextObject->terms)) {
         $terms = array();
         foreach ($contextObject->terms->getItems() as $term) {
             $terms[] = $term->number;
         }
     }
     $termSectionsData = new CArrayList();
     foreach ($contextObject->terms->getItems() as $term) {
         $query = new CQuery();
         $query->select("sum(if(term.alias = 'lecture', l.value, 0)) as lecture")->from(TABLE_WORK_PLAN_CONTENT_SECTIONS . " as section")->innerJoin(TABLE_WORK_PLAN_CONTENT_LOADS . " as l", "l.section_id = section.id")->innerJoin(TABLE_TAXONOMY_TERMS . " as term", "term.id = l.load_type_id")->leftJoin(TABLE_WORK_PLAN_SELFEDUCATION . " as selfedu", "selfedu.load_id = l.id")->group("l.section_id")->condition("l.term_id = " . $term->getId());
         $items = $query->execute();
         if ($items->getCount() > 0) {
             $termSectionsData->add($term->getId(), $items);
         }
     }
     foreach ($termSectionsData->getItems() as $termId => $termData) {
         if (CBaseManager::getWorkPlanTerm($termId)->number == $terms[0]) {
             $result = 0;
             foreach ($termData as $row) {
                 $result += $row["lecture"];
             }
         }
     }
     return $result;
 }
 public function execute($contextObject)
 {
     $result = array();
     if (!is_null($contextObject->terms)) {
         $terms = array();
         foreach ($contextObject->terms->getItems() as $term) {
             $terms[] = $term->number;
         }
     }
     $termSectionsData = new CArrayList();
     foreach ($contextObject->terms->getItems() as $term) {
         $query = new CQuery();
         $select = array();
         $select[] = "section.sectionIndex";
         $select[] = "section.name";
         $select[] = "section.content";
         $select[] = "sum(if(term.alias in ('lecture', 'practice', 'labwork', 'ksr'), l.value, 0)) + sum(ifnull(selfedu.question_hours, 0)) as total";
         $select[] = "sum(if(term.alias = 'lecture', l.value, 0)) as lecture";
         $select[] = "sum(if(term.alias = 'practice', l.value, 0)) as practice";
         $select[] = "sum(if(term.alias = 'labwork', l.value, 0)) as labwork";
         $select[] = "sum(if(term.alias = 'ksr', l.value, 0)) as ksr";
         $select[] = "sum(ifnull(selfedu.question_hours, 0)) as selfedu";
         $query->select(join(", ", $select))->from(TABLE_WORK_PLAN_CONTENT_SECTIONS . " as section")->innerJoin(TABLE_WORK_PLAN_CONTENT_LOADS . " as l", "l.section_id = section.id")->innerJoin(TABLE_TAXONOMY_TERMS . " as term", "term.id = l.load_type_id")->leftJoin(TABLE_WORK_PLAN_SELFEDUCATION . " as selfedu", "selfedu.load_id = l.id")->group("l.section_id")->condition("l.term_id = " . $term->getId());
         $items = $query->execute();
         if ($items->getCount() > 0) {
             $termSectionsData->add($term->getId(), $items);
         }
     }
     foreach ($termSectionsData->getItems() as $termId => $termData) {
         foreach ($termData as $row) {
             $dataRow = array();
             $dataRow[0] = $row["sectionIndex"];
             $dataRow[1] = $row["name"] . ": " . $row["content"];
             $dataRow[2] = $row["lecture"];
             $dataRow[3] = $row["practice"];
             $dataRow[4] = $row["labwork"];
             $dataRow[5] = $row["ksr"];
             $dataRow[6] = $row["selfedu"];
             $dataRow[7] = $row["total"];
             $dataRow[8] = "";
             $dataRow[9] = "";
             $result[] = $dataRow;
         }
     }
     return $result;
 }
 public function execute($contextObject)
 {
     $termSectionsData = new CArrayList();
     foreach ($contextObject->terms->getItems() as $term) {
         $query = new CQuery();
         $query->select("sum(ifnull(selfedu.question_hours, 0)) as selfedu")->from(TABLE_WORK_PLAN_CONTENT_SECTIONS . " as section")->innerJoin(TABLE_WORK_PLAN_CONTENT_LOADS . " as l", "l.section_id = section.id")->innerJoin(TABLE_TAXONOMY_TERMS . " as term", "term.id = l.load_type_id")->leftJoin(TABLE_WORK_PLAN_SELFEDUCATION . " as selfedu", "selfedu.load_id = l.id")->group("l.section_id")->condition("l.term_id = " . $term->getId());
         $items = $query->execute();
         if ($items->getCount() > 0) {
             $termSectionsData->add($term->getId(), $items);
         }
     }
     $result = 0;
     foreach ($termSectionsData->getItems() as $termId => $termData) {
         foreach ($termData as $row) {
             $result += $row["selfedu"];
         }
     }
     return $result;
 }
 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 actionSelectLoadTypesByPersonsPlans()
 {
     if ($this->getSelectedInPickListDialog()->getCount() == 0) {
         $this->setData("message", "Год не выбран, продолжение невозможно");
         $this->renderView("_flow/dialog.ok.tpl", "", "");
         return true;
     }
     $year_id = $this->getSelectedInPickListDialog()->getFirstItem();
     // соберем всех людей
     $bean = self::getStatefullBean();
     $bean->add("year_id", $year_id);
     $ids = $bean->getItem("id");
     $persons = new CArrayList();
     foreach ($ids->getItems() as $id) {
         $person = CStaffManager::getPerson($id);
         if (!is_null($person)) {
             $persons->add($person->getId(), $person);
         }
     }
     /**
      * @var $person CPerson
      */
     $types = new CArrayList();
     foreach ($persons->getItems() as $person) {
         foreach ($person->getIndPlansByYears($year_id)->getItems() as $year_id => $plans) {
             foreach ($plans->getItems() as $plan) {
                 $types->add($plan->type, $plan->type);
             }
         }
     }
     $this->setData("items", $types);
     $this->setData("multiple", true);
     $this->renderView("_flow/pickList.tpl", get_class($this), "SelectMonthForPersonPlans");
 }
 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;
 }
예제 #9
0
 /**
  * Получить роли по идентификатору задачи выбранного сотрудника 
  * @param CUserRole $key
  * @param CUser $user
  * @return CArrayList
  */
 public static function getRolesByTaskByUser(CUserRole $key, CUser $user)
 {
     $roles = new CArrayList();
     $users = new CArrayList();
     foreach (CActiveRecordProvider::getWithCondition(TABLE_USER_IN_GROUPS, "user_id = '" . $user->getId() . "'")->getItems() as $item) {
         $user = new CUser($item);
         $users->add($user->getId(), $user);
     }
     foreach (CStaffManager::getRolesByTask($key)->getItems() as $role) {
         foreach ($users->getItems() as $user) {
             if ($role->user_group_id == $user->group_id) {
                 $roles->add($role->getId(), $role);
                 self::getCacheRolesGroups()->add($role->id, $role);
             }
         }
     }
     return $roles;
 }
 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);
 }
예제 #11
0
 /**
  * @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;
 }
 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 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();
         if (array_key_exists($plan->person_id, $result)) {
             $row = $result[$plan->person_id];
         }
         $row[0] = "АСУ";
         $row[1] = count($result);
         $row[2] = "";
         if (!is_null($plan->person)) {
             if (!is_null($plan->person->getPost())) {
                 $row[2] = $plan->person->getPost()->name_short;
             }
         }
         $row[3] = "";
         if (!is_null($plan->person)) {
             if (!is_null($plan->person->degree)) {
                 $row[3] = $plan->person->degree->comment;
             }
         }
         $row[4] = "";
         if (!is_null($plan->person)) {
             $row[4] = $plan->person->fio_short;
         }
         // план на семестр бюджет
         if (!array_key_exists(5, $row)) {
             $row[5] = 0;
         }
         // план на семестр контракт
         if (!array_key_exists(6, $row)) {
             $row[6] = 0;
         }
         // итого бюджет
         if (!array_key_exists(23, $row)) {
             $row[23] = 0;
         }
         // итого контракт
         if (!array_key_exists(24, $row)) {
             $row[24] = 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];
                 }
                 // не разделяем бюджет-контракт плана на осенний семестр
                 $preparedRow[18] = $r[1];
                 $preparedRow[19] = $r[2];
                 // не разделяем бюджет-контракт плана на весенний семестр
                 $preparedRow[20] = $r[15];
                 $preparedRow[21] = $r[16];
                 // не разделяем бюджет-контракт итога за осенний семестр
                 $preparedRow[20] = $r[13];
                 $preparedRow[21] = $r[14];
                 // не разделяем бюджет-контракт итога за весенний семестр
                 $preparedRow[22] = $r[29];
                 $preparedRow[23] = $r[30];
                 $preparedData[] = $preparedRow;
             } else {
                 // нет разделения на бюджет-контракт, копируем
                 $preparedData[] = $r;
             }
         }
         if ($plan->isSeparateContract()) {
             if (in_array($month, array(2, 3, 4, 5, 6))) {
                 foreach ($preparedData as $preparedRow) {
                     $row[5] += $preparedRow[18];
                     $row[6] += $preparedRow[19];
                     $row[23] += $preparedRow[20];
                     $row[24] += $preparedRow[21];
                 }
             } else {
                 foreach ($preparedData as $preparedRow) {
                     $row[5] += $preparedRow[20];
                     $row[6] += $preparedRow[21];
                     $row[23] += $preparedRow[22];
                     $row[24] += $preparedRow[23];
                 }
             }
             $rows = array(7 => 0, 8 => 1, 9 => 2, 10 => -1, 11 => 4, 12 => -1, 13 => 14, 14 => 3, 15 => 5, 16 => 6, 17 => 7, 18 => 8, 19 => 9, 20 => 10, 21 => 15, 22 => 16);
         } else {
             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 (!array_key_exists(22, $row)) {
                 $row[22] = 0;
             }
             if ($source != -1) {
                 $row[$target] += $preparedData[$source][$month];
                 $row[22] += $preparedData[$source][$month];
             }
         }
         if (!$plan->isSeparateContract()) {
             if (!array_key_exists(22, $row)) {
                 $row[22] = 0;
             }
             for ($i = 6; $i <= 21; $i++) {
                 $row[22] += $row[$i];
             }
         }
         $result[$plan->person_id] = $row;
     }
     return $result;
 }
예제 #14
0
 /**
  * Преобразовать плоскую таблицу в журнал
  *
  * @return CArrayList
  */
 public function toGradebookTable()
 {
     $rows = new CArrayList();
     // шаг 1. определим количество записей в одной строке
     $types = new CArrayList();
     $dates = new CArrayList();
     $comments = new CArrayList();
     foreach ($this->activities->getItems() as $activity) {
         if (!is_null($activity->controlType)) {
             /*
             $types->add($activity->study_act_id."_".str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT)."_".date("Ymd", strtotime($activity->getDate())), $activity->controlType->getValue());
             $dates->add($activity->study_act_id."_".str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT)."_".date("Ymd", strtotime($activity->getDate())), $activity->getDate());
             $comments->add($activity->study_act_id."_".str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT)."_".date("Ymd", strtotime($activity->getDate())), $activity->study_act_comment);
             */
             $types->add($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT), $activity->controlType->getValue());
             $dates->add($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT), $activity->getDate());
             $comments->add($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT), $activity->study_act_comment);
         }
     }
     $types = $types->getSortedByKey(SORT_ASC);
     $dates = $dates->getSortedByKey(SORT_ASC);
     $firstCol = new CArrayList();
     $firstCol->add($firstCol->getCount(), "");
     // добавим все виды деятельности
     foreach ($types->getItems() as $key => $type) {
         $firstCol->add($key, $type);
     }
     $rows->add($rows->getCount(), $firstCol);
     // все номера лабораторных работ
     $col = $firstCol->getCopy();
     foreach ($comments->getItems() as $key => $date) {
         $col->add($key, $date);
     }
     $rows->add($rows->getCount(), $col);
     // шаг 2. пройдемся по всем записям, получим всех студентов
     $students = new CArrayList();
     foreach ($this->activities->getItems() as $activity) {
         if (!is_null($activity->student)) {
             $students->add($activity->student->getName(), $activity->student);
         }
     }
     $students = $students->getSortedByKey(SORT_ASC);
     // шаг 3. создадим на каждого студента по строчке в таблице
     foreach ($students->getItems() as $student) {
         $col = $firstCol->getCopy();
         foreach ($col->getItems() as $key => $value) {
             if ($key !== 0) {
                 $col->add($key, "");
             }
         }
         $col->add(0, $student->getName());
         foreach ($this->activities->getItems() as $activity) {
             if ($activity->student_id == $student->getId()) {
                 $arr = array();
                 if ($col->hasElement($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT))) {
                     $arr = $col->getItem($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT));
                 }
                 if (!is_null($activity->mark)) {
                     $arr[] = $activity->mark->getValue();
                 }
                 $col->add($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT), $arr);
             }
         }
         $rows->add($rows->getCount(), $col);
     }
     // по просьбе ГВ в клетку 1.1 ставим название группы
     if (!is_null($this->group)) {
         $firstCol->add(0, $this->group->getName());
     }
     return $rows;
 }
 public function actionTasks()
 {
     $roles = new CArrayList();
     foreach (CSession::getCurrentUser()->getRoles()->getItems() as $role) {
         if ($role->hidden != 1) {
             $roles->add($role->getId(), $role);
         }
     }
     $sort = new CArrayList();
     foreach ($roles->getItems() as $i) {
         $sort->add($i->name, $i->getId());
     }
     $tasks = new CArrayList();
     foreach ($sort->getSortedByKey(true)->getItems() as $i) {
         $item = $roles->getItem($i);
         $tasks->add($item->getId(), $item);
     }
     $this->setData("tasks", $tasks);
     $this->renderView("_dashboard/tasks.tpl");
 }
 public function actionSearch()
 {
     $res = array();
     $term = CRequest::getString("term");
     /**
      * Поиск по ФИО
      */
     $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("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "filter" => "person");
     }
     /**
      * Поиск по типу участия на кафедре
      */
     $query = new CQuery();
     $query->select("type.id as id, type.name as name")->from(TABLE_TYPES . " as type")->condition("type.name like '%" . $term . "%'")->limit(0, 5);
     foreach ($query->execute()->getItems() as $item) {
         $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "filter" => "type");
     }
     /**
      * Поиск по полу
      */
     $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("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "filter" => "gender");
     }
     /**
      * Поиск по роли на кафедре
      */
     $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("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "filter" => "role");
     }
     /**
      * Поиск по семейному положению
      */
     $query = new CQuery();
     $query->select("s.id as id, s.name as name")->from("family_status as s")->condition("s.name like '%" . $term . "%'")->limit(0, 5);
     foreach ($query->execute()->getItems() as $item) {
         $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "filter" => "family");
     }
     /**
      * Поиск по иностранному языку
      */
     $query = new CQuery();
     $query->select("s.id as id, s.name as name")->from("language as s")->condition("s.name like '%" . $term . "%'")->limit(0, 5);
     foreach ($query->execute()->getItems() as $item) {
         $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "filter" => "language");
     }
     /**
      * Поиск по должности
      */
     $query = new CQuery();
     $query->select("s.id as id, s.name as name")->from(TABLE_POSTS . " as s")->condition("s.name like '%" . $term . "%'")->limit(0, 5);
     foreach ($query->execute()->getItems() as $item) {
         $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "filter" => "post");
     }
     /**
      * Поиск по званию
      */
     $query = new CQuery();
     $query->select("s.id as id, s.name as name")->from("zvanie as s")->condition("s.name like '%" . $term . "%'")->limit(0, 5);
     foreach ($query->execute()->getItems() as $item) {
         $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "filter" => "title");
     }
     /**
      * Поиск по ученой степени
      */
     $query = new CQuery();
     $query->select("s.id as id, s.name as name")->from("stepen as s")->condition("s.name like '%" . $term . "%'")->limit(0, 5);
     foreach ($query->execute()->getItems() as $item) {
         $res[] = array("label" => $item["name"], "value" => $item["name"], "object_id" => $item["id"], "filter" => "degree");
     }
     /**
      * Полнотекстовый поиск по остальным полям
      */
     $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");
     $query = new CQuery();
     $query->select("person.*")->from(TABLE_PERSON . " as person")->condition("MATCH (" . implode($fields, ", ") . ") AGAINST ('" . $term . "')")->limit(0, 5);
     $objects = new CArrayList();
     foreach ($query->execute()->getItems() as $ar) {
         $person = new CPerson(new CActiveRecord($ar));
         $objects->add($person->getId(), $person);
     }
     foreach ($objects->getItems() as $person) {
         foreach ($fields as $field) {
             if (strpos($person->{$field}, $term) !== false) {
                 $labels = $person->attributeLabels();
                 if (array_key_exists($field, $labels)) {
                     $label = $labels[$field];
                 } else {
                     $label = $field;
                 }
                 $res[] = array("label" => $person->getName() . " (" . $label . ": " . $person->{$field} . ")", "value" => $person->getName() . " (" . $label . ": " . $person->{$field} . ")", "object_id" => $person->getId(), "filter" => "person");
             }
         }
     }
     echo json_encode($res);
 }
예제 #17
0
 /**
  * Возможноные значения показателя
  *
  * @return CArrayList
  */
 public function getIndexValues()
 {
     if (is_null($this->_indexValues)) {
         $this->_indexValues = new CArrayList();
         // идем в словарь, по которому выбираются значения
         $manager = $this->manager_class;
         $method = $this->manager_method;
         $fromTaxonomy = new CArrayList();
         if ($manager != "" && $method != "") {
             $str = '$fromTaxonomy = ' . $manager . '::' . $method . ';';
             eval($str);
         }
         // ходим по значениям, полученным из словаря, преобразуем их
         // в значения показателя. попутно смотрим, вдруг для них уже
         // определен в сохраненных вес
         $resArray = new CArrayList();
         foreach ($fromTaxonomy->getItems() as $term) {
             if (!$this->hasSavedValueFromTaxonomy($term->id)) {
                 $value = new CRatingIndexValue();
                 $value->manager_class = $manager;
                 $value->manager_method = $method;
                 $value->fromTaxonomy = "1";
                 $value->title = $term->id;
                 $value->index_id = $this->id;
                 $resArray->add("unsaved_" . $value->title, $value);
             } else {
                 $value = $this->getSavedValueFromTaxonomy($term->id);
                 if (!is_null($value)) {
                     $resArray->add($value->getId(), $value);
                 }
             }
         }
         // добавляем вручную созданные и сохраненны (если их еще нет)
         foreach ($this->savedIndexValues->getItems() as $item) {
             $resArray->add($item->getId(), $item);
         }
         // возврат значения =)
         $this->_indexValues = $resArray;
     }
     return $this->_indexValues;
 }
 public function actionSearch()
 {
     $term = CRequest::getString("query");
     $result = array();
     // извлекаем все папки и файлы, у которых что-то совпадает
     $query = new CQuery();
     $query->select("f.*")->from(TABLE_DOCUMENT_FOLDERS . " as f")->condition("f.title like '%" . $term . "%'")->order("f.title asc");
     $objects = new CArrayList();
     foreach ($query->execute()->getItems() as $ar) {
         $folder = new CDocumentFolder(new CActiveRecord($ar));
         $objects->add($objects->getCount(), $folder);
     }
     // теперь извлекаем все файлы
     $query = new CQuery();
     $query->select("f.*")->from(TABLE_DOCUMENTS . " as f")->condition("f.nameFolder like 'gost%' and f.browserFile like '%" . $term . "%'")->order("f.browserFile asc");
     foreach ($query->execute()->getItems() as $ar) {
         $file = new CDocumentFile(new CDocumentActiveRecord($ar));
         if ($file->isFileExists()) {
             $objects->add($objects->getCount(), $file);
         }
     }
     foreach ($objects->getItems() as $obj) {
         $arr = array("id" => $obj->getId());
         if ($obj->isFolder()) {
             $arr["type"] = "folder";
             $arr["title"] = $obj->title;
         } else {
             $arr["type"] = "file";
             $arr["icon"] = $obj->getIconLink();
             $arr["title"] = $obj->browserFile;
             $arr["link"] = $obj->getFileLink();
         }
         $result[] = $arr;
     }
     echo json_encode($result);
 }