Commit 3bd582e6 authored by Florian Azizian's avatar Florian Azizian
Browse files

FIX #17195 TIME 2:40 Save fastParapheur subscriberId in external_id (entities)...

FIX #17195 TIME 2:40 Save fastParapheur subscriberId in external_id (entities) instead of business_id
parent 14aab2e0
......@@ -102,7 +102,8 @@ class EntityController
'email' => $entity['email'],
'producerService' => $entity['producer_service'],
'business_id' => $entity['business_id'],
'external_id' => $entity['external_id']
'external_id' => $entity['external_id'],
'fastParapheurSubscriberId' => json_decode($entity['external_id'], true)['fastParapheurSubscriberId'],
];
$aEntities = EntityModel::getAllowedEntitiesByUserId(['userId' => $GLOBALS['login']]);
......@@ -219,6 +220,10 @@ class EntityController
return $response->withStatus(400)->withJson(['errors' => _ENTITY_ID_ALREADY_EXISTS]);
}
$externalId = [];
if (!empty($body['fastParapheurSubscriberId'])) {
$externalId['fastParapheurSubscriberId'] = $body['fastParapheurSubscriberId'];
}
$id = EntityModel::create([
'entity_id' => $body['entity_id'],
'entity_label' => $body['entity_label'],
......@@ -236,7 +241,8 @@ class EntityController
'entity_type' => $body['entity_type'],
'ldap_id' => $body['ldap_id'],
'entity_full_name' => $body['entity_full_name'],
'producer_service' => $body['producerService']
'producer_service' => $body['producerService'],
'external_id' => json_encode($externalId)
]);
HistoryController::add([
'tableName' => 'entities',
......@@ -274,7 +280,7 @@ class EntityController
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
$entity = EntityModel::getByEntityId(['entityId' => $aArgs['id'], 'select' => [1]]);
$entity = EntityModel::getByEntityId(['entityId' => $aArgs['id'], 'select' => ['id', 'external_id']]);
if (empty($entity)) {
return $response->withStatus(400)->withJson(['errors' => 'Entity not found']);
}
......@@ -306,6 +312,12 @@ class EntityController
$body['producer_service'] = $aArgs['id'];
}
$externalId = json_decode($entity['external_id'], true);
if (!empty($body['fastParapheurSubscriberId'])) {
$externalId['fastParapheurSubscriberId'] = $body['fastParapheurSubscriberId'];
} else {
unset($externalId['fastParapheurSubscriberId']);
}
EntityModel::update(['set' => [
'entity_label' => $body['entity_label'],
'short_label' => $body['short_label'],
......@@ -322,7 +334,8 @@ class EntityController
'entity_type' => $body['entity_type'],
'ldap_id' => $body['ldap_id'],
'entity_full_name' => $body['entity_full_name'],
'producer_service' => $body['producerService']
'producer_service' => $body['producerService'],
'external_id' => json_encode($externalId)
],
'where' => ['entity_id = ?'],
'data' => [$aArgs['id']]
......
......@@ -109,7 +109,8 @@ abstract class EntityModelAbstract
'entity_type' => $args['entity_type'],
'ldap_id' => $args['ldap_id'],
'entity_full_name' => $args['entity_full_name'],
'producer_service' => $args['producer_service']
'producer_service' => $args['producer_service'],
'external_id' => $args['external_id']
]
]);
......
......@@ -367,7 +367,7 @@ class FastParapheurController
$config = $aArgs['config'];
// We need the SIRET field and the user_id of the signatory user's primary entity
$signatory = DatabaseModel::select([
'select' => ['user_id', 'business_id', 'entities.entity_label'],
'select' => ['user_id', 'external_id', 'entities.entity_label'],
'table' => ['listinstance', 'users_entities', 'entities'],
'left_join' => ['item_id = user_id', 'users_entities.entity_id = entities.entity_id'],
'where' => ['res_id = ?', 'item_mode = ?', 'process_date is null'],
......@@ -381,6 +381,7 @@ class FastParapheurController
'data' => [$aArgs['resIdMaster']]
])[0];
$signatory['business_id'] = json_decode($signatory['external_id'], true)['fastParapheurSubscriberId'];
if (empty($signatory['business_id']) || substr($signatory['business_id'], 0, 3) == 'org') {
$signatory['business_id'] = $config['data']['subscriberId'];
}
......
......@@ -182,27 +182,31 @@ export class SendExternalSignatoryBookActionComponent implements OnInit {
}
hasEmptyOtpSignaturePosition() {
const externalUsers: any[] = this.maarchParapheur.appExternalVisaWorkflow.visaWorkflow.items.filter((user: any) => user.item_id === null && user.role === 'sign');
if (externalUsers.length > 0) {
let resToSign: any[] = this.maarchParapheur.resourcesToSign.filter((res: any) => res.hasOwnProperty('signaturePositions'));
let mustSign: boolean = false;
if (this.maarchParapheur.resourcesToSign.length > 1 && this.maarchParapheur.resourcesToSign.length - resToSign.length >= 1) {
return true;
}else if (resToSign.length === 0) {
return true;
} else {
resToSign = resToSign.map((res: any) => res.signaturePositions);
externalUsers.forEach((element: any) => {
for (let i = 0; i < resToSign.length; i++) {
const userIndex: number = this.maarchParapheur.appExternalVisaWorkflow.visaWorkflow.items.indexOf(element);
if (resToSign[i].filter((item: any) => item.sequence === userIndex).length === 0) {
mustSign = true;
break;
if (this.signatoryBookEnabled == 'maarchParapheur') {
const externalUsers: any[] = this.maarchParapheur.appExternalVisaWorkflow.visaWorkflow.items.filter((user: any) => user.item_id === null && user.role === 'sign');
if (externalUsers.length > 0) {
let resToSign: any[] = this.maarchParapheur.resourcesToSign.filter((res: any) => res.hasOwnProperty('signaturePositions'));
let mustSign: boolean = false;
if (this.maarchParapheur.resourcesToSign.length > 1 && this.maarchParapheur.resourcesToSign.length - resToSign.length >= 1) {
return true;
} else if (resToSign.length === 0) {
return true;
} else {
resToSign = resToSign.map((res: any) => res.signaturePositions);
externalUsers.forEach((element: any) => {
for (let i = 0; i < resToSign.length; i++) {
const userIndex: number = this.maarchParapheur.appExternalVisaWorkflow.visaWorkflow.items.indexOf(element);
if (resToSign[i].filter((item: any) => item.sequence === userIndex).length === 0) {
mustSign = true;
break;
}
}
}
});
return mustSign;
});
return mustSign;
}
}
} else {
return false;
}
}
}
......@@ -326,6 +326,17 @@
</mat-form-field>
</div>
</div>
<div class="form-group" *ngIf="externalSignatoryBook == 'fastParapheur'">
<div class="col-sm-12">
<mat-form-field>
<input matInput [(ngModel)]="currentEntity.fastParapheurSubscriberId"
name="fastParapheurSubscriberId" id="fastParapheurSubscriberId"
title="{{'lang.fastParapheurSubscriberId' | translate}}" type="text"
placeholder="{{'lang.fastParapheurSubscriberId' | translate}}" maxlength="255"
pattern="^[\w-]*$">
</mat-form-field>
</div>
</div>
</mat-expansion-panel>
</mat-accordion>
<div class="form-group">
......
......@@ -72,6 +72,7 @@ export class EntitiesAdministrationComponent implements OnInit {
addressBANFilteredResult: Observable<string[]>;
addressBANCurrentDepartment: string = '75';
departmentList: any[] = [];
externalSignatoryBook: string;
constructor(
public translate: TranslateService,
......@@ -114,6 +115,21 @@ export class EntitiesAdministrationComponent implements OnInit {
this.initEntitiesTree();
this.initBanSearch();
this.initAutocompleteAddressBan();
this.initSignatoryBook();
}
initSignatoryBook() {
this.http.get('../rest/externalConnectionsEnabled').pipe(
tap((data: any) => {
Object.keys(data.connection).filter(connectionId => connectionId !== 'maileva').forEach(connectionId => {
this.externalSignatoryBook = connectionId;
});
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
initEntitiesTree() {
......
......@@ -2067,6 +2067,7 @@
"manualSearchInfo": "You can leave the term in the field without selecting a value for the search.",
"groupSign": "Signatory's group",
"producerService": "Producer service",
"fastParapheurSubscriberId": "Fast-Parapheur subscriber Id",
"sendersDepartment": "Senders department",
"recordManagement": "Record management",
"slipLabel": "Slip label",
......
......@@ -2084,6 +2084,7 @@
"groupSign": "Groupe du signataire",
"noAdminSearchConfiguration": "Aucune configuration de recherche trouvée",
"producerService": "Identifiant de service producteur",
"fastParapheurSubscriberId": "Identifiant Fast-Parapheur",
"sendersDepartment": "Département des expéditeurs",
"recordManagement": "Archivage électronique",
"slipLabel": "Libellé du bordereau",
......
Markdown is supported
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