From 19c9e358be56682df95256efb21f334ee1125bef Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Mon, 9 Dec 2019 14:49:01 +0100
Subject: [PATCH] FEAT #12510 TIME 1:30 Remove old contacts files

---
 .../admin/contacts/ajaxDeleteContact.php      |   36 -
 .../admin/contacts/ajaxLoadDocList.php        |  133 -
 .../contact_addresses/contact_addresses.php   |  353 --
 .../contact_addresses_add.php                 |   86 -
 .../contact_addresses_del.php                 |  178 -
 .../contact_addresses_list_by_name.php        |  118 -
 .../contact_addresses_status.php              |   65 -
 .../contact_addresses_up.php                  |  140 -
 .../contact_addresses_up_db.php               |   83 -
 .../contact_purposes/contact_purposes.php     |  150 -
 .../contact_purposes/contact_purposes_del.php |   93 -
 .../contact_purposes_list_by_name.php         |   71 -
 .../contact_purposes/contact_purposes_up.php  |  352 --
 .../get_tree_children_contact.php             |  139 -
 .../contact_tree/show_tree_contacts.php       |  210 --
 .../contact_tree/view_tree_contacts.php       |   63 -
 .../contacts/contact_types/contact_types.php  |  169 -
 .../contact_types/contact_types_del.php       |   93 -
 .../contact_types_list_by_name.php            |   59 -
 .../contact_types/contact_types_up.php        |  355 --
 .../contacts/contacts_v2/contacts_v2.php      |  299 --
 .../contacts/contacts_v2/contacts_v2_add.php  |   67 -
 .../contacts/contacts_v2/contacts_v2_del.php  |  120 -
 .../contacts_v2/contacts_v2_list_by_name.php  |  206 --
 .../contacts_v2/contacts_v2_status.php        |   65 -
 .../contacts/contacts_v2/contacts_v2_up.php   |  349 --
 .../contacts_v2/contacts_v2_up_db.php         |   56 -
 .../admin/contacts/fusionContact.php          |   66 -
 .../admin/contacts/manage_duplicates.php      |  509 ---
 .../admin/export_admin_list.php               |  138 -
 .../class_business_app_tools_Abstract.php     |  154 -
 .../class/class_contacts_v2.php               |   37 -
 .../class/class_contacts_v2_Abstract.php      | 2960 -----------------
 apps/maarch_entreprise/css/styles.css         |   14 -
 .../autocomplete_contacts.php                 |  318 --
 .../autocomplete_contacts_prepare_multi.php   |   35 -
 .../change_doctype_details.php                |  129 -
 .../contact_address_view.php                  |  119 -
 .../indexing_searching/contact_check.php      |   77 -
 .../contacts_v2_list_by_name_filters.php      |  105 -
 .../indexing_searching/contacts_view.php      |   90 -
 .../documents_list_mlb_search_adv.php         |    3 -
 .../list_results_contacts.php                 |   77 -
 .../indexing_searching/search_contacts.php    |  215 --
 .../search_contacts_result.php                |  168 -
 .../update_process_date.php                   |   97 -
 apps/maarch_entreprise/js/functions.js        |  907 -----
 apps/maarch_entreprise/js/indexing.js         |  543 ---
 .../js/usergroups_management.js               |  123 -
 apps/maarch_entreprise/lang/en.php            |   72 -
 apps/maarch_entreprise/lang/fr.php            |   72 -
 apps/maarch_entreprise/lang/nl.php            |   23 -
 .../my_contacts/create_address_iframe.php     |   93 -
 .../my_contacts/create_contact_iframe.php     |   87 -
 .../my_contacts/getContacts.php               |   82 -
 .../my_contacts/info_contact_iframe.php       |  301 --
 .../my_contacts/my_contact_add.php            |   44 -
 .../my_contacts/my_contact_del.php            |  104 -
 .../my_contacts/my_contact_up.php             |   74 -
 .../my_contacts/my_contact_up_db.php          |   39 -
 .../my_contacts/my_contacts.php               |  313 --
 .../my_contacts/purpose_check.php             |   43 -
 .../my_contacts/put_in_session.php            |   26 -
 .../my_contacts/setContactType.php            |   63 -
 .../my_contacts/update_address_iframe.php     |   68 -
 .../xml/IVS/requests_definitions.xml          |  153 -
 .../xml/IVS/validation_rules.xml              |  130 -
 apps/maarch_entreprise/xml/config.xml.default |    7 -
 apps/maarch_entreprise/xml/menu.xml           |   34 -
 core/class/class_core_tools.php               |   19 -
 modules/attachments/README.md                 |   17 -
 modules/attachments/js/functions.js           |  606 ----
 .../xml/IVS/requests_definitions.xml          |    8 +-
 .../attachments/xml/IVS/validation_rules.xml  |    8 -
 modules/export_seda/export_seda_list.php      |    4 +-
 modules/life_cycle/batch/process_purge.php    |   97 +-
 .../batch/load_basket_event_stack.php         |    4 -
 .../batch/load_process_event_stack.php        |    4 -
 modules/templates/js/functions.js             |   60 -
 sql/data_en.sql                               |   37 -
 src/app/contact/models/ContactModel.php       |   27 +-
 src/app/resource/models/ResourceListModel.php |   55 -
 82 files changed, 45 insertions(+), 13721 deletions(-)
 delete mode 100755 apps/maarch_entreprise/admin/contacts/ajaxDeleteContact.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/ajaxLoadDocList.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_add.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_del.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_list_by_name.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_status.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up_db.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_del.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_list_by_name.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_up.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_tree/get_tree_children_contact.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_tree/show_tree_contacts.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_tree/view_tree_contacts.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_types/contact_types.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_types/contact_types_del.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_types/contact_types_list_by_name.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_types/contact_types_up.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_add.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_del.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_list_by_name.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_status.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up_db.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/fusionContact.php
 delete mode 100755 apps/maarch_entreprise/admin/contacts/manage_duplicates.php
 delete mode 100755 apps/maarch_entreprise/admin/export_admin_list.php
 delete mode 100755 apps/maarch_entreprise/class/class_contacts_v2.php
 delete mode 100755 apps/maarch_entreprise/class/class_contacts_v2_Abstract.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/autocomplete_contacts.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/autocomplete_contacts_prepare_multi.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/change_doctype_details.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/contact_address_view.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/contact_check.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/contacts_v2_list_by_name_filters.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/contacts_view.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/list_results_contacts.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/search_contacts.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/search_contacts_result.php
 delete mode 100755 apps/maarch_entreprise/indexing_searching/update_process_date.php
 delete mode 100755 apps/maarch_entreprise/js/usergroups_management.js
 delete mode 100755 apps/maarch_entreprise/my_contacts/create_address_iframe.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/create_contact_iframe.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/getContacts.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/info_contact_iframe.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/my_contact_add.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/my_contact_del.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/my_contact_up.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/my_contact_up_db.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/my_contacts.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/purpose_check.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/put_in_session.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/setContactType.php
 delete mode 100755 apps/maarch_entreprise/my_contacts/update_address_iframe.php
 delete mode 100755 apps/maarch_entreprise/xml/menu.xml
 delete mode 100755 modules/templates/js/functions.js

diff --git a/apps/maarch_entreprise/admin/contacts/ajaxDeleteContact.php b/apps/maarch_entreprise/admin/contacts/ajaxDeleteContact.php
deleted file mode 100755
index 6851d457903..00000000000
--- a/apps/maarch_entreprise/admin/contacts/ajaxDeleteContact.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-require_once('core/class/class_core_tools.php');
-$Core_Tools = new core_tools;
-$Core_Tools->load_lang();
-$db = new Database();
-$return = '';
-$status = 0;
-if (isset($_REQUEST['contactId'])) {
-    $deleteContactQuery = "DELETE FROM contacts_v2 WHERE contact_id = ? ";
-    if ($_REQUEST['replacedContactId'] == '') {
-        $status = 1;
-    } elseif ($_REQUEST['replacedAddressId'] == '') {
-        $status = 1;
-    } elseif (
-        $_REQUEST['replacedContactId'] <> 'false' 
-        && $_REQUEST['replacedContactId'] <> ''
-        && $_REQUEST['replacedAddressId'] <> 'false' 
-        && $_REQUEST['replacedAddressId'] <> ''
-    ) {
-        $replaceQueryExpContact = "UPDATE res_letterbox SET exp_contact_id = ?, address_id = ? WHERE exp_contact_id = ?";
-        $db->query($replaceQueryExpContact, array($_REQUEST['replacedContactId'], $_REQUEST['replacedAddressId'], $_REQUEST['contactId']));
-        $replaceQueryDestContact = "UPDATE res_letterbox SET dest_contact_id = ?, address_id = ? WHERE dest_contact_id = ?";
-        $db->query($replaceQueryDestContact, array($_REQUEST['replacedContactId'], $_REQUEST['replacedAddressId'], $_REQUEST['contactId']));
-        $db->query("UPDATE contacts_res SET contact_id = ?, address_id = ? WHERE contact_id = ?",
-            array($_REQUEST['replacedContactId'], $_REQUEST['replacedAddressId'], $_REQUEST['contactId']));
-    }
-    
-    if ($status == 0) {
-        $db->query($deleteContactQuery, array($_REQUEST['contactId']));
-        $db->query("DELETE FROM contact_addresses WHERE contact_id = ?", array($_REQUEST['contactId']));
-    }
-}
-
-echo "{status : " . $status . ", toShow : '" . addslashes($return) . "'}";
-exit ();
diff --git a/apps/maarch_entreprise/admin/contacts/ajaxLoadDocList.php b/apps/maarch_entreprise/admin/contacts/ajaxLoadDocList.php
deleted file mode 100755
index 165ab1eaf58..00000000000
--- a/apps/maarch_entreprise/admin/contacts/ajaxLoadDocList.php
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-
-require_once('core/class/class_core_tools.php');
-$Core_Tools = new core_tools;
-$Core_Tools->load_lang();
-
-$return = '';
-
-if (isset($_REQUEST['contact_id'])) {
-
-    $status = 0;
-    $return .= '<td colspan="8" style="background-color: #FFF;">';
-        $return .= '<div align="center" width="100%">';
-            $return .= '<table width="100%" style="background-color: rgba(100, 200, 213, 0.2);">';
-                $return .= '<tr style="font-weight: bold;">';
-                    $return .= '<th style="font-weight: bold; color: black;">&nbsp;</th>';
-                    $return .= '<th style="font-weight: bold; color: black;">';
-                        $return .= _STATUS;
-                    $return .= '</th>';
-                    $return .= '<th style="font-weight: bold; color: black;">';
-                        $return .= _DATE;
-                    $return .= '</th>';
-                    $return .= '<th style="font-weight: bold; color: black;">';
-                        $return .= _SUBJECT;
-                    $return .= '</th>';
-                    $return .= '<th style="font-weight: bold; color: black;">';
-                        $return .= _DEPARTMENT_DEST;
-                    $return .= '</th>';
-                    $return .= '<th style="font-weight: bold; color: black;">';
-                        $return .= _DOCTYPE;
-                    $return .= '</th>';
-                    $return .= '<th style="font-weight: bold; color: black;">';
-                        $return .= _ID;
-                    $return .= '</th>';
-                    $return .= '<th style="font-weight: bold; color: black;">&nbsp;</th>';
-                $return .= '</tr>';
-
-
-                $db = new Database();
-
-                $query = "SELECT * FROM res_view_letterbox WHERE (exp_contact_id = ? or dest_contact_id = ?) and status <> 'DEL'";
-
-                $stmt = $db->query($query, array($_REQUEST['contact_id'], $_REQUEST['contact_id']));
-                $cptDocs = 0;
-                while ($return_db = $stmt->fetchObject()) {
-                    if ($cptDocs < 10) {
-                    $return .= '<tr style="border: 1px solid;" style="background-color: #FFF;">';
-                        $return .= '<td>';
-                            $return .= '&nbsp;&nbsp;';
-                            $return .= '<a ';
-                            $return .= 'href="';
-                               $return .= 'index.php?'
-                                . 'dir=indexing_searching'
-                                . '&page=details'
-                                . '&collid=letterbox_coll&id=' 
-                                . $return_db->res_id;
-                            $return .= '" ';
-                            $return .= 'target="_blank" ';
-                            $return .= '>';
-                                $return .= '<i class="fa fa-info-circle fa-2x" title="'._DETAILS.'"></i>';
-                            $return .= '</a>';
-                        $return .= '</td>';
-                        $return .= '<td>';
-                            $return .= '&nbsp;&nbsp;';
-
-                            $query = "SELECT label_status FROM status " 
-                                . "WHERE id = ?";
-                            $stmt2 = $db->query($query, array($return_db->status));
-                            while ($status_db = $stmt2->fetchObject()) {
-                                $return .= $status_db->label_status;
-                            }
-                        $return .= '</td>';
-                        $return .= '<td>';
-                            $return .= '&nbsp;&nbsp;';
-                            $return .= functions::format_date_db($return_db->creation_date);
-                        $return .= '</td>';
-                        $return .= '<td>';
-                            $return .= '&nbsp;&nbsp;';
-                            $return .= functions::cut_string($return_db->subject, 40);
-                        $return .= '</td>';
-                        $return .= '<td>';
-                            $return .= '&nbsp;&nbsp;';
-                            $return .= functions::xssafe($return_db->entity_label);
-                        $return .= '</td>';
-                        $return .= '<td>';
-                            $return .= '&nbsp;&nbsp;';
-                            $return .= functions::xssafe($return_db->type_label);
-                        $return .= '</td>';
-                        $return .= '<td>';
-                            $return .= '&nbsp;&nbsp;';
-                            $return .= functions::xssafe($return_db->res_id);
-                        $return .= '</td>';
-                        $return .= '<td>';
-                            $return .= '&nbsp;&nbsp;';
-                            $return .= '<a ';
-                            $return .= 'href="';
-                              $return .= 'index.php?display=true'
-                                . '&dir=indexing_searching'
-                                . '&page=view_resource_controler'
-                                . '&collid=letterbox_coll&id=' 
-                                . $return_db->res_id;
-                            $return .= '" ';
-                            $return .= 'target="_blank" ';
-                            $return .= '>';
-                                $return .= '<i class="fa fa-download fa-2x" title="'._VIEW_DOC.'"></i>';
-                            $return .= '</a>';
-                        $return .= '</td>';
-                    $return .= '</tr>';
-                    } else {
-                        $return .= '<tr><td>...<tr></td>';
-                        break;
-                    }
-                    $cptDocs++;
-                }
-
-            $return .= '</table>';
-            $return .= '<br />';
-        $return .= '</div>';
-    $return .= '</td>';
-} else {
-    $status = 1;
-    $return .= '<td colspan="8" style="background-color: red;">';
-        $return .= '<p style="padding: 10px; color: black;">';
-            $return .= 'Error loading documents';
-        $return .= '</p>';
-    $return .= '</td>';
-}
-
-
-//usleep(900000);
-
-echo "{status : " . $status . ", toShow : '" . addslashes($return) . "'}";
-exit ();
diff --git a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses.php b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses.php
deleted file mode 100755
index 79b50829c43..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses.php
+++ /dev/null
@@ -1,353 +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   contact_addresses
-* @author  dev <dev@maarch.org>
-* @ingroup apps
-*/
-
-// GESTION DES ADDRESSES
-echo '<h2><i class="fa fa-home fa-2x"></i> &nbsp;'; 
-
-if ($mode <> 'view') { 
-    echo _MANAGE_CONTACT_ADDRESSES_IMG;
-} else {
-    echo _CONTACT_ADDRESSES_ASSOCIATED;
-} 
-echo '</h2>';
-
-require_once "core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR
-    . "class_request.php";
-require_once "apps" . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-    . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR
-    . "class_list_show.php";
-$func = new functions();
-
-if (isset($_REQUEST['fromMyContactsList']) || isset($_REQUEST['fromSearchContactsList'])) {
-    $_REQUEST['what']        = "";
-    $_REQUEST['order']       = "";
-    $_REQUEST['order_field'] = "";
-}
-
-$select[$_SESSION['tablename']['contact_addresses']] = array();
-array_push(
-    $select[$_SESSION['tablename']['contact_addresses']],
-    "id", "contact_id", "contact_purpose_id", "departement", "lastname", "firstname", "function", "is_private","address_num", "address_street", "address_postal_code", "address_town", "phone", "email"
-);
-$what = "";
-$where = "contact_id = ? ";
-$arrayPDO = array($_SESSION['contact']['current_contact_id']);
-if (isset($_REQUEST['what']) && ! empty($_REQUEST['what'])) {
-    $what = $_REQUEST['what'];
-    $where .= " and lower(lastname) like lower(?)";
-    $arrayPDO = array_merge($arrayPDO, array($what. '%'));
-}
-
-$list = new list_show();
-$order = 'asc';
-if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
-    $order = trim($_REQUEST['order']);
-}
-$field = 'lastname';
-if (isset($_REQUEST['order_field']) && ! empty($_REQUEST['order_field'])) {
-    $field = trim($_REQUEST['order_field']);
-}
-
-$orderstr = $list->define_order($order, $field);
-
-$request = new request;
-$tab = $request->PDOselect(
-    $select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype']
-);
-if (!empty($tab)) {
-    for ($i = 0; $i < count($tab); $i ++) {
-        for ($j = 0; $j < count($tab[$i]); $j ++) {
-            foreach (array_keys($tab[$i][$j]) as $value) {
-                if ($tab[$i][$j][$value] == "id") {
-                    $tab[$i][$j]["id"]          = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       = _ID;
-                    $tab[$i][$j]["size"]        = "30";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"]       = "left";
-                    $tab[$i][$j]["valign"]      = "bottom";
-                    $tab[$i][$j]["show"]        = false;
-                    $tab[$i][$j]["order"]       = 'id';
-                }
-                if ($tab[$i][$j][$value] == "contact_id") {
-                    $tab[$i][$j]["contact_id"]  = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       = _CONTACT_ID;
-                    $tab[$i][$j]["size"]        = "30";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"]       = "left";
-                    $tab[$i][$j]["valign"]      = "bottom";
-                    $tab[$i][$j]["show"]        = false;
-                    $tab[$i][$j]["order"]       = 'contact_id';
-                }
-                if ($tab[$i][$j][$value] == "contact_purpose_id") {
-                    $tab[$i][$j]["value"]              = $contact->get_label_contact($tab[$i][$j]['value'], $_SESSION['tablename']['contact_purposes']);
-                    $tab[$i][$j]["contact_purpose_id"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]              = _CONTACT_PURPOSE;
-                    $tab[$i][$j]["size"]               = "20";
-                    $tab[$i][$j]["label_align"]        = "left";
-                    $tab[$i][$j]["align"]              = "left";
-                    $tab[$i][$j]["valign"]             = "bottom";
-                    $tab[$i][$j]["show"]               = true;
-                    $tab[$i][$j]["order"]              = 'contact_purpose_id';
-                }
-                if ($tab[$i][$j][$value] == "departement") {
-                    $tab[$i][$j]['value'] = $request->show_string(
-                        $tab[$i][$j]['value']
-                    );
-                    $tab[$i][$j]["departement"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       = _SERVICE;
-                    $tab[$i][$j]["size"]        = "20";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"]       = "left";
-                    $tab[$i][$j]["valign"]      = "bottom";
-                    $tab[$i][$j]["show"]        = true;
-                    $tab[$i][$j]["order"]       = 'departement';
-                }
-                if ($tab[$i][$j][$value]=="lastname") {
-
-                    $tab[$i][$j]['value']       =$request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["lastname"]    =$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       =_LASTNAME;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="left";
-                    $tab[$i][$j]["align"]       ="left";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=true;
-                    } else {
-                        $tab[$i][$j]["show"]=false;
-                    }
-                    $tab[$i][$j]["order"] = "lastname";
-                }
-                if ($tab[$i][$j][$value]=="firstname") {
-
-                    $tab[$i][$j]["firstname"]   = $request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["label"]       =_FIRSTNAME;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="left";
-                    $tab[$i][$j]["align"]       ="left";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=true;
-                    } else {
-                        $tab[$i][$j]["show"]=false;
-                    }
-                    $tab[$i][$j]["order"]= "firstname";
-                }
-                if ($tab[$i][$j][$value]=="function") {
-
-                    $tab[$i][$j]['value']       =$request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["function"]    =$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       =_FUNCTION;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="left";
-                    $tab[$i][$j]["align"]       ="left";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=true;
-                    } else {
-                        $tab[$i][$j]["show"]=false;
-                    }
-                    $tab[$i][$j]["order"]= "function";
-                }
-                if ($tab[$i][$j][$value]=="is_private") {
-
-                    $is_private = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["show"]=false;
-                }
-                if ($tab[$i][$j][$value]=="address_num") {
-
-                    $address_num = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["show"]=false;
-                }
-                if ($tab[$i][$j][$value]=="address_street") {
-                    
-                    if ($is_private == "Y") {
-                        $tab[$i][$j]['value'] = "Confidentielle";
-                    } else {
-                        $tab[$i][$j]['value'] = $address_num . " " . $request->show_string($tab[$i][$j]['value']);
-                    }
-
-                    $tab[$i][$j]["address_street"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]          = _ADDRESS;
-                    $tab[$i][$j]["size"]           ="15";
-                    $tab[$i][$j]["label_align"]    ="left";
-                    $tab[$i][$j]["align"]          ="left";
-                    $tab[$i][$j]["valign"]         ="bottom";
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=false;
-                    } else {
-                        $tab[$i][$j]["show"]=true;
-                    }
-                    $tab[$i][$j]["order"]= "address_street";
-                }
-                if ($tab[$i][$j][$value]=="address_postal_code") {
-                    if ($is_private == "Y") {
-                        $tab[$i][$j]['value'] = "Confidentiel";
-                    } else {
-                        $tab[$i][$j]['value']=$request->show_string($tab[$i][$j]['value']);
-                    }
-                    $tab[$i][$j]["address_postal_code"] =$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]               =_POSTAL_CODE;
-                    $tab[$i][$j]["size"]                ="15";
-                    $tab[$i][$j]["label_align"]         ="left";
-                    $tab[$i][$j]["align"]               ="left";
-                    $tab[$i][$j]["valign"]              ="bottom";
-
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=false;
-                    } else {
-                        $tab[$i][$j]["show"]=true;
-                    }
-                    $tab[$i][$j]["order"]= "address_postal_code";
-                }
-                if ($tab[$i][$j][$value]=="address_town") {
-
-                    if ($is_private == "Y") {
-                        $tab[$i][$j]['value'] = "Confidentielle";
-                    }
-                    $tab[$i][$j]["address_town"] = $request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["label"]        =_TOWN;
-                    $tab[$i][$j]["size"]         ="15";
-                    $tab[$i][$j]["label_align"]  ="left";
-                    $tab[$i][$j]["align"]        ="left";
-                    $tab[$i][$j]["valign"]       ="bottom";
-                    $tab[$i][$j]["show"]         =true;
-                    $tab[$i][$j]["order"]        = "address_town";
-                }
-                if ($tab[$i][$j][$value]=="phone") {
-                    if ($is_private == "Y") {
-                        $tab[$i][$j]['value'] = "Confidentiel";
-                    } else {
-                        $tab[$i][$j]['value']=$request->show_string($tab[$i][$j]['value']);
-                    }
-                    $tab[$i][$j]["phone"]       =$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       =_PHONE;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="left";
-                    $tab[$i][$j]["align"]       ="left";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    $tab[$i][$j]["show"]        =true;
-                    $tab[$i][$j]["order"]       = "phone";
-                }
-                if ($tab[$i][$j][$value]=="email") {
-                    if ($is_private == "Y") {
-                        $tab[$i][$j]['value'] = "Confidentiel";
-                    }
-                    $tab[$i][$j]["email"]       = $request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["label"]       =_MAIL;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="center";
-                    $tab[$i][$j]["align"]       ="center";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    $tab[$i][$j]["show"]        =true;
-                    $tab[$i][$j]["order"]       = "email";
-                }
-            }
-        }
-    }
-}
-
-//List parameters
-$paramsTab = array();
-$paramsTab['bool_modeReturn'] = false;                                              //Desactivation du mode return (vs echo)
-$paramsTab['pageTitle'] =  '';                                                      //Titre de la page
-$paramsTab['listCss'] =  'listing largerList spec';
-if ($mode == "view") {
-    $paramsTab['urlParameters'] = '&dir=indexing_searching&letters&display=true'; 
-} else {
-    $paramsTab['urlParameters'] = '&dir=my_contacts&letters&display=true&seeAllAddresses';          //parametre d'url supplementaire        
-}
-
-$paramsTab['bool_sortColumn']      = true;                                          //Affichage Tri
-$paramsTab['bool_showSearchTools'] = false;                                         //Affiche le filtre alphabetique
-$paramsTab['bool_showSearchBox']   = false;                                         //Affiche le champ de recherche
-
-$paramsTab['searchBoxAutoCompletionUrl'] = $_SESSION['config']['businessappurl']
-    ."index.php?display=true&page=contact_addresses_list_by_name&idContact=".$_SESSION['contact']['current_contact_id'];   //Script pour l'autocompletion
-$paramsTab['searchBoxAutoCompletionMinChars'] = 2;                                  //Nombre minimum de caractere pour activer l'autocompletion (1 par defaut)
-if ($mode <> 'view' && $_SESSION['user']['services']['my_contacts']) {
-    $paramsTab['bool_showAddButton'] = true;                                            //Affichage du bouton Nouveau
-}
-$paramsTab['addButtonLabel'] = _NEW_CONTACT_ADDRESS;                                //Libellé du bouton Nouveau
-if ($from_iframe) {
-    $paramsTab['addButtonScript'] = "window.location='".$_SESSION['config']['businessappurl']
-        ."index.php?display=false&dir=my_contacts&page=create_address_iframe&iframe=fromContactIframe'";
-} else {
-    if ($mode <> 'view') {
-        $paramsTab['addButtonScript'] = "window.top.location='".$_SESSION['config']['businessappurl']
-            ."index.php?page=contact_addresses_add&mycontact=Y'";                       //Action sur le bouton nouveau (2)            
-    }
-}
-
-//Action icons array
-$paramsTab['actionIcons'] = array();
-//get start
-$start = $list2->getStart();
-if ($mode <> 'view') {
-    if ($from_iframe) {
-        $update = array(
-            "script"        => "window.location='".$_SESSION['config']['businessappurl']
-                                    ."index.php?display=false&dir=my_contacts&page=update_address_iframe&id=@@id@@&fromContactIframe'",
-            "class"         =>  "change",
-            "label"         =>  _MODIFY,
-            "tooltip"       =>  _MODIFY
-        );
-    } else {
-        $update = array(
-            "script"        => "window.top.location='".$_SESSION['config']['businessappurl']
-                                    ."index.php?page=contact_addresses_up&mycontact=Y&id=@@id@@&what=".$what."&start=".$start."'",
-            "class"         =>  "change",
-            "label"         =>  _MODIFY,
-            "tooltip"       =>  _MODIFY
-        );
-    }
-
-    array_push($paramsTab['actionIcons'], $update); 
-
-    if ($from_iframe) {
-        if ($_SESSION['AttachmentContact'] == "1") {
-            $infoContactDiv = "info_contact_div_attach";
-        } else {
-            $infoContactDiv = "show_tab";
-        }
-        $use = array(
-            "script"        => "set_new_contact_address('".$_SESSION['config']['businessappurl'] . "index.php?display=false&dir=my_contacts&page=get_last_contact_address&contactid=".$_SESSION['contact']['current_contact_id']."&addressid=@@id@@', '".$infoContactDiv."', 'true');simpleAjax('".$_SESSION['config']['businessappurl']."index.php?display=true&page=unsetAttachmentContact');",
-            "class"         =>  "use",
-            "label"         =>  _USE,
-            "tooltip"       =>  _USE
-        );
-        array_push($paramsTab['actionIcons'], $use);
-    } else {
-        $delete = array(
-            "href"          => $_SESSION['config']['businessappurl']
-                                ."index.php?page=contact_addresses_del&mycontact=Y&what=".$what."&start=".$start,
-            "class"         =>  "delete",
-            "label"         =>  _DELETE,
-            "tooltip"       =>  _DELETE,
-            "alertText"     =>  _REALLY_DELETE.": @@lastname@@ @@firstname@@ ?"
-        );
-        array_push($paramsTab['actionIcons'], $delete);
-    }
-} else {
-    $view = array(
-        "script"        => "window.top.location='".$_SESSION['config']['businessappurl']
-                                ."index.php?dir=indexing_searching&page=contact_address_view&addressid=@@id@@&what=".$what."&start=".$start."'",
-        "class"         =>  "view",
-        "label"         =>  _VIEW,
-        "tooltip"       =>  _VIEW
-    );
-    array_push($paramsTab['actionIcons'], $view);
-}
-
-//Afficher la liste
-echo '<br/>';
-$list2->showList($tab, $paramsTab, 'id');
-    
\ No newline at end of file
diff --git a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_add.php b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_add.php
deleted file mode 100755
index e9321407238..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_add.php
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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  Add contact form
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools2 = new core_tools();
-$core_tools2->load_lang();
-$return = $core_tools2->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $core_tools2->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $return = $core_tools2->test_admin('my_contacts', 'apps', false);
-}
-if (!$return) {
-    $return = $core_tools2->test_admin('my_contacts_menu', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN;
-    ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php';</script>
-    <?php
-    exit();
-}
-
-/****************Management of the location bar  ************/
-$init = false;
-if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-{
-    $init = true;
-}
-$level = "";
-if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-{
-    $level = $_REQUEST['level'];
-}
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=contact_addresses_add';
-$page_label = _ADDITION_ADDRESS;
-$page_id = "contact_addresses_add";
-$core_tools2->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$contact = new contacts_v2();
-
-if(isset($_GET['mycontact']) && $_GET['mycontact'] <> ''){
-	$admin = false;
-} else {
-	$admin = true;
-}
-?>
-<br>
-<div class="block">
-<?php
-    $contact->formaddress("add", "", $admin);
-?>
-</div>
diff --git a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_del.php b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_del.php
deleted file mode 100755
index b4524dfedf7..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_del.php
+++ /dev/null
@@ -1,178 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 Delete a structure
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-$contact = new contacts_v2();
-$core_tools = new core_tools('');
-$return = $core_tools->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $core_tools->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $return = $core_tools->test_admin('my_contacts', 'apps', false);
-}
-if (!$return) {
-    $return = $core_tools->test_admin('my_contacts_menu', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN; ?>
-<script type="text/javascript">
-	window.top.location.href = '<?php echo $_SESSION['config']['businessappurl']; ?>index.php';
-</script>
-<?php
-    exit();
-}
-$core_tools->load_lang();
-$db = new Database();
-
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") {
-    $init = true;
-}
-$level = "";
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2
-    || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4
-    || $_REQUEST['level'] == 1)
-) {
-    $level = $_REQUEST['level'];
-}
-$pagePath = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_del';
-$pageLabel = _ADDRESS_DEL;
-$pageId = "contact_addresses_del";
-$core_tools->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-/***********************************************************/
-
-if (isset($_GET['id'])) {
-    $id = addslashes(functions::wash($_GET['id'], "no", _THE_CONTACT_ADDRESS));
-} else {
-    $id = "";
-}
-
-if (isset($_GET['mycontact']) && $_GET['mycontact'] <> '') {
-    $admin = false;
-} else {
-    $admin = true;
-}
-
-if ($_REQUEST['valid']) {
-    $id = $_POST['id'];
-
-    if ($_POST['new'] && $_POST['new_contact_id']) {
-        $newid = $_POST['new'];
-        $new_contact_id = $_POST['new_contact_id'];
-
-        // delete contact types
-        $db->query("DELETE FROM ".$_SESSION['tablename']['contact_addresses']." WHERE id = ?", array($id));
-
-        $stmt = $db->query("SELECT res_id, exp_contact_id, dest_contact_id FROM res_letterbox WHERE address_id = ?", array($id));
-
-        while ($res = $stmt->fetchObject()) {
-            if ($res->exp_contact_id <> "") {
-                $db->query("UPDATE res_letterbox SET exp_contact_id = ? WHERE res_id = ?", array($new_contact_id, $res->res_id));
-            } else {
-                $db->query("UPDATE res_letterbox SET dest_contact_id = ? WHERE res_id = ?", array($new_contact_id, $res->res_id));
-            }
-        }
-
-        $db->query("UPDATE res_letterbox SET address_id = ? WHERE address_id = ?", array($newid, $id));
-        $db->query("UPDATE contacts_res SET contact_id = ?, address_id = ? WHERE address_id = ?", array($new_contact_id, $newid, $id));
-        $db->query("UPDATE resource_contacts SET item_id = ? WHERE item_id = ?", array($newid, $id));
-
-        if ($_SESSION['history']['contact_addresses_del'] == "true") {
-            require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php");
-            $users = new history();
-            $users->add($_SESSION['tablename']['contact_addresses'], $id, "DEL", 'contact_addresses_del', _ADDRESS_DEL." ".strtolower(_NUM).$id."", $_SESSION['config']['databasetype']);
-        }
-        $_SESSION['info'] = _DELETED_ADDRESS;
-        unset($_SESSION['m_admin']); ?>
-<script type="text/javascript">
-	window.location.href = "<?php echo $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_up&order='.$_REQUEST['order'].'&order_field='.$_REQUEST['order_field'].'&start='.$_REQUEST['start'].'&what='.$_REQUEST['what']; ?>";
-</script>
-<?php
-    } elseif (!$_POST['new_contact_id']) {
-        $_SESSION['error'] = _NEW_CONTACT.' '._IS_EMPTY.". ". _USE_AUTOCOMPLETION;
-        $contact->type_purpose_address_del($id, $admin, $_SESSION['tablename']['contact_addresses'], 'contact_address', _DELETED_ADDRESS, _WARNING_MESSAGE_DEL_CONTACT_ADDRESS, _ADDRESS_DEL, _CONTACT_ADDRESS_REAFFECT, _NEW_ADDRESS, _CHOOSE_CONTACT_ADDRESS, 'contacts_v2_up', 'contact_addresses_del', _CONTACT_ADDRESS);
-    } elseif (!$_POST['new']) {
-        $_SESSION['error'] = _NEW_ADDRESS.' '._IS_EMPTY.". ". _USE_AUTOCOMPLETION;
-        $contact->type_purpose_address_del($id, $admin, $_SESSION['tablename']['contact_addresses'], 'contact_address', _DELETED_ADDRESS, _WARNING_MESSAGE_DEL_CONTACT_ADDRESS, _ADDRESS_DEL, _CONTACT_ADDRESS_REAFFECT, _NEW_ADDRESS, _CHOOSE_CONTACT_ADDRESS, 'contacts_v2_up', 'contact_addresses_del', _CONTACT_ADDRESS);
-    }
-} elseif ($_REQUEST['move']) {
-    $id = $_POST['id'];
-    
-    if ($_POST['new_contact_id_reaffect']) {
-        $db->query("UPDATE contact_addresses set contact_id = ? WHERE id = ?", array($_POST['new_contact_id_reaffect'], $id));
-        $db->query("UPDATE contacts_res set contact_id = ? WHERE address_id = ?", array($_POST['new_contact_id_reaffect'], $id));
-
-        $stmt = $db->query("SELECT res_id, exp_contact_id, dest_contact_id FROM res_letterbox WHERE address_id = ?", array($id));
-
-        while ($res = $stmt->fetchObject()) {
-            if ($res->exp_contact_id <> "") {
-                $db->query("UPDATE res_letterbox SET exp_contact_id = ? WHERE res_id = ?", array($_POST['new_contact_id_reaffect'], $res->res_id));
-            } else {
-                $db->query("UPDATE res_letterbox SET dest_contact_id = ? WHERE res_id = ?", array($_POST['new_contact_id_reaffect'], $res->res_id));
-            }
-        }
-
-        if ($_SESSION['history']['contact_addresses_del'] == "true") {
-            require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php");
-            $users = new history();
-            $users->add($_SESSION['tablename']['contact_addresses'], $id, "DEL", 'contact_addresses_del', _ADDRESS_MOVED." ".strtolower(_NUM).$id."", $_SESSION['config']['databasetype']);
-        }
-        $_SESSION['info'] = _ADDRESS_MOVED.".";
-        unset($_SESSION['m_admin']); ?>
-<script type="text/javascript">
-	window.location.href = "<?php echo $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_up&order='.$_REQUEST['order'].'&order_field='.$_REQUEST['order_field'].'&start='.$_REQUEST['start'].'&what='.$_REQUEST['what']; ?>";
-</script>
-<?php
-    } else {
-        $_SESSION['error'] = _NEW_CONTACT.' '._IS_EMPTY.". ". _USE_AUTOCOMPLETION;
-        $contact->type_purpose_address_del($id, $admin, $_SESSION['tablename']['contact_addresses'], 'contact_address', _DELETED_ADDRESS, _WARNING_MESSAGE_DEL_CONTACT_ADDRESS, _ADDRESS_DEL, _CONTACT_ADDRESS_REAFFECT, _NEW_ADDRESS, _CHOOSE_CONTACT_ADDRESS, 'contacts_v2_up', 'contact_addresses_del', _CONTACT_ADDRESS);
-    }
-} elseif ($_REQUEST['delete']) {
-    $id = $_POST['id'];
-    $db->query("DELETE FROM contact_addresses WHERE id = ?", array($id));
-
-    if ($_SESSION['history']['contact_addresses_del'] == "true") {
-        require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php");
-        $users = new history();
-        $users->add($_SESSION['tablename']['contact_addresses'], $id, "DEL", 'contact_addresses_del', _ADDRESS_DEL." ".strtolower(_NUM).$id."", $_SESSION['config']['databasetype']);
-    }
-    $_SESSION['info'] = _DELETED_ADDRESS;
-    unset($_SESSION['m_admin']); ?>
-<script type="text/javascript">
-	window.location.href = "<?php echo $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_up&order='.$_REQUEST['order'].'&order_field='.$_REQUEST['order_field'].'&start='.$_REQUEST['start'].'&what='.$_REQUEST['what']; ?>";
-</script>
-<?php
-} else {
-        $contact->type_purpose_address_del($id, $admin, $_SESSION['tablename']['contact_addresses'], 'contact_address', _DELETED_ADDRESS, _WARNING_MESSAGE_DEL_CONTACT_ADDRESS, _ADDRESS_DEL, _CONTACT_ADDRESS_REAFFECT, _NEW_ADDRESS, _CHOOSE_CONTACT_ADDRESS, 'contacts_v2_up', 'contact_addresses_del', _CONTACT_ADDRESS);
-    }
diff --git a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_list_by_name.php b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_list_by_name.php
deleted file mode 100755
index d42d8e194d3..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_list_by_name.php
+++ /dev/null
@@ -1,118 +0,0 @@
-<?php
-/*
-*    Copyright 2014 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 List of structures for autocompletion
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
-require_once("apps".DIRECTORY_SEPARATOR."maarch_entreprise".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-$contact = new contacts_v2();
-$db = new Database();
-
-$query = "SELECT ca.id, ca.lastname as tag, ca.firstname, ca.contact_purpose_id, cp.label, ca.address_num, ca.address_street, ca.address_complement
-			FROM ".$_SESSION['tablename']['contact_addresses']." ca
-			LEFT JOIN contact_purposes cp on ca.contact_purpose_id = cp.id	
-			WHERE (lower(lastname) like lower(?)
-			or lower(firstname) like lower(?)
-			or lower(address_town) like lower(?)
-			or lower(label) like lower(?))";
-	$arrayPDO = array('%'.$_REQUEST['what'].'%', '%'.$_REQUEST['what'].'%', '%'.$_REQUEST['what'].'%', '%'.$_REQUEST['what'].'%');
-if(isset($_GET['id']) &&  $_GET['id'] <> ''){
-	$query .= ' and ca.id <> ? and contact_id = ?';
-	$arrayPDO = array_merge($arrayPDO, array($_GET['id'], $_SESSION['contact']['current_contact_id']));
-} else if (isset($_REQUEST['idContact']) &&  $_REQUEST['idContact'] <> ''){
-	$query .= ' and contact_id = ?';
-	$arrayPDO = array_merge($arrayPDO, array($_REQUEST['idContact']));
-} else if (isset($_REQUEST['reaffectAddress']) &&  $_REQUEST['reaffectAddress'] <> ''){
-	$query .= ' and contact_id = ? and ca.id <> ?';
-	$arrayPDO = array_merge($arrayPDO, array($_REQUEST['reaffectAddress'], $_SESSION['contact']['current_address_id']));
-}
-
-$query .= " order by lastname";
-$stmt = $db->query($query, $arrayPDO);
-$listArray = array();
-while($line = $stmt->fetchObject())
-{
-	$listArray[$line->id]['label'] = $contact->get_label_contact($line->contact_purpose_id, $_SESSION['tablename']['contact_purposes']);	
-	$adr = $line->address_num." ".$line->address_street." ".$line->address_complement;
-	$listArray[$line->id]['address'] = $adr;
-
-	if ($line->tag <> "" || $line->firstname) {
-		$listArray[$line->id]['label'] .= " :";
-		if ($line->tag <> "") {
-			$listArray[$line->id]['label'] .= " " . $line->tag;
-		}
-		if ($line->firstname <> "") {
-			$listArray[$line->id]['label'] .= " " . $line->firstname;
-		}
-	}
-}
-
-$query = "SELECT ca.id, c.lastname as tag, c.firstname, ca.contact_purpose_id, cp.label 
-			FROM ".$_SESSION['tablename']['contact_addresses']." ca
-			LEFT JOIN contact_purposes cp on ca.contact_purpose_id = cp.id LEFT JOIN contacts_v2 c on c.contact_id = ca.contact_id 
-			WHERE (lower(c.lastname) like lower(?)
-			or lower(c.firstname) like lower(?)
-			or lower(address_town) like lower(?)
-			or lower(label) like lower(?))";
-	$arrayPDO = array('%'.$_REQUEST['what'].'%', '%'.$_REQUEST['what'].'%', '%'.$_REQUEST['what'].'%', '%'.$_REQUEST['what'].'%');
-
-$query .= " order by c.lastname";
-$stmt = $db->query($query, $arrayPDO);
-
-while($line = $stmt->fetchObject())
-{
-	$listArray[$line->id]['label'] = $contact->get_label_contact($line->contact_purpose_id, $_SESSION['tablename']['contact_purposes']);
-	
-	if ($line->tag <> "" || $line->firstname) {
-		$listArray[$line->id]['label'] .= " :";
-		if ($line->tag <> "") {
-			$listArray[$line->id]['label'] .= " " . $line->tag;
-		}
-		if ($line->firstname <> "") {
-			$listArray[$line->id]['label'] .= " " . $line->firstname;
-		}
-	}
-
-}
-echo "<ul>\n";
-$authViewList = 0;
-
-foreach($listArray as $key => $what)
-{
-	if($authViewList >= 10)
-	{
-		$flagAuthView = true;
-	}
-    echo "<li id=".functions::xssafe($key).">".$what['address']."\n";
-	echo "<div style='font-size:11px;font-style:italic;'>".functions::xssafe($what['label'])."</div></li>";
-	if($flagAuthView)
-	{
-		echo "<li id=".functions::xssafe($key).">...</li>\n";
-		break;
-	}
-	$authViewList++;
-}
-echo "</ul>";
diff --git a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_status.php b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_status.php
deleted file mode 100755
index f18ed19b47e..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_status.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/*
-*    Copyright 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  Enabled/disable a contact address in the database
-*
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-$return = $core_tools->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $core_tools->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN;
-    ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php';</script>
-    <?php
-    exit();
-}
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$contact = new contacts_v2();
-
-if ($_GET['mode'] == "ban") {
-	$contact->addressEnabled($_GET['id'], "N");
-} else if ($_GET['mode'] == "allow") {
-	$contact->addressEnabled($_GET['id'], "Y");
-}
-
-?>
-
-<script>
-	window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=contacts_v2_up&id=<?php functions::xecho($_SESSION['contact']['current_contact_id']);?>';
-</script>
-
-<?php
-
-exit();
\ No newline at end of file
diff --git a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up.php b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up.php
deleted file mode 100755
index c357598cdf5..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up.php
+++ /dev/null
@@ -1,140 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 Modify a structure
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-
-$return = $core_tools->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $core_tools->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $return = $core_tools->test_admin('my_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $return = $core_tools->test_admin('search_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $return = $core_tools->test_admin('my_contacts_menu', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN;
-    ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php';</script>
-    <?php
-    exit();
-}
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-require_once "core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_request.php";
-
-$func = new functions();
-
-if(isset($_GET['id']))
-{
-    $id = addslashes($func->wash($_GET['id'], "alphanum", _CONTACT));
-}
-else
-{
-    $id = "";
-}
- /****************Management of the location bar  ************/
-$init = false;
-if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-{
-    $init = true;
-}
-$level = "";
-if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-{
-    $level = $_REQUEST['level'];
-}
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=contact_addresses_up';
-$page_label = _MODIFICATION;
-$page_id = "contact_addresses_up";
-$core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-
-if(isset($_GET['mycontact']) && $_GET['mycontact'] <> ''){
-	$admin = false;
-} else {
-	$admin = true;
-}
-
-$contact = new contacts_v2();
-$request = new request;
-$db = new Database();
-
-if (isset($_REQUEST['fromContactAddressesList']) || isset($_REQUEST['fromSearchContacts'])) {
-    $query = "SELECT contact_id FROM contact_addresses WHERE id = ?";
-    $stmt = $db->query($query, array($id));
-    $result = $stmt->fetchObject();
-    $stmt = $db->query("SELECT * FROM contacts_v2 WHERE contact_id = ?", array($result->contact_id));
-
-    $_SESSION['m_admin']['contact'] = array();
-    $line = $stmt->fetchObject();
-    $_SESSION['m_admin']['contact']['ID'] = $line->contact_id;
-    $_SESSION['m_admin']['contact']['TITLE'] = $request->show_string($line->title);
-    $_SESSION['m_admin']['contact']['LASTNAME'] = $request->show_string($line->lastname);
-    $_SESSION['m_admin']['contact']['FIRSTNAME'] = $request->show_string($line->firstname);
-    $_SESSION['m_admin']['contact']['SOCIETY'] = $request->show_string($line->society);
-    $_SESSION['m_admin']['contact']['SOCIETY_SHORT'] = $request->show_string($line->society_short);
-    $_SESSION['m_admin']['contact']['FUNCTION'] = $request->show_string($line->function);
-    $_SESSION['m_admin']['contact']['OTHER_DATA'] = $request->show_string($line->other_data);
-    $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = $request->show_string($line->is_corporate_person);
-    $_SESSION['m_admin']['contact']['CONTACT_TYPE'] = $line->contact_type;
-    $_SESSION['m_admin']['contact']['OWNER'] = $line->user_id;
-    if($admin && !empty($_SESSION['m_admin']['contact']['OWNER']))
-    {
-        $stmt = $db->query("SELECT lastname, firstname FROM ".$_SESSION['tablename']['users']." WHERE user_id = ?", array($_SESSION['m_admin']['contact']['OWNER']));
-        $res = $stmt->fetchObject();
-        $_SESSION['m_admin']['contact']['OWNER'] = $res->lastname.', '.$res->firstname.' ('.$_SESSION['m_admin']['contact']['OWNER'].')';
-    }
-    $_SESSION['contact_address']['fromContactAddressesList'] = "yes";
-    
-}
-
-if (isset($_REQUEST['fromSearchContacts'])) {
-    ?>
-    <script>
-        window.top.location='<?php echo $_SESSION['config']['businessappurl'] . "index.php?dir=indexing_searching&page=contact_address_view&addressid=".$id;?>';
-    </script>
-    <?php
-    exit;
-} else {
-    echo '<div class="block" style="margin-top:15px;">';
-    functions::xssafe($contact->formaddress("up",$id, $admin));
-    echo '</div>';
-}
diff --git a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up_db.php b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up_db.php
deleted file mode 100755
index d83e74b0bd3..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up_db.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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  Modify the contact in the database after the form
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-$return = $core_tools->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $core_tools->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $return = $core_tools->test_admin('my_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $return = $core_tools->test_admin('update_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $return = $core_tools->test_admin('my_contacts_menu', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN; ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl']; ?>index.php';</script>
-    <?php
-    exit();
-}
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$contact = new contacts_v2();
-$iframe = false;
-
-if (isset($_GET['mycontact']) && $_GET['mycontact'] <> '') {
-    $admin = false;
-    if ($_GET['mycontact'] == 'iframe') {
-        $iframe = 1;
-    } elseif ($_GET['mycontact'] == 'iframe_add_up') {
-        $iframe = 2;
-    } elseif ($_GET['mycontact'] == 'fromContactIframe') {
-        $iframe = 3;
-    } elseif ($_GET['mycontact'] == 'editDetail') {
-        $iframe = 4;
-    } elseif ($_GET['mycontact'] == 'editDetailSender') {
-        $iframe = 5;
-    }
-} else {
-    $admin = true;
-}
-
-if (isset($_REQUEST['fromContactAddressesList'])) {
-    $_SESSION['contact_address']['fromContactAddressesList'] = "yes";
-}
-
diff --git a/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes.php b/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes.php
deleted file mode 100755
index ca4bf3d628d..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes.php
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 Structures list
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$admin = new core_tools();
-$admin->test_admin('admin_contacts', 'apps');
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") {
-    $init = true;
-}
-$level = "";
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2
-    || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4
-    || $_REQUEST['level'] == 1)
-) {
-    $level = $_REQUEST['level'];
-}
-$pagePath = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_purposes';
-$pageLabel = _CONTACT_PURPOSES_LIST;
-$pageId = "contact_purposes";
-$admin->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-/***********************************************************/
-unset($_SESSION['m_admin']);
-require_once "core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR
-    . "class_request.php";
-require_once "apps" . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-    . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR
-    . "class_list_show.php";
-$func = new functions();
-$select[$_SESSION['tablename']['contact_purposes']] = array();
-array_push(
-    $select[$_SESSION['tablename']['contact_purposes']],
-    "id", "label"
-);
-$what = "";
-$where = "";
-$arrayPDO = array();
-if (isset($_REQUEST['what']) && ! empty($_REQUEST['what'])) {
-    $what = $_REQUEST['what'];
-    $where .= " lower(label) like lower(?)";
-    $arrayPDO = array($what. '%');
-}
-
-$list = new list_show();
-$order = 'asc';
-if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
-    $order = trim($_REQUEST['order']);
-}
-$field = 'label';
-if (isset($_REQUEST['order_field']) && ! empty($_REQUEST['order_field'])) {
-    $field = trim($_REQUEST['order_field']);
-}
-
-$orderstr = $list->define_order($order, $field);
-
-if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) {
-    $parameters .= '&start='.$_REQUEST['start'];
-} else {
-    $_REQUEST['start'] = 0;
-}
-if (isset($_REQUEST['lines'])) {
-    $limit = $_REQUEST['lines'];
-} else {
-    $limit = 'default';
-}
-$request = new request;
-$tab = $request->PDOselect(
-    $select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype'], $limit, false, '', '', '', true, false, false, $_REQUEST['start']
-);
-
-if (!empty($tab)) {
-    for ($i = 0; $i < count($tab); $i ++) {
-        for ($j = 0; $j < count($tab[$i]); $j ++) {
-            foreach (array_keys($tab[$i][$j]) as $value) {
-                if ($tab[$i][$j][$value] == "id") {
-                    $tab[$i][$j]["contact_purposes_id"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"] = _ID;
-                    $tab[$i][$j]["size"] = "30";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"] = "left";
-                    $tab[$i][$j]["valign"] = "bottom";
-                    $tab[$i][$j]["show"] = true;
-                    $tab[$i][$j]["order"] = 'contact_purposes_id';
-                }
-                if ($tab[$i][$j][$value] == "label") {
-                    $tab[$i][$j]['value'] = $request->show_string(
-                        $tab[$i][$j]['value']
-                    );
-                    $tab[$i][$j]["contact_purposes_label"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"] = _DESC_CONTACT_PURPOSES;
-                    $tab[$i][$j]["size"] = "60";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"] = "left";
-                    $tab[$i][$j]["valign"] = "bottom";
-                    $tab[$i][$j]["show"] = true;
-                    $tab[$i][$j]["order"] = 'contact_purposes_label';
-                }
-            }
-        }
-    }
-}
-$pageName = "contact_purposes";
-$pageNameUp = "contact_purposes_up";
-$pageNameAdd = "contact_purposes_up";
-$pageNameDel = "contact_purposes_del";
-$pageNameVal = "";
-$tableName = $_SESSION['tablename']['contact_purposes'];
-$pageNameBan = "";
-$addLabel = _NEW_CONTACT_PURPOSE_ADDED;
-
-$autoCompletionArray = array();
-$autoCompletionArray["list_script_url"] = $_SESSION['config']['businessappurl']
-    . "index.php?display=true&page=contact_purposes_list_by_name";
-$autoCompletionArray["number_to_begin"] = 1;
-$list->admin_list(
-    $tab, $_SESSION['save_list']['full_count'], _CONTACT_PURPOSES_LIST . ' : ' .$_SESSION['save_list']['full_count']. " " . _CONTACT_PURPOSES,
-    'contact_purposes_id"', 'contact_purposes', 'contact_purposes',
-    'contact_purposes_id', true, $pageNameUp, $pageNameVal, $pageNameBan,
-    $pageNameDel, $pageNameAdd, $addLabel, FALSE, FALSE, _ALL_CONTACT_PURPOSES,
-    _A_CONTACT_PURPOSE, 'tags', false, true, true, true,
-    "", true, $autoCompletionArray
-);
diff --git a/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_del.php b/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_del.php
deleted file mode 100755
index f2885c73fe1..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_del.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 Delete a structure
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-$contact = new contacts_v2();
-$core_tools = new core_tools('');
-$core_tools->test_admin('admin_contacts', 'apps');
-$core_tools->load_lang();
-$db = new Database();
-
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") {
-    $init = true;
-}
-$level = "";
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2
-    || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4
-    || $_REQUEST['level'] == 1)
-) {
-    $level = $_REQUEST['level'];
-}
-$pagePath = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_purposes_del';
-$pageLabel = _CONTACT_PURPOSE_DEL;
-$pageId = "contact_purposes_del";
-$core_tools->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-/***********************************************************/
-
-if(isset($_GET['id']))
-{
-	$id = addslashes(functions::wash($_GET['id'], "no", _THE_CONTACT_PURPOSE));
-}
-else
-{
-	$id = "";
-}
-
-if ($_REQUEST['valid']) {
-	$id = $_POST['id'];
-	if ($_POST['new']){
-		$newid = $_POST['new'];
-
-		// delete contact types
-		$db->query("DELETE FROM ".$_SESSION['tablename']['contact_purposes']." WHERE id = ?", array($id));
-		$db->query("UPDATE ".$_SESSION['tablename']['contact_addresses']." SET contact_purpose_id = ? WHERE contact_purpose_id = ?", array($newid, $id));
-
-		if($_SESSION['history']['contact_purposes_del'] == "true")
-		{
-			require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php");
-			$users = new history();
-			$users->add($_SESSION['tablename']['contact_purposes'], $id,"DEL",'contact_purposes_del',_CONTACT_TYPE_DEL." ".strtolower(_NUM).$id."", $_SESSION['config']['databasetype']);
-		}
-		$_SESSION['info'] = _DELETED_CONTACT_PURPOSE.".";
-		unset($_SESSION['m_admin']);
-		?>
-	        <script type="text/javascript">
-	            window.location.href="<?php echo $_SESSION['config']['businessappurl'].'index.php?page=contact_purposes&order='.functions::xssafe($_REQUEST['order']).'&order_field='.functions::xssafe($_REQUEST['order_field']).'&start='.functions::xssafe($_REQUEST['start']).'&what='.functions::xssafe($_REQUEST['what']);?>";
-	        </script>	
-	    <?php
-	} else {
-		$_SESSION['error'] = _NEW_CONTACT_PURPOSE.' '._IS_EMPTY.". ". _USE_AUTOCOMPLETION;
-		$contact->type_purpose_address_del($id, true, $_SESSION['tablename']['contact_purposes'], 'contact_purpose', _DELETED_CONTACT_PURPOSE, _WARNING_MESSAGE_DEL_CONTACT_PURPOSE, _CONTACT_PURPOSE_DEL, _CONTACT_PURPOSE_REAFFECT, _NEW_CONTACT_PURPOSE, _CHOOSE_CONTACT_PURPOSES, 'contact_purposes', 'contact_purposes_del', _CONTACT_PURPOSE);
-	}
-} else {
-	$contact->type_purpose_address_del($id, true, $_SESSION['tablename']['contact_purposes'], 'contact_purpose', _DELETED_CONTACT_PURPOSE, _WARNING_MESSAGE_DEL_CONTACT_PURPOSE, _CONTACT_PURPOSE_DEL, _CONTACT_PURPOSE_REAFFECT, _NEW_CONTACT_PURPOSE, _CHOOSE_CONTACT_PURPOSES, 'contact_purposes', 'contact_purposes_del', _CONTACT_PURPOSE);
-}
\ No newline at end of file
diff --git a/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_list_by_name.php b/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_list_by_name.php
deleted file mode 100755
index 74a5c142f6f..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_list_by_name.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 List of structures for autocompletion
-*
-*
-* @file
-* @author Laurent Giovannoni <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
-$db = new Database();
-
-$query = "SELECT id, label as tag FROM ".$_SESSION['tablename']['contact_purposes']." WHERE lower(label) like lower(?)";
-
-$arrayPDO = array('%'.$_REQUEST['what'].'%');
-
-if(isset($_GET['id']) &&  $_GET['id'] <> ''){
-	$query .= ' and id <> ?';
-	$arrayPDO = array_merge($arrayPDO, array($_GET['id']));
-}
-
-$query .= " order by label";
-$stmt = $db->query($query, $arrayPDO);
-
-$listArray = array();
-while($line = $stmt->fetchObject())
-{
-	// array_push($listArray, $line->tag);
-	$listArray[$line->id] = $line->tag;
-}
-echo "<ul>\n";
-$authViewList = 0;
-
-foreach($listArray as $key => $what)
-{
-	if($authViewList >= 10)
-	{
-		$flagAuthView = true;
-	}
-    echo "<li id=".functions::xssafe($key).">"
-    	.functions::xssafe($what)."</li>\n";
-	if($flagAuthView)
-	{
-		echo "<li id=".functions::xssafe($key).">...</li>\n";
-		break;
-	}
-	$authViewList++;
-}
-echo "</ul>";
diff --git a/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_up.php b/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_up.php
deleted file mode 100755
index a6551b9d054..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_purposes/contact_purposes_up.php
+++ /dev/null
@@ -1,352 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 Modify a structure
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-require "core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR
-    . "class_history.php";
-$core = new core_tools();
-if(!$core->test_admin('admin_contacts', 'apps', false)){
-	if(!$core->test_admin('my_contacts', 'apps', false)){
-		$core->test_admin('my_contacts_menu', 'apps');
-	}
-}
-
-$mode = "";
-if (isset($_GET['id']) && ! empty($_GET['id'])) {
-	$mode = 'up';
-	$_SESSION['m_admin']['mode'] = $mode;
-} else if (isset($_SESSION['m_admin']['mode']) && ! empty($_SESSION['m_admin']['mode'])){
-	$mode = $_SESSION['m_admin']['mode'];
-} else {
-	$_SESSION['CURRENT_ID_CONTACT_PURPOSE'] = '';
-	$_SESSION['CURRENT_DESC_CONTACT_PURPOSE'] = '';
-	if(isset($_GET['mode']) && ! empty($_GET['mode'])){
-		$mode = $_GET['mode'];
-		$_SESSION['m_admin']['mode'] = $mode;
-	}
-}
-
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") {
-    $init = true;
-}
-$level = "";
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2
-    || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4
-    || $_REQUEST['level'] == 1)
-) {
-    $level = $_REQUEST['level'];
-}
-$pagePath = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_purposes_up';
-if ($mode == "up") {
-	$pageLabel = _CONTACT_PURPOSE_MODIF;
-} else {
-	$pageLabel = _NEW_CONTACT_PURPOSE_ADDED;
-}
-$pageId = "contact_purposes_up";
-$core->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-/***********************************************************/
-
-$db = new Database();
-
-$desc = "";
-$id = "";
-
-if (isset($_GET['id']) && ! empty($_GET['id'])) {
-	$id = $_GET['id'];
-	$stmt = $db->query(
-		"SELECT label FROM "
-	    . $_SESSION['tablename']['contact_purposes']
-	    . " WHERE id = ?", array($id)
-	);
-
-	$res = $stmt->fetchObject();
-	$desc = functions::show_string($res->label);
-	$_SESSION['CURRENT_ID_CONTACT_PURPOSE'] = $id;
-	$_SESSION['CURRENT_DESC_CONTACT_PURPOSE'] = $desc;
-}
-
-$erreur = "";
-if (isset($_REQUEST['valid'])) {
-	if (isset($_REQUEST['desc_contact_purposes'])
-	    && ! empty($_REQUEST['desc_contact_purposes'])
-	) {
-		$desc = $_REQUEST['desc_contact_purposes'];
-        $desc=str_replace(';', ' ', $desc);
-        $desc=str_replace('--', '-', $desc);
-	    $desc = $core->wash(
-	        $desc, 'no', _CONTACT_PURPOSE, 'yes', 0, 255
-	    );
-	    if($_SESSION['error'] <> ''){
-	    	$_SESSION['error'] = '';
-	    	$erreur .= _CONTACT_PURPOSE .' '. MUST_BE_LESS_THAN." 255 "._CHARACTERS;
-	    }
-	} else {
-		$erreur .= _CONTACT_PURPOSE_MISSING . ".<br/>";
-	}
-
-	if (empty($erreur)) {
-		if(utf8_encode(utf8_decode($desc)) != $desc) {
-			$desc = utf8_encode($desc);
-		}
-		$stmt = $db->query(
-			"SELECT * FROM ".$_SESSION['tablename']['contact_purposes']
-		    . " WHERE lower(label) = lower(?)",
-		    array($desc)
-		);
-
-		if ($stmt->rowCount() > 0 && $mode <> 'up') {
-			$erreur .= _THIS_CONTACT_PURPOSE . ' ' . _ALREADY_EXISTS ;
-		} else {
-			if ($mode == "up") {
-				$stmt = $db->query(
-					"SELECT * FROM ".$_SESSION['tablename']['contact_purposes']
-				    . " WHERE lower(label) = lower(?) and id <> ?",
-				    array($desc, $_REQUEST['ID_contact_purposes'])
-				);	
-				if($stmt->rowCount() > 0){
-					$erreur .= _THIS_CONTACT_PURPOSE . ' ' . _ALREADY_EXISTS ;
-				} else {
-					if (isset($_REQUEST['ID_contact_purposes'])
-					    && ! empty($_REQUEST['ID_contact_purposes'])
-					) {
-						$id = $_REQUEST['ID_contact_purposes'];
-						$db->query(
-							"UPDATE " . $_SESSION['tablename']['contact_purposes']
-						    . " set label = ?"
-						    . "WHERE id = ?",
-						    array($desc, $id)
-						);
-
-						if ($_SESSION['history']['contact_purposes_up'] == "true") {
-							$hist = new history();
-							$hist->add(
-							    $_SESSION['tablename']['contact_purposes'], $id,
-							    "UP", 'contact_purposes_up', _CONTACT_PURPOSE_MODIF . " " . strtolower(_NUM)
-							    . $id,
-							    $_SESSION['config']['databasetype']
-							);
-						}
-						$_SESSION['info'] .= _CONTACT_PURPOSE_MODIF . " : " . $id;
-					} else {
-						$erreur .= _ID_CONTACT_PURPOSE_PB . ".";
-					}
-				}
-			} else {
-				$desc = $_REQUEST['desc_contact_purposes'];
-				if(utf8_encode(utf8_decode($desc)) != $desc) {
-					$desc = utf8_encode($desc);
-				}
-		        $desc=str_replace(';', ' ', $desc);
-		        $desc=str_replace('--', '-', $desc);
-				$db->query(
-					"INSERT INTO "
-				    . $_SESSION['tablename']['contact_purposes']
-				    . " ( label) VALUES (?)",
-				array($desc)
-				);
-				$stmt = $db->query(
-					"SELECT id FROM "
-				    . $_SESSION['tablename']['contact_purposes']
-				    . " WHERE label = ?",
-				    array($desc)
-				);
-				$res = $stmt->fetchObject();
-				$id = $res->id;
-
-				if ($_SESSION['history']['contact_purposes_add'] == "true") {
-					$hist = new history();
-					$hist->add(
-					    $_SESSION['tablename']['contact_purposes'], $id,
-					    "ADD", 'contact_purposes_add', _NEW_CONTACT_PURPOSE_ADDED . " (" . $desc . ")",
-					    $_SESSION['config']['databasetype']
-					);
-
-				}
-				if($mode <> 'popup'){
-					$_SESSION['info'] .= _NEW_CONTACT_PURPOSE . " : " . $desc;
-				}
-			}
-		}
-	}
-	if (empty($erreur)) {
-		if($mode == 'popup'){
-			$stmt = $db->query(
-				"SELECT id, label FROM ".$_SESSION['tablename']['contact_purposes']
-			    . " WHERE label = ?",
-			    array($desc)
-			);
-			$res = $stmt->fetchObject();
-			?>
-				<script type="text/javascript">window.opener.$("new_id").value ="<?php functions::xecho(utf8_decode($res->label));?>";window.opener.$("contact_purposes").value ='<?php functions::xecho($res->id);?>';self.close();</script> 
-			<?php
-		} else {
-			unset($_SESSION['m_admin']);
-		?>
-			<script type="text/javascript">window.location.href="<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=contact_purposes";</script> 
-		<?php
-		}
-		exit();
-	} else {
-		if($mode <> 'popup'){
-			?>
-			<div id="header">
-		        <div id="nav">
-	            <div><p id="ariane"><?php
-	            ?></p></div>
-	            <p id="gauchemenu"></p>
-	            <a href="index.php"><p id="logo"></p></a>
-	       </div>
-			</div>
-			<div id="container">
-			    <div id="content">
-			<?php
-			/****************Management of the location bar  ************/
-			$core->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-			/***********************************************************/
-		}
-	}
-}
-
-$core->load_html();
-
-if ($mode == "up") {
-	$title = _CONTACT_PURPOSE_MODIF;
-} else {
-	$title = _NEW_CONTACT_PURPOSE_ADDED;
-}
-$core->load_header($title, true, false);
-$time = $core->get_session_time_expire();
-?>
-<!-- <body onload="setTimeout(window.close, <?php echo $time;?>*60*1000);window.resizeTo(700,700);"> -->
-<br/>
-
-<div class="error">
-<?php
-functions::xecho($erreur);
-$erreur = "";
-?>
-</div>
-<h1 class="tit">
-<?php
-if ($mode == "up") {
-	?><i class="fa fa-edit fa-2x"></i> <?php
-    echo _CONTACT_PURPOSE_MODIF;
-} else {
-	?><i class="fa fa-plus fa-2x"></i> <?php
-    echo _NEW_CONTACT_PURPOSE_ADDED;
-}
-?></h1>
-<div class="block">
-<br/>
-
-<br/>
-<form method="post" name="frmcontact_purposes" id="frmcontact_purposes" class="forms" action="<?php
-	echo $_SESSION['config']['businessappurl'];
-	?>index.php?display=true&page=contact_purposes_up">
-		<input type="hidden" name="display" value="true" />
-	    <input type="hidden" name="page" value="contact_purposes_up" />
-		<?php
-	if ($mode == "up") {
-	    ?>
-		<p>
-	    	<label><?php
-	    echo _ID . ' ' . _CONTACT_PURPOSE;
-	    ?> :</label>
-			<input type="text" class="readonly" name="ID_contact_purposes" value="<?php
-		functions::xecho($_SESSION['CURRENT_ID_CONTACT_PURPOSE']);
-		?>" readonly="readonly" />
-	     </p>
-	     <p>&nbsp;</p>
-		<?php
-	}
-	?>
-
-		<p>
-	    	<label>
-	    		<?php echo _CONTACT_PURPOSE;?> :
-	    	</label>
-		   <input 
-		   		type="text"  name="desc_contact_purposes" value="<?php functions::xecho($_SESSION['CURRENT_DESC_CONTACT_PURPOSE']);?>" 
-			/>
-	     </p>
-
-	<p class="buttons">
-		<input type="submit" name="valid" class="button" value="<?php
-	echo _VALIDATE;
-	?>" />
-		<input type="button" class="button"  name="cancel" value="<?php
-	echo _CANCEL;
-	?>" 
-	<?php 
-		if($mode == 'popup'){
-		?>
-			onclick="self.close();"
-		<?php
-		} else {
-		?>
-			onclick="javascript:window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=contact_purposes';" 
-		<?php
-		}
-	?>
-		/>
-	<br/><br/>
-	<input type="hidden" name="mode" value="<?php echo $mode;?>"/>
-
-</form>
-
-</div>
-
-<div class="block_end">&nbsp;</div>
-
-</body>
-</html>
-
-<?php 
-if (isset($_REQUEST['valid']) && $mode <> 'popup') {
-?>
-		    <p id="footer">
-		        <?php
-		        if (isset($_SESSION['config']['showfooter'])
-		            && $_SESSION['config']['showfooter'] == 'true'
-		        ) {
-		            $core->load_footer();
-		        }
-		        ?>
-		    </p>
-		    <?php
-		    $_SESSION['error'] = '';
-		    $_SESSION['info'] = '';
-		    $core->view_debug();
-		    ?>
-		</div>
-	</div>
-<?php
-}
diff --git a/apps/maarch_entreprise/admin/contacts/contact_tree/get_tree_children_contact.php b/apps/maarch_entreprise/admin/contacts/contact_tree/get_tree_children_contact.php
deleted file mode 100755
index a4521b80a45..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_tree/get_tree_children_contact.php
+++ /dev/null
@@ -1,139 +0,0 @@
-<?php
-/*
-*    Copyright 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 used to populate tree branches
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-if(isset($_REQUEST['branch_id']) && !empty($_REQUEST['branch_id']) && isset($_REQUEST['tree_id']) && !empty($_REQUEST['tree_id']))
-{
-	$string = $_REQUEST['branch'];
-	$search="'branch_level_id'";
-	$search="#branch_level_id\":(.*)\,#U";
-	preg_match($search,$string,$out);
-	$count=count($out[0]);
-	if($count == 1)
-	{
-		$find = true;
-	}
-	$branch_level_id = str_replace("branch_level_id\":", "", $out[0]);
-	$branch_level_id = str_replace(",", "", $branch_level_id);
-	$branch_level_id = str_replace("\"", "", $branch_level_id);
-
-	require_once 'core/class/class_functions.php';
-	require_once 'core/class/class_core_tools.php';
-	require_once("apps".DIRECTORY_SEPARATOR."maarch_entreprise".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-	$core_tools = new core_tools();
-	$core_tools->load_lang();
-	$core_tools->test_user();
-	$func = new functions();
-	$tree_id = $_REQUEST['tree_id'];
-	$db = new Database();
-	$contactv2 = new contacts_v2();
-	$where = "";
-
-	if($branch_level_id == "1") {
-		$stmt = $db->query("SELECT contact_id, society, society_short, lastname, firstname, is_corporate_person, enabled 
-						FROM ".$_SESSION['tablename']['contacts_v2']." WHERE contact_type = ? order by society, lastname ",
-						array($_REQUEST['branch_id']));
-		$children = array();
-		while($res = $stmt->fetchObject()) {
-	        $contact = '';
-	        if($res->is_corporate_person == 'Y'){
-	            $contact = ucfirst($func->show_string($res->society, true));
-	            if ($res->society_short <> '') {
-	               $contact .= ' ('.$res->society_short.')';
-	            }
-	        } else {
-	            $contact = strtoupper($func->show_string($res->lastname, true)) . ' ' . $func->show_string($res->firstname, true);
-	            if ($res->society <> '') {
-	               $contact .= ' ('.$res->society.')';
-	            }
-	        }
-	        array_push($children, array('id' => $res->contact_id, 'contact_label' => $contact, 'enabled' => $res->enabled));
-		}
-		if(count($children) > 0) {
-			$openlink =  $_SESSION['config']['businessappurl']."index.php?display=true&page=get_tree_children_contact";
-			echo "[";
-			for($cpt_level2=0; $cpt_level2< count($children); $cpt_level2++) {
-				$color = "";
-				if ($children[$cpt_level2]['enabled'] ==  'N') {
-					$color = "style=\"color:red;\"";
-				}
-				echo "{'id':'contact_".functions::xssafe($children[$cpt_level2]['id'])."', 
-						'txt':'<a ".$color." onmouseover=\'this.style.cursor=\"pointer\";\' onclick=\"window.top.location.href=\'". $_SESSION['config']['businessappurl']."index.php?page=contacts_v2_up&id="
-							.functions::xssafe($children[$cpt_level2]['id'])."&fromContactTree\';\">"
-							.addslashes(functions::xssafe($children[$cpt_level2]['contact_label']))."</a>',
-						'onopenpopulate' : funcOpen, 
-						'openlink' : '".$openlink."', 
-						'canhavechildren' : true,
-						'branch_level_id' : 2}";
-
-				if(isset($children[$cpt_level2+1]['id']) && !empty($children[$cpt_level2+1]['id'])) {
-					echo ',';
-				}
-			}
-			echo "]";
-		}
-	}
-	if($branch_level_id == "2") {
-		$branchIdContact = substr($_REQUEST['branch_id'], 8);
-
-		$stmt = $db->query("SELECT id, contact_purpose_id, lastname, firstname, address_num, address_street, address_town, address_postal_code, enabled 
-							FROM ".$_SESSION['tablename']['contact_addresses']." where contact_id = ? order by lastname, firstname, address_num",
-							array($branchIdContact));
-		
-		$children = array();
-		while($res = $stmt->fetchObject()) {
-			$address = '';
-			$address = '('.$contactv2->get_label_contact($res->contact_purpose_id, $_SESSION['tablename']['contact_purposes']).') ';
-			if ($res->lastname <> '' || $res->firstname <> ''){
-			    $address .= strtoupper($func->show_string($res->lastname, true)) . ' ' . $func->show_string($res->firstname, true) . ' : ';
-			}
-			$address .= $func->show_string($res->address_num, true) . ' ' . $func->show_string($res->address_street, true) . ' ' . $func->show_string($res->address_postal_code, true) . ' ' . $func->show_string($res->address_town, true);
-			array_push($children, array('id' => $res->id, 'address_label' => $address, 'enabled' => $res->enabled));
-		}
-		if(count($children) > 0) {
-			echo "[";
-			for($cpt_level3=0; $cpt_level3< count($children); $cpt_level3++) {
-				$color = "";
-				if ($children[$cpt_level3]['enabled'] ==  'N') {
-					$color = "style=\"color:red;\"";
-				}
-				
-				echo "{'id':'address_".$children[$cpt_level3]['id']."', 
-						'txt':'<span ".$color.">".trim(addslashes(functions::xssafe($children[$cpt_level3]['address_label'])))."</span>', 
-						'canhavechildren' : false, 
-						'img' : 'page.gif'}";
-				if(isset($children[$cpt_level3+1]['id']) && !empty($children[$cpt_level3+1]['id'])) {
-					echo ',';
-				}
-			}
-			echo "]";
-		}
-	}
-}
diff --git a/apps/maarch_entreprise/admin/contacts/contact_tree/show_tree_contacts.php b/apps/maarch_entreprise/admin/contacts/contact_tree/show_tree_contacts.php
deleted file mode 100755
index 9ef8aa3d6c6..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_tree/show_tree_contacts.php
+++ /dev/null
@@ -1,210 +0,0 @@
-<?php
-/*
-*    Copyright 2014-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 Show the contact tree
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
-require_once("apps".DIRECTORY_SEPARATOR."maarch_entreprise".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-$func = new functions();
-$db = new Database();
-
-$core_tools->load_html();
-$core_tools->load_header('', true, false);
-$f_level = array();
-
-?>
-<body>
-<?php
-
-?>
-<script type="text/javascript" src="<?php echo $_SESSION['config']['businessappurl'].'tools/tafelTree/';?>js/prototype.js"></script>
-<script type="text/javascript" src="<?php echo $_SESSION['config']['businessappurl'].'tools/tafelTree/';?>js/scriptaculous.js"></script>
-<script type="text/javascript" src="<?php echo $_SESSION['config']['businessappurl'].'tools/tafelTree/';?>Tree.js"></script>
-<?php
-$search_customer_results = array();
-$f_level = array();
-
-$query="SELECT id, label FROM  ".$_SESSION['tablename']['contact_types']." order by label";
-
-$stmt = $db->query($query);
-$contactv2 = new contacts_v2();
-while($res1 = $stmt->fetchObject())
-{
-    $s_level = array(array());
-    array_push($f_level, array('contact_type_id' => $res1->id, 'contact_type_label' => ucfirst($func->show_string($res1->label, true)), 'second_level' => $s_level));
-}
-
-array_push($search_customer_results, array('contact' => _VIEW_TREE_CONTACTS . ' ' . _TREE_INFO, 'content' => $f_level));
-
-
-$openlink =  $_SESSION['config']['businessappurl']."index.php?display=true&page=get_tree_children_contact";
-
-?>
-<script type="text/javascript">
-
-    var BASE_URL = '<?php echo $_SESSION['config']['businessappurl'];?>';
-    function funcOpen(branch, response) {
-        // Ici tu peux traiter le retour et retourner true si
-        // tu veux inserer les enfants, false si tu veux pas
-        //MyClick(branch);
-        return true;
-    }
-
-    function myClick(branch) {
-
-    }
-
-    function MyOpen(branch)
-    {
-        if(branch.struct.script != '' && branch.struct.script != 'default')
-        {
-            var parents = [];
-            parents = branch.getParents();
-            var str = '';
-            for(var i=0; i < (parents.length -1) ;i++)
-            {
-                str = str + '&parent_id[]=' + parents[i].getId();
-            }
-            var str_children  = '';
-            var children = branch.getChildren();
-            for(var i=0; i < (children.length -1) ;i++)
-            {
-                str_children = str_children + '&children_id[]=' + children[i].getId();
-            }
-        }
-        return true;
-    }
-
-    function MyClose(branch)
-    {
-        var parents = branch.getParents();
-        var branch_id = branch.getId();
-        if(current_branch_id != null)
-        {
-            var branch2 = tree.getBranchById(current_branch_id);
-            if(current_branch_id == branch_id )
-            {
-                current_branch_id = branch.getNextOpenedBranch;
-            }
-            else if(branch2 && branch2.isChild(branch_id))
-            {
-                current_branch_id = branch.getNextOpenedBranch;
-            }
-        }
-        branch.collapse();
-        branch.openIt(false);
-    }
-
-    function MyBeforeOpen(branch, opened)
-    {
-        if(opened == true)
-        {
-            MyClose(branch);
-        }
-        else
-        {
-            current_branch_id = branch.getId();
-            MyOpen(branch);
-            return true;
-        }
-    }
-
-    function myMouseOver (branch)
-    {
-        document.body.style.cursor='pointer';
-    }
-
-    function myMouseOut (branch)
-    {
-        document.body.style.cursor='auto';
-    }
-
-    var tree = null;
-    var current_branch_id = null;
-
-    function TafelTreeInit ()
-    {
-        <?php $_SESSION['fromContactTree'] = "yes";?>
-        var struct = [
-        <?php
-
-            for($i=0;$i<count($search_customer_results);$i++)
-            {
-                    ?>
-                    {
-                        'id':'<?php echo addslashes(functions::xssafe($search_customer_results[$i]['contact']));?>',
-                        'txt':'<b><?php echo addslashes(functions::xssafe($search_customer_results[$i]['contact']));?></b>',
-                        'items':[
-                                    <?php
-                                    for($j=0;$j<count($search_customer_results[$i]['content']);$j++)
-                                    {
-                                        ?>
-                                        {
-                                            'id':'<?php echo addslashes(functions::xssafe($search_customer_results[$i]['content'][$j]['contact_type_id']));?>',
-                                            'txt':'<a href="#" onclick="window.top.location.href=\'<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=contact_types_up&id=<?php functions::xecho($search_customer_results[$i]['content'][$j]['contact_type_id']);?>\'"><?php echo addslashes(functions::xssafe($search_customer_results[$i]['content'][$j]['contact_type_label']));?></a>',
-                                            'onopenpopulate' : funcOpen,
-                                            'openlink' : '<?php echo($openlink);?>',
-                                            'canhavechildren' : true,
-                                            'branch_level_id' : 1
-                                        }
-                                        <?php
-                                        if($j <> count($search_customer_results[$i]['content']) - 1)
-                                            echo ',';
-                                    }
-                                    ?>
-                                ]
-                    }
-                    <?php
-                    if ($i <> count($search_customer_results) - 1)
-                        echo ',';
-                }
-
-                        ?>
-                    ];
-        tree = new TafelTree('trees_div', struct, {
-            'generate' : true,
-            'imgBase' : '<?php echo $_SESSION['config']['businessappurl'].'tools/tafelTree/';?>imgs/',
-            'defaultImg' : 'folder.gif',
-            'defaultImgOpen' : 'folderopen.gif',
-            'defaultImgClose' : 'folder.gif'
-        });
-
-        //close all branches
-        tree.collapse();
-    };
-</script>
-<div id="trees_div"></div>
-<?php
-
-$core_tools->load_js();
-?>
-</body>
-</html>
diff --git a/apps/maarch_entreprise/admin/contacts/contact_tree/view_tree_contacts.php b/apps/maarch_entreprise/admin/contacts/contact_tree/view_tree_contacts.php
deleted file mode 100755
index 0b9970b71b1..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_tree/view_tree_contacts.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/*
-*    Copyright 2014 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 Contacts Administration view tree
- *
- * @file
- *
- * @author <dev@maarch.org>
- * @date $date$
- *
- * @version $Revision$
- * @ingroup admin
- */
-$admin = new core_tools();
-$admin->test_admin('admin_contacts', 'apps');
-
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == 'true') {
-    $init = true;
-}
-$level = '';
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) {
-    $level = $_REQUEST['level'];
-}
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=view_tree_contacts';
-$page_label = _VIEW_TREE_CONTACTS;
-$page_id = 'view_tree_contacts';
-$admin->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-unset($_SESSION['m_admin']);
-?>
-
-<h1><i class="fa fa-code-branch fa-2x"></i> <?php echo _VIEW_TREE_CONTACTS; ?></h1>
-<div id="inner_content" class="clearfix">
-	<div class="block">
-    <table width="100%" border="0">
-        <tr>
-            <td>
-                <iframe name="show_trees" id="show_trees" width="900px" height="650" frameborder="0" scrolling="auto" src="<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&page=show_tree_contacts'; ?>"></iframe>
-            </td>
-        </tr>
-    </table>
-    </div>
-</div>
diff --git a/apps/maarch_entreprise/admin/contacts/contact_types/contact_types.php b/apps/maarch_entreprise/admin/contacts/contact_types/contact_types.php
deleted file mode 100755
index 8a64a6f3ce0..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_types/contact_types.php
+++ /dev/null
@@ -1,169 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 Structures list
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$admin = new core_tools();
-$admin->test_admin('admin_contacts', 'apps');
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") {
-    $init = true;
-}
-$level = "";
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2
-    || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4
-    || $_REQUEST['level'] == 1)
-) {
-    $level = $_REQUEST['level'];
-}
-$pagePath = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_types';
-$pageLabel = _CONTACT_TYPES_LIST;
-$pageId = "contact_types";
-$admin->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-/***********************************************************/
-unset($_SESSION['m_admin']);
-$_SESSION['fromContactTree'] = "";
-require_once "core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR
-    . "class_request.php";
-require_once "apps" . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-    . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR
-    . "class_list_show.php";
-$func = new functions();
-$select[$_SESSION['tablename']['contact_types']] = array();
-array_push(
-    $select[$_SESSION['tablename']['contact_types']],
-    "id", "label", "contact_target"
-);
-$what = "";
-$where = "";
-$arrayPDO = array();
-if (isset($_REQUEST['what']) && ! empty($_REQUEST['what'])) {
-    $what = $_REQUEST['what'];
-    $where .= " lower(label) like lower(?)";
-    $arrayPDO = array($what. '%');
-}
-
-$list = new list_show();
-$order = 'asc';
-if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
-    $order = trim($_REQUEST['order']);
-}
-$field = 'label';
-if (isset($_REQUEST['order_field']) && ! empty($_REQUEST['order_field'])) {
-    $field = trim($_REQUEST['order_field']);
-}
-
-$orderstr = $list->define_order($order, $field);
-
-if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) {
-    $parameters .= '&start='.$_REQUEST['start'];
-} else {
-    $_REQUEST['start'] = 0;
-}
-if (isset($_REQUEST['lines'])) {
-    $limit = $_REQUEST['lines'];
-} else {
-    $limit = 'default';
-}
-$request = new request;
-$tab = $request->PDOselect(
-    $select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype'], $limit, false, '', '', '', true, false, false, $_REQUEST['start']
-);
-if (!empty($tab)) {
-    for ($i = 0; $i < count($tab); $i ++) {
-        for ($j = 0; $j < count($tab[$i]); $j ++) {
-            foreach (array_keys($tab[$i][$j]) as $value) {
-                if ($tab[$i][$j][$value] == "id") {
-                    $tab[$i][$j]["contact_types_id"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"] = _ID;
-                    $tab[$i][$j]["size"] = "10";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"] = "left";
-                    $tab[$i][$j]["valign"] = "bottom";
-                    $tab[$i][$j]["show"] = true;
-                    $tab[$i][$j]["order"] = 'contact_types_id';
-                }
-                if ($tab[$i][$j][$value] == "label") {
-                    $tab[$i][$j]['value'] = $request->show_string(
-                        $tab[$i][$j]['value']
-                    );
-                    $tab[$i][$j]["contact_types_label"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"] = _DESC_CONTACT_TYPES;
-                    $tab[$i][$j]["size"] = "30";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"] = "left";
-                    $tab[$i][$j]["valign"] = "bottom";
-                    $tab[$i][$j]["show"] = true;
-                    $tab[$i][$j]["order"] = 'contact_types_label';
-                }
-                if ($tab[$i][$j][$value] == "contact_target") {
-                    if ($tab[$i][$j]['value'] == "both") {
-                        $tab[$i][$j]['value'] = _IS_CORPORATE_PERSON . " ". _AND ." " . _INDIVIDUAL;
-                    } else if ($tab[$i][$j]['value'] == "corporate") {
-                        $tab[$i][$j]['value'] = _IS_CORPORATE_PERSON;
-                    } else if($tab[$i][$j]['value'] == "no_corporate") {
-                        $tab[$i][$j]['value'] = _INDIVIDUAL;
-                    } else {
-                        $tab[$i][$j]['value'] = "";
-                    }
-                    
-                    $tab[$i][$j]["label"] = _CONTACT_TARGET_LIST;
-                    $tab[$i][$j]["size"] = "50";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"] = "left";
-                    $tab[$i][$j]["valign"] = "bottom";
-                    $tab[$i][$j]["show"] = true;
-                    $tab[$i][$j]["order"] = 'contact_target';
-                }
-            }
-        }
-    }
-}
-$pageName = "contact_types";
-$pageNameUp = "contact_types_up";
-$pageNameAdd = "contact_types_up";
-$pageNameDel = "contact_types_del";
-$pageNameVal = "";
-$tableName = $_SESSION['tablename']['contact_types'];
-$pageNameBan = "";
-$addLabel = _NEW_CONTACT_TYPE_ADDED;
-
-$autoCompletionArray = array();
-$autoCompletionArray["list_script_url"] = $_SESSION['config']['businessappurl']
-    . "index.php?display=true&page=contact_types_list_by_name";
-$autoCompletionArray["number_to_begin"] = 1;
-$list->admin_list(
-    $tab, $_SESSION['save_list']['full_count'], _CONTACT_TYPES_LIST . ' : ' . $_SESSION['save_list']['full_count'] . " " . _CONTACT_TYPES,
-    'contact_types_id"', 'contact_types', 'contact_types',
-    'contact_types_id', true, $pageNameUp, $pageNameVal, $pageNameBan,
-    $pageNameDel, $pageNameAdd, $addLabel, FALSE, FALSE, _ALL_CONTACT_TYPES,
-    _A_CONTACT_TYPE, 'share-alt', false, true, true, true,
-    "", true, $autoCompletionArray
-);
diff --git a/apps/maarch_entreprise/admin/contacts/contact_types/contact_types_del.php b/apps/maarch_entreprise/admin/contacts/contact_types/contact_types_del.php
deleted file mode 100755
index 557d3905ef7..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_types/contact_types_del.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 Delete a structure
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-$contact = new contacts_v2();
-$core_tools = new core_tools('');
-$core_tools->test_admin('admin_contacts', 'apps');
-$core_tools->load_lang();
-$db = new Database();
-
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") {
-    $init = true;
-}
-$level = "";
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2
-    || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4
-    || $_REQUEST['level'] == 1)
-) {
-    $level = $_REQUEST['level'];
-}
-$pagePath = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_types_del';
-$pageLabel = _CONTACT_TYPE_DEL;
-$pageId = "contact_types_del";
-$core_tools->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-/***********************************************************/
-
-if(isset($_GET['id']))
-{
-	$id = addslashes(functions::wash($_GET['id'], "no", _THE_CONTACT_TYPE));
-}
-else
-{
-	$id = "";
-}
-
-if ($_REQUEST['valid']) {
-	$id = $_POST['id'];
-	if ($_POST['new']){
-		$newid = $_POST['new'];
-
-		// delete contact types
-		$db->query("DELETE FROM ".$_SESSION['tablename']['contact_types']." WHERE id = ?", array($id));
-		$db->query("UPDATE ".$_SESSION['tablename']['contacts_v2']." SET contact_type = ? WHERE contact_type = ?", array($newid, $id));
-
-		if($_SESSION['history']['contact_types_del'] == "true")
-		{
-			require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php");
-			$users = new history();
-			$users->add($_SESSION['tablename']['contact_types'], $id,"DEL",'contact_types_del',_CONTACT_TYPE_DEL." ".strtolower(_NUM).$id."", $_SESSION['config']['databasetype']);
-		}
-		$_SESSION['info'] = _DELETED_CONTACT_TYPE.".";
-		unset($_SESSION['m_admin']);
-		?>
-	        <script type="text/javascript">
-	            window.location.href="<?php echo $_SESSION['config']['businessappurl'].'index.php?page=contact_types&order='.functions::xssafe($_REQUEST['order']).'&order_field='.functions::xssafe($_REQUEST['order_field']).'&start='.functions::xssafe($_REQUEST['start']).'&what='.functions::xssafe($_REQUEST['what']);?>";
-	        </script>	
-	    <?php
-	} else {
-		$_SESSION['error'] = _NEW_CONTACT_TYPE.' '._IS_EMPTY.".";
-		$contact->type_purpose_address_del($id, true, $_SESSION['tablename']['contact_types'], 'contact_type', _DELETED_CONTACT_TYPE, _WARNING_MESSAGE_DEL_CONTACT_TYPE, _CONTACT_TYPE_DEL, _CONTACT_TYPE_REAFFECT, _NEW_CONTACT_TYPE, _CHOOSE_CONTACT_TYPES, 'contact_types', 'contact_types_del', _CONTACT_TYPE);
-	}
-} else {
-	$contact->type_purpose_address_del($id, true, $_SESSION['tablename']['contact_types'], 'contact_type', _DELETED_CONTACT_TYPE, _WARNING_MESSAGE_DEL_CONTACT_TYPE, _CONTACT_TYPE_DEL, _CONTACT_TYPE_REAFFECT, _NEW_CONTACT_TYPE, _CHOOSE_CONTACT_TYPES, 'contact_types', 'contact_types_del', _CONTACT_TYPE);
-}
diff --git a/apps/maarch_entreprise/admin/contacts/contact_types/contact_types_list_by_name.php b/apps/maarch_entreprise/admin/contacts/contact_types/contact_types_list_by_name.php
deleted file mode 100755
index 630548f8f03..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_types/contact_types_list_by_name.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 List of structures for autocompletion
-*
-*
-* @file
-* @author Laurent Giovannoni <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
-$db = new Database();
-$stmt = $db->query("SELECT label as tag FROM ".$_SESSION['tablename']['contact_types']." WHERE lower(label) like lower(?) order by label",
-	array('%'.$_REQUEST['what'].'%'));
-
-$listArray = array();
-while($line = $stmt->fetchObject())
-{
-	array_push($listArray, $line->tag);
-}
-echo "<ul>\n";
-$authViewList = 0;
-
-foreach($listArray as $what)
-{
-	if($authViewList >= 10)
-	{
-		$flagAuthView = true;
-	}
-    echo "<li>".functions::xssafe($what)."</li>\n";
-	if($flagAuthView)
-	{
-		echo "<li>...</li>\n";
-		break;
-	}
-	$authViewList++;
-}
-echo "</ul>";
diff --git a/apps/maarch_entreprise/admin/contacts/contact_types/contact_types_up.php b/apps/maarch_entreprise/admin/contacts/contact_types/contact_types_up.php
deleted file mode 100755
index ad72c08a6ef..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contact_types/contact_types_up.php
+++ /dev/null
@@ -1,355 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 Modify a structure
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-require_once "core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR
-    . "class_history.php";
-$core = new core_tools();
-$core->test_admin('admin_contacts', 'apps');
-$core->load_lang();
-
-$mode = "";
-if (isset($_GET['id']) && ! empty($_GET['id'])) {
-	$mode = 'up';
-	$_SESSION['m_admin']['mode'] = $mode;
-} else if (isset($_SESSION['m_admin']['mode']) && ! empty($_SESSION['m_admin']['mode'])){
-	$mode = 'up';
-} else {
-	$_SESSION['CURRENT_ID_CONTACT_TYPE'] = '';
-	$_SESSION['CURRENT_DESC_CONTACT_TYPE'] = '';
-	$_SESSION['CURRENT_TARGET_CONTACT_TYPE'] = '';
-	$_SESSION['CURRENT_CONTACT_CREATION'] = '';
-
-}
-
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") {
-    $init = true;
-}
-$level = "";
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2
-    || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4
-    || $_REQUEST['level'] == 1)
-) {
-    $level = $_REQUEST['level'];
-}
-$pagePath = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_types_up';
-if ($mode == "up") {
-	$pageLabel = _CONTACT_TYPE_MODIF;
-} else {
-	$pageLabel = _NEW_CONTACT_TYPE_ADDED;
-}
-$pageId = "contact_types_up";
-$core->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-/***********************************************************/
-
-$db = new Database();
-
-$desc = "";
-$id = "";
-
-if (isset($_GET['id']) && ! empty($_GET['id'])) {
-	$id = $_GET['id'];
-	$stmt = $db->query(
-		"SELECT label, contact_target, can_add_contact FROM "
-	    . $_SESSION['tablename']['contact_types']
-	    . " WHERE id = ?", array($id)
-	);
-
-	$res = $stmt->fetchObject();
-	$desc = functions::show_string($res->label);
-	$_SESSION['CURRENT_ID_CONTACT_TYPE'] = $id;
-	$_SESSION['CURRENT_DESC_CONTACT_TYPE'] = $desc;
-	$_SESSION['CURRENT_TARGET_CONTACT_TYPE'] = $res->contact_target;
-	$_SESSION['CURRENT_CONTACT_CREATION'] = $res->can_add_contact;
-}
-
-$erreur = "";
-if (isset($_REQUEST['valid'])) {
-	if (isset($_REQUEST['desc_contact_types'])
-	    && ! empty($_REQUEST['desc_contact_types'])
-	) {
-		$desc = $_REQUEST['desc_contact_types'];
-		$contact_target = $_REQUEST['contact_target'];
-		$contact_creation = $_REQUEST['contact_creation'];
-        $desc=str_replace(';', ' ', $desc);
-        $desc=str_replace('--', '-', $desc);
-	    $desc = $core->wash(
-	        $desc, 'no', _CONTACT_TYPE, 'yes', 0, 255
-	    );
-	    if($_SESSION['error'] <> ''){
-	    	$_SESSION['error'] = '';
-	    	$erreur .= _CONTACT_TYPE .' '. MUST_BE_LESS_THAN." 255 "._CHARACTERS;
-	    }	
-	} else {
-		$erreur .= _CONTACT_TYPE_MISSING . ".<br/>";
-	}
-
-	if (empty($erreur)) {
-		if(utf8_encode(utf8_decode($desc)) != $desc) {
-			$desc = utf8_encode($desc);
-		}
-		$stmt = $db->query(
-			"SELECT * FROM ".$_SESSION['tablename']['contact_types']
-		    . " WHERE lower(label) = lower(?)",
-		    array($desc)
-		);
-
-		if ($stmt->rowCount() > 0 && $mode <> 'up') {
-			$erreur .= _THIS_CONTACT_TYPE . ' ' . _ALREADY_EXISTS ;
-		} else {
-			if ($mode == "up") {
-				$stmt = $db->query(
-					"SELECT * FROM ".$_SESSION['tablename']['contact_types']
-				    . " WHERE lower(label) = lower(?) and id <> ?",
-				    array($desc, $_REQUEST['ID_contact_types'])
-				);	
-				if($stmt->rowCount() > 0){
-					$erreur .= _THIS_CONTACT_TYPE . ' ' . _ALREADY_EXISTS ;
-				} else {			
-					if (isset($_REQUEST['ID_contact_types'])
-					    && ! empty($_REQUEST['ID_contact_types'])
-					) {
-						$id = $_REQUEST['ID_contact_types'];
-						$db->query(
-							"UPDATE " . $_SESSION['tablename']['contact_types']
-						    . " SET label = ?, contact_target = ?, can_add_contact = ? WHERE id = ?",
-						    array($desc, $contact_target, $contact_creation, $id)
-						);
-
-						if ($_SESSION['history']['contact_types_up'] == "true") {
-							$hist = new history();
-							$hist->add(
-							    $_SESSION['tablename']['contact_types'], $id,
-							    "UP", 'contact_types_up', _CONTACT_TYPE_MODIF . " " . strtolower(_NUM)
-							    . $id,
-							    $_SESSION['config']['databasetype']
-							);
-						}
-						$_SESSION['info'] .= _CONTACT_TYPE_MODIF . " : " . $id;
-					} else {
-						$erreur .= _ID_CONTACT_TYPE_PB . ".";
-					}
-				}
-			} else {
-				$desc = $_REQUEST['desc_contact_types'];
-				if(utf8_encode(utf8_decode($desc)) != $desc) {
-					$desc = utf8_encode($desc);
-				}
-	            $desc=str_replace(';', ' ', $desc);
-	            $desc=str_replace('--', '-', $desc);				
-				$db->query(
-					"INSERT INTO "
-				    . $_SESSION['tablename']['contact_types']
-				    . " ( label, contact_target, can_add_contact) VALUES (?, ?, ?)",
-					array($desc, $contact_target, $contact_creation)
-				);
-				$stmt = $db->query(
-					"SELECT id FROM "
-				    . $_SESSION['tablename']['contact_types']
-				    . " WHERE label = ?",
-				    array($desc)
-				);
-				$res = $stmt->fetchObject();
-				$id = $res->id;
-
-				if ($_SESSION['history']['contact_types_add'] == "true") {
-					$hist = new history();
-					$hist->add(
-					    $_SESSION['tablename']['contact_types'], $id,
-					    "ADD", 'contact_types_add', _NEW_CONTACT_TYPE_ADDED . " (" . $desc . ")",
-					    $_SESSION['config']['databasetype']
-					);
-
-				}
-				$_SESSION['info'] .= _NEW_CONTACT_TYPE . " : " . $desc;
-			}
-		}
-	}
-	if (empty($erreur)) {
-		unset($_SESSION['m_admin']);
-		if (isset($_SESSION['fromContactTree']) && $_SESSION['fromContactTree'] == 'yes') {
-			$_SESSION['error'] = "";
-			?><script type="text/javascript">window.location.href="<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=view_tree_contacts";</script><?php
-		} else {
-		?>
-	   		<script type="text/javascript">window.location.href="<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=contact_types";</script>
-		<?php
-		}
-		exit();
-	} else {
-		?>
-		<div id="header">
-        <div id="nav">
-            <div><p id="ariane"><?php
-            ?></p></div>
-            <p id="gauchemenu"></p>
-            <a href="index.php"><p id="logo"></p></a>
-       </div>
-		</div>
-		<div id="container">
-		    <div id="content">
-		<?php
-		/****************Management of the location bar  ************/
-		$core->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-		/***********************************************************/
-	}
-}
-
-$core->load_html();
-
-if ($mode == "up") {
-	$title = _CONTACT_TYPE_MODIF;
-} else {
-	$title = _NEW_CONTACT_TYPE_ADDED;
-}
-$core->load_header($title, true, false);
-$time = $core->get_session_time_expire();
-?>
-<!-- <body onload="setTimeout(window.close, <?php echo $time;?>*60*1000);window.resizeTo(700,700);"> -->
-<br/>
-
-<div class="error">
-<?php
-functions::xecho($erreur);
-$erreur = "";
-?>
-</div>
-<h1 class="tit">
-<?php
-if ($mode == "up") {
-	?><i class = "fa fa-edit fa-2x"></i><?php
-    echo _CONTACT_TYPE_MODIF;
-} else {
-	?><i class = "fa fa-plus fa-2x"></i>&nbsp;<?php
-    echo _NEW_CONTACT_TYPE_ADDED;
-}
-?></h1>
-<div class="block">
-<br/>
-
-<br/>
-<form method="post" name="frmcontact_types" id="frmcontact_types" class="forms" action="<?php
-	echo $_SESSION['config']['businessappurl'];
-	?>index.php?display=true&page=contact_types_up">
-		<input type="hidden" name="display" value="true" />
-	    <input type="hidden" name="page" value="contact_types_up" />
-	    <?php 
-/*	    if (isset($_SESSION['fromContactTree']) && $_SESSION['fromContactTree']=="yes"){
-	    		?><input type="hidden" name="fromContactTree" value="yes" /><?php
-	    	}*/
-	if ($mode == "up") {
-	    ?>
-		<p>
-	    	<label><?php
-	    echo _ID . ' ' . _CONTACT_TYPE;
-	    ?> :</label>
-			<input type="text" class="readonly" name="ID_contact_types" value="<?php
-		functions::xecho($_SESSION['CURRENT_ID_CONTACT_TYPE']);
-		?>" readonly="readonly" />
-	     </p>
-	     <p>&nbsp;</p>
-		<?php
-	}
-	?>
-
-		<p>
-	    	<label>
-	    		<?php echo _CONTACT_TYPE;?> :
-	    	</label>
-		   <input 
-		   		type="text"  name="desc_contact_types" value="<?php functions::xecho($_SESSION['CURRENT_DESC_CONTACT_TYPE']);?>" 
-			/>
-	     </p>
-
-		<p>
-	    	<label>
-	    		<?php echo _CONTACT_TARGET;?>
-	    	</label>
-		   <select name="contact_target" id="contact_target" >
-		   		<option value="both" <?php if($_SESSION['CURRENT_TARGET_CONTACT_TYPE'] == 'both'){?> selected="selected"<?php } ?> ><?php echo _IS_CORPORATE_PERSON . " ". _AND ." " . _INDIVIDUAL;?></option>
-		   		<option value="corporate" <?php if($_SESSION['CURRENT_TARGET_CONTACT_TYPE'] == 'corporate'){?> selected="selected"<?php } ?> ><?php echo _IS_CORPORATE_PERSON;?></option>
-		   		<option value="no_corporate" <?php if($_SESSION['CURRENT_TARGET_CONTACT_TYPE'] == 'no_corporate'){?> selected="selected"<?php } ?> ><?php echo _INDIVIDUAL;?></option>
-			</select>
-		</p>
-		<p>
-			<label>
-				<?php echo _CONTACT_TYPE_CREATION;?>
-			</label>
-			<input name="contact_creation" value="Y" type="radio"
-				   <?php if($_SESSION['CURRENT_CONTACT_CREATION'] == 'Y' || $_SESSION['CURRENT_CONTACT_CREATION'] == ''){?>checked=""<?php }?> ><?php echo _YES;?>
-			<input name="contact_creation" value="N" type="radio"
-				   <?php if($_SESSION['CURRENT_CONTACT_CREATION'] == 'N'){?>checked=""<?php }?>><?php echo _NO;?>
-		</p>
-	<p class="buttons">
-		<input type="submit" name="valid" class="button" value="<?php
-	echo _VALIDATE;
-	?>" />
-		<input type="button" class="button"  name="cancel" value="<?php
-	echo _CANCEL;
-	?>" 
-	    <?php 
-	    if (isset($_SESSION['fromContactTree']) && $_SESSION['fromContactTree']=="yes"){
-    		?> onclick="window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=view_tree_contacts';" /><?php
-    	} else {
-    		?> onclick="javascript:window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=contact_types';" /><?php
-    	}?>
-	<br/><br/>
-	<input type="hidden" name="mode" value="<?php echo $mode;?>"/>
-
-</form>
-
-</div>
-
-<div class="block_end">&nbsp;</div>
-<!-- </body> -->
-</html>
-
-<?php 
-if (isset($_REQUEST['valid'])) {
-?>
-		    <p id="footer">
-		        <?php
-		        if (isset($_SESSION['config']['showfooter'])
-		            && $_SESSION['config']['showfooter'] == 'true'
-		        ) {
-		            $core->load_footer();
-		        }
-		        ?>
-		    </p>
-		    <?php
-		    $_SESSION['error'] = '';
-		    $_SESSION['info'] = '';
-		    $core->view_debug();
-		    ?>
-		</div>
-	</div>
-<?php
-}
diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2.php
deleted file mode 100755
index 85378d84f45..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2.php
+++ /dev/null
@@ -1,299 +0,0 @@
-<?php
-/*
-*    Copyright 2008-2014 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  contacts list
-*
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$admin = new core_tools();
-$return = $admin->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $admin->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN;
-    ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php';</script>
-    <?php
-    exit();
-}
-
-$func = new functions();
-$_SESSION['m_admin'] = array();
-/****************Management of the location bar  ************/
-$init = false;
-if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-{
-    $init = true;
-}
-$level = "";
-if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-{
-    $level = $_REQUEST['level'];
-}
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2';
-$page_label = _CONTACTS_LIST;
-$page_id = "contacts_v2";
-$admin->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-unset($_SESSION['fromContactTree']);
-?>
-<table width="100%" id="magicContactsTable">
-    <tr>
-        <?php if ($admin->test_admin('admin_contacts', 'apps', false)) { ?>
-        <td width="33%">
-
-                <a href="<?php 
-                    echo $_SESSION['config']['businessappurl']
-                    ;?>index.php?admin=contacts&page=manage_duplicates">
-                    <h2>
-                        <i class="fa fa-magic fa-2x"></i>&nbsp;<?php 
-                        echo _MANAGE_DUPLICATES;?>
-                    </h2>
-                </a>
-
-        </td>
-        <?php } ?>
-        <td align="left">
-            <input class="button" type="button" value="<?php echo _EXPORT_CONTACT;?>" onclick="window.open('<?php echo $_SESSION['config']['businessappurl'] . 'index.php?display=true&dir=admin&page=export_admin_list'?>');window.location.reload();"/>      
-        </td>
-        <td align="right">
-            <input class="button" type="button" value="<?php echo _MANAGE_CONTACT_ADDRESSES_LIST;?>" onclick="window.location.href='<?php echo $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_list'?>'"/>      
-        </td>
-   </tr>
-</table>
-<?php
-require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_list_show.php");
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-$contact = new contacts_v2();
-$select[$_SESSION['tablename']['contacts_v2']] = array();
-array_push($select[$_SESSION['tablename']['contacts_v2']],"contact_id", "is_corporate_person", "contact_type", "society","lastname","firstname", "user_id", "enabled");
-$what = "";
-
-$where =" ";
-$arrayPDO = array();
-if (isset($_REQUEST['selectedObject']) && ! empty($_REQUEST['selectedObject'])) {
-    $where .= " contact_id = ? ";
-    $arrayPDO = array($_REQUEST['selectedObject']);
-} elseif(isset($_REQUEST['what']) && !empty($_REQUEST['what'])) {
-    $what = $func->wash($_REQUEST['what'], "alphanum", "", "no");
-
-    $what = str_replace("  ", "", $_REQUEST['what']);
-    $what_table = explode(" ", $what);
-
-    foreach($what_table as $key => $what_a){
-        $sql_lastname[] = " lower(lastname) LIKE lower(:what_".$key.")";
-        $sql_society[] = " lower(society) LIKE lower(:what_".$key.")";
-        $arrayPDO = array_merge($arrayPDO, array(":what_".$key => $what_a."%"));
-    }
-
-    $where .= " (" . implode(' OR ', $sql_lastname) . " ";
-    $where .= " or " . implode(' OR ', $sql_society) . ") ";
-
-}
-$list = new list_show();
-$order = 'asc';
-if(isset($_REQUEST['order']) && !empty($_REQUEST['order']))
-{
-    $order = trim($_REQUEST['order']);
-}
-$field = 'lastname, society';
-if(isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field']))
-{
-    $field = trim($_REQUEST['order_field']);
-}
-
-$orderstr = $list->define_order($order, $field);
-if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) {
-    $parameters .= '&start='.$_REQUEST['start'];
-} else {
-    $_REQUEST['start'] = 0;
-}
-//EXPORT DE LA LISTE
-$select2[$_SESSION['tablename']['contacts_v2']] = array();
-array_push($select2[$_SESSION['tablename']['contacts_v2']], 'contact_id as "'._ID.'"','is_corporate_person as "'._IS_CORPORATE_PERSON.'"', 'contact_type as "'._CONTACT_TYPE.'"','lastname as "'._LASTNAME . '"', 'firstname as "'._FIRSTNAME . '"', 'society as "'._STRUCTURE_ORGANISM . '"');
-
-$request= new request;
-
-// $request->show();
-
-$_SESSION['export_admin_list'] = array();
-$_SESSION['export_admin_list']['select'] = $select2;
-$_SESSION['export_admin_list']['where'] = $where;
-$_SESSION['export_admin_list']['aPDO'] = $arrayPDO;
-$_SESSION['export_admin_list']['order'] = $orderstr;
-
-if (isset($_REQUEST['lines'])) {
-    $limit = $_REQUEST['lines'];
-} else {
-    $limit = 'default';
-}
-$tab=$request->PDOselect($select,$where,$arrayPDO, $orderstr,$_SESSION['config']['databasetype'], $limit, false, '', '', '', true, false, false, $_REQUEST['start']);
-
-for ($i=0;$i<count($tab);$i++)
-{
-    for ($j=0;$j<count($tab[$i]);$j++)
-    {
-        foreach(array_keys($tab[$i][$j]) as $value)
-        {
-            if($tab[$i][$j][$value]=="contact_id")
-            {
-                $tab[$i][$j]["contact_id"]=$tab[$i][$j]['value'];
-                $tab[$i][$j]["label"]= _ID;
-                $tab[$i][$j]["size"]="5";
-                $tab[$i][$j]["label_align"]="left";
-                $tab[$i][$j]["align"]="left";
-                $tab[$i][$j]["valign"]="bottom";
-                $tab[$i][$j]["show"]=true;
-                $tab[$i][$j]["order"]= "contact_id";
-            }
-            if($tab[$i][$j][$value]=="contact_type")
-            {
-                $tab[$i][$j]["contact_type"]= $tab[$i][$j]['value'];
-                $tab[$i][$j]["value"]= $contact->get_label_contact($tab[$i][$j]['value'], $_SESSION['tablename']['contact_types']);
-                $tab[$i][$j]["label"]= _CONTACT_TYPE;
-                $tab[$i][$j]["size"]="10";
-                $tab[$i][$j]["label_align"]="left";
-                $tab[$i][$j]["align"]="left";
-                $tab[$i][$j]["valign"]="bottom";
-                $tab[$i][$j]["show"]=true;
-                $tab[$i][$j]["order"]= "contact_type";
-            }
-            if($tab[$i][$j][$value]=="is_corporate_person")
-            {
-                $tab[$i][$j]['value']= ($tab[$i][$j]['value'] == 'Y')? _YES : _NO;
-                $tab[$i][$j]["label"]=_IS_CORPORATE_PERSON;
-                $tab[$i][$j]["size"]="5";
-                $tab[$i][$j]["label_align"]="center";
-                $tab[$i][$j]["align"]="center";
-                $tab[$i][$j]["valign"]="bottom";
-                $tab[$i][$j]["show"]=true;
-                $tab[$i][$j]["order"]= "is_corporate_person";
-            }
-            if($tab[$i][$j][$value]=="society")
-            {
-                $tab[$i][$j]['value']=$request->show_string($tab[$i][$j]['value']);
-                $tab[$i][$j]["society"]=$tab[$i][$j]['value'];
-                $tab[$i][$j]["label"]=_STRUCTURE_ORGANISM;
-                $tab[$i][$j]["size"]="15";
-                $tab[$i][$j]["label_align"]="left";
-                $tab[$i][$j]["align"]="left";
-                $tab[$i][$j]["valign"]="bottom";
-                $tab[$i][$j]["show"]=true;
-                $tab[$i][$j]["order"]= "society";
-            }
-            if($tab[$i][$j][$value]=="lastname")
-            {
-                $tab[$i][$j]['value']=$request->show_string($tab[$i][$j]['value']);
-                $tab[$i][$j]["lastname"]=$tab[$i][$j]['value'];
-                $tab[$i][$j]["label"]=_LASTNAME;
-                $tab[$i][$j]["size"]="15";
-                $tab[$i][$j]["label_align"]="left";
-                $tab[$i][$j]["align"]="left";
-                $tab[$i][$j]["valign"]="bottom";
-                $tab[$i][$j]["show"]=true;
-                $tab[$i][$j]["order"]= "lastname";
-            }
-            if($tab[$i][$j][$value]=="firstname")
-            {
-                $tab[$i][$j]["firstname"]= $tab[$i][$j]['value'];
-                $tab[$i][$j]["label"]=_FIRSTNAME;
-                $tab[$i][$j]["size"]="15";
-                $tab[$i][$j]["label_align"]="center";
-                $tab[$i][$j]["align"]="center";
-                $tab[$i][$j]["valign"]="bottom";
-                $tab[$i][$j]["show"]=true;
-                $tab[$i][$j]["order"]= "firstname";
-            }
-            if($tab[$i][$j][$value]=="user_id")
-            {
-                $tab[$i][$j]["user_id"]= $tab[$i][$j]['value'];
-                $tab[$i][$j]["label"]=_CREATE_BY;
-                $tab[$i][$j]["size"]="15";
-                $tab[$i][$j]["label_align"]="center";
-                $tab[$i][$j]["align"]="center";
-                $tab[$i][$j]["valign"]="bottom";
-                $tab[$i][$j]["show"]=true;
-                $tab[$i][$j]["order"]= "user_id";
-            }
-            if($tab[$i][$j][$value]=="enabled")
-            {
-                $tab[$i][$j]["enabled"]= $tab[$i][$j]['value'];
-                $tab[$i][$j]["label"]=_STATUS;
-                $tab[$i][$j]["size"]="5";
-                $tab[$i][$j]["label_align"]="center";
-                $tab[$i][$j]["align"]="center";
-                $tab[$i][$j]["valign"]="bottom";
-                $tab[$i][$j]["show"]=true;
-                $tab[$i][$j]["order"]= "enabled";
-            }
-        }
-    }
-}
-$page_name = "contacts_v2";
-$page_name_up = "contacts_v2_up";
-$page_name_ban = "";
-$page_name_val= "";
-
-if ($admin->test_admin('admin_contacts', 'apps', false)) {
-    $page_name_del = "contacts_v2_del";
-    $page_name_ban = "contacts_v2_status&mode=ban";
-    $page_name_val = "contacts_v2_status&mode=allow";
-}
-
-$page_name_add = "contacts_v2_add";
-$label_add = _CONTACT_ADDITION;
-$_SESSION['m_admin']['init'] = true;
-$title = _CONTACTS_LIST." : ".$_SESSION['save_list']['full_count']." "._CONTACTS;
-$autoCompletionArray = array();
-$autoCompletionArray["list_script_url"] = $_SESSION['config']['businessappurl']."index.php?display=true&page=contacts_v2_list_by_name";
-$autoCompletionArray["number_to_begin"] = 1;
-$autoCompletionArray["searchBoxAutoCompletionUpdate"] = true;
-
-$list->admin_list($tab, $_SESSION['save_list']['full_count'], $title, 'contact_id','contacts_v2','contacts_v2','contact_id', true, $page_name_up, $page_name_val, $page_name_ban, $page_name_del, $page_name_add, $label_add, FALSE, FALSE, _ALL_CONTACTS, _CONTACT, 'users', false, true, true, true, $what, true, $autoCompletionArray, false, true);
-$_SESSION['m_admin']['contacts'] = array();
-$_SESSION['m_admin']['contacts']['id'] = "";
-$_SESSION['m_admin']['contacts']['title'] = "";
-$_SESSION['m_admin']['contacts']['lastname'] = "";
-$_SESSION['m_admin']['contacts']['firtsname'] = "";
-$_SESSION['m_admin']['contacts']['society'] = "";
-$_SESSION['m_admin']['contacts']['function'] = "";
-$_SESSION['m_admin']['contacts']['address_num'] = "";
-$_SESSION['m_admin']['contacts']['address_street'] = "";
-$_SESSION['m_admin']['contacts']['address_complement'] = "";
-$_SESSION['m_admin']['contacts']['address_town'] = "";
-$_SESSION['m_admin']['contacts']['address_postal_code'] = "";
-$_SESSION['m_admin']['contacts']['address_country'] = "";
-$_SESSION['m_admin']['contacts']['email'] = "";
-$_SESSION['m_admin']['contacts']['phone'] = "";
-$_SESSION['m_admin']['contacts']['other_data'] = "";
-$_SESSION['m_admin']['contacts']['is_corporate_person'] = "";
-$_SESSION['m_admin']['contacts']['is_private'] = "";
-
-$_SESSION['origin']="contacts_list";
diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_add.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_add.php
deleted file mode 100755
index 24565963d9f..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_add.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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  Add contact form
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools2 = new core_tools();
-$core_tools2->load_lang();
-$return = $core_tools2->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $core_tools2->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN;
-    ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php';</script>
-    <?php
-    exit();
-}
-/****************Management of the location bar  ************/
-$init = false;
-if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-{
-    $init = true;
-}
-$level = "";
-if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-{
-    $level = $_REQUEST['level'];
-}
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_add';
-$page_label = _ADDITION;
-$page_id = "contacts_v2_add";
-$core_tools2->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$contact = new contacts_v2();
-$contact->formcontact("add");
-?>
diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_del.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_del.php
deleted file mode 100755
index dd8d1caab71..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_del.php
+++ /dev/null
@@ -1,120 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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  Delete contact
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-$core_tools->test_admin('admin_contacts', 'apps');
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
- /****************Management of the location bar  ************/
-$init = false;
-if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-{
-    $init = true;
-}
-$level = "";
-if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-{
-    $level = $_REQUEST['level'];
-}
-
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_del';
-$page_label = _DELETION;
-$page_id = "contacts_v2_del";
-$core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-$func = new functions();
-$db = new Database();
-$contact = new contacts_v2();
-
-if(isset($_GET['id']))
-{
-    $s_id = addslashes($func->wash($_GET['id'], "alphanum", _CONTACT));
-}
-else
-{
-    $s_id = "";
-}
-
-if(isset($_REQUEST['valid']))
-{
-        
-    if(!empty($_REQUEST['contact']) && !empty($_REQUEST['address']))
-    {
-        $new_contact = $_REQUEST['contact'];
-        $new_address = $_REQUEST['address'];
-
-        $i=0;
-        $db->query("UPDATE res_letterbox SET exp_contact_id = ?, address_id = ? WHERE exp_contact_id = ?", array($new_contact, $new_address, $s_id));
-        $db->query("UPDATE res_letterbox SET dest_contact_id = ?, address_id = ? WHERE dest_contact_id = ?", array($new_contact, $new_address, $s_id));
-        $db->query("UPDATE contacts_res SET contact_id = ?, address_id = ? WHERE contact_id = ?", array($new_contact, $new_address, $s_id));
-
-		$aAddressesTmp = \SrcCore\models\DatabaseModel::select([
-			'select'    => ['id'],
-			'table'     => ['contact_addresses'],
-			'where'     => ['contact_id = ?'],
-			'data'      => [$s_id],
-		]);
-
-		$aAddresses = [];
-		if (!empty($aAddressesTmp)) {
-			foreach ($aAddressesTmp as $value) {
-				$aAddresses[] = $value['id'];
-			}
-            $db->query("UPDATE resource_contacts SET item_id = ? WHERE item_id in (?)", array($new_address, $aAddresses));
-		}
-
-        $db->query("DELETE FROM " . $_SESSION['tablename']['contacts_v2']
-            . " WHERE contact_id = ?", array($s_id));
-        $db->query("DELETE FROM " . $_SESSION['tablename']['contact_addresses']
-            . " WHERE contact_id = ?", array($s_id));
-        if($_SESSION['history']['contactdel'])
-        {
-            require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php');
-            $hist = new history();
-            $hist->add($_SESSION['tablename']['contacts_v2'], $s_id,"DEL","contactdel",_CONTACT_DELETED.' : '.$s_id, $_SESSION['config']['databasetype']);
-        }
-        ?>
-        <script type="text/javascript">
-            window.location.href="<?php echo $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2&order='.functions::xssafe($_REQUEST['order'])
-                ."&order_field=".functions::xssafe($_REQUEST['order_field'])."&start=".functions::xssafe($_REQUEST['start'])
-                ."&what=".functions::xssafe($_REQUEST['what']);?>";
-        </script>
-        <?php
-    } elseif (empty($_REQUEST['contact'])) {
-        $_SESSION['error'] = _NEW_CONTACT.' '._IS_EMPTY.". ". _USE_AUTOCOMPLETION;
-        $contact->delcontact($s_id);
-    } elseif (empty($_REQUEST['address'])) {
-        $_SESSION['error'] = _NEW_ADDRESS.' '._IS_EMPTY.". ". _USE_AUTOCOMPLETION;
-        $contact->delcontact($s_id);
-    }
-} else {
-    $contact->delcontact($s_id);
-}
diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_list_by_name.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_list_by_name.php
deleted file mode 100755
index 1d8f46f39f9..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_list_by_name.php
+++ /dev/null
@@ -1,206 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 List of users for autocompletion
-*
-*
-* @file
-* @author  Laurent Giovannoni <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
-require_once("apps".DIRECTORY_SEPARATOR."maarch_entreprise".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-$contact = new contacts_v2();
-$db = new Database();
-
-$listArray = array();
-
-$Input = $_REQUEST['what'];
-$boldInput = strtoupper($Input);
-$ucwordsInput = ucwords($Input);
-$Input = $Input . ' ' . $boldInput . ' ' . $ucwordsInput;
-
-$args = explode(' ', $Input);
-$args[] = $Input;
-$args_bold = array();
-foreach ($args as $key => $value) {
-    $args_bold[$key] = '<b>'. $value . '</b>';
-}
-echo "<ul id=\"autocomplete_contacts_ul\">";
-//STEP 1 : search with lastname (physical contact)
-    $query = "SELECT contact_id, contact_type, society, lastname, firstname, function, contact_id, is_corporate_person, society_short FROM contacts_v2 WHERE is_corporate_person = 'N' AND enabled = 'Y' AND enabled = 'Y' ";
-    $query.= "AND (LOWER(translate(lastname || ' ' || firstname,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))";
-    $query.= "LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')))";
-    $query.= "OR (LOWER(translate(firstname || ' ' || lastname,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))";
-    $query.= "LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')))";
-    $query.= "OR (LOWER(translate(function,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))";
-    $query.= "LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')))";
-    $query.= "OR (LOWER(translate(society,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))";
-    $query.= "LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')))";
-    $query.= "ORDER BY lastname,firstname ASC";
-    $arrayPDO = array('%'.$_REQUEST['what'].'%','%'.$_REQUEST['what'].'%','%'.$_REQUEST['what'].'%','%'.$_REQUEST['what'].'%');
-    $stmt = $db->query($query, $arrayPDO);
-    $nb_step1 = $stmt->rowCount();
-    
-    $m = 30;
-    if ($nb_step1 >= $m) $l = $m;
-    else $l = $nb_step1;
-    
-    $found = false;
-
-    for ($i=0; $i<$l; $i++) {
-
-        $res = $stmt->fetchObject();
-
-        $isSociety = false;
-        if(!empty($res->society)){
-            if($res->firstname == null && $res->lastname == null){
-                $arr_contact_info = array($res->firstname,$res->lastname,$res->society);
-                $isSociety = true;               
-            } else {
-                $arr_contact_info = array($res->firstname,$res->lastname,'('.$res->society.')');
-                $contact_info = implode(' ', $arr_contact_info);
-            }
-        }else{
-            $arr_contact_info = array($res->firstname,$res->lastname);
-            $contact_info = implode(' ', $arr_contact_info);
-        }
-
-        if ($i%2==1) $color = 'LightYellow';
-        else $color = 'white';
-
-        if($isSociety){
-            echo "<li id='".$res->contact_id."' style='font-size:12px;background-color:$color;'><i class='fa fa-building fa-1x' style='padding:5px;display:table-cell;vertical-align:middle;' title='structure'></i> "
-                . '<span style="display:table-cell;vertical-align:middle;">'. str_replace($args, $args_bold, $res->society) .'</span>'
-            ."</li>";
-        } else {
-            echo "<li id='".$res->contact_id."' style='font-size:12px;background-color:$color;'><i class='fa fa-user fa-1x' style='padding:5px;display:table-cell;vertical-align:middle;' title='personne physique'></i> "
-                . '<span style="display:table-cell;vertical-align:middle;">' . str_replace($args, $args_bold, $contact_info) . '</span>'
-            ."</li>";
-        }
-    }
-
-    //STEP 2 : search with society(physical contact)
-    /*$query = "SELECT contact_id,firstname,lastname,society FROM contacts_v2 WHERE is_corporate_person = 'N' AND enabled = 'Y' AND (LOWER(translate(society,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) OR LOWER(translate(society_short,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))) ORDER BY society,lastname,firstname ASC";
-    $arrayPDO = array('%'.$_REQUEST['what'].'%','%'.$_REQUEST['what'].'%');
-    $stmt = $db->query($query, $arrayPDO);
-    $nb_step3 = $stmt->rowCount();
-    
-    $m = 30;
-    if ($nb_step3 >= $m) $l = $m;
-    else $l = $nb_step3;
-    
-    $found = false;
-
-    for ($i=0; $i<$l; $i++) {
-
-        $res = $stmt->fetchObject();
-
-        if(!empty($res->society)){
-            $arr_contact_info = array($res->firstname,$res->lastname,'('.$res->society.')');
-        }else{
-            $arr_contact_info = array($res->firstname,$res->lastname);
-        }
-        $contact_info = implode(' ', $arr_contact_info);
-
-        if ($i%2==1) $color = 'LightYellow';
-        else $color = 'white';
-
-        echo "<li id='".$res->contact_id."' style='font-size:12px;background-color:$color;'><i class='fa fa-user fa-1x' style='padding:5px;display:table-cell;vertical-align:middle;' title='personne physique'></i> "
-                . '<span style="display:table-cell;vertical-align:middle;">' . str_replace($args, $args_bold, $contact_info) . '</span>'
-            ."</li>";
-    }*/
-    ///////////////////////
-
-    //STEP 3 : search with society(corporate contact)
-    /*$query = "SELECT contact_id, society FROM contacts_v2 WHERE is_corporate_person = 'Y' AND enabled = 'Y' AND (LOWER(translate(society,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) OR LOWER(translate(society_short,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))) ORDER BY society ASC";
-    $arrayPDO = array('%'.$_REQUEST['what'].'%','%'.$_REQUEST['what'].'%');
-    $stmt = $db->query($query, $arrayPDO);
-    $nb_step4 = $stmt->rowCount();
-    
-    $m = 30;
-    if ($nb_step4 >= $m) $l = $m;
-    else $l = $nb_step4;
-    
-    $found = false;
-
-    for ($i=0; $i<$l; $i++) {
-     
-        $res = $stmt->fetchObject();
-
-        if ($i%2==1) $color = 'LightYellow';
-        else $color = 'white';
-        echo "<li id='".$res->contact_id."' style='font-size:12px;background-color:$color;'><i class='fa fa-building fa-1x' style='padding:5px;display:table-cell;vertical-align:middle;' title='structure'></i> "
-                . '<span style="display:table-cell;vertical-align:middle;">'. str_replace($args, $args_bold, $res->society) .'</span>'
-            ."</li>";
-    }*/
-    ///////////////////////
-
-    //STEP 4 : search with other informations (physical contact)
-    /*$query = "SELECT contact_id,firstname,lastname,function FROM contacts_v2 WHERE is_corporate_person = 'N' AND enabled = 'Y'"
-            ." AND (LOWER(translate(firstname,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))"
-            ." OR LOWER(translate(function,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) LIKE LOWER(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')))  ORDER BY society,lastname,firstname ASC";
-    $arrayPDO = array('%'.$_REQUEST['what'].'%','%'.$_REQUEST['what'].'%');
-    $stmt = $db->query($query, $arrayPDO);
-    $nb_step5 = $stmt->rowCount();
-    
-    $m = 30;
-    if ($nb_step5 >= $m) $l = $m;
-    else $l = $nb_step5;
-    
-    $found = false;
-
-    for ($i=0; $i<$l; $i++) {
-
-        $res = $stmt->fetchObject();
-
-        if(!empty($res->society)){
-            $arr_contact_info = array($res->firstname,$res->lastname,'('.$res->society.')');
-        }else{
-            $arr_contact_info = array($res->firstname,$res->lastname);
-        }
-        $contact_info = implode(' ', $arr_contact_info);
-
-        if ($i%2==1) $color = 'LightYellow';
-        else $color = 'white';
-        echo "<li id='".$res->contact_id."' style='font-size:12px;background-color:$color;' title=''><i class='fa fa-user fa-1x' style='padding:5px;display:table-cell;vertical-align:middle;' title='personne physique'></i> "
-                . '<span style="display:table-cell;vertical-align:middle;">' . str_replace($args, $args_bold, $contact_info) . '</span>'
-            ."</li>";
-    }*/
-
-
-    ///////////////////////
-
-    if($nb_step1 == 0 && $nb_step2 == 0 && $nb_step3 == 0 && $nb_step4 == 0 && $nb_step5 == 0 && $nb_step6 == 0) echo "<li></li>";
-    echo "</ul>";
-    if($nb_step1 == 0 && $nb_step2 == 0 && $nb_step3 == 0 && $nb_step4 == 0 && $nb_step5 == 0 && $nb_step6 == 0){
-        $noResultContacts = true;
-    }
-
-    $nb_total = $nb_step1+$nb_step2+$nb_step3+$nb_step4+$nb_step5+$nb_step6;
-    if ($nb_step1 > $m || $nb_step2 > $m || $nb_step3 > $m || $nb_step4 > $m || $nb_step5 > $m || $nb_step6 > $m) echo "<p align='right' style='background-color:LemonChiffon;font-size:9px;font-style:italic;padding-right:5px;padding-bottom:0px;' title=\"La liste n'a pas pu être affichée intégralement, veuillez compléter votre recherche.\" >...".$nb_total." résulats au total</p>";
-
-    if($noResultContacts){
-        echo "<p align='left' style='background-color:LemonChiffon;text-align:center;color:grey;font-style:italic;padding-bottom:0px;' title=\"Aucun résultat trouvé, veuillez compléter votre recherche.\" >Aucun résultat trouvé.</p>";
-    }
\ No newline at end of file
diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_status.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_status.php
deleted file mode 100755
index 0e8b1bc7733..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_status.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/*
-*    Copyright 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  Enabled/disable a contact in the database
-*
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-$return = $core_tools->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $core_tools->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN;
-    ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php';</script>
-    <?php
-    exit();
-}
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$contact = new contacts_v2();
-
-if ($_GET['mode'] == "ban") {
-	$contact->contactEnabled($_GET['id'], "N");
-} else if ($_GET['mode'] == "allow") {
-	$contact->contactEnabled($_GET['id'], "Y");
-}
-
-?>
-
-<script>
-	window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=contacts_v2';
-</script>
-
-<?php
-
-exit();
\ No newline at end of file
diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up.php
deleted file mode 100755
index 41a108cee58..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up.php
+++ /dev/null
@@ -1,349 +0,0 @@
-<?php
-/*
-*    Copyright 2014 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  Form to modify a contact
-*
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-$return = $core_tools->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $core_tools->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN; ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl']; ?>index.php';</script>
-    <?php
-    exit();
-}
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$func = new functions();
-
-if (isset($_GET['id'])) {
-    $id = addslashes($func->wash($_GET['id'], "alphanum", _CONTACT));
-    $_SESSION['contact']['current_contact_id'] = $id;
-} elseif ($_SESSION['contact']['current_contact_id'] <> '') {
-    $id = $_SESSION['contact']['current_contact_id'];
-} else {
-    $id = "";
-}
-
- /****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") {
-    $init = true;
-}
-$level = "";
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) {
-    $level = $_REQUEST['level'];
-}
-$page_path  = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_up';
-$page_label = _MODIFICATION;
-$page_id    = "contacts_v2_up";
-$core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-
-if (isset($_REQUEST['fromContactTree'])) {
-    $_SESSION['fromContactTree'] = 'yes';
-}
-$contact = new contacts_v2();
-$contact->formcontact("up", $id);
-
-// GESTION DES ADDRESSES
-echo '<div>';
-echo '<h2><i class="fa fa-home fa-2x"></i> &nbsp;' . _MANAGE_CONTACT_ADDRESSES_IMG . '</h2>';
-require_once "core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_request.php";
-require_once "apps" . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_list_show.php";
-$func = new functions();
-
-$what = "";
-$where = "contact_id = :contactid ";
-$arrayPDO = array(":contactid" => $id);
-if (isset($_REQUEST['selectedObject']) && ! empty($_REQUEST['selectedObject'])) {
-    $where .= " and ca_id = :selectedObject ";
-    $arrayPDO = array_merge($arrayPDO, array(":selectedObject" => $_REQUEST['selectedObject']));
-} elseif (isset($_REQUEST['what2']) && ! empty($_REQUEST['what2'])) {
-    $what = str_replace("  ", "", $_REQUEST['what2']);
-    $what_table = explode(" ", $what);
-
-    foreach ($what_table as $key => $what_a) {
-        if (strlen($what_a) > 2) {
-            $sql_lastname[] = " lower(lastname) LIKE lower(:what_".$key.")";
-            $sql_firstname[] = " lower(firstname) LIKE lower(:what_".$key.")";
-            $sql_society[] = " lower(departement) LIKE lower(:what_".$key.")";
-            $sql_purpose[] = " lower(contact_purpose_label) LIKE lower(:what_".$key.")";
-            $arrayPDO = array_merge($arrayPDO, array(":what_".$key => $what_a."%"));
-        }
-    }
-    if ($sql_lastname <> "") {
-        $where .= " and (" . implode(' OR ', $sql_lastname) . " ";
-        $where .= " or " . implode(' OR ', $sql_firstname) . " ";
-        $where .= " or " . implode(' OR ', $sql_purpose) . " ";
-        $where .= " or " . implode(' OR ', $sql_society) . ") ";
-    }
-}
-
-$list = new list_show();
-$order = 'asc';
-if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
-    $order = trim($_REQUEST['order']);
-}
-$field = 'lastname';
-if (isset($_REQUEST['order_field']) && ! empty($_REQUEST['order_field']) && in_array($_REQUEST['order_field'], $select['view_contacts'])) {
-    $field = trim($_REQUEST['order_field']);
-}
-
-$orderstr = $list->define_order($order, $field);
-
-if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) {
-    $parameters .= '&start='.$_REQUEST['start'];
-} else {
-    $_REQUEST['start'] = 0;
-}
-
-$request = new request;
-$tab = $request->PDOselect(
-    $select,
-    $where,
-    $arrayPDO,
-    $orderstr,
-    $_SESSION['config']['databasetype'], "default", false, "", "", "", true, false, true, $_REQUEST['start']
-);
-if (!empty($tab)) {
-    for ($i = 0; $i < count($tab); $i ++) {
-        for ($j = 0; $j < count($tab[$i]); $j ++) {
-            foreach (array_keys($tab[$i][$j]) as $value) {
-                if ($tab[$i][$j][$value] == "id") {
-                    $tab[$i][$j]["id"]          = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       = _ID;
-                    $tab[$i][$j]["size"]        = "30";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"]       = "left";
-                    $tab[$i][$j]["valign"]      = "bottom";
-                    $tab[$i][$j]["show"]        = false;
-                    $tab[$i][$j]["order"]       = 'id';
-                }
-                if ($tab[$i][$j][$value] == "contact_id") {
-                    $tab[$i][$j]["contact_id"]  = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       = _ID;
-                    $tab[$i][$j]["size"]        = "30";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"]       = "left";
-                    $tab[$i][$j]["valign"]      = "bottom";
-                    $tab[$i][$j]["show"]        = false;
-                    $tab[$i][$j]["order"]       = 'contact_id';
-                }
-                if ($tab[$i][$j][$value] == "contact_purpose_id") {
-                    $tab[$i][$j]["value"]              = $contact->get_label_contact($tab[$i][$j]['value'], $_SESSION['tablename']['contact_purposes']);
-                    $tab[$i][$j]["contact_purpose_id"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]              = _CONTACT_PURPOSE;
-                    $tab[$i][$j]["size"]               = "20";
-                    $tab[$i][$j]["label_align"]        = "left";
-                    $tab[$i][$j]["align"]              = "left";
-                    $tab[$i][$j]["valign"]             = "bottom";
-                    $tab[$i][$j]["show"]               = true;
-                    $tab[$i][$j]["order"]              = 'contact_purpose_id';
-                }
-                if ($tab[$i][$j][$value] == "departement") {
-                    $tab[$i][$j]['value'] = $request->show_string(
-                        $tab[$i][$j]['value']
-                    );
-                    $tab[$i][$j]["departement"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       = _SERVICE;
-                    $tab[$i][$j]["size"]        = "20";
-                    $tab[$i][$j]["label_align"] = "left";
-                    $tab[$i][$j]["align"]       = "left";
-                    $tab[$i][$j]["valign"]      = "bottom";
-                    $tab[$i][$j]["show"]        = true;
-                    $tab[$i][$j]["order"]       = 'departement';
-                }
-
-                if ($tab[$i][$j][$value]=="lastname") {
-                    $tab[$i][$j]['value']       =$request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["lastname"]    =$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       =_LASTNAME;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="left";
-                    $tab[$i][$j]["align"]       ="left";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=true;
-                    } else {
-                        $tab[$i][$j]["show"]=false;
-                    }
-                    $tab[$i][$j]["order"]= "lastname";
-                }
-                if ($tab[$i][$j][$value]=="firstname") {
-                    $tab[$i][$j]["firstname"]   = $request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["label"]       =_FIRSTNAME;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="center";
-                    $tab[$i][$j]["align"]       ="center";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=true;
-                    } else {
-                        $tab[$i][$j]["show"]=false;
-                    }
-                    $tab[$i][$j]["order"]= "firstname";
-                }
-                if ($tab[$i][$j][$value]=="function") {
-                    $tab[$i][$j]['value']       =$request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["function"]    =$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       =_FUNCTION;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="left";
-                    $tab[$i][$j]["align"]       ="left";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=true;
-                    } else {
-                        $tab[$i][$j]["show"]=false;
-                    }
-                    $tab[$i][$j]["order"]= "function";
-                }
-                if ($tab[$i][$j][$value]=="address_num") {
-                    $address_num = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["show"]=false;
-                }
-                if ($tab[$i][$j][$value]=="address_street") {
-                    $tab[$i][$j]['value']          = $address_num . " " . $request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["address_street"] = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]          = _ADDRESS;
-                    $tab[$i][$j]["size"]           ="15";
-                    $tab[$i][$j]["label_align"]    ="left";
-                    $tab[$i][$j]["align"]          ="left";
-                    $tab[$i][$j]["valign"]         ="bottom";
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=false;
-                    } else {
-                        $tab[$i][$j]["show"]=true;
-                    }
-                    $tab[$i][$j]["order"]= "address_street";
-                }
-                if ($tab[$i][$j][$value]=="address_postal_code") {
-                    $tab[$i][$j]['value']               =$request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["address_postal_code"] =$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]               =_POSTAL_CODE;
-                    $tab[$i][$j]["size"]                ="15";
-                    $tab[$i][$j]["label_align"]         ="left";
-                    $tab[$i][$j]["align"]               ="left";
-                    $tab[$i][$j]["valign"]              ="bottom";
-                    if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == "Y") {
-                        $tab[$i][$j]["show"]=false;
-                    } else {
-                        $tab[$i][$j]["show"]=true;
-                    }
-                    $tab[$i][$j]["order"]= "address_postal_code";
-                }
-
-                if ($tab[$i][$j][$value]=="address_town") {
-                    $tab[$i][$j]["address_town"] = $request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["label"]        =_TOWN;
-                    $tab[$i][$j]["size"]         ="15";
-                    $tab[$i][$j]["label_align"]  ="center";
-                    $tab[$i][$j]["align"]        ="center";
-                    $tab[$i][$j]["valign"]       ="bottom";
-                    $tab[$i][$j]["show"]         =true;
-                    $tab[$i][$j]["order"]        = "address_town";
-                }
-                if ($tab[$i][$j][$value]=="phone") {
-                    $tab[$i][$j]['value']       =$request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["phone"]       =$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       =_PHONE;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="left";
-                    $tab[$i][$j]["align"]       ="left";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    $tab[$i][$j]["show"]        =true;
-                    $tab[$i][$j]["order"]       = "phone";
-                }
-                if ($tab[$i][$j][$value]=="email") {
-                    $tab[$i][$j]["email"]       = $request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["label"]       =_EMAIL;
-                    $tab[$i][$j]["size"]        ="15";
-                    $tab[$i][$j]["label_align"] ="center";
-                    $tab[$i][$j]["align"]       ="center";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    $tab[$i][$j]["show"]        =true;
-                    $tab[$i][$j]["order"]       = "email";
-                }
-                if ($tab[$i][$j][$value]=="enabled") {
-                    $tab[$i][$j]["enabled"]     = $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]       =_STATUS;
-                    $tab[$i][$j]["size"]        ="5";
-                    $tab[$i][$j]["label_align"] ="center";
-                    $tab[$i][$j]["align"]       ="center";
-                    $tab[$i][$j]["valign"]      ="bottom";
-                    $tab[$i][$j]["show"]        =true;
-                    $tab[$i][$j]["order"]       = "enabled";
-                }
-            }
-        }
-    }
-}
-
-$pageName    = "contact_addresses";
-$pageNameUp  = "contact_addresses_up";
-$pageNameAdd = "contact_addresses_add";
-$pageNameVal = "";
-$pageNameBan = "";
-
-if ($core_tools->test_admin('admin_contacts', 'apps', false)) {
-    $pageNameDel = "contact_addresses_del";
-    $pageNameBan = "contact_addresses_status&mode=ban";
-    $pageNameVal = "contact_addresses_status&mode=allow";
-}
-
-$tableName = $_SESSION['tablename']['contact_addresses'];
-$addLabel = _NEW_CONTACT_ADDRESS;
-$autoCompletionArray = array();
-$autoCompletionArray["list_script_url"] = $_SESSION['config']['businessappurl']
-    . "index.php?display=true&page=contact_addresses_list_by_name&idContact=".$id;
-$autoCompletionArray["number_to_begin"] = 1;
-$autoCompletionArray["searchBoxAutoCompletionUpdate"] = true;
-
-if ($_SESSION['origin']=='contacts_list') {
-    $_REQUEST['start']='';
-    $_SESSION['origin']='contact_up';
-}
-
-$list->admin_list(
-    $tab, $_SESSION['save_list']['full_count'], '',
-    'contact_id"', 'contacts_v2_up', 'contacts_v2',
-    'id', true, $pageNameUp, $pageNameVal, $pageNameBan,
-    $pageNameDel, $pageNameAdd, $addLabel, FALSE, FALSE, _ALL_CONTACT_ADDRESSES,
-    _A_CONTACT_ADDRESS, '', false, true, true, true,
-    $what, true, $autoCompletionArray, false, false, 'what2', 'whatListInput2'
-);
-
-$_SESSION['m_admin']['address'] = array();
-echo '</div>';
diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up_db.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up_db.php
deleted file mode 100755
index 207f893c428..00000000000
--- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up_db.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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  Modify the contact in the database after the form
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-$return = $core_tools->test_admin('admin_contacts', 'apps', false);
-if (!$return) {
-    $return = $core_tools->test_admin('create_contacts', 'apps', false);
-}
-
-if (!$return) {
-    $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN;
-    ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php';</script>
-    <?php
-    exit();
-}
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$contact = new contacts_v2();
-if(isset($_GET['confirm']) &&  $_GET['confirm'] <> ''){
-	$confirm = 'Y';
-	$_POST['mode'] = $_GET['mode'];
-} else {
-	$confirm = 'N';
-}
-?>
diff --git a/apps/maarch_entreprise/admin/contacts/fusionContact.php b/apps/maarch_entreprise/admin/contacts/fusionContact.php
deleted file mode 100755
index 4bf81e63db9..00000000000
--- a/apps/maarch_entreprise/admin/contacts/fusionContact.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-require_once('core/class/class_core_tools.php');
-$Core_Tools = new core_tools;
-$Core_Tools->load_lang();
-$db = new Database();
-$return = '';
-$status = 0;
-
-
-$master_contact_id = $_POST['master_contact_id'];
-$master_address_id = $_POST['master_address_id'];
-$contacts_id = explode(',', $_POST['slave_contact_id']);
-$del_address_id = explode(',', $_POST['del_address_id']);
-
-foreach ($contacts_id as $key => $value) {
-
-    //mise à jour des contacts courriers de type arrivé
-    $query = "UPDATE res_letterbox SET dest_contact_id = ? WHERE dest_contact_id = ?";
-    $arrayPDO = array($master_contact_id,$value);
-    $db->query($query, $arrayPDO);
-
-    //mise à jour des contacts courriers de type départ
-    $query = "UPDATE res_letterbox SET exp_contact_id = ? WHERE exp_contact_id = ?";
-    $arrayPDO = array($master_contact_id,$value);
-    $db->query($query, $arrayPDO);
-
-    //mise à jour des pièces jointes
-    $query = "UPDATE res_attachments SET dest_contact_id = ? WHERE dest_contact_id = ?";
-    $arrayPDO = array($master_contact_id,$value);
-    $db->query($query, $arrayPDO);
-
-    //deplace adresse au master
-    $query = "UPDATE contact_addresses SET contact_id = ? WHERE contact_id = ?";
-    $arrayPDO = array($master_contact_id,$value);
-    $db->query($query, $arrayPDO);
-
-    //supression du contact substitué
-    $query = "DELETE FROM contacts_v2 WHERE contact_id = ?";
-    $arrayPDO = array($value);
-    $db->query($query, $arrayPDO);
-}
-
-foreach ($del_address_id as $key => $value) {
-    if (!empty($value)) {
-        //mise à jour des adresses courriers de type arrivé
-        $query = "UPDATE res_letterbox SET address_id = ? WHERE address_id = ?";
-        $arrayPDO = array($master_address_id,$value);
-        $db->query($query, $arrayPDO);
-
-        //mise à jour des pièces jointes
-        $query = "UPDATE res_attachments SET dest_address_id = ? WHERE dest_address_id = ?";
-        $arrayPDO = array($master_address_id,$value);
-        $db->query($query, $arrayPDO);
-
-        //supression de l'adresse
-        $query = "DELETE FROM contact_addresses WHERE id = ?";
-        $arrayPDO = array($value);
-        $db->query($query, $arrayPDO);
-    }
-    
-}
-$return = 'OK';
-
-echo "{status : " . $status . ", toShow : '" . addslashes($return) . "'}";
-exit ();
diff --git a/apps/maarch_entreprise/admin/contacts/manage_duplicates.php b/apps/maarch_entreprise/admin/contacts/manage_duplicates.php
deleted file mode 100755
index a3b81a3bb53..00000000000
--- a/apps/maarch_entreprise/admin/contacts/manage_duplicates.php
+++ /dev/null
@@ -1,509 +0,0 @@
-<?php
-/*
-*   Copyright 2008-2013 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  manage contacts duplicates
- *
- *
- * @file
- * @author Laurent Giovannoni <dev@maarch.org>
- * @date $date$
- * @version $Revision$
- * @ingroup admin
- */
-
-require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-    . DIRECTORY_SEPARATOR  . 'class' . DIRECTORY_SEPARATOR
-    . 'class_business_app_tools.php';
-$admin = new core_tools();
-$admin->test_admin('admin_contacts', 'apps');
-$func = new functions();
-$db = new Database();
-
-$business = new business_app_tools();
-
-$_SESSION['m_admin'] = array();
-
-// ----------------------------------------------------
-
-$limit = 13;
-$offsetSoc = 0;
-if (isset($_POST["offsetSoc"])) {
-    $offsetSoc = $_POST["offsetSoc"];
-
-    if ($offsetSoc < 0) {
-        $offsetSoc = 0;
-    }
-}
-
-$offsetName = 0;
-if (isset($_POST["offsetName"])) {
-    $offsetName = $_POST["offsetName"];
-
-    if ($offsetName < 0) {
-        $offsetName = 0;
-    }
-}
-
-// ----------------------------------------------------
-
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") {
-    $init = true;
-}
-$level = "";
-if (
-    isset($_REQUEST['level'])
-    && (
-        $_REQUEST['level'] == 2
-        || $_REQUEST['level'] == 3
-        || $_REQUEST['level'] == 4
-        || $_REQUEST['level'] == 1
-    )
-) {
-    $level = $_REQUEST['level'];
-}
-$page_path = $_SESSION['config']['businessappurl']
-    . 'index.php?page=manage_duplicates&admin=contacts';
-$page_label = _MANAGE_DUPLICATES;
-$page_id = "manage_duplicates";
-$admin->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-$color = array('#254e7b','#5584b1','#85c1e5','#a2adc3');
-function randomColor($lastColor)
-{
-    if ($lastColor <> 0) {
-        $val = rand(0, $lastColor - 1);
-    } else {
-        $val = 3;
-    }
-    return $val;
-}
-
-echo '<h1><i class="fa fa-magic fa-2x"></i>&nbsp;'
-    . _MANAGE_DUPLICATES
-    . '</h1>';
-
-echo '<div id="inner_content">';
-echo '<div class="block" style="text-align:left;">';
-//TODO: ENABLE THIS FUNCTION FOR ALL COLLECTION USING CONTACTS
-
-//update NULL to ''
-$db->query("UPDATE contacts_v2 SET user_id='' WHERE user_id IS NULL");
-
-//duplicates by society
-$selectDuplicatesBySociety = "SELECT contact_id,
-       society,
-       lower(translate(society, 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                       'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr ')) as society_comp
-from contacts_v2
-WHERE is_corporate_person = 'Y'
-  AND
-      lower(translate(society, 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                      'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr ')) in (
-          SELECT lower(translate(society, 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                                 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr '))
-          FROM contacts_v2
-          where is_corporate_person = 'Y'
-          GROUP BY lower(translate(society, 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                                   'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr '))
-          HAVING Count(lower(translate(society, 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                                       'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr '))) > 1
-             and lower(translate(society, 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                                 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr ')) <> ''
-      )
-order by lower(society), contact_id";
-
-$htmlTabSoc = '<form name="manage_duplicate_society" action="#" onsubmit="return linkDuplicate(\'manage_duplicate_society\')" method="post">';
-$htmlTabSoc .= '<table style="width:100%;" id="duplicates_society">';
-$htmlTabSoc .= '<CAPTION>' . _DUPLICATES_BY_SOCIETY . '</CAPTION>';
-$htmlTabSoc .= '<thead style="display:block;">';
-$htmlTabSoc .= '<tr style="display:table;width:100%;">';
-
-$htmlTabSoc .= '<th style="width:7%;">&nbsp;</th>';
-$htmlTabSoc .= '<th style="width:8%;">' . _ID . '</th>';
-$htmlTabSoc .= '<th style="width:30%;">' . _STRUCTURE_ORGANISM . '</th>';
-$htmlTabSoc .= '<th style="width:40%;">' . _ADDRESS . '</th>';
-$htmlTabSoc .= '<th style="width:10%;">' . _ADDRESS_NB. '</th>';
-$htmlTabSoc .= '<th style="width:5%;">&nbsp;</th>';
-$htmlTabSoc .= '</tr>';
-$htmlTabSoc .= '</thead>';
-$htmlTabSoc .= '<tbody style="width:100%;display:block;height: 400px;overflow-y: auto;overflow-x: hidden;color:white;">';
-$tabSoc = array();
-$socCompare = '';
-$colorToUse = '';
-$colorNumber = '2';
-
-$stmt = $db->query($selectDuplicatesBySociety);
-
-// -------------------------------------
-$nbSoc = $stmt->rowCount();
-
-$lineDoublSocTab = [];
-while ($lineDoublSocTmp = $stmt->fetchObject()) {
-    $lineDoublSocTab[] = $lineDoublSocTmp;
-}
-
-
-// -------------------------------------
-$cptSoc = 0;
-$i = 0;
-
-for($cptLineDoublSoc = $offsetSoc; $cptLineDoublSoc < ($limit + $offsetSoc); $cptLineDoublSoc++) {
-    $lineDoublSoc = $lineDoublSocTab[$cptLineDoublSoc];
-
-    $stmt2 = $db->query("SELECT id,firstname,lastname,address_num,address_street,address_postal_code,address_town,email FROM contact_addresses WHERE contact_id = ?", array($lineDoublSoc->contact_id));
-    $res = $stmt2->fetchObject();
-
-    $nb_addresses = $stmt2->rowCount();
-    $arr_address = array($res->address_num,$res->address_street,$res->address_postal_code,$res->address_town);
-    $tmp_address = implode(' ', $arr_address);
-
-    if(!empty($res->firstname) || !empty($res->lastname) ){
-        $arr_address = array($res->firstname.' '.$res->lastname,$tmp_address);
-        $address = implode(', ', $arr_address);
-    }else{
-        $address = $tmp_address;
-    }
-
-    if(!empty($res->email)){
-        $address .= ' ('.$res->email.')';
-    }
-
-    if (empty(trim($address))) {
-        $address = '<i style="color:red;">adresse vide ...</i>';
-    }
-
-    if ($lineDoublSoc->contact_id <> ''/* && $result_address->id <> '' */) {
-        $cptSoc++;
-
-        if ($socCompare == $lineDoublSoc->society_comp) {
-            //echo 'doublon<br>';
-        } else {
-            $i++;
-            //echo 'new doublon<br>';
-            $class = 'duplicate_'.$i;
-            if ($colorToUse == 'LightYellow'){
-                $colorToUse = 'white';
-            }else{
-                $colorToUse = 'LightYellow';
-            }
-        }
-        $socCompare = $lineDoublSoc->society_comp;
-        $htmlTabSoc .= '<tr style="background-color: '.$colorToUse.';display:table;width:100%;color:#666;" id="tr_' . $lineDoublSoc->contact_id . '">';
-        $htmlTabSoc .= '<td style="width:7%;"><input type="checkbox" class="'.$class.'" title="contact à fusionner" id="fusion_id_'.$lineDoublSoc->contact_id.'" name="slave_'.$class.'" value="'.$lineDoublSoc->contact_id.'" onclick="checkOthersDuplicate(\'manage_duplicate_society\',\'slave_'.$class.'\',\'master_'.$class.'\');" /> <input type="radio" title="contact maître servant de fusion" id="master_fusion_id_'.$lineDoublSoc->contact_id.'" name="master_'.$class.'" value="'.$lineDoublSoc->contact_id.'"/><input type="hidden" id="master_address_fusion_id_'.$lineDoublSoc->contact_id.'" name="master_address_'.$class.'" value="'.$res->id.'"/> <input type="checkbox" class="'.$class.'" id="delete_contact_id_'.$res->id.'" name="delete_address" title="supprimer l\'adresse" value="'.$res->id.'"/></td>';
-        $htmlTabSoc .= '<td style="width:8%;">' . $lineDoublSoc->contact_id . '</td>';
-        $htmlTabSoc .= '<td style="width:30%;">' . $lineDoublSoc->society . '</td>';
-        $htmlTabSoc .= '<td style="width:40%;">' . $address . '</td>';
-        $htmlTabSoc .= '<td style="width:10%;">' . $nb_addresses.' adresse(s) au total ...</td>';
-        $htmlTabSoc .= '<td style="width:5%;"><i onclick="loadDocList('
-            . $lineDoublSoc->contact_id . ');" class="fa fa-search fa-2x" title="'._IS_ATTACHED_TO_DOC.'" title="'
-            . _IS_ATTACHED_TO_DOC . '" style="cursor: pointer;"></i></td>';
-        $htmlTabSoc .= '</tr>';
-        $htmlTabSoc .= '<tr id="docList_' . $lineDoublSoc->contact_id
-            . '" name="docList_' . $lineDoublSoc->contact_id
-            . '" style="display: none; width:100%;border-bottom: solid 1px black; '
-            . 'background-color: #FFF;">';
-        $htmlTabSoc .= '<td style="background-color: white;" colspan="9">';
-        $htmlTabSoc .= '<div id="divDocList_' . $lineDoublSoc->contact_id
-            . '" align="center" style="color: grey;" width="100%">';
-        $htmlTabSoc .= '<img width="10%" style="background-color: white; '
-            . 'margin: 0; padding: 0;" src="static.php?filename=loading_big.gif">';
-        $htmlTabSoc .= '</div>';
-        $htmlTabSoc .= '</td>';
-        $htmlTabSoc .= '</tr>';
-    }
-    $comp_society = $lineDoublSoc->contact_id;
-}
-
-$htmlTabSoc .= '</tbody>';
-//$func->show_array($tabSoc);
-$htmlTabSoc .= '</table>';
-$htmlTabSoc .= '<style>#duplicates_society tbody tr:hover{opacity:0.5 !important;}</style>';
-$htmlTabSoc .= '<input type="submit" value="fusionner!" class="button"/>';
-$htmlTabSoc .= '</form>';
-
-
-// -----------------------------------------------------------
-
-$htmlNavigationButtonsSoc = '<div style="display: inline; float: right; margin-top: -15px">';
-if ($offsetSoc >= $limit) {
-    $htmlNavigationButtonsSoc .= '<form style="display: inline" method="post" action="#">';
-
-    $htmlNavigationButtonsSoc .= '<input type="hidden" name="offsetName" value="' . $offsetName . '"/>';
-    $htmlNavigationButtonsSoc .= '<input type="hidden" name="offsetSoc" value="0"/>';
-    $htmlNavigationButtonsSoc .= '<input type="submit" value="Première page" class="button"/>';
-
-    $htmlNavigationButtonsSoc .= '</form>';
-
-    $htmlNavigationButtonsSoc .= '<form style="display: inline; margin-left: 10px" method="post" action="#">';
-
-    $htmlNavigationButtonsSoc .= '<input type="hidden" name="offsetName" value="' . $offsetName . '"/>';
-    $htmlNavigationButtonsSoc .= '<input type="hidden" name="offsetSoc" value="' . ($offsetSoc - $limit) . '"/>';
-    $htmlNavigationButtonsSoc .= '<input type="submit" value="Précédent" class="button"/>';
-
-    $htmlNavigationButtonsSoc .= '</form>';
-}
-
-$htmlNavigationButtonsSoc .= '<p style="display: inline; margin-right: 20px; margin-left: 20px">Résultat(s) ' . ($offsetSoc + 1). ' à ' . ($offsetSoc + $limit) . ' / ' . $nbSoc . '</p>';
-
-if ($offsetSoc + $limit < $nbSoc) {
-    $htmlNavigationButtonsSoc .= '<form style="display: inline; margin-right: 10px" method="post" action="#">';
-
-    $htmlNavigationButtonsSoc .= '<input type="hidden" name="offsetName" value="' . $offsetName . '"/>';
-    $htmlNavigationButtonsSoc .= '<input type="hidden" name="offsetSoc" value="' . ($offsetSoc + $limit) . '"/>';
-    $htmlNavigationButtonsSoc .= '<input type="submit" value="Suivant" class="button"/>';
-
-    $htmlNavigationButtonsSoc .= '</form>';
-
-    $htmlNavigationButtonsSoc .= '<form style="display: inline" method="post" action="#">';
-
-    $htmlNavigationButtonsSoc .= '<input type="hidden" name="offsetName" value="' . $offsetName . '"/>';
-    $htmlNavigationButtonsSoc .= '<input type="hidden" name="offsetSoc" value="' . ($nbSoc - $limit) . '"/>';
-    $htmlNavigationButtonsSoc .= '<input type="submit" value="Dernière page" class="button"/>';
-
-    $htmlNavigationButtonsSoc .= '</form>';
-}
-$htmlNavigationButtonsSoc .= '</div>';
-
-// -----------------------------------------------------------
-
-if ($cptSoc == 0) {
-    echo _NO_SOCIETY_DUPLICATES . '<br>';
-} else {
-    echo $htmlTabSoc;
-
-    echo $htmlNavigationButtonsSoc;
-}
-?><br><?php
-/***********************************************************************/
-//duplicates by name
-
-$selectDuplicatesByName = "SELECT distinct contacts_v2.contact_id,
-                      lower(translate(contacts_v2.lastname || ' ' || contacts_v2.firstname,
-                                      'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                                      'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr '))         as lastname_firstname,
-                      society,
-                      society_short,
-                      is_corporate_person,
-                      contacts_v2.lastname,
-                      contacts_v2.firstname,
-                      contacts_v2.title,
-                      (select count(*)
-                       from contact_addresses as ca2
-                       where ca2.contact_id = contacts_v2.contact_id)                                               as nb_addresses,
-                      (select id from contact_addresses where contact_addresses.contact_id = contacts_v2.contact_id LIMIT 1),
-                      (select address_num from contact_addresses where contact_addresses.contact_id = contacts_v2.contact_id LIMIT 1),
-                      (select address_street from contact_addresses where contact_addresses.contact_id = contacts_v2.contact_id LIMIT 1),
-                      (select address_postal_code from contact_addresses where contact_addresses.contact_id = contacts_v2.contact_id LIMIT 1),
-                      (select address_town from contact_addresses where contact_addresses.contact_id = contacts_v2.contact_id LIMIT 1),
-                      (select email from contact_addresses where contact_addresses.contact_id = contacts_v2.contact_id LIMIT 1)
-      from contacts_v2
-      WHERE lower(translate(contacts_v2.lastname || ' ' || contacts_v2.firstname,
-                            'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                            'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr ')) in (
-                SELECT lower(translate(contacts_v2.lastname || ' ' || contacts_v2.firstname,
-                                       'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                                       'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr ')) as lastname_firstname
-                FROM contacts_v2
-                GROUP BY lastname_firstname
-                HAVING Count(lower(translate(contacts_v2.lastname || ' ' || contacts_v2.firstname,
-                                             'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                                             'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr '))) >
-                       1
-                   and lower(translate(contacts_v2.lastname || ' ' || contacts_v2.firstname,
-                                       'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                                       'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr ')) <>
-                       ' ')
-      order by lower(translate(contacts_v2.lastname || ' ' || contacts_v2.firstname,
-                               'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ-',
-                               'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr ')),
-               contacts_v2.contact_id";
-
-$htmlTabName = '<form name="manage_duplicate_person" action="#" onsubmit="return linkDuplicate(\'manage_duplicate_person\')" method="post">';
-$htmlTabName .= '<table style="width:100%;">';
-$htmlTabName .= '<CAPTION>' . _DUPLICATES_BY_NAME . '</CAPTION>';
-$htmlTabName .= '<thead style="display:block;">';
-$htmlTabName .= '<tr style="display:table;width:100%;">';
-$htmlTabName .= '<th style="width:10%;">&nbsp;</th>';
-$htmlTabName .= '<th style="width:5%;">' . _ID . '</th>';
-$htmlTabName .= '<th style="width:10%;">' . _TITLE2 . '</th>';
-$htmlTabName .= '<th style="width:15%;">' . _LASTNAME . '</th>';
-$htmlTabName .= '<th style="width:15%;">' . _FIRSTNAME . '</th>';
-$htmlTabName .= '<th style="width:30%;">' . _ADDRESS.' </th>';
-$htmlTabName .= '<th style="width:10%;">' . _ADDRESS_NB.' </th>';
-$htmlTabName .= '<th style="width:5%;">&nbsp;</th>';
-$htmlTabName .= '</tr>';
-$htmlTabName .= '</thead>';
-$htmlTabName .= '<tbody style="width:100%;display:block;height: 400px;overflow-y: auto;overflow-x: hidden;color:white;">';
-$tabName = array();
-$nameCompare = '';
-$colorToUse = '';
-$colorNumber = '2';
-
-$stmt = $db->query($selectDuplicatesByName);
-
-// -------------------------------------
-$nbName = $stmt->rowCount();
-
-$lineDoublNameTab = [];
-while ($lineDoublNameTmp = $stmt->fetchObject()) {
-    $lineDoublNameTab[] = $lineDoublNameTmp;
-}
-
-// -------------------------------------
-
-$cptName = 0;
-$i++;
-
-for ($cptLineDoublName = $offsetName; $cptLineDoublName < ($limit + $offsetName); $cptLineDoublName++) {
-    $lineDoublName = $lineDoublNameTab[$cptLineDoublName];
-
-    $nb_addresses = $lineDoublName->nb_addresses;
-
-    $address = $lineDoublName->address_num . ' ' . $lineDoublName->address_street . ' ' . $lineDoublName->address_postal_code . ' ' . $lineDoublName->address_town;
-
-    if(!empty($lineDoublName->email)){
-        $address .= ' ('.$lineDoublName->email.')';
-    }
-
-    if (empty(trim($address))) {
-        $address = '<i style="color:red;">adresse vide ...</i>';
-    }
-    if ($lineDoublName->contact_id <> '') {
-        $cptName++;
-
-//        if ($nameCompare == $lineDoublName->lastname_firstname) {
-//            echo 'doublon<br>';
-//        } else {
-        if ($nameCompare != $lineDoublName->lastname_firstname) {
-            //echo 'new doublon<br>';
-            $i++;
-            $class = 'duplicate_person_'.$i;
-            if ($colorToUse == 'LightYellow'){
-                $colorToUse = 'white';
-            }else{
-                $colorToUse = 'LightYellow';
-            }
-        }
-
-        $corporatePeople = ($lineDoublName->is_corporate_person == "Y")? _YES : _NO;
-
-        $nameCompare = $lineDoublName->lastname_firstname;
-        $htmlTabName .= '<tr style="background-color: '.$colorToUse.';display:table;width:100%;color:#666;" id="tr_' . $lineDoublName->contact_id . '">';
-        $htmlTabName .= '<td style="width:10%;"><input type="checkbox" class="'.$class.'" id="fusion_id_'.$lineDoublName->contact_id.'" name="slave_'.$class.'" title="contact à fusionner" value="'.$lineDoublName->contact_id.'" onclick="checkOthersDuplicate(\'manage_duplicate_person\',\'slave_'.$class.'\',\'master_'.$class.'\');"/> <input type="radio" id="master_fusion_id_'.$lineDoublName->contact_id.'" name="master_'.$class.'" title="contact maître servant de fusion" value="'.$lineDoublName->contact_id.'"/> <input type="hidden" id="master_address_fusion_id_'.$lineDoublName->contact_id.'" name="master_address_'.$class.'" value="'.$lineDoublName->id.'"/> <input type="checkbox" class="'.$class.'" id="delete_contact_id_'.$lineDoublName->id.'" name="delete_address" title="supprimer l\'adresse" value="'.$lineDoublName->id.'"/></td>';
-        $htmlTabName .= '<td style="width:5%;">' . $lineDoublName->contact_id . '</td>';
-        $htmlTabName .= '<td style="width:10%;">' . $business->get_label_title($lineDoublName->title) . '</td>';
-        $htmlTabName .= '<td style="width:15%;">' . $lineDoublName->lastname . '</td>';
-        $htmlTabName .= '<td style="width:15%;">' . $lineDoublName->firstname . '</td>';
-        $htmlTabName .= '<td style="width:30%;">' . $address . '</td>';
-        $htmlTabName .= '<td style="width:10%;">' . $nb_addresses.' adresse(s) au total ...</td>';
-        $htmlTabName .= '<td style="width:5%;"><i onclick="loadDocList('
-            . $lineDoublName->contact_id . ');" class="fa fa-search fa-2x" title="'._IS_ATTACHED_TO_DOC.'" title="'
-            . _IS_ATTACHED_TO_DOC . '" style="cursor: pointer;"></i></td>';
-        $htmlTabName .= '</tr>';
-        $htmlTabName .= '<tr id="deleteContactDiv_' . $lineDoublName->contact_id
-            . '" name="deleteContactDiv_' . $lineDoublName->contact_id
-            . '" style="display: none; border-bottom: solid 1px black; '
-            . 'background-color: #FFF;">';
-        $htmlTabName .= '<td style="background-color: white;" colspan="10">';
-        $htmlTabName .= '<div id="divDeleteContact_' . $lineDoublName->contact_id
-            . '" align="center" style="color: grey;" width="100%">';
-        $htmlTabName .= '<img width="10%" style="background-color: white; '
-            . 'margin: 0; padding: 0;" src="static.php?filename=loading_big.gif">';
-        $htmlTabName .= '</div>';
-        $htmlTabName .= '</td>';
-        $htmlTabName .= '</tr>';
-        $htmlTabName .= '<tr id="docList_' . $lineDoublName->contact_id
-            . '" name="docList_' . $lineDoublName->contact_id
-            . '" style="display: none; border-bottom: solid 1px black; '
-            . 'background-color: #FFF;">';
-        $htmlTabName .= '<td style="background-color: white;" colspan="10">';
-        $htmlTabName .= '<div id="divDocList_' . $lineDoublName->contact_id
-            . '" align="center" style="color: grey;" width="100%">';
-        $htmlTabName .= '<img width="10%" style="background-color: white; '
-            . 'margin: 0; padding: 0;" src="static.php?filename=loading_big.gif">';
-        $htmlTabName .= '</div>';
-        $htmlTabName .= '</td>';
-        $htmlTabName .= '</tr>';
-    }
-}
-
-$htmlTabName .= '</tbody>';
-//$func->show_array($tabName);
-$htmlTabName .= '</table>';
-$htmlTabName .= '<input type="submit" value="fusionner!" class="button"/>';
-$htmlTabName .= '</form>';
-
-// -----------------------------------------------------------
-
-$htmlNavigationButtonsName = '<div style="display: inline; float: right; margin-top: -15px">';
-if ($offsetName >= $limit) {
-    $htmlNavigationButtonsName .= '<form style="display: inline" method="post" action="#">';
-
-    $htmlNavigationButtonsName .= '<input type="hidden" name="offsetSoc" value="' . $offsetSoc . '"/>';
-    $htmlNavigationButtonsName .= '<input type="hidden" name="offsetName" value="0"/>';
-    $htmlNavigationButtonsName .= '<input type="submit" value="Première page" class="button"/>';
-
-    $htmlNavigationButtonsName .= '</form>';
-
-    $htmlNavigationButtonsName .= '<form style="display: inline; margin-left: 10px" method="post" action="#">';
-
-    $htmlNavigationButtonsName .= '<input type="hidden" name="offsetSoc" value="' . $offsetSoc . '"/>';
-    $htmlNavigationButtonsName .= '<input type="hidden" name="offsetName" value="' . ($offsetName - $limit) . '"/>';
-    $htmlNavigationButtonsName .= '<input type="submit" value="Précédent" class="button"/>';
-
-    $htmlNavigationButtonsName .= '</form>';
-}
-
-$htmlNavigationButtonsName .= '<p style="display: inline; margin-right: 20px; margin-left: 20px">Résultat(s) ' . ($offsetName + 1). ' à ' . ($offsetName + $limit) . ' / ' . $nbName . '</p>';
-
-
-if ($offsetName + $limit < $nbName) {
-    $htmlNavigationButtonsName .= '<form style="display: inline; margin-right: 10px" method="post" action="#">';
-    $htmlNavigationButtonsName .= '<input type="hidden" name="offsetSoc" value="' . $offsetSoc . '"/>';
-    $htmlNavigationButtonsName .= '<input type="hidden" name="offsetName" value="' . ($offsetName + $limit) . '"/>';
-    $htmlNavigationButtonsName .= '<input type="submit" value="Suivant" class="button"/>';
-
-    $htmlNavigationButtonsName .= '</form>';
-
-    $htmlNavigationButtonsName .= '<form style="display: inline" method="post" action="#">';
-
-    $htmlNavigationButtonsName .= '<input type="hidden" name="offsetSoc" value="' . $offsetSoc . '"/>';
-    $htmlNavigationButtonsName .= '<input type="hidden" name="offsetName" value="' . ($nbName - $limit) . '"/>';
-    $htmlNavigationButtonsName .= '<input type="submit" value="Dernière page" class="button"/>';
-
-    $htmlNavigationButtonsName .= '</form>';
-}
-$htmlNavigationButtonsName .= '</div>';
-
-// -----------------------------------------------------------
-if ($cptName == 0) {
-    echo '<hr/>';
-    echo _NO_NAME_DUPLICATES . '<br>';
-} else {
-    echo $htmlTabName;
-
-    echo $htmlNavigationButtonsName;
-}
-echo '</div>';
-echo '</div>';
-
diff --git a/apps/maarch_entreprise/admin/export_admin_list.php b/apps/maarch_entreprise/admin/export_admin_list.php
deleted file mode 100755
index b685a0ddec6..00000000000
--- a/apps/maarch_entreprise/admin/export_admin_list.php
+++ /dev/null
@@ -1,138 +0,0 @@
-<?php
-/*
-*    Copyright 2008-2014 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  export contacts
-*
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR  . 'class' . DIRECTORY_SEPARATOR . 'class_business_app_tools.php';
-$business = new business_app_tools();
-$contact = new contacts_v2();
-$core_tools = new core_tools();
-$core_tools->load_lang();
-
-$request= new request;
-$tab_export = $request->PDOselect($_SESSION['export_admin_list']['select'], $_SESSION['export_admin_list']['where'],
-									$_SESSION['export_admin_list']['aPDO'],$_SESSION['export_admin_list']['order'],
-									$_SESSION['config']['databasetype'], 20000);
-unset($_SESSION['export_admin_list']);
-
-$fp = fopen($_SESSION['config']['tmppath'].'contact_list'.$_SESSION['user']['UserId'].'.csv', 'w');
-
-$list_row = array();
-$list_address = array();
-$list_header = array();
-$db = new Database();
-
-$header_done = false;
-
-$nb_colum = count($tab_export[0]);
-
-for ($i_export=0;$i_export<count($tab_export);$i_export++){
-    for ($j_export=0;$j_export<$nb_colum;$j_export++){
-    	if($tab_export[$i_export][$j_export]['column'] <> _ID){
-	    	if ($i_export==0) {
-	    		array_push($list_header, mb_strtoupper($tab_export[$i_export][$j_export]['column'], 'UTF-8'));
-	    	}
-			if($tab_export[$i_export][$j_export]['column'] == _CONTACT_TYPE){
-				array_push($list_row, $contact->get_label_contact(($tab_export[$i_export][$j_export]['value']),$_SESSION['tablename']['contact_types']));
-			} else if($tab_export[$i_export][$j_export]['column'] == _IS_CORPORATE_PERSON){
-				if($tab_export[$i_export][$j_export]['value'] == 'Y'){
-					array_push($list_row, _YES);
-				} else {
-					array_push($list_row, _NO);
-				}
-			} else {
-				array_push($list_row, $tab_export[$i_export][$j_export]['value']);
-			}
-		}
-    }
-
-    $stmt = $db->query("SELECT * FROM contact_addresses WHERE contact_id = ? ", array($tab_export[$i_export][0]['value']));
-
-    if ($stmt->rowCount()>0) {
-	    while($address = $stmt->fetchObject()){
-	    	if ($i_export==0) {
-	    		array_push($list_header, mb_strtoupper(html_entity_decode(_CONTACT_PURPOSE), 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(html_entity_decode(_SERVICE), 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(html_entity_decode(_FIRSTNAME), 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(_LASTNAME, 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(html_entity_decode(_TITLE2), 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(_FUNCTION, 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(_OCCUPANCY, 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(html_entity_decode(_NUM), 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(_STREET, 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(html_entity_decode(_COMPLEMENT), 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(_TOWN, 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(_COUNTRY, 'UTF-8'));
-    			array_push($list_header, mb_strtoupper(html_entity_decode(_PHONE), 'UTF-8'));
-	    		array_push($list_header, mb_strtoupper(_MAIL, 'UTF-8'));
-	    	}
-
-	    	$list_address = $list_row;
-	    	array_push($list_address, $contact->get_label_contact($address->contact_purpose_id,$_SESSION['tablename']['contact_purposes']));
-	    	array_push($list_address, $address->departement);
-	    	array_push($list_address, $address->firstname);
-	    	array_push($list_address, $address->lastname);
-	    	array_push($list_address, $business->get_label_title($address->title));
-	    	array_push($list_address, $address->function);
-	    	array_push($list_address, $address->occupancy);
-	    	array_push($list_address, $address->address_num);
-	    	array_push($list_address, $address->address_street);
-	    	array_push($list_address, $address->address_complement);
-	    	array_push($list_address, $address->address_town);
-	    	array_push($list_address, $address->address_country);
-	    	array_push($list_address, $address->phone);
-	    	array_push($list_address, $address->email);
-
-			if ($i_export==0 && $header_done == false) {
-				fputcsv($fp, $list_header, ';', '"');
-				$header_done = true;
-			}
-	    	fputcsv($fp, $list_address, ';', '"');
-    		$list_address = array();
-	    }
-    } else {
-		if ($i_export==0) {
-			fputcsv($fp, $list_header, ';', '"');
-		}
-    	fputcsv($fp, $list_row, ';', '"');    	
-    }
-
-    $list_row = array();
-}
-
-fclose($fp);
-header('Pragma: public');
-header('Expires: 0');
-header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-header('Content-Type: application/vnd.ms-excel; charset=utf-8');
-header('Content-Disposition: inline; filename=contact_list'.$_SESSION['user']['UserId'].'.csv;');
-readfile($_SESSION['config']['tmppath'].'contact_list'.$_SESSION['user']['UserId'].'.csv');
-exit;
\ No newline at end of file
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 12b4f1d9648..bcb144c0e70 100755
--- a/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php
+++ b/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php
@@ -122,11 +122,6 @@ abstract class business_app_tools_Abstract extends Database
             $_SESSION['tablename']['doctypes_second_level'] = (string) $tablename->doctypes_second_level;
             $_SESSION['tablename']['doctypes_indexes']      = (string) $tablename->doctypes_indexes;
             $_SESSION['tablename']['saved_queries']         = (string) $tablename->saved_queries;
-            $_SESSION['tablename']['contacts_v2']           = (string) $tablename->contacts_v2;
-            $_SESSION['tablename']['contact_types']         = (string) $tablename->contact_types;
-            $_SESSION['tablename']['contact_purposes']      = (string) $tablename->contact_purposes;
-            $_SESSION['tablename']['contact_addresses']     = (string) $tablename->contact_addresses;
-            $_SESSION['tablename']['contact_communication'] = 'contact_communication';
             $_SESSION['tablename']['tags']                  = (string) $tablename->tags;
             
             $_SESSION['config']['tmppath'] = \SrcCore\models\CoreConfigModel::getTmpPath();
@@ -241,15 +236,6 @@ abstract class business_app_tools_Abstract extends Database
             $_SESSION['history']['docserverstypesdel']       = (string) $history->docserverstypesdel;
             $_SESSION['history']['docserverstypesallow']     = (string) $history->docserverstypesallow;
             $_SESSION['history']['docserverstypesban']       = (string) $history->docserverstypesban;
-            $_SESSION['history']['contact_types_del']        = (string) $history->contact_types_del;
-            $_SESSION['history']['contact_types_add']        = (string) $history->contact_types_add;
-            $_SESSION['history']['contact_types_up']         = (string) $history->contact_types_up;
-            $_SESSION['history']['contact_purposes_del']     = (string) $history->contact_purposes_del;
-            $_SESSION['history']['contact_purposes_add']     = (string) $history->contact_purposes_add;
-            $_SESSION['history']['contact_purposes_up']      = (string) $history->contact_purposes_up;
-            $_SESSION['history']['contact_addresses_del']    = (string) $history->contact_addresses_del;
-            $_SESSION['history']['contact_addresses_add']    = (string) $history->contact_addresses_add;
-            $_SESSION['history']['contact_addresses_up']     = (string) $history->contact_addresses_up;
             $_SESSION['history_keywords'] = array();
             foreach ($xmlconfig->KEYWORDS as $keyword) {
                 $tmp = (string) $keyword->label;
@@ -626,146 +612,6 @@ abstract class business_app_tools_Abstract extends Database
         $this->_loadListsConfig();
     }
 
-    /**
-    * Return a specific path or false
-    *
-    */
-    public function insert_app_page($name)
-    {
-        if (! isset($name) || empty($name)) {
-            return false;
-        }
-        if ($name == 'contact_types' || $name == 'contact_types_list_by_name'
-            || $name == 'contact_types_up' || $name == 'contact_types_del'
-        ) {
-            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-                  . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR
-                  . 'contacts' . DIRECTORY_SEPARATOR . 'contact_types'
-                  . DIRECTORY_SEPARATOR . $name . '.php';
-            return $path;
-        } else if ($name == 'contact_purposes' || $name == 'contact_purposes_list_by_name'
-            || $name == 'contact_purposes_up' || $name == 'contact_purposes_del'
-        ) {
-            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-                  . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR
-                  . 'contacts' . DIRECTORY_SEPARATOR . 'contact_purposes'
-                  . DIRECTORY_SEPARATOR . $name . '.php';
-            return $path;
-        } else if ($name == 'contacts_v2' || $name == 'contacts_v2_list_by_name'
-            || $name == 'contacts_v2_up' || $name == 'contacts_v2_del' || $name == 'contacts_v2_add'
-            || $name == 'contacts_v2_up_db' || $name == 'contacts_v2_confirm' || $name == 'contacts_v2_status'
-        ) {
-            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-                  . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR
-                  . 'contacts' . DIRECTORY_SEPARATOR . 'contacts_v2'
-                  . DIRECTORY_SEPARATOR . $name . '.php';
-            return $path;
-        } else if ($name == 'contact_addresses' || $name == 'contact_addresses_list_by_name'
-            || $name == 'contact_addresses_up' || $name == 'contact_addresses_del' || $name == 'contact_addresses_add'
-            || $name == 'contact_addresses_up_db' || $name == 'contact_addresses_list' || $name == 'contact_addresses_status'
-        ) {
-            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-                  . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR
-                  . 'contacts' . DIRECTORY_SEPARATOR . 'contact_addresses'
-                  . DIRECTORY_SEPARATOR . $name . '.php';
-            return $path;
-        } else if ($name == 'view_tree_contacts' || $name == 'show_tree_contacts' || $name == 'get_tree_children_contact') {
-            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-                  . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR
-                  . 'contacts' . DIRECTORY_SEPARATOR . 'contact_tree'
-                  . DIRECTORY_SEPARATOR . $name . '.php';
-            return $path;
-        } else {
-            return false;
-        }
-    }
-
-    public function get_titles()
-    {
-        $core = new core_tools();
-        if (file_exists(
-            $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
-            . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps'
-            . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-            . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR
-            . 'entreprise.xml'
-        )
-        ) {
-            $path = $_SESSION['config']['corepath'] . 'custom'
-                  . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
-                  . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR
-                  . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml'
-                  . DIRECTORY_SEPARATOR . 'entreprise.xml';
-        } else {
-            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-                  . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR
-                  . 'entreprise.xml';
-        }
-        $xmlfile = simplexml_load_file($path);
-        $langPath = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-                  . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR
-                  . $_SESSION['config']['lang'] . '.php';
-
-        $resTitles = array();
-        $titles = $xmlfile->titles;
-        foreach ($titles->title as $title ) {
-            $label = (string) $title->label;
-            if (!empty($label) && defined($label)
-                && constant($label) <> NULL
-            ) {
-                $label = constant($label);
-            }
-
-            $resTitles[(string) $title->id] = $label;
-        }
-
-        asort($resTitles, SORT_LOCALE_STRING);
-        $defaultTitle = (string) $titles->default_title;
-        return array('titles' => $resTitles, 'default_title' => $defaultTitle);
-    }
-
-
-    public function get_label_title($titleId)
-    {
-        $core = new core_tools();
-        if (file_exists(
-            $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
-            . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps'
-            . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-            . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR
-            . 'entreprise.xml'
-        )
-        ) {
-            $path = $_SESSION['config']['corepath'] . 'custom'
-                  . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
-                  . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR
-                  . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR .'xml'
-                  . DIRECTORY_SEPARATOR . 'entreprise.xml';
-        } else {
-            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-            . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR
-            . 'entreprise.xml';
-        }
-        $xmlfile = simplexml_load_file($path);
-        $langPath = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
-                  . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR
-                  . $_SESSION['config']['lang'] . '.php';
-        $titles = $xmlfile->titles;
-        foreach ($titles->title as $title ) {
-            if ($titleId == (string) $title->id) {
-                $label = (string) $title->label;
-                if (!empty($label) && defined($label)
-                    && constant($label) <> NULL
-                ) {
-                    $label = constant($label);
-                }
-
-                return $label;
-            }
-        }
-        return '';
-    }
-    
     protected function _loadListsConfig() {
 
         if (file_exists(
diff --git a/apps/maarch_entreprise/class/class_contacts_v2.php b/apps/maarch_entreprise/class/class_contacts_v2.php
deleted file mode 100755
index d59a8ca4b0c..00000000000
--- a/apps/maarch_entreprise/class/class_contacts_v2.php
+++ /dev/null
@@ -1,37 +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 Contains functions to manage contacts
-*
-*
-* @file
-* @date $date$
-* @version $Revision$
-* @ingroup apps
-*/
-
-require_once 'apps/'. $_SESSION['config']['app_id'] .'/class/class_contacts_v2_Abstract.php';
-
-class contacts_v2 extends contacts_v2_Abstract
-{
-    // custom
-}
diff --git a/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php b/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php
deleted file mode 100755
index 63d648d9b89..00000000000
--- a/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php
+++ /dev/null
@@ -1,2960 +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 Contains functions to manage contacts
- *
- *
- * @file
- * @date $date$
- *
- * @version $Revision$
- * @ingroup apps
- */
-abstract class contacts_v2_Abstract extends Database
-{
-    /**
-     * Return the contacts data in sessions vars.
-     *
-     * @param string $mode add or up
-     */
-    public function contactinfo($mode)
-    {
-        //  return the user information in sessions vars
-        $func = new functions();
-        $_SESSION['m_admin']['contact']['IS_EXTERNAL_CONTACT'] = 'N';
-
-        $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] =
-        $_REQUEST['is_corporate'];
-        $controlTarget = "SELECT id FROM contact_types WHERE contact_target = ? or contact_target = 'both' or contact_target is null";
-        $db = new Database();
-        if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') {
-            $stmt = $db->query($controlTarget, array('corporate'));
-            if ($stmt->rowCount() == 0) {
-                $_SESSION['error'] = 'No contact type set for corporate contact.';
-            }
-
-            $_SESSION['m_admin']['contact']['SOCIETY'] = $func->wash(
-                $_REQUEST['society'], 'no', _STRUCTURE_ORGANISM.' ', 'yes', 0, 255
-            );
-            $_SESSION['m_admin']['contact']['LASTNAME'] = '';
-            $_SESSION['m_admin']['contact']['FIRSTNAME'] = '';
-            $_SESSION['m_admin']['contact']['FUNCTION'] = '';
-            $_SESSION['m_admin']['contact']['TITLE'] = '';
-        } else {
-            $stmt = $db->query($controlTarget, array('no_corporate'));
-            if ($stmt->rowCount() == 0) {
-                $_SESSION['error'] = 'No contact type set for no corporate contact.';
-            }
-
-            $_SESSION['m_admin']['contact']['LASTNAME'] = $func->wash(
-                $_REQUEST['lastname'], 'no', _LASTNAME, 'yes', 0, 255
-            );
-            $_SESSION['m_admin']['contact']['FIRSTNAME'] = $func->wash(
-                $_REQUEST['firstname'], 'no', _FIRSTNAME, 'no', 0, 255
-            );
-            if ($_REQUEST['society'] != '') {
-                $_SESSION['m_admin']['contact']['SOCIETY'] = $func->wash(
-                    $_REQUEST['society'], 'no', _STRUCTURE_ORGANISM.' ', 'yes', 0, 255
-                );
-            } else {
-                $_SESSION['m_admin']['contact']['SOCIETY'] = '';
-            }
-            if ($_REQUEST['function'] != '') {
-                $_SESSION['m_admin']['contact']['FUNCTION'] = $func->wash(
-                    $_REQUEST['function'], 'no', _FUNCTION.' ', 'yes', 0, 255
-                );
-            } else {
-                $_SESSION['m_admin']['contact']['FUNCTION'] = '';
-            }
-            if ($_REQUEST['title'] != '') {
-                $_SESSION['m_admin']['contact']['TITLE'] = $func->wash(
-                    $_REQUEST['title'], 'no', _TITLE2.' ', 'yes', 0, 255
-                );
-            } else {
-                $_SESSION['m_admin']['contact']['TITLE'] = '';
-            }
-        }
-        if ($_REQUEST['society_short'] != '') {
-            $_SESSION['m_admin']['contact']['SOCIETY_SHORT'] = $func->wash(
-                $_REQUEST['society_short'], 'no', _SOCIETY_SHORT.' ', 'yes', 0, 32
-            );
-        } else {
-            $_SESSION['m_admin']['contact']['SOCIETY_SHORT'] = '';
-        }
-        if ($_REQUEST['communication_type'] != '') {
-            $_SESSION['m_admin']['communication']['TYPE'] = $func->wash(
-                $_REQUEST['communication_type'], 'no', _COMMUNICATION_TYPE.' ', 'yes', 0, 32
-            );
-        } else {
-            $_SESSION['m_admin']['communication']['TYPE'] = '';
-        }
-        if (!empty($_SESSION['m_admin']['communication']['TYPE'])) {
-            $_SESSION['m_admin']['communication']['VALUE'] = trim(trim($func->wash(
-                $_REQUEST['communication_value'], 'no', _COMMUNICATION_VALUE.' ', 'yes', 0, 255
-            )), '/');
-        } else {
-            $_SESSION['m_admin']['communication']['VALUE'] = '';
-        }
-
-        $_SESSION['m_admin']['contact']['CONTACT_TYPE'] = $func->wash(
-            $_REQUEST['contact_type'], 'no', _CONTACT_TYPE.' ', 'yes', 0, 255
-        );
-
-        if ($_REQUEST['comp_data'] != '') {
-            $_SESSION['m_admin']['contact']['OTHER_DATA'] = $func->wash(
-                $_REQUEST['comp_data'], 'no', _COMP_DATA.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['contact']['OTHER_DATA'] = '';
-        }
-
-        if (isset($_REQUEST['owner']) && $_REQUEST['owner'] != '') {
-            if (preg_match('/\((.|\s|\d|\h|\w)+\)$/i', $_REQUEST['owner']) == 0) {
-                $_SESSION['error'] = _CREATE_BY.' '._WRONG_FORMAT.'.<br/>'
-                                   ._USE_AUTOCOMPLETION;
-            } else {
-                $_SESSION['m_admin']['contact']['OWNER'] = str_replace(
-                    ')', '', substr($_REQUEST['owner'],
-                    strrpos($_REQUEST['owner'], '(') + 1)
-                );
-                $_SESSION['m_admin']['contact']['OWNER'] = $func->wash(
-                    $_SESSION['m_admin']['contact']['OWNER'], 'no',
-                    _CREATE_BY.' ', 'yes', 0, 32
-                );
-            }
-        } else {
-            $_SESSION['m_admin']['contact']['OWNER'] = '';
-        }
-
-        $_SESSION['m_admin']['contact']['order'] = $_REQUEST['order'];
-        $_SESSION['m_admin']['contact']['order_field'] = $_REQUEST['order_field'];
-        $_SESSION['m_admin']['contact']['what'] = $_REQUEST['what'];
-        $_SESSION['m_admin']['contact']['start'] = $_REQUEST['start'];
-    }
-
-    /**
-     * Form to modify a contact v2.
-     *
-     * @param  $string $mode up or add
-     * @param int $id $id of the contact to change
-     */
-    public function formcontact($mode, $id = '', $admin = true, $iframe = false)
-    {
-        $db = new Database();
-
-        // usefull for fields important
-        $contactsFilling = \Contact\models\ContactFillingModel::get();
-        $contactsFilling['rating_columns'] = $contactsFilling['rating_columns'];
-        
-        $display_value = 'table-row';
-
-        $func = new functions();
-        $state = true;
-        if (!isset($_SESSION['m_admin']['contact'])) {
-            $this->clearcontactinfos();
-        }
-        if ($mode != 'add') {
-            $query = 'SELECT * FROM '.$_SESSION['tablename']['contacts_v2'].' WHERE contact_id = ?';
-
-            $stmt = $db->query($query, array($id));
-
-            if ($stmt->rowCount() == 0) {
-                $_SESSION['error'] = _THE_CONTACT.' '._ALREADY_EXISTS;
-                $state = false;
-            } else {
-                $_SESSION['m_admin']['contact'] = array();
-                $line = $stmt->fetchObject();
-                $_SESSION['m_admin']['contact']['ID'] = $line->contact_id;
-                $_SESSION['m_admin']['contact']['TITLE'] = functions::show_string($line->title);
-                $_SESSION['m_admin']['contact']['LASTNAME'] = functions::show_string($line->lastname);
-                $_SESSION['m_admin']['contact']['FIRSTNAME'] = functions::show_string($line->firstname);
-                $_SESSION['m_admin']['contact']['SOCIETY'] = functions::show_string($line->society);
-                $_SESSION['m_admin']['contact']['SOCIETY_SHORT'] = functions::show_string($line->society_short);
-                $_SESSION['m_admin']['contact']['FUNCTION'] = functions::show_string($line->function);
-                $_SESSION['m_admin']['contact']['OTHER_DATA'] = functions::show_string($line->other_data);
-                $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = functions::show_string($line->is_corporate_person);
-                $_SESSION['m_admin']['contact']['IS_EXTERNAL_CONTACT'] = functions::show_string($line->is_external_contact);
-                $_SESSION['m_admin']['contact']['CONTACT_TYPE'] = $line->contact_type;
-                $_SESSION['m_admin']['contact']['OWNER'] = $line->user_id;
-                if ($admin && !empty($_SESSION['m_admin']['contact']['OWNER'])) {
-                    $stmt = $db->query('SELECT lastname, firstname FROM '.$_SESSION['tablename']['users'].' WHERE user_id = ?',
-                        array($_SESSION['m_admin']['contact']['OWNER']));
-                    $res = $stmt->fetchObject();
-                    $_SESSION['m_admin']['contact']['OWNER'] = $res->lastname.', '.$res->firstname.' ('.$_SESSION['m_admin']['contact']['OWNER'].')';
-                }
-
-                $query = 'SELECT * FROM '.$_SESSION['tablename']['contact_communication'].' WHERE contact_id = ?';
-
-                $stmt = $db->query($query, array($id));
-
-                $_SESSION['m_admin']['communication'] = array();
-                $line = $stmt->fetchObject();
-                $_SESSION['m_admin']['communication']['ID'] = $line->id;
-                $_SESSION['m_admin']['communication']['CONTACT_ID'] = $line->contact_id;
-                $_SESSION['m_admin']['communication']['TYPE'] = functions::show_string($line->type);
-                $_SESSION['m_admin']['communication']['VALUE'] = functions::show_string($line->value);
-            }
-        } elseif ($mode == 'add' && !isset($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'])) {
-            $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = 'Y';
-            $_SESSION['m_admin']['contact']['IS_EXTERNAL_CONTACT'] = 'N';
-        }
-        require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_business_app_tools.php';
-        $business = new business_app_tools();
-        $tmp = $business->get_titles();
-        $titles = $tmp['titles'];
-
-        if ($iframe != true) {
-            echo '<h1>';
-            if ($mode == 'up') {
-                ?>
-<i class="fa fa-edit fa-2x"></i>
-<?php
-                echo '&nbsp;'._MODIFY_CONTACT;
-            } elseif ($mode == 'add') {
-                ?>
-<i class="fa fa-plus fa-2x"></i>
-<?php
-                echo '&nbsp;'._ADD_NEW_CONTACT;
-            } elseif ($mode == 'view') {
-                ?>
-<i class="fa fa-users fa-2x"></i>
-<?php
-                echo '&nbsp;'._VIEW;
-            }
-            echo '</h1><br/><div class="block">';
-        } else {
-            echo '<div class="block"><h2>';
-            if ($mode == 'up') {
-                echo _CONTACT;
-            } elseif ($mode == 'add') {
-                echo _ADD_NEW_CONTACT;
-            } elseif ($mode == 'view') {
-                ?>
-<i class="fa fa-users fa-2x"></i>
-<?php
-                echo '&nbsp;'._VIEW;
-            }
-            echo '</h2>';
-        } ?>
-<div id="inner_content_contact" class="clearfix" align="center" style="margin-bottom:15px;width:100% !important;">
-    <?php
-            if ($state == false) {
-                echo '<br /><br /><br /><br />'._THE_CONTACT.' '._UNKOWN.'<br /><br /><br /><br />';
-            } else {
-                $can_add_contact = ($admin ? '' : 'Y');
-                $action = $_SESSION['config']['businessappurl'].'index.php?display=true&page=contacts_v2_up_db';
-                if (!$admin) {
-                    $action = $_SESSION['config']['businessappurl'].'index.php?display=true&dir=my_contacts&page=my_contact_up_db';
-                    if ($iframe) {
-                        $action = $_SESSION['config']['businessappurl'].'index.php?display=true&dir=my_contacts&page=my_contact_up_db&mycontact=iframe';
-                    }
-                } ?>
-    <form name="frmcontact" id="frmcontact" method="post" action="<?php functions::xecho($action); ?>"
-        class="forms" style="width:700px">
-        <input type="hidden" name="display" value="true" />
-        <?php if (!$admin) {
-                    ?>
-        <input type="hidden" name="dir" value="my_contacts" />
-        <input type="hidden" name="page" value="my_contact_up_db" />
-        <?php
-
-                } else {
-                    ?>
-        <input type="hidden" name="admin" value="contacts_v2" />
-        <input type="hidden" name="page" value="contacts_v2_up_db" />
-        <?php
-
-                } ?>
-        <input type="hidden" name="order" id="order" value="<?php if (isset($_REQUEST['order'])) {
-                    functions::xecho($_REQUEST['order']);
-                } ?>" />
-        <input type="hidden" name="order_field" id="order_field" value="<?php if (isset($_REQUEST['order_field'])) {
-                    functions::xecho($_REQUEST['order_field']);
-                } ?>" />
-        <input type="hidden" name="what" id="what" value="<?php if (isset($_REQUEST['what'])) {
-                    functions::xecho($_REQUEST['what']);
-                } ?>" />
-        <input type="hidden" name="start" id="start" value="<?php if (isset($_REQUEST['start'])) {
-                    functions::xecho($_REQUEST['start']);
-                } ?>" />
-        <table id="frmcontact_table">
-            <!--                     <tr>
-                        <td>&nbsp;</td>
-                        <td class="indexing_field">
-                            <input type="radio"  class="check" name="is_external" value="N" <?php if ($_SESSION['m_admin']['contact']['IS_EXTERNAL_CONTACT'] == 'N') {
-                    ?>checked="checked"
-            <?php
-
-                } ?>onclick="javascript:show_admin_external_contact( false, '
-            <?php functions::xecho($display_value); ?>')" id="external_no">
-            <span onclick="$('external_no').click();" onmouseover="this.style.cursor='pointer';">
-                <?php echo _IS_INTERNAL_CONTACT; ?>
-            </span>
-            <input type="radio" class="check" name="is_external" value="Y" <?php if ($_SESSION[ 'm_admin'][
-                'contact'][ 'IS_EXTERNAL_CONTACT']=='Y') {
-                    ?> checked="checked"
-            <?php
-
-                } ?>onclick="javascript:show_admin_external_contact( true, '
-            <?php functions::xecho($display_value); ?>')" id="external_yes">
-            <span onclick="$('external_yes').click();" onmouseover="this.style.cursor='pointer';">
-                <?php echo _IS_EXTERNAL_CONTACT; ?>
-            </span>
-            </td>
-            <td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
-            </td>
-            <td>&nbsp;</td>
-            </tr>
-            <tr id="search_directory" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_EXTERNAL_CONTACT'] == 'N') {
-                    echo 'none';
-                } else {
-                    functions::xecho($display_value);
-                } ?>">
-                <td>
-                    <label for="searchDirectory">
-                        <?php echo _SEARCH_DIRECTORY; ?>: </label>
-                </td>
-                <td class="indexing_field">
-                    <input name="searchDirectory" type="text" onkeyup="this.value=this.value.toUpperCase()" id="lastname" value="" />
-                </td>
-                <td>&nbsp;</td>
-            </tr> -->
-            <tr>
-                <td>&nbsp;</td>
-                <td class="indexing_field">
-                    <input type="radio" class="check" name="is_corporate" value="Y" <?php if ($_SESSION[ 'm_admin']['contact'][ 'IS_CORPORATE_PERSON']=='Y') {
-                    ?> checked="checked"
-                    <?php
-
-                } ?>onclick="javascript:show_admin_contacts( true, '<?php functions::xecho($display_value); ?>');setContactType('corporate', '<?php echo $can_add_contact; ?>')" id="corpo_yes">
-                    <span onclick="$('corpo_yes').click();" onmouseover="this.style.cursor='pointer';">
-                        <?php echo _IS_CORPORATE_PERSON; ?>
-                    </span>
-                    <input type="radio" class="check" name="is_corporate" value="N" <?php if ($_SESSION[ 'm_admin'][
-                        'contact'][ 'IS_CORPORATE_PERSON']=='N') {
-                    ?> checked="checked"
-                    <?php
-
-                } ?>onclick="javascript:show_admin_contacts( false, '<?php functions::xecho($display_value); ?>');setContactType('no_corporate', '<?php echo $can_add_contact; ?>')" id="corpo_no">
-                    <span onclick="$('corpo_no').click();" onmouseover="this.style.cursor='pointer';">
-                        <?php echo _INDIVIDUAL; ?>
-                    </span>
-                </td>
-                <td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
-                    &nbsp; </td>
-                <td>&nbsp;</td>
-            </tr>
-            <?php if ($admin && $mode == 'up') {
-                    ?>
-            <tr>
-                <td>
-                    <label for="owner">
-                        <?php echo _CREATE_BY; ?>: </label>
-                </td>
-                <td class="indexing_field">
-                    <input disabled name="owner" type="text" id="owner" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['contact']['OWNER'])); ?>"
-                    />
-                    <div id="show_user" class="autocomplete"></div>
-                </td>
-                <td>&nbsp;</td>
-            </tr>
-            <?php
-
-                } ?>
-            <tr id="contact_types_tr">
-                <td>
-                    <?php echo _CONTACT_TYPE; ?>:</td>
-                <td class="indexing_field">
-                    <select name="contact_type" id="contact_type" <?php if ($mode=='add') {
-                    ?> onchange="getContacts('
-                        <?php echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&dir=my_contacts&page=getContacts', this.options[this.selectedIndex].value,
-                        'view');"
-                        <?php
-
-                } ?>
-                        >
-                        <option value="">
-                            <?php echo _CHOOSE_CONTACT_TYPES; ?>
-                        </option>
-
-                    </select>
-                </td>
-                <td>
-                    <span class="red_asterisk" style="visibility:visible;" id="contact_types_mandatory">
-                        <i class="fa fa-star"></i>
-                    </span>
-                </td>
-            </tr>
-            <?php
-                    if (defined('_EXAMPLE_SELECT_CONTACT_TYPE') && _EXAMPLE_SELECT_CONTACT_TYPE != '') {
-                        ?>
-            <tr>
-                <td colspan="3">
-                    <i>&nbsp;
-                        <?php echo _EXAMPLE_SELECT_CONTACT_TYPE; ?>
-                    </i>
-                </td>
-            </tr>
-            <?php
-
-                    } ?>
-
-            <tr>
-                <td>
-                    <label for="society">
-                        <?php echo _STRUCTURE_ORGANISM; ?>:</label>
-                </td>
-                <td class="indexing_field">
-                    <input name="society" type="text" id="society" value="<?php if ($mode != 'add' && isset($_SESSION['m_admin']['contact']['SOCIETY'])) {
-                        functions::xecho($func->show_str($_SESSION['m_admin']['contact']['SOCIETY']));
-                    } ?>" />
-                </td>
-                <td class="indexing_field" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'N') {
-                        echo 'none';
-                    } else {
-                        functions::xecho($display_value);
-                    } ?>">
-                    <span class="red_asterisk" style="visibility:visible;" id="society_mandatory">
-                        <i class="fa fa-star"></i>
-                    </span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <?php echo _SOCIETY_SHORT; ?>:</td>
-                <td class="indexing_field">
-                    <input name="society_short" type="text" id="society_short" value="<?php if ($mode != 'add' && isset($_SESSION['m_admin']['contact']['SOCIETY_SHORT'])) {
-                        functions::xecho($func->show_str($_SESSION['m_admin']['contact']['SOCIETY_SHORT']));
-                    } ?>" />
-                </td>
-            </tr>
-            <tr id="title_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') {
-                        echo 'none';
-                    } else {
-                        functions::xecho($display_value);
-                    } ?>">
-                <td>
-                    <label for="title">
-                        <?php echo _TITLE2; ?>: </label>
-                </td>
-                <td class="indexing_field">
-                    <select name="title" id="title">
-                        <option value="">
-                            <?php echo _CHOOSE_TITLE; ?>
-                        </option>
-                        <?php
-                            foreach (array_keys($titles) as $key) {
-                                ?>
-                        <option value="<?php functions::xecho($key); ?>" <?php
-                            if ((!isset($_SESSION[ 'm_admin'][ 'contact'][ 'TITLE']) || empty($_SESSION[ 'm_admin'][
-                            'contact'][ 'TITLE']) && $mode !='add') && $key==$_SESSION[ 'default_mail_title']) {
-                                echo
-                            'selected="selected"';
-                            } elseif (isset($_SESSION[ 'm_admin'][ 'contact'][ 'TITLE']) && $key==$_SESSION[ 'm_admin'][
-                            'contact'][ 'TITLE'] && $mode !='add') {
-                                echo 'selected="selected"';
-                            } ?>>
-                            <?php functions::xecho($titles[$key]); ?>
-                        </option>
-                        <?php
-
-                            } ?>
-                    </select>
-                </td>
-                <td>&nbsp;</td>
-            </tr>
-            <tr id="lastname_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') {
-                                echo 'none';
-                            } else {
-                                functions::xecho($display_value);
-                            } ?>">
-                <td>
-                    <label for="lastname">
-                        <?php echo _LASTNAME; ?>: </label>
-                </td>
-                <td class="indexing_field">
-                    <input name="lastname" type="text" onkeyup="this.value=this.value.toUpperCase()" id="lastname" value="<?php if ($mode != 'add' && isset($_SESSION['m_admin']['contact']['LASTNAME'])) {
-                                functions::xecho($func->show_str($_SESSION['m_admin']['contact']['LASTNAME']));
-                            } ?>" />
-                </td>
-                <td>
-                    <span id="lastname_mandatory" class="red_asterisk" style="visibility:none;">
-                        <i class="fa fa-star"></i>
-                    </span>
-                </td>
-                <td>&nbsp;</td>
-            </tr>
-            <tr id="firstname_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') {
-                                echo 'none';
-                            } else {
-                                functions::xecho($display_value);
-                            } ?>">
-                <td>
-                    <label for="firstname">
-                        <?php echo _FIRSTNAME; ?>: </label>
-                </td>
-                <td class="indexing_field">
-                    <input name="firstname" type="text" id="firstname" onkeyup="this.value=capitalizeFirstLetter(this.value)" value="<?php if ($mode != 'add' && isset($_SESSION['m_admin']['contact']['FIRSTNAME'])) {
-                                functions::xecho($func->show_str($_SESSION['m_admin']['contact']['FIRSTNAME']));
-                            } ?>" />
-                </td>
-                <td>
-                    <span id="firstname_mandatory" class="red_asterisk" style="visibility:hidden;">
-                        <i class="fa fa-star"></i>
-                    </span>
-                </td>
-            </tr>
-            <tr id="function_p" style="display:<?php if (isset($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON']) && $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') {
-                                echo 'none';
-                            } else {
-                                functions::xecho($display_value);
-                            } ?>">
-                <td>
-                    <label for="function">
-                        <?php echo _FUNCTION; ?>: </label>
-                </td>
-                <td class="indexing_field">
-                    <input name="function" type="text" id="function" value="<?php if ($mode != 'add' && isset($_SESSION['m_admin']['contact']['FUNCTION'])) {
-                                functions::xecho($func->show_str($_SESSION['m_admin']['contact']['FUNCTION']));
-                            } ?>" />
-                </td>
-                <td>&nbsp;</td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="comp_data">
-                        <?php echo _COMP_DATA; ?>&nbsp;:</label>
-                </td>
-                <td class="indexing_field">
-                    <textarea name="comp_data" id="comp_data"><?php if ($mode != 'add' && isset($_SESSION['m_admin']['contact']['OTHER_DATA'])) {
-                                functions::xecho($func->show_str($_SESSION['m_admin']['contact']['OTHER_DATA']));
-                            } ?></textarea>
-                </td>
-                <td>&nbsp;</td>
-            </tr>
-            <tr id="communication_type_tr">
-                <td>
-                    <?php echo _COMMUNICATION_TYPE; ?>:</td>
-                <td class="indexing_field">
-                    <select name="communication_type" id="communication_type">
-                        <option value="">
-                            <?php echo _CHOOSE_COMMUNICATION_TYPES; ?>
-                        </option>
-                        <?php if ($_SESSION['m_admin']['communication']['TYPE'] == 'email') {
-                                ?>
-                        <option value="email" selected="selected">
-                            <?php echo _EMAIL; ?>
-                        </option>
-                        <?php
-
-                            } else {
-                                ?>
-                        <option value="email">
-                            <?php echo _EMAIL; ?>
-                        </option>
-                        <?php
-
-                            }
-                if ($_SESSION['m_admin']['communication']['TYPE'] == 'url') {
-                    ?>
-                        <option value="url" selected="selected">
-                            <?php echo _URL; ?>
-                        </option>
-                        <?php
-
-                } else {
-                    ?>
-                        <option value="url">
-                            <?php echo _URL; ?>
-                        </option>
-                        <?php
-
-                } ?>
-                    </select>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <?php echo _COMMUNICATION_VALUE; ?>:</td>
-                <td class="indexing_field">
-                    <input name="communication_value" type="text" id="communication_value" value="<?php if (isset($_SESSION['m_admin']['communication']['VALUE'])) {
-                    functions::xecho($func->show_str($_SESSION['m_admin']['communication']['VALUE']));
-                } ?>" />
-                </td>
-            </tr>
-        </table>
-        <input name="mode" type="hidden" value="<?php echo $mode; ?>" />
-        <br/>
-        <em style="display:none">(
-            <?php echo _YOU_SHOULD_ADD_AN_ADDRESS; ?>)</em>
-        <p>
-
-            <input class="button" type="submit" name="Submit" onclick='$j("#frmcontact").submit();this.disabled="disabled";this.style.opacity="0.5";'
-                value="<?php echo _VALIDATE; ?>" />
-
-            <?php
-                    $cancel_target = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2';
-                if (!$admin) {
-                    $cancel_target = $_SESSION['config']['businessappurl'].'index.php?page=my_contacts&amp;dir=my_contacts&amp;load';
-                }
-                if ($iframe) {
-                    ?>
-            <input type="button" class="button" name="cancel" value="<?php echo _CANCEL; ?>"
-                <?php if ($_SESSION['info_contact_popup']=='true') {
-                        ?> onclick="self.close();"
-            <?php
-
-                    } elseif ($_SESSION['AttachmentContact'] == '1') {
-                        ?>
-            onclick="new Effect.BlindUp(parent.document.getElementById('create_contact_div_attach'));new Effect.BlindUp(parent.document.getElementById('info_contact_div_attach'));simpleAjax('<?php echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&page=unsetAttachmentContact');return false;"
-            <?php
-
-                    } else {
-                        ?>
-            onclick="new Effect.BlindUp(parent.document.getElementById('show_tab'));new Effect.BlindUp(parent.document.getElementById('info_contact_div'));return false;"
-            <?php
-
-                    } ?>
-            />
-            <?php
-
-                } else {
-                    if ($mode == 'view') {
-                        ?>
-            <input type="button" class="button" name="cancel" value="<?php echo _BACK_TO_RESULTS_LIST; ?>"
-                onclick="history.go(-1);" />
-            <?php
-
-                    } else {
-                        if (isset($_SESSION['fromContactTree']) && $_SESSION['fromContactTree'] == 'yes') {
-                            ?>
-            <input type="button" class="button" name="cancel" value="<?php echo _CANCEL; ?>"
-                onclick="window.location.href='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=view_tree_contacts';"
-            />
-            <?php
-                                    // $_SESSION['fromContactTree'] = "";
-                        } else {
-                            ?>
-            <input type="button" class="button" name="cancel" value="<?php echo _CANCEL; ?>"
-                onclick="javascript:window.location.href='<?php functions::xecho($cancel_target); ?>';"
-            />
-            <?php
-
-                        }
-                    }
-                } ?>
-        </p>
-    </form>
-    
-    <script type="text/javascript">
-        var fieldsCtrl = <?php echo $contactsFilling['rating_columns']; ?>;
-        contactMapping(fieldsCtrl, "frmcontact");
-        
-        var isChecked = false;
-        if (!checkContactType('no_corporate', '<?php echo $can_add_contact; ?>')) {
-            $j('#span_no_corporate').css('display', 'none');
-            setContactType('corporate', '<?php echo $can_add_contact; ?>');
-            $j('#corpo_yes').prop('checked', true);
-            $j('#corpo_yes').click();
-            isChecked = true;
-
-        }
-        if (!checkContactType('corporate', '<?php echo $can_add_contact; ?>')) {
-            $j('#span_corporate').css('display', 'none');
-            setContactType('no_corporate', '<?php echo $can_add_contact; ?>');
-            $j('#corpo_no').prop('checked', true);
-            $j('#corpo_no').click();
-            isChecked = true;
-
-        }
-        if ($j('[name=is_corporate]:checked').val() == 'N' && isChecked == false) {
-            setContactType('no_corporate', '<?php echo $can_add_contact; ?>');
-        } else if ($j('[name=is_corporate]:checked').val() == 'Y' && isChecked == false) {
-            setContactType('corporate', '<?php echo $can_add_contact; ?>');
-        }
-    </script>
-
-
-    <?php
-                if ($mode == 'up' && $admin) {
-                    ?>
-        <script type="text/javascript">
-            launch_autocompleter('<?php echo $_SESSION['
-                config ']['
-                businessappurl ']; ?>index.php?display=true&page=users_autocomplete_list',
-                'owner', 'show_user');
-        </script>
-        <?php
-
-                }
-            } ?>
-</div>
-<?php
-        if ($iframe != true) {
-            echo '</div><br/>';
-        }
-    }
-
-    public function chooseContact($clean = true)
-    {
-        $db = new Database();
-        if ($clean) {
-            $this->clearcontactinfos();
-        } ?>
-<div class="block">
-    <h2>
-        </i>
-        <?php
-                echo '&nbsp;'._ADD_ADDRESS_TO_CONTACT; ?>
-    </h2>
-    <br/>
-    <span style="margin-left:30px;">
-        <?php echo '&nbsp;'._ADD_ADDRESS_TO_CONTACT_DESC; ?>
-    </span>
-    <br/>
-    <br/>
-    <form class="forms" method="post" style="margin-left:30px;width:80%;">
-        <table style="margin:auto;">
-            <tr>
-                <td>
-                    <?php echo '&nbsp;'._TYPE_OF_THE_CONTACT; ?>
-                </td>
-                <td>
-                    <select id="contact_type_selected" onchange="getContacts('<?php echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&dir=my_contacts&page=getContacts', this.options[this.selectedIndex].value, 'set');">
-                        <option value="all">
-                            <?php echo _ALL; ?>
-                        </option>
-                        <?php
-                                        $stmt = $db->query('SELECT id, label FROM contact_types ORDER BY label');
-        while ($res_label = $stmt->fetchObject()) {
-            ?>
-                        <option value="<?php functions::xecho($res_label->id); ?>">
-                            <?php functions::xecho($res_label->label); ?>
-                        </option>
-                        <?php
-
-        } ?>
-                    </select>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <?php echo '&nbsp;'._WHICH_CONTACT; ?>
-                </td>
-                <td>
-                    <select id="contactSelect">
-                        <option value="">
-                            <?php echo _CHOOSE_A_CONTACT; ?>
-                        </option>
-                        <?php
-                                        $stmt = $db->query("SELECT contact_id, society, firstname, lastname, is_corporate_person FROM contacts_v2 WHERE enabled = 'Y' ORDER BY is_corporate_person desc, society, lastname");
-        while ($res_contact = $stmt->fetchObject()) {
-            ?>
-                        <option value="<?php functions::xecho($res_contact->contact_id); ?>">
-                            <?php
-                                            if ($res_contact->is_corporate_person == 'Y') {
-                                                functions::xecho($res_contact->society);
-                                            } elseif ($res_contact->is_corporate_person == 'N') {
-                                                functions::xecho($res_contact->lastname.' '.$res_contact->firstname);
-                                            } ?>
-                        </option>
-                        <?php
-
-        } ?>
-                    </select>
-                    <span class="red_asterisk">
-                        <i class="fa fa-star"></i>
-                    </span>
-                </td>
-            </tr>
-        </table>
-        <div style="text-align:center;">
-            <input class="button" type="button" value="<?php echo _CHOOSE_THIS_CONTACT; ?>"
-                onclick="putInSessionContact('<?php echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&dir=my_contacts&page=put_in_session');"
-            />
-        </div>
-    </form>
-</div>
-</div>
-<!-- <input id="contactid" type="hidden"/> -->
-<?php
-
-    }
-
-    /**
-     * Clear the session variables of the edmit 's administration.
-     */
-    protected function clearcontactinfos()
-    {
-        // clear the session variable
-        unset($_SESSION['m_admin']);
-    }
-
-    /**
-     * Clear the session variables of the edmit 's administration.
-     */
-    protected function clearaddressinfos()
-    {
-        // clear the session variable
-        unset($_SESSION['m_admin']['address']);
-    }
-
-    /**
-     * delete a contact in the database.
-     *
-     * @param string $id contact identifier
-     */
-    public function delcontact($id, $admin = true)
-    {
-        $db = new Database();
-        $element_found = false;
-        $nb_docs = 0;
-        $tables = array();
-        $_SESSION['m_admin']['contact'] = array();
-        $order = $_REQUEST['order'];
-        $order_field = $_REQUEST['order_field'];
-        $start = $_REQUEST['start'];
-        $what = $_REQUEST['what'];
-        $path_contacts = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2&order='.$order.'&order_field='.$order_field.'&start='.$start.'&what='.$what;
-        if (!$admin) {
-            $path_contacts = $_SESSION['config']['businessappurl'].'index.php?page=my_contacts&dir=my_contacts&load&order='.$order.'&order_field='.$order_field.'&start='.$start.'&what='.$what;
-        }
-
-        if (!empty($id)) {
-            $stmt = $db->query('SELECT res_id FROM '.$_SESSION['collections'][0]['view']." WHERE (exp_contact_id = ? or dest_contact_id = ?) and status <> 'DEL'",
-                array($id, $id));
-            if ($stmt->rowCount() > 0) {
-                $nb_docs = $nb_docs + $stmt->rowCount();
-            }
-
-            $stmt = $db->query("SELECT DISTINCT cr.contact_id FROM contacts_res cr LEFT JOIN res_letterbox rl ON rl.res_id = cr.res_id WHERE rl.status <> 'DEL' AND cr.contact_id = ?", array($id));
-            if ($stmt->rowCount() > 0) {
-                $nb_docs = $nb_docs + $stmt->rowCount();
-            }
-
-            $aAddressesTmp = \SrcCore\models\DatabaseModel::select([
-                'select'    => ['id'],
-                'table'     => ['contact_addresses'],
-                'where'     => ['contact_id = ?'],
-                'data'      => [$id],
-            ]);
-
-            $aAddresses = [];
-            if (!empty($aAddressesTmp)) {
-                foreach ($aAddressesTmp as $value) {
-                    $aAddresses[] = $value['id'];
-                }
-                $stmt = $db->query("SELECT DISTINCT rl.res_id FROM resource_contacts cr LEFT JOIN res_letterbox rl ON rl.res_id = cr.res_id WHERE rl.status <> 'DEL' AND cr.type = 'contact' AND cr.item_id IN (?)", array($aAddresses));
-                if ($stmt->rowCount() > 0) {
-                    $nb_docs = $nb_docs + $stmt->rowCount();
-                }
-            }
-
-            if ($nb_docs == 0) {
-                $query = 'SELECT contact_id FROM '.$_SESSION['tablename']['contacts_v2'].' WHERE contact_id = ? ';
-                $arrayPDO = array($id);
-                if (!$admin) {
-                    $query .= ' and user_id = ?';
-                    $arrayPDO = array_merge($arrayPDO, array($_SESSION['user']['UserId']));
-                }
-                $stmt = $db->query($query, $arrayPDO);
-                if ($stmt->rowCount() == 0) {
-                    $_SESSION['error'] = _CONTACT.' '._UNKNOWN;
-                } else {
-                    $res = $stmt->fetchObject();
-                    $db->query('DELETE FROM '.$_SESSION['tablename']['contacts_v2'].' WHERE contact_id = ?', array($id));
-                    $db->query('DELETE FROM '.$_SESSION['tablename']['contact_addresses'].' WHERE contact_id = ?', array($id));
-                    $db->query('DELETE FROM '.$_SESSION['tablename']['contact_communication'].' WHERE contact_id = ?', array($id));
-                    if ($_SESSION['history']['contactdel']) {
-                        require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php';
-                        $hist = new history();
-                        $hist->add($_SESSION['tablename']['contacts_v2'], $id, 'DEL', 'contactdel', _CONTACT_DELETED.' : '.$id, $_SESSION['config']['databasetype']);
-                        $hist->add($_SESSION['tablename']['contact_addresses'], $id, 'DEL', 'contact_addresses_del', _ADDRESS_DEL.' '.strtolower(_NUM).$id.'', $_SESSION['config']['databasetype']);
-                        $hist->add($_SESSION['tablename']['contact_communication'], $id, 'DEL', 'contact_communication_del', _COMMUNICATION_DELETED.' '.strtolower(_NUM).$id.'', $_SESSION['config']['databasetype']);
-                    }
-                    $_SESSION['info'] = _CONTACT_DELETED;
-                }
-            } else {
-                ?>
-<br>
-<div id="main_error">
-    <b>
-        <?php
-                        echo _WARNING_MESSAGE_DEL_CONTACT; ?>
-    </b>
-</div>
-<br>
-<br>
-
-<h1>
-    <i class="fa fa-times fa-2x"></i>
-    <?php echo _CONTACT_DELETION; ?>
-</h1>
-
-<form name="entity_del" id="entity_del" method="post" class="forms">
-    <input type="hidden" value="<?php functions::xecho($id); ?>" name="id">
-    <h2 class="tit">
-        <?php echo _CONTACT_REAFFECT.' : <i>'.$label.'</i>'; ?>
-    </h2>
-    <?php
-                    if ($nb_docs > 0) {
-                        echo '<br><b> - '.$nb_docs.'</b> '._DOC_SENDED_BY_CONTACT; ?>
-    <br>
-    <br>
-    <input type="hidden" value="documents" name="documents">
-    <td>
-        <label for="contact_list">
-            <?php echo _NEW_CONTACT; ?>: </label>
-    </td>
-    <td class="indexing_field">
-        <input name="contact_list" type="text" id="contact_list" value="" />
-        <div id="show_contact" class="autocomplete">
-            <script type="text/javascript">
-                initList_hidden_input('contact_list', 'show_contact', '<?php echo $_SESSION['
-                    config ']['
-                    businessappurl ']; ?>index.php?display=true&page=contacts_v2_list_by_name&id=<?php functions::xecho($id); ?>',
-                    'what', '2', 'contact');
-            </script>
-        </div>
-        <input type="hidden" id="contact" name="contact" />
-    </td>
-    <br>
-    <br>
-    <td>
-        <label for="address_list">
-            <?php echo _NEW_ADDRESS; ?>: </label>
-    </td>
-    <td class="indexing_field">
-        <input name="address_list" type="text" id="address_list" value="" />
-        <div id="show_address" class="autocomplete">
-            <script type="text/javascript">
-                initList_hidden_input_before('address_list', 'show_address',
-                    '<?php echo $_SESSION['
-                    config ']['
-                    businessappurl ']; ?>index.php?display=true&page=contact_addresses_list_by_name',
-                    'what', '2', 'address', 'idContact', 'contact');
-            </script>
-        </div>
-        <input type="hidden" id="address" name="address" />
-    </td>
-
-    <br/>
-    <br/>
-    <p class="buttons">
-        <input type="submit" value="<?php echo _DEL_AND_REAFFECT; ?>" name="valid" class="button"
-            onclick="return(confirm('<?php echo _REALLY_DELETE;
-                        if (isset($page_name) && $page_name == 'users') {
-                            echo $complete_name;
-                        } elseif (isset($admin_id)) {
-                            echo ' '.$admin_id;
-                        } ?> ?\n\r\n\r<?php echo _DEFINITIVE_ACTION; ?>'));"
-        />
-        <input type="button" value="<?php echo _CANCEL; ?>" onclick="window.location.href='<?php functions::xecho($path_contacts); ?>';"
-            class="button" />
-    </p>
-    <?php
-
-                    } ?>
-</form>
-<?php
-                exit;
-            }
-        } else {
-            $_SESSION['error'] = _CONTACT.' '._EMPTY;
-        } ?>
-        <script type="text/javascript">
-            window.location.href="<?php functions::xecho($path_contacts); ?>";
-        </script>
-        <?php
-        exit;
-    }
-
-    public function get_contact_information_from_view($category_id, $contact_lastname = '', $contact_firstname = '', $contact_society = '', $user_lastname = '', $user_firstname = '')
-    {
-        if ($category_id == 'incoming') {
-            $prefix = '<b>'._TO_CONTACT_C.'</b>';
-        } elseif ($category_id == 'outgoing' || $category_id == 'internal') {
-            $prefix = '<b>'._FOR_CONTACT_C.'</b>';
-        } else {
-            $prefix = '';
-        }
-        if ($contact_lastname != '') {
-            $lastname = $contact_lastname;
-            $firstname = $contact_firstname;
-        } else {
-            $lastname = $user_lastname;
-            $firstname = $user_firstname;
-        }
-        if ($contact_society != '') {
-            if ($firstname == '' && $lastname == '') {
-                $society = $contact_society;
-            } else {
-                $society = ' ('.$contact_society.') ';
-            }
-        } else {
-            $society = '';
-        }
-        $the_contact = $prefix.' '.$firstname.' '.$lastname.' '.$society;
-
-        return $the_contact;
-    }
-
-    /**
-     * Form to modify or add an address v2.
-     *
-     * @param  $string $mode up or add
-     * @param int $id $id of the contact to change
-     */
-    public function formaddress($mode, $id = '', $admin = true, $iframe = '')
-    {
-        $db = new Database();
-
-        // usefull for fields important
-        $contactsFilling = \Contact\models\ContactFillingModel::get();
-        $contactsFilling['rating_columns'] = $contactsFilling['rating_columns'];
-
-        $display_value = 'table-row';
-        $func = new functions();
-        $state = true;
-        if (!isset($_SESSION['m_admin']['address']) && !isset($_SESSION['m_admin']['contact'])) {
-            $this->clearcontactinfos();
-        }
-        if ($mode != 'add') {
-            $query = 'SELECT * FROM '.$_SESSION['tablename']['contact_addresses'].' WHERE id = ?';
-            $arrayPDO = array($id);
-            $core_tools = new core_tools();
-            if (!$admin && !$core_tools->test_service('update_contacts', 'apps', false)) {
-                $query .= ' and user_id = ?';
-                $arrayPDO = array_merge($arrayPDO, array($_SESSION['user']['UserId']));
-            }
-            $stmt = $db->query($query, $arrayPDO);
-
-            if ($stmt->rowCount() == 0) {
-                $_SESSION['error'] = _THE_ADDRESS.' '._ALREADY_EXISTS;
-                $state = false;
-            } else {
-                if (!isset($_SESSION['address_up_error'])) {
-                    $_SESSION['m_admin']['address'] = array();
-                    $line = $stmt->fetchObject();
-                    $_SESSION['m_admin']['address']['ID'] = $line->id;
-                    $_SESSION['m_admin']['address']['CONTACT_ID'] = $line->contact_id;
-                    $_SESSION['m_admin']['address']['TITLE'] = functions::show_string($line->title);
-                    $_SESSION['m_admin']['address']['LASTNAME'] = functions::show_string($line->lastname);
-                    $_SESSION['m_admin']['address']['FIRSTNAME'] = functions::show_string($line->firstname);
-                    $_SESSION['m_admin']['address']['FUNCTION'] = functions::show_string($line->function);
-                    $_SESSION['m_admin']['address']['OTHER_DATA'] = functions::show_string($line->other_data);
-                    $_SESSION['m_admin']['address']['OWNER'] = $line->user_id;
-                    $_SESSION['m_admin']['address']['DEPARTEMENT'] = functions::show_string($line->departement);
-                    $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $line->contact_purpose_id;
-                    $_SESSION['m_admin']['address']['OCCUPANCY'] = functions::show_string($line->occupancy);
-                    $_SESSION['m_admin']['address']['ADD_NUM'] = functions::show_string($line->address_num);
-                    $_SESSION['m_admin']['address']['ADD_STREET'] = functions::show_string($line->address_street);
-                    $_SESSION['m_admin']['address']['ADD_COMP'] = functions::show_string($line->address_complement);
-                    $_SESSION['m_admin']['address']['ADD_TOWN'] = functions::show_string($line->address_town);
-                    $_SESSION['m_admin']['address']['ADD_CP'] = functions::show_string($line->address_postal_code);
-                    $_SESSION['m_admin']['address']['ADD_COUNTRY'] = functions::show_string($line->address_country);
-                    $_SESSION['m_admin']['address']['PHONE'] = functions::show_string($line->phone);
-                    $_SESSION['m_admin']['address']['MAIL'] = functions::show_string($line->email);
-                    $_SESSION['m_admin']['address']['WEBSITE'] = functions::show_string($line->website);
-                    $_SESSION['m_admin']['address']['IS_PRIVATE'] = functions::show_string($line->is_private);
-                    $_SESSION['m_admin']['address']['SALUTATION_HEADER'] = functions::show_string($line->salutation_header);
-                    $_SESSION['m_admin']['address']['SALUTATION_FOOTER'] = functions::show_string($line->salutation_footer);
-                    $externalId = (array)json_decode($line->external_id);
-                    $_SESSION['m_admin']['address']['M2M_ID'] = $externalId['m2m'];
-                    $_SESSION['m_admin']['address']['BAN_ID'] = functions::show_string($line->ban_id);
-                } else {
-                    unset($_SESSION['address_up_error']);
-                }
-                if ($admin && !empty($_SESSION['m_admin']['address']['OWNER'])) {
-                    $stmt = $db->query('SELECT lastname, firstname FROM '.$_SESSION['tablename']['users'].' WHERE user_id = ?', array($_SESSION['m_admin']['address']['OWNER']));
-                    $res = $stmt->fetchObject();
-                    $_SESSION['m_admin']['address']['OWNER'] = $res->lastname.', '.$res->firstname.' ('.$_SESSION['m_admin']['address']['OWNER'].')';
-                }
-            }
-        } elseif ($mode == 'add' && !isset($_SESSION['m_admin']['address']['IS_PRIVATE'])) {
-            $_SESSION['m_admin']['address']['IS_PRIVATE'] = 'N';
-        }
-        require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_business_app_tools.php';
-        $business = new business_app_tools();
-        $tmp = $business->get_titles();
-        $titles = $tmp['titles'];
-
-        $contact_purposes = array();
-
-        $stmt = $db->query('SELECT id, label FROM '.$_SESSION['tablename']['contact_purposes']);
-        while ($res = $stmt->fetchObject()) {
-            $contact_purposes[$res->id] = functions::show_string($res->label);
-        }
-
-        if ($iframe != true) {
-            echo '<h1>';
-            if ($mode == 'up') {
-                ?>
-<i class="fa fa-edit fa-2x"></i>
-<?php
-                echo _MODIFY_ADDRESS;
-            } elseif ($mode == 'add') {
-                ?>
-<i class="fa fa-plus fa-2x"></i>
-<?php
-                echo _ADDITION_ADDRESS;
-            }
-            echo '</h1>';
-        } else {
-            echo '<div class="block"><h2>';
-            if ($mode == 'up') {
-                echo _MODIFY_ADDRESS;
-            } elseif ($mode == 'add') {
-                echo _ADDITION_ADDRESS;
-            }
-            echo '</h2>';
-        }
-
-        echo '<div id="inner_content_contact" class="clearfix" align="center">';
-
-        if ($state == false) {
-            echo '<br /><br /><br /><br />'._THE_ADDRESS.' '._UNKOWN.'<br /><br /><br /><br />';
-        } else {
-            $this->get_contact_form();
-            $action = $_SESSION['config']['businessappurl'].'index.php?display=true&page=contact_addresses_up_db';
-            $fieldAddressClass = 'address_modification_field';
-            $fieldSalutationClass = 'salutation_modification_field';
-            if (!$admin) {
-                $action = $_SESSION['config']['businessappurl'].'index.php?display=true&page=contact_addresses_up_db&mycontact=Y';
-            }
-            if ($iframe == 'iframe') {
-                $action = $_SESSION['config']['businessappurl'].'index.php?display=false&page=contact_addresses_up_db&mycontact=iframe';
-                $fieldAddressClass = 'address_modification_field_frame';
-                $fieldSalutationClass = 'salutation_modification_field_frame';
-            } elseif ($iframe == 'iframe_add_up') {
-                $action = $_SESSION['config']['businessappurl'].'index.php?display=false&page=contact_addresses_up_db&mycontact=iframe_add_up';
-            } elseif ($iframe == 'fromContactIframe') {
-                $action = $_SESSION['config']['businessappurl'].'index.php?display=false&page=contact_addresses_up_db&mycontact=fromContactIframe';
-            } elseif ($iframe == 'editDetail') {
-                $action = 'index.php?display=false&page=contact_addresses_up_db&mycontact=editDetail&editDetail';
-            } elseif ($iframe == 'editDetailSender') {
-                $action = 'index.php?display=false&page=contact_addresses_up_db&mycontact=editDetailSender&editDetailSender';
-            }
-            if (isset($_SESSION['contact_address']['fromContactAddressesList']) && $_SESSION['contact_address']['fromContactAddressesList'] != '') {
-                $action = $_SESSION['config']['businessappurl'].'index.php?display=true&page=contact_addresses_up_db&fromContactAddressesList';
-            } ?>
-<form name="frmcontact" id="frmcontact" method="post" action="<?php echo $action; ?>"
-    class="forms">
-    <input type="hidden" name="display" value="true" />
-    <?php if (!$admin) {
-                ?>
-    <input type="hidden" name="dir" value="my_contacts" />
-    <input type="hidden" name="page" value="my_contact_up_db" />
-    <?php
-
-            } else {
-                ?>
-    <input type="hidden" name="admin" value="contacts_v2_up" />
-    <input type="hidden" name="page" value="contact_addresses_up_db" />
-    <?php
-
-            } ?>
-    <input type="hidden" name="order" id="order" value="<?php if (isset($_REQUEST['order'])) {
-                functions::xecho($_REQUEST['order']);
-            } ?>" />
-    <input type="hidden" name="order_field" id="order_field" value="<?php if (isset($_REQUEST['order_field'])) {
-                functions::xecho($_REQUEST['order_field']);
-            } ?>" />
-    <input type="hidden" name="what" id="what" value="<?php if (isset($_REQUEST['what'])) {
-                functions::xecho($_REQUEST['what']);
-            } ?>" />
-    <input type="hidden" name="start" id="start" value="<?php if (isset($_REQUEST['start'])) {
-                functions::xecho($_REQUEST['start']);
-            } ?>" />
-
-    <table width="600px">
-        <tr align="left">
-            <td colspan="4" onclick="toggleBlock('address_div', 'divStatus_address_div');">
-                <label>
-                    <span id="divStatus_address_div" style="color:#1C99C5;">
-                        <i class="fa fa-minus-square"></i>
-                    </span>&nbsp;
-                    <b>
-                        <?php echo _ADDRESS; ?>
-                    </b>
-                </label>
-            </td>
-        </tr>
-    </table>
-    <div id="address_div" style="display:inline">
-        <table width="600px" id="frmaddress_table1" style="position:relative;">
-            <?php
-                    if ($mode == 'add') {
-                        ?>
-            <tr id="previous_address_tr">
-                <td width="50%"></td>
-                <td width="50%" align="right">
-                    <?php 
-                                $stmt = $db->query('SELECT distinct address_num, address_street, address_complement, address_postal_code, address_town, address_country, website FROM contact_addresses WHERE contact_id = ?', array($_SESSION['m_admin']['contact']['ID']));
-                        $nbRes = $stmt->rowCount();
-                        if ($nbRes > 0) {
-                            $frm = '<select style="margin-left:0px;" onchange="setPreviousAddress(this.options[this.selectedIndex].value)" class="'.$fieldAddressClass.'">';
-                            $frm .= '<option value="">'._USE_PREVIOUS_ADDRESS.'</option>';
-                            while ($result = $stmt->fetchObject()) {
-                                if ($result->address_num != '' || $result->address_street != '' || $result->address_postal_code != '' || $result->address_town != '' || $result->address_country != '') {
-                                    $pipeAddress = $result->address_num.'||'.$result->address_street.'||'.$result->address_complement.'||'.$result->address_postal_code.'||'.$result->address_town.'||'.$result->address_country.'||'.$result->website;
-                                    $AddressReplacePipe = str_replace('||', ' ', $pipeAddress);
-                                    $frm .= '<option value="'.$pipeAddress.'">'.$AddressReplacePipe.'</option>';
-                                }
-                            }
-                            $frm .= '</select>';
-                            echo $frm;
-                        } ?>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <?php
-
-                    } ?>
-            <tr id="contact_purposes_tr">
-                <td width="50%">
-                    <label for="new_id" style="width:auto;">
-                        <?php echo _CONTACT_PURPOSE; ?>&nbsp;:&nbsp;</label>
-                </td>
-                <td width="50%" align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="new_id"
-                        id="new_id" onfocus="$('rule_purpose').style.display='table-row'" onblur="purposeCheck();$('rule_purpose').style.display='none'"
-                        ; <?php if (isset($_SESSION[ 'm_admin'][ 'address'][ 'CONTACT_PURPOSE_ID']) &&
-                        $_SESSION[ 'm_admin'][ 'address'][ 'CONTACT_PURPOSE_ID'] !='') {
-                        echo 'value="'.functions::xssafe($this->get_label_contact($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'], $_SESSION['tablename']['contact_purposes'])).'"';
-                    } else {
-                        echo 'value="'._MAIN_ADDRESS.'"';
-                    } ?> />
-                    <div id="show_contact" class="autocomplete">
-                        <script type="text/javascript">
-                            initList_hidden_input('new_id', 'show_contact',
-                                '<?php echo $_SESSION['
-                                config ']['
-                                businessappurl ']; ?>index.php?display=true&page=contact_purposes_list_by_name&id=<?php functions::xecho($id); ?>',
-                                'what', '2', 'contact_purposes');
-                        </script>
-                    </div>
-                    <input type="hidden" id="contact_purposes" name="contact_purposes" <?php if (isset($_SESSION[
-                        'm_admin'][ 'address'][ 'CONTACT_PURPOSE_ID']) && $_SESSION[ 'm_admin'][ 'address'][ 'CONTACT_PURPOSE_ID'] !=''
-                        ) {
-                        echo 'value="'.functions::xssafe($_SESSION[ 'm_admin'][ 'address'][ 'CONTACT_PURPOSE_ID']). '"';
-                    } ?> />
-                    <span class="red_asterisk" style="visibility:visible;" id="contact_purposes_mandatory">
-                        <i class="fa fa-star"></i>
-                    </span>
-                </td>
-            </tr>
-            <tr style="display:none;" id="rule_purpose">
-                <td>&nbsp;</td>
-                <td align="right">
-                    <i>
-                        <?php echo _EXAMPLE_PURPOSE; ?>
-                    </i>
-                </td>
-            </tr>
-            <tr id="purpose_to_create" style="display:none">
-                <td colspan="3">
-                    <em>
-                        <?php echo _CONTACT_PURPOSE_WILL_BE_CREATED; ?>
-                    </em>
-                </td>
-            </tr>
-
-            <tr id="departement_p">
-                <td>
-                    <label for="departement" style="width:auto;">
-                        <?php echo _SERVICE; ?>&nbsp;: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="departement"
-                        type="text" onfocus="$('rule_departement').style.display='table-row'" onblur="$('rule_departement').style.display='none';"
-                        id="departement" value="<?php if (isset($_SESSION['m_admin']['address']['DEPARTEMENT'])) {
-                        functions::xecho($func->show_str($_SESSION['m_admin']['address']['DEPARTEMENT']));
-                    } ?>" />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-
-            <tr id="title_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'N') {
-                        echo 'none';
-                    } else {
-                        functions::xecho($display_value);
-                    } ?>">
-                <td>
-                    <label for="title" style="width:auto;">
-                        <?php echo _TITLE2; ?>&nbsp;: </label>
-                </td>
-                <td align="right">
-                    <select style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="title"
-                        id="title">
-                        <option value="">
-                            <?php echo _CHOOSE_TITLE; ?>
-                        </option>
-                        <?php
-                                    foreach (array_keys($titles) as $key) {
-                                        ?>
-                        <option value="<?php functions::xecho($key); ?>" <?php
-                            if ((!isset($_SESSION[ 'm_admin'][ 'address'][ 'TITLE']) || empty($_SESSION[ 'm_admin'][
-                            'address'][ 'TITLE'])) && $key==$_SESSION[ 'default_mail_title']) {
-                                echo 'selected="selected"';
-                            } elseif (isset($_SESSION[ 'm_admin'][ 'address'][ 'TITLE']) && $key==$_SESSION[ 'm_admin'][ 'address'][
-                            'TITLE']) {
-                                echo 'selected="selected"';
-                            } ?>>
-                            <?php functions::xecho($titles[$key]); ?>
-                        </option>
-                        <?php
-
-                                    } ?>
-                    </select>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="lastname_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'N') {
-                                        echo 'none';
-                                    } else {
-                                        functions::xecho($display_value);
-                                    } ?>">
-                <td>
-                    <label for="lastname" style="width:auto;">
-                        <?php echo _LASTNAME; ?>: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="lastname"
-                        type="text" onkeyup="this.value=this.value.toUpperCase()" id="lastname" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['LASTNAME'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="firstname_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'N') {
-                                        echo 'none';
-                                    } else {
-                                        functions::xecho($display_value);
-                                    } ?>">
-                <td>
-                    <label for="firstname" style="width:auto;">
-                        <?php echo _FIRSTNAME; ?>&nbsp;: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="firstname"
-                        type="text" id="firstname" onkeyup="this.value=capitalizeFirstLetter(this.value)" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['FIRSTNAME'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="function_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'N') {
-                                        echo 'none';
-                                    } else {
-                                        functions::xecho($display_value);
-                                    } ?>">
-                <td>
-                    <label for="function" style="width:auto;">
-                        <?php echo _FUNCTION; ?>&nbsp;: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="function"
-                        type="text" id="function" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['FUNCTION'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="occupancy" style="width:auto;">
-                        <?php echo _OCCUPANCY; ?>:</label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="occupancy"
-                        type="text" id="occupancy" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['OCCUPANCY'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="add_comp" style="width:auto;">
-                        <?php echo _COMPLEMENT; ?>&nbsp;: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="add_comp"
-                        type="text" id="add_comp" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_COMP'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <?php 
-                            $contactController = new \Contact\controllers\ContactController();
-            if (!$numDepList = $contactController->availableReferential()) {
-                $stateRef = 'disabled';
-                $stateRefInfo = _WARNING_REF;
-                $stateRefCss = 'opacity:0.5;';
-            }
-            
-            $defaultDepartment = \Parameter\models\ParameterModel::getById(['id' => 'defaultDepartment', 'select' => ['param_value_int']]);
-            if(!empty($defaultDepartment['param_value_int'])){
-                $selected = $defaultDepartment['param_value_int'];
-            } ?>
-                <td colspan="2" style="text-align:center;padding-bottom:10px;">
-                    <hr/>
-                    <div style="color:red;<?php echo $stateRefCss; ?>">
-                        <?php echo $stateRefInfo; ?>
-                    </div>
-                    <div style="text-align:right;color:#135F7F;font-style:italic;<?php echo $stateRefCss; ?>">
-                        <label for="refMaarch" style="width:auto;float:none;display:inline-block;">
-                            <?php echo _USE_REF; ?>&nbsp;: </label>
-                        <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="refMaarch"
-                            type="checkbox" id="refMaarch" value="Y" onclick="toggleRefMaarch()" <?php
-                            echo $stateRef; ?>/>
-                    </div>
-                    <div id="refSearch" style="display:none;">
-                        <select id="numDep" style="display:inline-block;width:10%;" onchange="reloadTypeahead(this);">
-                            <?php foreach ($numDepList as $value) {
-                                echo "<option value='{$value}'";
-                                if($selected == $value){
-                                    echo " selected ";
-                                }
-                                echo ">{$value}</option>";
-                            } ?>
-
-                        </select>
-                        <div class="typeahead__container" style="width: 100%;display:inline-block;">
-                            <div class="typeahead__field">
-                                <span class="typeahead__query">
-                                    <input placeholder="<?php echo _REF_SEARCH.' du '.$numDepList[0]; ?>" style="margin-left:0px;"
-                                        class="<?php echo $fieldAddressClass; ?>"
-                                        name="searchAddress" autocomplete="off" type="text" id="searchAddress" value="" />
-                                </span>
-
-                            </div>
-                        </div>
-                        <input name="ban_id" type="hidden" id="ban_id" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['BAN_ID'])); ?>"
-                        />
-
-                        <script>
-                            $j("#numDep").chosen({
-                                width: "10%",
-                                disable_search_threshold: 10
-                            });
-                            reloadTypeahead($j("#numDep")[0]);
-                        </script>
-                        <style>
-                            .typeahead__cancel-button {
-                                padding: 4px 10px;
-                            }
-
-                            #numDep_chosen .chosen-drop {
-                                width: 70px;
-                            }
-
-                            #numDep_chosen .chosen-single {
-                                border-radius: 5px 0 0 5px
-                            }
-
-                            #searchAddress {
-                                height: 25px;
-                                min-height: inherit;
-                                padding: 4px
-                            }
-                        </style>
-                    </div>
-                </td>
-                <script>
-                    $j("#searchAddress").typeahead({
-                        delay: '500',
-                        minLength: 3,
-                        order: "asc",
-                        filter: false,
-                        dynamic: true,
-                        maxItem: 10,
-                        display: "address",
-                        templateValue: "{{address}}",
-                        emptyTemplate: "Aucune adresse n'existe avec <b>{{query}}</b>",
-                        source: {
-                            ajax: {
-                                type: "GET",
-                                dataType: "json",
-                                url: "../../rest/autocomplete/banAddresses",
-                                data: {
-                                    address: "{{query}}",
-                                    department: $j("#numDep").val()
-                                }
-                            }
-                        },
-                        callback: {
-                            onClickAfter: function(node, a, item, event) {
-                                setRefAdresse(item);
-                            }
-                        }
-                    });
-                    $j(".typeahead__list").css({
-                        "width": "100% important"
-                    });
-                </script>
-            </tr>
-            <tr class="refMaarch">
-                <td>
-                    <label for="num">
-                        <?php echo _NUM; ?>: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="num"
-                        type="text" id="num" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_NUM'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-            <tr class="refMaarch">
-                <td>
-                    <label for="street" style="width:auto;">
-                        <?php echo _STREET; ?>: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="street"
-                        type="text" id="street" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_STREET'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-            <tr class="refMaarch">
-                <td>
-                    <label for="cp" style="width:auto;">
-                        <?php echo _POSTAL_CODE; ?>&nbsp;:</label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="cp"
-                        type="text" id="cp" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_CP'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                    <div id="show_town" class="autocomplete">
-                        <script type="text/javascript">
-                            initList_hidden_input2('cp', 'show_town', '<?php $_SESSION['
-                                config ']['
-                                businessappurl ']; ?>index.php?display=true&dir=indexing_searching&page=ajaxShowVille&id=<?php functions::xecho($id); ?>',
-                                'what', '2', 'town', 'cp');
-                        </script>
-                    </div>
-                </td>
-            </tr>
-            <tr class="refMaarch">
-                <td>
-                    <label for="town" style="width:auto;">
-                        <?php echo _TOWN; ?>: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="town"
-                        type="text" id="town" onkeyup="this.value=this.value.toUpperCase()" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_TOWN'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-                <div id="show_postal_code" class="autocomplete">
-                    <script type="text/javascript">
-                        initList_hidden_input3('town', 'show_postal_code', '<?php $_SESSION['
-                            config ']['
-                            businessappurl ']; ?>index.php?display=true&dir=indexing_searching&page=ajaxShowCodePostal&id=<?php functions::xecho($id); ?>',
-                            'what', '2', 'cp', 'town');
-                    </script>
-                </div>
-            </tr>
-            <tr class="refMaarch">
-                <td>
-                    <label for="country" style="width:auto;">
-                        <?php echo _COUNTRY; ?>: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="country"
-                        type="text" onkeyup="this.value=this.value.toUpperCase()" id="country" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_COUNTRY'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td colspan="2">
-                    <hr/>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="phone" style="width:auto;">
-                        <?php echo _PHONE; ?>&nbsp;: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="phone"
-                        type="text" onfocus="$('rule_phone').style.display='table-row'" onblur="$('rule_phone').style.display='none';"
-                        id="phone" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['PHONE'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-            <?php if ($mode == 'add' || !empty($_SESSION['m_admin']['address']['BAN_ID'])) {
-                                ?>
-                            <script type="text/javascript">
-                                $j('#refMaarch').click();
-                            </script>
-                        <?php
-
-                            } ?>
-            <tr style="display:none;" id="rule_phone">
-                <td>&nbsp;</td>
-                <td align="right">
-                    <i>
-                        <?php echo _FORMAT_PHONE; ?>
-                    </i>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="mail" style="width:auto;">
-                        <?php echo _EMAIL; ?>&nbsp;: </label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="mail"
-                        type="text" id="mail" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['MAIL'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="website" style="width:auto;">
-                        <?php echo _WEBSITE; ?>&nbsp;:</label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="website"
-                        type="text" id="website" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['WEBSITE'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="comp_data" style="width:auto;">
-                        <?php echo _COMP_DATA; ?>&nbsp;:</label>
-                </td>
-                <td align="right">
-                    <textarea style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="comp_data"
-                        id="comp_data"><?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['OTHER_DATA'])); ?></textarea>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="m2m_id" style="width:auto;">
-                        <?php echo _M2M_ID; ?>:</label>
-                </td>
-                <td align="right">
-                    <input style="margin-left:0px;" class="<?php echo $fieldAddressClass; ?>" name="m2m_id"
-                        id="m2m_id" type="text" value="<?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['M2M_ID'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <?php echo _IS_PRIVATE; ?>&nbsp;: </td>
-                <td align="right">
-                    <input class="<?php echo $fieldAddressClass; ?>" type="radio" class="check" name="is_private"
-                        value="Y" <?php if ($_SESSION[ 'm_admin'][ 'address'][ 'IS_PRIVATE']=='Y') {
-                                ?> checked="checked"
-                    <?php
-
-                            } ?>/>
-                    <?php echo _YES; ?>
-                    <input type="radio" class="check" name="is_private" value="N" <?php if ($_SESSION[ 'm_admin'][
-                        'address'][ 'IS_PRIVATE']=='N' or $_SESSION[ 'm_admin'][ 'address'][ 'IS_PRIVATE'] !='Y') {
-                                ?> checked="checked"
-                    <?php
-
-                            } ?>/>
-                    <?php echo _NO; ?>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr style="line-height: 20px;opacity:0.8;" align="center">
-                <td colspan="4">
-                    <?php echo _HELP_PRIVATE; ?>
-                </td>
-            </tr>
-        </table>
-    </div>
-    <br>
-    <table width="600px">
-        <tr align="left">
-            <td colspan="4" onclick="toggleBlock('salutation_div', 'divStatus_salutation_div');">
-                <label>
-                    <span id="divStatus_salutation_div" style="color:#1C99C5;">
-                        <i class="fa fa-minus-square"></i>
-                    </span>&nbsp;
-                    <b>
-                        <?php echo _SALUTATION; ?>
-                    </b>
-                </label>
-            </td>
-        </tr>
-    </table>
-    <div id="salutation_div" style="display:inline">
-        <table width="600px" id="frmaddress_table2">
-            <tr>
-                <td width="50%">
-                    <label for="salutation_header" style="width:auto;">
-                        <?php echo _SALUTATION_HEADER; ?>&nbsp;:</label>
-                </td>
-                <td width="50%" align="right">
-                    <textarea style="margin-left:0px;" class="<?php echo $fieldSalutationClass; ?>"
-                        name="salutation_header" id="salutation_header"><?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['SALUTATION_HEADER'])); ?></textarea>
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td width="50%">
-                    <label for="salutation_footer" style="width:auto;">
-                        <?php echo _SALUTATION_FOOTER; ?>&nbsp;:</label>
-                </td>
-                <td width="50%" align="right">
-                    <textarea style="margin-left:0px;" class="<?php echo $fieldSalutationClass; ?>"
-                        name="salutation_footer" id="salutation_footer"><?php functions::xecho($func->show_str($_SESSION['m_admin']['address']['SALUTATION_FOOTER'])); ?></textarea>
-                    <span class="blue_asterisk" style="visibility:visible;">*</span>
-                </td>
-            </tr>
-        </table>
-    </div>
-    <input name="mode" type="hidden" value="<?php echo $mode; ?>" />
-    <p>
-
-        <input class="button" type="submit" name="Submit" onclick='$("frmcontact").submit();this.disabled="disabled";this.style.opacity="0.5";'
-            value="<?php echo _VALIDATE; ?>" />
-        <?php
-
-                    $cancel_target = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_up';
-            if (!$admin) {
-                $cancel_target = $_SESSION['config']['businessappurl'].'index.php?page=my_contact_up&amp;dir=my_contacts&amp;load';
-            }
-            if ($iframe == 'iframe') {
-                $cancel_target = 'index.php?display=false&page=create_contact_iframe&dir=my_contacts';
-            } elseif ($iframe == 'fromContactIframe') {
-                $cancel_target = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&seeAllAddresses&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id'];
-            } elseif ($iframe == 'editDetail' || $iframe == 'editDetailSender') {
-                $cancel_target = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&created=cancelDetail';
-            }
-            if (isset($_SESSION['contact_address']['fromContactAddressesList']) && $_SESSION['contact_address']['fromContactAddressesList'] != '') {
-                $cancel_target = $_SESSION['config']['businessappurl'].'index.php?page=contact_addresses_list';
-                $_SESSION['contact_address']['fromContactAddressesList'] = '';
-            }
-
-            if ($iframe == 'iframe_add_up') {
-                $see_all_addresses = $_SESSION['config']['businessappurl'].'index.php?display=false&dir=my_contacts&page=info_contact_iframe&seeAllAddresses&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id'];
-                if ($_SESSION['AttachmentContact'] == '1') {
-                    ?>
-        <input type="button" class="button" name="cancel" value="<?php echo _CANCEL; ?>"
-            <?php $core_tools=new core_tools();
-                    if ($core_tools->test_service('my_contacts', 'apps', false)) {
-                        ?>onclick="new Effect.BlindUp(parent.document.getElementById('create_contact_div_attach'));new
-        Effect.BlindUp(parent.document.getElementById('info_contact_div_attach'));simpleAjax('
-        <?php echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&page=unsetAttachmentContact');return false;"
-        <?php
-
-                    } else {
-                        ?>onclick="new Effect.BlindUp(parent.document.getElementById('info_contact_div_attach'));simpleAjax('
-        <?php echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&page=unsetAttachmentContact');return false;"
-        <?php
-
-                    } ?>
-        />
-        <?php
-
-                } else {
-                    ?>
-        <input type="button" class="button" name="cancel" value="<?php echo _CANCEL; ?>"
-            <?php $core_tools=new core_tools();
-                    if ($core_tools->test_service('my_contacts', 'apps', false)) {
-                        ?>onclick="new Effect.BlindUp(parent.document.getElementById('create_contact_div'));new
-        Effect.BlindUp(parent.document.getElementById('info_contact_div'));return false;"
-        <?php
-
-                    } else {
-                        ?>onclick="new Effect.BlindUp(parent.document.getElementById('info_contact_div'));return false;"
-        <?php
-
-                    } ?>
-        />
-        <?php
-
-                } ?>
-        <input type="button" class="button" name="cancel" value="<?php echo _SEE_ALL_ADDRESSES; ?>"
-            onclick="javascript:window.location.href='<?php echo $see_all_addresses; ?>';"
-        />
-        <?php
-
-            } else {
-                ?>
-        <input type="button" class="button" name="cancel" value="<?php echo _CANCEL; ?>"
-            onclick="javascript:window.location.href='<?php echo $cancel_target; ?>';"
-        />
-        <?php
-
-            } ?>
-    </p>
-</form>
-
-    <script type="text/javascript">
-        var fieldsCtrl = <?php echo $contactsFilling['rating_columns']; ?>;
-        contactMapping(fieldsCtrl, "frmcontact");
-    </script>
-
-<?php
-                if ($mode == 'up' && $admin) {
-                    ?>
-    <script type="text/javascript">
-        launch_autocompleter('<?php echo $_SESSION['
-            config ']['
-            businessappurl ']; ?>index.php?display=true&page=users_autocomplete_list', 'owner',
-            'show_user');
-    </script>
-    <?php
-
-                }
-        } ?>
-</div>
-<?php
-
-    }
-
-    /**
-     * Return the address data in sessions vars.
-     *
-     * @param string $mode add or up
-     */
-    public function addressinfo($mode)
-    {
-        // return the user information in sessions vars
-        $func = new functions();
-        if ($_REQUEST['title'] != '') {
-            $_SESSION['m_admin']['address']['TITLE'] = $func->wash(
-                $_REQUEST['title'], 'no', _TITLE2.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['TITLE'] = '';
-        }
-
-        if ($_REQUEST['contact_purposes'] != '') {
-            $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $func->wash(
-                $_REQUEST['contact_purposes'], 'no', _CONTACT_PURPOSE.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = '';
-        }
-
-        $_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'] = $func->wash(
-            $_REQUEST['new_id'], 'no', _CONTACT_PURPOSE.' ', 'yes', 0, 255
-        );
-
-        if ($_REQUEST['m2m_id'] != '') {
-            $_SESSION['m_admin']['address']['M2M_ID'] = $func->wash(
-                $_REQUEST['m2m_id'], 'no', _M2M_ID.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['M2M_ID'] = '';
-        }
-
-        if ($_REQUEST['departement'] != '') {
-            $_SESSION['m_admin']['address']['DEPARTEMENT'] = $func->wash(
-                $_REQUEST['departement'], 'no', _DEPARTEMENT.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['DEPARTEMENT'] = '';
-        }
-
-        if ($_REQUEST['lastname'] != '') {
-            $_SESSION['m_admin']['address']['LASTNAME'] = $func->wash(
-                $_REQUEST['lastname'], 'no', _LASTNAME.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['LASTNAME'] = '';
-        }
-
-        if ($_REQUEST['firstname'] != '') {
-            $_SESSION['m_admin']['address']['FIRSTNAME'] = $func->wash(
-                $_REQUEST['firstname'], 'no', _FIRSTNAME.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['FIRSTNAME'] = '';
-        }
-
-        if ($_REQUEST['function'] != '') {
-            $_SESSION['m_admin']['address']['FUNCTION'] = $func->wash(
-                $_REQUEST['function'], 'no', _FUNCTION.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['FUNCTION'] = '';
-        }
-
-        if ($_REQUEST['ban_id'] != '' && $_REQUEST['refMaarch'] == 'Y') {
-            $_SESSION['m_admin']['address']['BAN_ID'] = $func->wash(
-                $_REQUEST['ban_id'], 'no', _ID.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['BAN_ID'] = '';
-        }
-
-        if ($_REQUEST['num'] != '') {
-            $_SESSION['m_admin']['address']['ADD_NUM'] = $func->wash(
-                $_REQUEST['num'], 'no', _NUM.' ', 'yes', 0, 32
-            );
-        } else {
-            $_SESSION['m_admin']['address']['ADD_NUM'] = '';
-        }
-
-        if ($_REQUEST['street'] != '') {
-            $_SESSION['m_admin']['address']['ADD_STREET'] = $func->wash(
-                $_REQUEST['street'], 'no', _STREET.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['ADD_STREET'] = '';
-        }
-
-        if ($_REQUEST['add_comp'] != '') {
-            $_SESSION['m_admin']['address']['ADD_COMP'] = $func->wash(
-                $_REQUEST['add_comp'], 'no', ADD_COMP.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['ADD_COMP'] = '';
-        }
-
-        if ($_REQUEST['town'] != '') {
-            $_SESSION['m_admin']['address']['ADD_TOWN'] = $func->wash(
-                $_REQUEST['town'], 'no', _TOWN.' ', 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['ADD_TOWN'] = '';
-        }
-        if ($_REQUEST['cp'] != '') {
-            $_SESSION['m_admin']['address']['ADD_CP'] = $func->wash(
-                $_REQUEST['cp'], 'no', _POSTAL_CODE, 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['ADD_CP'] = '';
-        }
-        if ($_REQUEST['country'] != '') {
-            $_SESSION['m_admin']['address']['ADD_COUNTRY'] = $func->wash(
-                $_REQUEST['country'], 'no', _COUNTRY, 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['ADD_COUNTRY'] = '';
-        }
-        if ($_REQUEST['phone'] != '') {
-            $_SESSION['m_admin']['address']['PHONE'] = $func->wash(
-                $_REQUEST['phone'], 'phone', _PHONE, 'yes', 0, 20
-            );
-        } else {
-            $_SESSION['m_admin']['address']['PHONE'] = '';
-        }
-        if ($_REQUEST['mail'] != '') {
-            $_SESSION['m_admin']['address']['MAIL'] = $func->wash(
-                $_REQUEST['mail'], 'mail', _MAIL, 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['MAIL'] = '';
-        }
-        if ($_REQUEST['comp_data'] != '') {
-            $_SESSION['m_admin']['address']['OTHER_DATA'] = $func->wash(
-                $_REQUEST['comp_data'], 'no', _COMP_DATA, 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['OTHER_DATA'] = '';
-        }
-        if ($_REQUEST['website'] != '') {
-            $_SESSION['m_admin']['address']['WEBSITE'] = $func->wash(
-                $_REQUEST['website'], 'no', _WEBSITE, 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['WEBSITE'] = '';
-        }
-        if ($_REQUEST['occupancy'] != '') {
-            $_SESSION['m_admin']['address']['OCCUPANCY'] = $func->wash(
-                $_REQUEST['occupancy'], 'no', _OCCUPANCY, 'yes', 0, 1024
-            );
-        } else {
-            $_SESSION['m_admin']['address']['occupancy'] = '';
-        }
-        if ($_REQUEST['salutation_header'] != '') {
-            $_SESSION['m_admin']['address']['SALUTATION_HEADER'] = $func->wash(
-                $_REQUEST['salutation_header'], 'no', _SALUTATION_HEADER, 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['SALUTATION_HEADER'] = '';
-        }
-        if ($_REQUEST['salutation_footer'] != '') {
-            $_SESSION['m_admin']['address']['SALUTATION_FOOTER'] = $func->wash(
-                $_REQUEST['salutation_footer'], 'no', _SALUTATION_FOOTER, 'yes', 0, 255
-            );
-        } else {
-            $_SESSION['m_admin']['address']['SALUTATION_FOOTER'] = '';
-        }
-        $_SESSION['m_admin']['address']['IS_PRIVATE'] =
-            $_REQUEST['is_private'];
-
-        if (isset($_REQUEST['owner']) && $_REQUEST['owner'] != '') {
-            if (preg_match('/\((.|\s|\d|\h|\w)+\)$/i', $_REQUEST['owner']) == 0) {
-                $_SESSION['error'] = _OWNER.' '._WRONG_FORMAT.'.<br/>'
-                                   ._USE_AUTOCOMPLETION;
-            } else {
-                $_SESSION['m_admin']['address']['OWNER'] = str_replace(
-                    ')', '', substr($_REQUEST['owner'],
-                    strrpos($_REQUEST['owner'], '(') + 1)
-                );
-                $_SESSION['m_admin']['address']['OWNER'] = $func->wash(
-                    $_SESSION['m_admin']['address']['OWNER'], 'no',
-                    _OWNER.' ', 'yes', 0, 32
-                );
-            }
-        } else {
-            $_SESSION['m_admin']['address']['OWNER'] = '';
-        }
-
-        $_SESSION['m_admin']['address']['order'] = $_REQUEST['order'];
-        $_SESSION['m_admin']['address']['order_field'] = $_REQUEST['order_field'];
-        $_SESSION['m_admin']['address']['what'] = $_REQUEST['what'];
-        $_SESSION['m_admin']['address']['start'] = $_REQUEST['start'];
-    }
-
-    /**
-     * Return the label from an id.
-     *
-     * @param int    $contact_type_id
-     * @param string $table
-     */
-    public function get_label_contact($contact_type_id, $table)
-    {
-        $db = new Database();
-        $stmt = $db->query('SELECT label FROM '.$table.' WHERE id = ?', array($contact_type_id));
-        $res = $stmt->fetchObject();
-
-        return functions::show_string($res->label);
-    }
-
-    public function get_civility_contact($title)
-    {
-        // $core = new core_tools();
-        if (file_exists(
-            $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR
-            .$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'
-            .DIRECTORY_SEPARATOR.$_SESSION['config']['app_id']
-            .DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR
-            .'entreprise.xml'
-        )
-        ) {
-            $path = $_SESSION['config']['corepath'].'custom'
-                  .DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']
-                  .DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR
-                  .$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'xml'
-                  .DIRECTORY_SEPARATOR.'entreprise.xml';
-        } else {
-            $path = 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id']
-                  .DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR
-                  .'entreprise.xml';
-        }
-        $xml = simplexml_load_file($path);
-        // $xml = simplexml_load_file('apps'.DIRECTORY_SEPARATOR.'maarch_entreprise'.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'entreprise.xml');
-        if ($xml != false) {
-            $result = $xml->xpath('/ROOT/titles');
-            foreach ($result as $key => $value) {
-                foreach ($value as $key2 => $value2) {
-                    if ($value2->id == $title) {
-                        $title_value = (string) $value2->label;
-                    }
-                }
-            }
-        }
-
-        return functions::show_string($title_value);
-    }
-
-    public function type_purpose_address_del($id, $admin = true, $tablename, $mode = 'contact_type', $deleted_sentence, $warning_sentence, $title, $reaffect_sentence, $new_sentence, $choose_sentence, $page_return, $page_del, $name)
-    {
-        $nb_elements = 0;
-        $db = new Database();
-        $order = $_REQUEST['order'];
-        $order_field = $_REQUEST['order_field'];
-        $start = $_REQUEST['start'];
-        $what = $_REQUEST['what'];
-        $path = $_SESSION['config']['businessappurl'].'index.php?page='.$page_return.'&order='.$order.'&order_field='.$order_field.'&start='.$start.'&what='.$what;
-        $path_del = $_SESSION['config']['businessappurl'].'index.php?page='.$page_del.'&order='.$order.'&order_field='.$order_field.'&start='.$start.'&what='.$what;
-        if (!$admin) {
-            if ($mode == 'contact_address') {
-                $path = $_SESSION['config']['businessappurl'].'index.php?page=my_contact_up&dir=my_contacts&load&order='.$order.'&order_field='.$order_field.'&start='.$start.'&what='.$what;
-            }
-        }
-
-        if (!empty($id)) {
-            if ($mode == 'contact_type') {
-                $stmt = $db->query('SELECT contact_id FROM '.$_SESSION['tablename']['contacts_v2']
-                .' WHERE contact_type = ?', array($id));
-            } elseif ($mode == 'contact_purpose') {
-                $stmt = $db->query('SELECT id FROM '.$_SESSION['tablename']['contact_addresses']
-                    .' WHERE contact_purpose_id = ?', array($id));
-            }
-
-            if (!empty($stmt) && $stmt->rowCount() > 0) {
-                $nb_elements = $nb_elements + $stmt->rowCount();
-            }
-
-            if ($mode == 'contact_address') {
-                $aRes = [];
-                $stmt = $db->query("SELECT res_id FROM res_letterbox  WHERE status <> 'DEL' AND address_id = ?", array($id));
-                while($object = $stmt->fetchObject()){
-                    $aRes[$object->res_id] = $object->res_id;
-                }
-                $stmt = $db->query("SELECT DISTINCT rl.res_id FROM contacts_res cr LEFT JOIN res_letterbox rl ON rl.res_id = cr.res_id WHERE rl.status <> 'DEL' AND cr.address_id = ?", array($id));
-                while($object = $stmt->fetchObject()){
-                    $aRes[$object->res_id] = $object->res_id;
-                }
-                $stmt = $db->query("SELECT DISTINCT rl.res_id FROM resource_contacts cr LEFT JOIN res_letterbox rl ON rl.res_id = cr.res_id WHERE rl.status <> 'DEL' AND cr.type = 'contact' AND cr.item_id = ?", array($id));
-                while($object = $stmt->fetchObject()){
-                    $aRes[$object->res_id] = $object->res_id;
-                }
-                $nb_elements = count($aRes);
-            } ?>
-
-<div class="error">
-    <b>
-        <?php
-                        functions::xecho($_SESSION['error']);
-            $_SESSION['error'] = ''; ?>
-    </b>
-</div>
-<br>
-
-<h1>
-    <i class="fa fa-times fa-2x"></i>
-    <?php
-                        functions::xecho($title); ?>
-</h1>
-<?php
-
-            if ($nb_elements == 0 && $mode != 'contact_address') {
-                $db->query('DELETE FROM '.$tablename.' WHERE id = ?', array($id));
-
-                if ($_SESSION['history'][$page_del] == 'true') {
-                    require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php';
-                    $users = new history();
-                    $users->add($tablename, $id, 'DEL', $page_del, $title.' '.strtolower(_NUM).$id.'', $_SESSION['config']['databasetype']);
-                }
-
-                $_SESSION['error'] = $deleted_sentence;
-
-                unset($_SESSION['m_admin']); ?>
-                    <script type="text/javascript">
-                        window.location.href="<?php functions::xecho($path); ?>";
-                    </script>   
-                <?php
-
-            } elseif ($nb_elements > 0) {
-                ?>
-
-<div id="main_error">
-    <b>
-        <?php
-                        functions::xecho($warning_sentence); ?>
-    </b>
-</div>
-<br>
-<br>
-
-<form name="contact_type_del" id="contact_type_del" method="post" class="forms" action="<?php functions::xecho($path_del); ?>">
-    <input type="hidden" value="<?php functions::xecho($id); ?>" name="id">
-    <h2 class="tit">
-        <?php functions::xecho($reaffect_sentence).' : <i>'.$label.'</i>'; ?>
-    </h2>
-    <?php
-                    if ($nb_elements > 0) {
-                        if ($mode == 'contact_type') {
-                            echo '<br><b> - '.$nb_elements.'</b> '._CONTACTS;
-                        } elseif ($mode == 'contact_purpose') {
-                            echo '<br><b> - '.$nb_elements.'</b> '._ADDRESSES;
-                        } elseif ($mode == 'contact_address') {
-                            echo '<br><b> - '.$nb_elements.'</b> '._DOC_S;
-                        } ?>
-    <br>
-    <br>
-
-    <?php
-                            if ($mode == 'contact_address') {
-                                $stmt = $db->query('SELECT * FROM '.$_SESSION['tablename']['contacts_v2']
-                                .' WHERE contact_id = ?', array($_SESSION['contact']['current_contact_id']));
-                                while ($line = $stmt->fetchObject()) {
-                                    $CurrentContact = $this->get_label_contact($line->contact_type, $_SESSION['tablename']['contact_types']).' : ';
-                                    if ($line->is_corporate_person == 'N') {
-                                        $CurrentContact = functions::show_string($line->lastname).' '.functions::show_string($line->firstname);
-                                        if ($line->society != '') {
-                                            $CurrentContact .= ' ('.$line->society.')';
-                                        }
-                                    } else {
-                                        $CurrentContact .= $line->society;
-                                        if ($line->society_short != '') {
-                                            $CurrentContact .= ' ('.$line->society_short.')';
-                                        }
-                                    }
-                                } ?>
-
-    <td>
-        <label for="contact">
-            <?php echo _NEW_CONTACT; ?>: </label>
-    </td>
-
-    <td class="indexing_field">
-        <input name="new_contact" id="new_contact" value="<?php functions::xecho($CurrentContact); ?>"
-            onchange="erase_contact_external_id('new_contact', 'new_contact_id')" />
-        <div id="show_contact_label" class="autocomplete">
-            <script type="text/javascript">
-                initList_hidden_input('new_contact', 'show_contact_label',
-                    '<?php echo $_SESSION['
-                    config ']['
-                    businessappurl ']; ?>index.php?display=true&page=contacts_v2_list_by_name',
-                    'what', '2', 'new_contact_id');
-            </script>
-        </div>
-        <input type="hidden" id="new_contact_id" name="new_contact_id" value="<?php functions::xecho($_SESSION['contact']['current_contact_id']); ?>"
-        />
-    </td>
-    <br>
-    <br>
-
-    <?php
-
-                            } ?>
-
-    <td>
-        <label for="contact">
-            <?php functions::xecho($new_sentence); ?>: </label>
-    </td>
-    <td class="indexing_field">
-        <?php 
-                            if ($mode == 'contact_address') {
-                                $_SESSION['contact']['current_address_id'] = $id; ?>
-        <input name="new_id" id="new_id" value="" />
-        <div id="show_contact" class="autocomplete">
-            <script type="text/javascript">
-                initList_hidden_input_before('new_id', 'show_contact', '<?php echo $_SESSION['
-                    config ']['
-                    businessappurl ']; ?>index.php?display=true&page=contact_addresses_list_by_name',
-                    'what', '2', 'new', 'reaffectAddress', 'new_contact_id');
-            </script>
-        </div>
-        <input type="hidden" id="new" name="new" />
-        <?php
-
-                            } elseif ($mode == 'contact_purpose') {
-                                ?>
-        <input name="new_id" id="new_id" value="" />
-        <div id="show_contact" class="autocomplete">
-            <script type="text/javascript">
-                initList_hidden_input('new_id', 'show_contact', '<?php echo $_SESSION['
-                    config ']['
-                    businessappurl ']; ?>index.php?display=true&page=contact_purposes_list_by_name&id=<?php functions::xecho($id); ?>',
-                    'what', '2', 'new');
-            </script>
-        </div>
-        <input type="hidden" id="new" name="new" />
-        <?php
-
-                            } else {
-                                $stmt = $db->query('SELECT id, label FROM '.$tablename.' WHERE id <> ?', array($id));
-
-                                while ($res = $stmt->fetchObject()) {
-                                    $array[$res->id] = functions::protect_string_db($res->label);
-                                } ?>
-        <select name="new" id="new">
-            <option value="">
-                <?php functions::xecho($choose_sentence); ?>
-            </option>
-            <?php
-                                    foreach ($array as $key => $label) {
-                                        ?>
-            <option value="<?php functions::xecho($key); ?>">
-                <?php functions::xecho($label); ?>
-            </option>
-            <?php
-
-                                    } ?>
-        </select>
-        <?php
-
-                            } ?>
-    </td>
-
-    <br/>
-    <br/>
-    <p class="buttons">
-        <input type="submit" value="<?php echo _DEL_AND_REAFFECT; ?>" name="valid" class="button"
-            onclick="return(confirm('<?php echo _REALLY_DELETE;
-                        if (isset($page_name) && $page_name == 'users') {
-                            functions::xecho($complete_name);
-                        } elseif (isset($admin_id)) {
-                            functions::xecho(' '.$admin_id);
-                        } ?> ?\n\r\n\r<?php echo _DEFINITIVE_ACTION; ?>'));"
-        />
-        <input type="button" value="<?php echo _CANCEL; ?>" onclick="window.location.href='<?php functions::xecho($path); ?>';"
-            class="button" />
-    </p>
-    <?php
-
-                    } ?>
-</form>
-
-<hr/>
-<?php
-
-            }
-
-            if ($mode == 'contact_address') {
-                ?>
-<br>
-<br>
-
-<h2>
-    <i class="fa fa-share"></i>
-    <?php
-                        echo _MOVE_CONTACT_ADDRESS; ?>
-</h2>
-
-<br>
-<?php echo _INFO_MOVE_CONTACT_ADDRESS; ?>
-
-<br>
-<br>
-<form name="contact_type_del" id="contact_type_del" method="post" class="forms" action="<?php functions::xecho($path_del); ?>">
-    <input type="hidden" value="<?php functions::xecho($id); ?>" name="id">
-    <td>
-        <label for="new_contact_reaffect">
-            <?php echo _NEW_CONTACT; ?>: </label>
-    </td>
-
-    <td class="indexing_field">
-        <input name="new_contact_reaffect" id="new_contact_reaffect" value="" onchange="erase_contact_external_id('new_contact_reaffect', 'new_contact_id_reaffect')"
-        />
-        <div id="show_contact_label_reaffect" class="autocomplete">
-            <script type="text/javascript">
-                initList_hidden_input('new_contact_reaffect', 'show_contact_label_reaffect',
-                    '<?php echo $_SESSION['
-                    config ']['
-                    businessappurl ']; ?>index.php?display=true&page=contacts_v2_list_by_name&id=<?php functions::xecho($_SESSION['
-                    contact ']['
-                    current_contact_id ']); ?>', 'what', '2', 'new_contact_id_reaffect');
-            </script>
-        </div>
-        <input type="hidden" id="new_contact_id_reaffect" name="new_contact_id_reaffect" />
-    </td>
-    <br/>
-    <br/>
-    <p class="buttons">
-        <input type="submit" value="<?php echo _MOVE; ?>" name="move" class="button" onclick="return(confirm('<?php echo _REALLY_MOVE;
-                if (isset($page_name) && $page_name == 'users') {
-                    functions::xecho($complete_name);
-                } elseif (isset($admin_id)) {
-                    functions::xecho(' '.$admin_id);
-                } ?> ?\n\r\n\r<?php echo _DEFINITIVE_ACTION; ?>'));"
-        />
-
-        <?php if ($nb_elements == 0) {
-                    ?>
-        <input type="submit" value="<?php echo _DELETE_CONTACT_ADDRESS; ?>" name="delete"
-            class="button" onclick="return(confirm('<?php echo _REALLY_DELETE;
-                    if (isset($page_name) && $page_name == 'users') {
-                        functions::xecho($complete_name);
-                    } elseif (isset($admin_id)) {
-                        functions::xecho(' '.$admin_id);
-                    } ?> ?\n\r\n\r<?php echo _DEFINITIVE_ACTION; ?>'));"
-        />
-        <?php
-
-                } ?>
-
-        <input type="button" value="<?php echo _CANCEL; ?>" onclick="window.location.href='<?php functions::xecho($path); ?>';"
-            class="button" />
-    </p>
-</form>
-<br>
-<br>
-
-<?php
-
-            }
-            exit;
-        } else {
-            $_SESSION['error'] = $name.' '._EMPTY;
-        } ?>
-        <script type="text/javascript">
-            window.location.href="<?php functions::xecho($path); ?>";
-        </script>
-        <?php
-        exit;
-    }
-
-    /**
-     * Contact form with every field disabled.
-     */
-    public function get_contact_form()
-    {
-        $func = new functions();
-        $business = new business_app_tools();
-
-        $db = new Database();
-        $stmt = $db->query('SELECT contact_target FROM contact_types', array());
-        $hasCorporate = false;
-        $hasNoCorporate = false;
-
-        while ($contactType = $stmt->fetchObject()) {
-            if (in_array($contactType->contact_target, ['both', 'corporate']) || empty($contactType->contact_target)) {
-                $hasCorporate = true;
-            }
-            if (in_array($contactType->contact_target, ['both', 'no_corporate']) || empty($contactType->contact_target)) {
-                $hasNoCorporate = true;
-            }
-        } ?>
-<form class="forms">
-    <table width="600px">
-        <tr align="left">
-            <td colspan="4" onclick="toggleBlock('info_contact_div', 'divStatus_contact_div');">
-                <label>
-                    <span id="divStatus_contact_div" style="color:#1C99C5;">
-                        <i class="fa fa-minus-square"></i>
-                    </span>&nbsp;
-                    <b>
-                        <?php echo _CONTACT; ?>
-                    </b>
-                </label>
-            </td>
-        </tr>
-    </table>
-    <div id="info_contact_div" style="display:inline;">
-        <table width="600px">
-            <tr>
-                <td class="indexing_field" align="center" colspan="3">
-                    <span <?php if (!$hasCorporate) {
-            ?> style="display:none"
-                        <?php
-
-        } ?>>
-                        <input disabled type="radio" class="check" name="is_corporate" value="Y" <?php if ($_SESSION[
-                            'm_admin'][ 'contact'][ 'IS_CORPORATE_PERSON']=='Y') {
-            ?> checked="checked"
-                        <?php
-
-        } ?>/>
-                        <?php echo _IS_CORPORATE_PERSON; ?>
-                    </span>
-                    <span <?php if (!$hasNoCorporate) {
-            ?> style="display:none"
-                        <?php
-
-        } ?>>
-                        <input disabled type="radio" class="check" name="is_corporate" value="N" <?php if ($_SESSION[
-                            'm_admin'][ 'contact'][ 'IS_CORPORATE_PERSON']=='N') {
-            ?> checked="checked"
-                        <?php
-
-        } ?>/>
-                        <?php echo _INDIVIDUAL; ?>
-                    </span>
-                </td>
-            </tr>
-            <tr id="contact_types_tr">
-                <td width="50%">
-                    <label style="width:auto">
-                        <?php echo _CONTACT_TYPE; ?>:</label>
-                </td>
-                <td width="45%" align="right">
-                    <input disabled class="readonly" name="contact_types" type="text" id="contact_types" value="<?php if (isset($_SESSION['m_admin']['contact']['CONTACT_TYPE'])) {
-            functions::xecho($this->get_label_contact($_SESSION['m_admin']['contact']['CONTACT_TYPE'], $_SESSION['tablename']['contact_types']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td width="50%">
-                    <label style="width:auto">
-                        <?php echo _STRUCTURE_ORGANISM; ?>:</label>
-                </td>
-                <td width="45%" class="indexing_field" align="right">
-                    <input disabled class="readonly" name="society" type="text" id="society" value="<?php if (isset($_SESSION['m_admin']['contact']['SOCIETY'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['contact']['SOCIETY']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td width="50%">
-                    <label style="width:auto">
-                        <?php echo _SOCIETY_SHORT; ?>:</label>
-                </td>
-                <td width="45%" class="indexing_field" align="right">
-                    <input disabled class="readonly" name="society_short" type="text" id="society_short" value="<?php if (isset($_SESSION['m_admin']['contact']['SOCIETY_SHORT'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['contact']['SOCIETY_SHORT']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="title_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') {
-            echo 'none';
-        } else {
-            functions::xecho($display_value);
-        } ?>">
-                <td width="50%" style="width:auto">
-                    <label>
-                        <?php echo _TITLE2; ?>:</label>
-                </td>
-                <td width="45%" class="indexing_field" align="right">
-                    <input disabled class="readonly" name="title" type="text" id="title" value="<?php if (isset($_SESSION['m_admin']['contact']['TITLE'])) {
-            functions::xecho($business->get_label_title($_SESSION['m_admin']['contact']['TITLE']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="lastname_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') {
-            echo 'none';
-        } else {
-            functions::xecho($display_value);
-        } ?>">
-                <td width="50%">
-                    <label style="width:auto">
-                        <?php echo _LASTNAME; ?>:</label>
-                </td>
-                <td width="45%" class="indexing_field" align="right">
-                    <input disabled class="readonly" name="lastname" type="text" id="lastname" value="<?php if (isset($_SESSION['m_admin']['contact']['LASTNAME'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['contact']['LASTNAME']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="firstname_p" style="display:<?php if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') {
-            echo 'none';
-        } else {
-            functions::xecho($display_value);
-        } ?>">
-                <td width="50%">
-                    <label style="width:auto">
-                        <?php echo _FIRSTNAME; ?>:</label>
-                </td>
-                <td width="45%" class="indexing_field" align="right">
-                    <input disabled class="readonly" name="firstname" type="text" id="firstname" value="<?php if (isset($_SESSION['m_admin']['contact']['FIRSTNAME'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['contact']['FIRSTNAME']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="function_p" style="display:<?php if (isset($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON']) && $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') {
-            echo 'none';
-        } else {
-            functions::xecho($display_value);
-        } ?>">
-                <td width="50%">
-                    <label style="width:auto">
-                        <?php echo _FUNCTION; ?>:</label>
-                </td>
-                <td width="45%" class="indexing_field" align="right">
-                    <input disabled class="readonly" name="function" type="text" id="function" value="<?php if (isset($_SESSION['m_admin']['contact']['FUNCTION'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['contact']['FUNCTION']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td width="50%">
-                    <label style="width:auto">
-                        <?php echo _COMP_DATA; ?>&nbsp;:</label>
-                </td>
-                <td width="45%" class="indexing_field" align="right">
-                    <textarea disabled class="readonly" name="comp_data" id="comp_data"><?php if (isset($_SESSION['m_admin']['contact']['OTHER_DATA'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['contact']['OTHER_DATA']));
-        } ?></textarea>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <?php if (!empty($_SESSION['m_admin']['communication']['VALUE'])) {
-            ?>
-            <tr>
-                <td width="50%">
-                    <label style="width:auto">
-                        <?php echo _COMMUNICATION_TYPE; ?>
-                    </label>: </td>
-                <td width="45%" class="indexing_field" align="right">
-                    <textarea disabled name="is_external_contact_id" id="is_external_contact_id"><?php if (isset($_SESSION['m_admin']['communication']['VALUE'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['communication']['VALUE']));
-            } ?></textarea>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <?php
-
-        } ?>
-        </table>
-    </div>
-</form>
-<?php
-
-    }
-
-    public function get_address_form()
-    {
-        $func = new functions();
-        $business = new business_app_tools(); ?>
-<form class="forms">
-    <table width="600px;">
-        <tr align="left">
-            <td colspan="4" onclick="toggleBlock('address_div', 'divStatus_address_div');">
-                <label>
-                    <span id="divStatus_address_div" style="color:#1C99C5;">
-                        <i class="fa fa-minus-square"></i>
-                    </span>&nbsp;
-                    <b>
-                        <?php echo _ADDRESS; ?>
-                    </b>
-                </label>
-            </td>
-        </tr>
-    </table>
-    <div id="address_div" style="display:inline">
-        <table width="600px">
-            <?php if ($_SESSION['m_admin']['address']['IS_PRIVATE'] == 'N') {
-            ?>
-            <tr id="contact_purposes_tr">
-                <td width="50%">
-                    <label for="new_id" style="width:auto;">
-                        <?php echo _CONTACT_PURPOSE; ?>&nbsp;: </label>
-                </td>
-                <td width="45%" class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="new_id" id="new_id" value="<?php functions::xecho($this->get_label_contact($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'], $_SESSION['tablename']['contact_purposes'])); ?>"
-                    />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="departement_p">
-                <td>
-                    <label for="departement" style="width:auto;">
-                        <?php echo _SERVICE; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="departement" type="text" id="departement" value="<?php if (isset($_SESSION['m_admin']['address']['DEPARTEMENT'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['DEPARTEMENT']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <?php
-
-        } ?>
-            <tr id="title_p" <?php if ($_SESSION[ 'm_admin'][ 'contact'][ 'IS_CORPORATE_PERSON']=='N') {
-            echo
-                'style="display:none"';
-        } ?>>
-                <td>
-                    <?php echo _TITLE2; ?>: </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="title" type="text" id="title" value="<?php if (isset($_SESSION['m_admin']['contact']['TITLE'])) {
-            functions::xecho($business->get_label_title($_SESSION['m_admin']['contact']['TITLE']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="lastname_p" <?php if ($_SESSION[ 'm_admin'][ 'contact'][ 'IS_CORPORATE_PERSON']=='N') {
-            echo
-                'style="display:none"';
-        } ?>>
-                <td>
-                    <label for="lastname" style="width:auto;">
-                        <?php echo _LASTNAME; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="lastname" type="text" id="lastname" value="<?php if (isset($_SESSION['m_admin']['address']['LASTNAME'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['address']['LASTNAME']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="firstname_p" <?php if ($_SESSION[ 'm_admin'][ 'contact'][ 'IS_CORPORATE_PERSON']=='N') {
-            echo 'style="display:none"';
-        } ?>>
-                <td>
-                    <label for="firstname" style="width:auto;">
-                        <?php echo _FIRSTNAME; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="firstname" type="text" id="firstname" value="<?php if (isset($_SESSION['m_admin']['address']['FIRSTNAME'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['address']['FIRSTNAME']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr id="function_p" <?php if ($_SESSION[ 'm_admin'][ 'contact'][ 'IS_CORPORATE_PERSON']=='N') {
-            echo
-                'style="display:none"';
-        } ?>>
-                <td>
-                    <label for="function" style="width:auto;">
-                        <?php echo _FUNCTION; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="function" type="text" id="function" value="<?php if (isset($_SESSION['m_admin']['address']['FUNCTION'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['address']['FUNCTION']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <?php if ($_SESSION['m_admin']['address']['IS_PRIVATE'] == 'N') {
-            ?>
-            <tr>
-                <td>
-                    <label for="occupancy" style="width:auto;">
-                        <?php echo _OCCUPANCY; ?>&nbsp;:</label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="occupancy" type="text" id="occupancy" value="<?php if (isset($_SESSION['m_admin']['address']['OCCUPANCY'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['OCCUPANCY']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="num" style="width:auto;">
-                        <?php echo _NUM; ?>: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="num" type="text" id="num" value="<?php if (isset($_SESSION['m_admin']['address']['ADD_NUM'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_NUM']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="street" style="width:auto;">
-                        <?php echo _STREET; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="street" type="text" id="street" value="<?php if (isset($_SESSION['m_admin']['address']['ADD_STREET'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_STREET']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="add_comp" style="width:auto;">
-                        <?php echo _COMPLEMENT; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="add_comp" type="text" id="add_comp" value="<?php if (isset($_SESSION['m_admin']['address']['ADD_COMP'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_COMP']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="cp" style="width:auto;">
-                        <?php echo _POSTAL_CODE; ?>&nbsp;:</label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="cp" type="text" id="cp" value="<?php if (isset($_SESSION['m_admin']['address']['ADD_CP'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_CP']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="town" style="width:auto;">
-                        <?php echo _TOWN; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="town" type="text" id="town" value="<?php if (isset($_SESSION['m_admin']['address']['ADD_TOWN'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_TOWN']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="country" style="width:auto;">
-                        <?php echo _COUNTRY; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="country" type="text" id="country" value="<?php if (isset($_SESSION['m_admin']['address']['ADD_COUNTRY'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['ADD_COUNTRY']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="phone" style="width:auto;">
-                        <?php echo _PHONE; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="phone" type="text" id="phone" value="<?php if (isset($_SESSION['m_admin']['address']['PHONE'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['PHONE']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="mail" style="width:auto;">
-                        <?php echo _EMAIL; ?>&nbsp;: </label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="mail" type="text" id="mail" value="<?php if (isset($_SESSION['m_admin']['address']['MAIL'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['MAIL']));
-            } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <?php
-
-        } ?>
-            <tr>
-                <td>
-                    <label for="website" style="width:auto;">
-                        <?php echo _WEBSITE; ?>&nbsp;:</label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="website" type="text" id="website" value="<?php if (isset($_SESSION['m_admin']['address']['WEBSITE'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['address']['WEBSITE']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="comp_data" style="width:auto;">
-                        <?php echo _COMP_DATA; ?>&nbsp;:
-                        <label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <textarea class="contact_field_margin readonly" disabled name="comp_data" id="comp_data"><?php if (isset($_SESSION['m_admin']['address']['OTHER_DATA'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['address']['OTHER_DATA']));
-        } ?></textarea>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="m2m_id" style="width:auto;">
-                        <?php echo _M2M_ID; ?>:
-                        <label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <input class="contact_field_margin readonly" disabled name="m2m_id" id="m2m_id" type="text" value="<?php if (isset($_SESSION['m_admin']['address']['M2M_ID'])) {
-            functions::xecho($func->show_str($_SESSION['m_admin']['address']['M2M_ID']));
-        } ?>" />
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <?php echo _IS_PRIVATE; ?>&nbsp;: </td>
-                <td class="indexing_field" align="right">
-                    <input type="radio" disabled class="check" name="is_private" value="Y" <?php if ($_SESSION[
-                        'm_admin'][ 'address'][ 'IS_PRIVATE']=='Y') {
-            ?> checked="checked"
-                    <?php
-
-        } ?>/>
-                    <?php echo _YES; ?>
-                    <input type="radio" disabled class="check" name="is_private" value="N" <?php if ($_SESSION[
-                        'm_admin'][ 'address'][ 'IS_PRIVATE']=='N' or $_SESSION[ 'm_admin'][ 'address'][ 'IS_PRIVATE'] !='Y') {
-            ?> checked="checked"
-                    <?php
-
-        } ?>/>
-                    <?php echo _NO; ?>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-        </table>
-    </div>
-    <?php if ($_SESSION['m_admin']['address']['IS_PRIVATE'] == 'N') {
-            ?>
-    <table width="600px">
-        <tr align="left">
-            <td colspan="4" onclick="toggleBlock('salutation_div', 'divStatus_salutation_div');">
-                <label>
-                    <span id="divStatus_salutation_div" style="color:#1C99C5;">
-                        <i class="fa fa-minus-square"></i>
-                    </span>&nbsp;
-                    <b>
-                        <?php echo _SALUTATION; ?>
-                    </b>
-                </label>
-            </td>
-        </tr>
-    </table>
-    <div id="salutation_div" style="display:inline">
-        <table width="600px">
-            <tr>
-                <td width="50%">
-                    <label for="salutation_header" style="width:auto;">
-                        <?php echo _SALUTATION_HEADER; ?>&nbsp;:</label>
-                </td>
-                <td class="indexing_field" width="45%" align="right">
-                    <textarea class="contact_field_margin readonly" disabled name="salutation_header" id="salutation_header"><?php if (isset($_SESSION['m_admin']['address']['SALUTATION_HEADER'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['SALUTATION_HEADER']));
-            } ?></textarea>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <label for="salutation_footer" style="width:auto;">
-                        <?php echo _SALUTATION_FOOTER; ?>&nbsp;:</label>
-                </td>
-                <td class="indexing_field" align="right">
-                    <textarea class="contact_field_margin readonly" disabled name="salutation_footer" id="salutation_footer"><?php if (isset($_SESSION['m_admin']['address']['SALUTATION_FOOTER'])) {
-                functions::xecho($func->show_str($_SESSION['m_admin']['address']['SALUTATION_FOOTER']));
-            } ?></textarea>
-                    <span class="blue_asterisk" style="visibility:hidden;">*</span>
-                </td>
-            </tr>
-        </table>
-    </div>
-    <?php
-
-        } ?>
-</form>
-<?php
-
-    }
-
-    public function contactEnabled($userId, $mode)
-    {
-        $db = new Database();
-        $db->query('UPDATE contacts_v2 SET enabled = ? WHERE contact_id = ?', array($mode, $userId));
-        $db->query('UPDATE contact_addresses SET enabled = ? WHERE contact_id = ?', array($mode, $userId));
-    }
-
-    public function addressEnabled($addressId, $mode)
-    {
-        $db = new Database();
-        $db->query('UPDATE contact_addresses SET enabled = ? WHERE id = ?', array($mode, $addressId));
-    }
-}
diff --git a/apps/maarch_entreprise/css/styles.css b/apps/maarch_entreprise/css/styles.css
index bbe097e43f9..d0ec3844fc2 100755
--- a/apps/maarch_entreprise/css/styles.css
+++ b/apps/maarch_entreprise/css/styles.css
@@ -340,20 +340,6 @@ a:hover {
     display: block;
 }
 
-#view_tree_contacts {
-    background:  url(static.php?filename=manage_architecture.gif) no-repeat 2px top;
-    width: 315px;
-    min-height: 110px;
-    float: left;
-    padding-top: 0px;
-    padding-right: 18px;
-    padding-bottom: 0px;
-    padding-left: 0px;
-    margin: 0px 0px 15px;
-    position: relative;
-    display: block;
-}
-
 /* floated blocks */
 
 .clear {
diff --git a/apps/maarch_entreprise/indexing_searching/autocomplete_contacts.php b/apps/maarch_entreprise/indexing_searching/autocomplete_contacts.php
deleted file mode 100755
index d672ae3387b..00000000000
--- a/apps/maarch_entreprise/indexing_searching/autocomplete_contacts.php
+++ /dev/null
@@ -1,318 +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   autocomplete_contacts
-*
-* @author  dev <dev@maarch.org>
-* @ingroup indexing_searching
-*/
-require_once 'core/class/class_request.php';
-
-$req = new request();
-$db  = new Database();
-
-if (empty($_REQUEST['table'])) {
-    exit();
-}
-$table                        = $_REQUEST['table'];
-$_SESSION['is_multi_contact'] = 'OK';
-$color                        = 'LightYellow';
-$multi_sessions_address_id    = $_SESSION['adresses']['addressid'];
-$user_ids                     = array();
-$address_ids                  = array();
-
-$arrContact                   = array();
-$arrContactCorporate          = array();
-$arrContactNonCorporate       = array();
-
-if ($_SESSION['is_multi_contact'] == 'OK') {
-    if (is_array($multi_sessions_address_id) && count($multi_sessions_address_id) > 0) {
-        for ($imulti = 0; $imulti <= count($multi_sessions_address_id); ++$imulti) {
-            if (is_numeric($multi_sessions_address_id[$imulti])) {
-                array_push($address_ids, $multi_sessions_address_id[$imulti]);
-            } else {
-                array_push($user_ids, "'".$multi_sessions_address_id[$imulti]."'");
-            }
-        }
-
-        if (!empty($address_ids)) {
-            $addresses = implode(' ,', $address_ids);
-            $request_contact = ' and ca_id not in ('.$addresses.')';
-        } else {
-            $request_contact = '';
-        }
-
-        if (!empty($user_ids)) {
-            $users = implode(' ,', $user_ids);
-            $request_user = ' and user_id not in ('.$users.')';
-        } else {
-            $request_user = '';
-        }
-    } else {
-        $request_user = '';
-        $request_contact = '';
-    }
-
-    // Order of select elements (# is for parallel check)
-    $columnTarget = array(
-        'lastname',
-        'contact_lastname',
-        'firstname#lastname',
-        'lastname#firstname',
-        'contact_firstname#contact_lastname',
-        'contact_lastname#contact_firstname',
-        'society',
-        'society_short',
-        'address_num#address_street#address_postal_code#address_town',
-    );
-
-    // Number of display lines
-    $maxResult = 30;
-
-    // Filter of common link word
-    $input = str_replace(' et ', ' ', $_REQUEST['Input']);
-    $input = str_replace(' de ', ' ', $input);
-    $input = str_replace(' la ', ' ', $input);
-    $input = str_replace(' sur ', ' ', $input);
-    $input = str_replace(' sous ', ' ', $input);
-    $keyList = explode(' ', $input);
-
-    $containResult = false;
-    $nb_total = 0;
-    // First, internal user
-    $contactRequest = "lower(translate(firstname || ' ' || lastname,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) LIKE lower(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))";
-
-    $query         = 'SELECT * FROM users WHERE '.$contactRequest.$request_user;
-    $arrayPDO      = array('%'.$_REQUEST['Input'].'%');
-    $stmt          = $db->query($query, $arrayPDO);
-    $nb_total      = $nb_total + $stmt->rowCount();
-    $aAlreadyCatch = [];
-    $itRes         = 0;
-    while ($res = $stmt->fetchObject()) {
-        if ($itRes > $maxResult) {
-            break;
-        }
-        $containResult = true;
-
-        $arr_contact_info = array($res->firstname, $res->lastname);
-        $contact_icon = "<i class='fa fa-user fa-1x' style='padding:5px;display:table-cell;vertical-align:middle;' title='"._USER."'></i>";
-
-        $contact_info = implode(' ', $arr_contact_info);
-
-        //Highlight
-        foreach ($keyList as $keyVal) {
-            $contact_info = preg_replace_callback(
-                '/'.$keyVal.'/i',
-                function ($matches) {
-                    return '<b>'.$matches[0].'</b>';
-                },
-                $contact_info
-            );
-        }
-        $arrContact[] = "<li id='".$res->user_id.", ' style='font-size:12px;background-color:$color;'>".$contact_icon.' '
-        .'<span style="display:table-cell;vertical-align:middle;">'.$contact_info.'</span>'
-    .'</li>';
-
-        ++$itRes;
-    }
-
-    // Second, other criteria define $columnTarget
-    foreach ($columnTarget as $column) {
-        $contactRequest = '';
-        $contactSubRequest = '';
-
-        $columnSql = str_replace('#', "|| ' ' ||", $column);
-
-        $contactRequest = 'lower(translate('.$columnSql.",'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) LIKE lower(translate(?,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))";
-        $orderStr      = ' ORDER by '.$columnSql.' ASC';
-        $query         = 'SELECT * FROM view_contacts WHERE '.$contactRequest.$request_contact.$orderStr;
-        $arrayPDO      = array('%'.$_REQUEST['Input'].'%');
-        $stmt          = $db->query($query, $arrayPDO);
-        $nb_total      = $nb_total + $stmt->rowCount();
-        $aAlreadyCatch = [];
-        while ($res = $stmt->fetchObject()) {
-            $containResult = true;
-
-            if ($res->is_corporate_person == 'N') {
-                $contact_icon = "<i class='fa fa-user fa-1x' style='padding:5px;display:table-cell;vertical-align:middle;' title='"._INDIVIDUAL."'></i>";
-                if (!empty($res->society)) {
-                    $arr_contact_info = array($res->contact_firstname, $res->contact_lastname, '('.$res->society.')');
-                } else {
-                    $arr_contact_info = array($res->contact_firstname, $res->contact_lastname);
-                }
-            } else {
-                $contact_icon = "<i class='fa fa-building fa-1x' style='padding:5px;display:table-cell;vertical-align:middle;' title='"._IS_CORPORATE_PERSON."'></i>";
-                $arr_contact_info = array($res->society);
-            }
-
-            $contact_info = implode(' ', $arr_contact_info);
-            $address = '';
-
-            if ((!empty($res->address_street) || !empty($res->lastname)) && $res->is_private != 'Y') {
-                if ($res->is_corporate_person == 'N') {
-                    $arr_address = array($res->address_num, $res->address_street, $res->address_postal_code, $res->address_town);
-                } else {
-                    $arr_address = array($res->firstname, $res->lastname.',', $res->address_num, $res->address_street, $res->address_postal_code, $res->address_town);
-                }
-                $address = implode(' ', $arr_address);
-            } elseif ($res->is_private == 'Y') {
-                $address = _CONFIDENTIAL_ADDRESS;
-            } else {
-                $address = _NO_ADDRESS_GIVEN;
-            }
-
-            //Highlight
-            $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'
-                .'ßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ';
-            $b = 'aaaaaaaceeeeiiiidnoooooouuuuy'
-                .'bsaaaaaaaceeeeiiiidnoooooouuuyybyRr';
-            $contact_info = utf8_decode($contact_info);
-            $contact_info = utf8_encode(strtr($contact_info, utf8_decode($a), $b));
-            $address      = utf8_decode($address);
-            $address      = utf8_encode(strtr($address, utf8_decode($a), $b));
-
-            foreach ($keyList as $keyVal) {
-                $keyVal = utf8_decode($keyVal);
-                $keyVal = utf8_encode(strtr($keyVal, utf8_decode($a), $b));
-
-                $contact_info = preg_replace_callback(
-                    '/'.$keyVal.'/i',
-                    function ($matches) {
-                        return '<b>'.$matches[0].'</b>';
-                    },
-                    $contact_info
-                );
-                $address = preg_replace_callback(
-                    '/'.$keyVal.'/i',
-                    function ($matches) {
-                        return '<b>'.$matches[0].'</b>';
-                    },
-                    $address
-                );
-            }
-            $color                        = 'LightYellow';
-
-            $rate = \Contact\controllers\ContactController::getFillingRate(['contactId' => (array)$res]);
-            if (!empty($rate)) {
-                $color = $rate['color'];
-            }
-
-            $arrContactTmp = "<li id='" . $res->contact_id . ',' . $res->ca_id . "' style='font-size:12px;background-color:$color;'>" . $contact_icon . ' '
-                . '<span style="display:table-cell;vertical-align:middle;">' . $contact_info . '</span>'
-                . '<div style="font-size:9px;font-style:italic;"> - ' . $address . '</div>'
-                . '</li>';
-
-            if ($res->is_corporate_person == 'Y') {
-                $arrContactCorporate[] = [$res, $arrContactTmp];
-            } else {
-                $arrContactNonCorporate[] = [$res, $arrContactTmp];
-            }
-
-            $aAlreadyCatch[$res->contact_id . ',' . $res->ca_id] = 'added';
-//                ++$itRes;
-        }
-    }
-
-
-    // ----------------------------------------------------------
-    // Sort on corporate person
-    uasort($arrContactCorporate, function ($a, $b) {
-        $diff =  strcmp($a[0]->society, $b[0]->society);
-
-        if ($diff != 0) {
-            return $diff;
-        }
-        $diff = strcmp($a[0]->lastname, $b[0]->lastname);
-        return $diff;
-    });
-
-    // Sort on non corporate person
-    uasort($arrContactNonCorporate, function ($a, $b) {
-        $diff =  strcmp($a[0]->contact_lastname, $b[0]->contact_lastname);
-
-        if ($diff != 0) {
-            return $diff;
-        }
-        $diff = strcmp($a[0]->society, $b[0]->society);
-        return $diff;
-    });
-
-//    $itRes = 0;
-//    $arrContact = array();
-    foreach ($arrContactCorporate as $contactCorporate) {
-        if ($itRes > $maxResult) {
-            break;
-        }
-        $arrContact[] = $contactCorporate[1];
-        $itRes++;
-    }
-
-    if ($itRes < $maxResult) {
-        foreach ($arrContactNonCorporate as $contactNonCorporate) {
-            if ($itRes > $maxResult) {
-                break;
-            }
-            $arrContact[] = $contactNonCorporate[1];
-            $itRes++;
-        }
-    }
-
-    // ----------------------------------------------------------
-
-    //Third, contacts groups
-    if ($_REQUEST['multiContact'] == "true") {
-        $contactRequest = "lower(translate(label,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) LIKE lower(translate('%".$_REQUEST['Input']."%','ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'))";
-        $id = \User\models\UserModel::getByLogin(['login' => $_SESSION['user']['UserId'], 'select' => ['id']]);
-        $contactsGroups = \Contact\models\ContactGroupModel::get([
-            'where' => [$contactRequest, '(public IS TRUE OR ? = owner)'],
-            'orderBy' => ['label ASC'],
-            'data' => [$id['id']]
-        ]);
-        $nb_total = $nb_total + count($contactsGroups);
-        foreach ($contactsGroups as $contactGroup) {
-            if ($itRes > $maxResult) {
-                break;
-            }
-            $containResult = true;
-
-            $contactIcon = "<i class='fa fa-users fa-1x' style='padding:5px;display:table-cell;vertical-align:middle;' title='" . _CONTACTS_GROUP . "'></i>";
-
-            //Highlight
-            foreach ($keyList as $keyVal) {
-                $contactGroup['label'] = preg_replace_callback(
-                    '/' . $keyVal . '/i',
-                    function ($matches) {
-                        return '<b>' . $matches[0] . '</b>';
-                    },
-                    $contactGroup['label']
-                );
-            }
-            $arrContact[] = "<li id='" . $contactGroup['id'] . ", ' style='font-size:12px;background-color:$color;'>" . $contactIcon . ' '
-                . '<span style="display:table-cell;vertical-align:middle;">' . $contactGroup['label'] . '</span>'
-                . '</li>';
-
-            ++$itRes;
-        }
-    }
-
-    if ($containResult) {
-        echo '<ul id="autocomplete_contacts_ul">';
-        echo implode(array_unique($arrContact));
-        echo '</ul>';
-        if ($maxResult < $nb_total) {
-            echo "<p align='right' style='background-color:LemonChiffon;font-size:9px;font-style:italic;padding-right:5px;' >...".$nb_total.' '._CONTACTS.' ('.$maxResult.' '._DISPLAYED.')</p>';
-        }
-    } else {
-        echo '<ul id="autocomplete_contacts_ul">';
-        echo "<li align='left' style='background-color:LemonChiffon;text-align:center;color:grey;font-style:italic;' title=\""._NO_RESULTS_AUTOCOMPLETE_CONTACT_INFO.'" >'._NO_RESULTS.'</li>';
-        echo '</ul>';
-    }
-
-    exit();
-}
-
-//$_SESSION['is_multi_contact'] = '';
diff --git a/apps/maarch_entreprise/indexing_searching/autocomplete_contacts_prepare_multi.php b/apps/maarch_entreprise/indexing_searching/autocomplete_contacts_prepare_multi.php
deleted file mode 100755
index 46ebb0846f1..00000000000
--- a/apps/maarch_entreprise/indexing_searching/autocomplete_contacts_prepare_multi.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/*
-*   Copyright 2008, 2013 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 used by an Ajax autocompleter object to get the contacts data (from users or contacts)
-*
-* @file autocomplete_contacts.php
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup indexing_searching_mlb
-*/
-
-if ($_REQUEST['paramsRequest'] == 'multi') {
-    $_SESSION['is_multi_contact'] = 'OK';
-} else {
-    $_SESSION['is_multi_contact'] = '';
-}
\ No newline at end of file
diff --git a/apps/maarch_entreprise/indexing_searching/change_doctype_details.php b/apps/maarch_entreprise/indexing_searching/change_doctype_details.php
deleted file mode 100755
index c043c9121e2..00000000000
--- a/apps/maarch_entreprise/indexing_searching/change_doctype_details.php
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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 from the details page
-*
-* @file change_doctype_details.php
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup indexing_searching_mlb
-*/
-
-require_once('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR."class_types.php");
-
-$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($_SESSION['error'])."'}";
-    exit();
-}
-
-$mandatory_indexes = $type->get_mandatory_indexes($_REQUEST['type_id'], 'letterbox_coll');
-$indexes = $type->get_indexes($_REQUEST['type_id'], 'letterbox_coll');
-
-if (!empty($indexes)) {
-    $db = new Database();
-    $customValues = implode(", ", array_keys($indexes));
-    $stmt = $db->query("SELECT " . $customValues . " FROM res_letterbox WHERE res_id = ?", [$_REQUEST['res_id']]);
-    $customSavedValues = $stmt->fetchObject();
-}
-
-$opt_indexes = '';
-$display_value = 'table-row';
-$opt_indexes  = '';
-if (count($indexes) > 0) {
-    $i=0;
-    foreach (array_keys($indexes) as $key) {
-        $mandatory = false;
-        if (in_array($key, $mandatory_indexes)) {
-            $mandatory = true;
-        }
-
-        if ($i%2 != 1 || $i==0) { // pair
-            $opt_indexes .= '<tr class="col">';
-        }
-        $opt_indexes .= '<th align="left" class="picto" >';
-
-        if (isset($indexes[$key]['img'])) {
-            $opt_indexes .= '<i title="'.$indexes[$key]['label'].'" class="fa fa-'.$indexes[$key]['img'].' fa-2x"></i></a>';
-        }
-        $opt_indexes .= '</th>';
-        $opt_indexes .= '<td align="left" width="200px">';
-        $opt_indexes .= $indexes[$key]['label'].' :';
-        $opt_indexes .= '</td>';
-
-        $opt_indexes .= '<td>';
-
-        if ($indexes[$key]['type_field'] == 'input') {
-            if ($indexes[$key]['type'] == 'string' || $indexes[$key]['type'] == 'float' || $indexes[$key]['type'] == 'integer') {
-                $opt_indexes .= '<input type="text" name="'.$key.'" id="'.$key.'" value="';
-                if (!empty($customSavedValues->$key)) {
-                    $opt_indexes .= functions::show_string($customSavedValues->$key, true);
-                } elseif ($indexes[$key]['default_value'] <> false) {
-                    $opt_indexes .= functions::show_string($indexes[$key]['default_value'], true);
-                }
-                $opt_indexes .='" size="40"  />';
-            } elseif ($indexes[$key]['type'] == 'date') {
-                $opt_indexes .= '<input type="text" name="'.$key.'" id="'.$key.'" value="';
-                if (!empty($customSavedValues->$key)) {
-                    $opt_indexes .= functions::format_date_db($customSavedValues->$key, true);
-                } elseif ($indexes[$key]['default_value'] <> false) {
-                    $opt_indexes .= functions::format_date_db($indexes[$key]['default_value'], true);
-                }
-                $opt_indexes .='" size="40"  onclick="showCalender(this);" />';
-            }
-        } else {
-            $opt_indexes .= '<select name="'.$key.'" id="'.$key.'" >';
-            $opt_indexes .= '<option value="">'._CHOOSE.'...</option>';
-            for ($i=0; $i<count($indexes[$key]['values']); $i++) {
-                $opt_indexes .= '<option value="'.$indexes[$key]['values'][$i]['id'].'"';
-                if (!empty($customSavedValues->$key)) {
-                    if ($indexes[$key]['values'][$i]['id'] == $customSavedValues->$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 ($i%2 == 1 && $i!=0) { // impair
-            $opt_indexes .= '</tr>';
-        } else {
-            {
-            if ($i+1 == count($indexes)) {
-                $opt_indexes .= '<td  colspan="2">&nbsp;</td></tr>';
-            }
-            }
-        }
-        $i++;
-    }
-}
-
-echo "{status : 0,  new_opt_indexes : '".addslashes($opt_indexes)."'}";
-exit();
diff --git a/apps/maarch_entreprise/indexing_searching/contact_address_view.php b/apps/maarch_entreprise/indexing_searching/contact_address_view.php
deleted file mode 100755
index d7bd0529acf..00000000000
--- a/apps/maarch_entreprise/indexing_searching/contact_address_view.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php
-/*
-*    Copyright 2014-2017 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/>.
-*/
-
-/**
-*
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools2 = new core_tools();
-$core_tools2->load_lang();
-$core_tools2->test_admin('search_contacts', 'apps');
-$core_tools2->load_html();
-$core_tools2->load_header('', true, false);
-
-require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_request.php';
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_business_app_tools.php");
-
- /****************Management of the location bar  ************/
-$init = false;
-if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-{
-    $init = true;
-}
-$level = "";
-if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-{
-    $level = $_REQUEST['level'];
-}
-$page_path  = $_SESSION['config']['businessappurl'].'index.php?page=contact_address_view&dir=indexing_searching';
-$page_label = _VIEW_ADDRESS;
-$page_id    = "contact_address_view";
-$core_tools2->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-
-$request = new request();
-$db = new Database();
-
-echo '<div class="error" id="main_error">';
-functions::xecho($_SESSION['error']);
-echo '</div>';
-
-echo '<div class="info" id="main_info">';
-functions::xecho($_SESSION['info']);
-echo '</div>';
-
-$_SESSION['error'] = '';
-$_SESSION['info'] = '';
-
-if (!isset($_GET['addressid']) || $_GET['addressid'] == '') {
-	echo '<div class="error" id="main_error">';
-	echo _YOU_MUST_SELECT_ADDRESS;
-	echo '</div>';
-	exit;
-}
-
-$contact = new contacts_v2();
-
-$query = "SELECT * FROM ".$_SESSION['tablename']['contact_addresses']." WHERE id = ?";
-$stmt = $db->query($query, array($_GET['addressid']));
-$line = $stmt->fetchObject();
-
-$_SESSION['m_admin']['address']                       = array();
-$_SESSION['m_admin']['address']['ID']                 = $line->id;
-$_SESSION['m_admin']['address']['CONTACT_ID']         = $line->contact_id;
-$_SESSION['m_admin']['address']['TITLE']              = $request->show_string($line->title);
-$_SESSION['m_admin']['address']['LASTNAME']           = $request->show_string($line->lastname);
-$_SESSION['m_admin']['address']['FIRSTNAME']          = $request->show_string($line->firstname);
-$_SESSION['m_admin']['address']['FUNCTION']           = $request->show_string($line->function);
-$_SESSION['m_admin']['address']['OTHER_DATA']         = $request->show_string($line->other_data);
-$_SESSION['m_admin']['address']['OWNER']              = $line->user_id;
-$_SESSION['m_admin']['address']['DEPARTEMENT']        = $request->show_string($line->departement);
-$_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $line->contact_purpose_id;
-$_SESSION['m_admin']['address']['OCCUPANCY']          = $request->show_string($line->occupancy);
-$_SESSION['m_admin']['address']['ADD_NUM']            = $request->show_string($line->address_num);
-$_SESSION['m_admin']['address']['ADD_STREET']         = $request->show_string($line->address_street);
-$_SESSION['m_admin']['address']['ADD_COMP']           = $request->show_string($line->address_complement);
-$_SESSION['m_admin']['address']['ADD_TOWN']           = $request->show_string($line->address_town);
-$_SESSION['m_admin']['address']['ADD_CP']             = $request->show_string($line->address_postal_code);
-$_SESSION['m_admin']['address']['ADD_COUNTRY']        = $request->show_string($line->address_country);
-$_SESSION['m_admin']['address']['PHONE']              = $request->show_string($line->phone);
-$_SESSION['m_admin']['address']['MAIL']               = $request->show_string($line->email);
-$_SESSION['m_admin']['address']['WEBSITE']            = $request->show_string($line->website);
-$_SESSION['m_admin']['address']['IS_PRIVATE']         = $request->show_string($line->is_private);
-$_SESSION['m_admin']['address']['SALUTATION_HEADER']  = $request->show_string($line->salutation_header);
-$_SESSION['m_admin']['address']['SALUTATION_FOOTER']  = $request->show_string($line->salutation_footer);
-
-?>
-	<h1><i class="fa fa-home fa-2x"></i>&nbsp;<?php echo _VIEW_ADDRESS;?></h1>
-    <br>
-    <div class="clearfix block" align="center">
-<?php
-	$contact->get_contact_form();
-	$contact->get_address_form();
-?>
-	<input type="button" class="button"  name="cancel" value="<?php echo _BACK;?>" onclick="history.go(-1);" />
-	</div>
diff --git a/apps/maarch_entreprise/indexing_searching/contact_check.php b/apps/maarch_entreprise/indexing_searching/contact_check.php
deleted file mode 100755
index dc882a9625f..00000000000
--- a/apps/maarch_entreprise/indexing_searching/contact_check.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-/*
-*
-*   Copyright 2014 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 to return ajax result
-*
-* @author   Alex ORLUC <dev@maarch.org>
-* @date     $date$
-* @version  $Revision$
-*/
-
-//NO CHECK IF OUTGOING
-if(empty($_POST['contact_id']) || $_POST['category'] == 'outgoing'){
-	echo "success";
-} else {
-	require_once 'apps/'. $_SESSION['config']['app_id'] .'/class/class_users.php';
-
-	$db       = new Database();
-	$arrayPDO = array();
-	$user     = new class_users();
-
-	$whereSec = $user->get_global_security();
-
-	//IF EXTERNAL CONTACT
-	if (!empty(trim($_POST['address_id']))) {
-		$where = "status <> 'DEL' AND contact_id = ".$_POST['contact_id']." AND address_id = ".$_POST['address_id']
-			." AND (creation_date >= " . $db->current_datetime() . " - INTERVAL '".$_SESSION['check_days_before']."' DAY)";
-		$wherePDO = "status <> 'DEL' AND contact_id = ? AND address_id = ? AND (creation_date >= " . $db->current_datetime() . " - INTERVAL '".$_SESSION['check_days_before']."' DAY)";
-		$arrayPDO = array($_POST['contact_id'], $_POST['address_id']);
-	//IF INTERNAL CONTACT
-	} else {
-		$where = "status <> 'DEL' AND (exp_user_id = '".$_POST['contact_id']."' OR dest_user_id = '".$_POST['contact_id']."') AND (creation_date >= " . $db->current_datetime() . " - INTERVAL '".$_SESSION['check_days_before']."' DAY)";
-		$wherePDO = "status <> 'DEL' AND (exp_user_id = ? OR dest_user_id = ?) AND (creation_date >= " . $db->current_datetime() . " - INTERVAL '".$_SESSION['check_days_before']."' DAY)";
-		$arrayPDO = array($_POST['contact_id'], $_POST['contact_id']);
-	}
-
-	//MERGE GLOBAL SECURITY WITH QUERY DOC
-	$wherePDO = $wherePDO . ' AND ('.$whereSec.')';
-
-	//EXCLUDE OWN RES_ID
-	if($_POST['res_id'] != "none"){
-		$wherePDO .= " AND res_id NOT IN (?)";
-		$allResId = explode(",", $_POST['res_id']);
-		$arrayPDO = array_merge($arrayPDO, array($allResId));
-		$_SESSION['excludeId'] = $_POST['res_id'];
-	}
-
-	$order = "ORDER by creation_date DESC";
-	$query = $db->limit_select(0, 1, 'res_id', 'res_view_letterbox', $wherePDO, '', '', $order);
-
-	$stmt = $db->query($query, $arrayPDO);
-
-	if ($stmt->rowCount() > 0){
-		$_SESSION['where_from_contact_check'] = " AND (".$where.")";
-		echo "fail";
-	} else {
-		echo "success";
-	}
-}
diff --git a/apps/maarch_entreprise/indexing_searching/contacts_v2_list_by_name_filters.php b/apps/maarch_entreprise/indexing_searching/contacts_v2_list_by_name_filters.php
deleted file mode 100755
index 387c795bc1d..00000000000
--- a/apps/maarch_entreprise/indexing_searching/contacts_v2_list_by_name_filters.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-/*
-*    Copyright 2014 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 List of users for autocompletion filter
-*
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
-require_once("apps".DIRECTORY_SEPARATOR."maarch_entreprise".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-$contact = new contacts_v2();
-$db = new Database();
-$listArray = array();
-$query = "SELECT contact_type, society, lastname, firstname, contact_id, is_corporate_person, society_short FROM "
-	.$_SESSION['tablename']['contacts_v2']." WHERE ((lower(lastname) like lower(:what) "
-	."or lower(firstname) like lower(:what) "
-    ."or lower(society_short) like lower(:what) "
-	."or lower(society) like lower(:what))) ";
-
-$arrayPDO = array(":what" => '%'.$_REQUEST['what'].'%');
-
-if(isset($_GET['id']) &&  $_GET['id'] <> ''){
-    $query .= ' and contact_id <> :contactid';
-    $arrayPDO[":contactid"] = $_GET['id'];
-}
-
-if(isset($_GET['my_contact']) &&  $_GET['my_contact'] == 'Y'){
-    $query .= " and user_id = :userid";
-    $arrayPDO[":userid"] = $_SESSION['user']['UserId'];
-}
-
-$query .= " order by lastname";
-$stmt = $db->query($query, $arrayPDO);
-
-if(isset($_GET['id']) &&  $_GET['id'] <> ''){
-    while($line = $stmt->fetchObject())
-    {
-        $listArray[$line->contact_id] = $contact->get_label_contact($line->contact_type, $_SESSION['tablename']['contact_types']) . ' : ' . $line->society . ', '. $line->lastname . ' '. $line->firstname;
-    }
-} else {
-    while ($line = $stmt->fetchObject()) {
-        if($line->is_corporate_person == 'N'){
-        	$listArray[$line->contact_id] = functions::show_string($line->lastname)." ".functions::show_string($line->firstname);
-            if($line->society <> ''){
-                $listArray[$line->contact_id] .= ' ('.$line->society.')';
-            }
-        } else {
-            $listArray[$line->contact_id] .= $line->society;
-            if($line->society_short <> ''){
-                $listArray[$line->contact_id] .= ' ('.$line->society_short.')';
-            }
-        }
-    }
-}
-
-$query = "SELECT lastname, firstname, user_id FROM users WHERE (lower(lastname) like lower(:what) "
-    ."or lower(firstname) like lower(:what) "
-    ."or user_id like :what) and (status = 'OK' or status = 'ABS') and enabled = 'Y' ORDER BY lastname";
-
-$arrayPDO = array(":what" => '%'.$_REQUEST['what'].'%');
-
-$stmt = $db->query($query, $arrayPDO);
-
-while ($line = $stmt->fetchObject()) {
-    $listArray[$line->user_id] .= $line->firstname . " " . $line->lastname;
-}
-
-echo "<ul>\n";
-$authViewList = 0;
-$flagAuthView = false;
-foreach ($listArray as $key => $what) {
-    if ($authViewList >= 10) {
-        $flagAuthView = true;
-    }
-    echo "<li id=".$key.">".$what."</li>\n";
-    if($flagAuthView) {
-        echo "<li id=".$key.">...</li>\n";
-        break;
-    }
-    $authViewList++;
-}
-echo "</ul>";
diff --git a/apps/maarch_entreprise/indexing_searching/contacts_view.php b/apps/maarch_entreprise/indexing_searching/contacts_view.php
deleted file mode 100755
index ae43dd9160a..00000000000
--- a/apps/maarch_entreprise/indexing_searching/contacts_view.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-/**
-* File : contacts_view.php
-*
-* Form to modify a contact
-*
-* @license GPL
-* @author   <dev@maarch.org>
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-$core_tools->test_service('search_contacts', 'apps');
-
-require("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_lists.php";
-require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_request.php';
-
-$func  = new functions();
-$list2 = new lists(); 
-$db    = new Database();
-
-if(isset($_GET['id']))
-{
-    $id = addslashes($func->wash($_GET['id'], "alphanum", _THE_CONTACT));
-    $_SESSION['contact']['current_contact_id'] = $id;
-}else if ($_SESSION['contact']['current_contact_id'] <> ''){
-	$id = $_SESSION['contact']['current_contact_id'];
-}
-else
-{
-    $id = "";
-}
-
-if (!isset($_REQUEST['letters'])) {
-	/****************Management of the location bar  ************/
-	$init = false;
-	if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-	{
-	    $init = true;
-	}
-	$level = "";
-	if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-	{
-	    $level = $_REQUEST['level'];
-	}
-	$page_path = $_SESSION['config']['businessappurl'].'index.php?page=contacts_view&dir=indexing_searching';
-	$page_label = _VIEW_CONTACT;
-	$page_id = "contacts_view";
-	$core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-	/***********************************************************/
-}
-
-?><div id="divList" name="divList"><?php
-
-$contact = new contacts_v2();
-$request = new request();
-
-$query = "SELECT * FROM ".$_SESSION['tablename']['contacts_v2']." WHERE contact_id = ?";
-$stmt = $db->query($query, array($_SESSION['contact']['current_contact_id']));
-$line = $stmt->fetchObject();
-
-$_SESSION['m_admin']['contact']                        = array();
-$_SESSION['m_admin']['contact']['ID']                  = $line->contact_id;
-$_SESSION['m_admin']['contact']['TITLE']               = $request->show_string($line->title);
-$_SESSION['m_admin']['contact']['LASTNAME']            = $request->show_string($line->lastname);
-$_SESSION['m_admin']['contact']['FIRSTNAME']           = $request->show_string($line->firstname);
-$_SESSION['m_admin']['contact']['SOCIETY']             = $request->show_string($line->society);
-$_SESSION['m_admin']['contact']['SOCIETY_SHORT']       = $request->show_string($line->society_short);
-$_SESSION['m_admin']['contact']['FUNCTION']            = $request->show_string($line->function);
-$_SESSION['m_admin']['contact']['OTHER_DATA']          = $request->show_string($line->other_data);
-$_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = $request->show_string($line->is_corporate_person);
-$_SESSION['m_admin']['contact']['CONTACT_TYPE']        = $line->contact_type;
-$_SESSION['m_admin']['contact']['OWNER']               = $line->user_id;
-?>
-	<h1><i class="fa fa-users fa-2x"></i>&nbsp;<?php echo _VIEW_CONTACT;?></h1>
-	<br>
-	<div id="test" class="clearfix block" align="center">
-<?php
-		$contact->get_contact_form();
-?>
-		<input type="button" class="button"  name="cancel" value="<?php echo _BACK_TO_RESULTS_LIST;?>" onclick="history.go(-1);" />
-		<br/><br/><br/><br/>
-	</div>
-<?php
-
-$mode = 'view';
-include_once 'apps/' . $_SESSION['config']['app_id'] . '/admin/contacts/contact_addresses/contact_addresses.php';
-?> 
-</div>
diff --git a/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php b/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php
index 4ea767a751f..76d1d826bfd 100755
--- a/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php
+++ b/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php
@@ -32,8 +32,6 @@
  */
 require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php';
 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_contacts_v2.php';
 require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_manage_status.php';
 require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
             .'class'.DIRECTORY_SEPARATOR.'class_lists.php';
@@ -42,7 +40,6 @@ $status_obj = new manage_status();
 $sec = new security();
 $core_tools = new core_tools();
 $request = new request();
-$contact = new contacts_v2();
 $list = new lists();
 
 //Labels
diff --git a/apps/maarch_entreprise/indexing_searching/list_results_contacts.php b/apps/maarch_entreprise/indexing_searching/list_results_contacts.php
deleted file mode 100755
index 84fafd93188..00000000000
--- a/apps/maarch_entreprise/indexing_searching/list_results_contacts.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-/*
-*
-*    Copyright 2014 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   Displays contacts list in search mode
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup basket
-*/
-
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
-            ."class".DIRECTORY_SEPARATOR."class_lists.php";
-
-$core_tools = new core_tools();
-$list       = new lists();
-
-$core_tools->test_user();
-$core_tools->test_service('search_contacts', 'apps');
-
-
-/****************Management of the location bar  ************/
-$init = false;
-if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-{
-    $init = true;
-}
-$level = "";
-if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-{
-    $level = $_REQUEST['level'];
-}
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=list_results_contacts&dir=indexing_searching';
-$page_label = _RESULTS;
-$page_id = "search_contacts_result";
-$core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-
-$saveTool       = true;
-$useTemplate    = false;
-$exportTool     = true;
-
-//List
-$target = $_SESSION['config']['businessappurl'].'index.php?page=my_contacts&dir=my_contacts&mode=search';
-$listContent = $list->loadList($target, true, 'divList', 'false');
-
-?>
-
-    <table width="100%" style="margin-bottom: -10px">
-        <tr>
-            <td align="right">
-                <input class="button" type="button" align="right" value="<?php echo _SEARCH_ADDRESSES;?>" onclick="window.location.href='<?php echo $_SESSION['config']['businessappurl'] . 'index.php?page=list_results_addresses&dir=indexing_searching&fromSearchContacts'?>'"/>      
-            </td>
-        </tr>
-    </table>
-
-<?php
-
-echo $listContent;
\ No newline at end of file
diff --git a/apps/maarch_entreprise/indexing_searching/search_contacts.php b/apps/maarch_entreprise/indexing_searching/search_contacts.php
deleted file mode 100755
index 7763b78cde4..00000000000
--- a/apps/maarch_entreprise/indexing_searching/search_contacts.php
+++ /dev/null
@@ -1,215 +0,0 @@
-<?php
-/*
-*    Copyright 2014 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/>.
-*
-* @file search_contacts.php
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-*/
-
-require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php';
-require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_indexing_searching_app.php';
-$core_tools = new core_tools();
-$core_tools->test_user();
-$core_tools->load_lang();
-
-$_SESSION['search']['plain_text'] = '';
-
-$func = new functions();
-$conn = new Database();
-
-$search_obj = new indexing_searching_app();
-
-$_SESSION['indexation'] = false;
-
-if (isset($_REQUEST['exclude'])) {
-    $_SESSION['excludeId'] = $_REQUEST['exclude'];
-}
-
-$mode = 'normal';
-
-$core_tools->test_service('search_contacts', 'apps');
-/****************Management of the location bar  ************/
-$init = false;
-if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == 'true') {
-    $init = true;
-}
-$level = '';
-if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) {
-    $level = $_REQUEST['level'];
-}
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=search_contacts&dir=indexing_searching';
-$page_label = _SEARCH_CONTACTS;
-$page_id = 'search_contacts';
-$core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-
-//Check if web brower is ie_6 or not
-
-$browser_ie = 'false';
-$class_for_form = 'forms';
-$hr = '';
-$size = '';
-
-// building of the parameters array used to pre-load the category list and the search elements
-$param = array();
-
-// Sorts the param array
-function cmp($a, $b)
-{
-    return strcmp(strtolower($a['label']), strtolower($b['label']));
-}
-uasort($param, 'cmp');
-
-$tab = $search_obj->send_criteria_data($param);
-
-// criteria list options
-$src_tab = $tab[0];
-
-//$core_tools->load_js();
-?>
-<script type="text/javascript" src="<?php echo $_SESSION['config']['businessappurl']; ?>static.php?filename=search_adv.js" ></script>
-<script type="text/javascript">
-<!--
-    var valeurs = { <?php functions::xecho($tab[1]); ?>};
-    var loaded_query = <?php if (isset($_SESSION['current_search_query']) && !empty($_SESSION['current_search_query'])) {
-    echo $_SESSION['current_search_query'];
-} else {
-    echo '{}';
-}?>;
-
--->
-</script>
-
-<h1 id="searchContactsTitle"><i class="fa fa-search fa-2x"></i> <?php echo _SEARCH_CONTACTS; ?></h1>
-<div id="inner_content">
-
-<form name="frmsearch2" method="get" action="<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=search_contacts_result'; ?>"  id="frmsearch2" class="<?php functions::xecho($class_for_form); ?>">
-    <input type="hidden" name="dir" value="indexing_searching" />
-    <input type="hidden" name="page" value="search_contacts_result" />
-    <input type="hidden" name="mode" value="<?php functions::xecho($mode); ?>" />
-    <?php
-    $contact_types = array();
-
-    $stmt = $conn->query('SELECT id, label FROM '.$_SESSION['tablename']['contact_types']);
-    while ($res = $stmt->fetchObject()) {
-        $contact_types[$res->id] = functions::show_string($res->label);
-    }
-    ?>
-    <table width="100%">
-        <tr>
-            <td align="right">
-                <input class="button" type="button" align="right" value="<?php echo _SEARCH_ADDRESSES; ?>" onclick="window.location.href='<?php echo $_SESSION['config']['businessappurl'].'index.php?page=list_results_addresses&dir=indexing_searching&fromSearchContacts'; ?>'"/>      
-            </td>
-        </tr>
-    </table>
-        <tr >
-            <td >
-            <div class="block">
-                <h2><?php echo _SEARCH_CONTACTS; ?></h2>
-                <table border = "0" width="100%">
-                    <tr>
-                        <td width="70%">
-                            <label for="contact_type" class="bold" ><?php echo _CONTACT_TYPE; ?> :</label>
-                            <select name="contact_type" id="contact_type" >
-                                <option value=""><?php echo _CHOOSE_CONTACT_TYPES; ?></option>
-                                <?php
-                                foreach (array_keys($contact_types) as $key) {
-                                    ?><option value="<?php functions::xecho($key); ?>">
-                                        <?php functions::xecho($contact_types[$key]); ?>
-                                    </option><?php
-                                }?>
-                            </select>
-                            <input type="hidden" name="meta[]" value="contact_type#contact_type#input_text" />
-                        </td>
-                    </tr>
-                    <tr>
-                        <td width="70%"><label for="society" class="bold" ><?php echo _STRUCTURE_ORGANISM; ?> :</label>
-                            <input type="text" name="society" id="society" <?php functions::xecho($size); ?>  />
-                            <input type="hidden" name="meta[]" value="society#society#input_text" />
-                        </td>
-                    </tr>
-                    <tr>
-                        <td width="70%"><label for="society_short" class="bold" ><?php echo _SOCIETY_SHORT; ?> :</label>
-                            <input type="text" name="society_short" id="society_short" <?php functions::xecho($size); ?>  />
-                            <input type="hidden" name="meta[]" value="society_short#society_short#input_text" />
-                        </td>
-                    </tr>
-                    <tr>
-                        <td width="70%"><label for="lastname" class="bold"><?php echo _LASTNAME; ?> :</label>
-                            <input type="text" name="lastname" id="lastname" <?php functions::xecho($size); ?>  />
-                            <input type="hidden" name="meta[]" value="lastname#lastname#input_text" />
-                        </td>
-                    </tr>
-                    <tr>
-                        <td width="70%"><label for="firstname" class="bold" ><?php echo _FIRSTNAME; ?> :</label>
-                            <input type="text" name="firstname" id="firstname" <?php functions::xecho($size); ?>  />
-                            <input type="hidden" name="meta[]" value="firstname#firstname#input_text" />
-                        </td>
-                    </tr>
-                    <tr>
-                        <td width="70%"><label for="created_by" class="bold"><?php echo _CREATE_BY; ?> :</label>
-                            <input type="text" name="created_by" id="created_by" onkeyup="erase_contact_external_id('created_by', 'created_by_id');"/>
-                            <input type="hidden" name="meta[]" value="created_by#created_by#input_text" />
-                            <div id="contactListByName" class="autocomplete"></div>
-                            <script type="text/javascript">
-                                initList_hidden_input('created_by', 'contactListByName', '<?php 
-                                    echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&dir=indexing_searching&page=users_list_by_name_search', 'what', '2', 'created_by_id');
-                            </script>
-                            <input id="created_by_id" name="created_by_id" type="hidden" />
-                        </td>
-                        <td><em><?php echo ''; ?></em></td>
-                    </tr>
-                </table>
-                </div>
-                <div class="block_end" style="margin-top:-20px">&nbsp;</div>
-            </td>
-        </tr>
-
-    <select name="select_criteria" id="select_criteria" style="display: none;"></select>
-
-    <table align="center" border="0" width="100%">
-        <tr>
-            <td>
-                <a href="#" onclick="clear_search_form('frmsearch2','select_criteria');clear_q_list();">
-                    <i class="fa fa-sync fa-4x" title="<?php echo _CLEAR_FORM; ?>"></i>
-                </a>
-            </td>
-            <td align="right">
-                <span style="display:none;">
-                    <input name="imageField" type="submit" value="" onclick="valid_search_form('frmsearch2');this.form.submit();" />
-                </span>
-                <a href="#" onclick="valid_search_form('frmsearch2');$('frmsearch2').submit();">
-                    <i class="fa fa-search fa-4x" title="<?php echo _SEARCH; ?>"></i>
-                </a>
-            </td>
-        </tr>
-    </table>
-
-</form>
-<br/>
-<div align="right">
-</div>
- </div>
-<script type="text/javascript">
-load_query(valeurs, loaded_query, 'frmsearch2', '<?php functions::xecho($browser_ie); ?>, <?php echo _ERROR_IE_SEARCH;?>');
-<?php if (isset($_REQUEST['init_search'])) {
-                                        ?>clear_search_form('frmsearch2','select_criteria');clear_q_list(); <?php
-                                    }?>
-</script>
diff --git a/apps/maarch_entreprise/indexing_searching/search_contacts_result.php b/apps/maarch_entreprise/indexing_searching/search_contacts_result.php
deleted file mode 100755
index c6cfec100fc..00000000000
--- a/apps/maarch_entreprise/indexing_searching/search_contacts_result.php
+++ /dev/null
@@ -1,168 +0,0 @@
-<?php
-
-/*
-*   Copyright 2014 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  Advanced search form management
-*
-* @file search_contacts_result.php
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-*/
-
-require_once('core/class/class_request.php');
-require_once('core/class/class_security.php');
-require_once('apps/' . $_SESSION['config']['app_id']
-    . '/class/class_indexing_searching_app.php'
-);
-require_once('apps/' . $_SESSION['config']['app_id'] . '/class/class_types.php');
-$core_tools = new core_tools();
-$core_tools->test_user();
-$core_tools->load_lang();
-$is = new indexing_searching_app();
-$func = new functions();
-$req = new request();
-$type = new types();
-$fields = "";
-$orderby = "";
-
-$coll_id = 'letterbox_coll';
-$indexes = $type->get_all_indexes($coll_id);
-//$func->show_array($indexes);
-$_SESSION['error_search'] = '';
-$_SESSION['searching']['comp_query'] = '';
-// define the row of the start
-if (isset($_REQUEST['start'])) {
-    $start = $_REQUEST['start'];
-} else {
-    $start = 0;
-}
-
-$mode = 'normal';
-$core_tools->test_service('search_contacts', 'apps');
-
-$where_request = "";
-$arrayPDO = array();
-$case_view = false;
- $_ENV['date_pattern'] = "/^[0-3][0-9]-[0-1][0-9]-[1-2][0-9][0-9][0-9]$/";
-$json_txt = '{';
-
-/**
- * Array $_REQUEST['meta'] exemple
-(
-    [0] => copies#copies_false,copies_true#radio
-    [1] => objet#objet#input_text
-    [2] => numged#numged#input_text
-    [3] => multifield#multifield#input_text
-    [4] => category#category#select_simple
-    [5] => doc_date#doc_date_from,doc_date_to#date_range
-)
-**/
-//$func->show_array($_REQUEST['meta']);exit;
-if (count($_REQUEST['meta']) > 0) {
-    //Verif for parms sended by url
-    if ($_GET['meta']) {
-        for ($m=0; $m<count($_REQUEST['meta']);$m++) {
-            if (strstr($_REQUEST['meta'][$m], '||') == true) {
-                $_REQUEST['meta'][$m] = str_replace('||', '#', $_REQUEST['meta'][$m]);
-            }
-        }
-    }
-    $opt_indexes = array();
-    $_SESSION['meta_search'] = $_REQUEST['meta'];
-    for ($i=0;$i<count($_REQUEST['meta']);$i++) {
-        $tab = explode('#', $_REQUEST['meta'][$i]);
-
-        $id_val = $tab[0];
-        $json_txt .= "'".$tab[0]."' : { 'type' : '".$tab[2]."', 'fields' : {";
-        $tab_id_fields = explode(',', $tab[1]);
-        //$func->show_array($tab_id_fields);
-        for ($j=0; $j<count($tab_id_fields);$j++) {
-
-            // CONTACT TYPE
-            if ($tab_id_fields[$j] == 'contact_type' && !empty($_REQUEST['contact_type'])) {
-                $json_txt .= " 'contact_type' : ['".addslashes(trim($_REQUEST['contact_type']))."'],";
-                $where_request .= " contact_type = :contactType and ";
-                $arrayPDO = array_merge($arrayPDO, array(":contactType" => $_REQUEST['contact_type']));
-            }
-            // SOCIETY
-            elseif ($tab_id_fields[$j] == 'society' && (!empty($_REQUEST['society']) || $_REQUEST['society'] <> '')) {
-                $json_txt .= " 'society' : ['".addslashes(trim($_REQUEST['society']))."'],";
-                $where_request .= " lower(society) like lower(:society) and ";
-                $arrayPDO = array_merge($arrayPDO, array(":society" => '%'.$_REQUEST['society'].'%'));
-            }
-            // SOCIETY SHORT
-            elseif ($tab_id_fields[$j] == 'society_short' && (!empty($_REQUEST['society_short']) || $_REQUEST['society_short'] <> '')) {
-                $json_txt .= " 'society_short' : ['".addslashes(trim($_REQUEST['society_short']))."'],";
-                $where_request .= " lower(society_short) like lower(:societyShort) and ";
-                $arrayPDO = array_merge($arrayPDO, array(":societyShort" => '%'.$_REQUEST['society_short'].'%'));
-            }
-            // LASTNAME
-            elseif ($tab_id_fields[$j] == 'lastname' && (!empty($_REQUEST['lastname']) ||$_REQUEST['lastname'] <> '')) {
-                $json_txt .= " 'lastname' : ['".addslashes(trim($_REQUEST['lastname']))."'],";
-                $where_request .= " lower(contact_lastname) like lower(:contactLastname) and ";
-                $arrayPDO = array_merge($arrayPDO, array(":contactLastname" => '%'.$_REQUEST['lastname'].'%'));
-            }
-            // FIRSTNAME
-            elseif ($tab_id_fields[$j] == 'firstname' && (!empty($_REQUEST['firstname']) ||$_REQUEST['firstname'] <> '')) {
-                $json_txt .= " 'firstname' : ['".addslashes(trim($_REQUEST['firstname']))."'],";
-                $where_request .= " lower(contact_firstname) like lower(:contactFirstname) and ";
-                $arrayPDO = array_merge($arrayPDO, array(":contactFirstname" => '%'.$_REQUEST['firstname'].'%'));
-            }
-            // CREATED BY
-            elseif ($tab_id_fields[$j] == 'created_by' && !empty($_REQUEST['created_by_id'])) {
-                $json_txt .= " 'created_by' : ['".addslashes(trim($_REQUEST['created_by']))."'], 'created_by_id' : ['".addslashes(trim($_REQUEST['created_by_id']))."'],";
-                $where_request .= " contact_user_id = :createdById and ";
-                $arrayPDO = array_merge($arrayPDO, array(":createdById" => $_REQUEST['created_by_id']));
-            }
-            // CONTACTS PURPOSE
-            elseif ($tab_id_fields[$j] == 'contact_purpose' && !empty($_REQUEST['contact_purposes_id'])) {
-                $json_txt .= " 'contact_purpose' : ['".addslashes(trim($_REQUEST['contact_purpose']))."'], 'contact_purposes_id' : ['".addslashes(trim($_REQUEST['contact_purposes_id']))."'],";
-                $where_request .= " contact_purposes_id = :contactPurposeId and ";
-                $arrayPDO = array_merge($arrayPDO, array(":contactPurposeId" => $_REQUEST['contact_purposes_id']));
-            }
-        }
-        $json_txt = preg_replace('/,$/', '', $json_txt);
-        $json_txt .= "}},";
-    }
-    $json_txt = preg_replace('/,$/', '', $json_txt);
-}
-$json_txt = preg_replace("/,$/", "", $json_txt);
-$json_txt .= '}';
-
-$_SESSION['current_search_query'] = $json_txt;
-if (!empty($_SESSION['error'])) {
-    $_SESSION['error_search'] = '<br /><div class="error">'._MUST_CORRECT_ERRORS.' : <br /><br /><strong>'.$_SESSION['error_search'].'<br /><a href="'.$_SESSION['config']['businessappurl'].'index.php?page=search_adv&dir=indexing_searching">'._CLICK_HERE_TO_CORRECT.'</a></strong></div>';
-    ?>
-    <script  type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'].'index.php?page=search_adv_error&dir=indexing_searching';?>';</script>
-    <?php
-    exit();
-} else {
-    $where_request = trim($where_request);
-    $_SESSION['searching']['where_request'] = $where_request;
-    $_SESSION['searching']['where_request_parameters'] = $arrayPDO;
-}
-
-if (empty($_SESSION['error_search'])) {
-
-    ?>
-    <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'].'index.php?page=list_results_contacts&dir=indexing_searching';?>';</script>
-    <?php
-    exit();
-}
diff --git a/apps/maarch_entreprise/indexing_searching/update_process_date.php b/apps/maarch_entreprise/indexing_searching/update_process_date.php
deleted file mode 100755
index 564e866653a..00000000000
--- a/apps/maarch_entreprise/indexing_searching/update_process_date.php
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-/*
-*   Copyright 2008-2014 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  compute the process limit with the doctype and the admission_date
-*
-* @file update_process_date.php
-* @author Laurent Giovannoni <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'])) {
-    echo "{status : 1, error_txt : '".addslashes(_DOCTYPE . ' ' . _IS_EMPTY)."'}";
-    exit();
-} else {
-    $typeId = $_REQUEST['type_id'];
-}
-
-if (!isset($_REQUEST['admission_date']) || empty($_REQUEST['admission_date'])) {
-    echo "{status : 1, error_txt : '".addslashes(_ADMISSION_DATE . ' ' . _IS_EMPTY)."'}";
-    exit();
-} else {
-    $admissionDate = $_REQUEST['admission_date'];
-}
-
-if (!isset($_REQUEST['priority_id']) || $_REQUEST['priority_id'] == '') {
-    echo "{status : 1, error_txt : '".addslashes(_PRIORITY . ' ' . _IS_EMPTY)."'}";
-    exit();
-} else {
-    $priorityId = $_REQUEST['priority_id'];
-    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];
-    }
-    $wdays = 'workingDay';
-    if (isset($_SESSION['mail_priorities_wdays'][$fakeId]) && $_SESSION['mail_priorities_wdays'][$fakeId] == 'false') {
-        $wdays = 'calendar';
-    }
-}
-
-//Process limit process date compute
-//Bug fix if delay process is disabled in 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, $wdays);
-    } 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($date) . "'}";
-    exit();
-} else {
-    echo "{status : 1}";
-    exit();
-}
diff --git a/apps/maarch_entreprise/js/functions.js b/apps/maarch_entreprise/js/functions.js
index 9e1b4155011..33db9d13588 100755
--- a/apps/maarch_entreprise/js/functions.js
+++ b/apps/maarch_entreprise/js/functions.js
@@ -2,10 +2,6 @@ var isAlreadyClick = false;
 
 page_result_final = '';
 
-function capitalizeFirstLetter(theString) {
-    return theString && theString[0].toUpperCase() + theString.slice(1);
-}
-
 function whatIsTheDivStatus(theDiv, divStatus) {
     if ($j('#' + theDiv).css('display') == 'none') {
         $j('#' + divStatus).html('<i class="fa fa-minus-square"></i>');
@@ -14,25 +10,6 @@ function whatIsTheDivStatus(theDiv, divStatus) {
     }
 }
 
-function deletePriority(rowToDelete) {
-    var rep = confirm("Confirmation de suppression ?");
-    var index = rowToDelete.getAttribute("data-index");
-
-    if (index >= 0 && rep) {
-        var path_manage_script = "index.php?page=priorityManager&admin=priorities";
-        new Ajax.Request(path_manage_script, {
-            method: "POST",
-            parameters: {
-                mode: "delete",
-                indexToDelete: index
-            },
-            onSuccess: function () {
-                window.top.location.reload();
-            }
-        });
-    }
-}
-
 function repost(php_file, update_divs, fields, action, timeout) {
     var event_count = 0;
 
@@ -108,56 +85,6 @@ var initList_hidden_input = function (idField, idList, theUrlToListScript, param
         });
 };
 
-var initList_hidden_input2 = function (idField, idList, theUrlToListScript, paramNameSrv, minCharsSrv, new_value, actual_value) {
-    new Ajax.Autocompleter(
-        idField,
-        idList,
-        theUrlToListScript, {
-            paramName: paramNameSrv,
-            minChars: minCharsSrv,
-            afterUpdateElement: function (text, li) {
-                var str = li.id;
-                var res = str.split(",");
-                $j("#" + new_value).val(res[1]);
-                $j("#" + actual_value).val(res[0]);
-                $j('#country').val('FRANCE');
-            }
-        });
-};
-
-var initList_hidden_input3 = function (idField, idList, theUrlToListScript, paramNameSrv, minCharsSrv, new_value, actual_value) {
-    new Ajax.Autocompleter(
-        idField,
-        idList,
-        theUrlToListScript, {
-            paramName: paramNameSrv,
-            minChars: minCharsSrv,
-            afterUpdateElement: function (text, li) {
-                var str = li.id;
-                var res = str.split(",");
-                $j("#" + new_value).val(res[0]);
-                $j("#" + actual_value).val(res[1]);
-                $j('#country').val('FRANCE');
-            }
-        });
-};
-
-var initList_hidden_input_before = function (idField, idList, theUrlToListScript, paramNameSrv, minCharsSrv, new_value, previous_name, previous_field) {
-    new Ajax.Autocompleter(
-        idField,
-        idList,
-        theUrlToListScript, {
-            paramName: paramNameSrv,
-            minChars: minCharsSrv,
-            callback: function (element, entry) {
-                return entry + "&" + previous_name + "=" + $j("#" + previous_field).val();
-            },
-            afterUpdateElement: function (text, li) {
-                $j("#" + new_value).val(li.id);
-            }
-        });
-};
-
 
 /*********** Init vars for the calendar ****************/
 var allMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@@ -463,57 +390,6 @@ function initMenu() {
 
 if (document.createElement) window.onload = initMenu;
 
-/************** fonction pour afficher/cacher le menu     ***********/
-
-function ShowHideMenu(menu, onouoff) {
-    if (typeof ($) == 'function') {
-        monmenu = $j("#" + menu)[0];
-        mondivmenu = $j("#menu")[0];
-        monadmin = $j("#admin")[0];
-        monhelp = $j("#aide")[0];
-    } else if (document.all) {
-        monmenu = document.all[menu];
-        mondivmenu = document.all["menu"];
-        monadmin = document.all["admin"];
-        monhelp = document.all["aide"];
-    } else return;
-
-    if (menu == "ssnav") {
-        if (onouoff == "fermee") {
-            monmenu.style.display = "block";
-            monadmin.className = "on";
-        } else if (onouoff == "ouverte") {
-            monmenu.style.display = "none";
-            monadmin.className = "off";
-        }
-    } else if (menu == "ssnavaide") {
-        if (onouoff == "fermee") {
-            monmenu.style.display = "block";
-            monhelp.className = "on";
-        } else if (onouoff == "ouverte") {
-            monmenu.style.display = "none";
-            monhelp.className = "off";
-        }
-    } else {
-        if (onouoff == "on") {
-            monmenu.style.display = "block";
-            mondivmenu.className = "on";
-        } else if (onouoff == "off") {
-            monmenu.style.display = "none";
-            mondivmenu.className = "off";
-        }
-    }
-}
-
-
-/****************************************/
-
-
-function ouvreFenetre(page, largeur, hauteur) {
-    window.open(page, "", "scrollbars=yes,menubar=no,toolbar=no,resizable=yes,width=" +
-        largeur + ",height=" + hauteur);
-}
-
 /************** Fonction utilisées pour la gestion des listes multiples  ***********/
 
 /**
@@ -716,19 +592,6 @@ var BrowserDetect = {
 
 BrowserDetect.init();
 
-function resize_frame_contact(mode) {
-    if (parent.$('contact_iframe_attach') && mode == 'contact') {
-        var contentHeight = 370;
-        parent.$('contact_iframe_attach').style.height = contentHeight + "px";
-    } else if (parent.$('info_contact_iframe_attach') && mode != 'contact') {
-        var contentHeight = Math.round($j('#inner_content_contact').height()) + 100;
-        parent.$('info_contact_iframe_attach').style.height = contentHeight + "px";
-    } else {
-        var contentHeight = Math.round($j('#inner_content_contact').height()) + 100;
-        parent.$('iframe_tab').style.height = contentHeight + "px";
-    }
-}
-
 /**
  * Resize frames in a modal
  *
@@ -1531,16 +1394,6 @@ function action_change_status(path_manage_script, mode_req, res_id_values, table
 
 /*************** Xml management functions : used with tiny_mce to load mapping_file *****************/
 
-/**
- * Remove a node in a xml file
- *
- * @param node Node Object Node to remove
- */
-function remove_tag(node) {
-    if (!node.data.replace(/\s/g, ''))
-        node.parentNode.removeChild(node);
-}
-
 /**
  * Resize the current window
  *
@@ -1651,122 +1504,6 @@ function unlock(path_script, id, coll) // A FAIRE
     }
 }
 
-function setContactType(mode, creation) {
-    new Ajax.Request("index.php?dir=my_contacts&page=setContactType", {
-        method: 'post',
-        parameters: {
-            contact_target: mode,
-            can_add_contact: creation
-        },
-        onSuccess: function (answer) {
-            $('contact_type').innerHTML = answer.responseText;
-        }
-    });
-}
-
-function checkContactType(mode, creation) {
-    var bool = false;
-    $j.ajax({
-        url: 'index.php?dir=my_contacts&page=setContactType&display=false',
-        type: 'POST',
-        async: false,
-        data: {
-            contact_target: mode,
-            can_add_contact: creation
-        },
-        success: function (answer) {
-            if (answer.substring(0, 5) == 'false') {
-                bool = false;
-            } else {
-                bool = true;
-            }
-        }
-    });
-    return bool;
-}
-
-/**
- * Show or hide the data related to a person in the contacts admin
- *
- * @param is_corporate Bool True the contact is corporate, Fasle otherwise
- **/
-function show_admin_contacts(is_corporate, display) {
-    var display_value = display || 'inline';
-    var title = $j("#title_p");
-    var lastname = $j("#lastname_p");
-    var firstname = $j("#firstname_p");
-    var function_p = $j("#function_p");
-    var lastname_mandatory = $j("#lastname_mandatory");
-    var society_mandatory = $j("#society_mandatory");
-    if (is_corporate == true) {
-        if (title) {
-            title.css('display', 'none');
-        }
-        if (lastname) {
-            lastname.css('display', 'none');
-        }
-        if (firstname) {
-            firstname.css('display', 'none');
-        }
-        if (function_p) {
-            function_p.css('display', 'none');
-        }
-        if (lastname_mandatory) {
-            lastname_mandatory.css('display', 'none');
-        }
-        if (society_mandatory) {
-            society_mandatory.css('display', 'none');
-        }
-    } else {
-        if (title) {
-            title.css('display', display_value);
-        }
-        if (lastname) {
-            lastname.css('display', display_value);
-        }
-        if (firstname) {
-            firstname.css('display', display_value);
-
-        }
-        if (function_p) {
-            function_p.css('display', display_value);
-
-        }
-        if (lastname_mandatory) {
-            lastname_mandatory.css('display', 'inline');
-
-        }
-        if (society_mandatory) {
-            society_mandatory.css('display', 'none');
-        }
-    }
-}
-/**
- * Show or hide the data related to a person in the external contacts admin
- *
- * @param is_external Bool True the contact is external contact
- **/
-function show_admin_external_contact(is_external, display) {
-    var display_value = display || 'inline';
-    var searchDirectory = $("search_directory");
-    var externalContactLabel = $("m2m_id");
-    if (is_external === false) {
-        if (searchDirectory) {
-            searchDirectory.style.display = "none";
-        }
-        if (externalContactLabel) {
-            externalContactLabel.style.display = "none";
-        }
-    } else {
-        if (searchDirectory) {
-            searchDirectory.style.display = display_value;
-        }
-        if (externalContactLabel) {
-            externalContactLabel.style.display = display_value;
-        }
-    }
-}
-
 /**
  * Returns in an array all values selected from check boxes or radio buttons
  *
@@ -1784,35 +1521,6 @@ function get_checked_values(name_input) {
     return arr;
 }
 
-/**
- * Clears a form (empties it)
- *
- * @param form_id String Form identifier
- **/
-function clear_form(form_id) {
-    var frm = $(form_id);
-    if (frm) {
-        var items = frm.getElementsByTagName('INPUT');
-        for (var i = 0; i < items.length; i++) {
-            if (items[i].type == "text") {
-                items[i].value = '';
-            }
-        }
-        items = frm.getElementsByTagName('TEXTAREA');
-        for (var i = 0; i < items.length; i++) {
-            items[i].value = '';
-        }
-        items = frm.getElementsByTagName('SELECT');
-        for (var i = 0; i < items.length; i++) {
-            if (items[i].multiple == "true") {
-                // TO DO
-            } else {
-                items[i].options[0].selected = 'selected';
-            }
-        }
-    }
-}
-
 /*************** Apps Reports functions *****************/
 
 /**
@@ -2036,31 +1744,6 @@ function valid_report_by_period(url) {
     }
 }
 
-/**
- * Launch the Ajax autocomplete object to activate autocompletion on a field
- *
- * @param path_script String Path to the Ajax script
- **/
-function launch_autocompleter(path_script, id_text, id_div, minCharSearch) {
-    var input = id_text;
-    var div = id_div;
-    var minCharSearch = minCharSearch || 2;
-    if (path_script) {
-        // Ajax autocompleter object creation
-        new Ajax.Autocompleter(input, div, path_script, {
-            method: 'get',
-            paramName: 'Input',
-            minChars: 2
-        });
-    } else {
-        if (console != null) {
-            console.log('error parameters launch_autocompleter function');
-        } else {
-            alert('error parameters launch_autocompleter function');
-        }
-    }
-}
-
 /**
  * Launch the Ajax autocomplete object to activate autocompletion on a field and then update an input field
  *
@@ -2081,71 +1764,6 @@ function launch_autocompleter_update(path_script, id_text, id_div, minCharSearch
     });
 }
 
-/**
- * Gets the indexes for a given collection and fills a div with it
- *
- * @param url String Url to the Ajax script
- * @param id_coll String Collection identifier
- **/
-function get_opt_index(url, id_coll) {
-    if (url && id_coll) {
-        new Ajax.Request(url, {
-            method: 'post',
-            parameters: {
-                coll_id: id_coll
-            },
-            onSuccess: function (answer) {
-                var div_to_fill = $('opt_index');
-
-                if (div_to_fill) {
-                    div_to_fill.innerHTML = answer.responseText;
-                }
-            }
-        });
-    }
-}
-
-/**
- * Gets the indexes for a given document type (used in details page)
- *
- * @param doctype_id String Document type identifier
- * @param url String Url to the Ajax script
- * @param error_empty_type Message to displays if the type is empty
- **/
-function change_doctype_details(doctype_id, url, error_empty_type, res_id) {
-    if (doctype_id != null && doctype_id != '' && doctype_id != NaN) {
-        new Ajax.Request(url, {
-            method: 'post',
-            parameters: {
-                type_id: doctype_id,
-                res_id: res_id
-            },
-            onSuccess: function (answer) {
-                eval("response = " + answer.responseText);
-                //  alert(answer.responseText);
-                if (response.status == 0) {
-                    var indexes = response.new_opt_indexes;
-                    var div_indexes = $('opt_indexes_custom');
-                    if (div_indexes) {
-                        div_indexes.update(indexes);
-                    }
-
-                } else {
-                    try {
-                        //  $('main_error').innerHTML = response.error_txt;
-                    } catch (e) {
-
-                    }
-                }
-            }
-        });
-    } else {
-        try {
-            //$('main_error').innerHTML = error_empty_type;
-        } catch (e) {}
-    }
-}
-
 function updateContent(url, id_div_to_update, onComplete_callback) {
     new Ajax.Updater(id_div_to_update, url, {
         parameters: {},
@@ -2157,33 +1775,6 @@ function updateContent(url, id_div_to_update, onComplete_callback) {
     });
 }
 
-function showValuesList(listId, spanId) {
-    if (window.document.getElementById(listId).style.display == 'none') {
-        window.document.getElementById(listId).style.display = 'block';
-        window.document.getElementById(spanId).style.display = 'none';
-    } else {
-        window.document.getElementById(listId).style.display = 'none';
-        window.document.getElementById(spanId).style.display = 'block';
-    }
-}
-
-function hideIndex(mode_hide, display_val) {
-    var displayVal = $(display_val);
-    if (mode_hide == true) {
-        if (displayVal) {
-            Element.setStyle(displayVal, {
-                display: 'none'
-            });
-        }
-    } else {
-        if (displayVal) {
-            Element.setStyle(displayVal, {
-                display: 'block'
-            });
-        }
-    }
-}
-
 function checkAll() {
     $$('input[type=checkbox]').without($('all')).each(
         function (e) {
@@ -2207,16 +1798,6 @@ function unCheckAll() {
     )
 }
 
-function show_attach(state) {
-    if (state == 'true') {
-        $('attach_show').slideDown();
-    } else {
-        $('attach_show').setStyle({
-            display: 'none'
-        });
-    }
-}
-
 function addLinks(path_manage_script, child, parent, action, tableHist) {
     //window.alert('child : '+child+', parent : '+parent+', action : '+action);
     var divName = 'loadLinks';
@@ -2401,66 +1982,6 @@ function f_filterResults(n_win, n_docel, n_body) {
     return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
 }
 
-function loadDocList(id) {
-    //new Effect.toggle('docList_'+id, 'appear' , {delay:0.2});
-
-    if ($('docList_' + id).style.display == 'none') {
-        $('docList_' + id).setStyle({
-            display: 'table'
-        });
-    } else {
-        $('docList_' + id).setStyle({
-            display: 'none'
-        });
-    }
-    var path_manage_script = 'index.php?admin=contacts&page=ajaxLoadDocList&display=true';
-
-    new Ajax.Request(path_manage_script, {
-        method: 'post',
-        parameters: {
-            contact_id: id
-        },
-        onSuccess: function (answer) {
-            eval("response = " + answer.responseText);
-            $('divDocList_' + id).innerHTML = response.toShow;
-        }
-    });
-}
-
-function deleteContact(id, replaced_contact_id, replaced_address_id) {
-    //alert(id+' '+replaced_contact_id);
-    var path_manage_script = 'index.php?admin=contacts&page=ajaxDeleteContact&display=true';
-
-    new Ajax.Request(path_manage_script, {
-        method: 'post',
-        parameters: {
-            contactId: id,
-            replacedContactId: replaced_contact_id,
-            replacedAddressId: replaced_address_id
-        },
-        onSuccess: function (answer) {
-            eval("response = " + answer.responseText);
-            //alert(response.status);
-            if (response.status == 0) {
-                new Effect.toggle('divDeleteContact_' + id, 'blind', {
-                    delay: 0.2
-                });
-                new Effect.toggle('deleteContactDiv_' + id, 'blind', {
-                    delay: 0.2
-                });
-                new Effect.toggle('divDocList_' + id, 'blind', {
-                    delay: 0.2
-                });
-                new Effect.toggle('tr_' + id, 'blind', {
-                    delay: 0.2
-                });
-            } else {
-                alert('Choisissez une adresse et un contact d\'abord');
-            }
-        }
-    });
-}
-
 /************************************ LISTS ****************************************/
 var globalEval = function (script) {
     if (window.execScript) {
@@ -2760,17 +2281,6 @@ function showPreviousAttachments(path_manage_script, id) {
     });
 }
 
-function affiche_reference() {
-    var nature = document.getElementById('nature_id').options[document.getElementById('nature_id').selectedIndex];
-
-    if (nature.getAttribute('with_reference') == 'true') {
-        $j('#reference_number_tr').css('display', 'table-row');
-    } else {
-        $j('#reference_number_tr').css('display', 'none');
-        $j('#reference_number').val('');
-    }
-}
-
 function erase_contact_external_id(id, erase_id) {
     if ($j('#' + id).val() == '') {
         $j('#' + erase_id).val('');
@@ -2780,37 +2290,6 @@ function erase_contact_external_id(id, erase_id) {
     }
 }
 
-function purposeCheck() {
-    var contact_purpose_id = $('contact_purposes').value;
-    var contact_purpose_name = $('new_id').value;
-    var path_manage_script = 'index.php?page=purpose_check&dir=my_contacts&display=true';
-    if (contact_purpose_name != null && contact_purpose_id == null) {
-        $('purpose_to_create').setStyle({
-            display: 'table-row'
-        });
-    } else if (contact_purpose_name != null && contact_purpose_id != null) {
-        new Ajax.Request(path_manage_script, {
-            method: 'post',
-            parameters: {
-                contact_purpose: contact_purpose_name,
-                contact_purpose_id: contact_purpose_id
-            },
-            onSuccess: function (answer) {
-                eval("response = " + answer.responseText);
-                if (response.status == 1) {
-                    $('purpose_to_create').setStyle({
-                        display: 'table-row'
-                    });
-                } else if (response.status == 0) {
-                    $('purpose_to_create').setStyle({
-                        display: 'none'
-                    });
-                }
-            }
-        });
-    }
-}
-
 function simpleAjax(url) {
     new Ajax.Request(url, {
         method: 'post'
@@ -2836,190 +2315,6 @@ function loadDiffListHistory(listinstance_history_id) {
     });
 }
 
-function saveSizeInBytes() {
-    if (!isNaN($('size_limit_number').value)) {
-        if ($('size_format').value == "MB") {
-            $('size_limit_hidden').value = $('size_limit_number').value * (1000 * 1000);
-        }
-        if ($('size_format').value == "GB") {
-            $('size_limit_hidden').value = $('size_limit_number').value * (1000 * 1000 * 1000);
-        }
-        if ($('size_format').value == "TB") {
-            $('size_limit_hidden').value = $('size_limit_number').value * (1000 * 1000 * 1000 * 1000);
-        }
-    } else {
-        window.alert('WRONG FORMAT');
-    }
-}
-
-function convertSize() {
-    if (!isNaN($('size_limit_number').value)) {
-        if ($('size_format').value == "MB") {
-            $('size_limit_number').value = $('size_limit_hidden').value / (1000 * 1000);
-            $('actual_size_number').value = $('actual_size_hidden').value / (1000 * 1000);
-        }
-        if ($('size_format').value == "GB") {
-            $('size_limit_number').value = $('size_limit_hidden').value / (1000 * 1000 * 1000);
-            $('actual_size_number').value = $('actual_size_hidden').value / (1000 * 1000 * 1000);
-        }
-        if ($('size_format').value == "TB") {
-            $('size_limit_number').value = $('size_limit_hidden').value / (1000 * 1000 * 1000 * 1000);
-            $('actual_size_number').value = $('actual_size_hidden').value / (1000 * 1000 * 1000 * 1000);
-        }
-    } else {
-        window.alert('WRONG FORMAT');
-    }
-}
-
-function setPreviousAddress(address) {
-    if (address != "") {
-        var allCoordoate = address.split('||');
-        $('num').value = allCoordoate[0];
-        $('street').value = allCoordoate[1];
-        $('add_comp').value = allCoordoate[2];
-        $('cp').value = allCoordoate[3];
-        $('town').value = allCoordoate[4];
-        $('country').value = allCoordoate[5];
-        $('website').value = allCoordoate[6];
-    }
-}
-
-function checkOthersDuplicate(id_form, checkbox_name, radio_name) {
-
-    elem = document.forms[id_form];
-    var state = false;
-    for (var i = 0; i < elem.length; i++) {
-        if (document.forms[id_form][i].name == checkbox_name) {
-            document.forms[id_form][i].checked = true;
-        } else if (document.forms[id_form][i].name == radio_name && state == false) {
-            document.forms[id_form][i].checked = true;
-            state = true;
-        } else {
-            document.forms[id_form][i].checked = false;
-        }
-
-        if (document.forms[id_form][i] == radio_name && state == false) {
-            document.forms[id_form][i].checked = true;
-            state = true;
-        }
-    }
-
-}
-
-function linkDuplicate(id_form) {
-    elem = document.forms[id_form];
-    var slave = [];
-    var address_del = [];
-    var master = '';
-    var master_address = '';
-    for (var i = 0; i < elem.length; i++) {
-        if (document.forms[id_form][i].type == 'checkbox' && document.forms[id_form][i].checked == true) {
-            if (document.forms[id_form][i].name == 'delete_address') {
-                address_del.push(document.forms[id_form][i].value);
-            } else {
-                slave.push(document.forms[id_form][i].value);
-            }
-        }
-        if (document.forms[id_form][i].type == 'radio' && document.forms[id_form][i].checked == true) {
-            master = document.forms[id_form][i].value;
-            master_address = document.getElementById('master_address_fusion_id_' + document.forms[id_form][i].value).value
-        }
-    }
-    var index = slave.indexOf(master);
-    slave.splice(index, 1);
-
-    if (slave.length == 0) {
-        alert('Aucun contact à fusionner !');
-        return false;
-    }
-
-    if (master == '') {
-        alert('Aucun contact Maitre sélectionné !');
-        return false;
-    }
-    var address_del_string = '';
-    address_del_string = address_del.join();
-    if (address_del_string != '') {
-        address_del_string = '(Les adresses suivantes seront effacées : ' + address_del_string + ')';
-    }
-    if (confirm('Vous êtes sur le point de substituer les contacts suivants : ' + slave.join() + '\navec le contact : ' + master + ' ' + address_del_string)) {
-        var path_manage_script = 'index.php?admin=contacts&page=fusionContact&display=true';
-        new Ajax.Request(path_manage_script, {
-            method: 'post',
-            parameters: {
-                master_address_id: master_address,
-                slave_contact_id: slave.join(),
-                del_address_id: address_del.join(),
-                master_contact_id: master
-            },
-            onSuccess: function (answer) {
-                eval("response = " + answer.responseText);
-                if (response.status == 0) {
-                    console.log(response);
-                } else if (response.status == 1) {
-                    alert('Erreur!');
-                }
-            }
-        });
-        alert('Opération terminée!');
-    }
-}
-
-function loadTab(resId, collId, titleTab, pathScriptTab, module) {
-    if (document.getElementById('show_tab').getAttribute('module') == module) {
-        document.getElementById('show_tab').style.display = 'none';
-        if (document.getElementById(module + '_tab') != undefined) {
-            document.getElementById(module + '_tab').innerHTML = '<i class="fa fa-plus-square"></i>';
-        }
-        document.getElementById('show_tab').setAttribute('module', '');
-        return false;
-
-    }
-
-    var path_manage_script = 'index.php?display=true&page=display_tab';
-    $j.ajax({
-        url: path_manage_script,
-        type: 'POST',
-        data: {
-            resId: resId,
-            collId: collId,
-            titleTab: titleTab,
-            pathScriptTab: pathScriptTab
-        },
-        success: function (answer) {
-            document.getElementById('show_tab').style.display = 'block';
-            document.getElementById('show_tab').setAttribute('module', module);
-
-            $j("span[class='tab_module']").each(function (i, e) {
-                e.innerHTML = '<i class="fa fa-plus-square"></i>';
-            })
-            if (document.getElementById(module + '_tab') != undefined) {
-                document.getElementById(module + '_tab').innerHTML = '<i class="fa fa-minus-square"></i>';
-            }
-            document.getElementById('show_tab').innerHTML = answer;
-        }
-    });
-}
-
-function loadSpecificTab(id_iframe, pathScriptTab) {
-    document.getElementById(id_iframe).src = pathScriptTab;
-}
-
-function tabClicked(TabId, toHide) {
-    var doc = $j("#home-panel");
-    if (toHide) {
-        doc.css("display", "none");
-        $j("#uniqueDetailsDiv").css("display", "");
-    } else {
-        $j("#uniqueDetailsDiv").css("display", "none");
-        doc.css("display", "");
-    }
-
-    $j(".DetailsTabFunc").removeClass("TabSelected");
-    $j("#" + TabId).addClass("TabSelected");
-
-}
-
 //LOAD BADGES TOOLBAR
 function loadToolbarBadge(targetTab, path_manage_script) {
 
@@ -3564,114 +2859,6 @@ function print_current_result_list(path) {
     }
 }
 
-function toggleRefMaarch() {
-    if ($j('#refMaarch').is(":checked")) {
-        $j('#refSearch').css({
-            "display": "flex"
-        });
-        $j(".refMaarch input").addClass("readonly");
-        $j(".refMaarch input").prop("readonly", true);
-    } else {
-        $j('#refSearch').hide();
-        $j(".refMaarch input").removeClass("readonly");
-        $j(".refMaarch input").prop("readonly", false);
-    }
-}
-
-function setRefAdresse(item) {
-    $j("#ban_id").val(item.banId);
-    $j(".refMaarch #num").val(item.number);
-    $j(".refMaarch #street").val(item.afnorName);
-    $j(".refMaarch #cp").val(item.postalCode);
-    $j(".refMaarch #town").val(item.city);
-    $j(".refMaarch #country").val("FRANCE");
-}
-
-function toggleBlock(div, divIcon) {
-    $j('#' + div).slideToggle('slow');
-    if ($j('#' + divIcon + ' i').hasClass('fa-minus-square')) {
-        $j('#' + divIcon + ' i').removeClass('fa-minus-square');
-        $j('#' + divIcon + ' i').addClass('fa-plus-square');
-    } else {
-        $j('#' + divIcon + ' i').removeClass('fa-plus-square');
-        $j('#' + divIcon + ' i').addClass('fa-minus-square');
-    }
-}
-
-function loadTypeahead(input, order, dynamic, url) {
-    $j.typeahead({
-        input: input,
-        order: order,
-        dynamic: dynamic,
-        debug: false,
-        source: {
-            ajax: function (query) {
-                return {
-                    type: 'POST',
-                    url: url,
-                    data: {
-                        Input: "{{query}}"
-                    }
-                }
-            }
-        }
-    });
-}
-
-function reloadTypeahead(elem) {
-    $j(".typeahead__result").remove();
-    $j("#searchAddress").val('');
-    $j("#searchAddress").attr("placeholder", "Rechercher dans le référentiel du " + $j('#' + elem.id).val());
-    $j("#searchAddress").typeahead({
-        delay: '500',
-        minLength: 3,
-        order: "asc",
-        maxItem: 10,
-        filter: false,
-        dynamic: true,
-        display: "address",
-        templateValue: "{{address}}",
-        emptyTemplate: "Aucune adresse n'existe avec <b>{{query}}</b>",
-        source: {
-            ajax: {
-                type: "GET",
-                dataType: "json",
-                url: "../../rest/autocomplete/banAddresses",
-                data: {
-                    address: "{{query}}",
-                    department: $j('#' + elem.id).val()
-                }
-            }
-        },
-        callback: {
-            onClickAfter: function (node, a, item, event) {
-                setRefAdresse(item);
-            }
-        }
-    });
-}
-
-function checkMultiIndexingGroup(url) {
-    $j.ajax({
-        url: '../../rest/header',
-        type: 'get',
-        data: {},
-        success: function (answer) {
-            if (answer.user.indexingGroups.length > 1) {
-                var link = '';
-                answer.user.indexingGroups.each(function (group, key) {
-                    link += '<li style="padding:5px;"><a href="'+url+'&groupId='+group.groupId+'">'+group.label+'</a></li>';
-                });  
-                var modal = $j('<div id="indexingGroupSelect" class="modal" style="position: fixed;left: 50%;transform: translate(-50%, -50%);top: 25%;"><h2>Profil d\'indexation :</h2><ul style="text-align:left;font-size: 24px;">'+link+'</ul><div style="display: flex;justify-content: center;"><input style="width: 70px;text-align: center;" class="button" value="Annuler" onclick="$j(\'#indexingGroupSelect\').remove();$j(\'#maarch_content\').css({opacity:1})"/></div></div>');
-                modal.appendTo('body');
-                $j('#maarch_content').css({opacity:0.2});
-            } else {
-                window.location.href=url;
-            }
-        }
-    });
-}
-
 function writeLocationBar(path,label,level) {
     if ($j('#ariane a:last').length == 0) {
         var home = $j('<a href="'+path+'" onclick="localStorage.setItem(\'PreviousV2Route\', \'/home\');">'+label+'</a>');
@@ -3684,100 +2871,6 @@ function writeLocationBar(path,label,level) {
     }    
 }
 
-function contactMapping(fieldsCtrl, formId) {
-    for (var j = 0, fieldsCtrlElem; fieldsCtrlElem = fieldsCtrl[j++];) {
-        if (fieldsCtrlElem === "department") {
-            fieldsCtrl[j-1] = "departement";
-        }
-        if (fieldsCtrlElem === "address_complement") {
-            fieldsCtrl[j-1] = "add_comp";
-        }
-        if (fieldsCtrlElem === "address_num") {
-            fieldsCtrl[j-1] = "num";
-        }
-        if (fieldsCtrlElem === "address_street") {
-            fieldsCtrl[j-1] = "street";
-        }
-        if (fieldsCtrlElem === "address_postal_code") {
-            fieldsCtrl[j-1] = "cp";
-        }
-        if (fieldsCtrlElem === "address_town") {
-            fieldsCtrl[j-1] = "town";
-        }
-        if (fieldsCtrlElem === "address_country") {
-            fieldsCtrl[j-1] = "country";
-        }
-        if (fieldsCtrlElem === "email") {
-            fieldsCtrl[j-1] = "mail";
-        }
-        if (fieldsCtrlElem === "add_comp") {
-            fieldsCtrl[j-1] = "comp_data";
-        }
-        if (fieldsCtrlElem === "other_data") {
-            fieldsCtrl[j-1] = "comp_data";
-        }
-    }
-    var elements = document.getElementById(formId).elements;
-
-    for (var i = 0, element; element = elements[i++];) {
-        for (var j = 0, fieldsCtrlElem; fieldsCtrlElem = fieldsCtrl[j++];) {
-            if (element.name === fieldsCtrlElem) {
-                element.style.borderWidth = "2px";
-                element.style.borderColor = "#CCFFCC";
-            }
-        }
-    }
-}
-
-function switchAutoCompleteType(id, mode, alternateVersion) {
-    if (mode == 'contactsUsers' && $j('#'+id+'_icon_contactsUsers').css('color') != 'rgb(19, 95, 127)') {
-        $j('#'+id+'_icon_contactsUsers').css({'color' : '#135F7F'});
-        $j('#'+id+'_icon_entities').css({'color' : '#666'});
-        $j('#'+id+'').attr('placeholder','Rechercher un contact / utilisateur');
-        $j(".typeahead__result").remove();
-        initSenderRecipientAutocomplete(id, 'contactsUsers', alternateVersion);
-        $j('#'+id).val('');
-        $j('#'+id+'_id').val('');
-        $j('#'+id+'_type').val('');
-        $j('#'+id+'').css('background-color', 'white');
-    } else if (mode == 'entities' && $j('#'+id+'_icon_entities').css('color') != 'rgb(19, 95, 127)') {
-        $j('#'+id+'_icon_contactsUsers').css({'color' : '#666'});
-        $j('#'+id+'_icon_entities').css({'color' : '#135F7F'});
-        $j('#'+id+'').attr('placeholder','Rechercher une entité');
-        $j(".typeahead__result").remove();
-        initSenderRecipientAutocomplete(id, 'entities', alternateVersion);
-        $j('#'+id).val('');
-        $j('#'+id+'_id').val('');
-        $j('#'+id+'_type').val('');
-        $j('#'+id+'').css('background-color', 'white');
-    }
-}
-
-function openSenderInfoContact(id, type) {
-    var height = '';
-    if (id == '') {
-        alert('Aucun contact sélectionné');
-        return false;
-    }
-    if(type == 'entity'){
-        alert('Aucune information disponible pour les entités');
-    } else {
-        if(type == 'user'){
-            height = '400';
-        } else {
-            height = '800';
-        }
-        window.open('index.php?display=true&dir=my_contacts&page=info_contact_iframe&mode=editDetailSender&editDetailSender&popup&sender_recipient_id='+id+'&sender_recipient_type='+type, 'contact_info', 'height='+height+', width=1000,scrollbars=yes,resizable=yes');
-    }
-}
-
-function displayAddMailing() {
-    if ($j("#mailingInfo").is(":visible")) {
-        $j("#addMailing").show();
-    }
-}
-
-
 function setSendAttachment(id) {
     $j.ajax({
         url: '../../rest/attachments/' + id + '/inSendAttachment',
diff --git a/apps/maarch_entreprise/js/indexing.js b/apps/maarch_entreprise/js/indexing.js
index 116a206f72d..2f18a50a353 100755
--- a/apps/maarch_entreprise/js/indexing.js
+++ b/apps/maarch_entreprise/js/indexing.js
@@ -1,297 +1,9 @@
 
 var $j = jQuery.noConflict();
 
-/**
- * Compute process limit date from the admission date
- *
- **/
-function updateProcessDate(path_manage_script)
-{
-    var admissionDate;
-    
-    if ($('admission_date')) {
-        admissionDate = $('admission_date').value;
-    }
-    var typeId;
-    if ($('type_id')) {
-        typeId = $('type_id').value;
-    }
-    var priorityId;
-    if ($('priority')) {
-        priorityId = $('priority').value;
-    }
-    if (admissionDate != null && admissionDate != '' && admissionDate != NaN) {
-        new Ajax.Request(path_manage_script,
-        {
-            method:'post',
-            parameters: {
-                    type_id: typeId,
-                    admission_date : admissionDate,
-                    priority_id : priorityId
-                },
-                onSuccess: function(answer){
-                eval("response = "+answer.responseText);
-                //alert(answer.responseText);
-                if (response.status == 0  || response.status == 1) {
-                    //console.log(response.process_date);
-                    var process_date = $('process_limit_date');
-                    if (response.process_date != null) {
-                        process_date.value = response.process_date;
-                    }
-                }
-            }
-        });
-    }
-}
-
 /** Declaration of the autocompleter object used for the contacts*/
 var contact_autocompleter;
 
-/**
- * Launch the Ajax autocomplete object to activate autocompletion on contacts
- *
- * @param path_script String Path to the Ajax script
- **/
-function launch_autocompleter_contacts(path_script, id_text, id_div, cat_id)
-{
-    var input  = id_text || 'contact';
-    var div    = id_div  || 'show_contacts';
-    
-    var params = get_contacts_params();
-    
-    if (contact_autocompleter && contact_autocompleter.element == $$('#' + input)[0])
-        contact_autocompleter.options.defaultParams = params;
-    else if(path_script)
-        contact_autocompleter = new Ajax.Autocompleter(input, div, path_script, {
-            method:'get',
-            paramName:'Input',
-            parameters: params,
-            minChars: 2
-        });
-    else return false;
-}
-
-/**
- * Launch the Ajax autocomplete object to activate autocompletion on contacts en put address_id and contact_id in an hidden input
- *
- * @param path_script String Path to the Ajax script
- **/
-function launch_autocompleter_contacts_v2(path_script, id_text, id_div, cat_id, contact_id, address_id, path_script2)
-{
-    var input  = id_text || 'contact';
-    var div    = id_div  || 'show_contacts';
-    
-    var params = get_contacts_params();
-
-    if (contact_autocompleter && contact_autocompleter.element == $j('#' + input)[0]) {
-        contact_autocompleter.options.defaultParams = params;
-    } else if(path_script) {
-        contact_autocompleter = new Ajax.Autocompleter(input, div, path_script, {
-            method:'get',
-            paramName:'Input',
-            parameters: params,
-            minChars: 2,
-            //loading
-            frequency: 0.5, // NOTICE THIS
-             indicator: 'searching_autocomplete', // AND THIS
-             onShow : function(element, update) {
-                Effect.Appear(update,{duration:0});
-            },
-            afterUpdateElement: function (text, li){
-                var all_li = li.id;
-                var res = all_li.split(",");
-                parent.$(contact_id).value = res[0];
-                if (typeof (parent.$(contact_id).onchange) == 'function')
-                    parent.$(contact_id).onchange();
-                parent.$(address_id).value = res[1];
-                if (path_script2 && res[1]) {
-                    getDepartment(path_script2, res[1]);
-                }
-                $j("#" + input).css('background-color', li.getStyle('background-color'));
-            }
-        });
-    } else {
-        return false;
-    }
-}
-
-function launch_autocompleter_contacts_search(path_script, id_text, id_div, cat_id, contact_id, address_id)
-{
-    var input  = id_text || 'contact';
-    var div    = id_div  || 'show_contacts';
-    
-    var params = 'table=contacts';
-
-    if (contact_autocompleter && contact_autocompleter.element == $j('#' + input)[0]) {
-        contact_autocompleter.options.defaultParams = params;
-    } else if(path_script) {
-        contact_autocompleter = new Ajax.Autocompleter(input, div, path_script, {
-            method:'get',
-            paramName:'Input',
-            parameters: params,
-            minChars: 2,
-            //loading
-            frequency: 0.5, // NOTICE THIS
-             indicator: 'searching_autocomplete', // AND THIS
-             onShow : function(element, update) {
-                Effect.Appear(update,{duration:0});
-            },
-            afterUpdateElement: function (text, li){
-                var all_li = li.id;
-                var res = all_li.split(",");
-                $(contact_id).value = res[0];
-                if (typeof ($(contact_id).onchange) == 'function')
-                    $(contact_id).onchange();
-                    $(address_id).value = res[1];
-            }
-        });
-    } else {
-        return false;
-    }
-}
-
-function launch_autocompleter2_contacts_v2(path_script, id_text, id_div, cat_id, contact_id, address_id, path_script2)
-{
-    var input  = id_text || 'contact';
-    var div    = id_div  || 'show_contacts';
-    
-    if (contact_autocompleter && contact_autocompleter.element == $j('#' + input)[0])
-        contact_autocompleter.options.defaultParams = params;
-    else if(path_script)
-        contact_autocompleter = new Ajax.Autocompleter2(input, div, path_script, {
-            method:'get',
-            paramName:'Input',
-            parameters: 'table=contacts&contact_type=letter',
-            minChars: 2,
-            afterUpdateElement: function (text, li){
-                var all_li = li.id;
-                var res = all_li.split(",");
-                if (parent.$(contact_id) == null) {
-                    top.$(contact_id).value = res[0];
-                    top.$(address_id).value = res[1];
-                } else {
-                    parent.$(contact_id).value = res[0];
-                    parent.$(address_id).value = res[1];
-                }
-                
-                
-            }
-        });
-    else {
-        return false;
-    }
-}
-
-function getDepartment(path_script, address_id) {
-    new Ajax.Request(path_script,
-    {
-        method:'post',
-        parameters: { address_id : address_id
-                    },
-            onSuccess: function(answer){
-            eval("response = "+answer.responseText);
-            if(response.status == 0 ) {
-                parent.$("department_number").value = response.departement_name;
-                parent.$("department_number_id").value = response.departement_id;
-            }
-        }
-    });
-}
-
-function launch_autocompleter_choose_contact(path_script, id_text, id_div, cat_id, contact_id){
-    var input  = id_text || 'contact';
-    var div    = id_div  || 'show_contacts';
-    
-    // var params = get_contacts_params();
-
-    contact_autocompleter = new Ajax.Autocompleter(input, div, path_script, {
-        method:'get',
-        paramName:'what',
-        // parameters: params,
-        minChars: 2,
-        afterUpdateElement: function (text, li){
-            $(contact_id).value = li.id;
-        }
-    });
-
-}
-
-function putInSessionContact(path_script){
-    var contactSelected = $('contactSelect').options[$('contactSelect').selectedIndex].value;
-    if (contactSelected == "") {
-        alert("Choisissez un contact");
-    } else {
-        new Ajax.Request(path_script,
-        {
-            method:'post',
-            parameters: {
-                contactid : contactSelected
-            },
-            onSuccess: function(answer){
-                    document.location = 'index.php?display=false&dir=my_contacts&page=create_address_iframe';
-            }
-        });
-    }
-}
-
-function getContacts(path_script, id, mode){
-    new Ajax.Request(path_script,
-    {
-        method:'post',
-        parameters: {
-            type_id: id,
-            mode: mode
-        },
-        onSuccess: function(answer){
-            if(mode=="view"){
-                if (id != "") {
-                    $('contacts_created_tr').setStyle({display : 'table-row'});
-                    $('contacts_created').innerHTML = answer.responseText;
-                } else {
-                    $('contacts_created_tr').setStyle({display : 'none'});
-                }
-            } else if(mode="set"){
-                //$('contactSelect').innerHTML = answer.responseText;
-            }
-        }
-    });
-}
-
-/**
- * Gets the parameters for the contacts : the table which must be use in the ajax script
- *
- * @return String parameters
- **/
-function get_contacts_params(name_radio)
-{
-    var check = name_radio || 'type_contact';
-    var arr = get_checked_values(check);
-    var params = '';
-    var cat = '';
-    
-    if (parent.document.getElementById('category_id').value != undefined) {
-        cat = parent.document.getElementById('category_id').value;
-    }else if (parent.parent.document.getElementById('category_id').value != undefined) {
-        cat = parent.parent.document.getElementById('category_id').value;
-    }else{
-        cat = document.getElementById('category_id').value;
-    }
-    if (arr.length == 0) {
-        var contact_type = 'letter';
-        params = 'table=contacts&contact_type=' + contact_type;
-    } else {
-        if (arr[0] == 'internal') {
-            params = 'table=users';
-        } else if(arr[0] == 'external') {
-            params = 'table=contacts';
-        } else {
-            params = 'table=contacts';
-        }
-    }
-    
-    return params;
-}
-
 function clear_error(id_error)
 {
     //console.log("'"+id_error+"'");
@@ -303,32 +15,6 @@ function clear_error(id_error)
     }
 }
 
-function display_contact_card(mode, id)
-{
-	if(id){
-		var contact_card = $(id);
-
-	}else{
-		var contact_card = $('contact_card');
-	}
-
-    if ($('contactidAttach')) {
-        var contactid = $('contactidAttach').value;
-    } else {
-        if ($('contactid')) {
-            var contactid = $('contactid').value;
-        }        
-    }
-    
-
-    if(contact_card && (mode == 'hidden' || mode == 'visible') && contactid != '')
-    {
-        Element.setStyle(contact_card, {visibility : mode});
-    } else if (contactid == '') {
-        Element.setStyle(contact_card, {visibility : 'hidden'});
-    }
-}
-
 function changeCycle(path_manage_script)
 {
     var policy_id = $('policy_id');
@@ -362,235 +48,6 @@ function changeCycle(path_manage_script)
     //}
 }
 
-var addMultiContacts = function (idField, idList, theUrlToListScript, paramNameSrv, minCharsSrv, contact_id, address_id) {
-     new Ajax.Autocompleter(
-         idField,
-         idList,
-         theUrlToListScript,
-         {
-             paramName : paramNameSrv,
-             minChars : minCharsSrv,
-             tokens : ',',
-             //afterUpdateElement : extractEmailAdress,
-			parameters : 'table=contacts',
-            //loading
-            frequency: 0.5, // NOTICE THIS
-             indicator: 'searching_autocomplete_multi', // AND THIS
-             onShow : function(element, update) {
-                Effect.Appear(update,{duration:0});
-            },
-            afterUpdateElement: function (text, li){
-                var all_li = li.id;
-                var res = all_li.split(",");
-                parent.$(contact_id).value = res[0];
-                if(res[1]==' ') {
-                    res[1] = 0;
-                }
-                parent.$(address_id).value = res[1];
-            }
-         });
- };
- 
-function updateMultiContacts(path, action, contact, target, array_index, addressid, contactid) {
-
-	new Ajax.Request(path,
-	{
-		method:'post',
-		parameters: { url : path,
-					  'for': action,
-					  contact: contact,
-					  field: target,
-					  index: array_index,
-                      addressid: addressid,
-                      contactid: contactid
-					},
-		onLoading: function(answer) {
-			$('loading_' + target).style.display='inline';
-		},
-		onSuccess: function(answer) {
-			eval("response = "+answer.responseText);
-			if(response.status == 0){
-				$(target).innerHTML = response.content;
-				if (action == 'add') {
-                    $j('#contactid').val('');
-                    $j('#is_multicontacts').val('');
-                    $j('#addressid').val('');
-                    $j('#email').val('');
-                }
-			} else {
-				alert(response.error);
-				eval(response.exec_js);
-			}
-			// $('loading_' + target).style.display='none';
-		}
-	});
-}
-
-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});  
-    }
-    
-    if(transmission != '' & transmission != '0' && transmission != undefined){
-        new Ajax.Request(path_manage_script,
-    {
-        method:'post',
-        parameters: {},
-        onSuccess: function(answer){
-            eval("response = "+answer.responseText);
-            if (parent.$('transmissionContact_attach'+transmission)) {
-                parent.$('transmissionContact_attach'+transmission).value = response.contactName;
-            } else if (parent.$('contact')) {
-                parent.$('contact').value = response.contactName;
-            }
-            if (parent.$('transmissionContactidAttach'+transmission)) {
-                parent.$('transmissionContactidAttach'+transmission).value = response.contactId;
-            } else if (parent.$('contactid')){
-                parent.$('contactid').value = response.contactId;
-            }
-            if (parent.$('addressidAttach'+transmission)) {
-                parent.$('addressidAttach'+transmission).value = response.addressId;
-            } else if (parent.$('transmissionAddressidAttach'+transmission)){
-                parent.$('transmissionAddressidAttach'+transmission).value = response.addressId;
-            }
-            getDepartment('index.php?display=true&page=getDepartment', response.addressId);
-        }       
-    });
-    }else{
-        new Ajax.Request(path_manage_script,
-        {
-        method:'post',
-        parameters: {},
-        onSuccess: function(answer){
-            eval("response = "+answer.responseText);
-            if (parent.$('contact_attach')) {
-                parent.$('contact_attach').value = response.contactName;
-            } else if (parent.parent.$('contact_attach')) {
-                parent.parent.$('contact_attach').value = response.contactName;
-            } else if (parent.$('contact') && parent.$('add_multi_contact_tr').style.display == 'none') {
-                parent.$('contact').value = response.contactName;
-            } else if (parent.parent.$('contact')  && parent.parent.$('add_multi_contact_tr').style.display == 'none') {
-                parent.parent.$('contact').value = response.contactName;
-            }
-            if (response.rateColor != "") {
-                parent.$j('#contact').css('background-color', response.rateColor);
-            }
-            if (parent.$('email') && parent.$('add_multi_contact_tr').style.display != 'none') {
-                parent.$('email').value = response.contactName;
-            } else if (parent.parent.$('email') && parent.parent.$('add_multi_contact_tr').style.display != 'none') {
-                parent.parent.$('email').value = response.contactName;
-            }
-            if (parent.$('contactidAttach')) {
-                parent.$('contactidAttach').value = response.contactId;
-            } else if (parent.parent.$('contactidAttach')){
-                parent.parent.$('contactidAttach').value = response.contactId;
-            } else if (parent.$('contactid')){
-                parent.$('contactid').value = response.contactId;
-            } else if (parent.parent.$('contactid')){
-                parent.parent.$('contactid').value = response.contactId;
-            }
-            if (parent.$('addressidAttach')) {
-                parent.$('addressidAttach').value = response.addressId;
-            } else if (parent.parent.$('addressidAttach')){
-                parent.parent.$('addressidAttach').value = response.addressId;
-            } else if (parent.$('addressid')){
-                parent.$('addressid').value = response.addressId;
-            } else if (parent.parent.$('addressid')){
-                parent.parent.$('addressid').value = response.addressId;
-            }
-            getDepartment('index.php?display=true&page=getDepartment', response.addressId);
-        }       
-    });
-    }
-}
-
-function affiche_chrono(){
-    
-    var type_id = document.getElementById('attachment_types').options[document.getElementById('attachment_types').selectedIndex];
-
-    if (type_id.getAttribute('with_chrono') == 'true') { 
-        $('get_chrono_display').setStyle({display: 'none'});     
-        $('chrono_label').setStyle({display: 'inline'});
-        $('chrono_display').setStyle({display: 'inline'});
-            new Ajax.Request('index.php?display=true&module=attachments&page=get_chrono_attachment',
-                {
-                    method:'post',
-                    parameters:
-                    {
-                        type_id : type_id
-                    },
-                     onSuccess: function(answer){
-                        eval("response = "+answer.responseText);
-                        $('chrono_display').value=response.chronoNB;
-                        $('chrono').value=response.chronoNB;
-                    }
-                });
-    } else if (type_id.getAttribute('get_chrono') != '') {
-        $('chrono_display').setStyle({display: 'none'});
-        $('chrono_display').value='';     
-        $('chrono_label').setStyle({display: 'inline'});
-        $('get_chrono_display').setStyle({display: 'inline'});
-        $('chrono').value='';
-            new Ajax.Request('index.php?display=true&module=attachments&page=get_other_chrono_attachment',
-                {
-                    method:'post',
-                    parameters:
-                    {
-                        type_id : type_id.value
-                    },
-                     onSuccess: function(answer){
-                        eval("response = "+answer.responseText);
-                        $('get_chrono_display').innerHTML=response.chronoList;
-                    }
-                });
-    } else {
-        $('chrono_label').setStyle({display: 'none'});
-        $('get_chrono_display').setStyle({display: 'none'});
-        $('chrono_display').setStyle({display: 'none'});
-        $('chrono_display').value='';
-        $('chrono').value='';
-    }
-}
-
-function showEditButton(){
-
-    var modele_id = document.getElementById('templateOffice').options[document.getElementById('templateOffice').selectedIndex];
-
-    if (modele_id.value != '') {
-        $('edit').setStyle({display: 'inline'});
-        if ($('not_enabled')) {
-            $('not_enabled').setStyle({display: 'inline'});
-		}
-        if ($('choose_file')){
-            $('choose_file').setStyle({display: 'none'});
-		}
-        if ($('file_loaded')) {
-            $('file_loaded').setStyle({display: 'none'});
-        }
-    } else {
-        $('edit').setStyle({display: 'none'});
-        if ($('not_enabled')) {
-            $('not_enabled').setStyle({display: 'none'});
-        }
-        if ($('file_loaded')) {
-            $('file_loaded').setStyle({display: 'none'});
-        }
-    }
-}
-
-function loadInfoContact(){
-    var reg = /^\d+$/;
-    var pathScript = '';
-
-    if(!reg.test(document.getElementById('contactid').value)){
-        pathScript = 'index.php?display=false&page=user_info&id='+document.getElementById('contactid').value;
-    }else{
-        pathScript = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&seeAllAddresses&contactid='+document.getElementById('contactid').value+'&addressid='+document.getElementById('addressid').value;
-    }
-    
-    return pathScript;
-}
-
 function initSenderRecipientAutocomplete(inputId, mode, alternateVersion, cardId) {
     var route = '../../rest/autocomplete/all';
 
diff --git a/apps/maarch_entreprise/js/usergroups_management.js b/apps/maarch_entreprise/js/usergroups_management.js
deleted file mode 100755
index b792ce22dad..00000000000
--- a/apps/maarch_entreprise/js/usergroups_management.js
+++ /dev/null
@@ -1,123 +0,0 @@
-function modifyAccess(url_modify)
-{
-    var accesses = document.getElementsByName('security[]');
-    var val = '';
-    if(accesses)
-    {
-        for(var i=0; i< accesses.length;i++)
-        {
-            if(accesses[i].checked == true)
-            {
-                val = '&val='+accesses[i].value;
-                break;
-            }
-        }
-    }
-    displayModal(url_modify+val, 'add_grant', 850, 650);
-}
-
-function removeAccess( url_remove, url_display_access)
-{
-    var accesses = document.getElementsByName('security[]');
-    var val = '';
-    if(accesses)
-    {
-        for(var i=0; i< accesses.length;i++)
-        {
-            if(accesses[i].checked == true)
-            {
-                val += accesses[i].value+'#';
-            }
-        }
-    }
-    //val.substring(0, val.length -3);
-
-    new Ajax.Request(url_remove,
-    {
-            method:'post',
-            parameters: {
-                            security : val
-                        },
-                onSuccess: function(answer){
-                eval("response = "+answer.responseText);
-            //  alert(answer.responseText);
-                if(response.status == 0  )
-                {
-                    updateContent(url_display_access, 'access');
-                }
-            }
-        });
-}
-
-function checkAccess(current_form_id, url_check, url_manage, url_display_access, protect_string)
-{
-    var frm_values = get_form_values(current_form_id);
-    if(protect_string == false)
-    {
-        var protect = false;
-    }
-    else
-    {
-        var protect = true;
-    }
-  //  alert(frm_values);
-    if(protect)
-    {
-        //frm_values = frm_values.replace(/\'/g, "\\'");
-        frm_values = frm_values.replace(/\"/g, '\\"');
-        frm_values = frm_values.replace(/\r\n/g, ' ');
-        frm_values = frm_values.replace(/\r/g, ' ');
-        frm_values = frm_values.replace(/\n/g, ' ');
-    }
-    new Ajax.Request(url_check,
-    {
-        method:'post',
-        parameters: {
-                      form_values : frm_values
-                    },
-            onSuccess: function(answer){
-            eval("response = "+answer.responseText);
-        //  alert(answer.responseText);
-            if(response.status == 0  )
-            {
-                manageAccess(url_manage,url_display_access, frm_values);
-            }
-            else //  Form Params errors
-            {
-                //console.log(response.error_txt);
-                try{
-                        $('frm_error').innerHTML = response.error_txt;
-                    }
-                catch(e){}
-            }
-        }
-    });
-}
-
-function manageAccess(url_manage, url_display_access, frm_values)
-{
-    new Ajax.Request(url_manage,
-    {
-        method:'post',
-        parameters: {
-                      form_values : frm_values
-                    },
-            onSuccess: function(answer){
-            eval("response = "+answer.responseText);
-        //  alert(answer.responseText);
-            if(response.status == 0  )
-            {
-                updateContent(url_display_access, 'access');
-                destroyModal('add_grant');
-            }
-            else
-            {
-                //console.log(response.error_txt);
-                try{
-                        $('frm_error').innerHTML = response.error_txt;
-                    }
-                catch(e){}
-            }
-        }
-    });
-}
diff --git a/apps/maarch_entreprise/lang/en.php b/apps/maarch_entreprise/lang/en.php
index 8120e4c9ede..0137048fa4c 100755
--- a/apps/maarch_entreprise/lang/en.php
+++ b/apps/maarch_entreprise/lang/en.php
@@ -2159,20 +2159,6 @@ if (!defined('_LIMIT_DATE_PROCESS')) {
     define('_LIMIT_DATE_PROCESS', 'Processing deadline');
 }
 
-if (!defined('_MANAGE_CONTACT_TYPES_DESC')) {
-    define('_MANAGE_CONTACT_TYPES_DESC', 'Contact types management');
-}
-if (!defined('_MANAGE_CONTACT_TYPES')) {
-    define('_MANAGE_CONTACT_TYPES', 'Contact types management <br/>(Level 1)');
-}
-
-if (!defined('_MANAGE_CONTACT_PURPOSES_DESC')) {
-    define('_MANAGE_CONTACT_PURPOSES_DESC', 'Denomination management');
-}
-if (!defined('_MANAGE_CONTACT_PURPOSES')) {
-    define('_MANAGE_CONTACT_PURPOSES', 'Denomination management <br/>(Level 3)');
-}
-
 if (!defined('_MANAGE_CONTACTS_DESC')) {
     define('_MANAGE_CONTACTS_DESC', 'Contacts management');
 }
@@ -2277,61 +2263,6 @@ if (!defined('_CONTACT_ALREADY_CREATED_INFORMATION')) {
     define('_CONTACT_ALREADY_CREATED_INFORMATION', '(for information)');
 }
 
-if (!defined('_CONTACT_PURPOSES_LIST')) {
-    define('_CONTACT_PURPOSES_LIST', 'Denomination list');
-}
-if (!defined('_DESC_CONTACT_PURPOSES')) {
-    define('_DESC_CONTACT_PURPOSES', 'Denomination');
-}
-if (!defined('_NEW_CONTACT_PURPOSE_ADDED')) {
-    define('_NEW_CONTACT_PURPOSE_ADDED', 'Addition of a new denomination');
-}
-if (!defined('_ALL_CONTACT_PURPOSES')) {
-    define('_ALL_CONTACT_PURPOSES', 'All');
-}
-if (!defined('_CONTACT_PURPOSE')) {
-    define('_CONTACT_PURPOSE', 'Denomination');
-}
-if (!defined('_THIS_CONTACT_PURPOSE')) {
-    define('_THIS_CONTACT_PURPOSE', 'This denomination');
-}
-if (!defined('_CONTACT_PURPOSE_MISSING')) {
-    define('_CONTACT_PURPOSE_MISSING', 'Denomination is missing');
-}
-if (!defined('_CONTACT_PURPOSES')) {
-    define('_CONTACT_PURPOSES', 'naming(s)');
-}
-if (!defined('_A_CONTACT_PURPOSE')) {
-    define('_A_CONTACT_PURPOSE', 'a naming');
-}
-if (!defined('_NEW_CONTACT_PURPOSE')) {
-    define('_NEW_CONTACT_PURPOSE', 'New denomination');
-}
-if (!defined('_CONTACT_PURPOSE_MODIF')) {
-    define('_CONTACT_PURPOSE_MODIF', 'Denomination modification');
-}
-if (!defined('_ID_CONTACT_PURPOSE_PB')) {
-    define('_ID_CONTACT_PURPOSE_PB', 'There is an issue with a denomination ID');
-}
-if (!defined('_THE_CONTACT_PURPOSE')) {
-    define('_THE_CONTACT_PURPOSE', 'The denomination');
-}
-if (!defined('_CONTACT_PURPOSE_DEL')) {
-    define('_CONTACT_PURPOSE_DEL', 'Deletion of a denomination');
-}
-if (!defined('_DELETED_CONTACT_PURPOSE')) {
-    define('_DELETED_CONTACT_PURPOSE', 'Deleted denomination');
-}
-if (!defined('_CONTACT_PURPOSE_REAFFECT')) {
-    define('_CONTACT_PURPOSE_REAFFECT', 'Addresses reallocation');
-}
-if (!defined('_WARNING_MESSAGE_DEL_CONTACT_PURPOSE')) {
-    define('_WARNING_MESSAGE_DEL_CONTACT_PURPOSE', 'Warning :<br> The denomination deletion leads to addresses reallocation to a new denomination.');
-}
-if (!defined('_CONTACT_PURPOSE_WILL_BE_CREATED')) {
-    define('_CONTACT_PURPOSE_WILL_BE_CREATED', "This denomination doesn't exist. It will automatically be created.");
-}
-
 if (!defined('_SEARCH_CONTACTS')) {
     define('_SEARCH_CONTACTS', 'Search a contact');
 }
@@ -2432,9 +2363,6 @@ if (!defined('_THE_ADDRESS')) {
 if (!defined('_MODIFY_ADDRESS')) {
     define('_MODIFY_ADDRESS', 'Address modification');
 }
-if (!defined('_CHOOSE_CONTACT_PURPOSES')) {
-    define('_CHOOSE_CONTACT_PURPOSES', 'Choose a denomination');
-}
 if (!defined('_WEBSITE')) {
     define('_WEBSITE', 'Website');
 }
diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php
index 160dcb886a6..d19c62a1a0a 100755
--- a/apps/maarch_entreprise/lang/fr.php
+++ b/apps/maarch_entreprise/lang/fr.php
@@ -2180,20 +2180,6 @@ if (!defined('_LIMIT_DATE_PROCESS')) {
     define('_LIMIT_DATE_PROCESS', 'Date limite de traitement');
 }
 
-if (!defined('_MANAGE_CONTACT_TYPES_DESC')) {
-    define('_MANAGE_CONTACT_TYPES_DESC', 'Gestion des types de contact');
-}
-if (!defined('_MANAGE_CONTACT_TYPES')) {
-    define('_MANAGE_CONTACT_TYPES', 'Gestion des types de contact <br/>(Niveau 1)');
-}
-
-if (!defined('_MANAGE_CONTACT_PURPOSES_DESC')) {
-    define('_MANAGE_CONTACT_PURPOSES_DESC', 'Gestion des dénominations');
-}
-if (!defined('_MANAGE_CONTACT_PURPOSES')) {
-    define('_MANAGE_CONTACT_PURPOSES', 'Gestion des dénominations <br/>(Niveau 3)');
-}
-
 if (!defined('_MANAGE_CONTACTS_DESC')) {
     define('_MANAGE_CONTACTS_DESC', 'Gestion des contacts');
 }
@@ -2301,61 +2287,6 @@ if (!defined('_CONTACT_ALREADY_CREATED_INFORMATION')) {
     define('_CONTACT_ALREADY_CREATED_INFORMATION', '(pour information)');
 }
 
-if (!defined('_CONTACT_PURPOSES_LIST')) {
-    define('_CONTACT_PURPOSES_LIST', 'Liste des dénominations');
-}
-if (!defined('_DESC_CONTACT_PURPOSES')) {
-    define('_DESC_CONTACT_PURPOSES', 'Dénomination');
-}
-if (!defined('_NEW_CONTACT_PURPOSE_ADDED')) {
-    define('_NEW_CONTACT_PURPOSE_ADDED', "Ajout d'une nouvelle dénomination");
-}
-if (!defined('_ALL_CONTACT_PURPOSES')) {
-    define('_ALL_CONTACT_PURPOSES', 'Toutes');
-}
-if (!defined('_CONTACT_PURPOSE')) {
-    define('_CONTACT_PURPOSE', 'Dénomination');
-}
-if (!defined('_THIS_CONTACT_PURPOSE')) {
-    define('_THIS_CONTACT_PURPOSE', 'Cette dénomination');
-}
-if (!defined('_CONTACT_PURPOSE_MISSING')) {
-    define('_CONTACT_PURPOSE_MISSING', 'Dénomination est manquant');
-}
-if (!defined('_CONTACT_PURPOSES')) {
-    define('_CONTACT_PURPOSES', 'dénomination(s)');
-}
-if (!defined('_A_CONTACT_PURPOSE')) {
-    define('_A_CONTACT_PURPOSE', 'une dénomination');
-}
-if (!defined('_NEW_CONTACT_PURPOSE')) {
-    define('_NEW_CONTACT_PURPOSE', 'Nouvelle dénomination');
-}
-if (!defined('_CONTACT_PURPOSE_MODIF')) {
-    define('_CONTACT_PURPOSE_MODIF', "Modification d'une dénomination");
-}
-if (!defined('_ID_CONTACT_PURPOSE_PB')) {
-    define('_ID_CONTACT_PURPOSE_PB', "Il y a un problème avec l'identifiant d'une dénomination");
-}
-if (!defined('_THE_CONTACT_PURPOSE')) {
-    define('_THE_CONTACT_PURPOSE', 'La dénomination');
-}
-if (!defined('_CONTACT_PURPOSE_DEL')) {
-    define('_CONTACT_PURPOSE_DEL', "Suppression d'une dénomination");
-}
-if (!defined('_DELETED_CONTACT_PURPOSE')) {
-    define('_DELETED_CONTACT_PURPOSE', 'Dénomination supprimée');
-}
-if (!defined('_CONTACT_PURPOSE_REAFFECT')) {
-    define('_CONTACT_PURPOSE_REAFFECT', 'Réaffectation des adresses');
-}
-if (!defined('_WARNING_MESSAGE_DEL_CONTACT_PURPOSE')) {
-    define('_WARNING_MESSAGE_DEL_CONTACT_PURPOSE', "Avertissement : La suppression d'une dénomination entraine la réaffectation des adresses à une nouvelle dénomination.");
-}
-if (!defined('_CONTACT_PURPOSE_WILL_BE_CREATED')) {
-    define('_CONTACT_PURPOSE_WILL_BE_CREATED', "Cette dénomination n'existe pas. Elle sera créée automatiquement.");
-}
-
 if (!defined('_SEARCH_CONTACTS')) {
     define('_SEARCH_CONTACTS', 'Rechercher un contact');
 }
@@ -2456,9 +2387,6 @@ if (!defined('_THE_ADDRESS')) {
 if (!defined('_MODIFY_ADDRESS')) {
     define('_MODIFY_ADDRESS', "Modification de l'adresse");
 }
-if (!defined('_CHOOSE_CONTACT_PURPOSES')) {
-    define('_CHOOSE_CONTACT_PURPOSES', 'Choisissez une dénomination');
-}
 if (!defined('_WEBSITE')) {
     define('_WEBSITE', 'Site internet');
 }
diff --git a/apps/maarch_entreprise/lang/nl.php b/apps/maarch_entreprise/lang/nl.php
index 03b62455603..1ca1e0d6382 100755
--- a/apps/maarch_entreprise/lang/nl.php
+++ b/apps/maarch_entreprise/lang/nl.php
@@ -697,10 +697,6 @@ if (!defined('_VALIDATE_MAIL')) { define('_VALIDATE_MAIL', 'Bevestiging brief');
 if (!defined('_LETTER_INFO')) { define('_LETTER_INFO', 'Informatie over de brief');}
 if (!defined('_DATE_START')) { define('_DATE_START', 'Aankomstdatum');}
 if (!defined('_LIMIT_DATE_PROCESS')) { define('_LIMIT_DATE_PROCESS', 'Verwerkingsdeadline');}
-if (!defined('_MANAGE_CONTACT_TYPES_DESC')) { define('_MANAGE_CONTACT_TYPES_DESC', 'Beheer van de contacttypes');}
-if (!defined('_MANAGE_CONTACT_TYPES')) { define('_MANAGE_CONTACT_TYPES', 'Beheer van de contacttypes<br/>(Niveau 1)');}
-if (!defined('_MANAGE_CONTACT_PURPOSES_DESC')) { define('_MANAGE_CONTACT_PURPOSES_DESC', 'Beheer van de benamingen');}
-if (!defined('_MANAGE_CONTACT_PURPOSES')) { define('_MANAGE_CONTACT_PURPOSES', 'Beheer van de benamingen<br/>(Niveau 3)');}
 if (!defined('_MANAGE_CONTACTS_DESC')) { define('_MANAGE_CONTACTS_DESC', 'Beheer van de contacten');}
 if (!defined('_MANAGE_CONTACTS')) { define('_MANAGE_CONTACTS', 'Beheer van de contacten<br/>(Niveau 2)');}
 if (!defined('_SEE_ALL_ADDRESSES')) { define('_SEE_ALL_ADDRESSES', 'Alle adressen bekijken');}
@@ -731,24 +727,6 @@ if (!defined('_CONTACT_TYPE_REAFFECT')) { define('_CONTACT_TYPE_REAFFECT', 'Cont
 if (!defined('_ALL')) { define('_ALL', 'Alle');}
 if (!defined('_CONTACT_ALREADY_CREATED')) { define('_CONTACT_ALREADY_CREATED', 'Reeds bestaande contacten');}
 if (!defined('_CONTACT_ALREADY_CREATED_INFORMATION')) { define('_CONTACT_ALREADY_CREATED_INFORMATION', '(ter informatie)');}
-if (!defined('_CONTACT_PURPOSES_LIST')) { define('_CONTACT_PURPOSES_LIST', 'Benamingenlijst');}
-if (!defined('_DESC_CONTACT_PURPOSES')) { define('_DESC_CONTACT_PURPOSES', 'Benaming');}
-if (!defined('_NEW_CONTACT_PURPOSE_ADDED')) { define('_NEW_CONTACT_PURPOSE_ADDED', 'Toevoeging van een nieuwe benaming');}
-if (!defined('_ALL_CONTACT_PURPOSES')) { define('_ALL_CONTACT_PURPOSES', 'Alle');}
-if (!defined('_CONTACT_PURPOSE')) { define('_CONTACT_PURPOSE', 'Benaming');}
-if (!defined('_THIS_CONTACT_PURPOSE')) { define('_THIS_CONTACT_PURPOSE', 'Deze benaming');}
-if (!defined('_CONTACT_PURPOSE_MISSING')) { define('_CONTACT_PURPOSE_MISSING', 'Benaming ontbreekt');}
-if (!defined('_CONTACT_PURPOSES')) { define('_CONTACT_PURPOSES', 'benaming(en)');}
-if (!defined('_A_CONTACT_PURPOSE')) { define('_A_CONTACT_PURPOSE', 'een benaming');}
-if (!defined('_NEW_CONTACT_PURPOSE')) { define('_NEW_CONTACT_PURPOSE', 'Nieuwe benaming');}
-if (!defined('_CONTACT_PURPOSE_MODIF')) { define('_CONTACT_PURPOSE_MODIF', 'Wijziging van een benaming');}
-if (!defined('_ID_CONTACT_PURPOSE_PB')) { define('_ID_CONTACT_PURPOSE_PB', 'Er is een probleem met de gebruikersnaam van een benaming');}
-if (!defined('_THE_CONTACT_PURPOSE')) { define('_THE_CONTACT_PURPOSE', 'De benaming');}
-if (!defined('_CONTACT_PURPOSE_DEL')) { define('_CONTACT_PURPOSE_DEL', 'Verwijderen van een benaming');}
-if (!defined('_DELETED_CONTACT_PURPOSE')) { define('_DELETED_CONTACT_PURPOSE', 'Benaming verwijderd');}
-if (!defined('_CONTACT_PURPOSE_REAFFECT')) { define('_CONTACT_PURPOSE_REAFFECT', 'Adressen opnieuw toewijzen');}
-if (!defined('_WARNING_MESSAGE_DEL_CONTACT_PURPOSE')) { define('_WARNING_MESSAGE_DEL_CONTACT_PURPOSE', 'Waarschuwing: Het verwijderen van een benaming leidt tot het opnieuw toewijzen van de adressen aan een nieuwe benaming.');}
-if (!defined('_CONTACT_PURPOSE_WILL_BE_CREATED')) { define('_CONTACT_PURPOSE_WILL_BE_CREATED', 'Deze benaming bestaat niet. Ze zal automatisch aangemaakt worden.');}
 if (!defined('_SEARCH_CONTACTS')) { define('_SEARCH_CONTACTS', 'Een contact zoeken');}
 if (!defined('_YOU_SHOULD_ADD_AN_ADDRESS')) { define('_YOU_SHOULD_ADD_AN_ADDRESS', 'Na bevestiging, een adres aan dit contact toevoegen');}
 if (!defined('_ADDRESSES')) { define('_ADDRESSES', 'adres(sen)');}
@@ -780,7 +758,6 @@ if (!defined('_DEPARTEMENT')) { define('_DEPARTEMENT', 'Afdeling');}
 if (!defined('_ADDITION_ADDRESS')) { define('_ADDITION_ADDRESS', 'Een adres toevoegen');}
 if (!defined('_THE_ADDRESS')) { define('_THE_ADDRESS', 'Het adres');}
 if (!defined('_MODIFY_ADDRESS')) { define('_MODIFY_ADDRESS', 'Het adres wijzigen');}
-if (!defined('_CHOOSE_CONTACT_PURPOSES')) { define('_CHOOSE_CONTACT_PURPOSES', 'Kies een benaming');}
 if (!defined('_WEBSITE')) { define('_WEBSITE', 'Website');}
 if (!defined('_OCCUPANCY')) { define('_OCCUPANCY', 'Nr. app verdieping trap');}
 if (!defined('_ADDRESS_ADDED')) { define('_ADDRESS_ADDED', 'Adres toegevoegd');}
diff --git a/apps/maarch_entreprise/my_contacts/create_address_iframe.php b/apps/maarch_entreprise/my_contacts/create_address_iframe.php
deleted file mode 100755
index 9ab092a86fc..00000000000
--- a/apps/maarch_entreprise/my_contacts/create_address_iframe.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-/*
-*    Copyright 2014 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/>.
-*/
-
-/**
-*
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools2 = new core_tools();
-$core_tools2->load_lang();
-if(!$core_tools2->test_service('my_contacts', 'apps', false)){
-    if(!$core_tools2->test_service('update_contacts', 'apps', false)){
-    	$core_tools2->test_service('my_contacts_menu', 'apps');
-    }
-}
-$core_tools2->load_html();
-$core_tools2->load_header('', true, false);
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR
-    . 'class_request.php';
-
-$request = new request();
-$contact = new contacts_v2();
-$db 	 = new Database();
-
-echo '<div class="error" id="main_error">';
-functions::xecho($_SESSION['error']);
-echo '</div>';
-
-echo '<div class="info" id="main_info">';
-functions::xecho($_SESSION['info']);
-echo '</div>';
-
-
-$query = "SELECT * FROM ".$_SESSION['tablename']['contacts_v2']." WHERE contact_id = ?";
-
-$stmt = $db->query($query, array($_SESSION['contact']['current_contact_id']));
-
-$_SESSION['m_admin']['contact'] = array();
-$line = $stmt->fetchObject();
-$_SESSION['m_admin']['contact']['ID'] = $line->contact_id;
-$_SESSION['m_admin']['contact']['TITLE'] = $request->show_string($line->title);
-$_SESSION['m_admin']['contact']['LASTNAME'] = $request->show_string($line->lastname);
-$_SESSION['m_admin']['contact']['FIRSTNAME'] = $request->show_string($line->firstname);
-$_SESSION['m_admin']['contact']['SOCIETY'] = $request->show_string($line->society);
-$_SESSION['m_admin']['contact']['SOCIETY_SHORT'] = $request->show_string($line->society_short);
-$_SESSION['m_admin']['contact']['FUNCTION'] = $request->show_string($line->function);
-$_SESSION['m_admin']['contact']['OTHER_DATA'] = $request->show_string($line->other_data);
-$_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = $request->show_string($line->is_corporate_person);
-$_SESSION['m_admin']['contact']['CONTACT_TYPE'] = $line->contact_type;
-$_SESSION['m_admin']['contact']['OWNER'] = $line->user_id;
-
-$core_tools2->load_js();
-if (isset($_GET['iframe']) && $_GET['iframe'] == 'fromContactIframe') {
-	$contact->formaddress("add", "", false, "fromContactIframe");
-} else {
-	if ($_SESSION['error'] == '') {
-		unset($_SESSION['m_admin']['address']);
-	}
-	$contact->formaddress("add", "", false, "iframe");
-}
-
-$_SESSION['error'] = '';
-$_SESSION['info'] = '';
-
-?>
-	<script type="text/javascript">
-		resize_frame_contact('address');
-	</script>
-<?php
diff --git a/apps/maarch_entreprise/my_contacts/create_contact_iframe.php b/apps/maarch_entreprise/my_contacts/create_contact_iframe.php
deleted file mode 100755
index 14102a48c0a..00000000000
--- a/apps/maarch_entreprise/my_contacts/create_contact_iframe.php
+++ /dev/null
@@ -1,87 +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   create_contact_iframe
-* @author  dev <dev@maarch.org>
-* @ingroup apps
-*/
-
-$core_tools2 = new core_tools();
-$core_tools2->load_lang();
-$core_tools2->test_admin('my_contacts', 'apps');
-$core_tools2->load_html();
-$core_tools2->load_header('', true, false);
-
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php";
-
-$contact = new contacts_v2();
-
-echo '<div class="error" id="main_error">';
-functions::xecho($_SESSION['error']);
-echo '</div>';
-
-echo '<div class="info" id="main_info">';
-functions::xecho($_SESSION['info']);
-echo '</div>';
-
-if (!empty($_SESSION['error'])) {
-    echo "<script>var main_error = document.getElementById('main_error');if (main_error != null) {main_error.style.display = 'table-cell';}</script>";
-}
-
-if (!empty($_SESSION['info'])) {
-    echo "<script>var main_info = document.getElementById('main_info');if (main_info != null) {main_info.style.display = 'table-cell';}</script>";
-}
-
-$_SESSION['error'] = '';
-$_SESSION['info'] = '';
-
-if ((!isset($_GET['created']) || $_GET['created'] == '') && $_SESSION['error'] <> '') {
-    $_SESSION['m_admin']['contact'] = '';
-}
-
-if (isset($_GET['fromAttachmentContact']) && $_GET['fromAttachmentContact'] == "Y") {
-    $_SESSION['AttachmentContact'] = "1";
-}
-
-if ($_SESSION['AttachmentContact'] != "1") {
-    $_SESSION['transmissionInput']= "";
-}
-
-if (isset($_GET['transmissionInput'])) {
-    $_SESSION['transmissionInput'] = $_GET['transmissionInput'];
-}
-
-$core_tools2->load_js();
-if (isset($_GET['created']) && $_GET['created'] <> '') {
-    $contact->chooseContact(true);
-    echo "<br/><br/><br/>";
-} else {
-    /*$contact->chooseContact(false);
-    echo "<br/><br/><br/>";*/
-}
-$contact->formcontact("add", "", false, true);
-
-$load_js = '<script type="text/javascript">';
-$load_js .= "resize_frame_contact('contact');";
-$load_js .= '</script>';
-
-echo $load_js;
-
-if ($_SESSION['AttachmentContact'] == "1") {
-    $createContactDiv = "create_contact_div_attach";
-} else {
-    $createContactDiv = "show_tab";
-}
-
-if (isset($_GET['created']) && $_GET['created'] <> '') {
-    ?>
-	<script type="text/javascript">
-		set_new_contact_address("<?php echo $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=get_last_contact_address'; ?>", "<?php functions::xecho($createContactDiv); ?>", "true", "<?php echo $_SESSION['transmissionInput']; ?>");
-		simpleAjax("<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&page=unsetAttachmentContact' ; ?>");
-	</script>
-<?php
-
-}
diff --git a/apps/maarch_entreprise/my_contacts/getContacts.php b/apps/maarch_entreprise/my_contacts/getContacts.php
deleted file mode 100755
index 5f513aa34d2..00000000000
--- a/apps/maarch_entreprise/my_contacts/getContacts.php
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-
-/*
-*    Copyright 2014-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/>.
-*/
-
-/**
-*
-*
-* @file
-* @author <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup apps
-*/
-
-$db = new Database();
-
-$query = "SELECT contact_id, society, firstname, lastname, is_corporate_person FROM contacts_v2 WHERE enabled = 'Y'";
-$arrayPDO = array();
-
-if ($_REQUEST['type_id'] <> "all") {
-	$query .= " AND contact_type = ? ";
-	$arrayPDO = array($_REQUEST['type_id']);
-}
-
-$query .= " ORDER BY is_corporate_person desc, society, lastname";
-$stmt = $db->query($query, $arrayPDO);
-
-$contact_selected = array();
-
-while($res = $stmt->fetchObject()){
-	$contact = "";
-	if ($res->is_corporate_person == "Y") {
-		$contact = $res->society;
-	} else if ($res->is_corporate_person == "N") {
-		$contact = $res->lastname .' '. $res->firstname;
-	}
-	array_push($contact_selected, array('id' => $res->contact_id, 'name' => $contact ));
-}
-
-$frmStr = '';
-
-$countsContact = count($contact_selected);
-
-if ($countsContact == 0) {
-	$frmStr .= '<option value="">Aucun contact</option>'; 
-} else {
-	if ($_REQUEST['mode'] != "view") {
-		$frmStr .= '<option value="">Choisissez un contact</option>'; 		
-	} else if($_REQUEST['mode'] == "view"){
-		$frmStr .= '<option value="">Voir les contacts</option>'; 
-	}
-}
- 
-for ($cptsContacts = 0;$cptsContacts< $countsContact;$cptsContacts++) {
-	$frmStr .= '<option value="'.functions::xssafe($contact_selected[$cptsContacts]['id']).'"';
-	if ($_REQUEST['mode'] == "view") {
-		$frmStr .= ' disabled ';
-	}
-	$frmStr .= '>'
-	.  functions::xssafe($contact_selected[$cptsContacts]['name'])
-	. '</option>';
-}
-
-echo $frmStr;
-exit;
diff --git a/apps/maarch_entreprise/my_contacts/info_contact_iframe.php b/apps/maarch_entreprise/my_contacts/info_contact_iframe.php
deleted file mode 100755
index 2b875161640..00000000000
--- a/apps/maarch_entreprise/my_contacts/info_contact_iframe.php
+++ /dev/null
@@ -1,301 +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   info_contact_iframe
-* @author  dev <dev@maarch.org>
-* @ingroup apps
-*/
-
-$core_tools2 = new core_tools();
-$core_tools2->test_user();
-$core_tools2->load_lang();
-$core_tools2->load_html();
-$core_tools2->load_header('', true, false);
-
-require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_request.php';
-$request = new request();
-$db = new Database();
-
-echo '<div class="error" id="main_error">';
-functions::xecho($_SESSION['error']);
-echo '</div>';
-
-echo '<div class="info" id="main_info">';
-functions::xecho($_SESSION['info']);
-echo '</div>';
-
-$_SESSION['error'] = '';
-$_SESSION['info'] = '';
-
-if (isset($_GET['editDetailSender']) && empty($_GET['contactid'])) {
-    if ($_GET['sender_recipient_type'] == 'user') {
-        $userInfo = \User\models\UserModel::getById(['id' => $_GET['sender_recipient_id']]);
-        $_GET['contactid'] = $userInfo['user_id'];
-    } elseif ($_GET['sender_recipient_type'] == 'contact') {
-        $addressInfos = \Contact\models\ContactModel::getByAddressId(['addressId' => $_GET['sender_recipient_id']]);
-        $_GET['contactid'] = $addressInfos['contact_id'];
-        $_GET['addressid'] = $_GET['sender_recipient_id'];
-    }
-}
-
-if (isset($_GET['contactid']) && $_GET['contactid'] <> '') {
-    $_SESSION['contact']['current_contact_id'] = $id;
-} elseif ($_SESSION['contact']['current_contact_id'] <> '') {
-    $_GET['contactid'] = $_SESSION['contact']['current_contact_id'];
-}
-
-if (isset($_GET['fromAttachmentContact']) && $_GET['fromAttachmentContact'] == "Y") {
-    $_SESSION['AttachmentContact'] = "1";
-}
-if (isset($_GET['addressid']) && $_GET['addressid'] <> '') {
-    $_SESSION['contact']['current_address_id'] = $id;
-} elseif ($_SESSION['contact']['current_address_id'] <> '') {
-    $_GET['addressid'] = $_SESSION['contact']['current_address_id'];
-}
-
-if (!isset($_GET['contactid']) || $_GET['contactid'] == '') {
-    echo '<div class="error" id="main_error">';
-    echo _YOU_MUST_SELECT_CONTACT;
-    echo '</div>';
-    exit;
-}
-if (!is_numeric($_GET['contactid'])) {
-    $_REQUEST['id'] = $_GET['contactid'];
-    $from_iframe = true;
-    include_once 'apps/' . $_SESSION['config']['app_id'] . '/user_info.php';
-    exit;
-}
-
-$query = "SELECT * FROM ".$_SESSION['tablename']['contacts_v2']." WHERE contact_id = ?";
-$stmt = $db->query($query, array($_GET['contactid']));
-$line = $stmt->fetchObject();
-
-$_SESSION['m_admin']['contact'] = array();
-$_SESSION['m_admin']['contact']['ID']                  = $line->contact_id;
-$_SESSION['m_admin']['contact']['TITLE']               = $request->show_string($line->title);
-$_SESSION['m_admin']['contact']['LASTNAME']            = $request->show_string($line->lastname);
-$_SESSION['m_admin']['contact']['FIRSTNAME']           = $request->show_string($line->firstname);
-$_SESSION['m_admin']['contact']['SOCIETY']             = $request->show_string($line->society);
-$_SESSION['m_admin']['contact']['SOCIETY_SHORT']       = $request->show_string($line->society_short);
-$_SESSION['m_admin']['contact']['FUNCTION']            = $request->show_string($line->function);
-$_SESSION['m_admin']['contact']['OTHER_DATA']          = $request->show_string($line->other_data);
-$_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = $request->show_string($line->is_corporate_person);
-$_SESSION['m_admin']['contact']['IS_EXTERNAL_CONTACT'] = $request->show_string($line->is_external_contact);
-$_SESSION['m_admin']['contact']['CONTACT_TYPE']        = $line->contact_type;
-$_SESSION['m_admin']['contact']['OWNER']               = $line->user_id;
-
-if (isset($_GET['mode']) && $_GET['mode'] <> '') {
-    $mode = $_GET['mode'];
-} else {
-    $mode = '';
-}
-
-if ($core_tools2->test_admin('update_contacts', 'apps', false) && $mode <> "view") {
-    $_SESSION['contact']['current_contact_id'] = $_GET['contactid'];
-    $_SESSION['contact']['current_address_id'] = $_GET['addressid'];
-    $from_iframe = true;
-    if (isset($_REQUEST['popup'])) {
-        $_SESSION['info_contact_popup'] = "true";
-    } else {
-        $_SESSION['info_contact_popup'] = "false";
-    }
-
-    if (isset($_GET['seeAllAddresses'])) {
-        $core_tools2->load_js();
-        unset($_SESSION['fromContactTree']);
-        include_once 'apps/' . $_SESSION['config']['app_id'] . '/my_contacts/my_contact_up.php';
-    } else {
-        $_GET['id'] = $_GET['addressid'];
-        include_once 'apps/' . $_SESSION['config']['app_id'] . '/my_contacts/update_address_iframe.php';
-    }
-} else {
-    include_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php";
-    include_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_business_app_tools.php";
-    $contact = new contacts_v2();
-
-    $query = "SELECT * FROM ".$_SESSION['tablename']['contact_addresses']." WHERE id = ?";
-    $stmt = $db->query($query, array($_GET['addressid']));
-    $line = $stmt->fetchObject();
-
-    $_SESSION['m_admin']['address'] = array();
-    $_SESSION['m_admin']['address']['ID']                 = $line->id;
-    $_SESSION['m_admin']['address']['CONTACT_ID']         = $line->contact_id;
-    $_SESSION['m_admin']['address']['TITLE']              = $request->show_string($line->title);
-    $_SESSION['m_admin']['address']['LASTNAME']           = $request->show_string($line->lastname);
-    $_SESSION['m_admin']['address']['FIRSTNAME']          = $request->show_string($line->firstname);
-    $_SESSION['m_admin']['address']['FUNCTION']           = $request->show_string($line->function);
-    $_SESSION['m_admin']['address']['OTHER_DATA']         = $request->show_string($line->other_data);
-    $_SESSION['m_admin']['address']['OWNER']              = $line->user_id;
-    $_SESSION['m_admin']['address']['DEPARTEMENT']        = $request->show_string($line->departement);
-    $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $line->contact_purpose_id;
-    $_SESSION['m_admin']['address']['OCCUPANCY']          = $request->show_string($line->occupancy);
-    $_SESSION['m_admin']['address']['ADD_NUM']            = $request->show_string($line->address_num);
-    $_SESSION['m_admin']['address']['ADD_STREET']         = $request->show_string($line->address_street);
-    $_SESSION['m_admin']['address']['ADD_COMP']           = $request->show_string($line->address_complement);
-    $_SESSION['m_admin']['address']['ADD_TOWN']           = $request->show_string($line->address_town);
-    $_SESSION['m_admin']['address']['ADD_CP']             = $request->show_string($line->address_postal_code);
-    $_SESSION['m_admin']['address']['ADD_COUNTRY']        = $request->show_string($line->address_country);
-    $_SESSION['m_admin']['address']['PHONE']              = $request->show_string($line->phone);
-    $_SESSION['m_admin']['address']['MAIL']               = $request->show_string($line->email);
-    $_SESSION['m_admin']['address']['WEBSITE']            = $request->show_string($line->website);
-    $_SESSION['m_admin']['address']['IS_PRIVATE']         = $request->show_string($line->is_private);
-    $_SESSION['m_admin']['address']['SALUTATION_HEADER']  = $request->show_string($line->salutation_header);
-    $_SESSION['m_admin']['address']['SALUTATION_FOOTER']  = $request->show_string($line->salutation_footer);
-    $externalId = (array)json_decode($line->external_id);
-    $_SESSION['m_admin']['address']['M2M_ID'] = $externalId['m2m'];
-
-    $core_tools2->load_js();
-
-    $query = "SELECT * FROM ".$_SESSION['tablename']['contact_communication']." WHERE contact_id = ?";
-    $stmt = $db->query($query, array($line->contact_id));
-
-    $_SESSION['m_admin']['communication'] = array();
-    $contactCommunication = $stmt->fetchObject();
-    $_SESSION['m_admin']['communication']['ID']              = $contactCommunication->id;
-    $_SESSION['m_admin']['communication']['CONTACT_ID']      = $contactCommunication->contact_id;
-    $_SESSION['m_admin']['communication']['TYPE']            = functions::show_string($contactCommunication->type);
-    $_SESSION['m_admin']['communication']['VALUE']           = functions::show_string($contactCommunication->value); ?>
-<div id="inner_content" class="clearfix" align="center" style="padding:0px;width:100% !important;">
-    <div class="block">
-        <?php
-        $contact->get_contact_form();
-    $contact->get_address_form(); ?>
-    </div>
-</div>
-<?php
-}
-
-    if ($_GET['created'] == "editDetail") {
-        ?>
-        <script type="text/javascript">
-        new Ajax.Request('index.php?display=false&dir=my_contacts&page=get_last_contact_address&mode=up',
-        {
-        method:'post',
-        parameters: {},
-        onSuccess: function(answer){
-            eval("response = "+answer.responseText);
-
-            //Page Detail
-            if(window.opener){
-                if (response.rateColor != "") {
-                    window.opener.$j('#contact').css('background-color', response.rateColor);
-                }
-                window.opener.$j('#contact').val(response.contactName);
-                window.opener.$j('#contactid').val(response.contactId);
-                window.opener.$j('#addressid').val(response.addressId);
-                this.close();
-            //Processing Mail
-            } else {
-                if(parent.$j('#exp_contact_id')){
-                    if (response.rateColor != "") {
-                        parent.$j('#exp_contact_id').css('background-color', response.rateColor);
-                    }
-                    parent.$j('#exp_contact_id').html(response.contactName);
-                }
-
-                if(parent.$j('#dest_contact_id')){
-                    if (response.rateColor != "") {
-                        parent.$j('#dest_contact_id').css('background-color', response.rateColor);
-                    }
-                    parent.$j('#dest_contact_id').html(response.contactName);
-                }
-
-                parent.document.getElementById('show_tab').style.display = 'none';
-                parent.document.getElementById('show_tab').setAttribute('module', '');
-            }
-        }       
-        });
-        </script><?php
-        exit;
-    } elseif ($_GET['created'] == "editDetailSender") {
-        ?>
-        <script type="text/javascript">
-        new Ajax.Request('index.php?display=false&dir=my_contacts&page=get_last_contact_address&mode=up',
-        {
-        method:'post',
-        parameters: {},
-        onSuccess: function(answer){
-            eval("response = "+answer.responseText);
-
-            //Page Detail
-            if(window.opener){
-                if (response.rateColor != "") {
-                    window.opener.$j('#sender_recipient').css('background-color', response.rateColor);
-                }
-                window.opener.$j('#sender_recipient').val(response.contactName);
-                this.close();
-            } else {
-                //Processing Mail
-                if(parent.$j('#resourceContact').length){
-                    if (response.rateColor != "") {
-                        parent.$j('#resourceContact').css('background-color', response.rateColor);
-                    }
-                    parent.$j('#resourceContact').html(response.contactName);
-                //Indexation/Validate Mail
-                } else if (parent.$j('#sender_recipient').length){
-                    if (response.rateColor != "") {
-                        parent.$j('#sender_recipient').css('background-color', response.rateColor);
-                    }
-                    parent.$j('#sender_recipient').val(response.contactName);
-                }
-
-                parent.document.getElementById('show_tab').style.display = 'none';
-                parent.document.getElementById('show_tab').setAttribute('module', '');
-            }
-        }       
-        });
-        </script><?php
-        exit;
-    } elseif ($_GET['created'] == "cancelDetail") {
-        ?>
-        <script type="text/javascript">
-        if (window.opener) {
-            this.close();
-        } else {
-            parent.document.getElementById('show_tab').style.display = 'none';
-            parent.document.getElementById('show_tab').setAttribute('module', '');
-        }
-        </script>
-        <?php
-        exit;
-    }
-
-?>
-	<script type="text/javascript">
-		resize_frame_contact('contact');
-	</script>
-<?php
-
-
-if (isset($_SESSION['AttachmentContact']) && $_SESSION['AttachmentContact'] =="1" && $_GET['created'] <> '' && isset($_GET['created'])) {
-    $infoContactDiv = "info_contact_div_attach"; ?>
-	<script>
-		simpleAjax("<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&page=unsetAttachmentContact'; ?>");
-	</script>
-	<?php
-} else {
-        $infoContactDiv = "show_tab";
-    }
-
-if ($_GET['created'] == "open") {
-    ?>
-		<script type="text/javascript">
-			set_new_contact_address("<?php echo $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=get_last_contact_address&mode=up'; ?>", "<?php functions::xecho($infoContactDiv); ?>", "false");
-		</script>
-	<?php
-} elseif (isset($_GET['created']) && $_GET['created'] == 'add') {
-        ?>
-	<script type="text/javascript">
-		set_new_contact_address("<?php echo $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=get_last_contact_address'; ?>", "<?php functions::xecho($infoContactDiv); ?>", "true");
-	</script>
-<?php
-    } elseif (isset($_GET['created']) && $_GET['created'] <> '') {
-        ?>
-	<script type="text/javascript">
-		set_new_contact_address("<?php echo $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=get_last_contact_address&mode=up'; ?>", "<?php functions::xecho($infoContactDiv); ?>", "true");
-	</script>
-<?php
-    }
diff --git a/apps/maarch_entreprise/my_contacts/my_contact_add.php b/apps/maarch_entreprise/my_contacts/my_contact_add.php
deleted file mode 100755
index a541fe28a10..00000000000
--- a/apps/maarch_entreprise/my_contacts/my_contact_add.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/**
-* File : my_contact_add.php
-*
-* Add contact form
-*
-* @package Maarch LetterBox 2.3
-* @version 2.0
-* @since 10/2007
-* @license GPL
-* @author  Claire Figueras  <dev@maarch.org>
-*/
-
-$core_tools2 = new core_tools();
-//here we loading the lang vars
-$core_tools2->load_lang();
-if(!$core_tools2->test_service('my_contacts', 'apps', false)){
-	$core_tools2->test_service('my_contacts_menu', 'apps');
-}
-/****************Management of the location bar  ************/
-$init = false;
-if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-{
-    $init = true;
-}
-$level = "";
-if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-{
-    $level = $_REQUEST['level'];
-}
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=my_contact_add&dir=my_contacts';
-$page_label = _ADDITION;
-$page_id = "my_contact_add";
-$core_tools2->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-/***********************************************************/
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$contact = new contacts_v2();
-echo '<h1></h1>';
-echo '<div style="margin-top:10px;">';
-$contact->formcontact("add", '', false);
-echo '</div>';
-?>
diff --git a/apps/maarch_entreprise/my_contacts/my_contact_del.php b/apps/maarch_entreprise/my_contacts/my_contact_del.php
deleted file mode 100755
index 4185facdb78..00000000000
--- a/apps/maarch_entreprise/my_contacts/my_contact_del.php
+++ /dev/null
@@ -1,104 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 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  Delete contact
-*
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-if(!$core_tools->test_service('my_contacts', 'apps', false)){
-    $core_tools->test_service('my_contacts_menu', 'apps');
-}
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
- /****************Management of the location bar  ************/
-$init = false;
-if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-{
-    $init = true;
-}
-$level = "";
-if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-{
-    $level = $_REQUEST['level'];
-}
-
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page=my_contact_del&dir=my_contacts';
-$page_label = _DELETION;
-$page_id = "my_contact_del";
-$core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-$func = new functions();
-$db = new Database();
-
-$contact = new contacts_v2();
-
-if(isset($_GET['id']))
-{
-    $s_id = addslashes($func->wash($_GET['id'], "alphanum", _CONTACT));
-}
-else
-{
-    $s_id = "";
-}
-
-if(isset($_REQUEST['valid']))
-{
-        
-    if(!empty($_REQUEST['contact']) && !empty($_REQUEST['address']))
-    {
-        $new_contact = $_REQUEST['contact'];
-        $new_address = $_REQUEST['address'];
-
-        $i=0;
-        $db->query("UPDATE res_letterbox SET exp_contact_id = ?, address_id = ? where exp_contact_id = ?", array($new_contact, $new_address, $s_id));
-        $db->query("UPDATE res_letterbox SET dest_contact_id = ?, address_id = ? where dest_contact_id = ?", array($new_contact, $new_address, $s_id));
-        $db->query("DELETE FROM " . $_SESSION['tablename']['contacts_v2'] . " WHERE contact_id = ?", array($s_id));
-        $db->query("DELETE FROM " . $_SESSION['tablename']['contact_addresses'] . " WHERE contact_id = ?", array($s_id));
-        if($_SESSION['history']['contactdel'])
-        {
-            require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php');
-            $hist = new history();
-            $hist->add($_SESSION['tablename']['contacts_v2'], $s_id,"DEL","contactdel",_CONTACT_DELETED.' : '.$s_id, $_SESSION['config']['databasetype']);
-        }
-        ?>
-        <script type="text/javascript">
-            window.location.href="<?php echo $_SESSION['config']['businessappurl'].'index.php?page=my_contacts&dir=my_contacts&load&order='.functions::xssafe($_REQUEST['order'])."&order_field=".functions::xssafe($_REQUEST['order_field'])."&start=".functions::xssafe($_REQUEST['start'])."&what=".functions::xssafe($_REQUEST['what']);?>";
-        </script>
-        <?php
-
-    } elseif(empty($_REQUEST['contact'])) {
-        $_SESSION['error'] = _NEW_CONTACT.' '._IS_EMPTY.". ". _USE_AUTOCOMPLETION;
-        $contact->delcontact($s_id);
-    } elseif(empty($_REQUEST['address'])) {
-        $_SESSION['error'] = _NEW_ADDRESS.' '._IS_EMPTY.". ". _USE_AUTOCOMPLETION;
-        $contact->delcontact($s_id);
-    }
-} else {
-    $contact->delcontact($s_id, false);
-}
-?>
diff --git a/apps/maarch_entreprise/my_contacts/my_contact_up.php b/apps/maarch_entreprise/my_contacts/my_contact_up.php
deleted file mode 100755
index a7c9a17ed90..00000000000
--- a/apps/maarch_entreprise/my_contacts/my_contact_up.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/**
-* File : my_contact_up.php
-*
-* Form to modify a contact
-*
-* @package Maarch LetterBox 2.3
-* @version 2.0
-* @since 10/2005
-* @license GPL
-* @author  Claire Figueras  <dev@maarch.org>
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-if(!$core_tools->test_service('my_contacts', 'apps', false)){
-    if(!$core_tools->test_service('update_contacts', 'apps', false)){
-        $core_tools->test_service('my_contacts_menu', 'apps');
-    }
-}
-
-require("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_lists.php";
-
-$func = new functions();
-$list2 = new lists(); 
-
-if(isset($_GET['id'])) {
-    $id = addslashes($func->wash($_GET['id'], "alphanum", _THE_CONTACT));
-    $_SESSION['contact']['current_contact_id'] = $id;
-} else if ($_SESSION['contact']['current_contact_id'] <> ''){
-	$id = $_SESSION['contact']['current_contact_id'];
-} else {
-    $id = "";
-}
-
-if (!isset($_REQUEST['letters'])) {
-     /****************Management of the location bar  ************/
-    $init = false;
-    if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-    {
-        $init = true;
-    }
-    $level = "";
-    if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-    {
-        $level = $_REQUEST['level'];
-    }
-    $page_path = $_SESSION['config']['businessappurl'].'index.php?page=my_contact_up&dir=my_contacts';
-    $page_label = _MODIFICATION;
-    $page_id = "my_contact_up";
-    $core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-    /***********************************************************/
-}
-
-?><div id="divList" name="divList"><?php
-
-$contact = new contacts_v2();
-if ($from_iframe) {
-	$contact->formcontact("up",$id, false, true);
-} else {
-	$contact->formcontact("up",$id, false);
-}
-
-$_SESSION['m_admin']['address'] = array();
-
-if ($_SESSION['origin']=='contacts_list') {
-    $_REQUEST['start']='';
-    $_SESSION['origin']='contact_up';
-}
-
-include_once 'apps/' . $_SESSION['config']['app_id'] . '/admin/contacts/contact_addresses/contact_addresses.php';
-
-?> </div>
diff --git a/apps/maarch_entreprise/my_contacts/my_contact_up_db.php b/apps/maarch_entreprise/my_contacts/my_contact_up_db.php
deleted file mode 100755
index c2df97e2512..00000000000
--- a/apps/maarch_entreprise/my_contacts/my_contact_up_db.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
-* File : my_contact_up_db.php
-*
-* Modify the contact in the database after the form
-*
-* @package Maarch LetterBox 2.3
-* @version 2.0
-* @since 10/2005
-* @license GPL
-* @author  Claire Figueras  <dev@maarch.org>
-*/
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-if(!$core_tools->test_service('my_contacts', 'apps', false)){
-    if(!$core_tools->test_service('update_contacts', 'apps', false)){
-    	$core_tools->test_service('my_contacts_menu', 'apps');
-    }
-}
-
-require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php");
-
-$contact = new contacts_v2();
-
-if(isset($_GET['confirm']) &&  $_GET['confirm'] <> ''){
-	$confirm = 'Y';
-	$_POST['mode'] = $_GET['mode'];
-} else {
-	$confirm = 'N';
-}
-
-if(isset($_GET['mycontact']) &&  $_GET['mycontact'] <> ''){
-	$mycontact = $_GET['mycontact'];
-} else {
-	$mycontact = 'Y';
-}
-
-?>
diff --git a/apps/maarch_entreprise/my_contacts/my_contacts.php b/apps/maarch_entreprise/my_contacts/my_contacts.php
deleted file mode 100755
index c7908f2ec54..00000000000
--- a/apps/maarch_entreprise/my_contacts/my_contacts.php
+++ /dev/null
@@ -1,313 +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    Contacts list of the current user
-*
-* @file     my_contacts.php
-* @author   Yves Christian Kpakpo <dev@maarch.org>
-* @date     $date$
-* @version  $Revision$
-* @ingroup  apps
-*/
-
-require_once "core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php";
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
-            ."class".DIRECTORY_SEPARATOR."class_lists.php";
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
-            ."class".DIRECTORY_SEPARATOR."class_contacts_v2.php";
-
-$core_tools = new core_tools();
-$request    = new request();
-$list       = new lists();   
-$contact    = new contacts_v2();
-
- $parameters = '';
- if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) $parameters .= '&order='.$_REQUEST['order'];
- if (isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field'])) $parameters .= '&order_field='.$_REQUEST['order_field'];
- if (isset($_REQUEST['what']) && !empty($_REQUEST['what'])) $parameters .= '&what='.$_REQUEST['what'];
- if (isset($_REQUEST['selectedObject']) && !empty($_REQUEST['selectedObject'])) $parameters .= '&selectedObject='.$_REQUEST['selectedObject'];
- if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) $parameters .= '&start='.$_REQUEST['start'];
- if (isset($_REQUEST['mode']) && !empty($_REQUEST['mode'])) $parameters .= '&mode='.$_REQUEST['mode'];
-
- $_SESSION['origin']="contacts_list";
- unset($_SESSION['fromContactTree']);
-
- if (isset($_REQUEST['load'])) {
-    $_SESSION['m_admin'] = array();
-    if(!$core_tools->test_service('my_contacts', 'apps', false)){
-        $core_tools->test_service('my_contacts_menu', 'apps');
-    }
-
-    /****************Management of the location bar  ************/
-    $init = false;
-    if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true")
-    {
-        $init = true;
-    }
-    $level = "";
-    if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1))
-    {
-        $level = $_REQUEST['level'];
-    }
-    $page_path = $_SESSION['config']['businessappurl'].'index.php?page=my_contacts&dir=my_contacts&load';
-    $page_label = _CONTACTS_LIST;
-    $page_id = "my_contacts";
-    $core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level);
-    /***********************************************************/
-    ?>
-    <div id="inner_content">
-    <?php    
-    //Load list
-    $target = $_SESSION['config']['businessappurl'].'index.php?page=my_contacts&dir=my_contacts'.$parameters;
-    $listContent = $list->loadList($target, true, 'divList', 'false');
-    echo $listContent;
-    ?>
-    </div>
-    <?php
-} else {
-
-    //Table
-    $table = "view_contacts";
-    $select[$table]= array(); 
-    
-    //Fields
-    array_push($select[$table],"contact_id", "is_corporate_person", "contact_type", "society","contact_lastname","contact_firstname", "contact_user_id", "contact_type_label");
-    
-    //Where clause
-    $where_tab = array();
-
-    $arrayPDO = array();
-
-    //From search
-    if (!empty($_SESSION['searching']['where_request']) && $_REQUEST['mode'] == 'search') {
-        $where_tab[] = $_SESSION['searching']['where_request'] . ' (1=1)';
-        $arrayPDO = array_merge($arrayPDO, $_SESSION['searching']['where_request_parameters']);
-    }
-
-    if ($_REQUEST['mode'] <> 'search') {
-        $where_tab[] = "(contact_user_id  = :userId)";
-        $arrayPDO = array_merge($arrayPDO, array(":userId" => $_SESSION['user']['UserId']));
-    }  
-
-    //Filtre alphabetique et champ de recherche
-    $what = $list->getWhatSearch();
-
-
-
-    if (isset($_REQUEST['selectedObject']) && ! empty($_REQUEST['selectedObject'])) {
-        $where_tab[] = " contact_id = :contactId ";
-        $arrayPDO = array_merge($arrayPDO, array(":contactId" => $_REQUEST['selectedObject']));
-    } elseif (!empty($what)) {
-
-        $what = str_replace("  ", "", $_REQUEST['what']);
-        $what_table = explode(" ", $what);
-
-        foreach($what_table as $key => $what_a){
-            $sql_lastname[] = " lower(contact_lastname) LIKE lower(:what_".$key.")";
-            $sql_society[] = " lower(society) LIKE lower(:what_".$key.")";
-            $arrayPDO = array_merge($arrayPDO, array(":what_".$key => $what_a."%"));
-        }
-
-        $where_tab[] = " (" . implode(' OR ', $sql_lastname) 
-                        . "  or " . implode(' OR ', $sql_society) . ") ";
-    }
-    //Build where
-    $where = implode(' and ', $where_tab);
-    
-    //Order
-    $order = $order_field = '';
-    $order = $list->getOrder();
-    $order_field = $list->getOrderField();
-    if (!empty($order_field) && !empty($order)) 
-        $orderstr = "order by ".$order_field." ".$order;
-    else  {
-        $list->setOrder('asc');
-        $list->setOrderField('contact_lastname');
-        $orderstr = "order by contact_lastname, society asc";
-    }
-
-    if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) {
-        $parameters .= '&start='.$_REQUEST['start'];
-    } else {
-        $_REQUEST['start'] = 0;
-    }
-    //Request
-    $tab=$request->PDOselect($select,$where,$arrayPDO,$orderstr,$_SESSION['config']['databasetype'], "default", false, "", "", "", true, false, true, $_REQUEST['start']);
-    
-    //Result array    
-    for ($i=0;$i<count($tab);$i++)
-    {
-        for ($j=0;$j<count($tab[$i]);$j++)
-        {
-            foreach(array_keys($tab[$i][$j]) as $value)
-            {
-                if($tab[$i][$j][$value]=="contact_id")
-                {
-                    $tab[$i][$j]["contact_id"]=$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]= _ID;
-                    $tab[$i][$j]["size"]="5";
-                    $tab[$i][$j]["label_align"]="left";
-                    $tab[$i][$j]["align"]="left";
-                    $tab[$i][$j]["valign"]="bottom";
-                    $tab[$i][$j]["show"]=true;
-                    $tab[$i][$j]["order"]= "contact_id";
-                }
-                if($tab[$i][$j][$value]=="contact_type")
-                {
-                    $tab[$i][$j]["contact_type"]= $tab[$i][$j]['value'];
-                    $tab[$i][$j]["value"]= $contact->get_label_contact($tab[$i][$j]['value'], $_SESSION['tablename']['contact_types']);
-                    $tab[$i][$j]["label"]= _CONTACT_TYPE;
-                    $tab[$i][$j]["size"]="5";
-                    $tab[$i][$j]["label_align"]="left";
-                    $tab[$i][$j]["align"]="left";
-                    $tab[$i][$j]["valign"]="bottom";
-                    $tab[$i][$j]["show"]=true;
-                    $tab[$i][$j]["order"]= "contact_type_label";
-                }
-                if($tab[$i][$j][$value]=="is_corporate_person")
-                {
-                    $tab[$i][$j]['value']= ($tab[$i][$j]['value'] == 'Y')? _YES : _NO;
-                    $tab[$i][$j]["label"]=_IS_CORPORATE_PERSON;
-                    $tab[$i][$j]["size"]="5";
-                    $tab[$i][$j]["label_align"]="center";
-                    $tab[$i][$j]["align"]="center";
-                    $tab[$i][$j]["valign"]="bottom";
-                    $tab[$i][$j]["show"]=true;
-                    $tab[$i][$j]["order"]= "is_corporate_person";
-                }
-                if($tab[$i][$j][$value]=="society")
-                {
-                    $tab[$i][$j]['value']=$request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["society"]=$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]=_STRUCTURE_ORGANISM;
-                    $tab[$i][$j]["size"]="15";
-                    $tab[$i][$j]["label_align"]="left";
-                    $tab[$i][$j]["align"]="left";
-                    $tab[$i][$j]["valign"]="bottom";
-                    $tab[$i][$j]["show"]=true;
-                    $tab[$i][$j]["order"]= "society";
-                }
-                if($tab[$i][$j][$value]=="contact_lastname")
-                {
-                    $tab[$i][$j]['value']=$request->show_string($tab[$i][$j]['value']);
-                    $tab[$i][$j]["contact_lastname"]=$tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]=_LASTNAME;
-                    $tab[$i][$j]["size"]="15";
-                    $tab[$i][$j]["label_align"]="left";
-                    $tab[$i][$j]["align"]="left";
-                    $tab[$i][$j]["valign"]="bottom";
-                    $tab[$i][$j]["show"]=true;
-                    $tab[$i][$j]["order"]= "contact_lastname";
-                }
-                if($tab[$i][$j][$value]=="contact_firstname")
-                {
-                    $tab[$i][$j]["contact_firstname"]= $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]=_FIRSTNAME;
-                    $tab[$i][$j]["size"]="15";
-                    $tab[$i][$j]["label_align"]="left";
-                    $tab[$i][$j]["align"]="left";
-                    $tab[$i][$j]["valign"]="bottom";
-                    $tab[$i][$j]["show"]=true;
-                    $tab[$i][$j]["order"]= "contact_firstname";
-                }
-                if($tab[$i][$j][$value]=="contact_user_id")
-                {
-                    $tab[$i][$j]["contact_user_id"]= $tab[$i][$j]['value'];
-                    $tab[$i][$j]["label"]=_CREATE_BY;
-                    $tab[$i][$j]["size"]="15";
-                    $tab[$i][$j]["label_align"]="left";
-                    $tab[$i][$j]["align"]="left";
-                    $tab[$i][$j]["valign"]="bottom";
-                    $tab[$i][$j]["show"]=true;
-                    $tab[$i][$j]["order"]= "contact_user_id";
-                }
-            }
-        }
-    } 
-
-    //List parameters
-    $paramsTab = array();
-    $paramsTab['bool_modeReturn'] = false;                                              //Desactivation du mode return (vs echo)
-    $paramsTab['pageTitle'] =  _CONTACTS_LIST." : ".$_SESSION['save_list']['full_count'].' '._CONTACTS;           //Titre de la page
-    $paramsTab['urlParameters'] = '&dir=my_contacts';                                   //parametre d'url supplementaire
-    if ($_REQUEST['mode'] == 'search') {
-        $paramsTab['urlParameters'] .= "&mode=search";
-    } 
-    $paramsTab['pagePicto'] = 'users';                                //Image (pictogramme) de la page
-    $paramsTab['bool_sortColumn'] = true;                                               //Affichage Tri
-    $paramsTab['start'] = $_REQUEST['start'];
-    $paramsTab['bool_showSearchTools'] = true;                                          //Afficle le filtre alphabetique et le champ de recherche
-    $paramsTab['searchBoxAutoCompletionUrl'] = $_SESSION['config']['businessappurl']
-                    ."index.php?display=true&page=contacts_v2_list_by_name";            //Script pour l'autocompletion
-    if ($_REQUEST['mode'] <> 'search') {
-        $paramsTab['searchBoxAutoCompletionUrl'] .= "&my_contact=Y";
-    }           
-    $paramsTab['searchBoxAutoCompletionMinChars'] = 2;                                  //Nombre minimum de caractere pour activer l'autocompletion (1 par defaut)
-    $paramsTab['searchBoxAutoCompletionUpdate'] = true;
-
-    // $paramsTab['addButtonLink'] = $_SESSION['config']['businessappurl']
-        // ."index.php?dir=my_contacts&page=my_contact_add";                            //Lien sur le bouton nouveau (1)
-    if ($_REQUEST['mode'] <> 'search') {
-        $paramsTab['bool_showAddButton'] = true;                                            //Affichage du bouton Nouveau
-        $paramsTab['addButtonLabel'] = _CONTACT_ADDITION;                                   //Libell� du bouton Nouveau
-        $paramsTab['addButtonScript'] = "window.top.location='".$_SESSION['config']['businessappurl']
-            ."index.php?dir=my_contacts&page=my_contact_add'";                              //Action sur le bouton nouveau (2)
-    }
-
-    //Action icons array
-    $paramsTab['actionIcons'] = array();
-    //get start
-    $start = $list->getStart();
-    if ($_REQUEST['mode'] <> 'search') {
-        
-        $update = array(
-                "script"        => "window.top.location='".$_SESSION['config']['businessappurl']
-                                        ."index.php?dir=my_contacts&page=my_contact_up&fromMyContactsList&id=@@contact_id@@&what=".$what."&start=".$start."'",
-                "class"         =>  "change",
-                "label"         =>  _MODIFY,
-                "tooltip"       =>  _MODIFY
-                );
-        $delete = array(
-                "href"          => $_SESSION['config']['businessappurl']
-                                    ."index.php?dir=my_contacts&page=my_contact_del&what=".$what."&start=".$start,
-                "class"         =>  "delete",
-                "label"         =>  _DELETE,
-                "tooltip"       =>  _DELETE,
-                "alertText"     =>  _REALLY_DELETE.": @@society@@ @@contact_lastname@@ @@contact_firstname@@ ?"
-                );
-        array_push($paramsTab['actionIcons'], $update);          
-        array_push($paramsTab['actionIcons'], $delete);
-    } else {
-        $view = array(
-                "script"        => "window.top.location='".$_SESSION['config']['businessappurl']
-                                        ."index.php?dir=indexing_searching&page=contacts_view&fromSearchContactsList&id=@@contact_id@@&what=".$what."&start=".$start."'",
-                "class"         =>  "view",
-                "label"         =>  _VIEW,
-                "tooltip"       =>  _VIEW
-                );
-        array_push($paramsTab['actionIcons'], $view);
-    }
-    
-    //Afficher la liste
-    echo '<br/>';
-    $list->showList($tab, $paramsTab, 'contact_id');
-}
\ No newline at end of file
diff --git a/apps/maarch_entreprise/my_contacts/purpose_check.php b/apps/maarch_entreprise/my_contacts/purpose_check.php
deleted file mode 100755
index 6fd257f9b67..00000000000
--- a/apps/maarch_entreprise/my_contacts/purpose_check.php
+++ /dev/null
@@ -1,43 +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/>.
-*/
-
-require_once('core/class/class_core_tools.php');
-
-$db = new Database();
-
-$purpose = $_REQUEST['contact_purpose'];
-$purpose_id = $_REQUEST['contact_purpose_id'];
-
-if ($purpose_id <> "") {
-	$stmt = $db->query("SELECT label FROM contact_purposes WHERE id= ?", array($purpose_id));
-	$res = $stmt->fetchObject();
-	if ($res->label == $purpose) {
-		echo "{status : 0}";  // le user a clique sur la liste en autocompletion
-		exit();
-	} else {
-		echo "{status : 1}"; // le label a été modifié apres autocompletion : on cree la nouvelle denomination
-		exit();
-	}
-} else {
-	echo "{status : 1}"; // nouvelle denomination
-	exit ();
-
-}
\ No newline at end of file
diff --git a/apps/maarch_entreprise/my_contacts/put_in_session.php b/apps/maarch_entreprise/my_contacts/put_in_session.php
deleted file mode 100755
index 2b47f747e27..00000000000
--- a/apps/maarch_entreprise/my_contacts/put_in_session.php
+++ /dev/null
@@ -1,26 +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/>.
-*/
-
-	$_SESSION['contact']['current_contact_id'] = $_REQUEST['contactid'];
-
-    echo '{ 1: 1 }'
-
-?>
\ No newline at end of file
diff --git a/apps/maarch_entreprise/my_contacts/setContactType.php b/apps/maarch_entreprise/my_contacts/setContactType.php
deleted file mode 100755
index ce2db6f7233..00000000000
--- a/apps/maarch_entreprise/my_contacts/setContactType.php
+++ /dev/null
@@ -1,63 +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/>.
-*/
-
-$core = new core_tools();
-$core->test_user();
-
-require_once 'core/class/class_db_pdo.php';
-$db = new Database();
-if ($_POST['contact_target'] == "") {
-    $_POST['contact_target'] = "corporate";
-}
-if ($_POST['can_add_contact'] == "") {
-    $stmt = $db->query("SELECT id, label FROM contact_types WHERE contact_target = ? or contact_target = 'both' or contact_target is null ORDER BY label", array($_POST['contact_target']));
-} else {
-    $stmt = $db->query("SELECT id, label FROM contact_types WHERE can_add_contact = ? AND (contact_target = ? or contact_target = 'both' or contact_target is null) ORDER BY label", array($_POST['can_add_contact'], $_POST['contact_target']));
-}
-
-
-$frmStr = '';
-
-$frmStr .= '<option value="">' . _CHOOSE_CONTACT_TYPES . '</option>';
-
-$iCount = 0;
-
-while($res = $stmt->fetchObject()){
-   	$frmStr .= '<option value="'. functions::xssafe($res->id).'"';
-
-    if(isset($_SESSION['m_admin']['contact']['CONTACT_TYPE']) && $res->id == $_SESSION['m_admin']['contact']['CONTACT_TYPE'] )
-    {
-        $frmStr .= 'selected="selected"';
-    } else if ($iCount == 0) {
-        $frmStr .= 'selected="selected"';
-    }
-
-    $frmStr .= '>';
-       $frmStr .= functions::xssafe($res->label);
-    $frmStr .= '</option>';
-    
-    $iCount++;
-}
-if($stmt->rowCount()==0){
-    echo "false";
-}
-echo $frmStr;
-exit;
diff --git a/apps/maarch_entreprise/my_contacts/update_address_iframe.php b/apps/maarch_entreprise/my_contacts/update_address_iframe.php
deleted file mode 100755
index 937057ade88..00000000000
--- a/apps/maarch_entreprise/my_contacts/update_address_iframe.php
+++ /dev/null
@@ -1,68 +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   update_address_iframe
-* @author  dev <dev@maarch.org>
-* @ingroup apps
-*/
-
-$core_tools2 = new core_tools();
-$core_tools2->load_lang();
-if (!$core_tools2->test_service('my_contacts', 'apps', false)) {
-    if (!$core_tools2->test_service('update_contacts', 'apps', false)) {
-        $core_tools2->test_service('my_contacts_menu', 'apps');
-    }
-}
-$core_tools2->load_html();
-$core_tools2->load_header('', true, false);
-
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php";
-require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR
-    . 'class_request.php';
-
-$request = new request();
-$contact = new contacts_v2();
-
-echo '<div class="error" id="main_error">';
-functions::xecho($_SESSION['error']);
-echo '</div>';
-
-echo '<div class="info" id="main_info">';
-functions::xecho($_SESSION['info']);
-echo '</div>';
-
-$_SESSION['error'] = '';
-$_SESSION['info'] = '';
-
-$core_tools2->load_js();
-$func = new functions();
-
-if (isset($_GET['id'])) {
-    $id = addslashes($func->wash($_GET['id'], "alphanum", _ADDRESS));
-} else {
-    $id = "";
-}
-
-if (isset($_GET['editDetail'])) {
-    $contact->formaddress("up", $id, false, 'editDetail');
-} elseif (isset($_GET['editDetailSender'])) {
-    $contact->formaddress("up", $id, false, 'editDetailSender');
-} else {
-    if (isset($_GET['fromContactIframe'])) {
-        $iframe_txt = "fromContactIframe";
-        $_SESSION['contact']['current_address_id'] = $id;
-    } else {
-        $iframe_txt = "iframe_add_up";
-    }
-        
-    $load_js = '<script type="text/javascript">';
-    $load_js .= "resize_frame_contact('address');";
-    $load_js .= '</script>';
-        
-    $contact->formaddress("up", $id, false, $iframe_txt);
-        
-    echo $load_js;
-}
diff --git a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml
index 7d9633187a9..2b1d85f6c99 100755
--- a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml
+++ b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml
@@ -73,109 +73,6 @@
       <parameter name="page" value="types_up_db"/>
     </requestDefinition>
 
-    <!-- Admin contact -->
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contact_id" >
-      <parameter name="page" value="ajaxLoadDocList"/>
-      <parameter name="admin" value="contacts"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="ajaxDeleteContact" >
-      <parameter name="page" value="ajaxDeleteContact"/>
-      <parameter name="admin" value="contacts"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contactAddressesUpDb" >
-      <parameter name="page" value="contact_addresses_up_db"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="contactAddressDel" >
-      <parameter name="page" value="contact_addresses_del"/>
-      <parameter name="id"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contactAddressDel" >
-      <parameter name="page" value="contact_addresses_del"/>
-    </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="only_id" >
-      <parameter name="page" value="contact_addresses_status"/>
-      <parameter name="id"/>
-    </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="contactAddressUp" >
-      <parameter name="page" value="contact_addresses_up"/>
-      <parameter name="id"/>
-    </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="admin_ajax_search" >
-      <parameter name="page" value="contact_addresses_list_by_name"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="contactPurposesDel" >
-      <parameter name="page" value="contact_purposes_del"/>
-      <parameter name="id"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contactPurposesDel" >
-      <parameter name="page" value="contact_purposes_del"/>
-    </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="admin_ajax_search" >
-      <parameter name="page" value="contact_purposes_list_by_name"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contactPurposesUp" >
-      <parameter name="page" value="contact_purposes_up"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="getTreeChildrenContact" >
-      <parameter name="page" value="get_tree_children_contact"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="contactPurposesDel" >
-      <parameter name="page" value="contact_types_del"/>
-      <parameter name="id"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contactPurposesDel" >
-      <parameter name="page" value="contact_types_del"/>
-    </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="admin_ajax_search" >
-      <parameter name="page" value="contact_types_list_by_name"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contactTypesUp" >
-      <parameter name="page" value="contact_types_up"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="only_id" >
-      <parameter name="page" value="contacts_v2_del"/>
-      <parameter name="id"/>
-    </requestDefinition>
-
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contacts_v2_up_db" >
-      <parameter name="page" value="contacts_v2_up_db"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="only_id" >
-      <parameter name="page" value="contacts_v2_up"/>
-      <parameter name="id"/>
-    </requestDefinition>
-
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="contactConfirm" >
-      <parameter name="page" value="contacts_v2_confirm"/>
-      <parameter name="mycontact"/>
-    </requestDefinition>
-
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="listContactId" >
-      <parameter name="page" value="contacts_v2_list_by_name"/>
-      <parameter name="display" value="true"/>
-      <parameter name="my_contact"/>
-      <parameter name="id"/>
-    </requestDefinition>
-
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="only_id" >
-      <parameter name="page" value="contacts_v2_status"/>
-      <parameter name="id"/>
-    </requestDefinition>
-
     <!-- indexing_searching  -->
     <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="addresses_list" >
       <parameter name="dir" value="indexing_searching"/>
@@ -195,55 +92,16 @@
       <parameter name="display" value="true"/>
       <parameter name="id"/>
     </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="autocomplete_contacts" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="autocomplete_contacts"/>
-      <parameter name="display" value="true"/>
-      <parameter name="Input"/>
-      <parameter name="table"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="autocomplete_contacts_prepare_multi" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="autocomplete_contacts_prepare_multi"/>
-      <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"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
     <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="choose_file" >
       <parameter name="dir" value="indexing_searching"/>
       <parameter name="page" value="choose_file"/>
       <parameter name="display" value="true"/>
     </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="addressid" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="contact_address_view"/>
-      <parameter name="addressid"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contact_check" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="contact_check"/>
-      <parameter name="display" value="true"/>
-      <parameter name="coll_id"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="admin_ajax_search_indexing" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="contacts_v2_list_by_name_filters"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
     <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="indexing_searching_id" >
       <parameter name="dir" value="indexing_searching"/>
       <parameter name="page" value="details"/>
       <parameter name="id"/>
     </requestDefinition>
-    <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="contact_view" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="contacts_view"/>
-      <parameter name="id"/>
-      <parameter name="fromSearchContactsList"/>
-    </requestDefinition>
     <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="document_list_indexing" >
       <parameter name="dir" value="indexing_searching"/>
       <parameter name="page" value="documents_list_mlb_search_adv"/>
@@ -293,12 +151,6 @@
       <parameter name="display" value="true"/>
     </requestDefinition>
 
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="update_process_date" >
-      <parameter name="dir" value="indexing_searching"/>
-      <parameter name="page" value="update_process_date"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-
     <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="manage_query" >
       <parameter name="dir" value="indexing_searching"/>
       <parameter name="page" value="manage_query"/>
@@ -325,11 +177,6 @@
 
     <!-- My contacts -->
 
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="setContactType" >
-      <parameter name="dir" value="my_contacts"/>
-      <parameter name="page" value="setContactType"/>
-    </requestDefinition>
-
     <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="contactid" >
       <parameter name="dir" value="my_contacts"/>
       <parameter name="page" value="put_in_session"/>
diff --git a/apps/maarch_entreprise/xml/IVS/validation_rules.xml b/apps/maarch_entreprise/xml/IVS/validation_rules.xml
index 6a39032e32b..f872bf7358b 100755
--- a/apps/maarch_entreprise/xml/IVS/validation_rules.xml
+++ b/apps/maarch_entreprise/xml/IVS/validation_rules.xml
@@ -33,12 +33,6 @@
       <parameter name="contact_id" type="integer" />
     </validationRule>
 
-    <validationRule name="ajaxDeleteContact" extends="standardForm" mode="error">
-      <parameter name="contactId" type="integer" />
-      <parameter name="replacedAddressId" type="string" />
-      <parameter name="replacedContactId" type="string" />
-    </validationRule>
-
     <validationRule name="admin_types_up_db" extends="standardForm" mode="error">
       <parameter name="Submit" type="string" />
       <parameter name="collection" type="collection_list" />
@@ -111,37 +105,6 @@
       <parameter name="status_id" type="identifier" />
     </validationRule>
 
-    <validationRule name="contactAddressesUpDb" extends="standardForm" mode="error">
-      <parameter name="Submit" type="string" />
-      <parameter name="add_comp" type="string" />
-      <parameter name="comp_data" type="string" />
-      <parameter name="contact_purposes" type="string" />
-      <parameter name="country" type="string" />
-      <parameter name="cp" type="alnum" />
-      <parameter name="departement" type="string" />
-      <parameter name="firstname" type="string" />
-      <parameter name="function" type="string" />
-      <parameter name="is_private" type="YN" />
-      <parameter name="lastname" type="personname" />
-      <parameter name="mail" type="email" />
-      <parameter name="new_id" type="string" />
-      <parameter name="num" type="alnumSpace" />
-      <parameter name="occupancy" type="string" />
-      <parameter name="phone" type="phone" />
-      <parameter name="salutation_footer" type="string" />
-      <parameter name="salutation_header" type="string" />
-      <parameter name="street" type="string" />
-      <parameter name="title" type="identifier" />
-      <parameter name="town" type="string" />
-      <parameter name="website" type="string" />
-      <parameter name="mycontact" type="string" />
-      <parameter name="dir" type="identifier" />
-      <parameter name="m2m_id" type="string" />
-      <parameter name="refMaarch" type="YN" />
-      <parameter name="searchAddress" type="string" />
-      <parameter name="ban_id" type="string" />
-    </validationRule>
-
     <validationRule name="admin_architecture" extends="standardForm" mode="error">
       <parameter name="tree_id" type="integer" />
     </validationRule>
@@ -181,77 +144,12 @@
       <parameter name="coll_id" type="collection_list" />
     </validationRule>
 
-    <validationRule name="contactAddressDel" extends="standardForm" mode="error">
-      <parameter name="id" type="integer" />
-      <parameter name="move" type="string" />
-      <parameter name="delete" type="string" />
-      <parameter name="new_contact_id_reaffect" type="integer" />
-      <parameter name="new_contact_reaffect" type="string" />
-      <parameter name="mycontact" type="YN" />
-    </validationRule>
-
-    <validationRule name="contactAddressUp" extends="standardForm" mode="error">
-      <parameter name="id" type="integer" />
-      <parameter name="mycontact" type="identifier" />
-      <parameter name="fromSearchContacts" type="string" />
-    </validationRule>
-
-    <validationRule name="setContactType" extends="standardForm" mode="error">
-      <parameter name="contact_target" type="identifier" />
-      <parameter name="can_add_contact" type="YN" />
-      <parameter name="dir" type="identifier" />
-    </validationRule>
-
-    <validationRule name="contactPurposesDel" extends="standardForm" mode="error">
-      <parameter name="valid" type="string" />
-      <parameter name="id" type="integer" />
-      <parameter name="new" type="integer" />
-      <parameter name="new_id" type="string" />
-    </validationRule>
-
-    <validationRule name="contactPurposesUp" extends="standardForm" mode="error">
-      <parameter name="ID_contact_purposes" type="integer" />
-      <parameter name="desc_contact_purposes" type="string" />
-      <parameter name="valid" type="string" />
-    </validationRule>
-
-    <validationRule name="contactTypesUp" extends="standardForm" mode="error">
-      <parameter name="ID_contact_types" type="integer" />
-      <parameter name="desc_contact_types" type="string" />
-      <parameter name="contact_target" type="identifier" />
-      <parameter name="contact_creation" type="YN" />
-      <parameter name="valid" type="string" />
-    </validationRule>
-
     <validationRule name="getTreeChildrenContact" extends="standardForm" mode="error">
       <parameter name="branch" type="string" />
       <parameter name="branch_id" type="identifier" />
       <parameter name="tree_id" type="identifier" />
     </validationRule>
 
-    <validationRule name="contacts_v2_up_db" extends="standardForm" mode="error">
-      <parameter name="Submit" type="string" />
-      <parameter name="comp_data" type="string" />
-      <parameter name="contact_type" type="integer" />
-      <parameter name="firstname" type="string" />
-      <parameter name="function" type="string" />
-      <parameter name="is_corporate" type="YN" />
-      <parameter name="is_external" type="YN" />
-      <parameter name="m2m_id" type="string" />
-      <parameter name="lastname" type="personname" />
-      <parameter name="society" type="string" />
-      <parameter name="society_short" type="string" />
-      <parameter name="title" type="string" />
-      <parameter name="dir" type="identifier" />
-      <parameter name="mycontact" type="identifier" />
-      <parameter name="communication_type" type="string" />
-      <parameter name="communication_value" type="string" />
-    </validationRule>
-
-    <validationRule name="contactConfirm" extends="standardForm" mode="error">
-      <parameter name="mycontact" type="string" />
-    </validationRule>
-
     <validationRule name="listContactId" extends="standardForm" mode="error">
       <parameter name="id" type="integer" />
     </validationRule>
@@ -394,18 +292,6 @@
       <parameter name="dir" type="identifier" />
       <parameter name="id" type="integer" />
     </validationRule>
-    
-    <validationRule name="autocomplete_contacts" extends="standardForm" mode="error">  
-      <parameter name="Input" type="string" />
-      <parameter name="table" type="contact_user_list" />
-      <parameter name="dir" type="identifier" />
-      <parameter name="contact_type" type="string" />
-    </validationRule>
-    
-    <validationRule name="autocomplete_contacts_prepare_multi" extends="standardForm" mode="error">  
-      <parameter name="paramsRequest" type="contact_user_list" />
-      <parameter name="dir" type="identifier" />
-    </validationRule>
 
     <validationRule name="ajax_ShowCP" extends="standardForm" mode="error">  
       <parameter name="what" type="safetext" />
@@ -434,15 +320,6 @@
       <parameter name="dir" type="identifier" />
     </validationRule>
 
-    <validationRule name="contact_check" extends="standardForm" mode="error">  
-      <parameter name="address_id" type="string" />
-      <parameter name="category" type="string" />
-      <parameter name="contact_id" type="string" />
-      <parameter name="res_id" type="alnum" />
-      <parameter name="dir" type="identifier" />
-      <parameter name="coll_id" type="collection_list" />
-    </validationRule>
-
     <validationRule name="contact_view" extends="standardForm" mode="error">  
       <parameter name="id" type="integer" />
       <parameter name="fromSearchContactsList" type="boolean" />
@@ -494,13 +371,6 @@
       <parameter name="dir" type="identifier" />
     </validationRule>
 
-    <validationRule name="update_process_date" extends="standardForm" mode="error">  
-      <parameter name="admission_date" type="datefr" />
-      <parameter name="priority_id" type="string" />
-      <parameter name="type_id" type="integer" />
-      <parameter name="dir" type="identifier" />
-    </validationRule>
-
     <validationRule name="search_contacts_result" extends="standardForm" mode="error">  
       <parameter name="contact_type" type="integer" />
       <parameter name="created_by" type="string" />
diff --git a/apps/maarch_entreprise/xml/config.xml.default b/apps/maarch_entreprise/xml/config.xml.default
index 7f27b7d970e..b16963a2d45 100755
--- a/apps/maarch_entreprise/xml/config.xml.default
+++ b/apps/maarch_entreprise/xml/config.xml.default
@@ -31,10 +31,6 @@
         <doctypes_second_level>doctypes_second_level</doctypes_second_level>
         <doctypes_indexes>doctypes_indexes</doctypes_indexes>
         <saved_queries>saved_queries</saved_queries>
-        <contacts_v2>contacts_v2</contacts_v2>
-        <contact_types>contact_types</contact_types>
-        <contact_purposes>contact_purposes</contact_purposes>
-        <contact_addresses>contact_addresses</contact_addresses>
         <tags>tags</tags>
     </TABLENAME>
     <WORKBATCH>
@@ -123,9 +119,6 @@
         <contact_types_del>true</contact_types_del>
         <contact_types_add>true</contact_types_add>
         <contact_types_up>true</contact_types_up>
-        <contact_purposes_del>true</contact_purposes_del>
-        <contact_purposes_add>true</contact_purposes_add>
-        <contact_purposes_up>true</contact_purposes_up>
         <contact_addresses_del>true</contact_addresses_del>
         <contact_addresses_add>true</contact_addresses_add>
         <contact_addresses_up>true</contact_addresses_up>
diff --git a/apps/maarch_entreprise/xml/menu.xml b/apps/maarch_entreprise/xml/menu.xml
deleted file mode 100755
index 0c6e63a36db..00000000000
--- a/apps/maarch_entreprise/xml/menu.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ROOT>
-    <MENU>
-        <id>admin</id>
-        <libconst>_ADMIN</libconst>
-        <url>/administration</url>
-        <style>fa fa-cogs</style>
-        <angular>true</angular>
-    </MENU>
-    <MENU>
-        <id>my_contacts_menu</id>
-        <libconst>_MY_CONTACTS_MENU</libconst>
-        <url>index.php?page=my_contacts&amp;dir=my_contacts&amp;load</url>
-        <style>fa fa-book</style>
-    </MENU>
-    <MENU>
-        <id>create_contacts</id>
-        <libconst>_CREATE_CONTACTS</libconst>
-        <url>index.php?page=contacts_v2</url>
-        <style>fa fa-users</style>
-    </MENU>
-    <MENU>
-        <id>adv_search_mlb</id>
-        <libconst>_ADV_SEARCH_MLB</libconst>
-        <url>index.php?page=search_adv&amp;dir=indexing_searching</url>
-        <style>fa fa-search</style>
-    </MENU>
-    <MENU>
-        <id>search_contacts</id>
-        <libconst>_SEARCH_CONTACTS</libconst>
-        <url>index.php?page=search_contacts&amp;dir=indexing_searching</url>
-        <style>fa fa-search</style>
-    </MENU>
-</ROOT>
diff --git a/core/class/class_core_tools.php b/core/class/class_core_tools.php
index 936be27ba81..4835745c938 100755
--- a/core/class/class_core_tools.php
+++ b/core/class/class_core_tools.php
@@ -1282,25 +1282,6 @@ class core_tools extends functions
                     require $_SESSION['maarchFilesWhiteList']['apps'][$cptM];
                     $found = true;
                     break;
-                } else {
-                    require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_business_app_tools.php';
-                    $app = new business_app_tools();
-                    $path = $app->insert_app_page($this->f_page);
-                    if (
-                        $_SESSION['maarchFilesWhiteList']['apps'][$cptM]
-                            == 'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.$path
-                    ) {
-                        require $_SESSION['maarchFilesWhiteList']['apps'][$cptM];
-                        $found = true;
-                        break;
-                    } elseif (
-                        $_SESSION['maarchFilesWhiteList']['apps'][$cptM]
-                            == $path
-                    ) {
-                        require $_SESSION['maarchFilesWhiteList']['apps'][$cptM];
-                        $found = true;
-                        break;
-                    }
                 }
             }
             if (!$found) {
diff --git a/modules/attachments/README.md b/modules/attachments/README.md
index 6a3989807b3..7bd3094a7ee 100755
--- a/modules/attachments/README.md
+++ b/modules/attachments/README.md
@@ -193,23 +193,6 @@ Par :
 
 	var cat_id = $(category_id).options[$(category_id).selectedIndex].value;
 	if(cat_id != 'attachment') Element.setStyle(contact_id_tr, {display : 'table-row'});
-
-Ajout d'une nouvelle fonction affiche_chrono_reconciliation(), basé sur affiche_chrono()
-    
-    function affiche_chrono_reconciliation(){
-        new Ajax.Request('index.php?display=true&module=attachments&page=get_chrono_attachment',
-        {
-            method:'post',
-            onSuccess: function(answer){
-                eval("response = "+answer.responseText);
-                var chrono_number = $('chrono_number');
-                chrono_number.value=response.chronoNB;
-                chrono_number.setAttribute('readonly','readonly');
-                chrono_number.setAttribute('class','readonly');
-                $('chrono_number_generate').style.display = 'none';
-            }
-        });
-    }
     
 **Modifier le fichier custom/modules/attachments/get_chrono_attachment.php - Ligne 65**
 
diff --git a/modules/attachments/js/functions.js b/modules/attachments/js/functions.js
index 66c5eba422a..6aa60a8a9f5 100755
--- a/modules/attachments/js/functions.js
+++ b/modules/attachments/js/functions.js
@@ -14,87 +14,6 @@ function defineBackDate(delay) {
 	return str_date;
 }
 
-function showOrButtonForAttachment() {
-  if ($("edit").style.display != "none" && $("newTransmissionButton0").style.display != "none") {
-    $("divOr0").style.display = "";
-  } else {
-    $("divOr0").style.display = "none";
-  }
-}
-
-
-function checkBackDate(inputDate) {
-
-  var dataCreationDate;
-  var dateToCheck = inputDate.value;
-
-  if($('dataCreationDate')) {
-    dataCreationDate = $('dataCreationDate').value;
-    var t = dataCreationDate.split(/[- :.]/);
-    var tmpDate = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
-    var d1_dataCreationDate = tmpDate.getTime();
-  }
-
-  if (dateToCheck != "") {
-    var tmpDate = new Date();
-    tmpDate.setFullYear(dateToCheck.substr(6,4));
-    tmpDate.setMonth(dateToCheck.substr(3,2) - 1);
-    tmpDate.setDate(dateToCheck.substr(0,2));
-    tmpDate.setHours(0);
-    tmpDate.setMinutes(0);
-    var d2_dateToCheck = tmpDate.getTime();
-  }
-  if ((d1_dataCreationDate > d2_dateToCheck) && !isNaN(d2_dateToCheck)) {
-    alert("La date de retour doit être supérieure à la date du courrier");
-    inputDate.value = "";
-  }else if(isNaN(d2_dateToCheck) && dateToCheck != ""){
-    alert("Le format de la date de retour est incorrect");
-    inputDate.value = "";
-  }
-
-}
-
-function setRturnForEffectiveDate() {
-  $('effectiveDateStatus').selectedIndex = 1;
-}
-
-function saveContactToSession(target) {
-
-  setTimeout(function() {
-    var transmissionContactidAttach = [];
-    var transmissionAddressidAttach = [];
-    
-    $j('#formAttachment #addAttach1').each(function (index) {
-        if ($j('#formAttachment #addAttach1').find('[name=attachment_types\\[\\]]').eq(index).val() == 'transmission') {
-            var item1 = {
-                "index": index,
-                "val": $j('#formAttachment #addAttach1').find('[name=contactidAttach\\[\\]]').eq(index).val(),
-            };
-            transmissionContactidAttach.push(item1);
-            var item2 = {
-                "index": index,
-                "val": $j('#formAttachment #addAttach1').find('[name=addressidAttach\\[\\]]').eq(index).val(),
-            };
-            transmissionAddressidAttach.push(item2);
-        }        
-    });
-
-    $j.ajax({
-        type: "POST",
-        data: {
-            transmissionContactidAttach : transmissionContactidAttach,
-            transmissionAddressidAttach : transmissionAddressidAttach
-        },
-        url: "index.php?display=true&module=attachments&page=saveTransmissionContact",
-        success: function(msg){
-            
-        }
-    });
-
-  }, 500);
-}
-
-
 function hideEditAndAddButton(editParagraph) {
   $(editParagraph).style.display = "none";
 }
@@ -110,18 +29,6 @@ function hideInput(target) {
 	}
 }
 
-function getTemplatesForSelect(path_to_script, attachment_type, selectToChange)
-{
-  new Ajax.Request(path_to_script,
-    {
-      method:'post',
-      parameters: {attachment_type: attachment_type},
-      onSuccess: function(answer) {
-        $(selectToChange).innerHTML = answer.responseText;
-      }
-    });
-}
-
 function showAttachmentsForm(path, width, height) {
     if(typeof(width)==='undefined'){
         width = '800';
@@ -150,57 +57,6 @@ function showAttachmentsForm(path, width, height) {
     });
 }
 
-function ValidAttachmentsForm(path, form_id, fromAngular) {
-
-    new Ajax.Request(path,
-    {
-        asynchronous: false,
-        method: 'post',
-        parameters: Form.serialize(form_id),
-        encoding: 'UTF-8',
-        onSuccess: function (answer) {
-            eval("response = " + answer.responseText);
-
-            if (response.status == 0) {
-
-                destroyModal('form_attachments');
-
-                if (typeof fromAngular != "undefined") {
-                    if (typeof response.type != "undefined" && response.type == "incoming_mail_attachment") {
-                        window.angularSignatureBookComponent.componentAfterAttach("rightContent");
-                    } else {
-                        window.angularSignatureBookComponent.componentAfterAttach(fromAngular);
-                    }
-                } else {
-                    if ($('viewframe') != undefined) {
-                        var srcViewFrame = $('viewframe').src;
-                        $('viewframe').src = srcViewFrame;
-                    }
-
-                    if (parent.document.getElementById('nb_attach') != undefined) {
-                        var nb_attach = parseInt(parent.document.getElementById('nb_attach').innerHTML);
-                        nb_attach = nb_attach+1;
-                        parent.document.getElementById('nb_attach').innerHTML = nb_attach;
-                    }
-                    if(document.getElementById('iframe_tab')){
-                        if (document.getElementById('iframe_tab').contentWindow.document.getElementById('list_attach') != undefined) {
-                            iframe_attach = document.getElementById('iframe_tab').contentWindow.document.getElementById('list_attach');
-                            iframe_attach.src = iframe_attach.src;
-                        }
-                    }
-
-                    $j("#main_info").html(response.content).show().delay(5000).fadeOut();
-
-                    eval(response.exec_js);
-                }
-            } else {
-                $j("#main_error").css("opacity","1");
-                $j("#main_error").html(response.error).show().delay(5000).fadeOut();
-            }
-        }
-    });
-}
-
 function modifyAttachmentsForm(path, width, height) {
     if(typeof(width)==='undefined'){
         width = '800';
@@ -228,57 +84,6 @@ function modifyAttachmentsForm(path, width, height) {
     });
 }
 
-function setFinalVersion(path) {  
-
-    new Ajax.Request(path,
-    {
-        asynchronous:false,
-        method:'post',
-        encoding: 'UTF-8',                       
-        onSuccess: function(answer){
-            eval("response = "+answer.responseText);
-            if(response.status == 0 || response.status == 1){
-                eval(response.exec_js);
-            } else {
-                alert(response.error);
-            }
-        }
-    });
-}
-
-function loadSelectedContact() {
-    var ContactAndAddress = $('selectContactIdRes').value;
-
-    if (ContactAndAddress == 'mailing') {
-        $j("#contactDiv").hide();
-        $j("#addMailing").show();
-        $j("#newAttachDiv").hide();
-        $j('#contactidAttach').val('mailing');
-        $j('#mailingInfo').slideToggle("slow");
-    } else {
-        if ($j('#mailingInfo').is(':visible')) {
-            $j('#mailingInfo').slideToggle("slow");
-        }
-        $j("#addMailing").hide();
-        $j("#contactDiv").show();
-        $j("#newAttachDiv").show();
-        var value = ContactAndAddress.split("#");
-        $j('#contactidAttach').val(value[0]);
-        $j('#addressidAttach').val(value[1]);
-        $j('#contact_attach').val(value[2]);
-        $j('#contact_attach').focus();
-    }
-    
-    if ($j("#choose_file").css("display") !== "inline-block") {
-        $j("#add").hide();
-        $j("#addMailing").hide();
-    }
-    
-    if ($j("#templateOffice option:selected").val() !== "" && $j("#templateOffice_edit").css("display") == "none") {
-        $j("#templateOffice_edit").css("display", "inline");
-    }
-}
-
 function createModalinAttachmentList(txt, id_mod, height, width, mode_frm){
     // FIX IE 11
     if($j('#leftPanelShowDocumentIframe')){
@@ -422,27 +227,6 @@ function displayInfos(chrono_number, title, contactid, addressid, placeholder, l
     self.close();
 }
 
-function affiche_chrono_reconciliation(){
-    if(document.getElementById('chrono_number_tr').style.display === 'none'){    // In case there is multiple response project but user want to generate a new one, display the chrono number input
-        document.getElementById('chrono_number_tr').style.display = 'table-row';
-        document.getElementById('list_chrono_number_tr').style.display = 'none';
-    }
-
-    new Ajax.Request('index.php?display=true&module=attachments&page=get_chrono_attachment',
-        {
-            method:'post',
-            parameters: 'type_id=attachment',
-            onSuccess: function(answer){
-                eval("response = "+answer.responseText);
-                var chrono_number = $('chrono_number');
-                chrono_number.value=response.chronoNB;
-                chrono_number.setAttribute('readonly','readonly');
-                chrono_number.setAttribute('class','readonly');
-                $('chrono_number_generate').style.display = 'none';
-            }
-        });
-}
-
 function fillHiddenInput(chrono_number){ // Function used to fill the chrono number and contact input when there is more than on response project
     document.getElementById('chrono_number').value = chrono_number;
     var data = document.getElementById('hiddenChronoNumber').value;
@@ -463,54 +247,6 @@ function fillHiddenInput(chrono_number){ // Function used to fill the chrono num
     }
 }
 
-function display_chrono(){
-    var type_id = document.getElementById('attachment_type').options[document.getElementById('attachment_type').selectedIndex];
-    var hiddenInput = document.getElementById('hiddenChronoNumber').value;
-
-    if (type_id.getAttribute('with_chrono') === 'true') {
-        if(hiddenInput === ''){
-            $('chrono_number_tr').setStyle({display: 'table-row'});
-            $('chrono_number_generate').setStyle({display: 'table-row'});
-        }else{
-            $('list_chrono_number_tr').setStyle({display: 'table-row'});
-        }
-    } else {
-        if(hiddenInput === ''){
-            $('chrono_number_tr').setStyle({display: 'none'});
-            $('chrono_number_generate').setStyle({display: 'none'});
-        }else{
-            $('list_chrono_number_tr').setStyle({display: 'none'});
-        }
-    }
-}
-
-function activeOngletAttachement() {
-  $j('#viewframevalid_attachment').css('display', 'inline');
-  $j('#viewframevalid_main').css('display', 'none');
-  $j('#viewframevalid_attachment').addClass('activeOngletAttachement');
-  $j('#viewframevalid_main').removeClass('activeOngletAttachement');
-  $j('#liAttachement').css('background-color', 'white');
-  $j('#liAttachement').css('height', '23px');
-  $j('#liAttachement').css('display', 'inline');
-  if(typeof($j('#liMainDocument')) != 'undefined'){
-    $j('#liMainDocument').css('background-color', 'rgb(197, 197, 197)');
-    $j('#liMainDocument').css('height', '21px');
-  }
-}
-
-function activeOngletMainDocument() {
-  $j('#viewframevalid_attachment').css('display', 'none');
-  $j('#viewframevalid_main').css('display', 'inline');
-  $j('#viewframevalid_attachment').removeClass('activeOngletAttachement');
-  $j('#viewframevalid_main').addClass('activeOngletAttachement');
-  $j('#liAttachement').css('background-color', 'rgb(197, 197, 197)');
-  $j('#liAttachement').css('height', '21px');
-  if(typeof($j('#liMainDocument')) != 'undefined'){
-    $j('#liMainDocument').css('background-color', 'white');
-    $j('#liMainDocument').css('height', '23px');
-  }
-}
-
 function activePjTab(target) {
 
     $j('[id^=PjDocument_],#MainDocument').css('background-color', 'rgb(197, 197, 197)');
@@ -521,345 +257,3 @@ function activePjTab(target) {
     $j('#'+target.id).css('height', '23px');
     $j('#iframe'+target.id).show();
 }
-
-function addNewAttach() {
-
-    //STEP 1 : add content
-    $j("#formAttachment #addAttach1").last().after($j("#formAttachment #addAttach1").first().clone().find("#choose_file").remove().end().clone());
-    
-    //STEP 2 : remove templateOfficeTool
-    $j("#formAttachment .transmissionDiv #templateOfficeTool").hide();
-
-    //STEP 3 : change ids
-    $j("[name=attachment_types\\[\\]]").each(function( index ) {
-        this.id = this.id.replace(/\d+/,'')+index;
-    });
-    $j("[name=chrono_display\\[\\]]").each(function( index ) {
-        this.id = this.id.replace(/\d+/,'')+index;
-    });
-    $j("[name=chrono\\[\\]]").each(function( index ) {
-        this.id = this.id.replace(/\d+/,'')+index;
-    });
-    $j("[name=attachNum\\[\\]]").each(function( index ) {
-        this.value = index;
-        this.id = this.id.replace(/\d+/,'')+index;    
-    });
-    $j("[name=back_date\\[\\]]").each(function( index ) {
-        this.id = this.id.replace(/\d+/,'')+index;
-    });
-    $j("[name=effectiveDateStatus\\[\\]]").each(function( index ) {
-        this.id = this.id.replace(/\d+/,'')+index;
-        $j("#"+this.id).attr("onchange","checkEffectiveDateStatus(this);");
-    });
-    $j("[name=contact_card_attach]").each(function( index ) {
-        this.id = this.id.replace(/\d+/,'')+index;
-        $j('#'+this.id).attr("onclick","showContactInfo(this,$j('[name=contactidAttach\\\\[\\\\]]')["+index+"],$j('[name=addressidAttach\\\\[\\\\]]')["+index+"]);");
-    });
-    $j("[name=contactidAttach\\[\\]]").each(function( index ) {
-        if ($j("#selectContactIdRes option:eq("+index+")").length) {
-            var contact = $j("#selectContactIdRes option:eq("+index+")").val();
-            contactId = contact.split('#');
-            this.value = contactId[0];
-        }
-        this.id = this.id.replace(/\d+/,'')+index;
-    });
-    $j("[name=addressidAttach\\[\\]]").each(function( index ) {
-        if($j("#selectContactIdRes option:eq("+index+")").length) {
-            var contact = $j("#selectContactIdRes option:eq("+index+")").val();
-            contactId = contact.split('#');
-            this.value = contactId[1];
-        }
-        this.id = this.id.replace(/\d+/,'')+index;
-    });
-    $j("[name=contact_attach\\[\\]]").each(function( index ) {
-        if ($j("#selectContactIdRes option:eq("+index+")").length) {
-            $j("#"+this.id).val($j("#selectContactIdRes option:eq("+index+")").html());
-        }
-        $j("#"+this.id).attr("onchange","saveContactToSession(this);");
-        $j("#"+this.id).change();
-        this.id = this.id+index;
-        
-    });
-    $j("[name=templateOffice\\[\\]]").each(function( index ) {
-        this.id = this.id.replace(/\d+/,'')+index;
-        $j("#"+this.id).attr("onchange","showEditButton(this);");
-    });
-
-    $j("[name=templateOffice_edit\\[\\]]").each(function( index ) {
-        var id_split = this.id.replace(/\d+/,'').split('_');
-        this.id = id_split[0]+index+'_'+id_split[1];
-    });
-
-    $j("[name=delAttachButton\\[\\]]").each(function( index ) {
-        this.id = this.id.replace(/\d+/,'')+index;
-        $j("#"+this.id).attr("onclick","delAttach("+index+");");
-
-        if ($j("[name=delAttachButton\\[\\]]").length == 1 || index == 0) {
-            $j("#"+this.id).css("display","none");
-            $j("#"+this.id).prop("disabled",true);
-        } else {
-            $j("#"+this.id).css("display","inline-block");
-            $j("#"+this.id).prop("disabled",false);
-        }
-    });
-
-    //STEP 4 : reset new element
-    $j("#formAttachment .transmissionDiv [name=attachment_types\\[\\]]").last().val('');
-    $j("#formAttachment .transmissionDiv [name=attachment_types\\[\\]]").last().change();
-    $j("#formAttachment .transmissionDiv [name=templateOffice\\[\\]]").last().val('');
-    $j("#formAttachment .transmissionDiv [name=templateOffice\\[\\]]").last().css('display','inline-block');
-    $j("#formAttachment .transmissionDiv [name=templateOffice\\[\\]]").last().prop('disabled',false);
-    $j("#formAttachment .transmissionDiv [name=templateOffice\\[\\]]").last().change();
-    $j("#formAttachment .transmissionDiv [name=chrono_display\\[\\]]").last().val('');
-    $j("#formAttachment .transmissionDiv [name=chrono\\[\\]]").last().val('');
-    $j("#formAttachment .transmissionDiv [name=back_date\\[\\]]").last().val('');
-    if($j("#selectContactIdRes option").length == 0) {
-        $j("#formAttachment .transmissionDiv [name=contact_attach\\[\\]]").last().val('');
-        $j("#formAttachment .transmissionDiv [name=contactidAttach\\[\\]]").last().val('');
-        $j("#formAttachment .transmissionDiv [name=addressidAttach\\[\\]]").last().val('');
-    }
-    $j("#formAttachment .transmissionDiv #newAttachButton").css("visibility","hidden");
-    $j("#formAttachment .transmissionDiv #newAttachButton").prop("disabled",true);
-    $j("#formAttachment .transmissionDiv #newAttachButton").last().css("visibility","visible");
-    $j("#formAttachment .transmissionDiv #newAttachButton").last().addClass("readonly");
-
-    $j("#formAttachment .transmissionDiv #templateOfficeTool #attachment_type_icon").first().attr("onclick","$j('#'+this.id).css('color','#135F7F');$j('#'+this.id).parent().parent().parent().parent().find('#attachment_type_icon2').first().css('color','#666');$j('#'+this.id).parent().parent().parent().parent().find('#templateOffice0').css('display','none');$j('#'+this.id).parent().parent().parent().parent().find('#templateOffice0').prop('disabled',true);$j('#'+this.id).parent().parent().parent().parent().find('#templateOffice0').css('display','none');$j('#'+this.id).parent().parent().parent().parent().find('#choose_file').css('display','inline-block');$j('#'+this.id).parent().parent().parent().parent().find('#choose_file').contents().find('#file').click()");
-    $j("#formAttachment .transmissionDiv #templateOfficeTool #attachment_type_icon2").first().attr("onclick","$j('#'+this.id).css('color','#135F7F');$j('#'+this.id).parent().parent().parent().parent().find('#attachment_type_icon').first().css('color','#666');$j('#'+this.id).parent().parent().parent().parent().find('#templateOffice0').css('display','inline-block');$j('#'+this.id).parent().parent().parent().parent().find('#templateOffice0').prop('disabled',false);$j('#'+this.id).parent().parent().parent().parent().find('#choose_file').css('display','none');");
-
-
-    $j("#formAttachment .transmissionDiv #templateOfficeTool").first().show();
-
-    launch_autocompleter2_contacts_v2("index.php?display=true&dir=indexing_searching&page=autocomplete_contacts", $j("#formAttachment .transmissionDiv [name=contact_attach\\[\\]]").last().attr("id"), "show_contacts_attach", "", $j("#formAttachment .transmissionDiv [name=contactidAttach\\[\\]]").last().attr("id"), $j("#formAttachment .transmissionDiv [name=addressidAttach\\[\\]]").last().attr("id"));
-    launch_autocompleter2_contacts_v2("index.php?display=true&dir=indexing_searching&page=autocomplete_contacts", $j("#formAttachment .transmissionDiv [name=contact_attach\\[\\]]").first().attr("id"), "show_contacts_attach", "", $j("#formAttachment .transmissionDiv [name=contactidAttach\\[\\]]").first().attr("id"), $j("#formAttachment .transmissionDiv [name=addressidAttach\\[\\]]").first().attr("id"));
-}
-
-function delAttach(index) {
-
-    //DELETE DATA IN SESSION
-    $j.ajax({
-        url: 'index.php?display=true&module=attachments&page=ajaxDelAttachment',
-        type: 'POST',
-        dataType: 'JSON',
-        data: {
-            index: index,
-        },
-        success: function (response) {
-            if (response.status == 0) {
-                //alert('ok');
-                $j("#MainDocument").click();
-                $j("#delAttachButton"+index).parent().parent().remove();
-                $j("#PjDocument_"+index).remove();
-                $j("#iframePjDocument_"+index).remove();
-
-                //reset ids
-                $j("[id^=PjDocument_]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                    $j("#"+this.id).html("<span>PJ n°"+(parseInt(index)+1)+"</span>");
-                });
-                $j("[id^=iframePjDocument_]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                });
-                $j("[name=attachment_types\\[\\]]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                });
-                $j("[name=chrono_display\\[\\]]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                });
-                $j("[name=chrono\\[\\]]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                });
-                $j("[name=attachNum\\[\\]]").each(function( index ) {
-                    this.value = index;
-                    this.id = this.id.replace(/\d+/,'')+index;    
-                });
-                $j("[name=back_date\\[\\]]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                });
-                $j("[name=backDateStatus\\[\\]]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                });
-                $j("[name=contact_card_attach]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                    $j('#'+this.id).attr("onclick","showContactInfo(this,$j('[name=contactidAttach\\\\[\\\\]]')["+index+"],$j('[name=addressidAttach\\\\[\\\\]]')["+index+"]);");
-                });
-                $j("[name=contactidAttach\\[\\]]").each(function( index ) {
-                    if ($j("#selectContactIdRes option:eq("+index+")").length) {
-                        var contact = $j("#selectContactIdRes option:eq("+index+")").val();
-                        contactId = contact.split('#');
-                        this.value = contactId[0];
-                    }
-                    this.id = this.id.replace(/\d+/,'')+index;
-                });
-                $j("[name=addressidAttach\\[\\]]").each(function( index ) {
-                    if($j("#selectContactIdRes option:eq("+index+")").length) {
-                        var contact = $j("#selectContactIdRes option:eq("+index+")").val();
-                        contactId = contact.split('#');
-                        this.value = contactId[1];
-                    }
-                    this.id = this.id.replace(/\d+/,'')+index;
-                });
-                $j("[name=contact_attach\\[\\]]").each(function( index ) {
-                    if ($j("#selectContactIdRes option:eq("+index+")").length) {
-                        $j("#"+this.id).val($j("#selectContactIdRes option:eq("+index+")").html());
-                    }
-                    $j("#"+this.id).attr("onchange","saveContactToSession(this);");
-                    $j("#"+this.id).change();
-                    this.id = this.id+index;
-                    
-                });
-                $j("[name=templateOffice\\[\\]]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                    $j("#"+this.id).attr("onchange","showEditButton(this);");
-                });
-
-                $j("[name=templateOffice_edit\\[\\]]").each(function( index ) {
-                    var id_split = this.id.replace(/\d+/,'').split('_');
-                    this.id = id_split[0]+index+'_'+id_split[1];
-                });
-
-                $j("[name=delAttachButton\\[\\]]").each(function( index ) {
-                    this.id = this.id.replace(/\d+/,'')+index;
-                    $j("#"+this.id).attr("onclick","delAttach("+index+");");
-
-                    if ($j("[name=delAttachButton\\[\\]]").length == 1 || index == 0) {
-                        $j("#"+this.id).css("display","none");
-                        $j("#"+this.id).prop("disabled",true);
-                    } else {
-                        $j("#"+this.id).css("display","inline-block");
-                        $j("#"+this.id).prop("disabled",false);
-                    }
-                });
-
-                $j("#formAttachment .transmissionDiv #templateOfficeTool").first().show();
-                $j("#formAttachment .transmissionDiv #newAttachButton").last().prop("disabled",false);
-                $j("#formAttachment .transmissionDiv #newAttachButton").last().css("visibility","visible");
-                $j("#formAttachment .transmissionDiv #newAttachButton").last().removeClass("readonly");
-                
-            }
-        },
-        error: function (error) {
-            alert(error);
-        }
-
-    });
-
-    
-}
-
-function showEditButton(target) {
-
-    var modele_id = $j('#'+target.id).val();
-
-    if (modele_id != '') {
-
-        $j('#'+target.id+'_edit').css("display","inline");
-        $j('#'+target.id).css("width","166px");
-        
-        if ($('not_enabled')) {
-            $('not_enabled').setStyle({display: 'inline'});
-        }
-
-        $j('#'+target.id).parent().parent().find('#choose_file').css("display","none");
-
-        if ($('file_loaded')) {
-            $('file_loaded').setStyle({display: 'none'});
-        }
-    } else {
-        $j('#'+target.id+'_edit').css("display","none");
-        $j('#'+target.id).css("width","206px");
-
-        if ($('not_enabled')) {
-            $('not_enabled').setStyle({display: 'none'});
-        }
-        if ($('file_loaded')) {
-            $('file_loaded').setStyle({display: 'none'});
-        }
-    }
-}
-
-function affiche_chrono(target){
-    var type_id = document.getElementById(target.id).options[document.getElementById(target.id).selectedIndex];
-    var chrono_display = $j(target).parent().parent().find("[name=chrono_display\\[\\]]");
-    var chrono_label = $j(target).parent().parent().find("[name=chrono_label\\[\\]]");
-    var get_chrono_display = $j(target).parent().parent().find("[name=get_chrono_display\\[\\]]");
-    var chrono = $j(target).parent().parent().find("[name=chrono\\[\\]]");
-
-    //FOR MULTI ATTACHMENT
-    var index = '0';
-    var regexIndex = chrono.attr("id").match(/\d+/);
-    if (regexIndex != null) {
-        index = regexIndex[0];
-    }
-
-    //GENERATE CHRONO
-    if (type_id.value == 'transmission' && index != '0') {
-        get_chrono_display.css("display","none"); 
-        chrono_label.css("display","inline"); 
-        chrono_display.css("display","inline"); 
-        var num = $j('[value=transmission]:selected').length;
-        var chr = String.fromCharCode(64 + num);
-        chrono_display.val($j("#chrono0").val()+'.'+chr);
-        chrono.val($j("#chrono0").val()+'.'+chr);
-
-    } else if (type_id.getAttribute('with_chrono') == 'true') {
-        get_chrono_display.css("display","none"); 
-        chrono_label.css("display","inline"); 
-        chrono_display.css("display","inline"); 
-        
-        new Ajax.Request('index.php?display=true&module=attachments&page=get_chrono_attachment',
-        {
-            method:'post',
-            parameters:
-            {
-                index : index,
-                type_id : type_id
-            },
-                onSuccess: function(answer){
-                eval("response = "+answer.responseText);
-                chrono_display.val(response.chronoNB);
-                chrono.val(response.chronoNB);
-            }
-        });
-    } else if (type_id.getAttribute('get_chrono') != '' && type_id.getAttribute('get_chrono') != null) {
-        chrono_display.css("display","none");
-        chrono_display.val('');
-        chrono_label.css("display","inline");
-        get_chrono_display.css("display","inline");
-        chrono.val('');
-        new Ajax.Request('index.php?display=true&module=attachments&page=get_other_chrono_attachment',
-        {
-            method:'post',
-            parameters:
-            {
-                type_id : type_id.value
-            },
-                onSuccess: function(answer){
-                eval("response = "+answer.responseText);
-                get_chrono_display.html(response.chronoList);
-            }
-        });
-    } else {
-        chrono_label.css("display","none");
-        get_chrono_display.css("display","none");
-        chrono_display.css("display","none");
-        chrono_display.val('');
-        chrono.val('');
-    }
-}
-
-function showContactInfo(target,contactTarget,addressTarget) {
-    $j('#info_contact_div_attach').slideToggle("slow",function(){
-        $j('#'+target.name+'_iframe').attr('src','index.php?display=false&dir=my_contacts&page=info_contact_iframe&fromAttachmentContact=Y&seeAllAddresses&contactid='+contactTarget.value+'&addressid='+addressTarget.value);
-    });
-}
-
-function checkEffectiveDateStatus(effectiveDateStatus) {
-    if ($j('#'+effectiveDateStatus.id).val() == 'NO_RTURN') {
-        $j('#'+effectiveDateStatus.id).parent().find('[name=back_date\\[\\]]').val('');
-        $j('#'+effectiveDateStatus.id).parent().find('[name=back_date\\[\\]]').prop('disabled',true);
-        $j('#'+effectiveDateStatus.id).parent().find('[name=back_date\\[\\]]').addClass('readonly');
-    } else {
-        $j('#'+effectiveDateStatus.id).parent().find('[name=back_date\\[\\]]').prop('disabled',false);
-        $j('#'+effectiveDateStatus.id).parent().find('[name=back_date\\[\\]]').removeClass('readonly');
-    }    
-}
diff --git a/modules/attachments/xml/IVS/requests_definitions.xml b/modules/attachments/xml/IVS/requests_definitions.xml
index 3bdb25ee647..bb38be84536 100755
--- a/modules/attachments/xml/IVS/requests_definitions.xml
+++ b/modules/attachments/xml/IVS/requests_definitions.xml
@@ -66,12 +66,6 @@
       <parameter name="page" value="get_other_chrono_attachment"/>
     </requestDefinition>
 
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="setFinalVersion" >
-	  <parameter name="module" type="identifier" />
-	  <parameter name="display" value="true"/>
-      <parameter name="page" value="setFinalVersion"/>
-    </requestDefinition>
-
     <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="view_attachment" >
 	  <parameter name="module" type="identifier" />
 	  <parameter name="display" value="true"/>
@@ -84,4 +78,4 @@
       <parameter name="page" value="view_attachment"/>
     </requestDefinition>
 
-</requestDefinitions>
\ No newline at end of file
+</requestDefinitions>
diff --git a/modules/attachments/xml/IVS/validation_rules.xml b/modules/attachments/xml/IVS/validation_rules.xml
index 033fd42e54f..ea075a9a5f3 100755
--- a/modules/attachments/xml/IVS/validation_rules.xml
+++ b/modules/attachments/xml/IVS/validation_rules.xml
@@ -71,14 +71,6 @@
 		<parameter name="type_id" type="identifier" />
 	</validationRule>
 
-	<validationRule name="setFinalVersion" extends="standardForm" mode="error">
-		<parameter name="module" type="identifier" />
-		<parameter name="fromDetail" type="identifier" />
-		<parameter name="id" type="integer" />
-		<parameter name="page" type="identifier" />
-		<parameter name="relation" type="integer" />
-	</validationRule>
-
 	<validationRule name="view_attachment" extends="standardForm" mode="error">
 		<parameter name="module" type="identifier" />
 		<parameter name="res_id_master" type="integer" />
diff --git a/modules/export_seda/export_seda_list.php b/modules/export_seda/export_seda_list.php
index 4344c523193..48e46714286 100755
--- a/modules/export_seda/export_seda_list.php
+++ b/modules/export_seda/export_seda_list.php
@@ -12,7 +12,6 @@
 */
 require_once 'core/class/class_request.php';
 require_once 'core/class/class_security.php';
-require_once 'apps/'.$_SESSION['config']['app_id'].'/class/class_contacts_v2.php';
 require_once 'core/class/class_manage_status.php';
 require_once 'apps/'.$_SESSION['config']['app_id'].'/class/class_lists.php';
 
@@ -20,7 +19,6 @@ $status_obj = new manage_status();
 $security = new security();
 $core_tools = new core_tools();
 $request = new request();
-$contact = new contacts_v2();
 $list = new lists();
 
 //Include definition fields
@@ -384,7 +382,7 @@ for ($i = 0; $i < $tabI; ++$i) {
                 $tab[$i][$j]['valign'] = 'bottom';
                 $tab[$i][$j]['show'] = false;
                 $tab[$i][$j]['value_export'] = $tab[$i][$j]['value'];
-                $tab[$i][$j]['value'] = $contact->get_contact_information_from_view($_SESSION['mlb_search_current_category_id'], $contact_lastname, $contact_firstname, $contact_society, $user_lastname, $user_firstname);
+//                $tab[$i][$j]['value'] = $contact->get_contact_information_from_view($_SESSION['mlb_search_current_category_id'], $contact_lastname, $contact_firstname, $contact_society, $user_lastname, $user_firstname);
                 $tab[$i][$j]['order'] = false;
             }
             if ($tab[$i][$j][$value] == 'dest_user') {
diff --git a/modules/life_cycle/batch/process_purge.php b/modules/life_cycle/batch/process_purge.php
index c0fcb28c13d..0ead9330d60 100755
--- a/modules/life_cycle/batch/process_purge.php
+++ b/modules/life_cycle/batch/process_purge.php
@@ -482,64 +482,45 @@ while ($GLOBALS['state'] <> "END") {
         /*                          DELETE_CONTACTS_ON_DB                     */
         /*                                                                    */
         /**********************************************************************/
-        case "DELETE_CONTACTS_ON_DB" :
-
-            if ($GLOBALS['CleanContactsMoral'] == "true" || $GLOBALS['CleanContactsNonMoral'] == "true") {
-
-                $GLOBALS['logger']->write('Clean contacts case', 'INFO');
-
-                if ($GLOBALS['CleanContactsMoral'] == "true"){
-                    $GLOBALS['logger']->write('Clean Moral Contacts', 'INFO');
-                    $stmt = Bt_doQuery(
-                        $GLOBALS['db'], 
-                        "SELECT contact_id FROM contacts_v2 WHERE is_corporate_person = 'Y' "
-                    );
-                } else if ($GLOBALS['CleanContactsNonMoral'] == "true"){
-                    $GLOBALS['logger']->write('Clean Non Moral Contacts', 'INFO');
-                     $stmt = Bt_doQuery(
-                        $GLOBALS['db'], 
-                        "SELECT contact_id FROM contacts_v2 WHERE is_corporate_person = 'N' "
-                    );                   
-                }
-
-                while($ContactToClean = $stmt->fetchObject()){
-                    $stmt2 = Bt_doQuery(
-                        $GLOBALS['db'], 
-                        "SELECT count(*) as total FROM res_view_letterbox WHERE contact_id = ? ", 
-                        array($ContactToClean->contact_id)
-                    );
-                    $totalContacts = $stmt2->fetchObject();
-
-                    $stmt3 = Bt_doQuery(
-                        $GLOBALS['db'], 
-                        "SELECT count(*) as total FROM contacts_res WHERE contact_id = ? ", 
-                        array($ContactToClean->contact_id)
-                    );
-                    $totalContactsMulti = $stmt3->fetchObject();
-
-                    if ($totalContacts->total < 1 && $totalContactsMulti->total < 1) {
-
-                        $GLOBALS['logger']->write('Clean Contact ' . $ContactToClean->contact_id, 'DEBUG');
-
-                        Bt_doQuery(
-                            $GLOBALS['db'], 
-                            "DELETE FROM contact_addresses WHERE contact_id = ?", 
-                            array($ContactToClean->contact_id)
-                        );
-
-                        Bt_doQuery(
-                            $GLOBALS['db'], 
-                            "DELETE FROM contacts_v2 WHERE contact_id = ? ", 
-                            array($ContactToClean->contact_id)
-                        );                        
-                    }
-                }
-
-            }
-
-            $state = 'END';
-            break;
-
+//        case "DELETE_CONTACTS_ON_DB" :
+//
+//            if ($GLOBALS['CleanContactsMoral'] == "true" || $GLOBALS['CleanContactsNonMoral'] == "true") {
+//
+//                $GLOBALS['logger']->write('Clean contacts case', 'INFO');
+//
+//                if ($GLOBALS['CleanContactsMoral'] == "true"){
+//                    $GLOBALS['logger']->write('Clean Moral Contacts', 'INFO');
+//                } else if ($GLOBALS['CleanContactsNonMoral'] == "true"){
+//                    $GLOBALS['logger']->write('Clean Non Moral Contacts', 'INFO');
+//                }
+//
+//                while($ContactToClean = $stmt->fetchObject()){
+//
+//                    $totalContactsMulti = $stmt3->fetchObject();
+//
+//                    if ($totalContacts->total < 1 && $totalContactsMulti->total < 1) {
+//
+//                        $GLOBALS['logger']->write('Clean Contact ' . $ContactToClean->contact_id, 'DEBUG');
+//
+//                        Bt_doQuery(
+//                            $GLOBALS['db'],
+//                            "DELETE FROM contact_addresses WHERE contact_id = ?",
+//                            array($ContactToClean->contact_id)
+//                        );
+//
+//                        Bt_doQuery(
+//                            $GLOBALS['db'],
+//                            "DELETE FROM contacts_v2 WHERE contact_id = ? ",
+//                            array($ContactToClean->contact_id)
+//                        );
+//                    }
+//                }
+//
+//            }
+//
+//            $state = 'END';
+//            break;
+//
     }
 
 }
diff --git a/modules/notifications/batch/load_basket_event_stack.php b/modules/notifications/batch/load_basket_event_stack.php
index d039b6ce5ca..0e15938ec0a 100755
--- a/modules/notifications/batch/load_basket_event_stack.php
+++ b/modules/notifications/batch/load_basket_event_stack.php
@@ -244,10 +244,6 @@ try {
         'modules' . DIRECTORY_SEPARATOR . 'templates'
         . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'templates_controler.php'
     );
-    Bt_myInclude(
-        'apps' . DIRECTORY_SEPARATOR . 'maarch_entreprise'
-        . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_contacts_v2.php'
-    );
 
     Bt_myInclude(
         'core' . DIRECTORY_SEPARATOR . 'class'
diff --git a/modules/notifications/batch/load_process_event_stack.php b/modules/notifications/batch/load_process_event_stack.php
index 9e8297880bb..8b0894c3900 100755
--- a/modules/notifications/batch/load_process_event_stack.php
+++ b/modules/notifications/batch/load_process_event_stack.php
@@ -233,10 +233,6 @@ try {
         'modules' . DIRECTORY_SEPARATOR . 'templates'
         . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'templates_controler.php'
     );
-    Bt_myInclude(
-        'apps' . DIRECTORY_SEPARATOR . 'maarch_entreprise'
-        . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_contacts_v2.php'
-    );
 } catch (IncludeFileError $e) {
     $logger->write(
         'Problem with the php include path:' .$e .' '. get_include_path(),
diff --git a/modules/templates/js/functions.js b/modules/templates/js/functions.js
deleted file mode 100755
index 275939bade3..00000000000
--- a/modules/templates/js/functions.js
+++ /dev/null
@@ -1,60 +0,0 @@
-function show_templates(show)
-{
-    var div = $('templates_div');
-    if (div != null) {
-        if (show == true) {
-            div.style.display = 'block';
-        } else {
-            div.style.display = 'none';
-            var list = $('templates');
-            list.selectedIndex = 0;
-        }
-    }
-}
-
-function select_template(path_to_script, attachment_type, mode)
-{
-    
-    if ($j('#'+attachment_type.id).val() != '') {
-        $j('#formAttachment .transmissionDiv #newAttachButton').prop("disabled",false);
-        $j('#formAttachment .transmissionDiv #newAttachButton').removeClass("readonly");
-        
-    } else {
-        $j('#formAttachment .transmissionDiv #newAttachButton').prop("disabled",true);
-        $j('#formAttachment .transmissionDiv #newAttachButton').addClass("readonly");
-    }
-    if (typeof mode == "undefined" || mode == "add") {
-        if ($j('#'+attachment_type.id+' option:selected').attr("width_delay") != '' && $j('#'+attachment_type.id+' option:selected').attr("width_delay") != undefined) {
-            var delay = $j('#'+attachment_type.id+' option:selected').attr("width_delay");
-            var delay_date = defineBackDate(delay);
-            $j('#'+attachment_type.id).parent().parent().find('[name=back_date\\[\\]]').val(delay_date);
-
-        } else {
-            $j('#'+attachment_type.id).parent().parent().find('[name=back_date\\[\\]]').val("");
-        }
-    }
-
-    if ($j('#'+attachment_type.id+' option:selected').val() == "transmission") {
-        $j('#'+attachment_type.id).parent().parent().find('[name=effectiveDateStatus\\[\\]]').css('display','inline-block');
-        $j('#'+attachment_type.id).parent().parent().find('[name=effectiveDateStatus\\[\\]] option').remove();
-        $j('#'+attachment_type.id).parent().parent().find('[name=effectiveDateStatus\\[\\]]').append('<option value="EXP_RTURN">Attente retour</option>');
-        $j('#'+attachment_type.id).parent().parent().find('[name=effectiveDateStatus\\[\\]]').append('<option value="NO_RTURN">Pas de retour</option>');
-        $j('#'+attachment_type.id).parent().parent().find('[name=back_date\\[\\]]').css('width','75px');
-    } else {
-        $j('#'+attachment_type.id).parent().parent().find('[name=effectiveDateStatus\\[\\]]').css('display','none');
-        $j('#'+attachment_type.id).parent().parent().find('[name=effectiveDateStatus\\[\\]] option').remove();
-        $j('#'+attachment_type.id).parent().parent().find('[name=effectiveDateStatus\\[\\]]').append('<option value="A_TRA">A traiter</option>');
-        $j('#'+attachment_type.id).parent().parent().find('[name=back_date\\[\\]]').css('width','inherite');
-    }
-
-    new Ajax.Request(path_to_script,
-    {
-        method:'post',
-        parameters: {attachment_type: $j('#'+attachment_type.id).val()},
-        onSuccess: function(answer){
-            $j('#'+attachment_type.id).parent().parent().find('[name=templateOffice\\[\\]]').html(answer.responseText);
-            $j('#'+attachment_type.id).parent().parent().find('[name=templateOffice\\[\\]]').change();    
-            $j('#'+attachment_type.id).parent().parent().find('[name=contact_attach\\[\\]]').change();
-        }
-    });
-}
diff --git a/sql/data_en.sql b/sql/data_en.sql
index f9f5be28566..0f3b09c522d 100644
--- a/sql/data_en.sql
+++ b/sql/data_en.sql
@@ -762,43 +762,6 @@ INSERT INTO users (user_id, password, firstname, lastname, mail, enabled, change
 DELETE FROM usergroup_content WHERE user_id = 24;
 INSERT INTO usergroup_content (user_id, group_id, role) VALUES (24, 11,'');
 
-------------
--- CONTACTS
-------------
-TRUNCATE TABLE contact_types;
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (100, '1. Companies', 'Y', 'corporate');
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (101, '2. Associations', 'Y', 'both');
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (102, '3. Administrations', 'Y', 'corporate');
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (103, '4. --', 'Y', 'corporate');
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (104, '5. --', 'Y', 'corporate');
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (105, '6. --', 'Y', 'corporate');
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (106, '0. Individual', 'Y', 'no_corporate');
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (107, '7. Banks', 'Y', 'corporate');
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (108, '8. --', 'Y', 'corporate');
-INSERT INTO contact_types (id, label, can_add_contact, contact_target) VALUES (109, 'UNDEFINED', 'N', 'no_corporate');
-select setval('contact_types_id_seq', (select max(id)+1 from contact_types), false);
-TRUNCATE TABLE contact_purposes;
-INSERT INTO contact_purposes (id, label) VALUES (1, 'Headquarters France');
-INSERT INTO contact_purposes (id, label) VALUES (2, 'Sengal subsidiary');
-INSERT INTO contact_purposes (id, label) VALUES (3, 'Main location');
-Select setval('contact_purposes_id_seq', (select max(id)+1 from contact_purposes), false);
-TRUNCATE TABLE contacts_v2;
-INSERT INTO contacts_v2 (contact_id, contact_type, is_corporate_person, society, society_short, firstname, lastname, title, function, other_data, user_id, entity_id, creation_date, update_date, enabled) VALUES (1, 100, 'Y', 'MAARCH', '', '', '', '', '', 'Editeur du logiciel libre Maarch', 'bblier', 'VILLE', '2015-04-24 12:43:54.97424', '2016-07-25 16:28:38.498185', 'Y');
-INSERT INTO contacts_v2 (contact_id, contact_type, is_corporate_person, society, society_short, firstname, lastname, title, function, other_data, user_id, entity_id, creation_date, update_date, enabled) VALUES (2, 102, 'Y', 'Préfecture de Maarch Les Bains', '', '', '', '', '', 'Préfecture de Maarch Les Bains', 'bblier', 'VILLE', '2018-04-18 12:43:54.97424', '2018-04-18 16:28:38.498185', 'Y');
-INSERT INTO contacts_v2 (contact_id, contact_type, is_corporate_person, society, society_short, firstname, lastname, title, function, other_data, user_id, entity_id, creation_date, update_date, enabled) VALUES (3, 100, 'Y', 'ACME', '', '', '', '', '', 'Archivage et Conservation des Mémoires Electroniques', 'bblier', 'VILLE', '2015-04-24 12:43:54.97424', '2016-07-25 16:28:38.498185', 'Y');
-Select setval('contact_v2_id_seq', (select max(contact_id)+1 from contacts_v2), false);
--- Default adresses
-TRUNCATE TABLE contact_addresses;
-INSERT INTO contact_addresses (id, contact_id, contact_purpose_id, departement, firstname, lastname, title, function, occupancy, address_num, address_street, address_complement, address_town, address_postal_code, address_country, phone, email, website, salutation_header, salutation_footer, other_data, user_id, entity_id, is_private, enabled) VALUES (1, 1, 1, '', 'Jean-Louis', 'ERCOLANI', 'title1', 'Directeur Général', '', '11', 'Boulevard du Sud-Est', '', 'MAARCH LES BAINS', '99000', 'France', '', 'jeanlouis.ercolani@maarch.org', 'http://www.maarch.com', '', '', '', 'bblier', 'VILLE', 'N', 'Y');
-INSERT INTO contact_addresses (id, contact_id, contact_purpose_id, departement, firstname, lastname, title, function, occupancy, address_num, address_street, address_complement, address_town, address_postal_code, address_country, phone, email, website, salutation_header, salutation_footer, other_data, user_id, entity_id, is_private, enabled) VALUES (2, 1, 2, '', 'Karim', 'SY', 'title1', 'Administrateur', '', '', 'Sacré Coeur 3', 'Villa 9653 4ème phase', 'DAKAR', '', 'SENEGAL', '', 'karim.sy@maarch.org', 'http://www.maarch.com', '', '', '', 'bblier', 'VILLE', 'N', 'Y');
-INSERT INTO contact_addresses (id, contact_id, contact_purpose_id, departement, firstname, lastname, title, function, occupancy, address_num, address_street, address_complement, address_town, address_postal_code, address_country, phone, email, website, salutation_header, salutation_footer, other_data, user_id, entity_id, is_private, enabled) VALUES (3, 1, 1, '', 'Laurent', 'GIOVANNONI', 'title1', 'Directeur Général Adjoint', NULL, '11', 'Boulevard du Sud-Est', '', 'MAARCH LES BAINS', '99000', 'FRANCE', '', 'laurent.giovannoni@maarch.org', 'http://www.maarch.com', '', '', '', 'bblier', 'COU', 'N', 'Y');
-INSERT INTO contact_addresses (id, contact_id, contact_purpose_id, departement, firstname, lastname, title, function, occupancy, address_num, address_street, address_complement, address_town, address_postal_code, address_country, phone, email, website, salutation_header, salutation_footer, other_data, user_id, entity_id, is_private, enabled, external_id) VALUES (4, 2, 1, '', 'Nicolas', 'MARTIN', 'title1', '', NULL, '13', 'RUE LA PREFECTURE', '', 'MAARCH LES BAINS', '', '', '', '', 'http://www.maarch.com', '', '', '', 'bblier', 'COU', 'N', 'Y', '{"m2m":"org_987654321_DGS_SF"}');
-INSERT INTO contact_addresses (id, contact_id, contact_purpose_id, departement, firstname, lastname, title, function, occupancy, address_num, address_street, address_complement, address_town, address_postal_code, address_country, phone, email, website, salutation_header, salutation_footer, other_data, user_id, entity_id, is_private, enabled) VALUES (5, 3, 1, '', 'Brigitte', 'BERGER', 'title1', 'Directrice Générale', NULL, '25', 'PLACE DES MIMOSAS', '', 'MAARCH LES BAINS', '99000', 'FRANCE', '', 'info@maarch.org', 'http://www.maarch.com', '', '', '', 'bblier', 'COU', 'N', 'Y');
-Select setval('contact_addresses_id_seq', (select max(id)+1 from contact_addresses), false);
--- Default contact_communication
-TRUNCATE TABLE contact_communication;
-INSERT INTO contact_communication (contact_id, type, value) VALUES (2, 'url', 'https://cchaplin:maarch@demo.maarchcourrier.com');
-
 ------------
 --STATUS-
 ------------
diff --git a/src/app/contact/models/ContactModel.php b/src/app/contact/models/ContactModel.php
index c2f231e757d..2266cd98adc 100755
--- a/src/app/contact/models/ContactModel.php
+++ b/src/app/contact/models/ContactModel.php
@@ -15,6 +15,7 @@
 namespace Contact\models;
 
 use Resource\models\ResModel;
+use Resource\models\ResourceContactModel;
 use SrcCore\models\CoreConfigModel;
 use SrcCore\models\DatabaseModel;
 use SrcCore\models\ValidatorModel;
@@ -147,30 +148,10 @@ class ContactModel
         ValidatorModel::notEmpty($aArgs, ['id']);
         ValidatorModel::intVal($aArgs, ['id']);
 
-        $firstCount = ResModel::getOnView([
-            'select'    => ['count(*) as count'],
-            'where'     => ['contact_id = ?'],
-            'data'      => [$aArgs['id']],
-        ]);
-
-        $secondCount = DatabaseModel::select([
-            'select'    => ['count(*) as count'],
-            'table'     => ['contacts_res'],
-            'where'     => ['contact_id = ?'],
-            'data'      => [$aArgs['id']],
-        ]);
+        $count = ResourceContactModel::get(['select' => ['count(1)'], 'where' => ['item_id = ?', 'type= ?'], 'data' => [$aArgs['id'], 'contact']]);
 
-        if ($firstCount[0]['count'] < 1 && $secondCount[0]['count'] < 1) {
-            DatabaseModel::delete([
-                'table' => 'contact_addresses',
-                'where' => ['contact_id = ?'],
-                'data'  => [$aArgs['id']]
-            ]);
-            DatabaseModel::delete([
-                'table' => 'contacts_v2',
-                'where' => ['contact_id = ?'],
-                'data'  => [$aArgs['id']]
-            ]);
+        if ($count[0]['count'] < 1) {
+            ContactModel::delete(['where' => ['id = ?'], 'data' => [$aArgs['id']]]);
         }
     }
 
diff --git a/src/app/resource/models/ResourceListModel.php b/src/app/resource/models/ResourceListModel.php
index a6248e877fc..07f52b25f82 100644
--- a/src/app/resource/models/ResourceListModel.php
+++ b/src/app/resource/models/ResourceListModel.php
@@ -19,61 +19,6 @@ use SrcCore\models\ValidatorModel;
 
 class ResourceListModel
 {
-    public static function get(array $aArgs)
-    {
-        ValidatorModel::notEmpty($aArgs, ['resIds']);
-        ValidatorModel::arrayType($aArgs, ['resIds']);
-
-        $order = 'CASE res_letterbox.res_id ';
-        foreach ($aArgs['resIds'] as $key => $resId) {
-            $order .= "WHEN {$resId} THEN {$key} ";
-        }
-        $order .= 'END';
-
-        $resources = DatabaseModel::select([
-            'select'    => [
-                'res_letterbox.res_id',
-                'res_letterbox.subject',
-                'res_letterbox.creation_date',
-                'res_letterbox.barcode',
-                'res_letterbox.alt_identifier',
-                'res_letterbox.category_id',
-                'res_letterbox.closing_date',
-                'res_letterbox.process_limit_date',
-                'res_letterbox.is_multicontacts',
-                'entities.entity_label as entity_destination',
-                'doctypes.description as doctype_label',
-                'contacts_v2.firstname as contact_firstname',
-                'contacts_v2.lastname as contact_lastname',
-                'contacts_v2.society as contact_society',
-                'users.firstname as user_firstname',
-                'users.lastname as user_lastname',
-                'priorities.color as priority_color',
-                'priorities.label as priority_label',
-                'status.img_filename as status_icon',
-                'status.label_status as status_label',
-                'status.id as status_id',
-                'us.lastname as user_dest_lastname',
-                'us.firstname as user_dest_firstname',
-            ],
-            'table'     => ['res_letterbox', 'entities', 'doctypes', 'contacts_v2', 'users', 'priorities', 'status', 'users us'],
-            'left_join' => [
-                'res_letterbox.destination = entities.entity_id',
-                'res_letterbox.type_id = doctypes.type_id',
-                'res_letterbox.exp_contact_id = contacts_v2.contact_id OR res_letterbox.dest_contact_id = contacts_v2.contact_id',
-                'res_letterbox.exp_user_id = users.user_id OR res_letterbox.dest_user_id = users.user_id',
-                'res_letterbox.priority = priorities.id',
-                'res_letterbox.status = status.id',
-                'res_letterbox.dest_user = us.user_id'
-            ],
-            'where'     => ['res_letterbox.res_id in (?)'],
-            'data'      => [$aArgs['resIds']],
-            'order_by'  => [$order]
-        ]);
-
-        return $resources;
-    }
-
     public static function getOnResource(array $aArgs)
     {
         ValidatorModel::notEmpty($aArgs, ['select']);
-- 
GitLab