diff --git a/apps/maarch_entreprise/actions/index_mlb.php b/apps/maarch_entreprise/actions/index_mlb.php
deleted file mode 100755
index 6fdd4530579bb092b088d52b9171f0bed9423a5f..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/index_mlb.php
+++ /dev/null
@@ -1,2007 +0,0 @@
-<?php
-/**
-* Copyright Maarch since 2008 under licence GPLv3.
-* See LICENCE.txt file at the root folder for more details.
-* This file is part of Maarch software.
-
-*
-* @brief   index_mlb
-*
-* @author  dev <dev@maarch.org>
-* @ingroup apps
-*/
-
-//$_SESSION['validStep'] = "ko";
-include_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'definition_mail_categories.php';
-require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php';
-require_once 'core'.DIRECTORY_SEPARATOR.'core_tables.php';
-require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php';
-require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_resource.php';
-require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_business_app_tools.php';
-require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_types.php';
-require_once 'modules'.DIRECTORY_SEPARATOR.'basket'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_modules_tools.php';
-require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_indexing_searching_app.php';
-require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'docservers_controler.php';
-require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_chrono.php';
-require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php';
-require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_contacts_v2.php';
-
-$_SESSION['is_multi_contact'] = '';
-unset($_SESSION['m_admin']['contact']);
-
-$core = new core_tools();
-$contacts_v2 = new contacts_v2();
-if ($core->is_module_loaded('entities')) {
-    require_once 'modules/entities/entities_tables.php';
-}
-
-/**
- * $confirm  bool false.
- */
-$confirm = false;
-/**
- * $etapes  array Contains only one etap : form.
- */
-$etapes = array('form');
-/**
- * $frm_width  Width of the modal (empty).
- */
-$frm_width = '';
-/**
- * $frm_height  Height of the modal (empty).
- */
-$frm_height = '';
-/**
- * $mode_form  Mode of the modal : fullscreen.
- */
-$mode_form = 'fullscreen';
-/**
- * Returns the indexing form text.
- *
- * @param $values Array Not used here
- * @param $pathManageAction String Path to the PHP file called in Ajax
- * @param $actionId String Action identifier
- * @param $table String Table
- * @param $module String Origin of the action
- * @param $collId String Collection identifier
- * @param $mode String Action mode 'mass' or 'page'
- *
- * @return string The form content text
- **/
-function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $collId, $mode)
-{
-    $_SESSION['category_id'] = '';
-    $displayValue = 'table-row';
-    //DECLARATIONS
-
-    //INSTANTIATE
-    $type = new types();
-    $core = new core_tools();
-    $db = new Database();
-
-    //INITIALIZE
-    $frmStr = '';
-    $_SESSION['stockCheckbox'] = '';
-    $_SESSION['req'] = 'action';
-    $resId = $values[0];
-    $today = date('d-m-Y');
-    $statuses = array();
-    $_SESSION['adresses']['to'] = array();
-    $_SESSION['adresses']['contactid'] = array();
-    $_SESSION['adresses']['addressid'] = array();
-
-    if ($_SESSION['features']['show_types_tree'] == 'true') {
-        $doctypes = $type->getArrayStructTypes($collId);
-    } else {
-        $doctypes = $type->getArrayTypes($collId);
-    }
-
-    if ($core->is_module_loaded('entities')) {
-        require_once 'modules'.DIRECTORY_SEPARATOR.'entities'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_manage_entities.php';
-
-        $ent = new entity();
-
-        $allEntitiesTree = array();
-        $EntitiesIdExclusion = array();
-        if (!empty($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$actionId]['entities'])) {
-            $stmt = $db->query(
-                'SELECT entity_id FROM '
-                .ENT_ENTITIES.' WHERE entity_id not in ('
-                .$_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$actionId]['entities']
-                .") and enabled= 'Y' order by entity_id"
-            );
-
-            while ($res = $stmt->fetchObject()) {
-                array_push($EntitiesIdExclusion, $res->entity_id);
-            }
-        }
-
-        //diffusion list in this basket ?
-        if ($_SESSION['current_basket']['difflist_type'] == 'entity_id') {
-            $target_model = 'document.getElementById(\'destination\').options[document.getElementById(\'destination\').selectedIndex]';
-        } elseif ($_SESSION['current_basket']['difflist_type'] == 'type_id') {
-            $target_model = 'document.getElementById(\'type_id\').options[document.getElementById(\'type_id\').selectedIndex]';
-            $func_load_listdiff = 'load_listmodel('.$target_model.', \'diff_list_div\', \'indexing\',  $j(\'#category_id\').val());';
-        } else {
-            $target_model = 'document.getElementById(\'destination\').options[document.getElementById(\'destination\').selectedIndex]';
-        }
-
-        //var_dump($EntitiesIdExclusion);
-        $allEntitiesTree = $ent->getShortEntityTreeAdvanced(
-            $allEntitiesTree,
-            'all',
-            '',
-            $EntitiesIdExclusion,
-            'all'
-        );
-    }
-
-    // Select statuses from groupbasket
-
-    /* Basket of ABS users */
-    if ($_SESSION['current_basket']['abs_basket'] == '1') {
-        $query = "SELECT group_id FROM usergroup_content WHERE user_id=? AND primary_group='Y'";
-        $stmt = $db->query($query, array($_SESSION['current_basket']['basket_owner']));
-        $grp_status = $stmt->fetchObject();
-        $owner_usr_grp = $grp_status->group_id;
-        $owner_basket_id = str_replace('_'.$_SESSION['current_basket']['basket_owner'], '', $_SESSION['current_basket']['id']);
-    } else {
-        $owner_usr_grp = $_SESSION['current_basket']['group_id'];
-        $owner_basket_id = $_SESSION['current_basket']['id'];
-    }
-    $query = 'SELECT status_id, label_status FROM groupbasket_status left join status on status_id = id '
-        .' WHERE basket_id= ? and (group_id = ?) and action_id = ? ORDER BY groupbasket_status.order';
-    $stmt = $db->query($query, array($owner_basket_id, $owner_usr_grp, $actionId));
-
-    if ($stmt->rowCount() > 0) {
-        while ($status = $stmt->fetchObject()) {
-            $statuses[] = array(
-                'ID' => $status->status_id,
-                'LABEL' => functions::show_string($status->label_status),
-            );
-        }
-    }
-
-    $frmStr .= '<form name="index_file" method="post" id="index_file" action="#"'
-            .' class="forms indexingform" style="text-align:left;width:100%;">';
-    //MODAL HEADER
-    $frmStr .= '<div style="margin:-10px;margin-bottom:10px;background-color: #135F7F;">';
-    $frmStr .= '<h2 class="tit" id="action_title" style="display:table-cell;vertical-align:middle;margin:0px;">'._INDEXING_MLB.' : ';
-    $frmStr .= '</h2>';
-    $frmStr .= '<div style="display:table-cell;vertical-align:middle;">';
-
-    //GET ACTION LIST BY AJAX REQUEST
-    $frmStr .= '<span id="actionSpan"></span>';
-
-    $frmStr .= '<input type="button" name="send" id="send" value="'
-            ._VALIDATE.'" class="button" '
-            .'onclick="getIframeContent(\''
-            .$_SESSION['config']['businessappurl'].'index.php?display=true'
-            .'&page=getIframeTemplateContent\');if(document.getElementById(\'contactcheck\').value!=\'success\'){if (confirm(\''._CONTACT_CHECK.'\n\nContinuer ?\'))valid_action_form(\'index_file\', \''
-            .$pathManageAction.'\', \''.$actionId.'\', \''.$resId
-            .'\', \''.$table.'\', \''.$module.'\', \''.$collId
-            .'\', \''.$mode.'\', true);}else{valid_action_form(\'index_file\', \''
-            .$pathManageAction.'\', \''.$actionId.'\', \''.$resId
-            .'\', \''.$table.'\', \''.$module.'\', \''.$collId
-            .'\', \''.$mode.'\', true);}"/> ';
-    $frmStr .= '</div>';
-    $frmStr .= '</div>';
-
-    $frmStr .= '<i onmouseover="this.style.cursor=\'pointer\';" '.
-             'onclick="javascript:window.top.location.href=\''
-            .$_SESSION['config']['businessappurl'].'index.php\';reinit();" class="fa fa-times-circle fa-2x closeModale" title="'._CLOSE.'"/>';
-    $frmStr .= '</i>';
-
-    $frmStr .= '<div style="height:90vh;overflow:auto;">';
-    $frmStr .= '<div id="validleft">';
-    $frmStr .= '<div id="index_div" style="display:none;";>';
-
-    $frmStr .= '<div id="frm_error_'.$actionId.'" class="indexing_error">'
-            .'</div>';
-    $frmStr .= '<input type="hidden" name="values" id="values" value="'.$resId
-            .'" />';
-    $frmStr .= '<input type="hidden" name="action_id" id="action_id" value="'
-            .$actionId.'" />';
-    $frmStr .= '<input type="hidden" name="mode" id="mode" value="'.$mode
-            .'" />';
-    $frmStr .= '<input type="hidden" name="table" id="table" value="'.$table
-            .'" />';
-    $frmStr .= '<input type="hidden" name="coll_id" id="coll_id" value="'
-            .$collId.'" />';
-    $frmStr .= '<input type="hidden" name="module" id="module" value="'
-            .$module.'" />';
-    $frmStr .= '<input type="hidden" name="req" id="req" value="second_request"'
-            .' />';
-    $frmStr .= '<input type="hidden" id="check_days_before" value="'.$_SESSION['check_days_before'].'"'
-            .' />';
-
-    $frmStr .= '<div  style="display:block">';
-
-    //INDEXING MODELS
-    $query = 'SELECT * FROM indexingmodels order by label ASC';
-    $stmt = $db->query($query, array());
-
-    $frmStr .= '<div style="display:table;width:100%;">';
-    $frmStr .= '<div style="display:table-cell;vertical-align:middle;">';
-    $frmStr .= '</div>';
-    $frmStr .= '<div style="display:table-cell;text-align:right;vertical-align:middle;width: 12%;">';
-    $frmStr .= '<a style="cursor:pointer;"><i id="action1_indexingmodels" class="fa fa-plus fa-2x" onclick="saveIndexingModel();"></i></a> <a id="delete_indexingmodels" style="cursor:pointer;"><i id="action2_indexingmodels" style="visibility:hidden;" class="fa fa-trash-alt fa-2x" onclick="delIndexingModel();"></i></a>';
-    $frmStr .= '</div>';
-    $frmStr .= '</div>';
-    $frmStr .= '<script>$j("#indexing_models_select").chosen({width: "100%", disable_search_threshold: 10, search_contains: true, allow_single_deselect: true});</script>';
-    $frmStr .= '<hr />';
-
-    $frmStr .= '<div  style="display:block" id="choose_file_div">';
-    $frmStr .= '<iframe src="'.$_SESSION['config']['businessappurl']
-            .'index.php?display=true&dir=indexing_searching&page='
-            .'choose_file" name="choose_file" id="choose_file" '
-            .'frameborder="0" scrolling="no" width="100%" height="30">'
-            .'</iframe>';
-    $frmStr .= '</div>';
-
-    $frmStr .= '<hr />';
-
-    $frmStr .= '<h4 onclick="new Effect.toggle(\'general_infos_div\', \'blind\', {delay:0.2});'
-        .'whatIsTheDivStatus(\'general_infos_div\', \'divStatus_general_infos_div\');" '
-        .'class="categorie" style="width:90%;" onmouseover="this.style.cursor=\'pointer\';">';
-    $frmStr .= ' <span id="divStatus_general_infos_div" style="color:#1C99C5;"><i class="fa fa-minus-square"></i></span>&nbsp;'
-        ._GENERAL_INFO;
-    $frmStr .= '</h4>';
-    $frmStr .= '<div id="general_infos_div"  style="display:inline">';
-    $frmStr .= '<div class="ref-unit">';
-
-    $frmStr .= '<table width="100%" align="center" border="0" '
-        .'id="indexing_fields" style="display:block;">';
-
-    if ($core->test_service('add_links', 'apps', false)) {
-        $frmStr .= '<tr id="attachment_tr" style="display:'.$displayValue
-                .';">';
-        $frmStr .= '<td>'
-                ._LINK_TO_DOC.'</td>';
-        $frmStr .= '<td>&nbsp;</td>';
-        $frmStr .= '<td class="indexing_field"><input type="radio" '
-                .'name="attachment" id="attach" value="true" '
-                .'onclick="show_attach(\'true\');"'
-                .' /> '
-                ._YES.' <input type="radio" name="attachment" id="no_attach"'
-                .' value="false" checked="checked" '
-                .'onclick="show_attach(\'false\');"'
-                .' /> '
-                ._NO.'</td>';
-        $frmStr .= ' <td><span class="red_asterisk" id="attachment_mandatory" '
-                .'style="display:inline;vertical-align:middle;"><i class="fa fa-star"></i></span></td>';
-        $frmStr .= '</tr>';
-
-        $frmStr .= '<tr id="attach_show" style="display:none;">';
-        $frmStr .= '<td>&nbsp;</td>';
-        $frmStr .= '<td style="text-align: right;">';
-        $frmStr .= '<a ';
-        $frmStr .= 'href="javascript://" ';
-        $frmStr .= 'onclick="window.open(';
-        $frmStr .= '\''.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=search_adv&mode=popup&action_form=show_res_id&modulename=attachments&init_search&nodetails\', ';
-        $frmStr .= '\'search_doc_for_attachment\', ';
-        $frmStr .= '\'scrollbars=yes,menubar=no,toolbar=no,resizable=yes,status=no,width=1100,height=775\'';
-        $frmStr .= ');"';
-        $frmStr .= ' title="'._SEARCH.'"';
-        $frmStr .= '>';
-        $frmStr .= '<span style="font-weight: bold;">';
-        $frmStr .= '<i class="fa fa-link"></i>';
-        $frmStr .= '</span>';
-        $frmStr .= '</a>';
-        $frmStr .= '</td>';
-        $frmStr .= '<td style="text-align: right;">';
-        if (_ID_TO_DISPLAY == 'res_id') {
-            $frmStr .= '<input ';
-            $frmStr .= 'type="text" ';
-            $frmStr .= 'name="res_id" ';
-            $frmStr .= 'id="res_id" ';
-            $frmStr .= 'class="readonly" ';
-            $frmStr .= 'readonly="readonly" ';
-            $frmStr .= 'value="" ';
-            $frmStr .= '/>';
-        } else {
-            $frmStr .= '<input ';
-            $frmStr .= 'type="text" ';
-            $frmStr .= 'name="chrono_id" ';
-            $frmStr .= 'id="chrono_id" ';
-            $frmStr .= 'class="readonly" ';
-            $frmStr .= 'readonly="readonly" ';
-            $frmStr .= 'value="" ';
-            $frmStr .= '/>';
-            $frmStr .= '<input style="display:none"';
-            $frmStr .= 'type="text" ';
-            $frmStr .= 'name="res_id" ';
-            $frmStr .= 'id="res_id" ';
-            $frmStr .= 'value="" ';
-            $frmStr .= '/>';
-        }
-
-        $frmStr .= '</td>';
-        $frmStr .= '<td>';
-        $frmStr .= '<span class="red_asterisk" id="attachment_link_mandatory" '
-                .'style="display:inline;vertical-align:middle;"><i class="fa fa-star"></i></span>';
-        $frmStr .= '</td>';
-        $frmStr .= '</tr>';
-    }
-
-    if ($_SESSION['FILE']['index_type'] == 'num') {
-        $hideSelectFile = '';
-    } else {
-        $hideSelectFile = 'hideSelectFile();';
-    }
-    /*** Category ***/
-    $frmStr .= '<tr id="category_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td style="width:200px;"><label for="category_id" '
-            .'class="form_title" >'._CATEGORY.'</label></td>';
-    $frmStr .= '<td style="width:10px;">&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><select name="category_id" '
-            .'id="category_id" onchange="clear_error(\'frm_error_'.$actionId
-            .'\');change_category(this.options[this.selectedIndex].value, \''
-            .$displayValue.'\',  \''.$_SESSION['config']['businessappurl']
-            .'index.php?display=true&dir=indexing_searching&page='
-            .'change_category\',  \''.$_SESSION['config']['businessappurl']
-            .'index.php?display=true&page=get_content_js\');change_category_actions(\''
-            .$_SESSION['config']['businessappurl']
-            .'index.php?display=true&dir=indexing_searching&page=change_category_actions'
-            .'&resId='.$resId.'&collId='.$collId.'\',\'none\',\''.$collId.'\',this.options[this.selectedIndex].value);'.$hideSelectFile.'">';
-    $frmStr .= '<option value="">'._CHOOSE_CATEGORY.'</option>';
-    foreach (array_keys($_SESSION['coll_categories']['letterbox_coll']) as $catId) {
-        if ($catId != 'default_category' && $catId != 'attachment') {
-            $frmStr .= '<option value="'.functions::xssafe($catId).'"';
-            if ($_SESSION['coll_categories']['letterbox_coll']['default_category'] == $catId || (isset($_SESSION['indexing']['category_id']) && $_SESSION['indexing']['category_id'] == $catId)
-            ) {
-                $frmStr .= 'selected="selected"';
-            }
-
-            $frmStr .= '>'.functions::xssafe($_SESSION['coll_categories']['letterbox_coll'][$catId]).'</option>';
-        }
-    }
-    $frmStr .= '</select></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="category_id_mandatory" '
-            .'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frmStr .= '</tr>';
-
-    $frmStr .= '<script>$j("#category_id").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
-    /*** Doctype ***/
-    $frmStr .= '<tr id="type_id_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td><label for="type_id" class="form_title" '
-            .'id="doctype_res" style="display:none;">'._DOCTYPE
-            .'</label><label for="type_id" class="form_title" id="doctype_mail" '
-            .'style="display:inline;">'._DOCTYPE_MAIL
-            .'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><select name="type_id" id="type_id" '
-            .'onchange="clear_error(\'frm_error_'.$actionId.'\');'
-            .'changePriorityForSve(this.options[this.selectedIndex].value,\''
-            .$_SESSION['config']['businessappurl'].'index.php?display=true'
-            .'&dir=indexing_searching&page=priority_for_sve\');change_doctype(this.options[this.selectedIndex].value, \''
-            .$_SESSION['config']['businessappurl'].'index.php?display=true'
-            .'&dir=indexing_searching&page=change_doctype\', \''
-            ._ERROR_DOCTYPE.'\', \''.$actionId.'\', \''
-            .$_SESSION['config']['businessappurl'].'index.php?display=true'
-            .'&page=get_content_js\', \''.$displayValue.'\')'.$func_load_listdiff.'">';
-    $frmStr .= '<option value="">'._CHOOSE_TYPE.'</option>';
-    if ($_SESSION['features']['show_types_tree'] == 'true') {
-        for ($i = 0; $i < count($doctypes); ++$i) {
-            $frmStr .= '<optgroup value="" class="' //doctype_level1
-                    .$doctypes[$i]['style'].'" label="'
-                    .functions::xssafe($doctypes[$i]['label']).'" >';
-            for ($j = 0; $j < count($doctypes[$i]['level2']); ++$j) {
-                $frmStr .= '<optgroup value="" class="' //doctype_level2
-                        .$doctypes[$i]['level2'][$j]['style'].'" label="&nbsp;&nbsp;'
-                        .functions::xssafe($doctypes[$i]['level2'][$j]['label']).'" >';
-                for ($k = 0; $k < count($doctypes[$i]['level2'][$j]['types']);
-                    ++$k
-                ) {
-                    $frmStr .= '<option data-object_type="type_id" value="'
-                            .functions::xssafe($doctypes[$i]['level2'][$j]['types'][$k]['id'])
-                            .'" title="'
-                            .functions::xssafe($doctypes[$i]['level2'][$j]['types'][$k]['label'])
-                            .'" label="'
-                            .functions::xssafe($doctypes[$i]['level2'][$j]['types'][$k]['label'])
-                            .'">&nbsp;&nbsp;&nbsp;&nbsp;'
-                            .functions::xssafe($doctypes[$i]['level2'][$j]['types'][$k]['label'])
-                            .'</option>';
-                }
-                $frmStr .= '</optgroup>';
-            }
-            $frmStr .= '</optgroup>';
-        }
-    } else {
-        for ($i = 0; $i < count($doctypes); ++$i) {
-            $frmStr .= '<option value="'.functions::xssafe($doctypes[$i]['ID']).'" >'
-                    .functions::xssafe($doctypes[$i]['LABEL']).'</option>';
-        }
-    }
-    $frmStr .= '</select></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="type_id_mandatory" '
-            .'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<script>$j("#type_id").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
-    /*** Priority ***/
-    $frmStr .= '<tr id="priority_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td><label for="priority" class="form_title" >'._PRIORITY
-            .'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><select name="priority" '
-            .'id="priority" onChange="updateProcessDate(\''
-            .$_SESSION['config']['businessappurl'].'index.php?display=true'
-            .'&dir=indexing_searching&page=update_process_date\');" onFocus="updateProcessDate(\''
-            .$_SESSION['config']['businessappurl'].'index.php?display=true'
-            .'&dir=indexing_searching&page=update_process_date\');clear_error(\'frm_error_'.$actionId
-            .'\');">';
-    $frmStr .= '<option value="">'._CHOOSE_PRIORITY.'</option>';
-    for ($i = 0; $i < count($_SESSION['mail_priorities']); ++$i) {
-        $frmStr .= '<option value="'.functions::xssafe($_SESSION['mail_priorities_id'][$i]).'" ';
-        if ($_SESSION['default_mail_priority'] == $i) {
-            $frmStr .= 'selected="selected"';
-        }
-        $frmStr .= '>'.functions::xssafe($_SESSION['mail_priorities'][$i]).'</option>';
-    }
-    $frmStr .= '</select></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="priority_mandatory" '
-            .'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<script>$j("#priority").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
-    /*** Confidentiality ***/
-    $frmStr .= '<tr id="confidentiality_tr" style="display:'.$displayValue
-            .';">';
-    $frmStr .= '<td><label for="confidentiality" class="form_title" >'
-            ._CONFIDENTIALITY.' </label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input type="radio" '
-            .'name="confidentiality" id="confidential" value="Y" />'
-            ._YES.' <input type="radio" name="confidentiality" id="no_confidential"'
-            .' value="N" checked="checked" />'
-            ._NO.'</td>';
-    $frmStr .= ' <td><span class="red_asterisk" id="confidentiality_mandatory" '
-            .'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-
-    /*** Doc date ***/
-    $frmStr .= '<tr id="doc_date_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td><label for="doc_date" class="form_title" '
-            .'id="mail_date_label" style="display:inline;" >'._MAIL_DATE
-            .'</label><label for="doc_date" class="form_title" '
-            .'id="doc_date_label" style="display:none;" >'._DOC_DATE
-            .'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input name="doc_date" type="text" '
-            .'id="doc_date" value="" placeholder="JJ-MM-AAAA" onfocus="checkRealDate(\'docDate\');" onChange="checkRealDate(\'docDate\');"  onclick="clear_error(\'frm_error_'
-            .$actionId.'\');showCalender(this);" /></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="doc_date_mandatory" '
-            .'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frmStr .= '</tr >';
-
-    /*** Author ***/
-    $frmStr .= '<tr id="author_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td><label for="author" class="form_title" >'._AUTHOR
-            .'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input name="author" type="text" '
-            .'id="author" onchange="clear_error(\'frm_error_'.$actionId
-            .'\');"/></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="author_mandatory" '
-            .'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-
-    /*** Admission date ***/
-    $frmStr .= '<tr id="admission_date_tr" style="display:'.$displayValue
-            .';">';
-    $frmStr .= '<td><label for="admission_date" class="form_title" >'
-            ._RECEIVING_DATE.'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input name="admission_date" '
-            .'type="text" id="admission_date" value="'.$today
-            .'" onclick="clear_error(\'frm_error_'.$actionId.'\');'
-            .'showCalender(this);" onChange="checkRealDate(\'admissionDate\');updateProcessDate(\''
-            .$_SESSION['config']['businessappurl'].'index.php?display=true'
-            .'&dir=indexing_searching&page=update_process_date\');" onFocus="checkRealDate(\'admissionDate\');updateProcessDate(\''
-            .$_SESSION['config']['businessappurl'].'index.php?display=true'
-            .'&dir=indexing_searching&page=update_process_date\');"/></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="admission_date_mandatory" '
-            .'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frmStr .= '</tr>';
-
-    /*** Reference courrier externe ***/
-    $frmStr .= '<tr id="external_reference_tr" style="display:' . $displayValue . ';">';
-    $frmStr .= '<td><label for="external_reference" class="form_title" >' . _REFERENCE_MAIL
-            . '</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input name="external_reference" type="text" '
-            . 'id="external_reference"/></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '</tr>';
-
-    /*** date de depart ***/
-    $frmStr .= '<tr id="departure_date_tr" style="display:' . $displayValue
-            . ';">';
-    $frmStr .= '<td><label for="departure_date" class="form_title" >'
-            . _EXP_DATE . '</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input name="departure_date" '
-            . 'type="text" id="departure_date" value="" onclick="clear_error(\'frm_error_' . $actionId . '\');'
-            . 'showCalender(this);" onChange="checkRealDate(\'departure_date\');" onFocus="checkRealDate(\'departure_date\');" /></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="departure_date_mandatory" '
-            . 'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frmStr .= '</tr>';
-    
-    /*** Contact ***/
-    $frmStr .= '<tr id="contact_choose_tr" style="display:'.$displayValue
-            .';">';
-    $frmStr .= '<td><label for="type_contact" class="form_title" >'
-            .'<span id="exp_contact_choose_label">'._SHIPPER_TYPE.'</span>'
-            .'<span id="dest_contact_choose_label">'._DEST_TYPE.'</span>'
-            .'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input type="radio" class="check" '
-            .'name="type_contact" id="type_contact_internal" value="internal" '
-            .'onclick="clear_error(\'frm_error_'.$actionId.'\');reset_check_date_exp();'
-            .'change_contact_type(\''.$_SESSION['config']['businessappurl']
-            .'index.php?display=true&dir=indexing_searching&page='
-            .'autocomplete_contacts\', false);update_contact_type_session(\''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts_prepare_multi\');"  /><label for="type_contact_internal">'._INTERNAL2.'</label>'
-            .'</td></tr>';
-    $frmStr .= '<tr id="contact_choose_2_tr" style="display:'.$displayValue
-            .';">';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input type="radio" name="type_contact" '
-            .'id="type_contact_external" value="external" '
-            .'onclick="clear_error(\'frm_error_'.$actionId.'\');'
-            .'change_contact_type(\''.$_SESSION['config']['businessappurl']
-            .'index.php?display=true&dir=indexing_searching'
-            .'&autocomplete_contacts\', false);update_contact_type_session(\''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts_prepare_multi\');"  class="check"/><label for="type_contact_external">'._EXTERNAL.'</label>'
-            .'</td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<tr id="contact_choose_3_tr" style="display:'.$displayValue
-            .';">';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input type="radio" name="type_contact" '
-            .'id="type_multi_contact_external" value="multi_external" '
-            .'onclick="clear_error(\'frm_error_'.$actionId.'\');'
-            .'change_contact_type(\''.$_SESSION['config']['businessappurl']
-            .'index.php?display=true&dir=indexing_searching'
-            .'&autocomplete_contacts\', true);update_contact_type_session(\''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts_prepare_multi\');"  class="check"/><label for="type_multi_contact_external">'._MULTI_CONTACT.'</label>'
-            .'</td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<tr id="contact_id_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td style="vertical-align:bottom;"><label for="contact" class="form_title" >'
-            .'<span id="exp_contact">'._SHIPPER.'</span>'
-            .'<span id="dest_contact">'._DEST.'</span>'
-            .'<span id="author_contact">'._AUTHOR_DOC.'</span>';
-    if ($core->test_admin('my_contacts', 'apps', false)) {
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-                .'index.php?display=false&dir=my_contacts&page=create_contact_iframe';
-        $frmStr .= ' <a href="#" id="create_contact" title="'._CREATE_CONTACT
-                .'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\'\',\''.$pathScriptTab.'\',\'create_contact\');return false;" '
-                .'style="display:inline;" ><i class="fa fa-pen-square" title="'
-                ._CREATE_CONTACT.'"></i></a>';
-    } else {
-        $frmStr .= ' <a href="#" id="create_contact"/></a>';
-    }
-    $frmStr .= '</label></td>';
-    $contact_mode = 'view';
-    if ($core->test_service('update_contacts', 'apps', false)) {
-        $contact_mode = 'update';
-    }
-    //Path to actual script
-    $path_to_script = $_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=contact_check&coll_id='.$collId;
-    $path_check_date_link = $_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=documents_list_mlb_search_adv&mode=popup&action_form=show_res_id&modulename=attachments&init_search&nodetails&fromContactCheck';
-    $frmStr .= '<td style="vertical-align:bottom;"><a href="#" class="fa fa-book fa-2x" id="contact_card" title="'._CONTACT_CARD
-            .'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_CONTACT).'\',loadInfoContact(),\'info_contact\');return false;"'
-            .'style="visibility:hidden;display:inline;" ></a>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field">';
-
-    //$frmStr .= '<i class="fa fa-user" title="'._INTERNAL2.'" style="cursor:pointer;" id="type_contact_internal_icon" onclick="$$(\'#type_contact_internal\')[0].click();$(\'type_contact_internal_icon\').setStyle({color: \'#135F7F\'});$(\'type_contact_external_icon\').setStyle({color: \'#666\'});$(\'type_multi_contact_external_icon\').setStyle({color: \'#666\'});"></i>';
-
-    $frmStr .= ' <i class="fa fa-user" title="'._SINGLE_CONTACT.'" style="cursor:pointer;color:#135F7F;" id="type_contact_external_icon" onclick="$j(\'#type_contact_external\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\',\'#666\');$j(\'#type_contact_external_icon\').css(\'color\',\'#135F7F\');$j(\'#type_multi_contact_external_icon\').css(\'color\',\'#666\');"></i>';
-
-    $frmStr .= ' <i class="fa fa-users" title="'._MULTI_CONTACT.'" style="cursor:pointer;" id="type_multi_contact_external_icon" onclick="$j(\'#type_multi_contact_external\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\',\'#666\');$j(\'#type_contact_external_icon\').css(\'color\',\'#666\');$j(\'#type_multi_contact_external_icon\').css(\'color\',\'#135F7F\');"></i>';
-    $frmStr .= ' <i class="fa fa-tty" title="'._CONTACT_COMMUNICATION_DEFINE.'"style="visibility:hidden;display:inline;"" id="type_contact_communication_icon"></i>';
-    $frmStr .= ' <span style="position:relative;"><input type="text" name="contact" placeholder="'._CONTACTS_USERS_SEARCH.'" onkeyup="erase_contact_external_id(\'contact\', \'contactid\');erase_contact_external_id(\'contact\', \'addressid\');"'
-        .'id="contact" onblur="clear_error(\'frm_error_'.$actionId.'\');'
-        .'display_contact_card(\'visible\');checkCommunication(document.getElementById(\'contactid\').value);if(document.getElementById(\'type_contact_external\').checked == true){check_date_exp(\''.$path_to_script.'\', \''.$path_check_date_link.'\');}" /><div id="show_contacts" '
-            .'class="autocomplete autocompleteIndex" style="width:100%;left:0px;top:17px;"></div><div class="autocomplete autocompleteIndex" id="searching_autocomplete" style="display: none;text-align:left;padding:5px;left:0px;width:100%;top:17px;"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i> chargement ...</div></span></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="contact_mandatory" '
-            .'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<tr style="display:none" id="contact_check"><td></td></tr>';
-    $frmStr .= '<input type="hidden" id="contactid" />';
-    $frmStr .= '<input type="hidden" id="addressid" />';
-    $frmStr .= '<input type="hidden" id="contactcheck" value="success"/>';
-
-    /****multicontact***/
-
-    //Path to actual script
-    $path_to_script = $_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=add_multi_contacts&coll_id='.$collId;
-
-    $frmStr .= '<tr id="add_multi_contact_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td><label for="contact" class="form_title" >'
-            .'<span id="exp_multi_contact">'._SHIPPER.'</span>'
-            .'<span id="dest_multi_contact">'._DEST.'</span>';
-    if ($core->test_admin('my_contacts', 'apps', false)) {
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-                .'index.php?display=false&dir=my_contacts&page=create_contact_iframe';
-        $frmStr .= ' <a href="#" id="create_multi_contact" title="'._CREATE_CONTACT
-                .'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\'\',\''.$pathScriptTab.'\',\'create_contact\');return false;" '
-                .'style="display:inline;" ><i class="fa fa-pen-square" title="'
-                ._CREATE_CONTACT.'"></i></a>';
-    }
-    $frmStr .= '</label></td>';
-    $contact_mode = 'view';
-    if ($core->test_service('update_contacts', 'apps', false)) {
-        $contact_mode = 'update';
-    }
-    $frmStr .= '<td><a href="#" id="multi_contact_card" class="fa fa-book fa-2x" title="'._CONTACT_CARD
-            .'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_CONTACT).'\',loadInfoContact(),\'info_contact\');return false;" '
-            .'style="visibility:hidden;" ></a>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field">';
-    //$frmStr .= '<i class="fa fa-user" title="'._INTERNAL2.'" style="cursor:pointer;" id="type_contact_internal_icon" onclick="$$(\'#type_contact_internal\')[0].click();$(\'type_contact_internal_icon\').setStyle({color: \'#135F7F\'});$(\'type_contact_external_icon\').setStyle({color: \'#666\'});$(\'type_multi_contact_external_icon\').setStyle({color: \'#666\'});"></i>';
-
-    $frmStr .= ' <i class="fa fa-user" title="'._SINGLE_CONTACT.'" style="cursor:pointer;" id="type_contact_external_icon" onclick="$j(\'#type_contact_external\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\',\'#135F7F\');$j(\'#type_contact_external_icon\').css(\'color\',\'#135F7F\');$j(\'#type_multi_contact_external_icon\').css(\'color\',\'#666\');"></i>';
-
-    $frmStr .= ' <i class="fa fa-users" title="'._MULTI_CONTACT.'" style="cursor:pointer;color:#135F7F;" id="type_multi_contact_external_icon" onclick="$j(\'#type_multi_contact_external\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\',\'#666\');$j(\'#type_contact_external_icon\').css(\'color\',\'#666\');$j(\'#type_multi_contact_external_icon\').css(\'color\',\'#135F7F\');"></i>';
-
-    $frmStr .= '<span style="position:relative;"><input type="text" name="email" id="email" placeholder="'._CONTACTS_USERS_GROUPS_SEARCH.'" value="" onblur="clear_error(\'frm_error_'.$actionId.'\');display_contact_card(\'visible\', \'multi_contact_card\');"/>';
-    $frmStr .= '<div id="multiContactList" class="autocomplete" style="left:0px;width:100%;top:17px;"></div><div class="autocomplete autocompleteIndex" id="searching_autocomplete_multi" style="display: none;text-align:left;padding:5px;left:0px;width:100%;top:17px;"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i> chargement ...</div></span>';
-    $frmStr .= '<script type="text/javascript">addMultiContacts(\'email\', \'multiContactList\', \''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&multiContact=true&dir=indexing_searching&page=autocomplete_contacts\', \'Input\', \'2\', \'contactid\', \'addressid\');</script>';
-    $frmStr .= ' <input type="button" name="add" value="&nbsp;'._ADD
-                    .'&nbsp;" id="valid_multi_contact" class="button" onclick="updateMultiContacts(\''.$path_to_script
-                    .'&mode=adress\', \'add\', document.getElementById(\'email\').value, '
-                    .'\'to\', false, document.getElementById(\'addressid\').value, document.getElementById(\'contactid\').value);display_contact_card(\'hidden\', \'multi_contact_card\');" />&nbsp;';
-    $frmStr .= '</td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<tr id="show_multi_contact_tr">';
-    $frmStr .= '<td align="right" nowrap width="10%" id="to_multi_contact"><label>'
-        ._SEND_TO_SHORT.'</label></td>';
-    $frmStr .= '<td>&nbsp;</td><td style="text-align:right;"><div name="to" id="to"  style="width:200px;text-align:left;" class="multicontactInput">'
-        .'<div id="loading_to" style="display:none;"><i class="fa fa-spinner fa-2x" '
-        .'style="vertical-align: middle;" title="loading..."></i></div></div></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="contact_mandatory" '
-            .'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-
-    /*** Sender/Recipient ***/
-    $frmStr .= '<tr id="sender_recipient_tr" style="display:' . $displayValue . ';">';
-    $frmStr .= '<td><label for="sender_recipient" class="form_title" >';
-    $frmStr .= '<span id="sr_sender_span">'._SHIPPER.'</span>';
-    $frmStr .= '<span id="sr_recipient_span">'._DEST.'</span>';
-    $frmStr .= '</label></td>';
-    $frmStr .= '<td><a href="#" id="sender_recipient_card" class="fa fa-book fa-2x" title="'._CONTACT_CARD
-    .'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_CONTACT).'\',loadInfoContactSenderRecipient(),\'info_contact\');return false;" '
-    .'style="visibility:hidden;" ></a>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field">';
-    $frmStr .= '<i id="sender_recipient_icon_contactsUsers" class="fa fa-user" onclick="switchAutoCompleteType(\'sender_recipient\',\'contactsUsers\', false);" style="color:#135F7F;display: inline-block;cursor:pointer;" title="'._CONTACTS_USERS_LIST.'" ></i> <i id="sender_recipient_icon_entities" class="fa fa-sitemap" onclick="switchAutoCompleteType(\'sender_recipient\',\'entities\');" style="display: inline-block;cursor:pointer;" title="'._ENTITIES_LIST.'" ></i>';
-    $frmStr .= '<div class="typeahead__container"><div class="typeahead__field"><span class="typeahead__query">';
-    $frmStr .= '<input name="sender_recipient" type="text" id="sender_recipient" autocomplete="off" placeholder="'._CONTACTS_USERS_SEARCH.'"/></span></div></div>';
-    $frmStr .= '</td><td></td>';
-    $frmStr .= '<input type="hidden" id="sender_recipient_id" />';
-    $frmStr .= '<input type="hidden" id="sender_recipient_type" />';
-    $frmStr .= '</tr>';
-
-    /****** RECOMMANDE ******/
-    $frmStr .= '<tr id="reference_number_tr" style="display:none;">';
-    $frmStr .= '<td><label for="reference_number" class="form_title" >'._MONITORING_NUMBER.'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input type="text" name="reference_number" id="reference_number"/></td>';
-    $frmStr .= '</tr>';
-
-    /*** Initiator ***/
-    $frmStr .= '<tr id="initiator_tr" style="display:'
-        .$displayValue.';">';
-    $frmStr .= '<td><label for="intitiator" class="form_title" >'
-            ._INITIATOR.'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field">'
-            .'<select name="initiator" id="initiator">';
-    foreach ($_SESSION['user']['entities'] as $entity) {
-        $frmStr .= '<option value="'.$entity['ENTITY_ID'].'"';
-        if ($_SESSION['user']['primaryentity']['id'] == $entity['ENTITY_ID']) {
-            $frmStr .= ' selected="selected" ';
-        }
-        $frmStr .= '>'.$entity['ENTITY_LABEL'].'</option>';
-    }
-    $frmStr .= '</select>'
-            .'</td>';
-    $frmStr .= '<td><span class="red_asterisk" '
-            .'id="process_limit_date_use_mandatory" style="display:inline;"><i class="fa fa-star"></i>'
-            .'</span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<script>$j("#initiator").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
-    /*** Subject ***/
-    $frmStr .= '<tr id="subject_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td><label for="subject" class="form_title" >'._SUBJECT
-            .'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><textarea name="subject" '
-            .'id="subject" style="resize:vertical" rows="4" onchange="clear_error(\'frm_error_'
-            .$actionId.'\');" ></textarea></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="subject_mandatory" '
-            .'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-
-    /*** Entities : department + diffusion list ***/
-    if ($core->is_module_loaded('entities')) {
-        $frmStr .= '<tr id="department_tr" style="display:'.$displayValue
-                .';">';
-        $frmStr .= '<td><label for="destination" class="form_title" '
-                .'id="label_dep_dest" style="display:inline;" >'
-                ._DEPARTMENT_DEST.'</label><label for="destination" '
-                .'class="form_title" id="label_dep_exp" style="display:none;" >'
-                ._DEPARTMENT_EXP.'</label><label for="destination" '
-                .'class="form_title" id="label_dep_owner" style="display:none;" >'
-                ._DEPARTMENT_OWNER.'</label></td>';
-        $frmStr .= '<td>&nbsp;</td>';
-        $frmStr .= '<td class="indexing_field">';
-        $frmStr .= '<select name="destination" id="destination" onchange="'
-                    .'clear_error(\'frm_error_'.$actionId.'\');'
-                    .'load_listmodel('.$target_model.', \'diff_list_div\', \'indexing\', $j(\'#category_id\').val())'
-
-                .';" >';
-        $frmStr .= '<option value="">'._CHOOSE_DEPARTMENT.'</option>';
-        $countAllEntities = count($allEntitiesTree);
-        for ($cptEntities = 0; $cptEntities < $countAllEntities; ++$cptEntities) {
-            if (!$allEntitiesTree[$cptEntities]['KEYWORD']) {
-                $frmStr .= '<option title="'.functions::show_string($allEntitiesTree[$cptEntities]['SHORT_LABEL']).'" data-object_type="entity_id" value="'.$allEntitiesTree[$cptEntities]['ID'].'"';
-                if ($allEntitiesTree[$cptEntities]['DISABLED']) {
-                    $frmStr .= ' disabled="disabled" class="disabled_entity"';
-                } else {
-                    //$frmStr .= ' style="font-weight:bold;"';
-                }
-                $frmStr .= '>'
-                    .functions::show_string($allEntitiesTree[$cptEntities]['SHORT_LABEL'])
-                    .'</option>';
-            }
-        }
-        $frmStr .= '</select></td>';
-        $frmStr .= '<td><span class="red_asterisk" id="destination_mandatory" '
-                .'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-        $frmStr .= '</tr>';
-
-        $frmStr .= '<tr id="diff_list_tr" style="display:none;">';
-        $frmStr .= '<td colspan="3">';
-        $frmStr .= '<div id="diff_list_div" class="scroll_div" '
-                //. 'style="height:200px; width:420px; border: 1px solid;"></div>';
-                .'style="width:420px; max-width: 420px;"></div>';
-        $frmStr .= '</td>';
-        $frmStr .= '</tr>';
-        $frmStr .= '<script>$j("#destination").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-    }
-
-    /*** Process limit date ***/
-    $frmStr .= '<tr id="process_limit_date_use_tr" style="display:'
-            .$displayValue.';">';
-    $frmStr .= '<td><label for="process_limit_date_use" class="form_title" >'
-            ._PROCESS_LIMIT_DATE_USE.'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input type="radio" '
-            .'name="process_limit_date_use" id="process_limit_date_use_yes" '
-            .'class="check" value="yes" checked="checked" '
-            .'onclick="clear_error(\'frm_error_'.$actionId.'\');'
-            .'activate_process_date(true,\''.$displayValue.'\' );" />'
-            ._YES.'<input type="radio" name="process_limit_date_use" '
-            .'id="process_limit_date_use_no" value="no" class="check" '
-            .'onclick="clear_error(\'frm_error_'.$actionId.'\');'
-            .'activate_process_date(false, \''.$displayValue.'\');"/>'
-            ._NO.'</td>';
-    $frmStr .= '<td><span class="red_asterisk" '
-            .'id="process_limit_date_use_mandatory" style="display:inline;"><i class="fa fa-star"></i>'
-            .'</span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<tr id="process_limit_date_tr" style="display:'.$displayValue
-            .';">';
-    $frmStr .= '<td><label for="process_limit_date" class="form_title" >'
-            ._PROCESS_LIMIT_DATE.'</label></td>';
-    $frmStr .= '<td>&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input name="process_limit_date" '
-            .'type="text" id="process_limit_date" value="" '
-            .'onclick="showCalender(this);" '
-            .'onchange="clear_error(\'frm_error_'.$actionId.'\');checkRealLimitDate(\'process_limit_date\');" onFocus="checkRealLimitDate(\'process_limit_date\');"/></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="process_limit_date_mandatory"'
-            .' style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-
-    /*** Status ***/
-    if (count($statuses) > 0) {
-        $frmStr .= '<tr id="status_tr" style="display:'.$displayValue.';">';
-        $frmStr .= '<td><label for="status" class="form_title" >'._STATUS
-                .'</label></td>';
-        $frmStr .= '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
-        $frmStr .= '<td class="indexing_field"><select name="status" '
-                .'id="status" onchange="clear_error(\'frm_error_'.$actionId
-                .'\');">';
-        //$frmStr .= '<option value="">' . _CHOOSE_STATUS . '</option>';
-        for ($i = 0; $i < count($statuses); ++$i) {
-            $frmStr .= '<option value="'.functions::xssafe($statuses[$i]['ID']).'" ';
-            $frmStr .= '>'.functions::xssafe($statuses[$i]['LABEL']).'</option>';
-        }
-        $frmStr .= '</select></td><td><span class="red_asterisk" id="market_mandatory" '
-                .'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-        $frmStr .= '</tr>';
-        $frmStr .= '<script>$j("#status").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-    }
-
-    $frmStr .= '</table>';
-
-    $frmStr .= '</div>';
-    $frmStr .= '</div>';
-
-    /*** CUSTOM INDEXES ***/
-    $frmStr .= '<div id="comp_indexes" style="display:block;">';
-    $frmStr .= '</div>';
-
-    /*** Complementary fields ***/
-    $frmStr .= '<hr />';
-
-    $frmStr .= '<h4 onclick="new Effect.toggle(\'complementary_fields\', \'blind\', {delay:0.2});'
-        .'whatIsTheDivStatus(\'complementary_fields\', \'divStatus_complementary_fields\');" '
-        .'class="categorie" style="width:90%;" onmouseover="this.style.cursor=\'pointer\';">';
-    $frmStr .= ' <span id="divStatus_complementary_fields" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>&nbsp;'
-        ._OPT_INDEXES;
-    $frmStr .= '</h4>';
-    $frmStr .= '<div id="complementary_fields"  style="display:none">';
-    $frmStr .= '<div>';
-
-    $frmStr .= '<table width="100%" align="center" border="0" '
-            .'id="indexing_fields" style="display:table;">';
-
-    /*** Chrono number ***/
-    $frmStr .= '<tr id="chrono_number_tr" style="display:'.$displayValue.';">';
-    $frmStr .= '<td><label for="chrono_number" class="form_title" >'
-            ._CHRONO_NUMBER.'</label></td>';
-    $frmStr .= '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
-    $frmStr .= '<td class="indexing_field"><input type="text" '
-            .'name="chrono_number" id="chrono_number" '
-            .'onchange="clear_error(\'frm_error_'.$actionId.'\');"/></td>';
-    $frmStr .= '<td><span class="red_asterisk" id="chrono_number_mandatory" '
-            .'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frmStr .= '</tr>';
-
-    /*** Description ***/
-    $frmStr .= '<tr id="description_tr" style="display:' . $displayValue . ';">';
-    $frmStr .= '<td colspan="3">' . _OTHERS_INFORMATIONS . '</td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<tr>';
-    $frmStr .= '<td colspan="2" class="indexing_field"><textarea style="width:97%;resize:vertical" name="description" '
-            . 'id="description"  rows="2" onchange="clear_error(\'frm_error_'
-            . $actionId . '\');" ></textarea></td>';
-    $frmStr .= '</tr>';
-
-    //Departement concerne
-    $frmStr .= '<tr id="department_number_tr" style="display:' . $displayValue . ';">';
-    $frmStr .= '<td colspan="3">' . _DEPARTMENT_NUMBER . '</td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<tr>';
-    $frmStr .= '<td  colspan="2" class="indexing_field"><input style="width:97%;" type="text" onkeyup="erase_contact_external_id(\'department_number\', \'department_number_id\');"'
-            . 'name="department_number" id="department_number" /><div id="show_department_number" '
-            . 'class="autocomplete autocompleteIndex"></div></td>';
-    $frmStr .= '</tr>';
-    $frmStr .= '<input type="hidden" id="department_number_id" />';
-    // Fin
-    /*** Tags ***/
-    if ($core->is_module_loaded('tags') && ($core->test_service('tag_view', 'tags', false) == 1) && ($core->test_service('add_tag_to_res', 'tags', false) == 1)
-    ) {
-        include_once 'modules/tags/templates/index_mlb/index.php';
-    }
-
-    // Fin
-    $frmStr .= '</table>';
-
-    $frmStr .= '</div>';
-    $frmStr .= '</div>';
-    $frmStr .= '</div>';
-    $frmStr .= '</div>';
-    $frmStr .= '</div>';
-
-    /*** Frame to display the doc ***/
-    $frmStr .= '<div id="validright">';
-
-    $frmStr .= '<div id =\'show_tab\' module=\'\'></div>';
-
-    $frmStr .= '<script type="text/javascript">show_admin_contacts( true);</script>';
-    //$frmStr .= '<iframe src="'.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=file_iframe" name="file_iframe" id="file_iframe" scrolling="auto" frameborder="0" style="display:block;" ></iframe>';
-    if ($_SESSION['origin'] == 'scan') {
-        $frmStr .= '<iframe src="'.$_SESSION['config']['businessappurl']
-                .'index.php?display=true&dir=indexing_searching&page='
-                .'file_iframe&#navpanes=0" name="file_iframe" id="file_iframe"'
-                .' scrolling="auto" frameborder="0" style="display:block;">'
-                .'</iframe>';
-        $origin = 'scan';
-    } else {
-        $frmStr .= '<iframe src="'.$_SESSION['config']['businessappurl']
-                .'index.php?display=true&dir=indexing_searching&page='
-                .'file_iframe" name="file_iframe" id="file_iframe" '
-                .'scrolling="auto" frameborder="0" style="display:block;" >'
-                .'</iframe>';
-        $origin = '';
-    }
-    $frmStr .= '</div>';
-
-    /*** Extra javascript ***/
-    $frmStr .= '<script type="text/javascript">window.scrollTo(0,0);';
-
-    if (isset($_SESSION['indexing']['category_id']) && $_SESSION['indexing']['category_id'] != '') {
-        $category_default = $_SESSION['indexing']['category_id'];
-        $_SESSION['indexing']['category_id'] = '';
-    } else {
-        $category_default = $_SESSION['coll_categories']['letterbox_coll']['default_category'];
-    }
-
-    $frmStr .= 'change_category(\''
-            .$category_default.'\', \''.$displayValue
-            .'\', \''.$_SESSION['config']['businessappurl']
-            .'index.php?display=true&dir=indexing_searching&page='
-            .'change_category\',  \''.$_SESSION['config']['businessappurl']
-            .'index.php?display=true&page=get_content_js\', \'\', \''.$origin.'\');change_category_actions(\''
-            .$_SESSION['config']['businessappurl']
-            .'index.php?display=true&dir=indexing_searching&page=change_category_actions'
-            .'&resId='.$resId.'&collId='.$collId.'\',\'none\',\''.$collId.'\',document.getElementById(\'category_id\').options[document.getElementById(\'category_id\').selectedIndex].value);'
-            .'launch_autocompleter_contacts_v2(\''
-            .$_SESSION['config']['businessappurl'].'index.php?display=true'
-            .'&dir=indexing_searching&page=autocomplete_contacts\', \'contact\', \'show_contacts\', \'\', \'contactid\', \'addressid\', \''
-            . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-            . '&page=getDepartment\');';
-
-    $frmStr .= ' initList_hidden_input(\'department_number\', \'show_department_number\',\''
-                . $_SESSION['config']['businessappurl'] . 'index.php?display='
-                . 'true&page=autocomplete_department_number\','
-                . ' \'Input\', \'2\', \'department_number_id\');';
-
-    $frmStr .= 'initSenderRecipientAutocomplete(\'sender_recipient\',\'contactsUsers\', false, \'sender_recipient_card\');';
-
-    $frmStr .= '$j(\'#baskets\').css(\'visibility\',\'hidden\');'
-            .'var item  = $j(\'#index_div\')[0]; if(item)'
-            .'{item.style.display=\'block\';}</script>';
-
-
-    /*** Extra CSS ***/
-    $frmStr .= '<style>';
-    $frmStr .= '#destination_chosen .chosen-drop{width:400px;}#folder_chosen .chosen-drop{width:400px;}';
-    $frmStr .= '#modal_'.$actionId.'{height:96% !important;width:98% !important;min-width:1250px;overflow:hidden;}';
-    $frmStr .= '#modal_'.$actionId.'_layer{height:100% !important;width:98% !important;min-width:1250px;overflow:hidden;}';
-    $frmStr .= '#validleft{height:100% !important;width:30% !important;}';
-    $frmStr .= '#validright{width:67% !important;height:100% !important;}';
-    $frmStr .= '@media screen and (min-width: 1280px) {#validleft{width:447px !important;}}';
-    $frmStr .= '@media screen and (max-width: 1400px) {#validright{width:57% !important;}}';
-    $frmStr .= '#file_iframe{width:100% !important;height:100% !important;}';
-    $frmStr .= '#maarch_body{overflow:hidden !important;}';
-    $frmStr .= '</style>';
-    $frmStr .= '</div>';
-    $frmStr .= '</form>';
-
-    return addslashes($frmStr);
-}
-
-/**
- * Checks the action form.
- *
- * @param $formId String Identifier of the form to check
- * @param $values Array Values of the form
- *
- * @return bool true if no error, false otherwise
- **/
-function check_form($formId, $values)
-{
-    if ($_SESSION['upfile']['format'] == 'maarch') {
-        $_SESSION['upfile'] = [];
-        $_SESSION['upfile']['error'] = '0';
-        $_SESSION['upfile']['format'] = 'maarch';
-    } elseif (empty($_SESSION['upfile']['format'])) {
-        $_SESSION['action_error'] = _FILE.' '.strtolower(_MANDATORY);
-
-        return false;
-    }
-
-    //print_r($values);
-    $_SESSION['action_error'] = '';
-    if (count($values) < 1 || empty($formId)) {
-        $_SESSION['action_error'] = _FORM_ERROR;
-
-        return false;
-    } else {
-        //print_r($values);
-        $attach = get_value_fields($values, 'attach');
-        $collId = get_value_fields($values, 'coll_id');
-        if ($attach) {
-            $idDoc = get_value_fields($values, 'res_id');
-            if (!$idDoc || empty($idDoc)) {
-                $_SESSION['action_error'] .= _LINK_REFERENCE.'<br/>';
-            }
-            if (!empty($_SESSION['action_error'])) {
-                return false;
-            }
-        }
-        $catId = get_value_fields($values, 'category_id');
-        if (!$catId) {
-            $_SESSION['action_error'] = _CATEGORY.' '._IS_EMPTY;
-
-            return false;
-        }
-        $noError = process_category_check($catId, $values);
-
-        if ($noError == false) {
-            //$_SESSION['action_error'] .= _ERROR_CATEGORY;
-            return false;
-        }
-
-        if (isset($_SESSION['upfile']['format'])
-            && $_SESSION['upfile']['format'] != 'maarch'
-        ) {
-            $is = new indexing_searching_app();
-            $state = $is->is_filetype_allowed(
-                $_SESSION['upfile']['format']
-            );
-            if (!$state) {
-                $_SESSION['action_error'] .= '<br/>'
-                    .$_SESSION['upfile']['format']._FILETYPE.' '
-                    ._NOT_ALLOWED;
-
-                return false;
-            }
-        }
-
-        return check_docserver($collId);
-    }
-}
-
-/**
- * Makes all the checks on the docserver and store the file.
- *
- * @param $catId String Collection identifier
- *
- * @return bool true if no error, false otherwise
- **/
-function check_docserver($collId)
-{
-    $core = new core_tools();
-    $docserverControler = new docservers_controler();
-
-    $storeResult = array();
-
-    if (isset($_SESSION['indexing']['path_template']) && !empty($_SESSION['indexing']['path_template']) && isset($_SESSION['indexing']['destination_dir']) && !empty($_SESSION['indexing']['destination_dir']) && isset($_SESSION['indexing']['docserver_id']) && !empty($_SESSION['indexing']['docserver_id']) && isset($_SESSION['indexing']['file_destination_name']) && !empty($_SESSION['indexing']['file_destination_name'])
-    ) {
-        $_SESSION['action_error'] = _CHECK_FORM_OK;
-
-        return true;
-    }
-
-    if ($core->is_module_loaded('templates')
-        && $_SESSION['upfile']['format'] == 'maarch'
-    ) {
-        if (!isset($_SESSION['template_modified_content'])
-            || $_SESSION['template_content_same']
-        ) {
-            $_SESSION['action_error'] = _TEMPLATE.' '._IS_EMPTY;
-            unset($_SESSION['template_content_same']);
-
-            return false;
-        }
-        if (
-            !isset($_SESSION['upfile']['name'])
-            && $_SESSION['upfile']['name'] == ''
-        ) {
-            $_SESSION['upfile']['name'] = 'tmp_file_'
-                .$_SESSION['user']['UserId'].'_'.rand().'.maarch';
-            $tmpPath = $_SESSION['config']['tmppath'].DIRECTORY_SEPARATOR
-                .$_SESSION['upfile']['name'];
-            $myfile = fopen($tmpPath, 'w');
-            if (!$myfile) {
-                $_SESSION['action_error'] .= _FILE_OPEN_ERROR.'.<br/>';
-
-                return false;
-            }
-            fwrite($myfile, $_SESSION['template_modified_content']);
-            fclose($myfile);
-            $_SESSION['template_modified_content'] = '';
-            $_SESSION['upfile']['size'] = filesize($tmpPath);
-            $_SESSION['template_modified_content'] = '';
-        }
-    }
-    if ($_SESSION['origin'] == 'scan') {
-        $newFileName = 'tmp_file_'.$_SESSION['upfile']['md5'].'.'
-                     .strtolower($_SESSION['upfile']['format']);
-    } else {
-        $newFileName = $_SESSION['upfile']['name'];
-    }
-
-    $resource = file_get_contents($_SESSION['config']['tmppath'] . $newFileName);
-    $pathInfo = pathinfo($_SESSION['config']['tmppath'] . $newFileName);
-    $storeResult = \Docserver\controllers\DocserverController::storeResourceOnDocServer([
-        'collId'            => $collId,
-        'docserverTypeId'   => 'DOC',
-        'encodedResource'   => base64_encode($resource),
-        'format'            => $pathInfo['extension']
-    ]);
-
-    if (isset($storeResult['errors']) && $storeResult['errors'] != '') {
-        $_SESSION['action_error'] = $storeResult['errors'];
-
-        return false;
-    } else {
-        $_SESSION['indexing']['path_template'] = $storeResult['path_template'];
-        $_SESSION['indexing']['destination_dir'] = $storeResult['destination_dir'];
-        $_SESSION['indexing']['docserver_id'] = $storeResult['docserver_id'];
-        $_SESSION['indexing']['file_destination_name'] = $storeResult['file_destination_name'];
-        $_SESSION['indexing']['fingerPrint'] = $storeResult['fingerPrint'];
-        $_SESSION['action_error'] = _CHECK_FORM_OK;
-
-        return true;
-    }
-}
-
-/**
- * Checks the values of the action form for a given category.
- *
- * @param $catId String Category identifier
- * @param $values Array Values of the form to check
- *
- * @return bool true if no error, false otherwise
- **/
-function process_category_check($catId, $values)
-{
-    require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_types.php';
-
-    //print_r($values);
-    $core = new core_tools();
-    $type = new types();
-    $db = new Database();
-
-    // If No category : Error
-    if (!isset($_ENV['categories'][$catId])) {
-        $_SESSION['action_error'] = _CATEGORY.' '._UNKNOWN.': '.$catId;
-
-        return false;
-    }
-
-    // Simple cases
-    for ($i = 0; $i < count($values); ++$i) {
-        if (!isset($values[$i]['ID'])) {
-            $tmpId = 'none';
-        } else {
-            $tmpId = $values[$i]['ID'];
-        }
-
-        if (isset($_ENV['categories'][$catId][$tmpId]['mandatory'])
-           && $_ENV['categories'][$catId][$tmpId]['mandatory'] == true
-           && empty($values[$i]['VALUE'])
-        ) {
-            $_SESSION['action_error'] = $_ENV['categories'][$catId][$tmpId]['label']
-                                      .' '._IS_EMPTY;
-
-            return false;
-        }
-        if (isset($_ENV['categories'][$catId][$tmpId]['type_form'])
-            && $_ENV['categories'][$catId][$tmpId]['type_form'] == 'date'
-            && !empty($values[$i]['VALUE'])
-            && preg_match($_ENV['date_pattern'], $values[$i]['VALUE']) == 0
-        ) {
-            $_SESSION['action_error'] = $_ENV['categories'][$catId][$tmpId]['label']
-                                      .' '._WRONG_FORMAT;
-
-            return false;
-        }
-        if (isset($_ENV['categories'][$catId][$tmpId]['type_form'])
-            && $_ENV['categories'][$catId][$tmpId]['type_form'] == 'integer'
-            && !empty($values[$i]['VALUE'])
-            && preg_match('/^[0-9]*$/', $values[$i]['VALUE']) == 0
-        ) {
-            $_SESSION['action_error'] = $_ENV['categories'][$catId][$tmpId]['label']
-                                      .' '._WRONG_FORMAT;
-
-            return false;
-        }
-        if (isset($_ENV['categories'][$catId][$tmpId]['type_form'])
-            && $_ENV['categories'][$catId][$tmpId]['type_form'] == 'radio'
-            && !empty($values[$i]['VALUE'])
-            && !in_array(
-                $values[$i]['VALUE'],
-                $_ENV['categories'][$catId][$tmpId]['values']
-            )
-        ) {
-            $_SESSION['action_error'] = $_ENV['categories'][$catId][$tmpId]['label']
-                                      .' '._WRONG_FORMAT;
-
-            return false;
-        }
-    }
-    ///// Checks the complementary indexes depending on the doctype
-
-    $typeId = get_value_fields($values, 'type_id');
-    $collId = get_value_fields($values, 'coll_id');
-    $indexes = $type->get_indexes($typeId, $collId, 'minimal');
-    $valIndexes = array();
-    for ($i = 0; $i < count($indexes); ++$i) {
-        $valIndexes[$indexes[$i]] = get_value_fields($values, $indexes[$i]);
-    }
-    $testType = $type->check_indexes($typeId, $collId, $valIndexes);
-    if (!$testType) {
-        $_SESSION['action_error'] .= $_SESSION['error'];
-        $_SESSION['error'] = '';
-
-        return false;
-    }
-
-    ///////////////////////// Other cases
-    // Process limit Date
-    $_SESSION['store_process_limit_date'] = '';
-    if (isset($_ENV['categories'][$catId]['other_cases']['process_limit_date'])) {
-        $processLimitDateUseYes = get_value_fields(
-            $values,
-            'process_limit_date_use_yes'
-        );
-        $processLimitDateUseNo = get_value_fields(
-            $values,
-            'process_limit_date_use_no'
-        );
-        if ($processLimitDateUseYes == 'yes') {
-            $_SESSION['store_process_limit_date'] = 'ok';
-            $processLimitDate = get_value_fields($values, 'process_limit_date');
-            if (trim($processLimitDate) == '') {
-                $_SESSION['action_error'] = $_ENV['categories'][$catId]['other_cases']['process_limit_date']['label']
-                    .' '._IS_EMPTY;
-
-                return false;
-            } elseif (preg_match($_ENV['date_pattern'], $processLimitDate) == 0
-            ) {
-                $_SESSION['action_error'] = $_ENV['categories'][$catId]['other_cases']['process_limit_date']['label']
-                    .' '._WRONG_FORMAT;
-
-                return false;
-            }
-        } elseif ($processLimitDateUseNo == 'no') {
-            $_SESSION['store_process_limit_date'] = 'ko';
-        }
-        $processLimitDate = new datetime($processLimitDate);
-        $processLimitDate = date_add($processLimitDate, date_interval_create_from_date_string('23 hours + 59 minutes + 59 seconds'));
-    }
-
-    if (isset($_ENV['categories'][$catId]['priority'])) {
-        $priority = get_value_fields(
-            $values,
-            'priority'
-        );
-
-        if ($priority === '') {
-            $_SESSION['action_error'] = $_ENV['categories'][$catId]['priority']['label']
-                .' '.strtolower(_MANDATORY);
-
-            return false;
-        }
-    }
-
-    // Contact
-    if (isset($_ENV['categories'][$catId]['other_cases']['contact'])) {
-        $contactType = get_value_fields($values, 'type_contact_external');
-        if (!$contactType) {
-            $contactType = get_value_fields($values, 'type_contact_internal');
-        }
-        if (!$contactType) {
-            $contactType = get_value_fields($values, 'type_multi_contact_external');
-        }
-        if (!$contactType) {
-            $_SESSION['action_error'] = $_ENV['categories'][$catId]['other_cases']['type_contact']['label']
-                .' '.strtolower(_MANDATORY);
-
-            return false;
-        }
-        $contact = get_value_fields($values, 'contactid');
-        $nb_multi_contact = count($_SESSION['adresses']['to']);
-
-        $contact_field = get_value_fields($values, 'contact');
-
-        if ($contact_field != '' && empty($contact)) {
-            $_SESSION['action_error'] = $_ENV['categories'][$catId]['other_cases']['contact']['label']
-                .' '._WRONG_FORMAT.'. '._USE_AUTOCOMPLETION;
-
-            return false;
-        }
-
-        if ($_ENV['categories'][$catId]['other_cases']['contact']['mandatory'] == true) {
-            if ((empty($contact) && $contactType != 'multi_external') || ($nb_multi_contact == 0 && $contactType == 'multi_external')) {
-                $_SESSION['action_error'] = $_ENV['categories'][$catId]['other_cases']['contact']['label']
-                    .' '._IS_EMPTY;
-
-                return false;
-            }
-        }
-    }
-
-    if ($core->is_module_loaded('entities')) {
-        // Diffusion list
-        if (isset($_ENV['categories'][$catId]['other_cases']['diff_list'])
-            && $_ENV['categories'][$catId]['other_cases']['diff_list']['mandatory'] == true
-        ) {
-            if (empty($_SESSION['indexing']['diff_list']['dest']['users'][0])
-                || !isset($_SESSION['indexing']['diff_list']['dest']['users'][0])
-            ) {
-                $_SESSION['action_error'] = $_ENV['categories'][$catId]['other_cases']['diff_list']['label']
-                    .' '.strtolower(_MANDATORY);
-
-                return false;
-            }
-        }
-    }
-
-    //For specific case => chrono number
-    $chronoOut = get_value_fields($values, 'chrono_number');
-    if (isset($_ENV['categories'][$catId]['other_cases']['chrono_number'])
-        && $_ENV['categories'][$catId]['other_cases']['chrono_number']['mandatory'] == true
-    ) {
-        if ($chronoOut == false) {
-            $_SESSION['action_error'] = _NO_CHRONO_NUMBER_DEFINED.' ';
-
-            return false;
-        }
-    }
-
-    return true;
-}
-
-/**
- * Get the value of a given field in the values returned by the form.
- *
- * @param $values Array Values of the form to check
- * @param $field String the field
- *
- * @return string the value, false if the field is not found
- **/
-function get_value_fields($values, $field)
-{
-    for ($i = 0; $i < count($values); ++$i) {
-        if ($values[$i]['ID'] == $field) {
-            return  $values[$i]['VALUE'];
-        }
-    }
-
-    return false;
-}
-
-/**
- * Action of the form : loads the index in the db.
- *
- * @param $arrId Array Not used here
- * @param $history String Log the action in history table or not
- * @param $actionId String Action identifier
- * @param $label_action String Action label
- * @param $status String  Not used here
- * @param $collId String Collection identifier
- * @param $table String Table
- * @param $formValues array
- *
- * @return array
- *               $data['result'] : res_id of the new file followed by #
- *               $data['history_msg'] : Log complement (empty by default)
- *               $data['page_result'] : Page to load when action is done and modal closed
- **/
-function manage_form($arrId, $history, $actionId, $label_action, $status, $collId, $table, $formValues)
-{
-    if (empty($formValues) || count($arrId) < 1 || empty($collId)) {
-        $_SESSION['action_error'] = _ERROR_MANAGE_FORM_ARGS;
-
-        return false;
-    }
-
-    $db = new Database();
-    $sec = new security();
-    $req = new request();
-    $core = new core_tools();
-    $resource = new resource();
-    $type = new types();
-    $arrayPDO = array();
-    $_SESSION['data'] = array();
-    $valIndexes = array();
-
-    $resId = '';
-    $table = $sec->retrieve_table_from_coll($collId);
-    $indColl = $sec->get_ind_collection($collId);
-    $tableExt = $_SESSION['collections'][$indColl]['extensions'][0];
-    $queryExtFields = '(';
-    $queryExtValues = '(';
-    $_SESSION['origin'] = '';
-
-    // Load in the $_SESSION['data'] minimal indexes
-    array_push(
-        $_SESSION['data'],
-        array(
-            'column' => 'typist',
-            'value' => $_SESSION['user']['UserId'],
-            'type' => 'string',
-        )
-    );
-    array_push(
-        $_SESSION['data'],
-        array(
-            'column' => 'docserver_id',
-            'value' => $_SESSION['indexing']['docserver_id'],
-            'type' => 'string',
-        )
-    );
-
-    if (isset($_SESSION['upfile']['format'])) {
-        array_push(
-            $_SESSION['data'],
-            array(
-                'column' => 'format',
-                'value' => $_SESSION['upfile']['format'],
-                'type' => 'string',
-            )
-        );
-    }
-
-    $confidentiality_yes = get_value_fields($formValues, 'confidential');
-
-    if (!empty($confidentiality_yes)) {
-        array_push(
-            $_SESSION['data'],
-            array(
-                'column' => 'confidentiality',
-                'value' => $confidentiality_yes,
-                'type' => 'string',
-            )
-        );
-    } else {
-        $confidentiality_no = get_value_fields($formValues, 'no_confidential');
-        array_push(
-            $_SESSION['data'],
-            array(
-                'column' => 'confidentiality',
-                'value' => $confidentiality_no,
-                'type' => 'string',
-            )
-        );
-    }
-
-    //store the initiator entity
-    $initiator = get_value_fields($formValues, 'initiator');
-    if (!empty($initiator)) {
-        array_push(
-            $_SESSION['data'],
-            array(
-                'column' => 'initiator',
-                'value' => $initiator,
-                'type' => 'string',
-            )
-        );
-    } else {
-        if (isset($_SESSION['user']['primaryentity']['id'])) {
-            array_push(
-                $_SESSION['data'],
-                array(
-                    'column' => 'initiator',
-                    'value' => $_SESSION['user']['primaryentity']['id'],
-                    'type' => 'string',
-                )
-            );
-        }
-    }
-    $status_id = get_value_fields($formValues, 'status');
-    if (empty($status_id) || $status_id === '') {
-        $status_id = 'BAD';
-    }
-    array_push(
-        $_SESSION['data'],
-        array(
-            'column' => 'status',
-            'value' => $status_id,
-            'type' => 'string',
-        )
-    );
-    array_push(
-        $_SESSION['data'],
-        array(
-            'column' => 'offset_doc',
-            'value' => '',
-            'type' => 'string',
-        )
-    );
-
-    // //without file case
-    // if (
-    //     isset($_SESSION['with_file'])
-    //     && $_SESSION['with_file']
-    // ) {
-    //     array_push(
-    //         $_SESSION['data'],
-    //         array(
-    //             'column' => 'source',
-    //             'value' => 'with_empty_file',
-    //             'type' => 'string',
-    //         )
-    //     );
-    // }
-
-    $attach = get_value_fields($formValues, 'attach');
-
-    $catId = get_value_fields($formValues, 'category_id');
-
-    $queryExtFields .= 'category_id,';
-    $queryExtValues .= '?,';
-    $arrayPDO = array_merge($arrayPDO, array($catId));
-
-    // Specific indexes : values from the form
-    // Simple cases
-    for ($i = 0; $i < count($formValues); ++$i) {
-        $tmpId = $formValues[$i]['ID'];
-        if (isset($_ENV['categories'][$catId][$tmpId]['type_field'])
-            && $_ENV['categories'][$catId][$tmpId]['type_field'] == 'integer'
-            && $_ENV['categories'][$catId][$tmpId]['table'] != 'none'
-        ) {
-            if (isset($_ENV['categories'][$catId][$tmpId]['table'])
-                && $_ENV['categories'][$catId][$tmpId]['table'] == 'res'
-            ) {
-                array_push(
-                    $_SESSION['data'],
-                    array(
-                        'column' => $tmpId,
-                        'value' => $formValues[$i]['VALUE'],
-                        'type' => 'integer',
-                    )
-                );
-            } elseif (isset($_ENV['categories'][$catId][$tmpId]['table'])
-                && $_ENV['categories'][$catId][$tmpId]['table'] == 'coll_ext'
-            ) {
-                $queryExtFields .= $tmpId.',';
-                $queryExtValues .= ' ? ,';
-                $arrayPDO = array_merge($arrayPDO, array($formValues[$i]['VALUE']));
-            }
-        } elseif (isset($_ENV['categories'][$catId][$tmpId]['type_field'])
-            && isset($_ENV['categories'][$catId][$tmpId]['table'])
-            && $_ENV['categories'][$catId][$tmpId]['type_field'] == 'string'
-            && $_ENV['categories'][$catId][$tmpId]['table'] != 'none'
-        ) {
-            if ($_ENV['categories'][$catId][$tmpId]['table'] == 'res') {
-                array_push(
-                    $_SESSION['data'],
-                    array(
-                        'column' => $tmpId,
-                        'value' => $formValues[$i]['VALUE'],
-                        'type' => 'string',
-                    )
-                );
-            } elseif ($_ENV['categories'][$catId][$tmpId]['table'] == 'coll_ext') {
-                $queryExtFields .= $formValues[$i]['ID'].',';
-                $queryExtValues .= ' ? ,';
-                $arrayPDO = array_merge($arrayPDO, array($formValues[$i]['VALUE']));
-            }
-        } elseif (isset($_ENV['categories'][$catId][$tmpId]['type_field'])
-            && isset($_ENV['categories'][$catId][$tmpId]['table'])
-            && $_ENV['categories'][$catId][$tmpId]['type_field'] == 'date'
-            && $_ENV['categories'][$catId][$tmpId]['table'] != 'none'
-        ) {
-            if ($_ENV['categories'][$catId][$tmpId]['table'] == 'res') {
-                if (!empty($formValues[$i]['VALUE'])) {
-                    array_push(
-                        $_SESSION['data'],
-                        array(
-                            'column' => $tmpId,
-                            'value' => functions::format_date_db($formValues[$i]['VALUE']),
-                            'type' => 'date',
-                        )
-                    );
-                } else {
-                    array_push(
-                        $_SESSION['data'],
-                        array(
-                            'column' => $tmpId,
-                            'value' => null,
-                            'type' => 'date',
-                        )
-                    );
-                }
-            } elseif ($_ENV['categories'][$catId][$tmpId]['table'] == 'coll_ext') {
-                $queryExtFields .= $formValues[$i]['ID'].',';
-                $queryExtValues .= ' ? ,';
-                $arrayPDO = array_merge($arrayPDO, array(functions::format_date_db(
-                    $formValues[$i]['VALUE']
-                )));
-            }
-        }
-    }
-    ///// Manages the complementary indexes depending on the doctype
-    $typeId = get_value_fields($formValues, 'type_id');
-    $indexes = $type->get_indexes($typeId, $collId, 'minimal');
-
-    for ($i = 0; $i < count($indexes); ++$i) {
-        $valIndexes[$indexes[$i]] = get_value_fields(
-            $formValues,
-            $indexes[$i]
-        );
-    }
-    $_SESSION['data'] = $type->fill_data_array(
-        $typeId,
-        $collId,
-        $valIndexes,
-        $_SESSION['data']
-    );
-
-    ///////////////////////// Other cases
-    // Process limit Date
-    if (isset($_ENV['categories'][$catId]['other_cases']['process_limit_date'])) {
-        $processLimitDate = get_value_fields(
-            $formValues,
-            'process_limit_date'
-        );
-        $processLimitDate = new datetime($processLimitDate);
-        $processLimitDate = date_add($processLimitDate, date_interval_create_from_date_string('23 hours + 59 minutes + 59 seconds'));
-
-        $processLimitDate = (array) $processLimitDate;
-
-        if ($_ENV['categories'][$catId]['other_cases']['process_limit_date']['table'] == 'res') {
-            array_push(
-                $_SESSION['data'],
-                array(
-                    'column' => 'process_limit_date',
-                    'value' => functions::format_date_db($processLimitDate['date'], 'true', '', 'true'),
-                    'type' => 'date',
-                )
-            );
-        } elseif ($_ENV['categories'][$catId]['other_cases']['process_limit_date']['table'] == 'coll_ext') {
-            if ($_SESSION['store_process_limit_date'] == 'ok') {
-                $queryExtFields .= 'process_limit_date,';
-                $queryExtValues .= ' ? ,';
-                $arrayPDO = array_merge($arrayPDO, array(functions::format_date_db(
-                    $processLimitDate['date'],
-                    'true',
-                    '',
-                    'true'
-                )));
-            }
-            $_SESSION['store_process_limit_date'] = '';
-        }
-    }
-
-    if ($core->is_module_loaded('entities')) {
-        // Diffusion list
-        $loadListDiff = false;
-        if (isset($_ENV['categories'][$catId]['other_cases']['diff_list'])) {
-            if (!empty($_SESSION['indexing']['diff_list']['dest']['users'][0])
-                && isset($_SESSION['indexing']['diff_list']['dest']['users'][0])
-            ) {
-                array_push(
-                    $_SESSION['data'],
-                    array(
-                        'column' => 'dest_user',
-                        'value' => $_SESSION['indexing']['diff_list']['dest']['users'][0]['user_id'],
-                        'type' => 'string',
-                    )
-                );
-            }
-            $loadListDiff = true;
-        }
-    }
-
-    $data = \Resource\controllers\StoreController::prepareStorageRes([
-        'data'          => $_SESSION['data'],
-        'docserverId'   => $_SESSION['indexing']['docserver_id'],
-        'fileName'      => $_SESSION['indexing']['file_destination_name'],
-        'fileFormat'    => $_SESSION['upfile']['format'],
-        'fileSize'      => $_SESSION['upfile']['size'],
-        'path'          => $_SESSION['indexing']['destination_dir'],
-        'fingerPrint'   => $_SESSION['indexing']['fingerPrint']
-    ]);
-
-    $resId = \Resource\models\ResModel::create($data);
-    if ($catId != 'outgoing') {
-        \Convert\controllers\ConvertThumbnailController::convert(['collId' => 'letterbox_coll', 'resId' => $resId]);
-    }
-    //CONVERTED DOC
-    if (!empty($_SESSION['upfile']['fileNamePdfOnTmp'])) {
-        $resource = file_get_contents($_SESSION['config']['tmppath'] . $_SESSION['upfile']['fileNamePdfOnTmp']);
-        $pathInfo = pathinfo($_SESSION['config']['tmppath'] . $_SESSION['upfile']['fileNamePdfOnTmp']);
-        $storeResult = \Docserver\controllers\DocserverController::storeResourceOnDocServer([
-            'collId'            => 'letterbox_coll',
-            'docserverTypeId'   => 'CONVERT',
-            'encodedResource'   => base64_encode($resource),
-            'format'            => $pathInfo['extension']
-        ]);
-        \Convert\models\AdrModel::createDocumentAdr([
-            'resId'         => $resId,
-            'type'          => 'PDF',
-            'docserverId'   => $storeResult['docserver_id'],
-            'path'          => $storeResult['destination_dir'],
-            'filename'      => $storeResult['file_destination_name'],
-            'fingerprint'   => $storeResult['fingerPrint'],
-        ]);
-    } else {
-        \Convert\controllers\ConvertPdfController::convert([
-            'resId'     => $resId,
-            'collId'    => 'letterbox_coll',
-            'isVersion' => false,
-        ]);
-    }
-    \History\controllers\HistoryController::add([
-        'tableName' => 'res_letterbox',
-        'recordId'  => $resId,
-        'eventType' => 'ADD',
-        'info'      => _DOC_CREATED,
-        'moduleId'  => 'res',
-        'eventId'   => 'resadd',
-        'userId'    => $_SESSION['user']['UserId']
-    ]);
-
-    // Contact
-    if (isset($_ENV['categories'][$catId]['other_cases']['contact'])) {
-        $contact = get_value_fields($formValues, 'contact');
-
-        $contactType = get_value_fields(
-            $formValues,
-            'type_contact_external'
-        );
-
-        if (!$contactType) {
-            $contactType = get_value_fields(
-                $formValues,
-                'type_contact_internal'
-            );
-        }
-
-        if (!$contactType) {
-            $contactType = get_value_fields(
-                $formValues,
-                'type_multi_contact_external'
-            );
-        }
-
-        $nb_multi_contact = count($_SESSION['adresses']['to']);
-
-        if ($nb_multi_contact > 0 && $contactType == 'multi_external') {
-            for ($icontact = 0; $icontact < $nb_multi_contact; ++$icontact) {
-                $db->query(
-                    'INSERT INTO contacts_res (coll_id, res_id, contact_id, address_id) VALUES (?, ?, ?, ?)',
-                    array($collId, $resId, $_SESSION['adresses']['contactid'][$icontact], $_SESSION['adresses']['addressid'][$icontact])
-                );
-            }
-
-            $queryExtFields .= 'is_multicontacts,';
-            $queryExtValues .= "'Y',";
-        } else {
-            $contactId = get_value_fields($formValues, 'contactid');
-            $addressId = get_value_fields($formValues, 'addressid');
-
-            if (empty(trim($addressId))) {
-                $contactType = 'internal';
-            } else {
-                $contactType = 'external';
-            }
-
-            if ($contactType == 'internal') {
-                if ($catId == 'incoming' || $catId == 'internal' || $catId == 'ged_doc') {
-                    $queryExtFields .= 'exp_user_id,';
-                    $queryExtValues .= ' ?,';
-                    $arrayPDO = array_merge($arrayPDO, array($contactId));
-                } elseif ($catId == 'outgoing') {
-                    $queryExtFields .= 'dest_user_id,';
-                    $queryExtValues .= ' ?,';
-                    $arrayPDO = array_merge($arrayPDO, array($contactId));
-                }
-            } elseif ($contactType == 'external') {
-                if ($catId == 'incoming' || $catId == 'ged_doc') {
-                    $queryExtFields .= 'exp_contact_id,';
-                    $queryExtValues .= ' ?,';
-                    $arrayPDO = array_merge($arrayPDO, array($contactId));
-                } elseif ($catId == 'outgoing' || $catId == 'internal') {
-                    $queryExtFields .= 'dest_contact_id,';
-                    $queryExtValues .= ' ?,';
-                    $arrayPDO = array_merge($arrayPDO, array($contactId));
-                }
-                $queryExtFields .= 'address_id,';
-                $queryExtValues .= ' ?,';
-                $arrayPDO = array_merge($arrayPDO, array($addressId));
-            }
-        }
-    }
-
-    // Sender/Recipient
-    $srId = get_value_fields($formValues, 'sender_recipient_id');
-    $srType = get_value_fields($formValues, 'sender_recipient_type');
-
-    if (!empty($srId) && !empty($srType) && in_array($catId, ['incoming', 'outgoing', 'internal'])) {
-        if ($catId == 'incoming' || $catId == 'internal') {
-            $srMode = 'recipient';
-        } else {
-            $srMode = 'sender';
-        }
-        \Resource\models\ResourceContactModel::create([
-            'res_id'    => $resId,
-            'item_id'   => $srId,
-            'type'      => $srType,
-            'mode'      => $srMode
-        ]);
-    }
-
-    if ($resId != false) {
-        //Create chrono number
-        //######
-        $cTypeId = get_value_fields($formValues, 'type_id');
-        $cEntity = get_value_fields($formValues, 'destination');
-
-        $cChronoOut = get_value_fields($formValues, 'chrono_number');
-        $chronoX = new chrono();
-        $myVars = array(
-            'entity_id' => $cEntity,
-            'type_id' => $cTypeId,
-            'category_id' => $catId,
-            'folder_id' => $folderId,
-        );
-        $_SESSION['folderId'] = $folderId;
-        $myForm = array(
-            'chrono_out' => $cChronoOut,
-        );
-        $myChrono = $chronoX->generate_chrono($catId, $myVars, $myForm);
-
-        $queryExtFields .= 'alt_identifier,';
-        $queryExtValues .= ' ?,';
-        $arrayPDO = array_merge($arrayPDO, array($myChrono));
-        //######
-        $queryExtFields = preg_replace('/,$/', ',res_id)', $queryExtFields);
-        $queryExtValues = preg_replace(
-            '/,$/',
-            ', ?)',
-            $queryExtValues
-        );
-        $arrayPDO = array_merge($arrayPDO, array($resId));
-        $queryExt = ' INSERT INTO '.$tableExt.' '.$queryExtFields
-                   .' values '.$queryExtValues;
-
-        $db->query($queryExt, $arrayPDO);
-
-        if ($core->is_module_loaded('entities')) {
-            if ($loadListDiff) {
-                require_once 'modules'.DIRECTORY_SEPARATOR.'entities'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_manage_listdiff.php';
-                $diffList = new diffusion_list();
-                $params = array(
-                    'mode' => 'listinstance',
-                    'table' => $_SESSION['tablename']['ent_listinstance'],
-                    'coll_id' => $collId,
-                    'res_id' => $resId,
-                    'user_id' => $_SESSION['user']['UserId'],
-                );
-                $diffList->load_list_db(
-                    $_SESSION['indexing']['diff_list'],
-                    $params
-                );
-            }
-        }
-        if ($core->is_module_loaded('tags')) {
-            $tags = get_value_fields($formValues, 'tag_userform');
-            $tags_list = explode('__', $tags);
-            include_once 'modules'.DIRECTORY_SEPARATOR.'tags'.DIRECTORY_SEPARATOR.'tags_update.php';
-        }
-    } else {
-        $_SESSION['action_error'] = _ERROR_RES_ID;
-
-        return false;
-    }
-
-    $customId = \SrcCore\models\CoreConfigModel::getCustomId();
-    if (empty($customId)) {
-        $customId = 'null';
-    }
-    $user = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => $_SESSION['user']['UserId']]);
-    exec("php src/app/convert/scripts/FullTextScript.php --custom {$customId} --resId {$resId} --collId 'letterbox_coll' --userId {$user['id']} > /dev/null &");
-
-    if ($attach) {
-        $idDoc = get_value_fields($formValues, 'res_id');
-        $idDocTab = explode(',', $idDoc);
-        for ($i = 0; $i < count($idDocTab); ++$i) {
-            $queryLink = 'INSERT INTO res_linked (res_parent, res_child, coll_id) VALUES(?, ?, ?)';
-            $arrayPDO = array($idDocTab[$i], $resId, $_SESSION['collection_id_choice']);
-            $db->query($queryLink, $arrayPDO);
-        }
-        $hist2 = new history();
-        $hist2->add(
-            $table,
-           $resId,
-           'ADD',
-           'linkadd',
-           _LINKED_TO.$idDoc,
-           $_SESSION['config']['databasetype'],
-           'apps'
-        );
-
-        $hist3 = new history();
-        $hist3->add(
-            $table,
-            $idDoc,
-           'UP',
-           'linkup',
-           '(doc. '.$resId.')'._NOW_LINK_WITH_THIS_ONE,
-           $_SESSION['config']['databasetype'],
-           'apps'
-        );
-    }
-    if ($core->is_module_loaded('tags')) {
-        include_once 'modules'.DIRECTORY_SEPARATOR.'tags'.DIRECTORY_SEPARATOR.'tags_update.php';
-    }
-
-    unset($_SESSION['upfile']);
-    unset($_SESSION['data']);
-    $_SESSION['action_error'] = _NEW_DOC_ADDED;
-    $_SESSION['indexation'] = true;
-
-    if ($catId == 'incoming') {
-        if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'sendResourceToExternalApplication'])) {
-            $bodyData = [];
-            $config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'sendResourceToExternalApplication']);
-
-            if (!empty($config['inObject'])) {
-                $multipleObject = true;
-
-                foreach ($config['objects'] as $object) {
-                    $select = [];
-                    $tmpBodyData = [];
-                    if ($object['name'] != 'citoyen') {
-                        foreach ($object['rawData'] as $value) {
-                            $select[] = $value;
-                        }
-                    }
-
-                    $select[] = 'address_id';
-                    $select[] = 'external_id';
-                    $document = \Resource\models\ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$resId]]);
-                    if (!empty($document[0])) {
-                        if ($object['name'] == 'citoyen') {
-                            $contact = \Contact\models\ContactModel::getOnView(['select' => ['external_id', 'ca_id'], 'where' => ['ca_id = ?'], 'data' => [$document[0]['address_id']]]);
-                            $externalId = json_decode($contact[0]['external_id'], true);
-                        }
-                        foreach ($object['rawData'] as $key => $value) {
-                            if ($object['name'] == 'citoyen') {
-                                if ($value == 'external_id') {
-                                    $tmpBodyData[$key] = $externalId['localeoId'];
-                                } elseif ($value == 'address_id') {
-                                    $tmpBodyData[$key] = $contact[0]['ca_id'];
-                                } else {
-                                    $tmpBodyData[$key] = $contact[0][$value];
-                                }
-                            } else {
-                                $tmpBodyData[$key] = $document[0][$value];
-                            }
-                        }
-                    }
-
-                    if (!empty($object['data'])) {
-                        $tmpBodyData = array_merge($tmpBodyData, $object['data']);
-                    }
-
-                    $bodyData[$object['name']] = $tmpBodyData;
-                }
-
-                if (!empty($config['file'])) {
-                    $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $_SESSION['indexing']['docserver_id'], 'select' => ['path_template']]);
-                    $bodyData[$config['file']] = \SrcCore\models\CurlModel::makeCurlFile(['path' => $docserver['path_template'] . str_replace('#', '/', $_SESSION['indexing']['destination_dir']) . $_SESSION['indexing']['file_destination_name']]);
-                }
-            }
-
-            $response = \SrcCore\models\CurlModel::exec(['curlCallId' => 'sendResourceToExternalApplication', 'bodyData' => $bodyData, 'multipleObject' => $multipleObject, 'noAuth' => true]);
-
-            $externalId = json_decode($document[0]['external_id'], true);
-            $externalId['localeoId'] = $response[$config['return']['key']];
-
-            \Resource\models\ResModel::update(['set' => ['external_id' => json_encode($externalId)], 'where' => ['res_id = ?'], 'data' => [$resId]]);
-        }
-    }
-
-    return [
-        'result' => $resId.'#',
-        'history_msg' => '',
-        'page_result' => $_SESSION['config']['businessappurl']
-                         .'index.php?page=details&dir=indexing_searching'
-                         .'&coll_id='.$collId.'&id='.$resId,
-    ];
-}
diff --git a/apps/maarch_entreprise/actions/process.php b/apps/maarch_entreprise/actions/process.php
deleted file mode 100755
index e2208a8158f9f405cb8d2c4b5f196005de9a92a2..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/process.php
+++ /dev/null
@@ -1,785 +0,0 @@
-<?php
-
-/*
-*   Copyright 2008-2015 Maarch
-*
-*   This file is part of Maarch Framework.
-*
-*   Maarch Framework is free software: you can redistribute it and/or modify
-*   it under the terms of the GNU General Public License as published by
-*   the Free Software Foundation, either version 3 of the License, or
-*   (at your option) any later version.
-*
-*   Maarch Framework is distributed in the hope that it will be useful,
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*   GNU General Public License for more details.
-*
-*   You should have received a copy of the GNU General Public License
-*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/**
- * @brief Action : Process a document
- *
- * Open a modal box to displays the process form, make the form checks and loads the result in database.
- * Used by the core (manage_action.php page).
- *
- * @file
- *
- * @author Claire Figueras <dev@maarch.org>
- * @author Laurent Giovannoni <dev@maarch.org>
- * @date $date$
- *
- * @version $Revision$
- * @ingroup apps
- */
-
-/**
- * $confirm  bool false.
- */
-$confirm = false;
-/**
- * $etapes  array Contains 2 etaps : form and status (order matters).
- */
-$etapes = array('form');
-/**
- * $frm_width  Width of the modal (empty).
- */
-$frm_width = '';
-/**
- * $frm_height  Height of the modal (empty).
- */
-$frm_height = '';
-/**
- * $mode_form  Mode of the modal : fullscreen.
- */
-$mode_form = 'fullscreen';
-
-include 'apps/'.$_SESSION['config']['app_id'].'/definition_mail_categories.php';
-
-/**
- * Returns the indexing form text.
- *
- * @param $values Array Contains the res_id of the document to process
- * @param $path_manage_action String Path to the PHP file called in Ajax
- * @param $id_action String Action identifier
- * @param $table String Table
- * @param $module String Origin of the action
- * @param $coll_id String Collection identifier
- * @param $mode String Action mode 'mass' or 'page'
- *
- * @return string The form content text
- **/
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    //DECLARATIONS
-    require_once 'core/class/class_security.php';
-    require_once 'modules/basket/class/class_modules_tools.php';
-    require_once 'core/class/class_request.php';
-    require_once 'apps/'.$_SESSION['config']['app_id'].'/class/class_types.php';
-    require_once 'apps/'.$_SESSION['config']['app_id'].'/class/class_indexing_searching_app.php';
-    require_once 'apps/'.$_SESSION['config']['app_id'].'/class/class_chrono.php';
-
-    //INSTANTIATE
-    $type = new types();
-    $sec = new security();
-    $core_tools = new core_tools();
-    $b = new basket();
-    $is = new indexing_searching_app();
-    $cr = new chrono();
-    $db = new Database();
-    $data = array();
-    $indexes = array();
-
-    //INITIALIZE
-    $frm_str = '';
-    $_SESSION['stockCheckbox'] = '';
-    $_SESSION['req'] = 'action';
-    $res_id = $values[0];
-    $doctypes = $type->getArrayTypes($coll_id);
-    $params_data = array('show_folder' => true, 'show_description' => false, 'show_department_number_id' => false);
-    $data = get_general_data($coll_id, $res_id, 'full', $params_data);
-    $_SESSION['save_list']['fromProcess'] = 'true';
-    $_SESSION['count_view_baskets'] = 0;
-    $chrono_number = $cr->get_chrono_number($res_id, $sec->retrieve_view_from_table($table));
-    $_SESSION['doc_id'] = $res_id;
-    $stmt = $db->query("SELECT department_number_id, description FROM res_letterbox WHERE res_id = ?", array($res_id));
-    $resOther = $stmt->fetchObject();
-
-    //LAUNCH DOCLOCKER
-    $docLockerCustomPath = 'apps/maarch_entreprise/actions/docLocker.php';
-    $docLockerPath = $_SESSION['config']['businessappurl'].'/actions/docLocker.php';
-    if (is_file($docLockerCustomPath)) {
-        require_once $docLockerCustomPath;
-    } elseif (is_file($docLockerPath)) {
-        require_once $docLockerPath;
-    } else {
-        exit("can't find docLocker.php");
-    }
-
-    $docLocker = new docLocker($res_id);
-    if (!$docLocker->canOpen()) {
-        $docLockerscriptError = '<script>';
-        $docLockerscriptError .= 'destroyModal("modal_'.$id_action.'");';
-        $docLockerscriptError .= 'alert("'._DOC_LOCKER_RES_ID.''
-                .$res_id.''._DOC_LOCKER_USER.' '.functions::xssafe($_SESSION['userLock']).'");';
-        $docLockerscriptError .= '</script>';
-
-        return $docLockerscriptError;
-    }
-    // DocLocker constantly
-    $frm_str .= '<script>';
-    $frm_str .= 'intervalLockDocument('.$res_id.')';
-
-    /**************************************************************************MODIFIE LA LIGNE PRECEDENTE****************************************************************************************************/
-
-    $frm_str .= '</script>';
-
-    $docLocker->lock();
-
-    if (isset($data['type_id'])) {
-        $indexes = $type->get_indexes($data['type_id']['value'], $coll_id);
-        $fields = 'res_id';
-        foreach (array_keys($indexes) as $key) {
-            $fields .= ','.$key;
-        }
-        $stmt = $db->query('SELECT '.$fields.' FROM '.$table.' WHERE res_id = ?', array($res_id));
-        $values_fields = $stmt->fetchObject();
-        //print_r($indexes);
-    }
-    if ($core_tools->is_module_loaded('entities')) {
-        require_once 'modules/entities/class/class_manage_listdiff.php';
-        $listdiff = new diffusion_list();
-        $roles = $listdiff->list_difflist_roles();
-        $_SESSION['process']['diff_list'] = $listdiff->get_listinstance($res_id, false);
-        $_SESSION['process']['difflist_type'] = $listdiff->get_difflist_type($_SESSION['process']['diff_list']['object_type']);
-    }
-
-    //Load multicontacts
-    $query = 'SELECT c.firstname, c.lastname, c.society, c.contact_id, c.ca_id, c.contact_firstname, c.contact_lastname, c.is_corporate_person  ';
-    $query .= 'FROM view_contacts c, contacts_res cres  ';
-    $query .= "WHERE cres.coll_id = 'letterbox_coll' AND cres.res_id = ? AND cast (c.contact_id as varchar(128)) = cres.contact_id AND c.ca_id = cres.address_id ";
-    $query .= 'GROUP BY c.firstname, c.lastname, c.society, c.contact_id, c.ca_id, c.contact_firstname, c.contact_lastname, c.is_corporate_person';
-
-    $stmt = $db->query($query, array($res_id));
-    $nbContacts = 0;
-    $frameContacts = '';
-    $frameContacts = '{';
-    while ($res = $stmt->fetchObject()) {
-        $nbContacts = $nbContacts + 1;
-        if ($res->is_corporate_person == 'Y') {
-            $firstname = str_replace("'", "\'", $res->firstname);
-            $firstname = str_replace('"', ' ', $firstname);
-            $lastname = str_replace("'", "\'", $res->lastname);
-            $lastname = str_replace('"', ' ', $lastname);
-        } else {
-            $firstname = str_replace("'", "\'", $res->contact_firstname);
-            $firstname = str_replace('"', ' ', $firstname);
-            $lastname = str_replace("'", "\'", $res->contact_lastname);
-            $lastname = str_replace('"', ' ', $lastname);
-        }
-        $society = str_replace("'", "\'", $res->society);
-        $society = str_replace('"', ' ', $society);
-        $frameContacts .= "'contact ".$nbContacts."' : '"
-            .functions::xssafe($firstname).' '.functions::xssafe($lastname)
-            .' '.functions::xssafe($society)." (contact)', ";
-    }
-
-    $query = 'select u.firstname, u.lastname, u.user_id ';
-    $query .= 'from users u, contacts_res cres  ';
-    $query .= "where cres.coll_id = 'letterbox_coll' AND cres.res_id = ? AND cast (u.user_id as varchar(128)) = cres.contact_id ";
-    $query .= 'GROUP BY u.firstname, u.lastname, u.user_id';
-
-    $stmt = $db->query($query, array($res_id));
-
-    while ($res = $stmt->fetchObject()) {
-        $nbContacts = $nbContacts + 1;
-        $firstname = str_replace("'", "\'", $res->firstname);
-        $firstname = str_replace('"', ' ', $firstname);
-        $lastname = str_replace("'", "\'", $res->lastname);
-        $lastname = str_replace('"', ' ', $lastname);
-        $frameContacts .= "'contact ".$nbContacts."' : '"
-        .functions::xssafe($firstname).' '.functions::xssafe($lastname)." (utilisateur)', ";
-    }
-    $frameContacts = substr($frameContacts, 0, -2);
-    $frameContacts .= '}';
-
-    $frm_str .= '<form name="process" method="post" id="process" action="#" '
-            .'class="formsProcess addformsProcess" style="text-align:left;width:100%;">';
-
-    //_ID_TO_DISPLAY ?
-    if (_ID_TO_DISPLAY == 'res_id') {
-        //MODAL HEADER
-        $frm_str .= '<div style="margin:-10px;margin-bottom:10px;background-color: #135F7F;">';
-        $frm_str .= '<h2 class="tit" id="action_title" style="display:table-cell;vertical-align:middle;margin:0px;">'._PROCESS._LETTER_NUM.$res_id.' : ';
-        $frm_str .= '</h2>';
-        $frm_str .= '<div style="display:table-cell;vertical-align:middle;">';
-    } else {
-        //MODAL HEADER
-        $frm_str .= '<div style="margin:-10px;margin-bottom:10px;background-color: #135F7F;">';
-        $frm_str .= '<h2 class="tit" title="'._LETTER_NUM.$res_id.'" id="action_title" style="display:table-cell;vertical-align:middle;margin:0px;">'._PROCESS._MAIL.' '.$chrono_number.' : ';
-        $frm_str .= '</h2>';
-        $frm_str .= '<div style="display:table-cell;vertical-align:middle;">';
-    }
-
-    //GET ACTION LIST BY AJAX REQUEST
-    $frm_str .= '<span id="actionSpan"></span>';
-    $frm_str .= '<script>';
-    $frm_str .= 'change_category_actions(\''
-            .$_SESSION['config']['businessappurl']
-            .'index.php?display=true&dir=indexing_searching&page=change_category_actions'
-            .'&resId='.$res_id.'&collId='.$coll_id.'\',\''.$res_id.'\',\''.$coll_id.'\',\''.$data['category_id']['value'].'\');';
-    $frm_str .= '</script>';
-
-    $frm_str .= '<input type="button" name="send" id="send" value="'
-       ._VALIDATE
-
-         .'" class="button" onclick="intervalUnlockDocument('.$res_id.');valid_action_form(\'process\', \''
-
-        .$path_manage_action.'\', \''.$id_action.'\', \''
-        .$res_id.'\', \''.$table.'\', \''.$module.'\', \''
-        .$coll_id.'\', \''.$mode.'\');"/> ';
-    $frm_str .= '</div>';
-    $frm_str .= '</div>';
-
-    $frm_str .= '<i onmouseover="this.style.cursor=\'pointer\';" ';
-    $frm_str .= 'onclick="clearInterval(lockInterval);$j.ajax({url :\'index.php?display=true&dir=actions&page=docLocker\', type : \'POST\',data : {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': '.$res_id.'}, success: function (answer) { ';
-    $frm_str .= 'destroyModal(\'modal_'.$id_action.'\');triggerAngular(\'#/basketList/users/'.$_SESSION['urlV2Basket']['userId'].'/groups/'.$_SESSION['urlV2Basket']['groupIdSer'].'/baskets/'.$_SESSION['urlV2Basket']['basketId'].'\');';
-    $frm_str .= ' }});"';
-
-    $frm_str .= ' class="fa fa-times-circle fa-2x closeModale" title="'._CLOSE.'"/>';
-    $frm_str .= '</i>';
-    /********************************* LEFT PART **************************************/
-    $frm_str .= '<div style="height:90vh;overflow:auto;">';
-    $frm_str .= '<div id="validleftprocess" style="display:none;">';
-    $frm_str .= '<div id="frm_error_'.$id_action.'" class="error"></div>';
-    $frm_str .= '<input type="hidden" name="values" id="values" value="'.$res_id.'" />';
-    $frm_str .= '<input type="hidden" name="action_id" id="action_id" value="'.$id_action.'" />';
-    $frm_str .= '<input type="hidden" name="mode" id="mode" value="'.$mode.'" />';
-    $frm_str .= '<input type="hidden" name="table" id="table" value="'.$table.'" />';
-    $frm_str .= '<input type="hidden" name="coll_id" id="coll_id" value="'.$coll_id.'" />';
-    $frm_str .= '<input type="hidden" name="module" id="module" value="'.$module.'" />';
-    $frm_str .= '<input type="hidden" name="req" id="req" value="second_request" />';
-
-    $frm_str .= '<h3 onclick="new Effect.toggle(\'general_datas_div\', \'blind\', {delay:0.2});'
-            .'whatIsTheDivStatus(\'general_datas_div\', \'divStatus_general_datas_div\');return false;" '
-            .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-    $frm_str .= ' <span id="divStatus_general_datas_div" style="color:#1C99C5;"><i class="fa fa-minus-square"></i></span>&nbsp;<b>'
-            ._GENERAL_INFO.'</b>';
-    $frm_str .= '<span class="lb1-details">&nbsp;</span>';
-    $frm_str .= '</h3>';
-
-    //GENERAL DATAS
-    $frm_str .= '<div id="general_datas_div" style="display:block">';
-    $frm_str .= '<div>';
-    $frm_str .= '<table width="95%" align="left" border="0">';
-    // Displays the document indexes
-    foreach (array_keys($data) as $key) {
-        if (!in_array($key, ['is_multicontacts', 'barcode', 'external_id']) || ($key == 'is_multicontacts' && $data[$key]['show_value'] == 'Y') || (in_array($key, ['barcode', 'external_id']) && !empty($data[$key]['value']))) {
-            $frm_str .= '<tr>';
-            $frm_str .= '<td width="50%" align="left"><span class="form_title_process">'
-                .$data[$key]['label'].' :</span>';
-            if (isset($data[$key]['addon'])) {
-                $frm_str .= ' '.$data[$key]['addon'];
-            }
-            $frm_str .= '<td>';
-            
-            if ($data[$key]['display'] == 'textinput') {
-                $frm_str .= '<input type="text" name="'.$key.'" id="'.$key
-                .'" value="'.$data[$key]['show_value']
-                .'" readonly="readonly" class="readonly" style="border:none;" />';
-            } elseif ($data[$key]['display'] == 'textarea') {
-                if ($key == 'is_multicontacts') {
-                    $frm_str .= '<input type="hidden" name="'.$key.'" id="'.$key
-                        .'" value="'.$data[$key]['show_value']
-                        .'" readonly="readonly" class="readonly" style="border:none;" />';
-
-                    $frm_str .= '<div onClick="$(\'return_previsualise\').style.display=\'none\';" id="return_previsualise" style="cursor: pointer; display: none; border-radius: 10px; box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.4); padding: 10px; width: auto; height: auto; position: absolute; top: 0; left: 0; z-index: 999; background-color: rgba(255, 255, 255, 0.9); border: 3px solid #459ed1;">';
-                    $frm_str .= '<input type="hidden" id="identifierDetailFrame" value="" />';
-                    $frm_str .= '</div>';
-
-                    $frm_str .= '<input type="text" value="'.$nbContacts.' '._CONTACTS.'" readonly="readonly" class="readonly" size="40" style="cursor: pointer; border:none;" title="'._SHOW_MULTI_CONTACT.'" alt="'._SHOW_MULTI_CONTACT.'"';
-                    $frm_str .= 'onClick = "previsualiseAdminRead(event, '.$frameContacts.');"';
-                    $frm_str .= '/>';
-                } else {
-                    $rate = [];
-                    if ($key == 'exp_contact_id' || $key == 'dest_contact_id') {
-                        if (!empty($data[$key]['address_value'])) {
-                            $contactData = \Contact\models\ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$data[$key]['address_value']]]);
-                            $rate = \Contact\controllers\ContactController::getFillingRate(['contact' => (array)$contactData[0]]);
-                        }
-                    } elseif ($key == 'resourceContact') {
-                        if (!empty($data[$key]['item_id'])) {
-                            $contactData = \Contact\models\ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$data[$key]['item_id']]]);
-                            $rate = \Contact\controllers\ContactController::getFillingRate(['contact' => (array)$contactData[0]]);
-                        }
-                    }
-                    $frm_str .= '<textarea name="'.$key.'" id="'.$key.'" rows="3" readonly="readonly" class="readonly" '
-                        .'title="'.$data[$key]['show_value'].'" style="width: 150px; max-width: 150px; border: none; color: #666666;';
-                    if (!empty($rate['color'])) {
-                        $frm_str .= 'background-color:'.$rate['color'];
-                    }
-                    $frm_str .= '">' . $data[$key]['show_value'] .'</textarea>';
-                }
-            } elseif ($data[$key]['field_type'] == 'radio') {
-                for ($k = 0; $k < count($data[$key]['radio']); ++$k) {
-                    $frm_str .= '<input name ="'.$key.'" ';
-                    if ($data[$key]['value'] == $data[$key]['radio'][$k]['ID']) {
-                        $frm_str .= 'checked';
-                    }
-                    $frm_str .= ' type="radio" id="'.$key.'_'.$data[$key]['radio'][$k]['ID'].'" value="'.$data[$key]['radio'][$k]['ID'].'" disabled >'.$data[$key]['radio'][$k]['LABEL'];
-                }
-            }
-
-            if ($key == 'type_id') {
-                $_SESSION['category_id_session'] = $data[$key]['value'];
-            }
-                $frm_str .= '</td>';
-                $frm_str .= '</tr>';    
-        }
-    }
-    if ($chrono_number != '' && _ID_TO_DISPLAY == 'res_id') {
-        $frm_str .= '<tr>';
-        $frm_str .= '<td width="50%" align="left"><span class="form_title_process">'
-            ._CHRONO_NUMBER.' :</span></td>';
-        $frm_str .= '<td>';
-        $frm_str .= '<input type="text" name="alt_identifier" id="alt_identifier" value="'
-            .functions::xssafe($chrono_number)
-            .'" readonly="readonly" class="readonly" style="border:none;" />';
-        $frm_str .= '</td>';
-        $frm_str .= '</tr>';
-    }
-    if (count($indexes) > 0) {
-        foreach (array_keys($indexes) as $key) {
-            $frm_str .= '<tr>';
-            $frm_str .= '<td width="50%" align="left"><span class="form_title_process" >'
-                          .$indexes[$key]['label'].' :</span></td>';
-            $frm_str .= '<td>';
-            $frm_str .= '<textarea name="'.$key.'"';
-            $frm_str .= ' id="'.$key.'"';
-            if (!isset($indexes[$key]['readonly']) || $indexes[$key]['readonly'] == true) {
-                $frm_str .= 'readonly="readonly" class="readonly"';
-            } elseif ($indexes[$key]['type'] == 'date') {
-                $frm_str .= 'onclick="showCalender(this);"';
-            }
-            $frm_str .= 'style="width: 200px; max-width: 150px; border: medium none; color: rgb(102, 102, 102); height: 60px;"';
-            $frm_str .= '>'.str_replace(array("\n", "\r"), ' ', $values_fields->{$key});
-            $frm_str .= '</textarea>';
-            $frm_str .= '</td >';
-            $frm_str .= '</tr>';
-        }
-    }
-    //extension
-    $db = new Database();
-    $stmt = $db->query('SELECT format FROM '.$table.' WHERE res_id = ?', array($res_id));
-    $formatLine = $stmt->fetchObject();
-    $frm_str .= '<tr>';
-    $frm_str .= '<td width="50%" align="left"><span class="form_title_process">'._FORMAT.' :</span></td>';
-    $frm_str .= '<td>';
-    $frm_str .= '<input type="text" name="alt_identifier" id="alt_identifier" value="'
-        .functions::xssafe($formatLine->format).'" readonly="readonly" class="readonly" style="border:none;" />';
-    $frm_str .= '</td >';
-    $frm_str .= '</tr>';
-    $frm_str .= '</table>';
-    $frm_str .= '</div>';
-    $frm_str .= '</div><br/>';
-
-    /**** Other informations ****/
-    $frm_str .= '<h3 onclick="new Effect.toggle(\'complementary_fields\', \'blind\', {delay:0.2});'
-        .'whatIsTheDivStatus(\'complementary_fields\', \'divStatus_complementary_fields\');" '
-        .'class="categorie" style="width:90%;" onmouseover="this.style.cursor=\'pointer\';">';
-    $frm_str .= ' <span id="divStatus_complementary_fields" style="color:#1C99C5;"><i class="fa fa-minus-square"></i></span>&nbsp;'
-        ._OPT_INDEXES;
-    $frm_str .= '</h3>';
-
-    $frm_str .= '<table style="width:100%;" id="complementary_fields">';
-
-    //TAGS
-    if ($core_tools->is_module_loaded('tags') && ($core_tools->test_service('tag_view', 'tags', false) == 1)) {
-        include_once 'modules'.DIRECTORY_SEPARATOR.'tags'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'process'.DIRECTORY_SEPARATOR.'index.php';
-    }
-
-	//AUTRES INFORMATIONS
-	$frm_str .= '<tr id="description_tr" style="display:'.$display_value.';">';
-        $frm_str .= '<td colspan="2">' . _OTHERS_INFORMATIONS . '</td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<tr>';
-        $frm_str .= '<td class="indexing_field"><textarea style="width:97%;resize:vertical" type="text" name="description" id="description" rows="2"/>'.$resOther->description.'</textarea></td>';
-    $frm_str .= '</tr>';
-
-	//DEPARTEMENT CONCERNE
-	require_once("apps".DIRECTORY_SEPARATOR."maarch_entreprise".DIRECTORY_SEPARATOR."department_list.php");
-	$frm_str .= '<tr id="department_number_tr" style="display:'.$display_value.';">';
-        $frm_str .= '<td colspan="2">' . _DEPARTMENT_NUMBER . '</td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<tr>';
-        $frm_str .= '<td class="indexing_field"><input type="text" style="width:97%;" onkeyup="erase_contact_external_id(\'department_number\', \'department_number_id\');" name="department_number" id="department_number" value="';
-            if( isset($resOther->department_number_id) && !empty($resOther->department_number_id)) {
-                $frm_str .= $resOther->department_number_id . ' - ' . $depts[$resOther->department_number_id];
-            }                
-            $frm_str .= '"/><div id="show_department_number" class="autocomplete"></div></td>';
-    $frm_str .= '</tr>';
-	$frm_str .= '<input type="hidden" id="department_number_id" value="'.$resOther->department_number_id.'"/>';
-	$frm_str .='<input type="hidden" name="res_id_to_process" id="res_id_to_process"  value="' . $res_id . '" />';
-	//script
-        $frm_str .= '<script>';
-            $frm_str .= ' initList_hidden_input(\'department_number\', \'show_department_number\',\''
-				. $_SESSION['config']['businessappurl'] . 'index.php?display='
-				. 'true&page=autocomplete_department_number\','
-				. ' \'Input\', \'2\', \'department_number_id\');';
-        $frm_str .= '</script>';
-    $frm_str .= '</table>';
-    $frm_str .= '</div>';
-
-    // ****************************** RIGHT PART *******************************************/
-
-    $frm_str .= '<div id="validright" style="display:none;">';
-
-    /*** TOOLBAR ***/
-    $frm_str .= '<div class="block" align="center" style="height:20px;width=100%;">';
-
-    $frm_str .= '<table width="95%" cellpadding="0" cellspacing="0">';
-    $frm_str .= '<tr align="center">';
-
-    //HISTORY
-    if ($core_tools->test_service('view_doc_history', 'apps', false) || $core->test_service('view_full_history', 'apps', false)) {
-        $frm_str .= '<td>';
-
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-            .'index.php?display=true&page=show_history_tab&resId='
-            .$res_id.'&collId='.$coll_id;
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._DOC_HISTORY.'\',\''.$pathScriptTab.'\',\'history\');return false;" '
-            .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-        $frm_str .= '<span id="history_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>'
-            .'&nbsp;<i class="fa fa-history fa-2x" title="'._DOC_HISTORY.'"></i> <sup><span style="display:none;"></span></sup>';
-        $frm_str .= '</span>';
-        $frm_str .= '</td>';
-    }
-
-    //NOTE
-    if ($core_tools->is_module_loaded('notes')) {
-        $frm_str .= '<td>';
-
-        $pathScriptTab = $_SESSION['config']['businessappurl'].'index.php?display=true&module=notes&page=notes&identifier='.$res_id.'&origin=document&coll_id='.$coll_id.'&load&size=medium';
-
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._NOTES.'\',\''.$pathScriptTab.'\',\'notes\');return false;" '
-            .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-        $frm_str .= '<span id="notes_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>'
-            .'&nbsp;<i id="notes_tab_img" class="fa fa-pen-square fa-2x" title="'._NOTES.'"></i><span id="notes_tab_badge"></span>';
-        $frm_str .= '</span>';
-
-        //LOAD TOOLBAR BADGE
-        $toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&module=notes&page=load_toolbar_notes&resId='.$res_id.'&collId='.$coll_id;
-        $frm_str .= '<script>loadToolbarBadge(\'notes_tab\',\''.$toolbarBagde_script.'\');</script>';
-
-        $frm_str .= '</td>';
-    }
-
-    //SENDMAILS
-    if ($core_tools->is_module_loaded('sendmail') === true && $core_tools->test_service('sendmail', 'sendmail', false) === true) {
-        $frm_str .= '<td>';
-
-        $pathScriptTab = $_SESSION['config']['businessappurl'].'index.php?display=true&module=sendmail&page=sendmail&identifier='.$res_id.'&origin=document&coll_id='.$coll_id.'&load&size=medium';
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._SENDED_EMAILS.'\',\''.$pathScriptTab.'\',\'sendmail\');return false;" '
-            .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-        $frm_str .= '<span id="sendmail_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span><b>&nbsp;'
-            .'<i id="sendmail_tab_img" class="fa fa-envelope fa-2x" title="'._SENDED_EMAILS.'"></i><span id="sendmail_tab_badge"></span>';
-        $frm_str .= '</span>';
-
-        //LOAD TOOLBAR BADGE
-        $toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&module=sendmail&page=load_toolbar_sendmail&resId='.$res_id.'&collId='.$coll_id;
-        $frm_str .= '<script>loadToolbarBadge(\'sendmail_tab\',\''.$toolbarBagde_script.'\');</script>';
-
-        $frm_str .= '</td>';
-    }
-
-    //DIFFUSION LIST
-    if ($core_tools->is_module_loaded('entities')) {
-        $category = $data['category_id']['value'];
-        json_encode($roles);
-        $roles_str = json_encode($roles);
-        $frm_str .= '<td>';
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-                    .'index.php?display=true&page=show_diffList_tab&module=entities&resId='.$res_id.'&collId='.$coll_id.'&category='.$category.'&roles='.urlencode($roles_str);
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._DIFF_LIST_COPY.'\',\''.$pathScriptTab.'\',\'difflist\');return false;" '
-            .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-        $frm_str .= '<span id="difflist_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>'
-            .'&nbsp;<i class="fa fa-share-alt fa-2x" title="'._DIFF_LIST_COPY.'"></i> <sup><span style="display:none;"></span></sup>';
-        $frm_str .= '</span>';
-        $frm_str .= '</td>';
-    }
-
-    //VERSIONS (NOT USED ?)
-    if ($core->is_module_loaded('content_management') && $viewVersions) {
-        $versionTable = $sec->retrieve_version_table_from_coll_id(
-            $coll_id
-        );
-        $selectVersions = 'SELECT res_id FROM '
-            .$versionTable." WHERE res_id_master = ? and status <> 'DEL' order by res_id desc";
-        $dbVersions = new Database();
-        $stmt = $dbVersions->query($selectVersions, array($res_id));
-        $nb_versions_for_title = $stmt->rowCount();
-        $lineLastVersion = $stmt->fetchObject();
-        $lastVersion = $lineLastVersion->res_id;
-        if ($lastVersion != '') {
-            $objectId = $lastVersion;
-            $objectTable = $versionTable;
-        } else {
-            $objectTable = $sec->retrieve_table_from_coll(
-                $coll_id
-            );
-            $objectId = $res_id;
-            $_SESSION['cm']['objectId4List'] = $res_id;
-        }
-        if ($nb_versions_for_title == 0) {
-            $extend_title_for_versions = '0';
-            $class = 'nbResZero';
-            $style2 = 'display:none';
-            $style = 'opacity:0.5;';
-        } else {
-            $extend_title_for_versions = $nb_versions_for_title;
-            $class = 'nbRes';
-            $style = '';
-            $style2 = '';
-        }
-        $_SESSION['cm']['resMaster'] = '';
-        $frm_str .= '<td>';
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-                    .'index.php?display=true&page=show_versions_tab&collId='.$coll_id.'&resId='.$res_id.'&objectTable='.$objectTable;
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._VERSIONS.'\',\''.$pathScriptTab.'\',\'versions\');return false;" '
-            .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-        $frm_str .= '<span id="versions_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span><b>'
-            .'&nbsp;<i class="fa fa-code-branch fa-2x" style="'.$style.'" title="'._VERSIONS.'"></i> <sup><span id="nbVersions" style="'.$style2.'" class="'.$class.'">'
-            .$extend_title_for_versions.'</span></sup>';
-        $frm_str .= '</b></span>';
-        $frm_str .= '</td>';
-    }
-
-    //LINKS
-    $frm_str .= '<td>';
-
-    $pathScriptTab = $_SESSION['config']['businessappurl']
-                    .'index.php?display=true&page=show_links_tab';
-    $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._LINK_TAB.'\',\''.$pathScriptTab.'\',\'links\');return false;" '
-        .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-    $frm_str .= '<span id="links_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span><b>&nbsp;'
-            .'<i id="links_tab_img" class="fa fa-link fa-2x" title="'._LINK_TAB.'"></i><span id="links_tab_badge"></span>';
-    $frm_str .= '</span>';
-
-    //LOAD TOOLBAR BADGE
-    $toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&page=load_toolbar_links&resId='.$res_id.'&collId='.$coll_id;
-    $frm_str .= '<script>loadToolbarBadge(\'links_tab\',\''.$toolbarBagde_script.'\');</script>';
-
-    $frm_str .= '</td>';
-
-    //VISA CIRCUIT
-    if ($core_tools->is_module_loaded('visa')) {
-        if ($core->test_service('config_visa_workflow', 'visa', false)) {
-            $frm_str .= '<td>';
-
-            $pathScriptTab = $_SESSION['config']['businessappurl']
-                    .'index.php?display=true&page=show_visa_tab&module=visa&resId='.$res_id.'&collId='.$coll_id.'&destination='.$data['destination']['value'];
-
-            $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._VISA_WORKFLOW.'\',\''.$pathScriptTab.'\',\'visa\');return false;" '
-                .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-            $frm_str .= '<span id="visa_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span><b>&nbsp;'
-                .'<i id="visa_tab_img" class="fa fa-list-ol fa-2x" title="'._VISA_WORKFLOW.'"></i><span id="visa_tab_badge"></span>';
-            $frm_str .= '</span>';
-            $frm_str .= '</td>';
-
-            //LOAD TOOLBAR BADGE
-            $toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&module=visa&page=load_toolbar_visa&resId='.$res_id.'&collId='.$coll_id;
-            $frm_str .= '<script>loadToolbarBadge(\'visa_tab\',\''.$toolbarBagde_script.'\');</script>';
-        }
-    }
-
-    //AVIS CIRCUIT
-    if ($core_tools->is_module_loaded('avis')) {
-        if ($core->test_service('config_avis_workflow', 'avis', false)) {
-            $frm_str .= '<td>';
-
-            $pathScriptTab = $_SESSION['config']['businessappurl']
-                .'index.php?display=true&page=show_avis_tab&module=avis&resId='.$res_id.'&collId='.$coll_id;
-
-            $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_AVIS_WORKFLOW).'\',\''.$pathScriptTab.'\',\'avis\');return false;" '
-                .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-            $frm_str .= '<span id="avis_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span><b>&nbsp;'
-                .'<i id="avis_tab_img" class="fa fa-comment-alt fa-2x" title="'._AVIS_WORKFLOW.'"></i><span id="avis_tab_badge"></span>';
-            $frm_str .= '</span>';
-            $frm_str .= '</td>';
-
-            //LOAD TOOLBAR BADGE
-            $toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&module=avis&page=load_toolbar_avis&resId='.$res_id.'&collId='.$coll_id;
-            $frm_str .= '<script>loadToolbarBadge(\'avis_tab\',\''.$toolbarBagde_script.'\');</script>';
-        }
-    }
-
-    //ATTACHMENTS
-    if ($core_tools->is_module_loaded('attachments')) {
-        $frm_str .= '<td>';
-        $_SESSION['destination_entity'] = $data['destination']['value'];
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-                        .'index.php?display=true&page=show_attachments_tab&module=attachments&resId='.$res_id.'&collId='.$coll_id;
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_PJ).'\',\''.$pathScriptTab.'\',\'attachments\');return false;" '
-                  .'onmouseover="this.style.cursor=\'pointer\';" style="width:90%;">';
-
-        $frm_str .= '<span id="attachments_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span><b>&nbsp;'
-                .'<i id="attachments_tab_img" class="fa fa-paperclip fa-2x" title="'._PJ.'"></i><span id="attachments_tab_badge"></span>';
-        $frm_str .= '</span>';
-        $frm_str .= '</td>';
-
-        //LOAD TOOLBAR BADGE
-        $toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=load_toolbar_attachments&resId='.$res_id.'&collId='.$coll_id;
-        $frm_str .= '<script>loadToolbarBadge(\'attachments_tab\',\''.$toolbarBagde_script.'\');</script>';
-    }
-
-    //PRINT FOLDER
-    if ($core_tools->test_service('print_folder_doc', 'visa', false)) {
-        $frm_str .= '<td>';
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-                .'index.php?display=true&page=show_printFolder_tab&module=visa&resId='
-                .$res_id.'&collId='.$coll_id.'&table='.$table;
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_PRINTFOLDER).'\',\''.$pathScriptTab.'\',\'printfolder\');return false;" '
-                .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-        $frm_str .= ' <span id="printfolder_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>&nbsp;<i class="fa fa-print fa-2x" title="'._PRINTFOLDER.'"></i><sup><span style="display:none;"></span></sup>';
-        $frm_str .= '</span>';
-        $frm_str .= '</td>';
-    }
-
-    //END TOOLBAR
-    $frm_str .= '</table>';
-    $frm_str .= '</div>';
-    $frm_str .= '<div id =\'show_tab\' module=\'\'>';
-    $frm_str .= '</div>';
-
-    //RESOURCE FRAME
-
-    if ($data['category_id']['value'] == 'outgoing' && $_SESSION['features']['watermark']['enabled'] == 'true') {
-        $watermark_outgoing = 'true';
-    } else {
-        $watermark_outgoing = 'false';
-    }
-
-    $frm_str .= '<iframe src="../../rest/res/'.$res_id.'/content" name="viewframe" id="viewframe" scrolling="auto" frameborder="0" width="100%" style="width:100% !important;"></iframe>';
-
-    $frm_str .= '</div>';
-
-    //EXTRA SCRIPT
-    $frm_str .= '<script type="text/javascript">';
-    $frm_str .= 'window.scrollTo(0,0);';
-    $frm_str .= '$j("#validleftprocess").show();';
-    $frm_str .= '$j("#validright").show();';
-    $frm_str .= '$(\'entity\').style.visibility=\'hidden\';';
-    $frm_str .= '$(\'category\').style.visibility=\'hidden\';';
-    $frm_str .= '$(\'baskets\').style.visibility=\'hidden\';';
-    $frm_str .= '</script>';
-
-    /*** Extra CSS ***/
-    $frm_str .= '<style>';
-    $frm_str .= '#destination_chosen .chosen-drop{width:400px;}#folder_chosen .chosen-drop{width:400px;}';
-    $frm_str .= '#modal_'.$id_action.'{height:96% !important;width:98% !important;min-width:1250px;overflow:hidden;}';
-    $frm_str .= '#modal_'.$id_action.'_layer{height:100% !important;width:98% !important;min-width:1250px;overflow:hidden;}';
-    $frm_str .= '#validleftprocess{height:100% !important;width:300px !important;}';
-    $frm_str .= '#validright{width:76% !important;height:100% !important;}';
-    $frm_str .= '@media screen and (max-width: 1280px) {#validright{width:73% !important;}}';
-    $frm_str .= '#viewframe{width:100% !important;height:93% !important;}';
-    $frm_str .= '#maarch_body{overflow:hidden !important;}';
-    $frm_str .= '</style>';
-
-    $frm_str .= '</div>';
-    $frm_str .= '</form>';
-
-    return addslashes($frm_str);
-}
-
-/**
- * Checks the action form.
- *
- * @param $form_id String Identifier of the form to check
- * @param $values Array Values of the form
- *
- * @return bool true if no error, false otherwise
- **/
-function check_form($form_id, $values)
-{
-    $db = new Database();
-    $core = new core_tools();
-    $check = true;
-    $folder = '';
-    $folder_id = '';
-    $foldertype_id = '';
-
-    return $check;
-}
-
-/**
- * Action of the form : loads the index in the db.
- *
- * @param $arr_id Array Not used here
- * @param $history String Log the action in history table or not
- * @param $id_action String Action identifier
- * @param $label_action String Action label
- * @param $status String  Not used here
- * @param $coll_id String Collection identifier
- * @param $table String Table
- * @param $values_form String Values of the form to load
- *
- * @return false or an array
- *               $data['result'] : res_id of the new file followed by #
- *               $data['history_msg'] : Log complement (empty by default)
- **/
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form)
-{
-    if (empty($values_form) || count($arr_id) < 1 || empty($coll_id)) {
-        return false;
-    }
-    require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php';
-
-    $sec = new security();
-    $db = new Database();
-    $core = new core_tools();
-
-    $res_table = $sec->retrieve_table_from_coll($coll_id);
-    $ind = $sec->get_ind_collection($coll_id);
-    $table = $_SESSION['collections'][$ind]['extensions'][0];
-    $folder = '';
-
-    for ($j = 0; $j < count($values_form); ++$j) {
-        if ($values_form[$j]['ID'] == "description") {
-            $description = $values_form[$j]['VALUE'];
-        }
-        if ($values_form[$j]['ID'] == "department_number_id") {
-            $department_number_id = $values_form[$j]['VALUE'];
-        }
-        if ($values_form[$j]['ID'] == 'tag_userform') {
-            $tags = $values_form[$j]['VALUE'];
-        }
-    }
-
-    //DEPARTEMENT CONCERNE et DESCRIPTION
-    $db->query("UPDATE res_letterbox SET department_number_id = ?, description = ? WHERE res_id= ?",
-	array($department_number_id, $description, $arr_id[0]));
-
-    if ($core->is_module_loaded('tags')) {
-        $tags_list = explode('__', $tags);
-        include_once 'modules'.DIRECTORY_SEPARATOR.'tags'.DIRECTORY_SEPARATOR.'tags_update.php';
-    }
-
-    //DIFFLIST
-    if ($core->is_module_loaded('entities') && (empty($_SESSION['redirect']['diff_list']) || !is_array($_SESSION['redirect']['diff_list']) || count($_SESSION['redirect']['diff_list']) == 0)) {
-        require_once 'modules/entities/class/class_manage_listdiff.php';
-
-        $list = new diffusion_list();
-
-        $params = array('mode' => 'listinstance', 'table' => $_SESSION['tablename']['ent_listinstance'], 'coll_id' => $coll_id, 'res_id' => $arr_id[0], 'user_id' => $_SESSION['user']['UserId'], 'concat_list' => true, 'only_cc' => true);
-
-        $list->load_list_db($_SESSION['process']['diff_list'], $params); //pb enchainement avec action redirect
-    }
-    //$_SESSION['process']['diff_list'] = array();
-    $_SESSION['redirect']['diff_list'] = array();
-    unset($_SESSION['redirection']);
-    unset($_SESSION['redirect']);
-
-    return array('result' => $arr_id[0].'#', 'history_msg' => '');
-}
diff --git a/apps/maarch_entreprise/actions/validate_mail.php b/apps/maarch_entreprise/actions/validate_mail.php
deleted file mode 100755
index 52acaa2c1310c1ac8efd1b593807dec76cced422..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/validate_mail.php
+++ /dev/null
@@ -1,2006 +0,0 @@
-<?php
-/**
-* Copyright Maarch since 2008 under licence GPLv3.
-* See LICENCE.txt file at the root folder for more details.
-* This file is part of Maarch software.
-
-*
-* @brief   validate_mail
-*
-* @author  dev <dev@maarch.org>
-* @ingroup apps
-*/
-
-/**
- * $confirm  bool false.
- */
-$confirm = false;
-/**
- * $etapes  array Contains only one etap : form.
- */
-$etapes = array('form');
-/**
- * $frm_width  Width of the modal (empty).
- */
-$frm_width = '';
-/**
- * $frm_height  Height of the modal (empty).
- */
-$frm_height = '';
-/**
- * $mode_form  Mode of the modal : fullscreen.
- */
-$mode_form = 'fullscreen';
-
-$_SESSION['is_multi_contact'] = '';
-
-include 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'definition_mail_categories.php';
-
-///////////////////// Pattern to check dates
-$_ENV['date_pattern'] = '/^[0-3][0-9]-[0-1][0-9]-[1-2][0-9][0-9][0-9]$/';
-
-function check_category($coll_id, $res_id)
-{
-    require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php';
-    $sec = new security();
-    $view = $sec->retrieve_view_from_coll_id($coll_id);
-
-    $db = new Database();
-    $stmt = $db->query('SELECT category_id FROM '.$view.' WHERE res_id = ?', array($res_id));
-    $res = $stmt->fetchObject();
-
-    if (!isset($res->category_id)) {
-        $db->query('UPDATE res_letterbox SET category_id = ? WHERE res_id = ?',
-            array('incoming', $res_id));
-    }
-}
-
-/**
- * Returns the validation form text.
- *
- * @param $values Array Contains the res_id of the document to validate
- * @param $path_manage_action String Path to the PHP file called in Ajax
- * @param $id_action String Action identifier
- * @param $table String Table
- * @param $module String Origin of the action
- * @param $coll_id String Collection identifier
- * @param $mode String Action mode 'mass' or 'page'
- *
- * @return string The form content text
- **/
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    $displayValue = 'table-row';
-    //DECLARATIONS
-    require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php';
-    require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_business_app_tools.php';
-    require_once 'modules'.DIRECTORY_SEPARATOR.'basket'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_modules_tools.php';
-    require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_types.php';
-    require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php';
-
-    //INSTANTIATE
-    $sec = new security();
-    $core_tools = new core_tools();
-    $b = new basket();
-    $type = new types();
-    $db = new Database();
-
-    //INITIALIZE
-    $frm_str = '';
-    $_SESSION['stockCheckbox'] = '';
-    $_SESSION['ListDiffFromRedirect'] = false;
-    unset($_SESSION['m_admin']['contact']);
-    $_SESSION['req'] = 'action';
-    $res_id = $values[0];
-    $_SESSION['doc_id'] = $res_id;
-    $_SESSION['save_list']['fromValidateMail'] = 'true';
-    $_SESSION['count_view_baskets'] = 0;
-    check_category($coll_id, $res_id);
-    $data = get_general_data($coll_id, $res_id, 'minimal');
-    $_SESSION['category_id'] = $data['category_id']['value'];
-    $view = $sec->retrieve_view_from_coll_id($coll_id);
-    $stmt = $db->query('SELECT initiator, alt_identifier, creation_date FROM '.$view.' WHERE res_id = ?', array($res_id));
-    $resChrono = $stmt->fetchObject();
-    $chrono_number = explode('/', $resChrono->alt_identifier);
-    $chrono_number = $chrono_number[1];
-    $creation_date = functions::format_date_db($resChrono->creation_date, false);
-    $initiator = $resChrono->initiator;
-
-    //LAUNCH DOCLOCKER
-    $docLockerCustomPath = 'apps/maarch_entreprise/actions/docLocker.php';
-    $docLockerPath = $_SESSION['config']['businessappurl'].'/actions/docLocker.php';
-
-    if (is_file($docLockerCustomPath)) {
-        require_once $docLockerCustomPath;
-    } elseif (is_file($docLockerPath)) {
-        require_once $docLockerPath;
-    } else {
-        exit("can't find docLocker.php");
-    }
-
-    $docLocker = new docLocker($res_id);
-
-    if (!$docLocker->canOpen()) {
-        $docLockerscriptError = '<script>';
-        $docLockerscriptError .= 'destroyModal("modal_'.$id_action.'");';
-        $docLockerscriptError .= 'alert("'._DOC_LOCKER_RES_ID.''.$res_id.''._DOC_LOCKER_USER.' '.$_SESSION['userLock'].'");';
-        $docLockerscriptError .= '</script>';
-
-        return $docLockerscriptError;
-    }
-
-    // DocLocker constantly
-    $frm_str .= '<script>';
-    $frm_str .= 'intervalLockDocument('.$res_id.')';
-    $frm_str .= '</script>';
-
-    $docLocker->lock();
-
-    if ($_SESSION['features']['show_types_tree'] == 'true') {
-        $doctypes = $type->getArrayStructTypes($coll_id);
-    } else {
-        $doctypes = $type->getArrayTypes($coll_id);
-    }
-
-    $hidden_doctypes = array();
-
-    if ($core_tools->is_module_loaded('templates')) {
-        $stmt = $db->query('SELECT type_id FROM '.$_SESSION['tablename']['temp_templates_doctype_ext']." WHERE is_generated = 'NULL!!!'");
-        while ($res = $stmt->fetchobject()) {
-            array_push($hidden_doctypes, $res->type_id);
-        }
-    }
-    $today = date('d-m-Y');
-
-    if ($core_tools->is_module_loaded('entities')) {
-        //DECLARATIONS
-        require_once 'modules/entities/class/class_manage_entities.php';
-        require_once 'modules/entities/class/class_manage_listdiff.php';
-
-        //INSTANTIATE
-        $allEntitiesTree = array();
-        $ent = new entity();
-        $diff_list = new diffusion_list();
-
-        //INITIALIZE
-        $EntitiesIdExclusion = array();
-        $load_listmodel = true;
-
-        if (!empty($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['entities'])) {
-            $stmt = $db->query(
-                'SELECT entity_id FROM '
-                .ENT_ENTITIES.' WHERE entity_id not in ('
-                .$_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['entities']
-                .") and enabled= 'Y' order by entity_id"
-            );
-            while ($res = $stmt->fetchObject()) {
-                array_push($EntitiesIdExclusion, $res->entity_id);
-            }
-        }
-
-        $allEntitiesTree = $ent->getShortEntityTreeAdvanced(
-            $allEntitiesTree, 'all', '', $EntitiesIdExclusion, 'all'
-        );
-
-        //diffusion list in this basket ?
-        if ($_SESSION['current_basket']['difflist_type'] == 'entity_id') {
-            $target_model = 'document.getElementById(\'destination\').options[document.getElementById(\'destination\').selectedIndex]';
-            $func_load_listdiff_by_entity = 'change_entity(this.options[this.selectedIndex].value, \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=load_listinstance'.'\',\'diff_list_div\', \'indexing\', \''.$display_value.'\', \'\', $j(\'#category_id\').val());';
-        } elseif ($_SESSION['current_basket']['difflist_type'] == 'type_id') {
-            $target_model = 'document.getElementById(\'type_id\').options[document.getElementById(\'type_id\').selectedIndex]';
-            $func_load_listdiff_by_type = 'load_listmodel('.$target_model.', \'diff_list_div\', \'indexing\', $j(\'#category_id\').val());';
-        } else {
-            $target_model = 'document.getElementById(\'destination\').options[document.getElementById(\'destination\').selectedIndex]';
-            $func_load_listdiff_by_entity = 'change_entity(this.options[this.selectedIndex].value, \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=load_listinstance'.'\',\'diff_list_div\', \'indexing\', \''.$display_value.'\', \'\', $j(\'#category_id\').val());';
-        }
-
-        //LOADING LISTMODEL
-        $stmt = $db->query('SELECT res_id FROM '.$_SESSION['tablename']['ent_listinstance'].' WHERE res_id = ?', array($res_id));
-        if ($stmt->rowCount() > 0) {
-            $load_listmodel = false;
-            $_SESSION['indexing']['diff_list'] = $diff_list->get_listinstance($res_id);
-        }
-    }
-
-    //Load Multicontacts
-    //CONTACTS
-    $_SESSION['adresses']['to'] = array();
-    $_SESSION['adresses']['addressid'] = array();
-    $_SESSION['adresses']['contactid'] = array();
-
-    $query = 'SELECT c.is_corporate_person, c.is_private, c.contact_lastname, c.contact_firstname, c.society, c.society_short, c.contact_purpose_id, c.address_num, c.address_street, c.address_postal_code, c.address_town, c.lastname, c.firstname, c.contact_id, c.ca_id ';
-    $query .= 'FROM view_contacts c, contacts_res cres ';
-    $query .= "WHERE cres.coll_id = 'letterbox_coll' AND cres.res_id = ? AND cast (c.contact_id as varchar(128)) = cres.contact_id AND c.ca_id = cres.address_id";
-    $stmt = $db->query($query, array($res_id));
-
-    while ($res = $stmt->fetchObject()) {
-        if ($res->is_corporate_person == 'Y') {
-            $addContact = $res->society.' ';
-            if (!empty($res->society_short)) {
-                $addContact .= '('.$res->society_short.') ';
-            }
-        } else {
-            $addContact = $res->contact_lastname.' '.$res->contact_firstname.' ';
-            if (!empty($res->society)) {
-                $addContact .= '('.$res->society.') ';
-            }
-        }
-        if ($res->is_private == 'Y') {
-            $addContact .= '('._CONFIDENTIAL_ADDRESS.')';
-        } else {
-            require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_contacts_v2.php';
-            $contact = new contacts_v2();
-            $addContact .= '- '.$contact->get_label_contact($res->contact_purpose_id, $_SESSION['tablename']['contact_purposes']).' : ';
-            if (!empty($res->lastname) || !empty($res->firstname)) {
-                $addContact .= $res->lastname.' '.$res->firstname;
-            }
-            if (!empty($res->address_num) || !empty($res->address_street) || !empty($res->address_town) || !empty($res->address_postal_code)) {
-                $addContact .= ', '.$res->address_num.' '.$res->address_street.' '.$res->address_postal_code.' '.strtoupper($res->address_town);
-            }
-        }
-
-        array_push($_SESSION['adresses']['to'], $addContact);
-        array_push($_SESSION['adresses']['addressid'], $res->ca_id);
-        array_push($_SESSION['adresses']['contactid'], $res->contact_id);
-    }
-
-    $resourceContacts = \Resource\models\ResourceContactModel::getFormattedByResId(['resId' => $res_id]);
-
-    //USERS
-    $query = 'SELECT u.firstname, u.lastname, u.user_id ';
-    $query .= 'FROM users u, contacts_res cres ';
-    $query .= "WHERE cres.coll_id = 'letterbox_coll' AND cres.res_id = ? AND cast (u.user_id as varchar(128)) = cres.contact_id";
-    $stmt = $db->query($query, array($res_id));
-
-    while ($res = $stmt->fetchObject()) {
-        $addContact = $res->firstname.$res->lastname;
-        array_push($_SESSION['adresses']['to'], $addContact);
-        array_push($_SESSION['adresses']['addressid'], 0);
-        array_push($_SESSION['adresses']['contactid'], $res->user_id);
-    }
-
-    $frm_str .= '<form name="index_file" method="post" id="index_file" action="#" class="forms indexingform" style="text-align:left;width:100%;">';
-    //MODAL HEADER
-    $frm_str .= '<div style="margin:-10px;margin-bottom:10px;background-color: #135F7F;">';
-    if (_ID_TO_DISPLAY == 'res_id') {
-        $frm_str .= '<h2 class="tit" id="action_title" style="display:table-cell;vertical-align:middle;margin:0px;">'._VALIDATE_MAIL.' '._NUM.functions::xssafe($res_id).' : ';
-        $frm_str .= '</h2>';
-    } else {
-        $frm_str .= '<h2 class="tit" id="action_title" title="'._LETTER_NUM.$res_id.'" style="display:table-cell;vertical-align:middle;margin:0px;">'._PROCESS._DOCUMENT.' '.$resChrono->alt_identifier.' : ';
-        $frm_str .= '</h2>';
-    }
-
-    $frm_str .= '<div style="display:table-cell;vertical-align:middle;">';
-
-    //GET ACTION LIST BY AJAX REQUEST
-    $frm_str .= '<span id="actionSpan"></span>';
-
-    $frm_str .= '<input type="button" name="send" id="send" value="'._VALIDATE.'" class="button" onclick="if(document.getElementById(\'contactcheck\').value!=\'success\'){if (confirm(\''._CONTACT_CHECK.'\n\nContinuer ?\')){intervalUnlockDocument('.$res_id.');valid_action_form( \'index_file\', \''.$path_manage_action.'\', \''.$id_action.'\', \''.$res_id.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');}}else{intervalUnlockDocument('.$res_id.');valid_action_form( \'index_file\', \''.$path_manage_action.'\', \''.$id_action.'\', \''.$res_id.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');}"/> ';
-    $frm_str .= '</div>';
-    $frm_str .= '</div>';
-
-    $frm_str .= '<i onmouseover="this.style.cursor=\'pointer\';" ';
-    $frm_str .= 'onclick="clearInterval(lockInterval);$j.ajax({url :\'index.php?display=true&dir=actions&page=docLocker\', type : \'POST\',data : {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': '.$res_id.'}, success: function (answer) { ';
-    $frm_str .= 'destroyModal(\'modal_'.$id_action.'\');triggerAngular(\'#/basketList/users/'.$_SESSION['urlV2Basket']['userId'].'/groups/'.$_SESSION['urlV2Basket']['groupIdSer'].'/baskets/'.$_SESSION['urlV2Basket']['basketId'].'\');';
-    $frm_str .= ' }});"';
-    $frm_str .=' class="fa fa-times-circle fa-2x closeModale" title="'._CLOSE.'"/>';
-    $frm_str .= '</i>';
-
-    //PART LEFT
-    $frm_str .= '<div style="height:90vh;overflow:auto;">';
-    $frm_str .= '<div id="validleft" style="width:430px;">';
-    $frm_str .= '<div id="valid_div" style="display:none;";>';
-    $frm_str .= '<div id="frm_error_'.$id_action.'" class="indexing_error"></div>';
-
-    $frm_str .= '<input type="hidden" name="values" id="values" value="'.$res_id.'" />';
-    $frm_str .= '<input type="hidden" name="action_id" id="action_id" value="'.$id_action.'" />';
-    $frm_str .= '<input type="hidden" name="mode" id="mode" value="'.$mode.'" />';
-    $frm_str .= '<input type="hidden" name="table" id="table" value="'.$table.'" />';
-    $frm_str .= '<input type="hidden" name="coll_id" id="coll_id" value="'.$coll_id.'" />';
-    $frm_str .= '<input type="hidden" name="module" id="module" value="'.$module.'" />';
-    $frm_str .= '<input type="hidden" name="req" id="req" value="second_request" />';
-    $frm_str .= '<input type="hidden" id="check_days_before" value="'.$_SESSION['check_days_before'].'" />';
-
-    $frm_str .= '<div  style="display:block">';
-
-    //INDEXING MODELS
-    $query = 'SELECT * FROM indexingmodels order by label ASC';
-    $stmt = $db->query($query, array());
-
-    $frm_str .= '<div style="display:table;width:100%;">';
-    $frm_str .= '<div style="display:table-cell;vertical-align:middle;">';
-    $frm_str .= '</div>';
-    $frm_str .= '<div style="display:table-cell;text-align:right;vertical-align:middle;width: 12%;">';
-    $frm_str .= '<a style="cursor:pointer;"><i id="action1_indexingmodels" class="fa fa-plus fa-2x" onclick="saveIndexingModel();"></i></a> <a style="cursor:pointer;"><i class="fa fa-trash-alt fa-2x" onclick="delIndexingModel();"></i></a>';
-    $frm_str .= '</div>';
-    $frm_str .= '</div>';
-    $frm_str .= '<script>$j("#indexing_models_select").chosen({width: "100%", disable_search_threshold: 10, search_contains: true, allow_single_deselect: true});</script>';
-
-    $frm_str .= '<hr width="90%" align="center"/>';
-
-    $frm_str .= '<h4 onclick="new Effect.toggle(\'general_infos_div\', \'blind\', {delay:0.2});'
-        .'whatIsTheDivStatus(\'general_infos_div\', \'divStatus_general_infos_div\');" '
-        .'class="categorie" style="width:90%;" onmouseover="this.style.cursor=\'pointer\';">';
-    $frm_str .= ' <span id="divStatus_general_infos_div" style="color:#1C99C5;"><i class="fa fa-minus-square"></i></span>&nbsp;'
-        ._GENERAL_INFO;
-    $frm_str .= '</h4>';
-    $frm_str .= '<div id="general_infos_div"  style="display:inline">';
-    $frm_str .= '<div class="ref-unit">';
-    $frm_str .= '<table width="100%" align="center" border="0"  id="indexing_fields" style="display:block;">';
-
-    //NCH01
-    $frm_str .= '<tr id="attachment_tr" style="display:none'
-        .';">';
-    $frm_str .= '<td>'._LINK_TO_DOC.'</td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input type="radio" '
-        .'name="attachment" id="attach_reconciliation" value="true" checked="checked"'
-        .'onclick="show_attach(\'true\');"'
-        .' /> '
-        ._YES.' <input type="radio" name="attachment" id="no_attach"'
-        .' value="false" '
-        .'onclick="show_attach(\'false\');"'
-        .' /> '
-        ._NO.'</td>';
-    $frm_str .= ' <td><span class="red_asterisk" id="attachment_mandatory" '
-        .'style="display:inline;vertical-align:middle;"><i class="fa fa-star"></i></span></td>';
-    $frm_str .= '</tr>';
-
-    $frm_str .= '<tr id="attach_show" style="display:none;">';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td style="text-align: right;">';
-    $frm_str .= '<a ';
-    $frm_str .= 'href="javascript://" ';
-    $frm_str .= 'onclick="window.open(';
-    $frm_str .= '\''.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=search_adv&mode=popup&action_form=fill_input&modulename=attachments&init_search&nodetails\', ';
-    $frm_str .= '\'search_doc_for_attachment\', ';
-    $frm_str .= '\'scrollbars=yes,menubar=no,toolbar=no,resizable=yes,status=no,width=1100,height=775\'';
-    $frm_str .= ');"';
-    $frm_str .= ' title="'._SEARCH.'"';
-    $frm_str .= '>';
-    $frm_str .= '<span style="font-weight: bold;">';
-    $frm_str .= '<i class="fa fa-link"></i>';
-    $frm_str .= '</span>';
-    $frm_str .= '</a>';
-    $frm_str .= '</td>';
-    $frm_str .= '<td style="text-align: right;">';
-    $frm_str .= '<input ';
-    $frm_str .= 'type="text" ';
-    $frm_str .= 'name="res_id" ';
-    $frm_str .= 'id="res_id" ';
-    $frm_str .= 'class="readonly" ';
-    $frm_str .= 'readonly="readonly" ';
-    $frm_str .= 'value=""';
-    $frm_str .= '/>';
-    $frm_str .= '</td>';
-    $frm_str .= '<td>';
-    $frm_str .= '<span class="red_asterisk" id="attachment_link_mandatory" '
-        .'style="display:inline;vertical-align:middle;"><i class="fa fa-star"></i></span>';
-    $frm_str .= '</td>';
-    $frm_str .= '</tr>';
-    // END NCH01
-
-    /*** CODE BARRE ***/
-    $barcode = '';
-    if(isset($data['barcode'])&& !empty($data['barcode'])) {
-        $barcode = $data['barcode'];
-        $frm_str .= '<tr id="barcode_tr" style="display:' . $displayValue . ';">';
-        $frm_str .= '<td><label for="barcode" class="form_title" >'. _BARCODE . '</label></td>';
-        $frm_str .= '<td>&nbsp;</td>';
-        $frm_str .= '<td class="indexing_field"><input name="barcode" ' . 'type="text" id="barcode" value="'.$barcode.'" readonly="readonly" class="readonly"' . ' /></td>';
-        $frm_str .= '<td>&nbsp;</td>';
-        $frm_str .= '</tr>';
-    }
-    
-    /*** Category ***/
-    $frm_str .= '<tr id="category_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="category_id" class="form_title" >'._CATEGORY.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><select name="category_id" id="category_id" onchange="clear_error(\'frm_error_'
-        .$id_action.'\');change_category(this.options[this.selectedIndex].value, \''.$display_value.'\',  \''
-        .$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=change_category\',  \''
-        .$_SESSION['config']['businessappurl'].'index.php?display=true&page=get_content_js\');change_category_actions(\''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=change_category_actions'
-        .'&resId='.$res_id.'&collId='.$coll_id.'\',\''.$res_id.'\',\''.$coll_id.'\',this.options[this.selectedIndex].value);">';
-    $frm_str .= '<option value="">'._CHOOSE_CATEGORY.'</option>';
-    $frm_str .= '</select></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="category_id_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<script>$j("#category_id").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
-    /*** Doctype ***/
-    $frm_str .= '<tr id="type_id_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="type_id" class="form_title" id="doctype_res" style="display:none;">'._DOCTYPE.'</label><label for="type_id" class="form_title" id="doctype_mail" style="display:inline;" >'._DOCTYPE_MAIL.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><select name="type_id" id="type_id" onchange="clear_error(\'frm_error_'.$id_action.'\');changePriorityForSve(this.options[this.selectedIndex].value,\''
-        .$_SESSION['config']['businessappurl'].'index.php?display=true'
-        .'&dir=indexing_searching&page=priority_for_sve\');change_doctype(this.options[this.selectedIndex].value, \''.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=change_doctype\', \''._ERROR_DOCTYPE.'\', \''.$id_action.'\', \''.$_SESSION['config']['businessappurl'].'index.php?display=true&page=get_content_js\' , \''.$display_value.'\','.$res_id.', \''.$coll_id.'\')'.$func_load_listdiff_by_type.'">';
-    $frm_str .= '<option value="">'._CHOOSE_TYPE.'</option>';
-    if ($_SESSION['features']['show_types_tree'] == 'true') {
-        for ($i = 0; $i < count($doctypes); ++$i) {
-            $frm_str .= '<optgroup value="" class="' //doctype_level1
-                    .$doctypes[$i]['style'].'" label="'
-                    .functions::xssafe($doctypes[$i]['label']).'" >';
-            for ($j = 0; $j < count($doctypes[$i]['level2']); ++$j) {
-                $frm_str .= '<optgroup value="" class="' //doctype_level2
-                        .$doctypes[$i]['level2'][$j]['style'].'" label="&nbsp;&nbsp;'
-                        .functions::xssafe($doctypes[$i]['level2'][$j]['label']).'" >';
-                for ($k = 0; $k < count($doctypes[$i]['level2'][$j]['types']);
-                    ++$k
-                ) {
-                    if (!in_array($doctypes[$i]['level2'][$j]['types'][$k]['id'], $hidden_doctypes)) {
-                        $frm_str .= '<option data-object_type="type_id" value="'.functions::xssafe($doctypes[$i]['level2'][$j]['types'][$k]['id']).'" ';
-                        if (isset($data['type_id']) && !empty($data['type_id']) && $data['type_id'] == $doctypes[$i]['level2'][$j]['types'][$k]['id']) {
-                            $frm_str .= ' selected="selected" ';
-                        }
-                        $frm_str .= ' title="'.functions::xssafe($doctypes[$i]['level2'][$j]['types'][$k]['label'])
-                        .'" label="'.functions::xssafe($doctypes[$i]['level2'][$j]['types'][$k]['label'])
-                        .'">&nbsp;&nbsp;&nbsp;&nbsp;'.functions::xssafe($doctypes[$i]['level2'][$j]['types'][$k]['label']).'</option>';
-                    }
-                }
-                $frmStr .= '</optgroup>';
-            }
-            $frmStr .= '</optgroup>';
-        }
-    } else {
-        for ($i = 0; $i < count($doctypes); ++$i) {
-            $frm_str .= '<option value="'.functions::xssafe($doctypes[$i]['ID']).'" ';
-            if (isset($data['type_id']) && !empty($data['type_id']) && $data['type_id'] == $doctypes[$i]['ID']) {
-                $frm_str .= ' selected="selected" ';
-            }
-            $frm_str .= ' >'.functions::xssafe($doctypes[$i]['LABEL']).'</option>';
-        }
-    }
-    $frm_str .= '</select>';
-    $frm_str .= '<td><span class="red_asterisk" id="type_id_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<script>$j("#type_id").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
-    // NCH01 add attachment_type
-    $frm_str .= '<tr id="attachment_type_tr" style="display:none">';
-    $frm_str .='<td><label for="attachment_type" class="form_title" >'._ATTACHMENT_TYPE.'</label></td>';
-    $frm_str .='<td>&nbsp;</td>';
-    $frm_str .='<td class="indexing_field"><select name="attachment_type" id="attachment_type" onchange="display_chrono();clear_error(\'frm_error_'.$id_action.'\');">';
-    $frm_str .="<option value='' selected>". _CHOOSE_ATTACHMENT_TYPE . "</option>";
-    if(in_array('true',array_values($_SESSION['attachment_types_reconciliation']))){
-        foreach($_SESSION['attachment_types_reconciliation'] as $attachmentType => $isReconciliation){
-            if($isReconciliation == 'true'){
-                $frm_str .= "<option value='" . $attachmentType . "' with_chrono='" . $_SESSION['attachment_types_with_chrono'][$attachmentType] . "'>";
-                $frm_str .= $_SESSION['attachment_types'][$attachmentType];
-                $frm_str .= "</option>";
-            }
-        }
-    }else{
-        $frm_str .= "<option value='outgoing_mail_signed' with_chrono='" . $_SESSION['attachment_types_with_chrono']['outgoing_mail_signed'] . "' selected>" . $_SESSION['attachment_types']['outgoing_mail_signed'] . "</option>";
-    }
-    $frm_str .= '</select></td>';
-    $frm_str .='<td><span class="red_asterisk" id="attachment_type_mandatory" style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frm_str .= '</tr>';
-
-    /*** Object NCH01 ***/
-    $frm_str .= '<tr id="title_tr" style="display:none">';
-    $frm_str .= '<td><label for="title" class="form_title" >'._OBJECT.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input type="text" name="title" value="" id="title" onchange="clear_error(\'frm_error_'.$id_action.'\');"/></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="title_mandatory" style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frm_str .= '</tr>';
-
-    /*** Chrono number ***/
-    $frm_str .= '<tr id="chrono_number_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td><label for="chrono_number" class="form_title" >'._CHRONO_NUMBER.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input type="text" name="chrono_number" value="'
-        .functions::xssafe($chrono_number).'" id="chrono_number" onchange="clear_error(\'frm_error_'.$id_action.'\');"/></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="chrono_number_mandatory" style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frm_str .= '</tr>';
-
-    // NCH01 list of chrono number
-    $frm_str .= '<tr style="display:none" id="chrono_check"><td></td></tr>';
-    $frm_str .= '<tr id="list_chrono_number_tr" style="display:none">';
-    $frm_str .= '<td><label for="list_chrono_number" class="form_title" >'._CHRONO_NUMBER.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field" id="list_chrono_number"></td>';
-    $frm_str .= '<input type="hidden" name="hiddenChronoNumber" id="hiddenChronoNumber" value="">';
-    $frm_str .= '</tr>';
-    $frm_str .= '<tr style="display:none" id="chrono_number_generate"><td colspan="3" style="text-align:center">';
-    $frm_str .= '<a href="#" onclick="affiche_chrono_reconciliation()">'._GENERATE_CHRONO_NUMBER.'</a>';    // NCH01
-    $frm_str .= '</td></tr>';
-
-    /*** Priority ***/
-    $frm_str .= '<tr id="priority_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="priority" class="form_title" >'._PRIORITY.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><select name="priority" id="priority" onChange="updateProcessDate(\''
-                      .$_SESSION['config']['businessappurl'].'index.php?display=true'
-                      .'&dir=indexing_searching&page=update_process_date\');" onFocus="updateProcessDate(\''
-                      .$_SESSION['config']['businessappurl'].'index.php?display=true'
-                      .'&dir=indexing_searching&page=update_process_date\');clear_error(\'frm_error_'.$id_action
-                      .'\');">';
-    $frm_str .= '<option value="">'._CHOOSE_PRIORITY.'</option>';
-    for ($i = 0; $i < count($_SESSION['mail_priorities']); ++$i) {
-        $frm_str .= '<option value="'.functions::xssafe($_SESSION['mail_priorities_id'][$i]).'" ';
-        if (isset($data['type_id']) && $data['priority'] === $_SESSION['mail_priorities_id'][$i]) {
-            $frm_str .= 'selected="selected"';
-        } elseif ($data['priority'] == '' && $_SESSION['default_mail_priority'] == $i) {
-            $frm_str .= 'selected="selected"';
-        }
-        $frm_str .= '>'.functions::xssafe($_SESSION['mail_priorities'][$i]).'</option>';
-    }
-    $frm_str .= '</select></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="priority_mandatory" style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<script>$j("#priority").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
-    /*** Confidentiality ***/
-    $frm_str .= '<tr id="confidentiality_tr" style="display:'.$display_value
-            .';">';
-    $frm_str .= '<td><label for="confidentiality" class="form_title" >'
-            ._CONFIDENTIALITY.' </label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input type="radio" '
-            .'name="confidentiality" id="confidential" value="Y" />'
-            ._YES.' <input type="radio" name="confidentiality" id="no_confidential"'
-            .' value="N" checked="checked" />'
-            ._NO.'</td>';
-    $frm_str .= ' <td><span class="red_asterisk" id="confidentiality_mandatory" '
-            .'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frm_str .= '</tr>';
-
-    /*** Doc date ***/
-    $frm_str .= '<tr id="doc_date_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="doc_date" class="form_title" id="mail_date_label" style="display:inline;" >'._MAIL_DATE.'</label><label for="doc_date" class="form_title" id="doc_date_label" style="display:none;" >'._DOC_DATE.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input name="doc_date" type="text" id="doc_date" value="';
-    if (isset($data['doc_date']) && !empty($data['doc_date'])) {
-        $frm_str .= $data['doc_date'];
-    }
-    $frm_str .= '" placeholder="JJ-MM-AAAA" onfocus="checkRealDate(\'docDate\');" onChange="checkRealDate(\'docDate\');" onclick="clear_error(\'frm_error_'.$id_action.'\');showCalender(this);"/></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="doc_date_mandatory" style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frm_str .= '</tr >';    
-
-    /*** Author ***/
-    $frm_str .= '<tr id="author_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="author" class="form_title" >'._AUTHOR.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input name="author" type="text" id="author" onchange="clear_error(\'frm_error_'.$id_action.'\');"';
-    if (isset($data['author']) && !empty($data['author'])) {
-        $frm_str .= ' value="'.$data['author'].'" ';
-    } else {
-        $frm_str .= ' value="" ';
-    }
-    $frm_str .= '/></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="author_mandatory" style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frm_str .= '</tr>';
-
-    /*** Admission date ***/
-    $frm_str .= '<tr id="admission_date_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="admission_date" class="form_title" >'._RECEIVING_DATE.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input name="admission_date" type="text" id="admission_date" value="';
-    if (isset($data['admission_date']) && !empty($data['admission_date'])) {
-        $frm_str .= $data['admission_date'];
-    } else {
-        $frm_str .= $creation_date;
-    }
-    $frm_str .= '" onclick="clear_error(\'frm_error_'.$actionId.'\');'
-        .'showCalender(this);" onChange="checkRealDate(\'admissionDate\');updateProcessDate(\''
-        .$_SESSION['config']['businessappurl'].'index.php?display=true'
-        .'&dir=indexing_searching&page=update_process_date\');" onFocus="checkRealDate(\'admissionDate\');updateProcessDate(\''
-        .$_SESSION['config']['businessappurl'].'index.php?display=true'
-        .'&dir=indexing_searching&page=update_process_date\');"/></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="admission_date_mandatory" style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-    $frm_str .= '</tr>';
-     
-    /*** Reference courrier ***/
-    $frm_str .= '<tr id="external_reference_tr" style="display:' . $display_value . ';">';
-    $frm_str .= '<td><label for="external_reference" class="form_title" >' . _REFERENCE_MAIL
-            . '</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input name="external_reference" type="text" value="';
-        if( isset($data['external_reference']) && !empty($data['external_reference']))
-        {
-            $frm_str .= $data['external_reference'];
-        }                    
-        $frm_str .= '" id="external_reference"/></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '</tr>';
-
-    /*** Date de depart ***/
-    $frm_str .= '<tr id="departure_date_tr" style="display:' . $displayValue
-            . ';">';
-    $frm_str .= '<td><label for="departure_date" class="form_title" >'
-            . _EXP_DATE . '</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input name="departure_date" '
-            . 'type="text" id="departure_date" onclick="clear_error(\'frm_error_' . $id_action . '\');'
-            . 'showCalender(this);" onChange="checkRealDate(\'departure_date\');" onFocus="checkRealDate(\'departure_date\');" value="';        
-            if( isset($data['departure_date']) && !empty($data['departure_date'])) {
-                $frm_str .= $data['departure_date'];
-            }   
-            $frm_str .= '"/></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="departure_date_mandatory" '
-            . 'style="display:inline;">*</span>&nbsp;</td>';
-    $frm_str .= '</tr>';
-
-    /*** Contact ***/
-    $frm_str .= '<tr id="contact_choose_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="type_contact" class="form_title" ><span id="exp_contact_choose_label">'._SHIPPER_TYPE.'</span><span id="dest_contact_choose_label">'._DEST_TYPE.'</span></label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input type="radio" name="type_contact" id="type_contact_internal" value="internal"  class="check" onclick="clear_error(\'frm_error_'.$id_action.'\');change_contact_type(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts\', false);update_contact_type_session(\''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts_prepare_multi\');reset_check_date_exp();"';
-
-    $frm_str .= ' /><label for="type_contact_internal">'._INTERNAL2.'</label></td></tr>';
-
-    $frm_str .= '<tr id="contact_choose_2_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field">';
-    $frm_str .= '<input type="radio" name="type_contact" class="check" id="type_contact_external" value="external" onclick="clear_error(\'frm_error_'.$id_action.'\');change_contact_type(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts\', false);update_contact_type_session(\''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts_prepare_multi\');"';
-    if ($data['type_contact'] == 'external') {
-        $frm_str .= ' checked="checked" ';
-    }
-    $frm_str .= '/><label for="type_contact_external">'._EXTERNAL.'</label></td></tr>';
-
-    $frm_str .= '<tr id="contact_choose_3_tr" style="display:'.$displayValue.';">';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input type="radio" name="type_contact" '
-        .'id="type_multi_contact_external" value="multi_external" '
-        .'onclick="clear_error(\'frm_error_'.$id_action.'\');'
-        .'change_contact_type(\''.$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching'
-        .'&autocomplete_contacts\', true);update_contact_type_session(\''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts_prepare_multi\');"  class="check" ';
-    if ($data['type_contact'] == 'multi_external') {
-        $frm_str .= ' checked="checked" ';
-    }
-    $frm_str .= '/><label for="type_multi_contact_external">'._MULTI_CONTACT.'</label>'
-        .'</td>';
-    $frm_str .= '</tr>';
-
-    $frm_str .= '<tr id="contact_id_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label" style="vertical-align:bottom;"><label for="contact" class="form_title" ><span id="exp_contact">'._SHIPPER.'</span><span id="dest_contact">'._DEST.'</span>'
-        .'<span id="author_contact">'._AUTHOR_DOC.'</span>';
-    if ($core->test_admin('my_contacts', 'apps', false)) {
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-        .'index.php?display=false&dir=my_contacts&page=create_contact_iframe';
-        $frm_str .= ' <a href="#" id="create_contact" title="'._CREATE_CONTACT.'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\'\',\''.$pathScriptTab.'\',\'create_contact\');return false;" >'
-            .'<i class="fa fa-pen-square" title="'._CREATE_CONTACT.'"></i></a>';
-    } else {
-        $frm_str .= ' <a href="#" id="create_contact"/></a>';
-    }
-    $frm_str .= '</label></td>';
-    $contact_mode = 'view';
-    if ($core_tools->test_service('update_contacts', 'apps', false)) {
-        $contact_mode = 'up';
-    }
-    $frm_str .= '<td style="vertical-align:bottom;"><a href="#" id="contact_card" class="fa fa-book fa-2x" title="'._CONTACT_CARD.'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_CONTACT).'\',loadInfoContact(),\'info_contact\');return false;"'
-        .' style="visibility:hidden;display:inline;" ></a>&nbsp;</td>';
-    //Path to actual script
-    $path_to_script = $_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=contact_check&coll_id='.$collId;
-    $path_check_date_link = $_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=documents_list_mlb_search_adv&mode=popup&action_form=show_res_id&modulename=attachments&init_search&nodetails&fromContactCheck&fromValidateMail';
-    //check functions on load page
-    /* if (condition) {
-        $frm_str.="<script>check_date_exp('".$path_to_script."');</script>";
-    }*/
-
-    $frm_str .= '<td class="indexing_field">';
-    if ($data['type_contact'] == 'internal') {
-        //MODIF:
-        $frm_str .= ' <i class="fa fa-user" title="'._SINGLE_CONTACT.'" style="cursor:pointer;color:#135F7F;" id="type_contact_internal_icon" onclick="$j(\'#type_contact_internal\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\', \'#666\');$j(\'#type_contact_internal_icon\').css(\'color\', \'#135F7F\');$j(\'#type_multi_contact_internal_icon\').css(\'color\', \'#666\');"></i>';
-    } else {
-        //MODIF:
-        $frm_str .= ' <i class="fa fa-user" title="'._SINGLE_CONTACT.'" style="cursor:pointer;color:#135F7F;" id="type_contact_external_icon" onclick="$j(\'#type_contact_external\')[0].click();$j(\'#type_contact_external_icon\').css(\'color\', \'#666\');$j(\'#type_contact_external_icon\').css(\'color\', \'#135F7F\');$j(\'#type_multi_contact_external_icon\').css(\'color\', \'#666\');"></i>';
-    }
-
-    $frm_str .= ' <i class="fa fa-users" title="'._MULTI_CONTACT.'" style="cursor:pointer;" id="type_multi_contact_external_icon" onclick="$j(\'#type_multi_contact_external\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\',\'#666\');$j(\'#type_contact_external_icon\').css(\'color\',\'#666\');$j(\'#type_multi_contact_external_icon\').css(\'color\',\'#135F7F\');"></i>';
-
-    if (!empty($data['addressId'])) {
-        $contactData = \Contact\models\ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$data['addressId']]]);
-        $rate = \Contact\controllers\ContactController::getFillingRate(['contact' => (array)$contactData[0]]);
-    }
-
-    $frm_str .= '<span style="position:relative;"><input type="text" placeholder="'._CONTACTS_USERS_SEARCH.'" onkeyup="erase_contact_external_id(\'contact\', \'contactid\');erase_contact_external_id(\'contact\', \'addressid\');" name="contact" id="contact" onchange="clear_error(\'frm_error_'.$id_action.'\');display_contact_card(\'visible\');" onblur="display_contact_card(\'visible\');if(document.getElementById(\'type_contact_external\').checked == true){check_date_exp(\''.$path_to_script.'\',\''.$path_check_date_link.'\');}"';
-    if (isset($data['contact']) && !empty($data['contact'])) {
-        $frm_str .= ' value="'.$data['contact'].'" ';
-    }
-    if (!empty($rate['color'])) {
-        $frm_str .= ' style="background-color:'.$rate['color'].'" ';
-    }
-
-    $frm_str .= ' /><div id="show_contacts" class="autocomplete autocompleteIndex" style="width:100%;left:0px;top:17px;"></div><div class="autocomplete autocompleteIndex" id="searching_autocomplete" style="display: none;text-align:left;padding:5px;left:0px;width:100%;top:17px;"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i> chargement ...</div></span></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="contact_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<tr style="display:none" id="contact_check"><td></td></tr>';
-    $frm_str .= '<input type="hidden" id="contactid" ';
-    if (isset($data['contactId']) && !empty($data['contactId'])) {
-        $frm_str .= ' value="'.$data['contactId'].'" ';
-    }
-    $frm_str .= '/>';
-    $frm_str .= '<input type="hidden" id="addressid" ';
-    if (isset($data['addressId']) && !empty($data['addressId'])) {
-        $frm_str .= ' value="'.$data['addressId'].'" ';
-    }
-    $frm_str .= '/>';
-    $frm_str .= '<input type="hidden" id="contactcheck" value="success"/>';
-
-    /****multicontact***/
-
-    //Path to actual script
-    $path_to_script = $_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=add_multi_contacts&coll_id='.$collId;
-
-    //$_SESSION['adresses'] = '';
-
-    $frm_str .= '<tr id="add_multi_contact_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td><label for="contact" class="form_title" >'
-        .'<span id="exp_multi_contact">'._SHIPPER.'</span>'
-        .'<span id="dest_multi_contact">'._DEST.'</span>';
-
-    if ($core->test_admin('my_contacts', 'apps', false)) {
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-            .'index.php?display=false&dir=my_contacts&page=create_contact_iframe';
-        $frm_str .= ' <a href="#" id="create_multi_contact" title="'._CREATE_CONTACT
-            .'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\'\',\''.$pathScriptTab.'\',\'create_contact\');return false;" '
-            .'style="display:inline;" ><i class="fa fa-pen-square" title="'._CREATE_CONTACT.'"></i></a>';
-    }
-    $frm_str .= '</label></td>';
-    $contact_mode = 'view';
-    if ($core->test_service('update_contacts', 'apps', false)) {
-        $contact_mode = 'update';
-    }
-    $frm_str .= '<td><a href="#" id="multi_contact_card" class="fa fa-book fa-2x" title="'._CONTACT_CARD
-        .'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_CONTACT).'\',loadInfoContact(),\'info_contact\');return false;" '
-        .'style="visibility:hidden;display:inline;text-align:right;" ></a>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field">';
-
-    //$frm_str .= '<i class="fa fa-user" title="'._INTERNAL2.'" style="cursor:pointer;" id="type_contact_internal_icon" onclick="$$(\'#type_contact_internal\')[0].click();$(\'type_contact_internal_icon\').setStyle({color: \'#135F7F\'});$(\'type_contact_external_icon\').setStyle({color: \'#666\'});$(\'type_multi_contact_external_icon\').setStyle({color: \'#666\'});"></i>';
-
-    $frm_str .= ' <i class="fa fa-user" title="'._SINGLE_CONTACT.'" style="cursor:pointer;" id="type_contact_external_icon" onclick="$j(\'#type_contact_external\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\',\'#666\');$j(\'#type_contact_external_icon\').css(\'color\',\'#135F7F\');$j(\'#type_multi_contact_external_icon\').css(\'color\',\'#666\');"></i>';
-
-    $frm_str .= ' <i class="fa fa-users" title="'._MULTI_CONTACT.'" style="cursor:pointer;color:#135F7F;" id="type_multi_contact_external_icon" onclick="$j(\'#type_multi_contact_external\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\',\'#666\');$j(\'#type_contact_external_icon\').css(\'color\',\'#666\');$j(\'#type_multi_contact_external_icon\').css(\'color\',\'#135F7F\');"></i>';
-
-    $frm_str .= '<span style="position:relative;"><input type="text" name="email" id="email" placeholder="'._CONTACTS_USERS_GROUPS_SEARCH.'" onblur="clear_error(\'frm_error_'.$id_action.'\');display_contact_card(\'visible\', \'multi_contact_card\');"/>';
-    $frm_str .= '<div id="multiContactList" class="autocomplete" style="left:0px;width:100%;top:17px;"></div><div class="autocomplete autocompleteIndex" id="searching_autocomplete_multi" style="display: none;text-align:left;padding:5px;left:0px;width:100%;top:17px;"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i> chargement ...</div></span>';
-    $frm_str .= '<script type="text/javascript">addMultiContacts(\'email\', \'multiContactList\', \''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts\', \'Input\', \'2\', \'contactid\', \'addressid\');</script>';
-    $frm_str .= '<input type="button" name="add" value="&nbsp;'._ADD
-        .'&nbsp;" id="valid_multi_contact" class="button" onclick="updateMultiContacts(\''.$path_to_script
-        .'&mode=adress\', \'add\', document.getElementById(\'email\').value, '
-        .'\'to\', false, document.getElementById(\'addressid\').value, document.getElementById(\'contactid\').value);display_contact_card(\'hidden\', \'multi_contact_card\');" />';
-    $frm_str .= '</td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<tr id="show_multi_contact_tr">';
-    $frm_str .= '<td align="right" nowrap width="10%" id="to_multi_contact"><label>'
-        ._SEND_TO_SHORT.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td><td style="width:200px"><div name="to" id="to" class="multicontactInput">';
-
-    $nbContacts = count($_SESSION['adresses']['to']);
-
-    if ($nbContacts > 0) {
-        for ($icontacts = 0; $icontacts < $nbContacts; ++$icontacts) {
-            $frm_str .= '<div class="multicontact_element" id="'.$icontacts.'_'.$_SESSION['adresses']['to'][$icontacts].'">'.$_SESSION['adresses']['to'][$icontacts];
-            //if ($readOnly === false) {
-            $frm_str .= '&nbsp;<div class="email_delete_button" id="'.$icontacts.'"'
-                    .'onclick="updateMultiContacts(\''.$path_to_script
-                    .'&mode=adress\', \'del\', \''.$_SESSION['adresses']['to'][$icontacts].'\', \'to\', this.id, \''.$_SESSION['adresses']['addressid'][$icontacts].'\', \''.$_SESSION['adresses']['contactid'][$icontacts].'\');" alt="'._DELETE.'" title="'
-                    ._DELETE.'">x</div>';
-            //}
-            $frm_str .= '</div>';
-        }
-    }
-
-    $frm_str .= '</div></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="contact_mandatory" '
-                    .'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frm_str .= '</tr>';
-
-    if ($_SESSION['modules_loaded']['attachments']['reconciliation']['close_incoming'] == 'true') {  // NCH01 - Close incoming
-        $frm_str .= '<tr style="display:none" id="close_incoming">';
-        $frm_str .= '<td><label for="close_incoming_mail" class="form_title" >'._CLOSE_INCOMING.'</label></td>';
-        $frm_str .= '<td>&nbsp;</td>';
-        $frm_str .= '<td class="indexing_field"><input type="radio" id="close_incoming_mail" name="close_incoming_mail" value="true">  '._YES.'  ';
-        $frm_str .= '<input type="radio" id="close_incoming_mail" name="close_incoming_mail" checked="checked" value="false">  '._NO.'  </td>';
-        $frm_str .= '</tr>';
-    }
-
-    foreach ($resourceContacts as $resourceContact) {
-        if ($resourceContact['mode'] == 'recipient' && ($data['category_id']['value'] == 'incoming' || $data['category_id']['value'] == 'internal')) {
-            $sr = $resourceContact;
-        } elseif ($resourceContact['mode'] == 'sender' && $data['category_id']['value'] == 'outgoing') {
-            $sr = $resourceContact;
-        }
-    }
-    $rate = [];
-    if (!empty($sr['type']) && $sr['type'] == 'contact') {
-        $contactData = \Contact\models\ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$sr['item_id']]]);
-        $rate = \Contact\controllers\ContactController::getFillingRate(['contact' => (array)$contactData[0]]);
-    }
-
-    /*** Sender/Recipient ***/
-    $frm_str .= '<tr id="sender_recipient_tr" style="display:' . $displayValue . ';">';
-    $frm_str .= '<td><label for="sender_recipient" class="form_title" >';
-    $frm_str .= '<span id="sr_sender_span">'._SHIPPER.'</span>';
-    $frm_str .= '<span id="sr_recipient_span">'._DEST.'</span>';
-    $frm_str .= '</label></td>';
-    if (!empty($sr['format']) && $sr['type'] != 'entity') {
-        $cardVisibility = 'visible';
-    } else {
-        $cardVisibility = 'hidden';
-    }
-    $frm_str .= '<td><a href="#" id="sender_recipient_card" class="fa fa-book fa-2x" title="'._CONTACT_CARD
-    .'" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_CONTACT).'\',loadInfoContactSenderRecipient(),\'info_contact\');return false;" '
-    .'style="visibility:'.$cardVisibility.';" ></a>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field">';
-    $frm_str .= '<i id="sender_recipient_icon_contactsUsers" class="fa fa-user" onclick="switchAutoCompleteType(\'sender_recipient\',\'contactsUsers\', false);" style="color:#135F7F;display: inline-block;cursor:pointer;" title="'._CONTACTS_USERS_LIST.'" ></i> <i id="sender_recipient_icon_entities" class="fa fa-sitemap" onclick="switchAutoCompleteType(\'sender_recipient\',\'entities\', false);" style="display: inline-block;cursor:pointer;" title="'._ENTITIES_LIST.'" ></i>';
-    $frm_str .= '<div class="typeahead__container"><div class="typeahead__field"><span class="typeahead__query">';
-    $frm_str .= '<input name="sender_recipient" type="text" placeholder="'._CONTACTS_USERS_SEARCH.'" id="sender_recipient" autocomplete="off"';
-    if (!empty($sr['format'])) {
-        $frm_str .= ' value="'. $sr['format'].'"';
-    }
-    if (!empty($rate['color'])) {
-        $frm_str .= ' style="background-color:'.$rate['color'].'"';
-    }
-    $frm_str .= '/></span></div></div>';
-    $frm_str .= '</td><td>&nbsp;</td>';
-    $frm_str .= '<input type="hidden" id="sender_recipient_id"';
-    if (!empty($sr['item_id'])) {
-        $frm_str .= 'value="'. $sr['item_id'].'"';
-    }
-    $frm_str .= '/>';
-    $frm_str .= '<input type="hidden" id="sender_recipient_type"';
-    if (!empty($sr['type'])) {
-        $frm_str .= 'value="'. $sr['type'].'"';
-    }
-
-    $frm_str .= '/>';
-    if ($sr['type'] == 'entity') {
-        $frm_str .= '<script>$j("#sender_recipient_icon_contactsUsers").css({"color":"#666"});</script>';
-        $frm_str .= '<script>$j("#sender_recipient_icon_entities").css({"color":"#135F7F"});</script>';
-    } else {
-        $frm_str .= '<script>$j("#sender_recipient_icon_contactsUsers").css({"color":"#135F7F"});</script>';
-        $frm_str .= '<script>$j("#sender_recipient_icon_entities").css({"color":"#666"});</script>';
-    }
-    $frm_str .= '</tr>';
-
-    /*** 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>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input type="text" name="reference_number" id="reference_number"';
-    if (isset($data['reference_number']) && $data['reference_number'] != '') {
-        $frm_str .= 'value = "'.$data['reference_number'].'"';
-    }
-    $frm_str .= '/></td>';
-    $frm_str .= '</tr>';
-
-    /*** Initiator ***/
-    $frm_str .= '<tr id="initiator_tr" style="display:'.$displayValue.';">';
-    $frm_str .= '<td><label for="intitiator" class="form_title" >'
-            ._INITIATOR.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field">'
-            .'<select name="initiator" id="initiator">';
-    if ($initiator) {
-        $frm_str .= '<optgroup label="Service initiateur actuel">';
-        $frm_str .= '<option value="'.$initiator.'">'.$ent->getentitylabel($initiator).'</option>';
-        $frm_str .= '</optgroup>';
-    }
-    $frm_str .= '<optgroup label="Autre(s) service(s) disponible">';
-    foreach ($_SESSION['user']['entities'] as $entity) {
-        $frm_str .= '<option value="'.$entity['ENTITY_ID'].'"';
-        if ($_SESSION['user']['primaryentity']['id'] == $entity['ENTITY_ID'] && (empty($initiator) || $initiator == null)) {
-            $frm_str .= ' selected="selected" ';
-        }
-        $frm_str .= '>'.$entity['ENTITY_LABEL'].'</option>';
-    }
-    $frm_str .= '</optgroup>';
-    $frm_str .= '</select>'
-            .'</td>';
-    $frm_str .= '<td><span class="red_asterisk" '
-            .'id="initiator_mandatory" style="display:inline;"><i class="fa fa-star"></i>'
-            .'</span>&nbsp;</td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<script>$j("#initiator").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-
-    /*** Subject ***/
-    $frm_str .= '<tr id="subject_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="subject" class="form_title" >'._SUBJECT.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><textarea style="resize:vertical" name="subject" id="subject" rows="4" onchange="clear_error(\'frm_error_'.$id_action.'\');" >';
-    if (isset($data['subject']) && !empty($data['subject'])) {
-        $frm_str .= $data['subject'];
-    }
-    $frm_str .= '</textarea></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="subject_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frm_str .= '</tr>';
-
-    /*** Entities : department + diffusion list ***/
-    if ($core_tools->is_module_loaded('entities')) {
-        $_SESSION['validStep'] = 'ok';
-        $countAllEntities = count($allEntitiesTree);
-
-        $frm_str .= '<tr id="department_tr" style="display:'.$display_value.';">';
-        $frm_str .= '<td class="indexing_label"><label for="destination" class="form_title" id="label_dep_dest" style="display:inline;" >'._DEPARTMENT_DEST.'</label><label for="destination" class="form_title" id="label_dep_exp" style="display:none;" >'._DEPARTMENT_EXP.'</label><label for="destination" '.'class="form_title" id="label_dep_owner" style="display:none;" >'._DEPARTMENT_OWNER.'</label></td>';
-        $frm_str .= '<td>&nbsp;</td>';
-        $frm_str .= '<td class="indexing_field"><select name="destination" id="destination" onchange="clear_error(\'frm_error_'.$id_action.'\');'.$func_load_listdiff_by_entity.'">';
-        $frm_str .= '<option value="">'._CHOOSE_DEPARTMENT.'</option>';
-
-        for ($cptEntities = 0; $cptEntities < $countAllEntities; ++$cptEntities) {
-            if (!$allEntitiesTree[$cptEntities]['KEYWORD']) {
-                $frm_str .= '<option data-object_type="entity_id" value="'.$allEntitiesTree[$cptEntities]['ID'].'"';
-                if (isset($data['destination']) && $data['destination'] == $allEntitiesTree[$cptEntities]['ID']) {
-                    $frm_str .= ' selected="selected"';
-                }
-                if ($allEntitiesTree[$cptEntities]['DISABLED']) {
-                    $frm_str .= ' disabled="disabled" class="disabled_entity"';
-                } else {
-                    //$frm_str .= ' style="font-weight:bold;"';
-                }
-                $frm_str .= '>'
-                    .functions::show_string($allEntitiesTree[$cptEntities]['SHORT_LABEL'])
-                    .'</option>';
-            }
-        }
-        $frm_str .= '</select></td>';
-        $frm_str .= '<td><span class="red_asterisk" id="destination_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-        $frm_str .= '</tr>';
-        $frm_str .= '<tr id="diff_list_tr" style="display:none;">';
-        $frm_str .= '<td colspan="3">';
-        $frm_str .= '<div id="diff_list_div" class="scroll_div" style="width:420px; max-width: 420px;"></div>';
-        $frm_str .= '</td>';
-        $frm_str .= '</tr>';
-        $frm_str .= '<script>$j("#destination").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-    }
-
-    /*** Process limit date ***/
-    $frm_str .= '<tr id="process_limit_date_use_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="process_limit_date_use" class="form_title" >'._PROCESS_LIMIT_DATE_USE.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input type="radio"  class="check" name="process_limit_date_use" id="process_limit_date_use_yes" value="yes" ';
-    if ($data['process_limit_date_use'] == true) {
-        $frm_str .= ' checked="checked"';
-    }
-    $frm_str .= ' onclick="clear_error(\'frm_error_'.$id_action.'\');activate_process_date(true, \''.$display_value.'\');" />'._YES.'<input type="radio" name="process_limit_date_use"  class="check"  id="process_limit_date_use_no" value="no" onclick="clear_error(\'frm_error_'.$id_action.'\');activate_process_date(false, \''.$display_value.'\');" ';
-    if (!isset($data['process_limit_date_use'])) {
-        $frm_str .= ' checked="checked"';
-    }
-    $frm_str .= '/>'._NO.'</td>';
-    $frm_str .= '<td><span class="red_asterisk" id="process_limit_date_use_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frm_str .= '</tr>';
-    $frm_str .= '<tr id="process_limit_date_tr" style="display:'.$display_value.';">';
-    $frm_str .= '<td class="indexing_label"><label for="process_limit_date" class="form_title" >'._PROCESS_LIMIT_DATE.'</label></td>';
-    $frm_str .= '<td>&nbsp;</td>';
-    $frm_str .= '<td class="indexing_field"><input name="process_limit_date" type="text" id="process_limit_date"  onclick="clear_error(\'frm_error_'.$id_action.'\');showCalender(this);" value="';
-    if (isset($data['process_limit_date']) && !empty($data['process_limit_date'])) {
-        $frm_str .= $data['process_limit_date'];
-    }
-    $frm_str .= '"/></td>';
-    $frm_str .= '<td><span class="red_asterisk" id="process_limit_date_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
-    $frm_str .= '</tr>';
-
-    /*** Status ***/
-    // Select statuses from groupbasket
-    $statuses = array();
-
-    /* Basket of ABS users */
-    if ($_SESSION['current_basket']['abs_basket'] == '1') {
-        $query = "SELECT group_id FROM usergroup_content WHERE user_id= ? AND primary_group='Y'";
-        $stmt = $db->query($query, array($_SESSION['current_basket']['basket_owner']));
-        $grp_status = $stmt->fetchObject();
-        $owner_usr_grp = $grp_status->group_id;
-        $owner_basket_id = str_replace('_'.$_SESSION['current_basket']['basket_owner'], '', $_SESSION['current_basket']['id']);
-    } else {
-        $owner_usr_grp = $_SESSION['current_basket']['group_id'];
-        $owner_basket_id = $_SESSION['current_basket']['id'];
-    }
-    $query = 'SELECT status_id, label_status FROM groupbasket_status left join status on status_id = id '
-        .' WHERE basket_id= ? and (group_id = ?) and action_id = ? ORDER BY groupbasket_status.order';
-    $stmt = $db->query($query, array($owner_basket_id, $owner_usr_grp, $id_action));
-
-    if ($stmt->rowCount() > 0) {
-        while ($status = $stmt->fetchObject()) {
-            $statuses[] = array(
-                'ID' => $status->status_id,
-                'LABEL' => functions::show_string($status->label_status),
-            );
-        }
-    }
-
-    if (count($statuses) > 0) {
-        //load current status
-        $stmt = $db->query('SELECT status FROM '
-            .$view
-            .' WHERE res_id = ?', array($res_id));
-        $statusObj = $stmt->fetchObject();
-        $current_status = $statusObj->status;
-        if ($current_status != '') {
-            $stmt = $db->query('SELECT label_status FROM '.STATUS_TABLE
-                .' WHERE id = ?', array($current_status));
-            $statusObjLabel = $stmt->fetchObject();
-            $current_status_label = $statusObjLabel->label_status;
-        }
-        $frm_str .= '<tr id="status_tr" style="display:'.$display_value.';">';
-        $frm_str .= '<td><label for="status" class="form_title" >'._STATUS
-                .'</label></td>';
-        $frm_str .= '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
-        $frm_str .= '<td class="indexing_field"><select name="status" '
-                .'id="status" onchange="clear_error(\'frm_error_'.$id_action
-                .'\');">';
-        if ($current_status != '') {
-            $frm_str .= '<option value="'.$current_status.'">'._CHOOSE_CURRENT_STATUS
-                .' : '.$current_status_label.'('.$current_status.')</option>';
-        } else {
-            $frm_str .= '<option value="">'._CHOOSE_CURRENT_STATUS.')</option>';
-        }
-        for ($i = 0; $i < count($statuses); ++$i) {
-            $frm_str .= '<option value="'.functions::xssafe($statuses[$i]['ID']).'" ';
-            $frm_str .= '>'.functions::xssafe($statuses[$i]['LABEL']).'</option>';
-        }
-        $frm_str .= '</select></td><td><span class="red_asterisk" id="market_mandatory" '
-            .'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
-        $frm_str .= '</tr>';
-        $frm_str .= '<script>$j("#status").chosen({width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
-    }
-
-    $frm_str .= '</table>';
-
-    $frm_str .= '</div>';
-    $frm_str .= '</div>';
-
-    /*** CUSTOM INDEXES ***/
-    $frm_str .= '<div id="comp_indexes" style="display:block;">';
-    $frm_str .= '</div>';
-
-    /*** Complementary fields ***/
-    $frm_str .= '<hr />';
-
-    $frm_str .= '<h4 onclick="new Effect.toggle(\'complementary_fields\', \'blind\', {delay:0.2});'
-        .'whatIsTheDivStatus(\'complementary_fields\', \'divStatus_complementary_fields\');" '
-        .'class="categorie" style="width:90%;" onmouseover="this.style.cursor=\'pointer\';">';
-    $frm_str .= ' <span id="divStatus_complementary_fields" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>&nbsp;'
-        ._OPT_INDEXES;
-    $frm_str .= '</h4>';
-    $frm_str .= '<div id="complementary_fields"  style="display:none">';
-    $frm_str .= '<div>';
-
-    $frm_str .= '<table width="100%" align="center" border="0" '
-        .'id="indexing_fields" style="display:table;">';
-
-
-	/*** Description ***/
-	$frm_str .= '<tr id="description_tr" style="display:' . $display_value . ';">';
-	$frm_str .= '<td colspan="3">' . _OTHERS_INFORMATIONS . '</label></td>';
-	$frm_str .= '</tr>';
-    $frm_str .= '<tr>';
-	$frm_str .= '<td class="indexing_field" colspan="2"><textarea style="width:97%;resize:vertical" name="description" '
-	. 'id="description"  rows="2" onchange="clear_error(\'frm_error_'
-	. $id_action . '\');" >';
-	if( isset($data['subject']) && !empty($data['subject'])) {
-	$frm_str .= $data['description'];
-	}
-	$frm_str .= '</textarea></td>';
-	$frm_str .= '</tr>';
-
-	//Departement concerne
-	require_once("apps".DIRECTORY_SEPARATOR."maarch_entreprise".DIRECTORY_SEPARATOR."department_list.php");
-
-	$frm_str .= '<tr id="department_number_tr" style="display:' . $display_value . ';">';
-	$frm_str .= '<td >' . _DEPARTMENT_NUMBER . '</td>';
-	$frm_str .= '<td class="indexing_field" ><input type="text" style="width:97%;" onkeyup="erase_contact_external_id(\'department_number\', \'department_number_id\');"'
-	. 'name="department_number" id="department_number" value="';
-	if( isset($data['department_number']) && !empty($data['department_number'])) {
-	$frm_str .= $data['department_number'] . ' - ' . $depts[$data['department_number']];
-	}                
-	$frm_str .= '"/><div id="show_department_number" '
-	. 'class="autocomplete autocompleteIndex"></div></td>';
-	$frm_str .= '</tr>';
-	$frm_str .= '<input type="hidden" id="department_number_id" value="';
-	if( isset($data['department_number']) && !empty($data['department_number'])) {
-	$frm_str .= $data['department_number'];
-	}                
-	$frm_str .= '"/>';
-	/*****************/
-
-    if ($core_tools->is_module_loaded('tags') && ($core_tools->test_service('tag_view', 'tags', false) == 1)) {
-        //INITIALIZE
-        $tags = get_value_fields($formValues, 'tag_userform');
-        $tags_list = explode('__', $tags);
-
-        include_once 'modules'.DIRECTORY_SEPARATOR.'tags'.DIRECTORY_SEPARATOR.'templates/validate_mail/index.php';
-    }
-
-    $frm_str .= '</table>';
-
-    $frm_str .= '</div>';
-    $frm_str .= '</div>';
-    $frm_str .= '</div>';
-    $frm_str .= '</div>';
-    $frm_str .= '</div>';
-
-    $frm_str .= '<div id="validright" style="display:none;">';
-
-    /*** TOOLBAR ***/
-    $frm_str .= '<div class="block" align="center" style="height:20px;width=95%;">';
-
-    $frm_str .= '<table width="95%" cellpadding="0" cellspacing="0">';
-    $frm_str .= '<tr align="center">';
-
-    // HISTORY
-    if ($core_tools->test_service('view_doc_history', 'apps', false) || $core->test_service('view_full_history', 'apps', false)) {
-        $frm_str .= '<td>';
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-        .'index.php?display=true&page=show_history_tab&resId='
-        .$res_id.'&collId='.$coll_id;
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._DOC_HISTORY.'\',\''.$pathScriptTab.'\',\'history\');return false;" '
-            .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-        $frm_str .= '<span id="history_tab"  class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>';
-        $frm_str .= '&nbsp;<i class="fa fa-history fa-2x" title="'._DOC_HISTORY.'"></i><sup><span style="display:none;"></span></sup>';
-        $frm_str .= '</span>';
-        $frm_str .= '</td>';
-    }
-
-    //NOTE
-    if ($core_tools->is_module_loaded('notes')) {
-        $frm_str .= '<td>';
-
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-        .'index.php?display=true&module=notes&page=notes&identifier='
-        .$res_id.'&origin=document&coll_id='.$coll_id.'&load&size=medium';
-
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._NOTES.'\',\''.$pathScriptTab.'\',\'notes\');return false;" '
-            .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-        $frm_str .= '<span id="notes_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>'
-        .'&nbsp;<i id="notes_tab_img" class="fa fa-pen-square fa-2x" title="'._NOTES.'"></i><span id="notes_tab_badge"></span>';
-        $frm_str .= '</span>';
-
-        //LOAD TOOLBAR BADGE
-        $toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&module=notes&page=load_toolbar_notes&resId='.$res_id.'&collId='.$coll_id;
-        $frm_str .= '<script>loadToolbarBadge(\'notes_tab\',\''.$toolbarBagde_script.'\');</script>';
-        $frm_str .= '</td>';
-    }
-
-    //ATTACHMENTS
-    if ($core_tools->is_module_loaded('attachments')) {
-        $frm_str .= '<td>';
-
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-                .'index.php?display=true&page=show_attachments_tab&module=attachments&resId='.$res_id.'&collId='.$coll_id;
-
-        $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''.urlencode(_PJ).'\',\''.$pathScriptTab.'\',\'attachments\');return false;" '
-            .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-        $frm_str .= '<span id="attachments_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span><b>&nbsp;'
-            .'<i id="attachments_tab_img" class="fa fa-paperclip fa-2x" title="'._PJ.'"></i><span id="attachments_tab_badge"></span>';
-        $frm_str .= '</span>';
-        $frm_str .= '</td>';
-
-        //LOAD TOOLBAR BADGE
-        $toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=load_toolbar_attachments&resId='.$res_id.'&collId='.$coll_id;
-        $frm_str .= '<script>loadToolbarBadge(\'attachments_tab\',\''.$toolbarBagde_script.'\');</script>';
-    }
-
-    //DIFFLIST HISTORY
-    if ($core_tools->is_module_loaded('entities')) {
-        $frm_str .= '<td>';
-
-        $pathScriptTab = $_SESSION['config']['businessappurl']
-                .'index.php?display=true&page=show_diffListHistory_tab&module=entities&resId='.$res_id.'&collId='.$coll_id;
-
-        $frm_str .= '<span class="diff_list_history" style="width: 90%; cursor: pointer;" onmouseover="this.style.cursor=\'pointer\';" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._DIFF_LIST_HISTORY.'\',\''.$pathScriptTab.'\',\'difflistHistory\');return false;">';
-        $frm_str .= '<span id="difflistHistory_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>';
-        $frm_str .= '<b>&nbsp;<i class="fa fa-share-alt fa-2x" title="'._DIFF_LIST_HISTORY.'"></i><sup><span style="display:none;"></span></sup></b>';
-        $frm_str .= '</span>';
-        $frm_str .= '</td>';
-    }
-
-    //LINKS
-    $frm_str .= '<td>';
-
-    $pathScriptTab = $_SESSION['config']['businessappurl']
-                .'index.php?display=true&page=show_links_tab';
-
-    $frm_str .= '<span id="to_link" onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._LINK_TAB.'\',\''.$pathScriptTab.'\',\'links\');return false;" '
-        .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
-    $frm_str .= '<span id="links_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span><b>&nbsp;'
-        .'<i id="links_tab_img" class="fa fa-link fa-2x" title="'._LINK_TAB.'"></i><span id="links_tab_badge"></span>';
-    $frm_str .= '</span>';
-
-    //LOAD TOOLBAR BADGE
-    $toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&page=load_toolbar_links&resId='.$res_id.'&collId='.$coll_id;
-    $frm_str .= '<script>loadToolbarBadge(\'links_tab\',\''.$toolbarBagde_script.'\');</script>';
-    $frm_str .= '</td>';
-
-    //END TOOLBAR
-    $frm_str .= '</table>';
-    $frm_str .= '</div>';
-    $frm_str .= '<div id =\'show_tab\' module=\'\'></div>';
-
-    $frm_str .= '<script type="text/javascript">show_admin_contacts(true);</script>';
-
-    //DOCUMENT VIEWER
-    $frm_str .= '<iframe src="../../rest/res/'.$res_id.'/content" name="viewframevalid" id="viewframevalid"  scrolling="auto" frameborder="0" style="width:100% !important;" ></iframe>';
-
-    //END RIGHT DIV
-    $frm_str .= '</div>';
-
-    /*** Extra javascript ***/
-    $frm_str .= '<script type="text/javascript">$j(\'#validright\').css(\'display\',\'block\');window.scrollTo(0,0);';
-
-    $frm_str .= 'init_validation(\''.$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts\', \''
-        .$display_value.'\', \''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=change_category\',  \''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&page=get_content_js\');$j(\'#baskets\').css(\'visibility\',\'hidden\');var item = $j(\'#valid_div\'); if(item){item.css(\'display\',\'block\');}';
-    $frm_str .= 'var type_id = $j(\'#type_id\')[0];change_category_actions(\''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=change_category_actions'
-        .'&resId='.$res_id.'&collId='.$coll_id.'\',\''.$res_id.'\',\''.$coll_id.'\',document.getElementById(\'category_id\').options[document.getElementById(\'category_id\').selectedIndex].value);';
-    $frm_str .= 'if(type_id){change_doctype(type_id.options[type_id.selectedIndex].value, \''.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=change_doctype\', \''._ERROR_DOCTYPE.'\', \''.$id_action.'\', \''.$_SESSION['config']['businessappurl'].'index.php?display=true&page=get_content_js\' , \''.$display_value.'\', '.$res_id.', \''.$coll_id.'\', true);}';
-    if ($data['process_limit_date'] == null) {
-        $frm_str .= "activate_process_date(false, '".$display_value."');";
-    }
-    if ($core_tools->is_module_loaded('entities')) {
-        if ($_SESSION['current_basket']['difflist_type'] == 'entity_id') {
-            $frm_str .= 'change_entity(\''.$data['destination'].'\', \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=load_listinstance'.'\',\'diff_list_div\', \'indexing\', \''.$display_value.'\'';
-            if (!$load_listmodel) {
-                $frm_str .= ',\'false\',$j(\'#category_id\').val());';
-            } else {
-                $frm_str .= ',\'true\',$j(\'#category_id\').val());';
-            }
-        } elseif ($_SESSION['current_basket']['difflist_type'] == 'type_id') {
-            if (!$load_listmodel) {
-                $frm_str .= 'change_entity(\''.$data['destination'].'\', \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=load_listinstance'.'\',\'diff_list_div\', \'indexing\', \''.$display_value.'\'';
-                $frm_str .= ',\'false\',$j(\'#category_id\').val());';
-            } else {
-                $frm_str .= 'load_listmodel('.$target_model.', \'diff_list_div\', \'indexing\', $j(\'#category_id\').val());';
-                $frm_str .= '$j(\'#diff_list_tr\').css(\'display\',\''.$display_value.'\');';
-            }
-        } else {
-            $frm_str .= 'change_entity(\''.$data['destination'].'\', \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=load_listinstance'.'\',\'diff_list_div\', \'indexing\', \''.$display_value.'\'';
-            if (!$load_listmodel) {
-                $frm_str .= ',\'false\',$j(\'#category_id\').val());';
-            } else {
-                $frm_str .= ',\'true\',$j(\'#category_id\').val());';
-            }
-        }
-    }
-    if ($data['confidentiality'] == 'Y') {
-        $frm_str .= '$j(\'#confidential\').prop("checked",true);';
-    } elseif ($data['confidentiality'] == 'N') {
-        $frm_str .= '$j(\'#no_confidential\').prop("checked",true);';
-    }
-
-    if ($data['type_contact'] == 'internal') {
-        $frm_str .= '$j(\'#type_contact_internal\').prop("checked",true);';
-    } elseif ($data['type_contact'] == 'external') {
-        $frm_str .= '$j(\'#type_contact_external\').prop("checked",true);';
-    }
-    //Path to actual script
-    $path_to_script = $_SESSION['config']['businessappurl']
-    .'index.php?display=true&dir=indexing_searching&page=contact_check&coll_id='.$collId;
-    //check functions on load page
-    if ($data['type_contact'] != 'internal') {
-        $frm_str .= "check_date_exp('".$path_to_script."','".$path_check_date_link."');";
-    }
-    $frm_str .='launch_autocompleter_contacts_v2(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts\', \'\', \'\', \'\', \'contactid\', \'addressid\', \''. $_SESSION['config']['businessappurl'] . 'index.php?display=true'. '&page=getDepartment\');update_contact_type_session(\''
-        .$_SESSION['config']['businessappurl']
-        .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts_prepare_multi\');';
-    $frm_str .= 'affiche_reference();';
-    if (!empty($sr['type']) && $sr['type'] == 'entity') {
-        $frm_str .= 'initSenderRecipientAutocomplete(\'sender_recipient\',\'entity\');';
-    } else {
-        $frm_str .= 'initSenderRecipientAutocomplete(\'sender_recipient\',\'contactsUsers\', false, \'sender_recipient_card\');';
-    }
-    $frm_str .= 'initList_hidden_input(\'department_number\', \'show_department_number\',\''
-         . $_SESSION['config']['businessappurl'] . 'index.php?display='
-         . 'true&page=autocomplete_department_number\','
-         . ' \'Input\', \'2\', \'department_number_id\');';
-    $frm_str .='</script>';
-    /*** Extra CSS ***/
-    $frm_str .= '<style>';
-    $frm_str .= '#destination_chosen .chosen-drop{width:400px;}#folder_chosen .chosen-drop{width:400px;}';
-    $frm_str .= '#modal_'.$id_action.'{height:96% !important;width:98% !important;min-width:1250px;overflow:hidden;}';
-    $frm_str .= '#modal_'.$id_action.'_layer{height:100% !important;width:98% !important;min-width:1250px;overflow:hidden;}';
-    $frm_str .= '#validleft{height:100% !important;width:30% !important;}';
-    $frm_str .= '#validright{width:67% !important;height:100% !important;}';
-    $frm_str .= '@media screen and (min-width: 1280px) {#validleft{width:447px !important;}}';
-    $frm_str .= '@media screen and (max-width: 1400px) {#validright{width:57% !important;}}';
-    $frm_str .= '#viewframevalid{width:100% !important;height:93% !important;}';
-    $frm_str .= '#maarch_body{overflow:hidden !important;}';
-    $frm_str .= '</style>';
-
-    $frm_str .= '</div>';
-    $frm_str .= '</form>';
-
-    return addslashes($frm_str);
-}
-
-/**
- * Checks the action form.
- *
- * @param $form_id String Identifier of the form to check
- * @param $values Array Values of the form
- *
- * @return bool true if no error, false otherwise
- **/
-function check_form($form_id, $values)
-{
-    $_SESSION['action_error'] = '';
-    if (count($values) < 1 || empty($form_id)) {
-        $_SESSION['action_error'] = _FORM_ERROR;
-
-        return false;
-    } else {
-        $attach = get_value_fields($values, 'attach');
-
-        if ($attach) {
-            $idDoc = get_value_fields($values, 'res_id');
-            if (!$idDoc || empty($idDoc)) {
-                $_SESSION['action_error'] .= _LINK_REFERENCE.'<br/>';
-            }
-            if (!empty($_SESSION['action_error'])) {
-                return false;
-            }
-        }
-
-        $cat_id = get_value_fields($values, 'category_id');
-
-        if ($cat_id == false) {
-            $_SESSION['action_error'] = _CATEGORY.' '._IS_EMPTY;
-
-            return false;
-        }
-
-        // NCH01
-        $attachment_type = get_value_fields($values, 'attachment_type');
-        if($cat_id == 'attachment' && $attachment_type == ''){
-            $_SESSION['action_error'] = _ATTACHMENT_TYPE . ' ' . _IS_EMPTY;
-            return false;
-        }
-        // END NCH01
-
-        $no_error = process_category_check($cat_id, $values);
-
-        return $no_error;
-    }
-}
-
-/**
- * Checks the values of the action form for a given category.
- *
- * @param $cat_id String Category identifier
- * @param $values Array Values of the form to check
- *
- * @return bool true if no error, false otherwise
- **/
-function process_category_check($cat_id, $values)
-{
-    //DECLARATIONS
-    require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_types.php';
-
-    //INSTANTIATE
-    $db = new Database();
-    $core = new core_tools();
-    $type = new types();
-
-    // If No category : Error
-    if (!isset($_ENV['categories'][$cat_id])) {
-        $_SESSION['action_error'] = _CATEGORY.' '._UNKNOWN.': '.$cat_id;
-
-        return false;
-    }
-
-    // Simple cases
-    for ($i = 0; $i < count($values); ++$i) {
-        if ($_ENV['categories'][$cat_id][$values[$i]['ID']]['mandatory'] == true && (empty($values[$i]['VALUE']))) { //&& ($values[$i]['VALUE'] == 0 && $_ENV['categories'][$cat_id][$values[$i]['ID']]['type_form'] <> 'integer')
-            $_SESSION['action_error'] = $_ENV['categories'][$cat_id][$values[$i]['ID']]['label'].' '._IS_EMPTY;
-
-            return false;
-        }
-        if ($_ENV['categories'][$cat_id][$values[$i]['ID']]['type_form'] == 'date' && !empty($values[$i]['VALUE']) && preg_match($_ENV['date_pattern'], $values[$i]['VALUE']) == 0) {
-            $_SESSION['action_error'] = $_ENV['categories'][$cat_id][$values[$i]['ID']]['label'].' '._WRONG_FORMAT.'';
-
-            return false;
-        }
-        if ($_ENV['categories'][$cat_id][$values[$i]['ID']]['type_form'] == 'integer' && (!empty($values[$i]['VALUE']) || $values[$i]['VALUE'] == 0) && preg_match('/^[0-9]*$/', $values[$i]['VALUE']) == 0) {
-            $_SESSION['action_error'] = $_ENV['categories'][$cat_id][$values[$i]['ID']]['label'].' '._WRONG_FORMAT.'';
-
-            return false;
-        }
-        if ($_ENV['categories'][$cat_id][$values[$i]['ID']]['type_form'] == 'radio' && !empty($values[$i]['VALUE']) && !in_array($values[$i]['VALUE'], $_ENV['categories'][$cat_id][$values[$i]['ID']]['values'])) {
-            $_SESSION['action_error'] = $_ENV['categories'][$cat_id][$values[$i]['ID']]['label'].' '._WRONG_FORMAT.'';
-
-            return false;
-        }
-    }
-
-    ///// Checks the complementary indexes depending on the doctype
-
-    $type_id = get_value_fields($values, 'type_id');
-    $coll_id = get_value_fields($values, 'coll_id');
-    $indexes = $type->get_indexes($type_id, $coll_id, 'minimal');
-    $val_indexes = array();
-    for ($i = 0; $i < count($indexes); ++$i) {
-        $val_indexes[$indexes[$i]] = get_value_fields($values, $indexes[$i]);
-    }
-    $test_type = $type->check_indexes($type_id, $coll_id, $val_indexes);
-    if (!$test_type) {
-        $_SESSION['action_error'] .= $_SESSION['error'];
-        $_SESSION['error'] = '';
-
-        return false;
-    }
-
-    ///////////////////////// Other cases
-    //doc date
-    /*$doc_date = get_value_fields($values, 'doc_date');
-    $admission_date = get_value_fields($values, 'admission_date');
-    if ($admission_date < $doc_date)
-    {
-        $_SESSION['action_error'] = "La date du courrier doit être antérieure à la date d'arrivée du courrier ";
-        return false;
-    }*/
-
-    // Process limit Date
-    $_SESSION['store_process_limit_date'] = '';
-    if (isset($_ENV['categories'][$cat_id]['other_cases']['process_limit_date'])) {
-        $process_limit_date_use_yes = get_value_fields($values, 'process_limit_date_use_yes');
-        $process_limit_date_use_no = get_value_fields($values, 'process_limit_date_use_no');
-
-        if ($process_limit_date_use_yes == 'yes') {
-            $_SESSION['store_process_limit_date'] = 'ok';
-            $process_limit_date = get_value_fields($values, 'process_limit_date');
-            if (trim($process_limit_date) == '' || preg_match($_ENV['date_pattern'], $process_limit_date) == 0) {
-                $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['label'].' '._WRONG_FORMAT.'';
-
-                return false;
-            }
-        } elseif ($process_limit_date_use_no == 'no') {
-            $_SESSION['store_process_limit_date'] = 'ko';
-        }
-
-        $process_limit_date = new datetime($process_limit_date);
-        $process_limit_date = date_add($process_limit_date, date_interval_create_from_date_string('23 hours + 59 minutes + 59 seconds'));
-    }
-
-    if (isset($_ENV['categories'][$cat_id]['priority'])) {
-        $priority = get_value_fields($values, 'priority');
-
-        if ($priority === '') {
-            $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['priority']['label'].' '.strtolower(_MANDATORY);
-
-            return false;
-        }
-    }
-
-    // Contact
-    if (isset($_ENV['categories'][$cat_id]['other_cases']['contact'])) {
-        $contact = get_value_fields($values, 'contactid');
-        $contact_type = get_value_fields($values, 'type_contact_external');
-        $nb_multi_contact = count($_SESSION['adresses']['to']);
-
-        if (!$contact_type) {
-            $contact_type = get_value_fields($values, 'type_contact_internal');
-        }
-        if (!$contact_type) {
-            $contact_type = get_value_fields($values, 'type_multi_contact_external');
-        }
-        if (!$contact_type) {
-            $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['type_contact']['label'].' '.strtolower(_MANDATORY).'';
-
-            return false;
-        }
-
-        $contact_field = get_value_fields($values, 'contact');
-
-        if ($contact_field != '' && empty($contact)) {
-            $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['contact']['label']
-                .' '._WRONG_FORMAT.'. '._USE_AUTOCOMPLETION;
-
-            return false;
-        }
-
-        if ($_ENV['categories'][$cat_id]['other_cases']['contact']['mandatory'] == true) {
-            if ((empty($contact) && $contact_type != 'multi_external') || ($nb_multi_contact == 0 && $contact_type == 'multi_external')) {
-                $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['contact']['label'].' '._IS_EMPTY;
-
-                return false;
-            }
-        }
-    }
-
-    // Attachments --> NCH01
-    if (isset($_ENV['categories'][$cat_id]['other_cases']['chrono_number']) && $_ENV['categories'][$cat_id]['other_cases']['chrono_number']['mandatory'] == true) {
-        $chrono = get_value_fields(
-            $values, 'chrono_number'
-        );
-        if ($chrono === '') {
-            $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['chrono_number']['label']
-                . " " . _MANDATORY;
-            return false;
-        }
-    }
-    // end NCH01
-
-    if ($core->is_module_loaded('entities')) {
-        // Diffusion list
-        if (isset($_ENV['categories'][$cat_id]['other_cases']['diff_list']) && $_ENV['categories'][$cat_id]['other_cases']['diff_list']['mandatory'] == true) {
-            if (empty($_SESSION['indexing']['diff_list']['dest']['users'][0]['user_id']) || !isset($_SESSION['indexing']['diff_list']['dest']['users'][0]['user_id'])) {
-                $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['diff_list']['label'].' '.strtolower(_MANDATORY).'';
-
-                return false;
-            }
-        }
-    }
-
-    return true;
-}
-
-/**
- * Get the value of a given field in the values returned by the form.
- *
- * @param $values Array Values of the form to check
- * @param $field String the field
- *
- * @return string the value, false if the field is not found
- **/
-function get_value_fields($values, $field)
-{
-    $ct = 0;
-    if (!empty($values) && is_array($values)) {
-        $ct = count($values);
-    }
-    for ($i = 0; $i < $ct; ++$i) {
-        if ($values[$i]['ID'] == $field) {
-            return  $values[$i]['VALUE'];
-        }
-    }
-
-    return false;
-}
-
-/**
- * Action of the form : update the database.
- *
- * @param $arr_id Array Contains the res_id of the document to validate
- * @param $history String Log the action in history table or not
- * @param $id_action String Action identifier
- * @param $label_action String Action label
- * @param $status String  Not used here
- * @param $coll_id String Collection identifier
- * @param $table String Table
- * @param $values_form String Values of the form to load
- **/
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form)
-{
-    //var_dump("manage_form");
-    if (empty($values_form) || count($arr_id) < 1 || empty($coll_id)) {
-        $_SESSION['action_error'] = _ERROR_MANAGE_FORM_ARGS;
-
-        return false;
-    }
-
-    //INSTANTIATE require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php');
-    require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php';
-    require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_resource.php';
-    require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_types.php';
-
-    //INSTANTIATE
-    $db = new Database();
-    $sec = new security();
-    $core = new core_tools();
-    $resource = new resource();
-    $type = new types();
-
-    //INITIALIZE
-    $arrayPDOres = array();
-    $arrayPDOext = array();
-    $val_indexes = array();
-    $table = $sec->retrieve_table_from_coll($coll_id);
-    $ind_coll = $sec->get_ind_collection($coll_id);
-    $cat_id = get_value_fields($values_form, 'category_id');
-    $table_ext = 'res_letterbox';
-    $res_id = $arr_id[0];
-    $status_id = get_value_fields($values_form, 'status');
-    $type_id = get_value_fields($values_form, 'type_id');
-    $indexes = $type->get_indexes($type_id, $coll_id, 'minimal');
-
-    if ($core->is_module_loaded('tags')) {
-        $tags_list = get_value_fields($values_form, 'tag_userform');
-        $tags_list = explode('__', $tags_list);
-
-        include_once 'modules'.DIRECTORY_SEPARATOR.'tags'.DIRECTORY_SEPARATOR.'tags_update.php';
-    }
-
-    $query_ext = 'update '.$table_ext.' set ';
-    $query_res = 'update '.$table.' set ';
-    $query_ext .= ' category_id = ? ';
-    $arrayPDOext = array_merge($arrayPDOext, array($cat_id));
-    //$query_res .= " status = 'NEW' " ;
-
-    // Specific indexes : values from the form
-    // Simple cases
-    for ($i = 0; $i < count($values_form); ++$i) {
-        if ($values_form[$i]['ID'] == 'destination' && $_SESSION['ListDiffFromRedirect'] == true) {
-            //fix redirect action in validate_page
-        } else {
-            if($values_form[$i]['ID'] != 'departure_date' && $cat_id != 'outgoing'){
-            if ($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['type_field'] == 'integer' && $_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] != 'none') {
-                if ($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'res') {
-                    $query_res .= ', '.$values_form[$i]['ID'].' = ? ';
-                    $arrayPDOres = array_merge($arrayPDOres, array($values_form[$i]['VALUE']));
-                } elseif ($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'coll_ext') {
-                    $query_ext .= ', '.$values_form[$i]['ID'].' = ? ';
-                    $arrayPDOext = array_merge($arrayPDOext, array($values_form[$i]['VALUE']));
-                }
-            } elseif ($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['type_field'] == 'string' && $_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] != 'none') {
-                if ($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'res') {
-                    $query_res .= ', '.$values_form[$i]['ID'].' = ?';
-                    $arrayPDOres = array_merge($arrayPDOres, array($values_form[$i]['VALUE']));
-                } elseif ($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'coll_ext') {
-                    $query_ext .= ', '.$values_form[$i]['ID'].' = ?';
-                    $arrayPDOext = array_merge($arrayPDOext, array($values_form[$i]['VALUE']));
-                }
-            } elseif ($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['type_field'] == 'date' && $_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] != 'none') {
-                if ($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'res') {
-                    $query_res .= ', '.$values_form[$i]['ID'].' = ?';
-                    $arrayPDOres = array_merge($arrayPDOres, array($values_form[$i]['VALUE']));
-                } elseif ($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'coll_ext') {
-                    $query_ext .= ', '.$values_form[$i]['ID'].' = ?';
-                    $arrayPDOext = array_merge($arrayPDOext, array($values_form[$i]['VALUE']));
-                }
-                }
-            }
-        }
-    }
-    if (empty($status_id) || $status_id === '') {
-        $status_id = 'BAD';
-    } else {
-        $query_res .= ', status = ?';
-        $arrayPDOres = array_merge($arrayPDOres, array($status_id));
-    }
-
-    ///////////////////////// Other cases
-    //$type->inits_opt_indexes($coll_id, $res_id);
-
-    for ($i = 0; $i < count($indexes); ++$i) {
-        if($indexes[$i] != 'departure_date'){
-        $val_indexes[$indexes[$i]] = get_value_fields($values_form, $indexes[$i]);
-        }
-    }
-    $query_res .= $type->get_sql_update($type_id, $coll_id, $val_indexes);
-
-    // Confidentiality
-    $confidentiality_yes = get_value_fields($values_form, 'confidential');
-
-    if (!empty($confidentiality_yes)) {
-        $query_res .= ', confidentiality = ?';
-        $arrayPDOres = array_merge($arrayPDOres, array($confidentiality_yes));
-    } else {
-        $confidentiality_no = get_value_fields($values_form, 'no_confidential');
-        $query_res .= ', confidentiality = ?';
-        $arrayPDOres = array_merge($arrayPDOres, array($confidentiality_no));
-    }
-
-    // Process limit Date
-    if (isset($_ENV['categories'][$cat_id]['other_cases']['process_limit_date'])) {
-        $process_limit_date = get_value_fields($values_form, 'process_limit_date');
-        $process_limit_date = new datetime($process_limit_date);
-        $process_limit_date = date_add($process_limit_date, date_interval_create_from_date_string('23 hours + 59 minutes + 59 seconds'));
-        $process_limit_date = (array) $process_limit_date;
-
-        if ($_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['table'] == 'res') {
-            $query_res .= ", process_limit_date = '".$db->format_date_db($process_limit_date['date'], 'true', '', 'true')."'";
-        } elseif ($_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['table'] == 'coll_ext') {
-            if ($_SESSION['store_process_limit_date'] == 'ok') {
-                $query_ext .= ", process_limit_date = '".$db->format_date_db($process_limit_date['date'], 'true', '', 'true')."'";
-            } else {
-                $query_ext .= ', process_limit_date = null';
-            }
-            $_SESSION['store_process_limit_date'] = '';
-        }
-    }
-
-    // Contact
-    if (isset($_ENV['categories'][$cat_id]['other_cases']['contact'])) {
-        $contact = get_value_fields($values_form, 'contact');
-
-        $contact_type = get_value_fields($values_form, 'type_contact_external');
-        if (!$contact_type) {
-            $contact_type = get_value_fields($values_form, 'type_contact_internal');
-        }
-        if (!$contact_type) {
-            $contact_type = get_value_fields($values_form, 'type_multi_contact_external');
-        }
-        $nb_multi_contact = count($_SESSION['adresses']['to']);
-
-        $db->query('DELETE FROM contacts_res where res_id = ?', array($res_id));
-
-        $db->query('UPDATE '.$table_ext
-            .' SET exp_user_id = NULL, dest_user_id = NULL, exp_contact_id = NULL, dest_contact_id = NULL where res_id = ?',
-        array($res_id));
-        if ($nb_multi_contact > 0 && $contact_type == 'multi_external') {
-            for ($icontact = 0; $icontact < $nb_multi_contact; ++$icontact) {
-                $db->query('INSERT INTO contacts_res (coll_id, res_id, contact_id, address_id) VALUES (?, ?, ?, ?)',
-                    array($coll_id, $res_id, $_SESSION['adresses']['contactid'][$icontact], $_SESSION['adresses']['addressid'][$icontact]));
-            }
-            $query_ext .= ", is_multicontacts = 'Y'";
-        } else {
-            $contact_id = get_value_fields($values_form, 'contactid');
-
-            if (!ctype_digit($contact_id)) {
-                $contact_type = 'internal';
-            } else {
-                $contact_type = 'external';
-            }
-
-            if ($contact_type == 'internal') {
-                if ($cat_id == 'incoming' || $cat_id == 'internal' || $cat_id == 'ged_doc') {
-                    $query_ext .= ', exp_user_id = ?';
-                    $arrayPDOext = array_merge($arrayPDOext, array($contact_id));
-                } elseif ($cat_id == 'outgoing') {
-                    $query_ext .= ', dest_user_id = ?';
-                    $arrayPDOext = array_merge($arrayPDOext, array($contact_id));
-                }
-                $db->query('DELETE FROM contacts_res where res_id = ?', array($res_id));
-                $query_ext .= ', is_multicontacts = null';
-            } elseif ($contact_type == 'external') {
-                if ($cat_id == 'incoming' || $cat_id == 'ged_doc') {
-                    $query_ext .= ', exp_contact_id = ?';
-                    $arrayPDOext = array_merge($arrayPDOext, array($contact_id));
-                } elseif ($cat_id == 'outgoing' || $cat_id == 'internal') {
-                    $query_ext .= ', dest_contact_id = ?';
-                    $arrayPDOext = array_merge($arrayPDOext, array($contact_id));
-                }
-                $addressId = get_value_fields($values_form, 'addressid');
-                $query_ext .= ', address_id = ?';
-                $arrayPDOext = array_merge($arrayPDOext, array($addressId));
-
-                $db->query('DELETE FROM contacts_res where res_id = ?', array($res_id));
-                $query_ext .= ', is_multicontacts = null';
-            }
-        }
-    }
-
-    // Sender/Recipient
-    $srId = get_value_fields($values_form, 'sender_recipient_id');
-    $srType = get_value_fields($values_form, 'sender_recipient_type');
-
-    if ($cat_id == 'incoming' || $cat_id == 'internal') {
-        $srMode = 'recipient';
-    } else {
-        $srMode = 'sender';
-    }
-    \Resource\models\ResourceContactModel::delete(['where' => ['res_id = ?', 'mode = ?'], 'data' => [$res_id, $srMode]]);
-    if (!empty($srId) && !empty($srType) && in_array($cat_id, ['incoming', 'outgoing', 'internal'])) {
-        \Resource\models\ResourceContactModel::create([
-            'res_id'    => $res_id,
-            'item_id'   => $srId,
-            'type'      => $srType,
-            'mode'      => $srMode
-        ]);
-    }
-
-    if ($core->is_module_loaded('entities') && $_SESSION['ListDiffFromRedirect'] == false) {
-        // Diffusion list
-        $load_list_diff = false;
-        if (isset($_ENV['categories'][$cat_id]['other_cases']['diff_list'])) {
-            if (!empty($_SESSION['indexing']['diff_list']['dest']['users'][0]['user_id']) && isset($_SESSION['indexing']['diff_list']['dest']['users'][0]['user_id'])) {
-                $query_res .= ', dest_user = ?';
-                $arrayPDOres = array_merge($arrayPDOres, array($_SESSION['indexing']['diff_list']['dest']['users'][0]['user_id']));
-            }
-            $load_list_diff = true;
-        }
-    }
-
-    //store the initiator entity
-    $initiator = get_value_fields($values_form, 'initiator');
-    if (!empty($initiator)) {
-        $query_res .= ', initiator = ?';
-        $arrayPDOres = array_merge($arrayPDOres, array($initiator));
-    } else {
-        if (isset($_SESSION['user']['primaryentity']['id'])) {
-            $query_res .= ', initiator = ?';
-            $arrayPDOres = array_merge($arrayPDOres, array($_SESSION['user']['primaryentity']['id']));
-        }
-    }
-
-    $query_res = preg_replace('/set ,/', 'set ', $query_res);
-    //$query_res = substr($query_res, strpos($query_string, ','));
-
-    $arrayPDOres = array_merge($arrayPDOres, array($res_id));
-    $db->query($query_res.' where res_id = ? ', $arrayPDOres);
-
-    $arrayPDOext = array_merge($arrayPDOext, array($res_id));
-    $db->query($query_ext.' where res_id = ?', $arrayPDOext);
-
-    if ($core->is_module_loaded('entities') && $_SESSION['ListDiffFromRedirect'] == false) {
-        if ($load_list_diff) {
-            require_once 'modules'.DIRECTORY_SEPARATOR.'entities'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_manage_listdiff.php';
-
-            $diff_list = new diffusion_list();
-
-            $params = array(
-                'mode' => 'listinstance',
-                'table' => $_SESSION['tablename']['ent_listinstance'],
-                'coll_id' => $coll_id,
-                'res_id' => $res_id,
-                'user_id' => $_SESSION['user']['UserId'],
-                'fromQualif' => true,
-            );
-            $diff_list->load_list_db($_SESSION['indexing']['diff_list'], $params);
-        }
-    }
-
-    //Create chrono number
-    if ($cat_id == 'outgoing') {
-        require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_chrono.php';
-        $queryChrono = 'SELECT alt_identifier FROM '.$table_ext
-            .' WHERE res_id = ?';
-        $stmt = $db->query($queryChrono, array($res_id));
-        $resultChrono = $stmt->fetchObject();
-
-        if ($resultChrono->alt_identifier == '' || $resultChrono->alt_identifier == null) {
-            $chronoX = new chrono();
-
-            $cTypeId = get_value_fields($values_form, 'type_id');
-            $cEntity = get_value_fields($values_form, 'destination');
-            $cChronoOut = get_value_fields($values_form, 'chrono_number');
-            $myVars = array(
-                'entity_id' => $cEntity,
-                'type_id' => $cTypeId,
-                'category_id' => $cat_id,
-            );
-            $myForm = array(
-                'chrono_out' => $cChronoOut,
-            );
-            $myChrono = $chronoX->generate_chrono($cat_id, $myVars, $myForm);
-
-            if ($myChrono != '' && $cChronoOut == '') {
-                $db->query('UPDATE '.$table_ext.' SET alt_identifier = ? WHERE res_id = ? ',
-                    array($myChrono, $res_id));
-            }
-        }
-    } elseif ($cat_id == 'incoming' || $cat_id == 'internal') {
-        $queryChrono = 'SELECT alt_identifier FROM '.$table_ext
-            .' WHERE res_id = ?';
-        $stmt = $db->query($queryChrono, array($res_id));
-        $resultChrono = $stmt->fetchObject();
-        if ($resultChrono->alt_identifier == '' or $resultChrono->alt_identifier == null) {
-            require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_chrono.php';
-
-            $chronoX = new chrono();
-
-            $cTypeId = get_value_fields($values_form, 'type_id');
-            $cEntity = get_value_fields($values_form, 'destination');
-            $cChronoOut = get_value_fields($values_form, 'chrono_number');
-
-            $myVars = array(
-                'entity_id' => $cEntity,
-                'type_id' => $cTypeId,
-                'category_id' => $cat_id,
-                'res_id' => $res_id,
-            );
-            //print_r($myVars);
-            $myForm = array(
-                'chrono_out' => $cChronoOut,
-            );
-            $myChrono = $chronoX->generate_chrono($cat_id, $myVars, $myForm);
-            if ($myChrono != '') {
-                $db->query('UPDATE '.$table_ext.' SET alt_identifier = ? where res_id = ?', array($myChrono, $res_id));
-            }
-        }
-    } elseif ($cat_id == 'attachment') {
-        require 'modules/attachments/add_attachments.php';                     //      NCH01
-        require 'modules/attachments/remove_letterbox.php';
-    }
-
-    if ($cat_id == 'incoming') {
-        if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'sendResourceToExternalApplication'])) {
-            $bodyData = [];
-            $config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'sendResourceToExternalApplication']);
-
-            $columnsInContact = ['external_contact_id'];
-            $resource = \Resource\models\ResModel::getById(['select' => [$config['return']['value'], 'docserver_id', 'path', 'filename'], 'resId' => $res_id]);
-
-            if (empty($resource[$config['return']['value']])) {
-                if (!empty($config['inObject'])) {
-                    $multipleObject = true;
-
-                    foreach ($config['objects'] as $object) {
-                        $select = [];
-                        $tmpBodyData = [];
-                        $getContact = false;
-                        foreach ($object['rawData'] as $value) {
-                            if (in_array($value, $columnsInContact)) {
-                                $getContact = true;
-                            } else {
-                                $select[] = $value;
-                            }
-                        }
-
-                        $select[] = 'address_id';
-                        $document = \Resource\models\ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$res_id]]);
-                        if (!empty($document[0])) {
-                            if ($getContact && !empty($document[0]['address_id'])) {
-                                $contact = \Contact\models\ContactModel::getOnView(['select' => $columnsInContact, 'where' => ['ca_id = ?'], 'data' => [$document[0]['address_id']]]);
-                            }
-                            foreach ($object['rawData'] as $key => $value) {
-                                if (in_array($value, $columnsInContact)) {
-                                    $tmpBodyData[$key] = '';
-                                    if (!empty($contact[0][$value])) {
-                                        $tmpBodyData[$key] = $contact[0][$value];
-                                    }
-                                } else {
-                                    $tmpBodyData[$key] = $document[0][$value];
-                                }
-                            }
-                        }
-
-                        if (!empty($object['data'])) {
-                            $tmpBodyData = array_merge($tmpBodyData, $object['data']);
-                        }
-
-                        $bodyData[$object['name']] = $tmpBodyData;
-                    }
-
-                    if (!empty($config['file'])) {
-                        $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $resource['docserver_id'], 'select' => ['path_template']]);
-                        $bodyData[$config['file']] = \SrcCore\models\CurlModel::makeCurlFile(['path' => $docserver['path_template'] . str_replace('#', '/', $resource['path']) . $resource['filename']]);
-                    }
-                } else {
-                    $multipleObject = false;
-                    $getContact = false;
-
-                    $select = [];
-                    foreach ($config['rawData'] as $value) {
-                        if (in_array($value, $columnsInContact)) {
-                            $getContact = true;
-                        } else {
-                            $select[] = $value;
-                        }
-                    }
-
-                    $select[] = 'address_id';
-                    $document = \Resource\models\ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$res_id]]);
-                    if (!empty($document[0])) {
-                        if ($getContact) {
-                            $contact = \Contact\models\ContactModel::getOnView(['select' => $columnsInContact, 'where' => ['ca_id = ?'], 'data' => [$document[0]['address_id']]]);
-                        }
-                        foreach ($config['rawData'] as $key => $value) {
-                            if (in_array($value, $columnsInContact)) {
-                                $bodyData[$key] = $contact[0][$value];
-                            } else {
-                                $bodyData[$key] = $document[0][$value];
-                            }
-                        }
-
-                    }
-
-                    if (!empty($config['data'])) {
-                        $bodyData = array_merge($bodyData, $config['data']);
-                    }
-                }
-
-                $response = \SrcCore\models\CurlModel::exec(['curlCallId' => 'sendResourceToExternalApplication', 'bodyData' => $bodyData, 'multipleObject' => $multipleObject, 'noAuth' => true]);
-
-                \Resource\models\ResModel::update(['set' => [$config['return']['value'] => $response[$config['return']['key']]], 'where' => ['res_id = ?'], 'data' => [$res_id]]);
-            }
-        }
-    }
-
-    unset($_SESSION['upfile']);
-
-    //$_SESSION['indexation'] = true;
-    return array('result' => $res_id.'#', 'history_msg' => '');
-}
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 10e36f7cf724c67bfb6de4cac5efb3a8645e2285..cbebcfb958d8d45fbc3e52ee679a9e17cf844386 100755
--- a/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php
+++ b/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php
@@ -447,18 +447,6 @@ abstract class business_app_tools_Abstract extends Database
             . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR
             . $_SESSION['config']['lang'] . '.php';
 
-        $_SESSION['processing_modes'] = array();
-        $processingModes = $xmlfile->process_modes; 
-        if(count($processingModes) > 0) {
-            foreach ($processingModes->process_mode as $process ) {
-                $label = (string) $process->label;
-                $_SESSION['processing_modes'][(string) $process->label] = $label;
-                $process_mode_priority = (string) $process->process_mode_priority;
-                $_SESSION['process_mode_priority'][(string) $process->label] = $process_mode_priority;
-            }
-
-        }
-
         $_SESSION['attachment_types'] = array();
         $_SESSION['attachment_types_with_chrono'] = array();
         $_SESSION['attachment_types_show'] = array();
diff --git a/apps/maarch_entreprise/indexing_searching/change_category.php b/apps/maarch_entreprise/indexing_searching/change_category.php
deleted file mode 100755
index 88f69960bd156a9c6357428524c33cfca5fd6899..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/indexing_searching/change_category.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-/*
-*    Copyright 2008-2015 Maarch
-*
-*  This file is part of Maarch Framework.
-*
-*   Maarch Framework is free software: you can redistribute it and/or modify
-*   it under the terms of the GNU General Public License as published by
-*   the Free Software Foundation, either version 3 of the License, or
-*   (at your option) any later version.
-*
-*   Maarch Framework is distributed in the hope that it will be useful,
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*   GNU General Public License for more details.
-*
-*   You should have received a copy of the GNU General Public License
-*    along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/**
-* @brief  Script called by an ajax object to process the category change during indexing (index_mlb.php) : possible services from apps or module
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup indexing_searching_mlb
-*/
-
-$core = new core_tools();
-$core->load_lang();
-
-if(!isset($_REQUEST['category_id']) || empty($_REQUEST['category_id']))
-{
-	$_SESSION['error'] = _CATEGORY.' '._IS_EMPTY;
-	echo "{status : 1, error_txt : '".addslashes($_SESSION['error'])."'}";
-	exit();
-}
-
-$services = '[';
-$_SESSION['indexing_services_cat'] = array();
-$_SESSION['indexing_category_id'] = $_REQUEST['category_id'];
-$_SESSION['category_id'] = $_REQUEST['category_id'];
-$doc_date = '';
-if ($_SESSION['category_id'] == 'outgoing') {
-	$doc_date = ', doc_date : "' . date('d-m-Y') . '"';
-	$destination = ', destination : "'.$_SESSION['user']['primaryentity']['id']. '"';
-	$_SESSION['indexing']['diff_list']['dest']['user'] = array();
-	$diffListOutgoing = array(
-							'user_id' => $_SESSION['user']['FirstName'],
-							'lastname' => $_SESSION['user']['LastName'],
-							'firstname' => $_SESSION['user']['FirstName'],
-							'entity_id' => $_SESSION['user']['entities'][0]['ENTITY_ID'],
-							'entity_label' => $_SESSION['user']['entities'][0]['ENTITY_LABEL'],
-							'visible' => 'Y',
-							'process_comment' => ''
-						);
-
-	$_SESSION['indexing']['diff_list']['dest']['user'][]=$diffListOutgoing;
-} else {
-	$doc_date = '';
-	$destination = '';
-}
-// Module and apps services
-$core->execute_modules_services($_SESSION['modules_services'], 'change_category.php', 'include');
-$core->execute_app_services($_SESSION['app_services'], 'change_category.php', 'include');
-for($i=0;$i< count($_SESSION['indexing_services_cat']);$i++)
-{
-	$services .= "{ script : '".$_SESSION['indexing_services_cat'][$i]['script']."', function_to_execute : '".$_SESSION['indexing_services_cat'][$i]['function_to_execute']."', arguments : '[";
-	for($j=0;$j<count($_SESSION['indexing_services_cat'][$i]['arguments']);$j++)
-	{
-		$services .= " { id : \'".$_SESSION['indexing_services_cat'][$i]['arguments'][$j]['id']."\', value : \'".addslashes($_SESSION['indexing_services_cat'][$i]['arguments'][$j]['value'])."\' }, ";
-	}
-	$services = preg_replace('/, $/', '', $services);
-	$services .= "]' }, ";
-}
-$services = preg_replace('/, $/', '', $services);
-$services .= ']';
-unset($_SESSION['indexing_category_id']);
-unset($_SESSION['indexing_services_cat']);
-echo "{status : 0,  services : ".$services . $doc_date . $destination ."}";
-exit();
diff --git a/apps/maarch_entreprise/indexing_searching/change_category_actions.php b/apps/maarch_entreprise/indexing_searching/change_category_actions.php
deleted file mode 100755
index 8352cac93ad278fa5183dea0e66fcb050fa9da25..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/indexing_searching/change_category_actions.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-require_once 'modules/basket/class/class_modules_tools.php';
-
-$b = new basket();
-
-$_SESSION['category_id'] = $_REQUEST['category_id'];
-
-$actions = $b->get_actions_from_current_basket(
-    $_REQUEST['resId'],
-    $_REQUEST['collId'],
-    'PAGE_USE',
-    true
-);
-if (count($actions) > 0) {
-    $frmStr .= '<select name="chosen_action" id="chosen_action">';
-
-    $frmStr .= '<option value="">' . _CHOOSE_ACTION . '</option>';
-    
-    for ($indAct = 0; $indAct < count($actions); $indAct ++) {
-        if ($indAct == 0 && $_SESSION['current_basket']['id'] == 'IndexingBasket' && count($actions) > 1) {
-        } else {
-            $frmStr .= '<option value="' . $actions[$indAct]['VALUE'] . '"';
-            if ($indAct == 0 || ($_SESSION['current_basket']['id'] == 'IndexingBasket' && $indAct == 1)) {
-                $frmStr .= 'selected="selected"';
-            }
-            $frmStr .= '>' . $actions[$indAct]['LABEL'] . '</option>';
-        }
-    }
-    
-    $frmStr .= '</select> ';
-} else {
-    $frmStr .= _NO_AVAILABLE_ACTIONS_FOR_THIS_BASKET;
-    echo "{status : 2, error_txt : '" . addslashes($frmStr) . "'}";
-    exit();
-}
-
-echo "{status : 0, selectAction : '" . addslashes($frmStr) . "'}";
-exit();
diff --git a/apps/maarch_entreprise/indexing_searching/change_doctype.php b/apps/maarch_entreprise/indexing_searching/change_doctype.php
deleted file mode 100755
index c7858a2cc3cd6f3c32e079e1d627c77682674d83..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/indexing_searching/change_doctype.php
+++ /dev/null
@@ -1,276 +0,0 @@
-<?php
-/*
-*   Copyright 2008-2012 Maarch
-*
-*   This file is part of Maarch Framework.
-*
-*   Maarch Framework is free software: you can redistribute it and/or modify
-*   it under the terms of the GNU General Public License as published by
-*   the Free Software Foundation, either version 3 of the License, or
-*   (at your option) any later version.
-*
-*   Maarch Framework is distributed in the hope that it will be useful,
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*   GNU General Public License for more details.
-*
-*   You should have received a copy of the GNU General Public License
-*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/**
- * @brief  Script called by an ajax object to process the document type
- * change during indexing (index_mlb.php), process limit date calcul and
- * possible services from apps or module
- *
- * @file change_doctype.php
- *
- * @author Claire Figueras <dev@maarch.org>
- * @date $date$
- *
- * @version $Revision$
- * @ingroup indexing_searching_mlb
- */
-require_once 'core/class/class_security.php';
-require_once 'apps/'.$_SESSION['config']['app_id'].'/class/class_types.php';
-
-$db = new Database();
-$core = new core_tools();
-$core->load_lang();
-$type = new types();
-
-if (!isset($_REQUEST['type_id']) || empty($_REQUEST['type_id'])) {
-    $_SESSION['error'] = _DOCTYPE.' '._IS_EMPTY;
-    echo "{status : 1, error_txt : '".addslashes(functions::xssafe($_SESSION['error']))."'}";
-    exit();
-}
-
-if (!isset($_REQUEST['id_action']) || empty($_REQUEST['id_action'])) {
-    $_SESSION['error'] = _ACTION_ID.' '._IS_EMPTY;
-    echo "{status : 1, error_txt : '".addslashes(functions::xssafe($_SESSION['error']))."'}";
-    exit();
-}
-$id_action = $_REQUEST['id_action'];
-
-if (
-    isset($_REQUEST['res_id'])
-    && !empty($_REQUEST['res_id'])
-    && isset($_REQUEST['coll_id'])
-    && !empty($_REQUEST['coll_id'])
-) {
-    $res_id = $_REQUEST['res_id'];
-    $coll_id = $_REQUEST['coll_id'];
-}
-if ($coll_id == '') {
-    $coll_id = $_REQUEST['coll_id'];
-}
-if ($coll_id == '') {
-    $coll_id = 'letterbox_coll';
-}
-if ($res_id == '') {
-    $res_id = $_REQUEST['res_id'];
-}
-if (isset($_REQUEST['admission_date'])
-    && !empty($_REQUEST['admission_date'])
-) {
-    $admissionDate = $_REQUEST['admission_date'];
-}
-
-$priorityId = $_SESSION['process_mode_priority'][$_SESSION['process_mode']];
-$_SESSION['process_mode'] = null;
-$priorityWDay = $_SESSION['mail_priorities_wdays'][$priorityId] == 'true' ? 'workingDay' : 'calendar';
-foreach ($_SESSION['mail_priorities_id'] as $key => $value) {
-    if ($value == $priorityId) {
-        $fakeId = $key;
-    }
-}
-if ($_SESSION['mail_priorities_attribute'][$fakeId] != 'false') {
-    $priorityDelay = $_SESSION['mail_priorities_attribute'][$fakeId];
-}
-
-$mandatory_indexes = $type->get_mandatory_indexes($_REQUEST['type_id'], $coll_id);
-$indexes = $type->get_indexes($_REQUEST['type_id'], $coll_id);
-
-if (is_array($indexes)) {
-    foreach ($indexes as $key => $value) {
-        if (filter_var($value['only_detail'], FILTER_VALIDATE_BOOLEAN)) {
-            unset($indexes[$key]);
-        }
-    }
-}
-
-$opt_indexes = '';
-$display_value = 'table-row';
-$opt_indexes = '';
-if (count($indexes) > 0) {
-    if ((isset($res_id) && isset($coll_id)) && (!empty($res_id) && !empty($coll_id))) {
-        $sec = new security();
-        $table = $sec->retrieve_table_from_coll($coll_id);
-        if (!empty($table)) {
-            $fields = 'res_id ';
-            foreach (array_keys($indexes) as $key) {
-                $fields .= ', '.$key;
-            }
-            $stmt = $db->query('SELECT '.$fields.' FROM '.$table
-                .' WHERE res_id = ?', array($res_id)
-            );
-            $values_fields = $stmt->fetchObject();
-        }
-    }
-    $opt_indexes .= '<hr />';
-
-    $opt_indexes .= '<h4 onclick="new Effect.toggle(\'doctype_fields\', \'blind\', {delay:0.2});'
-        .'whatIsTheDivStatus(\'doctype_fields\', \'divStatus_doctype_fields\');" '
-        .'class="categorie" style="width:90%;" onmouseover="this.style.cursor=\'pointer\';">';
-    $opt_indexes .= ' <span id="divStatus_doctype_fields" style="color:#1C99C5;"><i class="fa fa-minus-square"></i></span>&nbsp;'
-        ._DOCTYPE_INDEXES;
-    $opt_indexes .= '</h4>';
-
-    $opt_indexes .= '<div id="doctype_fields"  style="display:inline">';
-    $opt_indexes .= '<div>';
-
-    $opt_indexes .= '<table width="100%" align="center" border="0">';
-    foreach (array_keys($indexes) as $key) {
-        $mandatory = false;
-        if (in_array($key, $mandatory_indexes)) {
-            $mandatory = true;
-        }
-        $opt_indexes .= '<tr >';
-        $opt_indexes .= '<td><label for="'.functions::xssafe($key).'" class="form_title" >'
-                .$indexes[$key]['label'].'</label></td>';
-        $opt_indexes .= '<td>&nbsp;</td>';
-        $opt_indexes .= '<td class="indexing_field">';
-        $valueCustom = null;
-        if ($indexes[$key]['type_field'] == 'input') {
-            if ($indexes[$key]['type'] == 'date') {
-                $opt_indexes .= '<input name="'.functions::xssafe($key).'" type="text" id="'
-                        .$key.'" value="';
-                if (isset($values_fields->{$key})) {
-                    $opt_indexes .= functions::format_date_db(
-                            functions::xssafe($values_fields->{$key}), true
-                        );
-                } elseif ($indexes[$key]['default_value'] != false) {
-                    $opt_indexes .= functions::format_date_db(
-                            functions::xssafe($indexes[$key]['default_value']), true
-                        );
-                }
-                $opt_indexes .= '" onclick="clear_error(\'frm_error_'
-                        .$id_action.'\');showCalender(this);"/>';
-            } else {
-                $opt_indexes .= '<textarea name="'.functions::xssafe($key).'" type="text" id="'
-                        .$key.'" value="';
-                if (isset($values_fields->{$key})) {
-                    $valueCustom = functions::show_string(
-                        functions::xssafe($values_fields->{$key}), true
-                    );
-                    $opt_indexes .= $valueCustom;
-                } elseif ($indexes[$key]['default_value'] != false) {
-                    $valueCustom = functions::show_string(
-                        functions::xssafe($indexes[$key]['default_value']), true
-                    );
-                    $opt_indexes .= $valueCustom;
-                }
-                $opt_indexes .= '" onclick="clear_error(\'frm_error_'
-                        .$id_action.'\');">'.$valueCustom.'</textarea>';
-            }
-        } else {
-            $opt_indexes .= '<select name="'.functions::xssafe($key).'" id="'.functions::xssafe($key).'" >';
-            $opt_indexes .= '<option value="">'._CHOOSE.'...</option>';
-            for ($i = 0; $i < count($indexes[$key]['values']); ++$i) {
-                $opt_indexes .= '<option value="'
-                            .functions::xssafe($indexes[$key]['values'][$i]['id']).'"';
-                if ($indexes[$key]['values'][$i]['id']
-                            == $values_fields->{$key}) {
-                    $opt_indexes .= 'selected="selected"';
-                } elseif (
-                            $indexes[$key]['default_value'] != false
-                            && $indexes[$key]['values'][$i]['id']
-                                == $indexes[$key]['default_value']
-                        ) {
-                    $opt_indexes .= 'selected="selected"';
-                }
-                $opt_indexes .= ' >'.$indexes[$key]['values'][$i]['label']
-                            .'</option>';
-            }
-            $opt_indexes .= '</select>';
-        }
-        $opt_indexes .= '</td>';
-        if ($mandatory) {
-            $opt_indexes .= '<td><span class="red_asterisk" id="'
-                    .$key.'_mandatory">';
-            //$opt_indexes .= 'inline';
-            $opt_indexes .= '*</span>&nbsp;</td>';
-        } else {
-            $opt_indexes .= '<td><span style="visibility:hidden;" id="'
-                    .$key.'_mandatory">';
-            $opt_indexes .= '*</span>&nbsp;</td>';
-        }
-        //$opt_indexes .= ';">*</span>&nbsp;</td>';
-        $opt_indexes .= '</tr>';
-    }
-    $opt_indexes .= '</table>';
-
-    $opt_indexes .= '</div></div>';
-}
-
-$services = '[';
-$_SESSION['indexing_services'] = array();
-$_SESSION['indexing_type_id'] = $_REQUEST['type_id'];
-$_SESSION['category_id_session'] = $_SESSION['indexing_type_id'];
-
-// Module and apps services
-$core->execute_modules_services(
-    $_SESSION['modules_services'], 'change_doctype.php', 'include'
-);
-$core->execute_app_services(
-    $_SESSION['app_services'], 'change_doctype.php', 'include'
-);
-for ($i = 0; $i < count($_SESSION['indexing_services']); ++$i) {
-    $services .= "{ script : '".$_SESSION['indexing_services'][$i]['script']
-        ."', function_to_execute : '"
-        .functions::xssafe($_SESSION['indexing_services'][$i]['function_to_execute'])
-        ."', arguments : '[";
-    for ($j = 0; $j < count($_SESSION['indexing_services'][$i]['arguments']); ++$j) {
-        $services .= " { id : \'"
-            .functions::xssafe($_SESSION['indexing_services'][$i]['arguments'][$j]['id'])
-            ."\', value : \'"
-            .addslashes(
-                $_SESSION['indexing_services'][$i]['arguments'][$j]['value']
-            )
-            ."\' }, ";
-    }
-    $services = preg_replace('/, $/', '', $services);
-    $services .= "]' }, ";
-}
-$services = preg_replace('/, $/', '', $services);
-$services .= ']';
-unset($_SESSION['indexing_type_id']);
-unset($_SESSION['indexing_services']);
-
-if ($priorityDelay != '') {
-    $delay = $priorityDelay;
-}
-
-if (isset($delay) && $delay > 0) {
-    require_once 'core/class/class_alert_engine.php';
-    $alert_engine = new alert_engine();
-    if (isset($admissionDate) && !empty($admissionDate)) {
-        $convertedDate = $alert_engine->dateFR2Time(str_replace('-', '/', $admissionDate));
-        $date = $alert_engine->WhenOpenDay($convertedDate, $delay, false, $priorityWDay);
-        //$date = $alert_engine->date_max_treatment($delay, false);
-    } else {
-        $date = $alert_engine->date_max_treatment($delay, false);
-    }
-    $process_date = functions::dateformat($date, '-');
-    $tmpProcessDate = explode(' ', $process_date);
-    $date = $tmpProcessDate[0];
-
-    echo "{status : 0, process_date : '".trim(functions::xssafe($date))
-        ."', opt_indexes : '".addslashes($opt_indexes)."', services : "
-        .$services.'}';
-    exit();
-} else {
-    echo "{status : 1, opt_indexes : '".addslashes($opt_indexes)
-        ."', services : ".$services.'}';
-    exit();
-}
diff --git a/apps/maarch_entreprise/indexing_searching/priority_for_sve.php b/apps/maarch_entreprise/indexing_searching/priority_for_sve.php
deleted file mode 100755
index c8f968587fe45d95b7c40d47d7dfa1914bdb9ef0..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/indexing_searching/priority_for_sve.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-
-require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php');
-
-
-$res = \Doctype\models\DoctypeModel::getById(['id' => $_POST['type_id']]);
-
-$sve_type = $res['process_mode'];
-$_SESSION['process_mode'] = $sve_type;
-
-if (!empty($_SESSION['process_mode_priority'])) {
-	foreach ($_SESSION['process_mode_priority'] as $key => $value){
-	    if($sve_type == $key){
-			echo "{status : 0, value : '".$value."'}";
-			exit;
-		}elseif($sve_type == $key){
-			echo "{status : 0, value : '".$value."'}";
-			exit;
-		}elseif($sve_type == $key){
-			echo "{status : 1, value : '".$value."'}";
-			exit;
-		}
-	}
-}
-
-
-?>
diff --git a/apps/maarch_entreprise/js/indexing.js b/apps/maarch_entreprise/js/indexing.js
index 88319d5a028d3652f355f159e7abe1b0e83bec5f..7dd901911195fcab5f6448583771787b8481f6fb 100755
--- a/apps/maarch_entreprise/js/indexing.js
+++ b/apps/maarch_entreprise/js/indexing.js
@@ -1,159 +1,6 @@
 
 var $j = jQuery.noConflict();
 
-/**
- * When you choose a doctype, you must calculate the process date limit (Ajax) and execute module services
- *
- * @param doctype_id String Document type identifier
- * @param path_manage_script String Path to the php file called in the Ajax object
- * @param error_empty_type String Error label displayed when the document type is empty
- * @param action_id String Action identifier
- **/
-function change_doctype(doctype_id, path_manage_script, error_empty_type, action_id, get_js_script,display_value_tr, id_res, id_coll, from_valid_qualif)
-{
-    var admissionDate;
-    if ($('admission_date')) {
-        admissionDate = $('admission_date').value;
-    }
-    var priorityId;
-    if ($('priority')) {
-        priorityId = $('priority').value;
-    }
-    var theCollId = path_manage_script.split('coll_id=');
-    var tmp_res_id = id_res || null;
-    if (theCollId[1] != '') {
-        tmp_coll_id = theCollId[1];
-    } else {
-        var tmp_coll_id = id_coll || null;
-    }
-    if(doctype_id != null && doctype_id != '' && doctype_id != NaN)
-    {
-        new Ajax.Request(path_manage_script,
-        {
-            method:'post',
-            parameters: { type_id : doctype_id,
-                          id_action : action_id,
-                          res_id : tmp_res_id,
-                          coll_id : tmp_coll_id,
-                          admission_date : admissionDate,
-                          priority_id : priorityId                          
-                        },
-                onSuccess: function(answer){
-                eval("response = "+answer.responseText);
-                //alert(answer.responseText);
-                if(response.status == 0  || response.status == 1)
-                {
-                    if($('process_limit_date_tr').style.display != 'none'){
-                        if(response.status == 0)
-                        {
-                            var limit_use = $('process_limit_date_use_yes');
-                            if(limit_use)
-                            {
-                                limit_use.checked = true;
-                            }
-                            var process_date_tr = $('process_limit_date_tr');
-                            if(process_date_tr != null)
-                            {
-                                Element.setStyle(process_date_tr, {display : display_value_tr})
-                            }
-                            var process_date = $('process_limit_date');
-                            if(process_date != null && !from_valid_qualif)
-                            {
-                                process_date.value = response.process_date;
-                            }
-                            if (process_date.value == '') {
-                                process_date.value = response.process_date;
-                            }
-                        }
-                        else
-                        {
-
-                            var limit_use = $('process_limit_date_use_no');
-                            if(limit_use)
-                            {
-                                limit_use.checked = true;
-                            }
-                            var process_date_tr = $('process_limit_date_tr');
-                            if(process_date_tr != null)
-                            {
-                                Element.setStyle(process_date_tr, {display : 'none'})
-                            }
-                        }
-                    }
-                    
-                    var indexes = response.opt_indexes;
-                    var div_indexes = $('comp_indexes');
-                    if(div_indexes )
-                    {
-                        div_indexes.update(indexes);
-                    }
-                    var services_to_exec = response.services;
-                    var path_scripts = '';
-                    var call_func = '';
-                    for(var ind=0; ind < services_to_exec.length;ind++)
-                    {
-                        path_scripts += services_to_exec[ind]['script'] + '$$';
-                        call_func += services_to_exec[ind]['function_to_execute']+'('+services_to_exec[ind]['arguments']+');';
-                    }
-                    if(call_func != '' && path_scripts != '' && get_js_script != '')
-                    {
-                        path_scripts = path_scripts.replace("modules/templates/js/", "");
-                        new Ajax.Request(get_js_script,
-                        {
-                            method:'post',
-                            parameters:
-                            {
-                                scripts : path_scripts
-                            },
-                             onSuccess: function(answer){
-                                eval(answer.responseText+call_func);
-                            }
-                        });
-                    }
-                }
-                else
-                {
-                    try{
-                        $('frm_error').innerHTML = response.error_txt;
-                        }
-                    catch(e){}
-                }
-            }
-        });
-    }
-    else
-    {
-        try{
-            $('frm_error_'+action_id).innerHTML = error_empty_type;
-            }
-        catch(e){}
-    }
-}
-
-function changePriorityForSve(doctype_id, path_script){
-    new Ajax.Request(path_script,
-    {
-        method:'post',
-        parameters: { type_id : doctype_id,
-                      address_id : path_script
-                    },
-            onSuccess: function(answer){
-                eval("response = "+answer.responseText);
-                if(response.status == 0) {
-                    $j("#priority").val(response.value);
-                    $j("#priority").trigger("chosen:updated");
-
-                } else if(response.status == 1) {
-                    $j("#priority").val(response.value);
-                    $j("#priority").trigger("chosen:updated");
-                } else {
-                    console.log('Erreur Ajax');
-                }
-            },
-            onFailure: function(){ alert('Something went wrong...'); }
-    });
-}
-
 /**
  * Compute process limit date from the admission date
  *
@@ -197,746 +44,6 @@ function updateProcessDate(path_manage_script)
     }
 }
 
-function checkRealDate(arg) {
-
-    var cat = $('category_id').options[$('category_id').selectedIndex].value
-
-    if (cat == 'incoming') {
-
-        var admissionDate;
-        var docDate;
-
-        if ($('admission_date')) {
-            admissionDate = $('admission_date').value;
-			var date1 = new Date();
-			date1.setFullYear(admissionDate.substr(6,4));
-			date1.setMonth(admissionDate.substr(3,2) - 1, admissionDate.substr(0,2));
-			date1.setHours(0, 0, 0, 0);
-
-			var d1_admissionDate=date1.getTime();
-        }
-
-        if($('doc_date')) {
-            docDate = $('doc_date').value;
-			var date2 = new Date();
-			date2.setFullYear(docDate.substr(6,4));
-			date2.setMonth(docDate.substr(3,2) - 1, docDate.substr(0,2));
-			date2.setHours(0, 0, 0, 0);
-			var d2_docDate=date2.getTime();
-        }
-
-        if(admissionDate != "" && docDate != "" && d2_docDate > d1_admissionDate) {          
-            alert("La date du courrier doit être antérieure à la date d'arrivée du courrier ");
-            if(arg == 'admissionDate'){
-                $('admission_date').value = "";
-            }
-            if(arg == 'docDate'){
-                $('doc_date').value = "";
-            }    
-        }
-
-        var date = new Date();
-        var date3 = new Date();
-        date.setFullYear(date3.getFullYear());
-        date.setMonth(date3.getMonth()+1);
-        date.setDate(date3.getDate()); 
-        current_date = date.getTime();
-
-        if (d1_admissionDate > current_date) {
-            alert("La date d'arrivée doit être antérieure à la date du jour ");
-            var current_month = date3.getMonth()+1;
-            $('admission_date').value = (("0" + date3.getDate()).slice(-2)) + "-" + ("0" + current_month).slice(-2) + "-" + date3.getFullYear();
-        }
-    } else if (cat == 'outgoing') {
-        if($('departure_date')) {
-            departureDate = $('departure_date').value;
-            var date2 = new Date();
-            date2.setFullYear(departureDate.substr(6,4));
-            date2.setMonth(departureDate.substr(3,2));
-            date2.setDate(departureDate.substr(0,2));
-            date2.setHours(0);
-            date2.setMinutes(0);
-            var d2_departureDate=date2.getTime();
-        }
-
-        if(departureDate != "" && docDate != "" && d2_docDate > d2_departureDate) {          
-            alert("La date du courrier doit être antérieure à la date de départ du courrier ");
-            if(arg == 'custom_d1'){
-                $('custom_d1').value = "";
-            }
-            if(arg == 'docDate'){
-                $('doc_date').value = "";
-            }    
-        }
-    }
-}
-
-function checkRealLimitDate(arg) {
-
-    var process_limit_date;
-    var admission_date;
-    if ($('process_limit_date')) {
-        process_limit_date = $('process_limit_date').value;
-        var date1 = new Date();
-        date1.setFullYear(process_limit_date.substr(6,4),process_limit_date.substr(3,2)-1,process_limit_date.substr(0,2));
-        //date1.setMonth(process_limit_date.substr(3,2)-1,process_limit_date.substr(0,2));
-        // date1.setDate(process_limit_date.substr(0,2));
-        // date1.setHours(0);
-        // date1.setMinutes(0);
-
-        var d1_process_limit_date=date1.getTime();
-    }
-
-    if($('admission_date')) {
-        admission_date = $('admission_date').value;
-        var date2 = new Date();
-        date2.setFullYear(admission_date.substr(6,4),admission_date.substr(3,2)-1,admission_date.substr(0,2));
-		//date2.setMonth(admission_date.substr(3,2)-1,admission_date.substr(0,2));
-		// date2.setDate(admission_date.substr(0,2));
-		// date2.setHours(0);
-		// date2.setMinutes(0);
-        var d2_admission_date=date2.getTime();
-    }
-
-    if(process_limit_date != "" && admission_date != "" && d2_admission_date > d1_process_limit_date) {          
-        alert("La date limite de traitement doit être supérieure à la date d'arrivée du courrier ");
-        if(arg == 'process_limit_date'){
-            $('process_limit_date').value = "";
-        }
-        if(arg == 'admission_date'){
-        	$('admission_date').value = "";
-        }    
-    }
-
-/*    var date = new Date();
-    var date3 = new Date();
-    date.setFullYear(date3.getFullYear());
-    date.setMonth(date3.getMonth()+1);
-    date.setDate(date3.getDate()); 
-    current_date = date.getTime();
-
-    if (d1_admissionDate > current_date) {
-        alert("La date d'arrivée doit être antérieure à la date du jour ");
-        var current_month = date3.getMonth()+1;
-        $('admission_date').value = date3.getDate() + "-" + current_month + "-" + date3.getFullYear();
-    }*/
-
-}
-
-/**
- * Activates / Desactivates the process date limit
- *
- * @param activate Bool Activate mode = true, desactivate mode = false
- **/
-function activate_process_date(activate, display_value_tr)
-{
-    var process_date = $('process_limit_date_tr');
-    var tr_display_value = display_value_tr || 'table-row';
-    if(process_date != null)
-    {
-        if(activate == true)
-        {
-            Element.setStyle(process_date, {display : tr_display_value});
-            //process_date.style.display = tr_display_value;
-        }
-        else
-        {
-            //process_date.style.display = 'none';
-            Element.setStyle(process_date, {display : 'none'});
-        }
-    }
-}
-
-/**
- * Adapts the indexing form with the category : loads the fields to display in a JSON object
- *
- * @param cat_id String Category identifier
- **/
-function change_category(cat_id, display_value_tr, path_manage_script,get_js_script, params_cat, origin)
-{
-    var typeContactInternal = 'not_checked';
-    var typeContactExternal = 'not_checked';
-    var typeMultiContactExternal = 'not_checked';
-
-    if (typeof (origin) == "undefined") {
-        origin = '';
-    }
-    // if (cat_id == 'internal' || cat_id == 'incoming') {
-    //     $('type_contact_external').checked = true;
-    // };
-    if ($('type_contact_internal')) {
-        if ($('type_contact_internal').checked == true) {
-            var typeContactInternal = 'checked';
-        }
-    }
-    if ($('type_contact_external')) {
-        if ($('type_contact_external').checked == true) {
-            typeContactExternal = 'checked';
-        }
-    }    
-	  if ($('type_multi_contact_external')) {
-        if ($('type_multi_contact_external').checked == true) {
-            typeMultiContactExternal = 'checked';
-        }
-    }
-    if (typeContactInternal == 'not_checked' && typeContactExternal == 'not_checked' && typeMultiContactExternal == 'not_checked') {
-        typeContactExternal = 'checked';
-    }
-    //Category = INCOMING
-    if(cat_id == 'incoming')
-    {
-        var category = [
-            {id:'doctype_mail', type:'label', state:'display'},
-            {id:'doctype_res', type:'label', state:'hide'},
-            {id:'priority_tr', type:'tr', state:'display'},
-            {id:'external_reference_tr', type:'tr', state:'display'},
-            {id:'external_id_mandatory', type:'tr', state:'display'},
-            {id:'doc_date_label', type:'label', state:'hide'},
-            {id:'mail_date_label', type:'label', state:'display'},
-            {id:'author_tr', type:'tr', state:'hide'},
-            {id:'admission_date_tr', type:'tr', state:'display'},
-            {id:'contact_check', type:'tr', state:'hide'},
-            {id:'nature_id_tr', type:'tr', state:'display'},
-            {id:'label_dep_dest', type:'label', state:'display'},
-            {id:'label_dep_exp', type:'label', state:'hide'},
-            {id:'label_dep_owner', type:'label', state:'hide'},
-            {id:'process_limit_date_use_tr', type:'tr', state:'display'},
-            {id:'process_limit_date_tr', type:'tr', state:'display'},
-            {id:'department_tr', type:'tr', state:'display'},
-            {id:'difflist_tr', type:'tr', state:'display'},
-            {id:'box_id_tr', type:'tr', state:'display'},
-            {id:'contact_choose_tr', type:'tr', state:'hide'},
-            {id:'contact_choose_2_tr', type:'tr', state:'hide'},
-            {id:'contact_choose_3_tr', type:'tr', state:'hide'},
-            {id:'dest_contact_choose_label', type:'label', state:'hide'},
-            {id:'exp_contact_choose_label', type:'label', state:'display'},
-            {id:'contact_id_tr', type:'tr', state:'display'},
-            {id:'dest_contact', type:'label', state:'hide'},
-            {id:'exp_contact', type:'label', state:'display'},
-            {id:'dest_multi_contact', type:'label', state:'hide'},
-            {id:'exp_multi_contact', type:'label', state:'display'},
-            {id:'author_contact', type:'label', state:'hide'},
-            {id:'type_multi_contact_external_icon', type:'label', state:'display'},
-            {id:'type_contact_internal', type:'radiobutton', state:typeContactInternal},
-            {id:'type_contact_external', type:'radiobutton', state:typeContactExternal},
-            {id:'type_multi_contact_external', type:'radiobutton', state:typeMultiContactExternal},
-            {id:'folder_tr', type:'tr', state:'display'},
-            {id:'category_id_mandatory', type:'label', state:'display'},
-            {id:'type_id_mandatory', type:'label', state:'display'},
-            {id:'priority_mandatory', type:'label', state:'display'},
-            {id:'doc_date_mandatory', type:'label', state:'display'},
-            {id:'departure_date_mandatory', type:'label', state:'hide'},
-            {id:'departure_date_tr', type:'tr', state:'hide'},
-            {id:'author_mandatory', type:'label', state:'hide'},
-            {id:'admission_date_mandatory', type:'label', state:'display'},
-            {id:'type_contact_mandatory', type:'label', state:'display'},
-            {id:'contact_mandatory', type:'label', state:'display'},
-            {id:'nature_id_mandatory', type:'label', state:'display'},
-            {id:'subject_mandatory', type:'label', state:'display'},
-            {id:'destination_mandatory', type:'label', state:'display'},
-            {id:'process_limit_date_use_mandatory', type:'label', state:'display'},
-            {id:'process_limit_date_mandatory', type:'label', state:'display'},
-            {id:'chrono_number', type:'label', state:'hide'},
-            {id:'chrono_number_mandatory', type:'label', state:'hide'},
-            {id:'chrono_number_tr', type:'tr', state:'hide'},
-            {id:'folder_mandatory', type:'label', state:'hide'},
-            {id:'sr_sender_span', type:'label', state:'hide'},
-            {id:'sr_recipient_span', type:'label', state:'display'},
-            // NCH01
-            {id:'type_id_tr', type:'tr', state:'display'},
-            {id:'confidentiality_tr', type:'tr', state:'display'},
-            {id:'diff_list_tr', type:'tr', state:'display'},
-            {id:'priority_tr', type:'tr', state:'display'},
-            {id:'subject_tr', type:'tr', state:'display'},
-            {id:'initiator_tr', type:'tr', state:'display'},
-            {id:'sender_recipient_tr', type:'tr', state:'display'},
-            {id:'doc_date_tr', type:'tr', state:'display'}
-            // END NCH01
-        ];
-    }
-    //Category = OUTGOING
-    else if(cat_id == 'outgoing')
-    {
-        var category = [
-            {id:'doctype_mail', type:'label', state:'display'},
-            {id:'doctype_res', type:'label', state:'hide'},
-            {id:'priority_tr', type:'tr', state:'display'},
-            {id:'external_reference_tr', type:'tr', state:'hide'},
-            {id:'external_id_mandatory', type:'tr', state:'hide'},
-            {id:'doc_date_label', type:'label', state:'hide'},
-            {id:'mail_date_label', type:'label', state:'display'},
-            {id:'author_tr', type:'tr', state:'hide'},
-            {id:'admission_date_tr', type:'tr', state:'hide'},
-            {id:'contact_check', type:'tr', state:'hide'},
-            {id:'nature_id_tr', type:'tr', state:'display'},
-            {id:'department_tr', type:'tr', state:'display'},
-            {id:'label_dep_dest', type:'label', state:'hide'},
-            {id:'label_dep_exp', type:'label', state:'display'},
-            {id:'label_dep_owner', type:'label', state:'hide'},
-            {id:'difflist_tr', type:'tr', state:'display'},
-            {id:'process_limit_date_use_tr', type:'tr', state:'display'},
-            {id:'process_limit_date_tr', type:'tr', state:'display'},
-            {id:'box_id_tr', type:'tr', state:'display'},
-            {id:'contact_choose_tr', type:'tr', state:'hide'},
-            {id:'contact_choose_2_tr', type:'tr', state:'hide'},
-            {id:'contact_choose_3_tr', type:'tr', state:'hide'},
-            {id:'dest_contact_choose_label', type:'label', state:'display'},
-            {id:'exp_contact_choose_label', type:'label', state:'hide'},
-            {id:'contact_id_tr', type:'tr', state:'display'},
-            {id:'dest_contact', type:'label', state:'display'},
-            {id:'exp_contact', type:'label', state:'hide'},
-            {id:'dest_multi_contact', type:'label', state:'display'},
-            {id:'exp_multi_contact', type:'label', state:'hide'},
-            {id:'author_contact', type:'label', state:'hide'},
-            {id:'type_multi_contact_external_icon', type:'label', state:'display'},
-            {id:'type_contact_internal', type:'radiobutton', state:typeContactInternal},
-            {id:'type_contact_external', type:'radiobutton', state:typeContactExternal},
-            {id:'type_multi_contact_external', type:'radiobutton', state:typeMultiContactExternal},
-            {id:'folder_tr', type:'tr', state:'display'},
-            {id:'category_id_mandatory', type:'label', state:'display'},
-            {id:'type_id_mandatory', type:'label', state:'display'},
-            {id:'priority_mandatory', type:'label', state:'display'},
-            {id:'doc_date_mandatory', type:'label', state:'display'},
-            {id:'departure_date_mandatory', type:'label', state:'hide'},
-            {id:'departure_date_tr', type:'tr', state:'hide'},
-            {id:'author_mandatory', type:'label', state:'hide'},
-            {id:'admission_date_mandatory', type:'label', state:'hide'},
-            {id:'type_contact_mandatory', type:'label', state:'display'},
-            {id:'contact_mandatory', type:'label', state:'display'},
-            {id:'nature_id_mandatory', type:'label', state:'display'},
-            {id:'subject_mandatory', type:'label', state:'display'},
-            {id:'destination_mandatory', type:'label', state:'display'},
-            {id:'process_limit_date_use_mandatory', type:'label', state:'display'},
-            {id:'process_limit_date_mandatory', type:'label', state:'display'},
-            {id:'chrono_number', type:'label', state:'hide'},
-            {id:'chrono_number_tr', type:'tr', state:'hide'},
-            {id:'chrono_number_mandatory', type:'label', state:'hide'},
-            {id:'folder_mandatory', type:'label', state:'hide'},
-            {id:'sr_sender_span', type:'label', state:'display'},
-            {id:'sr_recipient_span', type:'label', state:'hide'},
-            //NCH01
-            {id:'type_id_tr', type:'tr', state:'display'},
-            {id:'confidentiality_tr', type:'tr', state:'display'},
-            {id:'diff_list_tr', type:'tr', state:'display'},
-            {id:'priority_tr', type:'tr', state:'display'},
-            {id:'subject_tr', type:'tr', state:'display'},
-            {id:'initiator_tr', type:'tr', state:'display'},
-            {id:'sender_recipient_tr', type:'tr', state:'display'},
-            {id:'doc_date_tr', type:'tr', state:'display'}
-            // END NCH01
-        ];
-    }
-    //Category = INTERNAL
-    else if(cat_id == 'internal')
-    {
-        var category = [
-        {id:'doctype_mail', type:'label', state:'display'},
-        {id:'doctype_res', type:'label', state:'hide'},
-        {id:'priority_tr', type:'tr', state:'display'},
-        {id:'doc_date_label', type:'label', state:'hide'},
-        {id:'mail_date_label', type:'label', state:'display'},
-        {id:'author_tr', type:'tr', state:'hide'},
-        {id:'admission_date_tr', type:'tr', state:'hide'},
-        {id:'contact_check', type:'tr', state:'hide'},
-        {id:'nature_id_tr', type:'tr', state:'display'},
-        {id:'department_tr', type:'tr', state:'display'},
-        {id:'label_dep_dest', type:'label', state:'display'},
-        {id:'label_dep_exp', type:'label', state:'hide'},
-        {id:'label_dep_owner', type:'label', state:'hide'},
-        {id:'difflist_tr', type:'tr', state:'display'},
-        {id:'process_limit_date_use_tr', type:'tr', state:'display'},
-        {id:'process_limit_date_tr', type:'tr', state:'display'},
-        {id:'box_id_tr', type:'tr', state:'display'},
-        {id:'contact_choose_tr', type:'tr', state:'hide'},
-        {id:'contact_choose_2_tr', type:'tr', state:'hide'},
-        {id:'contact_choose_3_tr', type:'tr', state:'hide'},
-        {id:'dest_contact_choose_label', type:'label', state:'hide'},
-        {id:'exp_contact_choose_label', type:'label', state:'display'},
-        {id:'contact_id_tr', type:'tr', state:'display'},
-        {id:'dest_contact', type:'label', state:'hide'},
-        {id:'exp_contact', type:'label', state:'display'},
-        {id:'dest_multi_contact', type:'label', state:'hide'},
-        {id:'exp_multi_contact', type:'label', state:'display'},
-        {id:'author_contact', type:'label', state:'hide'},
-        {id:'type_multi_contact_external_icon', type:'label', state:'hide'},
-        {id:'type_contact_internal', type:'radiobutton', state:typeContactInternal},
-        {id:'type_contact_external', type:'radiobutton', state:typeContactExternal},
-        {id:'type_multi_contact_external', type:'radiobutton', state:typeMultiContactExternal},
-        {id:'folder_tr', type:'tr', state:'display'},
-        {id:'category_id_mandatory', type:'label', state:'display'},
-        {id:'type_id_mandatory', type:'label', state:'display'},
-        {id:'priority_mandatory', type:'label', state:'display'},
-        {id:'doc_date_mandatory', type:'label', state:'display'},
-        {id:'author_mandatory', type:'label', state:'hide'},
-        {id:'admission_date_mandatory', type:'label', state:'hide'},
-        {id:'type_contact_mandatory', type:'label', state:'display'},
-        {id:'contact_mandatory', type:'label', state:'display'},
-        {id:'nature_id_mandatory', type:'label', state:'display'},
-        {id:'subject_mandatory', type:'label', state:'display'},
-        {id:'destination_mandatory', type:'label', state:'display'},
-        {id:'process_limit_date_use_mandatory', type:'label', state:'display'},
-        {id:'process_limit_date_mandatory', type:'label', state:'display'},
-        {id:'chrono_number', type:'label', state:'hide'},
-        {id:'chrono_number_tr', type:'tr', state:'hide'},
-        {id:'chrono_number_mandatory', type:'label', state:'hide'},
-        {id:'folder_mandatory', type:'label', state:'hide'},
-            {id:'sr_sender_span', type:'label', state:'hide'},
-            {id:'sr_recipient_span', type:'label', state:'display'},
-            //NCH01
-            {id:'type_id_tr', type:'tr', state:'display'},
-            {id:'confidentiality_tr', type:'tr', state:'display'},
-            {id:'diff_list_tr', type:'tr', state:'display'},
-            {id:'priority_tr', type:'tr', state:'display'},
-            {id:'subject_tr', type:'tr', state:'display'},
-            {id:'initiator_tr', type:'tr', state:'display'},
-            {id:'sender_recipient_tr', type:'tr', state:'display'},
-            {id:'doc_date_tr', type:'tr', state:'display'}
-            // END NCH01
-        ];
-    }
-    //Category = GED_DOC
-    if(cat_id == 'ged_doc')
-    {
-        var category = [
-        {id:'doctype_mail', type:'label', state:'hide'},
-        {id:'doctype_res', type:'label', state:'display'},
-        {id:'priority_tr', type:'tr', state:'hide'},
-        {id:'doc_date_label', type:'label', state:'display'},
-        {id:'mail_date_label', type:'label', state:'hide'},
-        {id:'author_tr', type:'tr', state:'hide'},
-        {id:'admission_date_tr', type:'tr', state:'hide'},
-        {id:'contact_check', type:'tr', state:'hide'},
-        {id:'nature_id_tr', type:'tr', state:'hide'},
-        {id:'label_dep_dest', type:'label', state:'hide'},
-        {id:'label_dep_exp', type:'label', state:'hide'},
-        {id:'label_dep_owner', type:'label', state:'display'},
-        {id:'process_limit_date_use_tr', type:'tr', state:'hide'},
-        {id:'process_limit_date_tr', type:'tr', state:'hide'},
-        {id:'department_tr', type:'tr', state:'display'},
-        {id:'box_id_tr', type:'tr', state:'hide'},
-        {id:'contact_choose_tr', type:'tr', state:'hide'},
-        {id:'contact_choose_2_tr', type:'tr', state:'hide'},
-        {id:'contact_choose_3_tr', type:'tr', state:'hide'},
-        {id:'dest_contact_choose_label', type:'label', state:'hide'},
-        {id:'exp_contact_choose_label', type:'label', state:'display'},
-        {id:'contact_id_tr', type:'tr', state:'display'},
-        {id:'dest_contact', type:'label', state:'hide'},
-        {id:'exp_contact', type:'label', state:'hide'},
-        {id:'dest_multi_contact', type:'label', state:'hide'},
-        {id:'exp_multi_contact', type:'label', state:'hide'},
-        {id:'author_contact', type:'label', state:'display'},
-        {id:'type_multi_contact_external_icon', type:'label', state:'hide'},
-        {id:'type_contact_internal', type:'radiobutton', state:typeContactInternal},
-        {id:'type_contact_external', type:'radiobutton', state:typeContactExternal},
-        {id:'type_multi_contact_external', type:'radiobutton', state:typeMultiContactExternal},
-        {id:'folder_tr', type:'tr', state:'display'},
-        {id:'category_id_mandatory', type:'label', state:'display'},
-        {id:'type_id_mandatory', type:'label', state:'display'},
-        {id:'priority_mandatory', type:'label', state:'display'},
-        {id:'doc_date_mandatory', type:'label', state:'display'},
-        {id:'author_mandatory', type:'label', state:'hide'},
-        {id:'admission_date_mandatory', type:'label', state:'display'},
-        {id:'type_contact_mandatory', type:'label', state:'display'},
-        {id:'contact_mandatory', type:'label', state:'display'},
-        {id:'nature_id_mandatory', type:'label', state:'display'},
-        {id:'subject_mandatory', type:'label', state:'display'},
-        {id:'destination_mandatory', type:'label', state:'display'},
-        {id:'process_limit_date_use_mandatory', type:'label', state:'display'},
-        {id:'process_limit_date_mandatory', type:'label', state:'display'},
-        {id:'chrono_number', type:'label', state:'hide'},
-        {id:'chrono_number_mandatory', type:'label', state:'hide'},
-        {id:'chrono_number_tr', type:'tr', state:'hide'},
-        {id:'folder_mandatory', type:'label', state:'hide'},
-        {id:'external_reference_tr', type:'tr', state:'hide'},
-        {id:'external_id_mandatory', type:'tr', state:'hide'},
-            {id:'sr_sender_span', type:'label', state:'hide'},
-            {id:'sr_recipient_span', type:'label', state:'display'},
-            //NCH01
-            {id:'type_id_tr', type:'tr', state:'display'},
-            {id:'confidentiality_tr', type:'tr', state:'display'},
-            {id:'subject_tr', type:'tr', state:'display'},
-            {id:'initiator_tr', type:'tr', state:'display'},
-            {id:'sender_recipient_tr', type:'tr', state:'display'},
-            {id:'doc_date_tr', type:'tr', state:'display'}
-            // END NCH01
-        ];
-    } else if(cat_id == 'attachment'){    // NCH01
-        var category = [
-            {id:'doctype_mail', type:'label', state:'display'},
-            {id:'doctype_res', type:'label', state:'hide'},
-            {id:'priority_tr', type:'tr', state:'hide'},
-            {id:'external_reference_tr', type:'tr', state:'hide'},
-            {id:'external_id_mandatory', type:'tr', state:'hide'},
-            {id:'doc_date_label', type:'label', state:'hide'},
-            {id:'doc_date_tr', type:'tr', state:'hide'},
-            {id:'mail_date_label', type:'label', state:'hide'},
-            {id:'author_tr', type:'tr', state:'hide'},
-            {id:'admission_date_tr', type:'tr', state:'hide'},
-            {id:'contact_check', type:'tr', state:'hide'},
-            {id:'nature_id_tr', type:'tr', state:'hide'},
-            {id:'department_tr', type:'tr', state:'hide'},
-            {id:'label_dep_dest', type:'label', state:'hide'},
-            {id:'label_dep_exp', type:'label', state:'hide'},
-            {id:'process_limit_date_use_tr', type:'tr', state:'hide'},
-            {id:'process_limit_date_tr', type:'tr', state:'hide'},
-            {id:'box_id_tr', type:'tr', state:'hide'},
-            {id:'confidentiality_tr', type:'tr', state:'hide'},
-            {id:'contact_choose_tr', type:'tr', state:'hide'},
-            {id:'contact_choose_2_tr', type:'tr', state:'hide'},
-            {id:'contact_choose_3_tr', type:'tr', state:'hide'},
-            {id:'dest_contact_choose_label', type:'label', state:'hide'},
-            {id:'exp_contact_choose_label', type:'label', state:'hide'},
-            {id:'contact_id_tr', type:'tr', state:'hide'},
-            {id:'dest_contact', type:'label', state:'display'},
-            {id:'exp_contact', type:'label', state:'hide'},
-            {id:'author_contact', type:'label', state:'hide'},
-            {id:'type_multi_contact_external_icon', type:'label', state:'hide'},
-            {id:'type_contact_internal', type:'radiobutton', state:typeContactInternal},
-            {id:'type_contact_external', type:'radiobutton', state:typeContactExternal},
-            {id:'type_multi_contact_external', type:'radiobutton', state:typeMultiContactExternal},
-            {id:'folder_tr', type:'tr', state:'hide'},
-            {id:'category_id_mandatory', type:'label', state:'hide'},
-            {id:'type_id_mandatory', type:'label', state:'hide'},
-            {id:'type_id_tr', type:'tr', state:'hide'},
-            {id:'diff_list_tr', type:'tr', state:'hide'},
-            {id:'priority_mandatory', type:'label', state:'hide'},
-            {id:'doc_date_mandatory', type:'label', state:'hide'},
-            {id:'author_mandatory', type:'label', state:'hide'},
-            {id:'admission_date_mandatory', type:'label', state:'hide'},
-            {id:'type_contact_mandatory', type:'label', state:'hide'},
-            {id:'contact_mandatory', type:'label', state:'hide'},
-            {id:'nature_id_mandatory', type:'label', state:'hide'},
-            {id:'subject_mandatory', type:'label', state:'hide'},
-            {id:'destination_mandatory', type:'label', state:'hide'},
-            {id:'process_limit_date_use_mandatory', type:'label', state:'hide'},
-            {id:'process_limit_date_mandatory', type:'label', state:'hide'},
-            {id:'chrono_number', type:'label', state:'hide'},
-            {id:'chrono_number_tr', type:'tr', state:'hide'},
-            {id:'chrono_number_mandatory', type:'label', state:'hide'},
-            {id:'folder_mandatory', type:'label', state:'hide'},
-            {id:'res_id_link', type:'label', state:'hide'},
-            {id:'status', type:'tr', state:'hide'},
-            {id:'departure_date_mandatory', type:'label', state:'hide'},
-            {id:'departure_date_tr', type:'tr', state:'hide'},
-            {id:'add_multi_contact_tr', type:'tr', state:'hide'},
-            {id:'show_multi_contact_tr', type:'tr', state:'hide'},
-            {id:'sr_sender_span', type:'label', state:'hide'},
-            {id:'sr_recipient_span', type:'label', state:'hide'},
-            {id:'initiator_tr', type:'tr', state:'hide'},
-            {id:'sender_recipient_tr', type:'tr', state:'hide'}
-        ];
-    }
-
-    if(cat_id == 'attachment'){ // only qualification page
-        document.getElementById("attachment_tr").style.display='table-row';
-        document.getElementById("attach_show").style.display='display';
-        $j('#attach_reconciliation').click();
-
-        document.getElementById("subject_tr").style.display = 'none';
-        document.getElementById("diff_list_tr").style.display = 'none';
-    }else{
-        if($j('#attach_reconciliation').length > 0){ // qualification page
-            document.getElementById("attachment_tr").style.display='none';
-        } else { // indexing page
-            document.getElementById("attachment_tr").style.display='table-row';
-        }
-        $j('#no_attach').click();
-        
-        document.getElementById("diff_list_tr").style.display = 'display';
-        document.getElementById("subject_tr").style.display = 'display';
-    }
-
-    if(params_cat)
-    {
-        process_category(category, display_value_tr, params_cat);
-    }
-    else
-    {
-        process_category(category, display_value_tr);
-    }
-
-    if(cat_id != null && cat_id != '' && cat_id != NaN)
-    {
-        //Read the actual box for this category
-        //change_box(cat_id);
-        new Ajax.Request(path_manage_script,
-        {
-            method:'post',
-            parameters: { category_id : cat_id
-                        },
-                onSuccess: function(answer){
-                eval("response = "+answer.responseText);
-                // console.log('1 '+answer.responseText);
-                // console.log('2 '+response);
-                if(response.status == 0 )
-                {
-                    var services_to_exec = response.services;
-                    if (
-                        cat_id == 'outgoing'
-                        && (response.doc_date != undefined 
-                        && ($('doc_date') != undefined && $('doc_date').value == ''))
-                    ) {
-                        var doc_date = response.doc_date;
-                        $('doc_date').value = doc_date;
-
-                        var destination = response.destination;
-                        $('destination').value = destination;
-                    }
-
-                    if(cat_id == 'ged_doc'){	// NCH01
-                        document.getElementById("diff_list_tr").style.display = 'none';
-                    }else if(cat_id == 'attachment'){
-                        document.getElementById("subject_tr").style.display = 'none';
-                        document.getElementById("diff_list_tr").style.display = 'none';
-                    }else{
-                        document.getElementById("diff_list_tr").style.display = 'table-row';
-                        document.getElementById("subject_tr").style.display = 'table-row';
-                    }
-                    
-                    if(cat_id != 'outgoing' && origin != 'scan'){
-                        $j("#choose_file").on("load", function () {
-                            $j("#choose_file").off();
-                            $j('#choose_file_div').show();
-                            $j('#choose_file').contents().find('#with_file').click();
-                        });                        
-                    } else if (origin != 'scan') {
-                        $j("#choose_file").on("load", function () {
-                            $j("#choose_file").off();
-                            $j('#choose_file').contents().find('#with_file2').click();
-                            $j('#choose_file_div').hide();
-                        });
-                    }
-
-                    if(origin != 'init'){
-                        document.getElementById("diff_list_tr").style.display='table-row';
-                        document.getElementById("destination").onchange();
-                        $j("#destination").trigger("chosen:updated");
-                    }
-
-                    var path_scripts = '';
-                    var call_func = '';
-
-                    for(var ind=0; ind < services_to_exec.length;ind++)
-                    {
-                        path_scripts += services_to_exec[ind]['script'] + '$$';
-                        call_func += services_to_exec[ind]['function_to_execute']+'('+services_to_exec[ind]['arguments']+');';
-                    }
-                    //console.log(get_js_script);
-                    if(call_func != '' && path_scripts != '' && get_js_script != '')
-                    {
-                        //console.log('OK');
-                        new Ajax.Request(get_js_script,
-                        {
-                            method:'post',
-                            parameters:
-                            {
-                                scripts : path_scripts
-                            },
-                             onSuccess: function(answer){
-                                //console.log(answer.responseText+call_func);
-                                eval(answer.responseText+call_func);
-                            }
-                        });
-                    }
-                }
-                else
-                {
-                    try{
-                        $('frm_error').innerHTML = response.error_txt;
-                        }
-                    catch(e){}
-                }
-            }
-        });
-    }
-
-    // NCH01
-    if(cat_id == 'attachment'){
-        if(document.getElementById("attachment_tr")){
-            document.getElementById("attachment_tr").style.display='table-row';
-            document.getElementById("attach_show").style.display='table-row';
-        }
-    }else{
-        if(document.getElementById("attachment_tr")){
-            document.getElementById("attachment_tr").style.diplay = 'none';
-            document.getElementById("attach_show").style.display='none';
-        }
-    }
-
-    var process_date_not_used = $('process_limit_date_use_no').checked;
-    if(process_date_not_used){
-        activate_process_date(false, 'none');
-    }
-
-    var div_indexes = $('comp_indexes');
-    if(div_indexes && cat_id == 'attachment')
-    {
-        document.getElementById("comp_indexes").style.display='none';
-    }else if(div_indexes && cat_id !== 'attachment'){
-        document.getElementById("comp_indexes").style.display='table-row';
-    }
-    // END NCH01
-}
-
-/**
- * Shows all the required fields and labels for the category and hides all the others
- *
- * @param category String JSON Object of the fields to display
- **/
-function process_category(category, display_value_tr, params_cat)
-{
-    var tr_display_val = display_value_tr || 'table-row';
-    var no_param = true;
-    if(params_cat)
-    {
-        no_param = false;
-    }
-    if(category != null && category.length > 0)
-    {
-        for(var i=0; i < category.length; i++)
-        {
-            var item = $(category[i]['id']);
-            if(item != null)
-            {
-                if(category[i]['state'] == 'hide' )
-                {
-                    Element.setStyle(item, {display : 'none'});
-                    //item.style.display = 'none';
-                }
-                else if(category[i]['state'] == 'display')
-                {
-                    if(category[i]['type'] == 'label')
-                    {
-                        Element.setStyle(item, {display : 'inline'});
-                        //item.style.display = 'inline';
-                    }
-                    else if(category[i]['type'] == 'tr')
-                    {
-                        Element.setStyle(item, {display : tr_display_val});
-                        //item.style.display = tr_display_val;
-                    }
-                }
-                else if(category[i]['state'] == 'checked')
-                {
-                    item.checked = true;
-                    //~ if(  no_param || typeof(params_cat[category[i]['id']]) == undefined ||  typeof(params_cat[category[i]['id']]['onchange']) == undefined || params_cat[category[i]['id']]['onchange'] == true )
-                    //~ {
-                        //~ item.onchange();
-                    //~ }
-                    if(  no_param || typeof(params_cat[category[i]['id']]) == undefined ||  typeof(params_cat[category[i]['id']]['onclick']) == undefined || params_cat[category[i]['id']]['onclick'] == true )
-                    {
-                        item.onclick();
-                    }
-                }
-                else if(category[i]['state'] == 'not_checked')
-                {
-                    item.checked = false;
-                }
-            }
-        }
-    }
-}
-
 /** Declaration of the autocompleter object used for the contacts*/
 var contact_autocompleter;
 
