diff --git a/core/class/PrintControler.php b/core/class/PrintControler.php index ba37c565a8b45e8ed2de15df566f6b779a2c5137..702fc23b79e94c54fbe384333b057f13ca3d9172 100644 --- a/core/class/PrintControler.php +++ b/core/class/PrintControler.php @@ -260,7 +260,7 @@ class PrintControler extends PrintFunctions $pdf->MultiCell(90, 5, utf8_decode(_INITIATOR . ' : ' . $resultEntity->entity_label . " (" . $this->array_print[$cpt]['initiator'] . ")"), 0, 'C', false); } elseif($this->array_print[$cpt]['typist'] <> '') { - $primaryEntity = \User\models\UserModel::getPrimaryEntityById(['id' => $this->array_print[$cpt]['typist']]); + $primaryEntity = \User\models\UserModel::getPrimaryEntityById(['id' => $this->array_print[$cpt]['typist'], 'select' => ['users_entities.entity_id', 'entities.entity_label']]); $pdf->MultiCell(90, 5, utf8_decode(_INITIATOR . ' : ' . $primaryEntity['entity_label'] . " (" . $primaryEntity['entity_id'] . ")"), 0, 'C', false); } diff --git a/src/app/contentManagement/controllers/MergeController.php b/src/app/contentManagement/controllers/MergeController.php index 59fbdf77f555d61e6fcd5a25f9826419bb1ad2e3..b7ffe15f42450d6495b080892e8ddc732ac60687 100644 --- a/src/app/contentManagement/controllers/MergeController.php +++ b/src/app/contentManagement/controllers/MergeController.php @@ -135,12 +135,14 @@ class MergeController $resource["initiator_{$key}"] = $value; } } + $initiator['path'] = EntityModel::getEntityPathByEntityId(['entityId' => $resource['initiator'], 'path' => '']); if (!empty($initiator['parent_entity_id'])) { $parentInitiator = EntityModel::getByEntityId(['entityId' => $initiator['parent_entity_id'], 'select' => ['*']]); } } if (!empty($resource['destination'])) { $destination = EntityModel::getByEntityId(['entityId' => $resource['destination'], 'select' => ['*']]); + $destination['path'] = EntityModel::getEntityPathByEntityId(['entityId' => $resource['destination'], 'path' => '']); if (!empty($destination['parent_entity_id'])) { $parentDestination = EntityModel::getByEntityId(['entityId' => $destination['parent_entity_id'], 'select' => ['*']]); } @@ -154,6 +156,10 @@ class MergeController //User $currentUser = UserModel::getById(['id' => $args['userId'], 'select' => ['firstname', 'lastname', 'phone', 'mail', 'initials']]); + $currentUserPrimaryEntity = UserModel::getPrimaryEntityById(['id' => $args['userId'], 'select' => ['entities.*', 'users_entities.user_role as role']]); + if (!empty($currentUserPrimaryEntity)) { + $currentUserPrimaryEntity['path'] = EntityModel::getEntityPathByEntityId(['entityId' => $currentUserPrimaryEntity['entity_id'], 'path' => '']); + } //Visas $visas = ''; @@ -253,6 +259,7 @@ class MergeController $dataToBeMerge['parentDestination'] = empty($parentDestination) ? [] : $parentDestination; $dataToBeMerge['attachment'] = $attachment; $dataToBeMerge['user'] = $currentUser; + $dataToBeMerge['userPrimaryEntity'] = $currentUserPrimaryEntity; $dataToBeMerge['visas'] = $visas; $dataToBeMerge['opinions'] = $opinions; $dataToBeMerge['copies'] = $copies; diff --git a/src/app/resource/controllers/StoreController.php b/src/app/resource/controllers/StoreController.php index 802a9775700f11978952a3b3b48198ed908e836f..265717bf8a25d8fb438bf22eb257cc34eb02be2f 100755 --- a/src/app/resource/controllers/StoreController.php +++ b/src/app/resource/controllers/StoreController.php @@ -100,7 +100,7 @@ class StoreController $id = AttachmentModel::create($data); } else { - $data = StoreController::prepareUpdateAttachmentStorage($data); + $data = StoreController::prepareUpdateAttachmentStorage($data, $args['id']); $id = AttachmentModel::update(['set' => $data, 'where' => ['res_id = ?'], 'data' => [$args['id']]]); } @@ -225,9 +225,15 @@ class StoreController return $preparedData; } - public static function prepareUpdateAttachmentStorage(array $args) + public static function prepareUpdateAttachmentStorage(array $args, int $id) { - //TODO chrono if not chrono + $attachment = AttachmentModel::getById(['id' => $id, 'select' => ['identifier', 'res_id_master']]); + $attachmentsTypes = AttachmentModel::getAttachmentsTypesByXML(); + if ($attachmentsTypes[$args['type']]['chrono'] && empty($attachment['identifier'])) { + $resource = ResModel::getById(['select' => ['destination', 'type_id'], 'resId' => $attachment['res_id_master']]); + $chrono = ChronoModel::getChrono(['id' => 'outgoing', 'entityId' => $resource['destination'], 'typeId' => $resource['type_id'], 'resId' => $attachment['res_id_master']]); + } + $preparedData = [ 'title' => $args['title'] ?? null, 'attachment_type' => $args['type'], @@ -235,6 +241,9 @@ class StoreController 'modification_date' => 'CURRENT_TIMESTAMP' ]; + if (!empty($chrono)) { + $preparedData['identifier'] = $chrono; + } if (!empty($args['docserver_id'])) { $preparedData = array_merge($preparedData, [ 'format' => $args['format'], diff --git a/src/app/resource/controllers/SummarySheetController.php b/src/app/resource/controllers/SummarySheetController.php index e3d507bdceff2c4385fbae58d6ae3e6add09aacd..7360cb1bc8a97a9fe2b33a5e9cc388e19d64b159 100755 --- a/src/app/resource/controllers/SummarySheetController.php +++ b/src/app/resource/controllers/SummarySheetController.php @@ -292,7 +292,7 @@ class SummarySheetController foreach ($resourcesContacts as $contactsKey => $value) { $entitiesFormat = ''; if ($value['type'] == 'user') { - $userEntity = UserModel::getPrimaryEntityById(['id' => $value['item_id']]); + $userEntity = UserModel::getPrimaryEntityById(['id' => $value['item_id'], 'select' => ['entities.entity_label']]); if (!empty($userEntity)) { $entitiesFormat = ' (' . $userEntity['entity_label'] . ')'; } diff --git a/src/app/user/models/UserModelAbstract.php b/src/app/user/models/UserModelAbstract.php index a5b2fe02d0c080b26c1e29252201e315cf29bee1..234516f5c82cc5c26f46ecb46405daf626367970 100755 --- a/src/app/user/models/UserModelAbstract.php +++ b/src/app/user/models/UserModelAbstract.php @@ -400,23 +400,24 @@ abstract class UserModelAbstract return $aEntity[0]; } - public static function getPrimaryEntityById(array $aArgs) + public static function getPrimaryEntityById(array $args) { - ValidatorModel::notEmpty($aArgs, ['id']); - ValidatorModel::intVal($aArgs, ['id']); + ValidatorModel::notEmpty($args, ['id', 'select']); + ValidatorModel::intVal($args, ['id']); + ValidatorModel::arrayType($args, ['select']); - $aEntity = DatabaseModel::select([ - 'select' => ['users_entities.entity_id', 'entities.entity_label', 'users_entities.user_role', 'users_entities.primary_entity'], + $entity = DatabaseModel::select([ + 'select' => $args['select'], 'table' => ['users, users_entities, entities'], 'where' => ['users.user_id = users_entities.user_id', 'users_entities.entity_id = entities.entity_id', 'users.id = ?', 'users_entities.primary_entity = ?'], - 'data' => [$aArgs['id'], 'Y'] + 'data' => [$args['id'], 'Y'] ]); - if (empty($aEntity[0])) { + if (empty($entity[0])) { return []; } - return $aEntity[0]; + return $entity[0]; } public static function getGroupsByLogin(array $aArgs)