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 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); }
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 actionDelete() { $person = CStaffManager::getPerson(CRequest::getInt("id")); $person->remove(); $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; }
public function actionConvert() { foreach (CActiveRecordProvider::getAllFromTable(TABLE_NMS_PROTOCOL)->getItems() as $ar) { $protocol = new CNMSProtocol($ar); $protocol->date_text = date("d.m.Y", strtotime($protocol->date_text)); $protocol->save(); foreach ($protocol->agenda->getItems() as $point) { $person = CStaffManager::getPerson($point->kadri_id); if (!is_null($person)) { $members = $point->members; $members->add($person->getId(), $person); $point->save(); } } } $this->redirect("?action=index", "Конвертация завершена"); }
/** * Идентификатор связанного с сотрудником пользователя портала * * @return int */ public function getUserId() { $person = CStaffManager::getPerson($this->getId()); if (!is_null($person->getUser())) { $userId = $person->getUser()->id; } else { $userId = 0; } return $userId; }
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; }
public function actionView() { $person = CStaffManager::getPerson(CRequest::getInt("id")); $this->setData("person", $person); $this->renderView("_orders/view.tpl"); }
public function actionView() { $this->addActionsMenuItem(array(array("title" => "Назад", "link" => WEB_ROOT . "_modules/_lecturers/index.php", "icon" => "actions/edit-undo.png"))); if (CSettingsManager::getSettingValue("hide_person_data_rule")) { $lect = CBaseManager::getLecturerOuter(CRequest::getInt("id")); $this->setData("lect", $lect); $this->renderView("__public/_lecturers/viewOuter.tpl"); } else { $lect = CStaffManager::getPerson(CStaffManager::getUserById(CRequest::getInt("id"))->kadri_id); $this->setData("lect", $lect); $this->renderView("__public/_lecturers/view.tpl"); } }
public function actionFillIndexes() { $form = new CPersonRatingAutofillForm(); $form->setAttributes(CRequest::getArray($form::getClassName())); $year = CTaxonomyManager::getYear($form->year_id); // берем показатели указанного года foreach (CRatingManager::getRatingIndexesByYear($year)->getItems() as $index) { foreach ($form->persons as $personId) { $person = CStaffManager::getPerson($personId); if (!is_null($person)) { // удаляем старые показатели foreach (CActiveRecordProvider::getWithCondition(TABLE_PERSON_RATINGS, "person_id = " . $person->getId() . " and year_id = " . $year->getId())->getItems() as $item) { $item->remove(); } // если поле не многозначное, то способ вычисления лежит в показателе if (!$index->isMultivalue()) { if ($index->person_method != "") { $v = null; eval('$v = $person->' . $index->person_method . ';'); if (!is_null($v)) { if (strtoupper(get_class($v)) == "CTERM") { if ($index->getIndexValues()->hasElement($v->getId())) { $personValue = new CPersonRatingIndex(); $personValue->person_id = $person->getId(); $personValue->year_id = $year->getId(); $personValue->index_id = $index->getIndexValues()->getItem($v->getId())->getId(); $personValue->save(); } } } } } else { /** * Это многозначный показатель, вычисляется отдельно каждое значение */ foreach ($index->getIndexValues()->getItems() as $indexValue) { if ($indexValue->evaluate_code != "") { if ($indexValue->evaluate_method == "1") { // это sql-запрос $query = $indexValue->evaluate_code; $query = str_replace("%person%", $person->getId(), $query); $query = str_replace("%year%", $year->getId(), $query); $res = mysql_query($query); if (mysql_errno() == 0) { while ($row = mysql_fetch_assoc($res)) { if (array_key_exists("res", $row)) { if ($row['res'] == "1") { $personValue = new CPersonRatingIndex(); $personValue->person_id = $person->getId(); $personValue->year_id = $year->getId(); $personValue->index_id = $indexValue->getId(); $personValue->save(); } } break; } } } elseif ($indexValue->evaluate_method == "2") { // это php код $v = null; $code = $indexValue->evaluate_code; $code = str_replace("%person%", $person->getId(), $code); $code = str_replace("%year%", $year->getId(), $code); eval('$v = ' . $code . ';'); if ($v === true) { $personValue = new CPersonRatingIndex(); $personValue->person_id = $person->getId(); $personValue->year_id = $year->getId(); $personValue->index_id = $indexValue->getId(); $personValue->save(); } } } } } } } } $this->redirect("persons.php?action=index"); }
public function actionSave() { $diplom = new CDiplom(); $diplom->setAttributes(CRequest::getArray($diplom::getClassName())); $oldDate = $diplom->date_act; if ($diplom->validate()) { // дату нужно сконвертить в MySQL date $diplom->date_act = date("Y-m-d", strtotime($diplom->date_act)); $diplom->save(); if ($this->continueEdit()) { $this->redirect("?action=edit&id=" . $diplom->getId()); } else { $this->redirect(WEB_ROOT . "_modules/_diploms/index.php"); } //$this->redirect("?action=index"); return true; } // сконвертим дату из MySQL date в нормальную дату $diplom->date_act = date("d.m.Y", strtotime($diplom->date_act)); $commissions = array(); foreach (CSABManager::getCommissionsList() as $id => $c) { $commission = CSABManager::getCommission($id); $nv = $commission->title; if (!is_null($commission->manager)) { $nv .= " " . $commission->manager->getName(); } if (!is_null($commission->secretar)) { $nv .= " (" . $commission->secretar->getName() . ")"; } $cnt = 0; foreach ($commission->diploms->getItems() as $d) { if (strtotime($diplom->date_act) == strtotime($d->date_act)) { $cnt++; } } $nv .= " " . $cnt; $commissions[$commission->getId()] = $nv; } if (!array_key_exists($diplom->gak_num, $commissions)) { $diplom->gak_num = null; } $reviewers = CStaffManager::getPersonsListWithType(TYPE_REVIEWER); if (!array_key_exists($diplom->recenz_id, $reviewers)) { $reviewer = CStaffManager::getPerson($diplom->recenz_id); if (!is_null($reviewer)) { $reviewers[$reviewer->getId()] = $reviewer->getName(); } } $this->setData("reviewers", $reviewers); $this->setData("commissions", $commissions); $this->setData("diplom", $diplom); $this->renderView("_diploms/edit.tpl"); }
public function actionGetObject($id) { return CStaffManager::getPerson($id); }