@@ -1185,133 +292,6 @@ function get_contacts_params(name_radio)
     return params;
 }
 
-/**
- * Update the parameters of the contact_autocompleter object
- *
- **/
-function update_contact_autocompleter()
-{
-    var params = get_contacts_params();
-    if( contact_autocompleter  )
-    {
-        if(contact_autocompleter.options.defaultParams == null)
-        {
-            contact_autocompleter.options.defaultParams = 'table=contacts';
-        }
-        var old_param = contact_autocompleter.options.defaultParams;
-        var new_param =old_param.substring(0, old_param.indexOf('table=') -1) ;
-        if(new_param && new_param !='')
-        {
-            new_param += '&'+params;
-        }
-        else
-        {
-            new_param =  params;
-        }
-        contact_autocompleter.options.defaultParams = new_param;
-    }
-}
-
-/**
- * When you change the contact type, the table used for the autocompletion change
- *
- * @param path_autocomplete String Path to the Ajax script
- **/
-function change_contact_type(path_autocomplete, empty_contact_div, id_internal, id_external, id_contact, id_multi_external)
-{
-    var contact_id = id_contact || 'contact';
-    var external_type = id_external || 'type_contact_external';
-    var internal_type = id_internal || 'type_contact_internal';
-    var multi_external_type = id_multi_external || 'type_multi_contact_external';
-    var create_contact = $('create_contact');
-    var contact_card = $('contact_card');
-    var valid_multi_contact = $('valid_multi_contact');
-    var email = $('email');
-    var to_multi_contact = $('to_multi_contact');
-    var to = $('to');
-    var show_multi_contact = $('show_multi_contact_tr');
-    var add_multi_contact = $('add_multi_contact_tr');
-    var contact_id_tr = $('contact_id_tr');
-    if(typeof(empty_contact_div) == 'undefined' || empty_contact_div == null)
-    {
-        var empty_contact = true ;
-    }
-    else
-    {
-        var empty_contact = empty_contact_div ;
-    }
-    if(create_contact)
-    {
-        if($(internal_type).checked == true)
-        {
-            Element.setStyle(create_contact, {display : 'none'});
-            //create_contact.style.display = 'none';
-			Element.setStyle(email, {display : 'none'});
-			Element.setStyle(valid_multi_contact, {display : 'none'});
-			Element.setStyle(to_multi_contact, {display : 'none'});
-			Element.setStyle(to, {display : 'none'});
-			Element.setStyle(show_multi_contact, {display : 'none'});
-			Element.setStyle(add_multi_contact, {display : 'none'});
-            Element.setStyle(contact_id_tr, {display : 'table-row'});
-            if($j('#create_contact_div').length > 0)
-            {
-                Element.setStyle('create_contact_div', {display : 'none'});
-            }
-            if($j('#info_contact_div').length > 0) {
-                Element.setStyle('info_contact_div', {display : 'none'});
-            }
-        }
-        else if($(external_type ).checked == true || $(multi_external_type ).checked == true )
-        {
-            var cat_id = $(category_id).options[$(category_id).selectedIndex].value; // NCH01
-            Element.setStyle(create_contact, {display : 'inline'});
-            //create_contact.style.display = 'inline';
-			if($(multi_external_type ).checked == true){
-				Element.setStyle(email, {display : 'inline'});
-				Element.setStyle(valid_multi_contact, {display : 'inline'});
-				Element.setStyle(to_multi_contact, {display : 'table-cell'});
-				Element.setStyle(to, {display : 'inline'});
-                // NCH01
-				if(cat_id !== 'attachment'){
-                    Element.setStyle(show_multi_contact, {display : 'table-row'});
-                }
-				Element.setStyle(add_multi_contact, {display : 'table-row'});
-				Element.setStyle(contact_id_tr, {display : 'none'});
-			}else if ($(external_type ).checked == true){
-				Element.setStyle(email, {display : 'none'});
-				Element.setStyle(valid_multi_contact, {display : 'none'});
-				Element.setStyle(to_multi_contact, {display : 'none'});
-				Element.setStyle(to, {display : 'none'});
-				Element.setStyle(show_multi_contact, {display : 'none'});
-				Element.setStyle(add_multi_contact, {display : 'none'});
-				// NCH01
-                if(cat_id !== 'attachment') {
-                    Element.setStyle(contact_id_tr, {display : 'table-row'});
-                }
-			}
-        }
-    }
-    if(empty_contact)
-    {
-        $(contact_id).value='';
-        $("contactid").value='';
-        $("contactcheck").value='success';
-        $("contact_check").innerHTML = "";
-        $("contact").style.backgroundColor='#ffffff';
-    }
-    display_contact_card('hidden');
-    update_contact_autocompleter();
-}
-
-function init_validation(path_autocomplete_contact, display_value_tr, path_manage_script, get_js_script)
-{
-    var param_cat = {'type_contact_internal' : {'onclick' : false} , 'type_contact_external' : {'onclick' : false}, 'type_multi_contact_external' : {'onclick' : false}};
-    change_category($('category_id').value, display_value_tr,path_manage_script,get_js_script, param_cat, 'init');
-    change_contact_type(path_autocomplete_contact, false);
-    $('contact').onchange();
-    //$('destination').onchange();
-}
-
 function clear_error(id_error)
 {
     //console.log("'"+id_error+"'");
@@ -1382,48 +362,6 @@ function changeCycle(path_manage_script)
     //}
 }
 
-function getIframeContent(path_manage_script)
-{
-    userAgent = navigator.userAgent;
-    var isIE = userAgent.indexOf("MSIE ") > -1 || userAgent.indexOf("Trident/") > -1 || userAgent.indexOf("Edge/") > -1;
-    if(isIE){
-        var iframe = document.frames['file_iframe'];
-        doc_content = iframe.document
-    } else {
-        var iframe = document.getElementById("file_iframe");
-        doc_content = iframe.contentDocument;
-    }
-
-    if ($j('#choose_file_div') && doc_content) {
-        var choose_file_div = $('choose_file_div');
-        if (choose_file_div.style.display == 'none') {            
-            var iframeContent = doc_content;
-            var templateContent2 = iframeContent.getElementById("template_content_ifr");
-            if (templateContent2) {
-                var templateContent = templateContent2.contentDocument;
-                if (templateContent) {
-                    var templateContentBody = templateContent.getElementById("tinymce");
-                    //window.alert(templateContentBody.innerHTML);
-                    new Ajax.Request(path_manage_script,
-                    {
-                        method:'post', asynchronous:false,
-                        parameters: { template_content : templateContentBody.innerHTML
-                        },
-                        onSuccess: function(answer){
-                            eval("response = "+answer.responseText);
-                            if(response.status == 0) {
-                                //
-                            } else {
-                                //alert(answer.responseText);
-                            }
-                        }
-                    });
-                }
-            }
-        }
-    }
-}
-
 var addMultiContacts = function (idField, idList, theUrlToListScript, paramNameSrv, minCharsSrv, contact_id, address_id) {
      new Ajax.Autocompleter(
          idField,
@@ -1488,92 +426,6 @@ function updateMultiContacts(path, action, contact, target, array_index, address
 	});
 }
 
