From 401cc40c1fe7ba9ddf54795db9c6962128dac472 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Fri, 25 Oct 2019 10:20:45 +0100
Subject: [PATCH] FEAT #11982 TIME 1:20 migrate nature to custom field

---
 apps/maarch_entreprise/actions/index_mlb.php  | 22 ----------
 .../actions/validate_mail.php                 | 20 ---------
 .../class_business_app_tools_Abstract.php     | 21 ----------
 .../definition_mail_categories.php            | 39 -----------------
 .../indexing_searching/search_adv.php         |  8 ----
 .../indexing_searching/search_adv_result.php  |  6 ---
 apps/maarch_entreprise/lang/en.php            |  6 ---
 apps/maarch_entreprise/lang/fr.php            |  6 ---
 apps/maarch_entreprise/lang/nl.php            |  2 -
 .../xml/IVS/validation_rules.xml              |  1 -
 apps/maarch_entreprise/xml/entreprise.xml     | 39 -----------------
 apps/maarch_entreprise/xml/print.xml          |  4 --
 core/class/PrintControler.php                 | 10 +----
 migration/19.12/1912.sql                      | 20 +++++++--
 migration/19.12/migrate.sh                    |  1 +
 migration/19.12/removeNatureFromPrint.php     | 40 ++++++++++++++++++
 modules/export_seda/RequestSeda.php           |  2 +-
 modules/export_seda/class/ArchiveTransfer.php |  2 +-
 modules/life_cycle/batch/extract_data.php     |  2 -
 modules/life_cycle/batch/extract_data_2.php   |  2 -
 .../life_cycle/batch/load_extract_data.php    | 15 -------
 .../life_cycle/batch/load_extract_data_2.php  | 15 -------
 .../datasources/letterbox_attachment.php      |  2 -
 .../controllers/SummarySheetController.php    |  3 +-
 src/app/resource/models/ResModelAbstract.php  | 42 -------------------
 25 files changed, 61 insertions(+), 269 deletions(-)
 create mode 100644 migration/19.12/removeNatureFromPrint.php

diff --git a/apps/maarch_entreprise/actions/index_mlb.php b/apps/maarch_entreprise/actions/index_mlb.php
index 75ea2d0a8d2..67a81a93f38 100755
--- a/apps/maarch_entreprise/actions/index_mlb.php
+++ b/apps/maarch_entreprise/actions/index_mlb.php
@@ -695,28 +695,6 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $c
     $frmStr .= '<input type="hidden" id="sender_recipient_type" />';
     $frmStr .= '</tr>';
 
-    /*** Nature ***/
-    $frmStr .= '<tr id="nature_id_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td><label for="nature_id" class="form_title" >'._NATURE
-            .'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><select name="nature_id" '
-            .'id="nature_id" onchange="clear_error(\'frm_error_'.$actionId
-            .'\');affiche_reference();">';
-    $frmStr .= '<option value="">'._CHOOSE_NATURE.'</option>';
-    foreach (array_keys($_SESSION['mail_natures']) as $nature) {
-        $frmStr .= '<option value="'.functions::xssafe($nature).'" with_reference = "'.$_SESSION['mail_natures_attribute'][$nature].'"';
-        if ($_SESSION['default_mail_nature'] == $nature) {
-            $frmStr .= 'selected="selected"';
-        }
-        $frmStr .= '>'.functions::xssafe($_SESSION['mail_natures'][$nature]).'</option>';
-    }
-    $frmStr .= '</select></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="nature_id_mandatory" '
-            .'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<script>$j("#nature_id").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
     /****** RECOMMANDE ******/
     $frmStr .= '<tr id="reference_number_tr" style="display:none;">';
     $frmStr .= '<td><label for="reference_number" class="form_title" >'._MONITORING_NUMBER.'</label></td>';
diff --git a/apps/maarch_entreprise/actions/validate_mail.php b/apps/maarch_entreprise/actions/validate_mail.php
index adaa008a60c..52acaa2c131 100755
--- a/apps/maarch_entreprise/actions/validate_mail.php
+++ b/apps/maarch_entreprise/actions/validate_mail.php
@@ -871,26 +871,6 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module,
     }
     $frm_str .= '</tr>';
 
-    /*** Nature ***/
-    $frm_str .= '<tr id="nature_id_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="nature_id" class="form_title" >'._NATURE.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><select name="nature_id" id="nature_id" onchange="clear_error(\'frm_error_'.$id_action.'\');affiche_reference();">';
-    $frm_str .= '<option value="">'._CHOOSE_NATURE.'</option>';
-    foreach (array_keys($_SESSION['mail_natures']) as $nature) {
-        $frm_str .= '<option value="'.functions::xssafe($nature).'"  with_reference = "'.$_SESSION['mail_natures_attribute'][$nature].'"';
-        if (isset($data['nature_id']) && $data['nature_id'] == $nature) {
-            $frm_str .= 'selected="selected"';
-        } elseif ($data['nature_id'] == '' && $_SESSION['default_mail_nature'] == $nature) {
-            $frm_str .= 'selected="selected"';
-        }
-        $frm_str .= '>'.functions::xssafe($_SESSION['mail_natures'][$nature]).'</option>';
-    }
-    $frm_str .= '</select></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="nature_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<script>$j("#nature_id").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
     /*** Recommande ***/
     $frm_str .= '<tr id="reference_number_tr" style="display:none;">';
     $frm_str .= '<td><label for="reference_number" class="form_title" >'._MONITORING_NUMBER.'</label></td>';
diff --git a/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php b/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php
index 76674fd47df..10e36f7cf72 100755
--- a/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php
+++ b/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php
@@ -447,27 +447,6 @@ abstract class business_app_tools_Abstract extends Database
             . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR
             . $_SESSION['config']['lang'] . '.php';
 
