Skip to content
Snippets Groups Projects
Verified Commit 33acb2ce authored by Damien's avatar Damien
Browse files

FEAT #12332 TIME 0:25 Mapping merge

parent ecaeb93e
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ use Contact\models\ContactModel; ...@@ -19,6 +19,7 @@ use Contact\models\ContactModel;
use Doctype\models\DoctypeModel; use Doctype\models\DoctypeModel;
use Entity\models\EntityModel; use Entity\models\EntityModel;
use Entity\models\ListInstanceModel; use Entity\models\ListInstanceModel;
use IndexingModel\models\IndexingModelModel;
use Note\models\NoteModel; use Note\models\NoteModel;
use Resource\models\ResModel; use Resource\models\ResModel;
use SrcCore\models\TextFormatModel; use SrcCore\models\TextFormatModel;
...@@ -85,36 +86,55 @@ class MergeController ...@@ -85,36 +86,55 @@ class MergeController
ValidatorModel::stringType($args, ['attachmentChrono', 'attachmentTitle']); ValidatorModel::stringType($args, ['attachmentChrono', 'attachmentTitle']);
//Resource //Resource
$resource = [];
if (!empty($args['resId'])) { if (!empty($args['resId'])) {
$resource = ResModel::getById(['select' => ['*'], 'resId' => [$args['resId']]]); $resource = ResModel::getById(['select' => ['*'], 'resId' => [$args['resId']]]);
$allDates = ['doc_date', 'departure_date', 'admission_date', 'process_limit_date', 'opinion_limit_date', 'closing_date', 'creation_date']; } else {
foreach ($allDates as $date) { if (!empty($args['modelId'])) {
$resource[$date] = TextFormatModel::formatDate($resource[$date], 'd/m/Y'); $indexingModel = IndexingModelModel::getById(['id' => $args['modelId'], 'select' => ['category']]);
} }
$resource['category_id'] = ResModel::getCategoryLabel(['category_id' => $resource['category_id']]); $resource = [
'model_id' => $args['modelId'] ?? null,
'category_id' => $indexingModel['category'] ?? null,
'type_id' => $args['doctype'] ?? null,
'subject' => $args['subject'] ?? null,
'destination' => $args['destination'] ?? null,
'initiator' => $args['initiator'] ?? null,
'doc_date' => $args['documentDate'] ?? null,
'admission_date' => $args['arrivalDate'] ?? null,
'departure_date' => $args['departureDate'] ?? null,
'process_limit_date' => $args['processLimitDate'] ?? null,
'barcode' => $args['barcode'] ?? null,
'origin' => $args['origin'] ?? null
];
}
$allDates = ['doc_date', 'departure_date', 'admission_date', 'process_limit_date', 'opinion_limit_date', 'closing_date', 'creation_date'];
foreach ($allDates as $date) {
$resource[$date] = TextFormatModel::formatDate($resource[$date], 'd/m/Y');
}
$resource['category_id'] = ResModel::getCategoryLabel(['category_id' => $resource['category_id']]);
if (!empty($resource['type_id'])) {
$doctype = DoctypeModel::getById(['id' => $resource['type_id'], 'select' => ['process_delay', 'process_mode', 'description']]); $doctype = DoctypeModel::getById(['id' => $resource['type_id'], 'select' => ['process_delay', 'process_mode', 'description']]);
$resource['type_label'] = $doctype['description']; $resource['type_label'] = $doctype['description'];
$resource['process_delay'] = $doctype['process_delay']; $resource['process_delay'] = $doctype['process_delay'];
$resource['process_mode'] = $doctype['process_mode']; $resource['process_mode'] = $doctype['process_mode'];
}
if (!empty($resource['initiator'])) { if (!empty($resource['initiator'])) {
$initiator = EntityModel::getByEntityId(['entityId' => $resource['initiator'], 'select' => ['*']]); $initiator = EntityModel::getByEntityId(['entityId' => $resource['initiator'], 'select' => ['*']]);
if (!empty($initiator)) { if (!empty($initiator)) {
foreach ($initiator as $key => $value) { foreach ($initiator as $key => $value) {
$resource["initiator_{$key}"] = $value; $resource["initiator_{$key}"] = $value;
}
}
if (!empty($initiator['parent_entity_id'])) {
$parentInitiator = EntityModel::getByEntityId(['entityId' => $initiator['parent_entity_id'], 'select' => ['*']]);
} }
} }
if (!empty($resource['destination'])) { if (!empty($initiator['parent_entity_id'])) {
$destination = EntityModel::getByEntityId(['entityId' => $resource['destination'], 'select' => ['*']]); $parentInitiator = EntityModel::getByEntityId(['entityId' => $initiator['parent_entity_id'], 'select' => ['*']]);
if (!empty($destination['parent_entity_id'])) { }
$parentDestination = EntityModel::getByEntityId(['entityId' => $destination['parent_entity_id'], 'select' => ['*']]); }
} if (!empty($resource['destination'])) {
$destination = EntityModel::getByEntityId(['entityId' => $resource['destination'], 'select' => ['*']]);
if (!empty($destination['parent_entity_id'])) {
$parentDestination = EntityModel::getByEntityId(['entityId' => $destination['parent_entity_id'], 'select' => ['*']]);
} }
} }
......
...@@ -257,37 +257,14 @@ class ResController ...@@ -257,37 +257,14 @@ class ResController
return $response->withStatus(400)->withJson(['errors' => 'Document has no file']); return $response->withStatus(400)->withJson(['errors' => 'Document has no file']);
} }
if ($document['category_id'] == 'outgoing') { $convertedDocument = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resId'], 'collId' => 'letterbox_coll']);
$attachment = AttachmentModel::get([
'select' => ['res_id', 'docserver_id', 'path', 'filename'], if (empty($convertedDocument['errors'])) {
'where' => ['res_id_master = ?', 'attachment_type = ?', 'status not in (?)'], $documentTodisplay = $convertedDocument;
'data' => [$aArgs['resId'], 'outgoing_mail', ['DEL', 'OBS']], $document['docserver_id'] = $documentTodisplay['docserver_id'];
'limit' => 1 $document['path'] = $documentTodisplay['path'];
]); $document['filename'] = $documentTodisplay['filename'];
if (!empty($attachment[0])) { $document['fingerprint'] = $documentTodisplay['fingerprint'];
$attachmentTodisplay = $attachment[0];
$id = $attachmentTodisplay['res_id'];
$collId = "attachments_coll";
$convertedDocument = ConvertPdfController::getConvertedPdfById(['resId' => $id, 'collId' => $collId]);
if (empty($convertedDocument['errors'])) {
$attachmentTodisplay = $convertedDocument;
}
$document['docserver_id'] = $attachmentTodisplay['docserver_id'];
$document['path'] = $attachmentTodisplay['path'];
$document['filename'] = $attachmentTodisplay['filename'];
$document['fingerprint'] = $attachmentTodisplay['fingerprint'];
}
} else {
$convertedDocument = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resId'], 'collId' => 'letterbox_coll']);
if (empty($convertedDocument['errors'])) {
$documentTodisplay = $convertedDocument;
$document['docserver_id'] = $documentTodisplay['docserver_id'];
$document['path'] = $documentTodisplay['path'];
$document['filename'] = $documentTodisplay['filename'];
$document['fingerprint'] = $documentTodisplay['fingerprint'];
}
} }
$docserver = DocserverModel::getByDocserverId(['docserverId' => $document['docserver_id'], 'select' => ['path_template', 'docserver_type_id']]); $docserver = DocserverModel::getByDocserverId(['docserverId' => $document['docserver_id'], 'select' => ['path_template', 'docserver_type_id']]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment