From 62cd1b631732579c9f50d0b08e5e845edad59786 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 19 Sep 2019 13:20:35 +0200 Subject: [PATCH] Adapted widget to receive and display only passed OrgUnits in Dropdown --- .../widgets/Organisationseinheit_widget.php | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/application/widgets/Organisationseinheit_widget.php b/application/widgets/Organisationseinheit_widget.php index 67d1598b0..9c285c44c 100644 --- a/application/widgets/Organisationseinheit_widget.php +++ b/application/widgets/Organisationseinheit_widget.php @@ -5,16 +5,34 @@ class Organisationseinheit_widget extends DropdownWidget public function display($widgetData) { $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); - + if (isset($widgetData['typ'])) - $typ = $widgetData['typ']; + { + $this->setElementsArray($this->OrganisationseinheitModel->getRecursiveList($widgetData['typ'])); + } + // If 'organisationseinheit' (array of specific oe_kurzbz) is given, retrieve these organisational units only + elseif (isset($widgetData['organisationseinheit']) && !empty($widgetData['organisationseinheit'])) + { + $condition = ' + oe_kurzbz IN (\''. implode('\',\'', $widgetData['organisationseinheit']) . '\') AND + aktiv = TRUE + '; + $this->addSelectToModel($this->OrganisationseinheitModel, 'oe_kurzbz', 'organisationseinheittyp_kurzbz || \' \' || bezeichnung'); + $this->OrganisationseinheitModel->addOrder('organisationseinheittyp_kurzbz', 'ASC'); + $this->setElementsArray( + $this->OrganisationseinheitModel->loadWhere($condition), + true, + $this->p->t('ui', 'bitteEintragWaehlen'), + 'No organisational units found' + ); + } + // Default: retrieve tree of all organisational units else - $typ = null; - - // NOTE: no need to call addSelectToModel because getRecursiveList already returns - // the correct names of the fields - - $this->setElementsArray($this->OrganisationseinheitModel->getRecursiveList($typ)); + { + // NOTE: no need to call addSelectToModel because getRecursiveList already returns + // the correct names of the fields + $this->setElementsArray($this->OrganisationseinheitModel->getRecursiveList()); + } $this->loadDropDownView($widgetData); }