-        $_SESSION['mail_natures'] = array();
-        $_SESSION['mail_natures_attribute'] = array();
-        $_SESSION['mail_natures_third'] = [];
-        $mailNatures = $xmlfile->mail_natures;
-        if (count($mailNatures) > 0) {
-            foreach ($mailNatures->nature as $nature ) {
-                $label = (string) $nature->label;
-                $attribute = (string) $nature['with_reference'];
-                $attributeThird = (string) $nature['with_third'];
-                if (!empty($label) && defined($label)
-                    && constant($label) <> NULL
-                ) {
-                    $label = constant($label);
-                }
-                $_SESSION['mail_natures'][(string) $nature->id] = $label;
-                $_SESSION['mail_natures_attribute'][(string) $nature->id] = $attribute;
-                $_SESSION['mail_natures_third'][(string) $nature->id] = $attributeThird;
-            }
-            $_SESSION['default_mail_nature'] = (string) $mailNatures->default_nature;
-        }
-
         $_SESSION['processing_modes'] = array();
         $processingModes = $xmlfile->process_modes; 
         if(count($processingModes) > 0) {
diff --git a/apps/maarch_entreprise/definition_mail_categories.php b/apps/maarch_entreprise/definition_mail_categories.php
index 5651ea6b28f..63ea0000ca6 100755
--- a/apps/maarch_entreprise/definition_mail_categories.php
+++ b/apps/maarch_entreprise/definition_mail_categories.php
@@ -137,16 +137,6 @@ $_ENV['categories']['incoming']['departure_date'] = array (
     'modify' => true,
     'form_show' => 'date'
 );
-// $_ENV['categories']['incoming']['nature_id'] = array(
-//     'type_form' => 'string',
-//     'type_field' => 'string',
-//     'mandatory' => true,
-//     'label' => _NATURE,
-//     'table' => 'coll_ext',
-//     'img' => 'envelope',
-//     'modify' => false, //DO NOT MODIFY !
-//     'form_show' => 'select',
-// );
 $_ENV['categories']['incoming']['reference_number'] = array(
     'type_form' => 'string',
     'type_field' => 'string',
@@ -309,16 +299,6 @@ $_ENV['categories']['outgoing']['departure_date'] = array (
     'modify' => true,
     'form_show' => 'date'
 );
-// $_ENV['categories']['outgoing']['nature_id'] = array(
-//     'type_form' => 'string',
-//     'type_field' => 'string',
-//     'mandatory' => true,
-//     'label' => _NATURE,
-//     'table' => 'coll_ext',
-//     'img' => 'envelope',
-//     'modify' => false, //DO NOT MODIFY !
-//     'form_show' => 'select',
-// );
 $_ENV['categories']['outgoing']['reference_number'] = array(
     'type_form' => 'string',
     'type_field' => 'string',
@@ -472,16 +452,6 @@ $_ENV['categories']['internal']['doc_date'] = array(
     'modify' => true,
     'form_show' => 'date',
 );
-// $_ENV['categories']['internal']['nature_id'] = array(
-//     'type_form' => 'string',
-//     'type_field' => 'string',
-//     'mandatory' => true,
-//     'label' => _NATURE,
-//     'table' => 'coll_ext',
-//     'img' => 'envelope',
-//     'modify' => false, //DO NOT MODIFY !
-//     'form_show' => 'select',
-// );
 $_ENV['categories']['internal']['reference_number'] = array(
     'type_form' => 'string',
     'type_field' => 'string',
@@ -952,13 +922,6 @@ function get_general_data($coll_id, $res_id, $mode, $params = array())
                         } elseif ($field == 'destination') {
                             //require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_entities.php");
                                 // TO DO : get the entities list
-                        } elseif ($field == 'nature_id') {
-                            foreach (array_keys($_SESSION['mail_natures']) as $nature) {
-                                array_push($data[$field]['select'], array(
-                                            'ID' => $nature,
-                                            'LABEL' => $_SESSION['mail_natures'][$nature],
-                                        ));
-                            }
                         } elseif ($field == 'priority') {
                             foreach (array_keys($_SESSION['mail_priorities']) as $prio) {
                                 $data[$field]['select'][] = [
@@ -1139,8 +1102,6 @@ function get_general_data($coll_id, $res_id, $mode, $params = array())
                     $res2 = $stmt2->fetchObject();
                     $data[$arr[$i]]['show_value'] = functions::show_string($res2->entity_label, true);
                 }
-            } elseif ($arr[$i] == 'nature_id') {
-                $data[$arr[$i]]['show_value'] = $_SESSION['mail_natures'][$line->{$arr[$i]}];
             } elseif ($arr[$i] == 'reference_number') {
                 if (empty($line->{$arr[$i]})) {
                     unset($data[$arr[$i]]);
diff --git a/apps/maarch_entreprise/indexing_searching/search_adv.php b/apps/maarch_entreprise/indexing_searching/search_adv.php
index 5814994d3e7..a995758f1fb 100755
--- a/apps/maarch_entreprise/indexing_searching/search_adv.php
+++ b/apps/maarch_entreprise/indexing_searching/search_adv.php
@@ -190,14 +190,6 @@ $arr_tmp2 = array('label' => _ASSIGNEE . ' / ' . _REDACTOR, 'type' => 'select_mu
 'id' => 'destinataire', 'options' => $arr_tmp, ));
 $param['destinataire'] = $arr_tmp2;
 
-//mail_natures
-$arr_tmp = array();
-foreach (array_keys($_SESSION['mail_natures']) as $nature) {
-    array_push($arr_tmp, array('VALUE' => $nature, 'LABEL' => $_SESSION['mail_natures'][$nature]));
-}
-$arr_tmp2 = array('label' => _MAIL_NATURE, 'type' => 'select_simple', 'param' => array('field_label' => _MAIL_NATURE, 'default_label' => addslashes(_CHOOSE_MAIL_NATURE), 'options' => $arr_tmp));
-$param['mail_nature'] = $arr_tmp2;
-
 //priority
 $arr_tmp = array();
 foreach (array_keys($_SESSION['mail_priorities']) as $priority) {
diff --git a/apps/maarch_entreprise/indexing_searching/search_adv_result.php b/apps/maarch_entreprise/indexing_searching/search_adv_result.php
index da0181ee0dd..ec8d1bf90e6 100755
--- a/apps/maarch_entreprise/indexing_searching/search_adv_result.php
+++ b/apps/maarch_entreprise/indexing_searching/search_adv_result.php
@@ -504,12 +504,6 @@ where lower(translate(folders.label , 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓ
                 $json_txt .= '],';
             }
 
-            // MAIL NATURE
-            elseif ($tab_id_fields[$j] == 'mail_nature' && !empty($_REQUEST['mail_nature'])) {
-                $json_txt .= "'mail_nature' : ['".addslashes(trim($_REQUEST['mail_nature']))."'],";
-                $where_request .= " nature_id = :mailNature and ";
-                $arrayPDO = array_merge($arrayPDO, array(":mailNature" => $_REQUEST['mail_nature']));
-            }
             // CREATION DATE PJ : FROM
             elseif ($tab_id_fields[$j] == 'creation_date_pj_from' && !empty($_REQUEST['creation_date_pj_from'])) {
                 if (preg_match($_ENV['date_pattern'], $_REQUEST['creation_date_pj_from'])==false) {
diff --git a/apps/maarch_entreprise/lang/en.php b/apps/maarch_entreprise/lang/en.php
index d85566e538b..1391efc7a77 100755
--- a/apps/maarch_entreprise/lang/en.php
+++ b/apps/maarch_entreprise/lang/en.php
@@ -1875,12 +1875,6 @@ if (!defined('_DOCTYPES')) {
 if (!defined('_DOCTYPE_INDEXES')) {
     define('_DOCTYPE_INDEXES', 'Document type index');
 }
-if (!defined('_MAIL_NATURE')) {
-    define('_MAIL_NATURE', ' Nature of the sending');
-}
-if (!defined('_CHOOSE_MAIL_NATURE')) {
-    define('_CHOOSE_MAIL_NATURE', 'Choose the nature of the sending');
-}
 if (!defined('_ERROR_DOCTYPE')) {
     define('_ERROR_DOCTYPE', 'Invalid document type');
 }
diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php
index 04bc1f53f48..e9d23ff0ca2 100755
--- a/apps/maarch_entreprise/lang/fr.php
+++ b/apps/maarch_entreprise/lang/fr.php
@@ -1893,12 +1893,6 @@ if (!defined('_DOCTYPES')) {
 if (!defined('_DOCTYPE_INDEXES')) {
     define('_DOCTYPE_INDEXES', 'Index du type de document');
 }
-if (!defined('_MAIL_NATURE')) {
-    define('_MAIL_NATURE', "Nature de l'envoi");
-}
-if (!defined('_CHOOSE_MAIL_NATURE')) {
-    define('_CHOOSE_MAIL_NATURE', "Choisissez la nature de l'envoi");
-}
 if (!defined('_ERROR_DOCTYPE')) {
     define('_ERROR_DOCTYPE', 'Type de document non valide');
 }
diff --git a/apps/maarch_entreprise/lang/nl.php b/apps/maarch_entreprise/lang/nl.php
index 14a5c85d579..0655fcaff8f 100755
--- a/apps/maarch_entreprise/lang/nl.php
+++ b/apps/maarch_entreprise/lang/nl.php
@@ -604,8 +604,6 @@ if (!defined('_ERROR_IE_SEARCH')) { define('_ERROR_IE_SEARCH', 'Dit element werd
 if (!defined('_DEST_USER')) { define('_DEST_USER', 'Ontvanger');}
 if (!defined('_DOCTYPES')) { define('_DOCTYPES', 'Documenttype(s)');}
 if (!defined('_DOCTYPE_INDEXES')) { define('_DOCTYPE_INDEXES', 'Index van het documenttype');}
-if (!defined('_MAIL_NATURE')) { define('_MAIL_NATURE', 'Aard van de verzending');}
-if (!defined('_CHOOSE_MAIL_NATURE')) { define('_CHOOSE_MAIL_NATURE', 'Kies de aard van de verzending');}
 if (!defined('_ERROR_DOCTYPE')) { define('_ERROR_DOCTYPE', 'Ongeldig documenttype');}
 if (!defined('_ADMISSION_DATE')) { define('_ADMISSION_DATE', 'Aankomstdatum');}
 if (!defined('_FOUND_DOC')) { define('_FOUND_DOC', 'brieven gevonden');}
diff --git a/apps/maarch_entreprise/xml/IVS/validation_rules.xml b/apps/maarch_entreprise/xml/IVS/validation_rules.xml
index 9d42ed7413a..73a27fcf92f 100755
--- a/apps/maarch_entreprise/xml/IVS/validation_rules.xml
+++ b/apps/maarch_entreprise/xml/IVS/validation_rules.xml
@@ -349,7 +349,6 @@
       <parameter name="signatory_name_id" type="identifier" />
       <parameter name="tags_chosen" type="string" />
       <parameter name="tags_available" type="string" />
-      <parameter name="mail_nature" type="identifier" />
       <parameter name="signatory_name" type="string" />
       <parameter name="doc_notes" type="string" />
       <parameter name="chrono" type="string" />
diff --git a/apps/maarch_entreprise/xml/entreprise.xml b/apps/maarch_entreprise/xml/entreprise.xml
index 16148e7f717..31f55824593 100755
--- a/apps/maarch_entreprise/xml/entreprise.xml
+++ b/apps/maarch_entreprise/xml/entreprise.xml
@@ -1,44 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <ROOT>
-    <mail_natures>
-        <nature with_reference="false">
-            <id>simple_mail</id>
-            <label>_SIMPLE_MAIL</label>
-        </nature>
-        <nature with_reference="false">
-            <id>email</id>
-            <label>_EMAIL</label>
-        </nature>
-        <nature with_reference="false">
-            <id>fax</id>
-            <label>_FAX</label>
-        </nature>
-        <nature with_reference="true">
-            <id>chronopost</id>
-            <label>_CHRONOPOST</label>
-        </nature>
-        <nature with_reference="true">
-            <id>fedex</id>
-            <label>_FEDEX</label>
-        </nature>
-        <nature with_reference="true">
-            <id>registered_mail</id>
-            <label>_REGISTERED_MAIL</label>
-        </nature>
-        <nature with_reference="false">
-            <id>courier</id>
-            <label>_COURIER</label>
-        </nature>
-        <nature with_reference="true">
-            <id>message_exchange</id>
-            <label>_NUMERIC_PACKAGE</label>
-        </nature>
-        <nature with_reference="false">
-            <id>other</id>
-            <label>_OTHER</label>
-        </nature>
-        <default_nature>simple_mail</default_nature>
-    </mail_natures>
     <attachment_types>
         <!-- with_chrono : generate chrono if chosen -->
         <!-- attach_in_mail : appear in sendmail -->
diff --git a/apps/maarch_entreprise/xml/print.xml b/apps/maarch_entreprise/xml/print.xml
index 141441ebf61..08a97907f4d 100644
--- a/apps/maarch_entreprise/xml/print.xml
+++ b/apps/maarch_entreprise/xml/print.xml
@@ -31,10 +31,6 @@
             <LIBELLE>Date de création</LIBELLE>
             <DATABASE_FIELD>creation_date</DATABASE_FIELD>
         </FIELD>
-        <FIELD>
-            <LIBELLE>Nature du courrier</LIBELLE>
-            <DATABASE_FIELD>nature_id</DATABASE_FIELD>
-        </FIELD>
         <!-- line 4 -->
         <FIELD>
             <LIBELLE>Date du document</LIBELLE>
diff --git a/core/class/PrintControler.php b/core/class/PrintControler.php
index 0d7e5c73db6..38e01cbd069 100644
--- a/core/class/PrintControler.php
+++ b/core/class/PrintControler.php
@@ -335,19 +335,11 @@ class PrintControler extends PrintFunctions
 				}
 				
 				//LINE 3, 4
-				if ($this->array_print[$cpt]['nature_id'] <> '' || $this->array_print[$cpt]['doc_date'] <> '') {
+				if ($this->array_print[$cpt]['doc_date'] <> '') {
 					//CREATION DATE
 					$pdf->Cell(91,5,utf8_decode(_CREATED_ON . ' : ') 
 						. $functions->format_date_db($this->array_print[$cpt]['creation_date'], false),1,0, 'L', false);
 					
-					//NATURE
-					foreach (array_keys($_SESSION['mail_natures']) as $nature) {
-						if ($this->array_print[$cpt]['nature_id'] == $nature) {
-							$this->array_print[$cpt]['nature_id'] = $_SESSION['mail_natures'][$nature];
-						}
-					}
-					$pdf->Cell(91,5,utf8_decode(_NATURE . ' : ' . $this->array_print[$cpt]['nature_id']),1,1, 'L', false);
-					
 					//DOC DATE
 					$pdf->Cell(91,5,utf8_decode(_PRINT_DOC_DATE . ' : ') 
 						. $functions->format_date_db($this->array_print[$cpt]['doc_date'], false),1,0, 'L', false);
diff --git a/migration/19.12/1912.sql b/migration/19.12/1912.sql
index 80dccdd38bc..da310122551 100644
--- a/migration/19.12/1912.sql
+++ b/migration/19.12/1912.sql
@@ -484,10 +484,22 @@ CREATE VIEW res_view_attachments AS
 
 /* DATA */
 TRUNCATE TABLE custom_fields;
-INSERT INTO custom_fields (id, label, type, values) VALUES (1, 'Nature', 'select', '["Courrier simple", "Courriel", "Chronopost", "Pli numérique"]');
+INSERT INTO custom_fields (id, label, type, values) VALUES (1, 'Nature', 'select', '["Courrier simple", "Courriel", "Courrier suivi", "Courrier avec AR", "Autre"]');
 INSERT INTO custom_fields (id, label, type, values) VALUES (2, 'N° recommandé', 'string', '[]');
 SELECT setval('custom_fields_id_seq', (select max(id)+1 from custom_fields), false);
 
+TRUNCATE TABLE resources_custom_fields;
+INSERT INTO resources_custom_fields (res_id, custom_field_id, value)  
+SELECT res_id, 1, '"Courrier simple"' FROM mlb_coll_ext WHERE nature_id = 'simple_mail';
+INSERT INTO resources_custom_fields (res_id, custom_field_id, value)  
+SELECT res_id, 1, '"Courriel"' FROM mlb_coll_ext WHERE nature_id = 'email';
+INSERT INTO resources_custom_fields (res_id, custom_field_id, value)  
+SELECT res_id, 1, '"Autre"' FROM mlb_coll_ext WHERE nature_id IN ('fax', 'other', 'courier');
+INSERT INTO resources_custom_fields (res_id, custom_field_id, value)  
+SELECT res_id, 1, '"Courrier suivi"' FROM mlb_coll_ext WHERE nature_id IN ('chronopost', 'fedex');
+INSERT INTO resources_custom_fields (res_id, custom_field_id, value)  
+SELECT res_id, 1, '"Courrier avec AR"' FROM mlb_coll_ext WHERE nature_id = 'registered_mail';
+
 TRUNCATE TABLE indexing_models;
 INSERT INTO indexing_models (id, category, label, "default", owner, private) VALUES (1, 'incoming', 'Courrier arrivée', TRUE, 23, FALSE);
 INSERT INTO indexing_models (id, category, label, "default", owner, private) VALUES (2, 'outgoing', 'Courrier départ', FALSE, 23, FALSE);
@@ -503,7 +515,7 @@ INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_val
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'documentDate', TRUE, null, 'mail');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'arrivalDate', TRUE, null, 'mail');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'subject', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'indexingCustomField_1', FALSE, null, 'mail');
+INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'indexingCustomField_1', FALSE, '"Courrier simple"', 'mail');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'senders', TRUE, null, 'contact');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'getRecipients', FALSE, null, 'contact');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'initiator', TRUE, null, 'process');
@@ -519,7 +531,7 @@ INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_val
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'documentDate', TRUE, null, 'mail');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'departureDate', TRUE, null, 'mail');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'subject', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'indexingCustomField_1', FALSE, null, 'mail');
+INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'indexingCustomField_1', FALSE, '"Courrier simple"', 'mail');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'senders', FALSE, null, 'contact');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'getRecipients', TRUE, null, 'contact');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'initiator', TRUE, null, 'process');
@@ -534,7 +546,7 @@ INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_val
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'confidential', TRUE, null, 'mail');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'documentDate', TRUE, null, 'mail');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'subject', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'indexingCustomField_1', FALSE, null, 'mail');
+INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'indexingCustomField_1', FALSE, '"Courrier simple"', 'mail');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'senders', FALSE, null, 'contact');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'getRecipients', FALSE, null, 'contact');
 INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'initiator', TRUE, null, 'process');
diff --git a/migration/19.12/migrate.sh b/migration/19.12/migrate.sh
index 4a369dc1705..d980699a066 100755
--- a/migration/19.12/migrate.sh
+++ b/migration/19.12/migrate.sh
@@ -17,3 +17,4 @@ php ./migrateOldIndexingModels.php
 php ./migrateWorkingDays.php
 php ./migrateExtensions.php
 php ./migrateM2MConfiguration.php
+php ./removeNatureFromPrint.php
\ No newline at end of file
diff --git a/migration/19.12/removeNatureFromPrint.php b/migration/19.12/removeNatureFromPrint.php
new file mode 100644
index 00000000000..d7c72ee11ec
--- /dev/null
+++ b/migration/19.12/removeNatureFromPrint.php
@@ -0,0 +1,40 @@
+<?php
+
+require '../../vendor/autoload.php';
+
+chdir('../..');
+
+$migrated = 0;
+$customs =  scandir('custom');
+foreach ($customs as $custom) {
+    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
+        continue;
+    }
+
+    $xmlfile = null;
+    $path = "custom/{$custom}/apps/maarch_entreprise/xml/print.xml";
+    if (file_exists($path)) {
+        $xmlfile = simplexml_load_file($path);
+
+        if ($xmlfile) {
+            $i = 0;
+            foreach ($xmlfile->letterbox_coll->FIELD as $field) {
+                if ($field->DATABASE_FIELD == 'nature_id') {
+                    unset($xmlfile->letterbox_coll->FIELD[$i]);
+                    break;
+                }
+                $i++;
+            }
+
+            $res = $xmlfile->asXML();
+            $fp = fopen($path, "w+");
+            if ($fp) {
+                fwrite($fp, $res);
+            }
+
+            $migrated++;
+        }
+    }
+}
+
+printf("Remove Nature : " . $migrated . " custom(s) avec un fichier print.xml trouvé(s) et migré(s).\n");
diff --git a/modules/export_seda/RequestSeda.php b/modules/export_seda/RequestSeda.php
index 0fce89544d0..b40358cd8a6 100755
--- a/modules/export_seda/RequestSeda.php
+++ b/modules/export_seda/RequestSeda.php
@@ -93,7 +93,7 @@ class RequestSeda
         $query = "SELECT destination FROM res_letterbox WHERE res_id = ?";
         $this->statement['getDestinationLetter'] = $this->db->prepare($query);
 
