Commit aee098d4 authored by Arnaud Pauget's avatar Arnaud Pauget
Browse files

Merge branch 'feat/18593_display_other_org_owner_in_search_form' into 'develop'

Feat/18593 display other org owner in search form

See merge request !709
parents 30b9a80b f9cdd7c3
Pipeline #16768 canceled with stages
......@@ -1650,20 +1650,22 @@ class organization
*/
protected function getOwnerOrgsByRole($currentService, $role)
{
$organizationController = \laabs::newController('organization/organization');
$orgUnits = $organizationController->getOrgsByRole($role);
$orgUnits = $this->getOrgsByRole($role);
$userPositionController = \laabs::newController('organization/userPosition');
$orgController = \laabs::newController('organization/organization');
$archivalAgreementController = \laabs::newController('medona/archivalAgreement');
$owner = false;
$archiver = false;
$userOrgUnits = [];
$userOrgs = [];
$allArchivalAgreements = $archivalAgreementController->index();
$originatorOrgIds = [];
$userOrgUnitOrgRegNumbers = array_merge(array($currentService->registrationNumber), $userPositionController->readDescandantService((string)$currentService->orgId));
foreach ($userOrgUnitOrgRegNumbers as $userOrgUnitOrgRegNumber) {
$userOrgUnit = $orgController->getOrgByRegNumber($userOrgUnitOrgRegNumber);
$userOrgUnit = $this->getOrgByRegNumber($userOrgUnitOrgRegNumber);
$userOrgUnits[] = $userOrgUnit;
if (isset($userOrgUnit->orgRoleCodes)) {
foreach ($userOrgUnit->orgRoleCodes as $orgRoleCode) {
......@@ -1672,6 +1674,12 @@ class organization
}
if ($orgRoleCode == 'archiver') {
$archiver = true;
$myOriginatorOrgs = [];
foreach ($allArchivalAgreements as $archivalAgreement) {
if($archivalAgreement->archiverOrgRegNumber == $userOrgUnitOrgRegNumber) {
$myOriginatorOrgs = array_merge($myOriginatorOrgs, $archivalAgreement->originatorOrgIds->jsonSerialize());
}
}
}
}
}
......@@ -1681,14 +1689,14 @@ class organization
foreach ($orgUnits as $orgUnit) {
if (// Owner = all originators
$owner
// Archiver = all originators fo the same org
|| ($archiver && $orgUnit->ownerOrgId == $userOrgUnit->ownerOrgId)
// Archiver = all originators for the same org
|| ($archiver && ($orgUnit->ownerOrgId == $userOrgUnit->ownerOrgId || in_array($orgUnit->orgId, $myOriginatorOrgs)))
// Originator = all originators at position and sub-services
|| ($role == 'originator' && $orgUnit->registrationNumber == $userOrgUnit->registrationNumber)
// Depositor = all
|| $role == 'depositor') {
if (!isset($userOrgs[(string)$orgUnit->ownerOrgId])) {
$orgObject = $organizationController->read((string)$orgUnit->ownerOrgId);
$orgObject = $this->read((string)$orgUnit->ownerOrgId);
$userOrgs[(string)$orgObject->orgId] = new \stdClass();
$userOrgs[(string)$orgObject->orgId]->displayName = $orgObject->displayName;
......
......@@ -77,7 +77,21 @@ class archive
$emptyRole = true;
} else {
$emptyRole = false;
$ownerOriginatorOrgs = $this->getOwnerOriginatorsOrgs($currentService);
// $ownerOriginatorOrgs = $this->getOwnerOriginatorsOrgs($currentService);
$orgController = \laabs::newController('organization/organization');
$originators = $orgController->getOriginator();
foreach ($originators as $originator) {
if (!isset($ownerOriginatorOrgs[(string) $originator->ownerOrgId])) {
$ownerOriginatorOrgs[(string) $originator->ownerOrgId] = new \stdClass();
$ownerOriginatorOrgs[(string) $originator->ownerOrgId]->displayName = $originator->ownerOrgName;
$ownerOriginatorOrgs[(string) $originator->ownerOrgId]->originators = [];
}
if (!in_array($originator, $ownerOriginatorOrgs[(string) $originator->ownerOrgId]->originators)) {
$ownerOriginatorOrgs[(string)$originator->ownerOrgId]->originators[] = $originator;
}
}
}
$descriptionSchemeNames = \laabs::callService('recordsManagement/descriptionScheme/read_name_Descriptionfields');
$retentionRuleController = \laabs::newController('recordsManagement/retentionRule');
......
......@@ -902,10 +902,11 @@
/* -- EDITION MODAL -- */
var organizations = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('displayName'),
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('orgName'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: '/organizations/todisplay?orgUnit=true',
//url: '/organizations/todisplay?orgUnit=true',
url: '/originator',
ttl: '0'
},
limit: 100
......
......@@ -246,6 +246,7 @@
<hr style="height:1px;border:none;color:gray;background-color:gray;">
</div>
<span class="hide" id="required_fields">You must fill all required fields (*)</span>
<div data-translate-catalog="recordsManagement/messages" id="noOriginatorFound" class="hide">No originator found</div>
</div>
<script>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment