From f051432bb2cf16f450e2112c98ca1f6480a8a029 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Tue, 29 Jan 2019 12:01:57 +0100 Subject: [PATCH] Export get copies --- apps/maarch_entreprise/xml/chrono.xml | 20 ---------------- migration/19.04/migrateExport.php | 2 +- .../resource/controllers/ExportController.php | 24 +++++++++++-------- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/apps/maarch_entreprise/xml/chrono.xml b/apps/maarch_entreprise/xml/chrono.xml index 68b8382cba8..0d5b19614af 100755 --- a/apps/maarch_entreprise/xml/chrono.xml +++ b/apps/maarch_entreprise/xml/chrono.xml @@ -73,7 +73,6 @@ For developper : <value>chr_by_category</value> </ELEMENT> </CHRONO> - <CHRONO> <id>outgoing</id> <separator></separator> @@ -98,24 +97,6 @@ For developper : <value>chr_by_category</value> </ELEMENT> </CHRONO> - - <CHRONO> - <id>market_document</id> - <separator>/</separator> - <ELEMENT> - <type>text</type> - <value>market</value> - </ELEMENT> - <ELEMENT> - <type>date</type> - <value>full_date</value> - </ELEMENT> - <ELEMENT> - <type>maarch_functions</type> - <value>chr_by_category</value> - </ELEMENT> - </CHRONO> - <CHRONO> <id>internal</id> <separator>/</separator> @@ -132,5 +113,4 @@ For developper : <value>chr_by_category</value> </ELEMENT> </CHRONO> - </root> diff --git a/migration/19.04/migrateExport.php b/migration/19.04/migrateExport.php index fc911b314f0..9706b368add 100755 --- a/migration/19.04/migrateExport.php +++ b/migration/19.04/migrateExport.php @@ -111,7 +111,7 @@ foreach ($customs as $custom) { } elseif ($functionName == 'get_priority') { $functionName = 'getPriority'; } elseif ($functionName == 'retrieve_copies') { - $functionName = 'getCopyEntities'; + $functionName = 'getCopies'; } elseif ($functionName == 'makeLink_detail') { $functionName = 'getDetailLink'; } elseif ($functionName == 'get_parent_folder') { diff --git a/src/app/resource/controllers/ExportController.php b/src/app/resource/controllers/ExportController.php index 05ee75e0886..798821380d3 100644 --- a/src/app/resource/controllers/ExportController.php +++ b/src/app/resource/controllers/ExportController.php @@ -191,8 +191,8 @@ class ExportController $csvContent[] = $resource['status.label_status']; } elseif ($value['value'] == 'getPriority') { $csvContent[] = $resource['priorities.label']; - } elseif ($value['value'] == 'getCopyEntities') { - $csvContent[] = ExportController::getCopyEntities(['resId' => $resource['res_id']]); + } elseif ($value['value'] == 'getCopies') { + $csvContent[] = ExportController::getCopies(['resId' => $resource['res_id']]); } elseif ($value['value'] == 'getDetailLink') { $csvContent[] = str_replace('rest/', "apps/maarch_entreprise/index.php?page=details&dir=indexing_searching&id={$resource['res_id']}", \Url::coreurl()); } elseif ($value['value'] == 'getParentFolder') { @@ -241,27 +241,31 @@ class ExportController return $response->withHeader('Content-Type', 'application/vnd.ms-excel'); } - private static function getCopyEntities(array $args) + private static function getCopies(array $args) { ValidatorModel::notEmpty($args, ['resId']); ValidatorModel::intVal($args, ['resId']); $listInstances = ListInstanceModel::get([ - 'select' => ['item_id'], - 'where' => ['res_id = ?', 'item_type = ?', 'item_mode = ?'], + 'select' => ['item_id', 'item_type'], + 'where' => ['res_id = ?', 'difflist_type = ?', 'item_mode = ?'], 'data' => [$args['resId'], 'entity_id', 'cc'] ]); - $copyEntities = ''; + $copies = ''; foreach ($listInstances as $listInstance) { - $entity = EntityModel::getByEntityId(['entityId' => $listInstance['item_id'], 'select' => ['short_label']]); if (!empty($copyEntities)) { - $copyEntities .= ' ; '; + $copies .= ' ; '; + } + if ($listInstance['item_type'] == 'user_id') { + $copies .= UserModel::getLabelledUserById(['login' => $listInstance['item_id']]); + } elseif ($listInstance['item_type'] == 'entity_id') { + $entity = EntityModel::getByEntityId(['entityId' => $listInstance['item_id'], 'select' => ['short_label']]); + $copies .= $entity['short_label']; } - $copyEntities .= $entity['short_label']; } - return $copyEntities; + return $copies; } private static function getTags(array $args) -- GitLab