-function update_contact_type_session(path)
-{
-    var check = 'type_contact';
-    // var arr = get_checked_values(check);
-    var arr = ["multi_external"];
-    var params = '';
-    
-    if (arr.length == 0) {
-        var contact_type = 'letter';
-        params = 'table=contacts&contact_type=' + contact_type;
-    } else {
-        if (arr[0] == 'internal') {
-            params = 'users';
-        } else if(arr[0] == 'external') {
-            params = 'contacts';
-        } else if(arr[0] == 'multi_external') {
-            params = 'multi';
-        } else {
-            params = 'contacts';
-        }
-    }
-    new Ajax.Request(path,
-    {
-        method:'post',
-        parameters:
-        {
-            paramsRequest : params
-        },
-        onSuccess: function(answer){
-            eval(answer.responseText);
-        }
-    });
-}
-
-function change_category_actions(path_manage_script, resId, collId,category_id)
-{  
-    
-    if(category_id != '') {
-        if (resId === undefined && collId === undefined) {
-            new Ajax.Request(path_manage_script,
-            {
-                method:'post',
-                parameters: { category_id : category_id
-                            },
-                    onSuccess: function(answer){
-                    eval("response = "+answer.responseText);
-                    if(response.status == 0 || response.status == 1) {
-                        if(response.status == 0) {
-                            $('actionSpan').innerHTML = response.selectAction;
-                        } else {
-                            //
-                        }
-                    } else {
-                        try {
-                            $('actionSpan').innerHTML = response.error_txt;
-                        }
-                        catch(e){}
-                    }
-                }
-            });
-        } else {
-            new Ajax.Request(path_manage_script,
-            {
-                method:'post',
-                parameters: { category_id : category_id, resId : resId, collId : collId
-                            },
-                    onSuccess: function(answer){
-                    eval("response = "+answer.responseText);
-                    if(response.status == 0 || response.status == 1) {
-                        if(response.status == 0) {
-                            $('actionSpan').innerHTML = response.selectAction;
-                        } else {
-                            //
-                        }
-                    } else {
-                        try {
-                            $('actionSpan').innerHTML = response.error_txt;
-                        }
-                        catch(e){}
-                    }
-                }
-            });
-        }
-    }
-}
-
 function set_new_contact_address(path_manage_script, id_div, close,transmission){
     if (close == "true") {
         new Effect.toggle(parent.document.getElementById(id_div), 'blind', {delay:0.2});  
@@ -1652,63 +504,6 @@ function set_new_contact_address(path_manage_script, id_div, close,transmission)
     }
 }
 
