From 22291f4ebfd46445ecbe674c6835039c26803223 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Wed, 4 Nov 2020 14:14:49 +0100
Subject: [PATCH] FEAT #15049 TIME 2 Docs + fixes

---
 bin/exportSeda/batch_tools.php     | 9 +++++++++
 bin/exportSeda/checkAllReplies.php | 5 ++++-
 bin/exportSeda/purge.php           | 1 -
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/bin/exportSeda/batch_tools.php b/bin/exportSeda/batch_tools.php
index 9d5a4f42ae8..2be12866dd5 100644
--- a/bin/exportSeda/batch_tools.php
+++ b/bin/exportSeda/batch_tools.php
@@ -351,6 +351,15 @@ function Bt_purgeAll($args = [])
             'where' => ['note_id in (select id from notes where identifier in (?))'],
             'data'  => [$args['resources']]
         ]);
+
+        $linkedResources = implode("' - '", $args['resources']);
+        \SrcCore\models\DatabaseModel::update([
+            'table'     => 'res_letterbox',
+            'postSet'   => ['linked_resources' => "linked_resources - '{$linkedResources}'"],
+            'where'     => ['linked_resources != ?'],
+            'data'      => ['[]']
+        ]);
+
         \SrcCore\models\DatabaseModel::delete([
             'table' => 'adr_attachments',
             'where' => ['res_id in (select res_id from res_attachments where res_id_master in (?))'],
diff --git a/bin/exportSeda/checkAllReplies.php b/bin/exportSeda/checkAllReplies.php
index 5baff5e7f5b..1b5bf7c5093 100755
--- a/bin/exportSeda/checkAllReplies.php
+++ b/bin/exportSeda/checkAllReplies.php
@@ -75,7 +75,6 @@ if (empty($file)) {
 $config = $file['config'];
 $GLOBALS['MaarchDirectory'] = $config['maarchDirectory'];
 $GLOBALS['customId']        = $config['customID'];
-$GLOBALS['applicationUrl']  = $config['maarchUrl'];
 $GLOBALS['batchDirectory']  = $GLOBALS['MaarchDirectory'] . 'bin/exportSeda';
 
 $config = $file['exportSeda'];
@@ -171,6 +170,10 @@ foreach ($unitIdentifiers as $reference => $value) {
             Bt_writeLog(['level' => 'ERROR', 'message' => '[storeAttachment] ' . $id['errors']]);
             continue;
         }
+        \Convert\controllers\ConvertPdfController::convert([
+            'resId'  => $id,
+            'collId' => 'attachments_coll'
+        ]);
         $status = (strpos((string)$messages['xmlContent']->ReplyCode, 'OOO')) === false ? $GLOBALS['statusReplyRejected'] : $GLOBALS['statusReplyReceived'];
         \Resource\models\ResModel::update([
             'set'   => ['status' => $status],
diff --git a/bin/exportSeda/purge.php b/bin/exportSeda/purge.php
index cdcf6a0be30..fa37203710c 100755
--- a/bin/exportSeda/purge.php
+++ b/bin/exportSeda/purge.php
@@ -75,7 +75,6 @@ if (empty($file)) {
 $config = $file['config'];
 $GLOBALS['MaarchDirectory'] = $config['maarchDirectory'];
 $GLOBALS['customId']        = $config['customID'];
-$GLOBALS['applicationUrl']  = $config['maarchUrl'];
 $GLOBALS['batchDirectory']  = $GLOBALS['MaarchDirectory'] . 'bin/exportSeda';
 
 $config = $file['exportSeda'];
-- 
GitLab