From f9aac4c8f2dd5e1848023f07a5a58b906aae70c4 Mon Sep 17 00:00:00 2001
From: Nathan Cheval <nathan.cheval@outlook.fr>
Date: Tue, 18 Dec 2018 18:04:26 +0100
Subject: [PATCH] delete tablename in attachment config file

---
 modules/attachments/add_attachments.php       |  2 -
 .../class/class_modules_tools_Abstract.php    |  6 --
 modules/attachments/fill_input.php            |  4 -
 modules/attachments/lang/fr.php               |  4 +
 modules/attachments/remove_letterbox.php      |  4 +-
 modules/attachments/xml/config.xml            | 82 +++++++++----------
 6 files changed, 43 insertions(+), 59 deletions(-)

diff --git a/modules/attachments/add_attachments.php b/modules/attachments/add_attachments.php
index 19b2566408c..3df6f1ca425 100755
--- a/modules/attachments/add_attachments.php
+++ b/modules/attachments/add_attachments.php
@@ -10,8 +10,6 @@ $core = new core_tools();
 $core->test_user();
 $db = new Database();
 
-$letterboxTable = $_SESSION['tablename']['reconciliation']['letterbox'];
-
 // Retrieve the parent res_id (the document which receive the attachment) and the res_id of the attachment we will inject
 $parentResId = $_SESSION['stockCheckbox'];
 $childResId = $_SESSION['doc_id'];
diff --git a/modules/attachments/class/class_modules_tools_Abstract.php b/modules/attachments/class/class_modules_tools_Abstract.php
index efec46fde82..b4d2eda985f 100755
--- a/modules/attachments/class/class_modules_tools_Abstract.php
+++ b/modules/attachments/class/class_modules_tools_Abstract.php
@@ -85,11 +85,5 @@ abstract class attachments_Abstract
         $_SESSION['modules_loaded']['attachments']['reconciliation']['attach_to_empty'] = (string)$reconciliation->attach_to_empty;
         $_SESSION['modules_loaded']['attachments']['reconciliation']['delete_response_project'] = (string)$reconciliation->delete_response_project;
         $_SESSION['modules_loaded']['attachments']['reconciliation']['close_incoming'] = (string)$reconciliation->close_incoming;
-
-        $reconciliationTab = $xmlconfig->RECONCILIATION->TABLENAME;
-        $_SESSION['tablename']['reconciliation']['attachment'] = (string)$reconciliationTab->attachment;
-        $_SESSION['tablename']['reconciliation']['letterbox'] = (string)$reconciliationTab->letterbox;
-        $_SESSION['tablename']['reconciliation']['contacts_v2'] = (string)$reconciliationTab->contacts_v2;
-        $_SESSION['tablename']['reconciliation']['contact_addresses'] = (string)$reconciliationTab->contact_addresses;
     }
 }
diff --git a/modules/attachments/fill_input.php b/modules/attachments/fill_input.php
index c4e77fe6cf8..1c531507bd2 100755
--- a/modules/attachments/fill_input.php
+++ b/modules/attachments/fill_input.php
@@ -14,10 +14,6 @@ $db = new Database();
 // Get informations from config.xml
 $multiple_res_id = $_SESSION['modules_loaded']['attachments']['reconciliation']['multiple_res_id'];
 $attach_to_empty = $_SESSION['modules_loaded']['attachments']['reconciliation']['attach_to_empty'];
-$attachmentTable = $_SESSION['tablename']['reconciliation']['attachment'];
-$letterboxTable = $_SESSION['tablename']['reconciliation']['letterbox'];
-$contactsV2Table = $_SESSION['tablename']['reconciliation']['contacts_v2'];
-$contactsAddressesTable = $_SESSION['tablename']['reconciliation']['contact_addresses'];
 
 // If no documents are choosen, force the user to modify his choice by going back in the modal window
 // If multiple documents are choose, the user have to enter manually the chrono number, the title and the recipient
diff --git a/modules/attachments/lang/fr.php b/modules/attachments/lang/fr.php
index 394cc979d7d..624b5b6b733 100755
--- a/modules/attachments/lang/fr.php
+++ b/modules/attachments/lang/fr.php
@@ -273,6 +273,10 @@ if (!defined('_SAME_RES_ID_ERROR')) {
     define('_SAME_RES_ID_ERROR', 'L\'Un des courriers sélectionnés est le même que le document courant, veuillez le désélectionner');
 }
 
+if (!defined('_NO_ATTACHMENT_CHRONO')) {
+    define('_NO_ATTACHMENT_CHRONO', 'Pas de pièces jointes pour ce numéro de chrono');
+}
+
 /************** INTERFACE ***********/
 
 if (!defined('_GENERATE_CHRONO_NUMBER')) {
diff --git a/modules/attachments/remove_letterbox.php b/modules/attachments/remove_letterbox.php
index f3a9914a5fa..923c7b02b49 100755
--- a/modules/attachments/remove_letterbox.php
+++ b/modules/attachments/remove_letterbox.php
@@ -13,8 +13,6 @@ $core->test_user();
 // Variable declaration
 $res_id = $_SESSION['doc_id'];
 $res_id_master = $_SESSION['stockCheckbox'];
-$letterboxTable = $_SESSION['tablename']['reconciliation']['letterbox'];
-$attachmentTable = $_SESSION['tablename']['reconciliation']['attachment'];
 $delete_response_project = $_SESSION['modules_loaded']['attachments']['reconciliation']['delete_response_project'];
 $close_incoming = $_SESSION['modules_loaded']['attachments']['reconciliation']['close_incoming'];
 
@@ -31,7 +29,7 @@ $tabFormValues = $_SESSION['modules_loaded']['attachments']['reconciliation']['t
 if($delete_response_project == 'true'){
     \SrcCore\models\DatabaseModel::update([
         'set'       => ['status' => 'DEL'],
-        'table'     => $attachmentTable,
+        'table'     => 'res_attachments',
         'where'     => ["res_id_master = ? AND identifier = ? AND status NOT IN ('DEL','TMP') AND attachment_type = 'response_project'"],
         'data'      => [$res_id_master[0], $tabFormValues['chrono_number']],
     ]);
diff --git a/modules/attachments/xml/config.xml b/modules/attachments/xml/config.xml
index f112103ab92..342909b790d 100755
--- a/modules/attachments/xml/config.xml
+++ b/modules/attachments/xml/config.xml
@@ -1,44 +1,38 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
-	<CONFIG>
-		<name>attachments</name>
-		<comment>_ATTACHMENTS_COMMENT</comment>
-		<file_prefix>attach</file_prefix>
-		<convertPdf>false</convertPdf> <!-- true = convert with applet, false = convert server-side -->
-		<vbs_convert_path></vbs_convert_path> <!-- Path to VBS file if necessary. ex: C:\Program Files (x86)\Outils SPM\DOC2PDF_VBS.vbs . Default : %HOME_DIR%\maarchTmp\DOC2PDF_VBS.vbs -->
-		<useExeConvert>false</useExeConvert>
-		<loaded>true</loaded>
-		<watermark>
-			<enabled>false</enabled> <!-- If true, a watermark is applied on the document /!\ WARNING /!\ BUG WITH SIGNATUREBOOK IF TRUE -->
-			<text>Copie conforme de [identifier] au statut [status] le [date_now] [hour_now]</text> <!-- text with fusion fields [column_name] or [date_now], ex : [identifier] with status [status] the [date_now] [hour_now]-->
-			<position>30,35,0,0.5</position> <!-- Setup position with X, Y, angle, opacity ; ex : 50,450,30,0.5 -->
-			<font>helvetica,10</font> <!-- Setup the font name and her size, ex: helvetica,10 -->
-			<text_color>20,192,30</text_color> <!-- Setup the color of the text, ex: 192,192,192 -->
-		</watermark>
-	</CONFIG>
-	<TABLENAME>
-		<attach_res_attachments>res_attachments</attach_res_attachments>
-	</TABLENAME>
-	<HISTORY>
-		<attachadd>true</attachadd>
-		<attachup>true</attachup>
-		<attachdel>true</attachdel>
-		<attachview>true</attachview>
-	</HISTORY>
-	<RECONCILIATION>
-		<CONFIG>
-			<name>reconciliation</name>
-			<comment>_RECONCILIATION_COMMENT</comment>
-			<multiple_res_id>true</multiple_res_id> <!-- Setting allowing, or not, the reconciliation of an attachment to multiple documents -->
-			<attach_to_empty>true</attach_to_empty> <!-- Setting allowing, or not, the reconciliation of an attachment to a document without response project -->
-			<delete_response_project>true</delete_response_project> <!-- Setting allowing, or not, the automatic deletion of the response project, thanks to his chrono number -->
-			<close_incoming>true</close_incoming> <!-- Setting allowing, or not, the possibility to close the incoming document, with a radio button-->
-		</CONFIG>
-		<TABLENAME>
-			<attachment>res_attachments</attachment>
-			<letterbox>res_letterbox</letterbox>
-			<contacts_v2>contacts_v2</contacts_v2>
-			<contact_addresses>contact_addresses</contact_addresses>
-		</TABLENAME>
-	</RECONCILIATION>
-</root>
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+	<CONFIG>
+		<name>attachments</name>
+		<comment>_ATTACHMENTS_COMMENT</comment>
+		<file_prefix>attach</file_prefix>
+		<convertPdf>false</convertPdf> <!-- true = convert with applet, false = convert server-side -->
+		<vbs_convert_path></vbs_convert_path> <!-- Path to VBS file if necessary. ex: C:\Program Files (x86)\Outils SPM\DOC2PDF_VBS.vbs . Default : %HOME_DIR%\maarchTmp\DOC2PDF_VBS.vbs -->
+		<useExeConvert>false</useExeConvert>
+		<loaded>true</loaded>
+		<watermark>
+			<enabled>false</enabled> <!-- If true, a watermark is applied on the document /!\ WARNING /!\ BUG WITH SIGNATUREBOOK IF TRUE -->
+			<text>Copie conforme de [identifier] au statut [status] le [date_now] [hour_now]</text> <!-- text with fusion fields [column_name] or [date_now], ex : [identifier] with status [status] the [date_now] [hour_now]-->
+			<position>30,35,0,0.5</position> <!-- Setup position with X, Y, angle, opacity ; ex : 50,450,30,0.5 -->
+			<font>helvetica,10</font> <!-- Setup the font name and her size, ex: helvetica,10 -->
+			<text_color>20,192,30</text_color> <!-- Setup the color of the text, ex: 192,192,192 -->
+		</watermark>
+	</CONFIG>
+	<TABLENAME>
+		<attach_res_attachments>res_attachments</attach_res_attachments>
+	</TABLENAME>
+	<HISTORY>
+		<attachadd>true</attachadd>
+		<attachup>true</attachup>
+		<attachdel>true</attachdel>
+		<attachview>true</attachview>
+	</HISTORY>
+	<RECONCILIATION>
+		<CONFIG>
+			<name>reconciliation</name>
+			<comment>_RECONCILIATION_COMMENT</comment>
+			<multiple_res_id>true</multiple_res_id> <!-- Setting allowing, or not, the reconciliation of an attachment to multiple documents -->
+			<attach_to_empty>true</attach_to_empty> <!-- Setting allowing, or not, the reconciliation of an attachment to a document without response project -->
+			<delete_response_project>true</delete_response_project> <!-- Setting allowing, or not, the automatic deletion of the response project, thanks to his chrono number -->
+			<close_incoming>true</close_incoming> <!-- Setting allowing, or not, the possibility to close the incoming document, with a radio button-->
+		</CONFIG>
+	</RECONCILIATION>
+</root>
-- 
GitLab