-function check_date_exp(path_manage_script, path_link){
-    var check_days_before = $('check_days_before').value;
-
-    if (check_days_before > 0) {
-        var contact_id = $('contactid').value;
-        var address_id = $('addressid').value;
-        var res_id = $('values').value;
-        var e = $("category_id");
-        var category = e.options[e.selectedIndex].value;
-        var scriptAddons = '';
-        new Ajax.Request(path_manage_script,
-        {
-            method:'post',
-            parameters: {
-                contact_id : contact_id,
-                address_id : address_id,
-                res_id : res_id,
-                category : category
-            },
-            onSuccess: function(answer){
-                if(answer.responseText == "success"){
-                    // document.getElementById('contact').style.backgroundColor='#ffffff';
-                    document.getElementById('contact_check').style.display='none';
-                    document.getElementById('contactcheck').value = answer.responseText;
-                } else {
-                    if (document.getElementById('to_link') != null) {
-                        scriptAddons = "document.getElementById('to_link').click();";
-                    }
-                    document.getElementById('contact_check').style.display='table-row';
-                    document.getElementById("contact_check").innerHTML = "<td colspan=\"3\" style=\"font-size: 9px;text-align: center;color:#ea0000;\">Au moins un courrier enregistré dans les "+check_days_before+" derniers jours est affecté au même contact. "+
-                                                                            "<input type='button' class='button' value='Voir' onclick=\""+scriptAddons+"window.open('"+path_link+"',"+
-                                                                            " 'search_doc_for_attachment', 'scrollbars=yes,menubar=no,toolbar=no,resizable=yes,status=no,width=1100,height=775');\"/></td>";
-                    document.getElementById('contactcheck').value = answer.responseText;
-                }
-            }
-        });
-    }
-}
-
-function reset_check_date_exp(){
-	document.getElementById('contact').style.backgroundColor='#ffffff';
-	document.getElementById('contact_check').style.display='none';
-	document.getElementById('contactcheck').value = 'success';
-}
-
-function hideSelectFile(){
-    var e = $("category_id");
-    var category = e.options[e.selectedIndex].value;
-    if (category == "outgoing") {
-        // $('choose_file_div').style.display='none';
-        window.frames["choose_file"].$('with_file2').click();       
-    } else {
-        // $('choose_file_div').style.display='block';
-        window.frames["choose_file"].$('with_file').click(); 
-    }
-}
-
 function affiche_chrono(){
     
     var type_id = document.getElementById('attachment_types').options[document.getElementById('attachment_types').selectedIndex];
@@ -1796,15 +591,6 @@ function loadInfoContact(){
     return pathScript;
 }
 
-function loadInfoContactSenderRecipient(){
-
-    var pathScript = '';
-
-    pathScript = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&mode=editDetailSender&editDetailSender&popup&sender_recipient_id='+document.getElementById('sender_recipient_id').value+'&sender_recipient_type='+document.getElementById('sender_recipient_type').value;
-
-    return pathScript;
-}
-
 function initSenderRecipientAutocomplete(inputId, mode, alternateVersion, cardId) {
     var route = '';
     if (mode == 'contactsUsers') {
diff --git a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml
index 4d55eaa6fdfd0dc8215276c3cb5917e68f44bed4..c4f17cd1d993b0c472481fb112ec720606b27397 100755
--- a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml
+++ b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml
@@ -218,23 +218,6 @@
       <parameter name="page" value="autocomplete_contacts_prepare_multi"/>
       <parameter name="display" value="true"/>
     </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="ix_change_category" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="change_category"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="ix_change_category_actions" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="change_category_actions"/>
-      <parameter name="display" value="true"/>
-      <parameter name="resId"/>
-      <parameter name="collId"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="ix_change_doctype" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="change_doctype"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
     <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="type_id_integer" >
       <parameter name="dir" value="indexing_searching"/>
       <parameter name="page" value="change_doctype_details"/>
diff --git a/apps/maarch_entreprise/xml/IVS/validation_rules.xml b/apps/maarch_entreprise/xml/IVS/validation_rules.xml
index c32b61ad789ae7db879e6da3715f2de0cda520a0..de78c11edf8d247f5932f70cfb160cd7a3210a6f 100755
--- a/apps/maarch_entreprise/xml/IVS/validation_rules.xml
+++ b/apps/maarch_entreprise/xml/IVS/validation_rules.xml
@@ -277,28 +277,6 @@
       <parameter name="dir" type="identifier" />
     </validationRule>
 
-    <validationRule name="ix_change_category" extends="standardForm" mode="error">
-      <parameter name="category_id" type="identifier" />
-      <parameter name="dir" type="identifier" />
-    </validationRule>
-
-    <validationRule name="ix_change_category_actions" extends="standardForm" mode="error">
-      <parameter name="category_id" type="identifier" />
-      <parameter name="dir" type="identifier" />
-      <parameter name="resId" type="identifier" />
-      <parameter name="collId" type="collection_list" />
-    </validationRule>
-
-    <validationRule name="ix_change_doctype" extends="standardForm" mode="error">
-      <parameter name="type_id" type="integer" />
-      <parameter name="admission_date" type="datefr" />
-      <parameter name="id_action" type="identifier" />
-      <parameter name="priority_id" type="string" />
-      <parameter name="dir" type="identifier" />
-      <parameter name="res_id" type="identifier" />
-      <parameter name="coll_id" type="collection_list" />
-    </validationRule>
-
     <validationRule name="search_adv_result" extends="standardForm" mode="error">
       <parameter name="baskets_clause" type="identifier" />
       <parameter name="sender" type="string" />