/** * Массив ключ-значение сотрудников с указанными ролями */ 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 actionGetViewData() { $result = array(); // выбор сотрудников $withOrder = false; if (in_array("order", $this->properties)) { $withOrder = true; unset($this->properties[array_search("order", $this->properties)]); } // если ничего не выбрано, то выдаем всех $personsArray = array(); if (count($this->properties) == 0) { foreach (CStaffManager::getAllPersons()->getItems() as $person) { $result[$person->getId()] = $person->getName(); $personsArray[] = $person; } } else { $types = new CArrayList(); foreach ($this->properties as $type) { $types->add($type, $type); } foreach (CStaffManager::getPersonsWithTypes($types)->getItems() as $person) { $result[$person->getId()] = $person->getName(); $personsArray[] = $person; } } if ($withOrder) { /** * @var $person CPerson */ foreach ($personsArray as $person) { if (!$person->hasActiveOrder()) { unset($result[$person->getId()]); } } } return $result; }