-        $query = "SELECT res_id, contact_id, filename, docserver_id, path, creation_date, modification_date, type_id, doc_date, admission_date, creation_date, exp_contact_id, dest_contact_id, destination, nature_id, type_label, alt_identifier, subject, title
+        $query = "SELECT res_id, contact_id, filename, docserver_id, path, creation_date, modification_date, type_id, doc_date, admission_date, creation_date, exp_contact_id, dest_contact_id, destination, type_label, alt_identifier, subject
                   FROM res_view_letterbox
                   WHERE res_id = ?";
         $this->statement['getLetter'] = $this->db->prepare($query);
diff --git a/modules/export_seda/class/ArchiveTransfer.php b/modules/export_seda/class/ArchiveTransfer.php
index 38ace00df04..87de4f2a7a5 100755
--- a/modules/export_seda/class/ArchiveTransfer.php
+++ b/modules/export_seda/class/ArchiveTransfer.php
@@ -551,7 +551,7 @@ class ArchiveTransfer
                     $content->Addressee[] = $addressee;
                 }
 
-                $content->Source = $_SESSION['mail_nature'][$object->nature_id];
+                $content->Source = '';
 
                 $content->DocumentType = $object->type_label;
                 $content->OriginatingAgencyArchiveUnitIdentifier = $object->alt_identifier;
diff --git a/modules/life_cycle/batch/extract_data.php b/modules/life_cycle/batch/extract_data.php
index 0e5236ab3c5..17a5a94fc25 100755
--- a/modules/life_cycle/batch/extract_data.php
+++ b/modules/life_cycle/batch/extract_data.php
@@ -83,7 +83,6 @@ try {
             "Date d'arrivée", 
             "Objet du courrier", 
             "Type du courrier", 
-            "Nature", 
             "Département",  //5
             "Mots clés", 
             "Thème", 
@@ -366,7 +365,6 @@ try {
                 format_date_db(str_replace("/", "-",$selectedFile->admission_date), "", $GLOBALS['databasetype']),
                 $selectedFile->subject,             
                 $selectedFile->type_label,
-                $GLOBALS['mail_natures'][$selectedFile->nature_id],
                 $department_name,  //5
                 $labelTags,
                 $selectedFile->folder_name, 
diff --git a/modules/life_cycle/batch/extract_data_2.php b/modules/life_cycle/batch/extract_data_2.php
index 47a6db9658b..67bd77a9d05 100755
--- a/modules/life_cycle/batch/extract_data_2.php
+++ b/modules/life_cycle/batch/extract_data_2.php
@@ -84,7 +84,6 @@ try {
             "Objet du courrier", 
             "Catégorie",
             "Type du courrier", 
-            "Nature", 
             "Département",  //5
             "Thésaurus", 
             "Thème", 
@@ -481,7 +480,6 @@ try {
                 $selectedFile->subject,             
                 $selectedFile->category_id,
                 $selectedFile->type_label,
-                $GLOBALS['mail_natures'][$selectedFile->nature_id],
                 $department_name,  //5
                 $parentFolder,
                 $selectedFile->folder_name,//"Sous Thème", 
diff --git a/modules/life_cycle/batch/load_extract_data.php b/modules/life_cycle/batch/load_extract_data.php
index 893e60b89e1..68ab89c56ee 100755
--- a/modules/life_cycle/batch/load_extract_data.php
+++ b/modules/life_cycle/batch/load_extract_data.php
@@ -315,21 +315,6 @@ if (count($mailPriorities) > 0) {
     }
 }
 
-$GLOBALS['mail_natures'] = array();
-$mailNatures = $xml_entreprise->mail_natures;
-if (count($mailNatures) > 0) {
-    foreach ($mailNatures->nature as $nature ) {
-        $label = (string) $nature->label;
-        $attribute = (string) $nature->attributes();
-        if (!empty($label) && defined($label)
-            && constant($label) <> NULL
-         ) {
-            $label = constant($label);
-        }
-        $GLOBALS['mail_natures'][(string) $nature->id] = $label;
-    }
-}
-
 $GLOBALS['mail_titles'] = array();
 $mailTitles = $xml_entreprise->titles;
 if (count($mailTitles) > 0) {
diff --git a/modules/life_cycle/batch/load_extract_data_2.php b/modules/life_cycle/batch/load_extract_data_2.php
index 583b3380621..75d8c331050 100755
--- a/modules/life_cycle/batch/load_extract_data_2.php
+++ b/modules/life_cycle/batch/load_extract_data_2.php
@@ -324,21 +324,6 @@ if (count($mailPriorities) > 0) {
     }
 }
 
-$GLOBALS['mail_natures'] = array();
-$mailNatures = $xml_entreprise->mail_natures;
-if (count($mailNatures) > 0) {
-    foreach ($mailNatures->nature as $nature ) {
-        $label = (string) $nature->label;
-        $attribute = (string) $nature->attributes();
-        if (!empty($label) && defined($label)
-            && constant($label) <> NULL
-         ) {
-            $label = constant($label);
-        }
-        $GLOBALS['mail_natures'][(string) $nature->id] = $label;
-    }
-}
-
 $GLOBALS['mail_titles'] = array();
 $mailTitles = $xml_entreprise->titles;
 if (count($mailTitles) > 0) {
diff --git a/modules/templates/datasources/letterbox_attachment.php b/modules/templates/datasources/letterbox_attachment.php
index fd1d309ffee..f7485e11ddd 100755
--- a/modules/templates/datasources/letterbox_attachment.php
+++ b/modules/templates/datasources/letterbox_attachment.php
@@ -33,8 +33,6 @@ if (!empty($res_id)) {
 
     $doc['category_id'] = html_entity_decode($_SESSION['coll_categories']['letterbox_coll'][$doc['category_id']]);
 
-    $doc['nature_id'] = $_SESSION['mail_natures'][$doc['nature_id']];
-
     //INITIATOR INFO OF DOCUMENT
     $stmt2 = $dbDatasource->query('SELECT a.*, b.entity_label as parent_entity_label
     FROM entities as a, entities as b
diff --git a/src/app/resource/controllers/SummarySheetController.php b/src/app/resource/controllers/SummarySheetController.php
index a7177cefd31..6d87fdfe634 100755
--- a/src/app/resource/controllers/SummarySheetController.php
+++ b/src/app/resource/controllers/SummarySheetController.php
@@ -219,8 +219,7 @@ class SummarySheetController
         }
         foreach ($units as $key => $unit) {
             if ($unit['unit'] == 'primaryInformations') {
-                $nature        = ResModel::getNatureLabel(['natureId' => '']);
-                $nature        = empty($nature) ? '<i>'._UNDEFINED.'</i>' : "<b>{$nature}</b>";
+                $nature        = '<i>'._UNDEFINED.'</i>';
                 $admissionDate = TextFormatModel::formatDate($resource['admission_date'], 'd-m-Y');
                 $admissionDate = empty($admissionDate) ? '<i>'._UNDEFINED.'</i>' : "<b>{$admissionDate}</b>";
                 $creationdate  = TextFormatModel::formatDate($resource['creation_date'], 'd-m-Y');
diff --git a/src/app/resource/models/ResModelAbstract.php b/src/app/resource/models/ResModelAbstract.php
index 8ca9e91587b..e201b3d44f9 100755
--- a/src/app/resource/models/ResModelAbstract.php
+++ b/src/app/resource/models/ResModelAbstract.php
@@ -230,48 +230,6 @@ abstract class ResModelAbstract
         return '';
     }
 
-    public static function getNatures()
-    {
-        static $natures;
-
-        if (!empty($natures)) {
-            return $natures;
-        }
-
-        $natures = [];
-
-        $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/entreprise.xml']);
-        if ($loadedXml) {
-            foreach ($loadedXml->mail_natures->nature as $nature) {
-                $withReference = (string)$nature['with_reference'] == 'true' ? true : false;
-                $nature = (array)$nature;
-
-                $natures[] = [
-                    'id'            => $nature['id'],
-                    'label'         => defined($nature['label']) ? constant($nature['label']) : $nature['label'],
-                    'withReference' => $withReference,
-                    'defaultNature' => $nature['id'] == $loadedXml->mail_natures->default_nature
-                ];
-            }
-        }
-
-        return $natures;
-    }
-
-    public static function getNatureLabel(array $args)
-    {
-        ValidatorModel::stringType($args, ['natureId']);
-
-        $natures = ResModel::getNatures();
-        foreach ($natures as $nature) {
-            if ($nature['id'] == $args['natureId']) {
-                return $nature['label'];
-            }
-        }
-
-        return '';
-    }
-
     public static function getNbContactsByResId(array $aArgs)
     {
         ValidatorModel::notEmpty($aArgs, ['resId']);
-- 
GitLab