diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 17a3a26e7fcb32e46b381228b281f495845c0978..b7a43c0ec03e77051a45afb2a2167ebf9cd26967 100755
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -50,52 +50,52 @@ job_php-7.3:
  only:
    - develop
 
-# job_php-7.2:
-#   image: php:7.2-apache
-#   stage: test
-#   script:
-#     - mkdir -p /opt/maarch/docservers/indexes/{letterbox_coll,attachments_coll,version_attachments_coll}
-#     - mkdir -p /opt/maarch/docservers/{ai,manual,manual_attachments,templates}
-#     - mkdir -p /opt/maarch/docservers/{convert_attachments,convert_attachments_version,convert_mlb}
-#     - mkdir -p /opt/maarch/docservers/{fulltext_attachments,fulltext_attachments_version,fulltext_mlb}
-#     - mkdir -p /opt/maarch/docservers/{thumbnails_attachments,thumbnails_attachments_version,thumbnails_mlb}
-#     - mkdir -p /var/www/html/
-#     - cp -R /builds/maarch/MaarchCourrier/ /var/www/html/
-#     - cd /var/www/html/MaarchCourrier
-#     - mkdir -p /var/www/html/MaarchCourrier
-#     #- curl -sL https://deb.nodesource.com/setup_7.x | bash - 
-#     #- apt-get install -yqq nodejs 
-#     #- npm install npm@latest -g 
-#     #- npm set registry https://registry.npmjs.org/ 
-#     #- npm install
-#     - sed 's/<databaseserver>.*<\/databaseserver>/<databaseserver>postgres<\/databaseserver>/;s/<databasepassword>.*<\/databasepassword>/<databasepassword><\/databasepassword>/;s/<databasename>.*<\/databasename>/<databasename>MaarchCourrier<\/databasename>/;s/<databaseuser>.*<\/databaseuser>/<databaseuser>maarch<\/databaseuser>/' apps/maarch_entreprise/xml/config.xml.default > apps/maarch_entreprise/xml/config.xml
-#     - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
-#     - chmod +x /usr/local/bin/phpunit
-#     - phpunit --coverage-text --colors=never -c phpunit.xml
-#   only:
-#     - develop
+job_php-7.2:
+  image: php:7.2-apache
+  stage: test
+  script:
+    - mkdir -p /opt/maarch/docservers/indexes/{letterbox_coll,attachments_coll,version_attachments_coll}
+    - mkdir -p /opt/maarch/docservers/{ai,manual,manual_attachments,templates}
+    - mkdir -p /opt/maarch/docservers/{convert_attachments,convert_attachments_version,convert_mlb}
+    - mkdir -p /opt/maarch/docservers/{fulltext_attachments,fulltext_attachments_version,fulltext_mlb}
+    - mkdir -p /opt/maarch/docservers/{thumbnails_attachments,thumbnails_attachments_version,thumbnails_mlb}
+    - mkdir -p /var/www/html/
+    - cp -R /builds/maarch/MaarchCourrier/ /var/www/html/
+    - cd /var/www/html/MaarchCourrier
+    - mkdir -p /var/www/html/MaarchCourrier
+    #- curl -sL https://deb.nodesource.com/setup_7.x | bash - 
+    #- apt-get install -yqq nodejs 
+    #- npm install npm@latest -g 
+    #- npm set registry https://registry.npmjs.org/ 
+    #- npm install
+    - sed 's/<databaseserver>.*<\/databaseserver>/<databaseserver>postgres<\/databaseserver>/;s/<databasepassword>.*<\/databasepassword>/<databasepassword><\/databasepassword>/;s/<databasename>.*<\/databasename>/<databasename>MaarchCourrier<\/databasename>/;s/<databaseuser>.*<\/databaseuser>/<databaseuser>maarch<\/databaseuser>/' apps/maarch_entreprise/xml/config.xml.default > apps/maarch_entreprise/xml/config.xml
+    - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
+    - chmod +x /usr/local/bin/phpunit
+    - phpunit --no-coverage
+  only:
+    - develop
 
-# job_php-7.1:
-#   image: php:7.1-apache
-#   stage: test
-#   script:
-#     - mkdir -p /opt/maarch/docservers/indexes/{letterbox_coll,attachments_coll,version_attachments_coll}
-#     - mkdir -p /opt/maarch/docservers/{ai,manual,manual_attachments,templates}
-#     - mkdir -p /opt/maarch/docservers/{convert_attachments,convert_attachments_version,convert_mlb}
-#     - mkdir -p /opt/maarch/docservers/{fulltext_attachments,fulltext_attachments_version,fulltext_mlb}
-#     - mkdir -p /opt/maarch/docservers/{thumbnails_attachments,thumbnails_attachments_version,thumbnails_mlb}
-#     - mkdir -p /var/www/html/
-#     - cp -R /builds/maarch/MaarchCourrier/ /var/www/html/
-#     - cd /var/www/html/MaarchCourrier
-#     - mkdir -p /var/www/html/MaarchCourrier
-#     #- curl -sL https://deb.nodesource.com/setup_7.x | bash - 
-#     #- apt-get install -yqq nodejs 
-#     #- npm install npm@latest -g 
-#     #- npm set registry https://registry.npmjs.org/ 
-#     #- npm install
-#     - sed 's/<databaseserver>.*<\/databaseserver>/<databaseserver>postgres<\/databaseserver>/;s/<databasepassword>.*<\/databasepassword>/<databasepassword><\/databasepassword>/;s/<databasename>.*<\/databasename>/<databasename>MaarchCourrier<\/databasename>/;s/<databaseuser>.*<\/databaseuser>/<databaseuser>maarch<\/databaseuser>/' apps/maarch_entreprise/xml/config.xml.default > apps/maarch_entreprise/xml/config.xml
-#     - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
-#     - chmod +x /usr/local/bin/phpunit
-#     - phpunit --coverage-text --colors=never -c phpunit.xml
-#   only:
-#     - develop
+job_php-7.1:
+  image: php:7.1-apache
+  stage: test
+  script:
+    - mkdir -p /opt/maarch/docservers/indexes/{letterbox_coll,attachments_coll,version_attachments_coll}
+    - mkdir -p /opt/maarch/docservers/{ai,manual,manual_attachments,templates}
+    - mkdir -p /opt/maarch/docservers/{convert_attachments,convert_attachments_version,convert_mlb}
+    - mkdir -p /opt/maarch/docservers/{fulltext_attachments,fulltext_attachments_version,fulltext_mlb}
+    - mkdir -p /opt/maarch/docservers/{thumbnails_attachments,thumbnails_attachments_version,thumbnails_mlb}
+    - mkdir -p /var/www/html/
+    - cp -R /builds/maarch/MaarchCourrier/ /var/www/html/
+    - cd /var/www/html/MaarchCourrier
+    - mkdir -p /var/www/html/MaarchCourrier
+    #- curl -sL https://deb.nodesource.com/setup_7.x | bash - 
+    #- apt-get install -yqq nodejs 
+    #- npm install npm@latest -g 
+    #- npm set registry https://registry.npmjs.org/ 
+    #- npm install
+    - sed 's/<databaseserver>.*<\/databaseserver>/<databaseserver>postgres<\/databaseserver>/;s/<databasepassword>.*<\/databasepassword>/<databasepassword><\/databasepassword>/;s/<databasename>.*<\/databasename>/<databasename>MaarchCourrier<\/databasename>/;s/<databaseuser>.*<\/databaseuser>/<databaseuser>maarch<\/databaseuser>/' apps/maarch_entreprise/xml/config.xml.default > apps/maarch_entreprise/xml/config.xml
+    - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
+    - chmod +x /usr/local/bin/phpunit
+    - phpunit --no-coverage
+  only:
+    - develop
diff --git a/apps/maarch_entreprise/actions/close_mail.php b/apps/maarch_entreprise/actions/close_mail.php
deleted file mode 100755
index a8d77a39cac83b29e1e63e8b8cf9a2d6811b0727..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/close_mail.php
+++ /dev/null
@@ -1,142 +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   Action : simple confirm
-*
-* Open a modal box to confirm a status modification. Used by the core (manage_action.php page).
-*
-* @file
-* @date $date$
-* @version $Revision$
-* @ingroup apps
-*/
-
-/**
-* $confirm  bool false
-*/
-$confirm    = false;
-$etapes     = array('form');
-$frm_width  = '285px';
-$frm_height = 'auto';
-
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    $labelAction = '';
-    if ($id_action <> '') {
-        $resAction   = \Action\models\ActionModel::getById(['id' => $id_action]);
-        $labelAction = functions::show_string($resAction['label_action']);
-    }
-    
-    $values_str = '';
-    if (empty($_SESSION['stockCheckbox'])) {
-        for ($i=0; $i < count($values); $i++) {
-            $values_str .= $values[$i].', ';
-        }
-    } else {
-        for ($i=0; $i < count($_SESSION['stockCheckbox']); $i++) {
-            $values_str .= $_SESSION['stockCheckbox'][$i].', ';
-        }
-    }
-    $values_str = preg_replace('/, $/', '', $values_str);
-  
-    $templates = array();
-    $destination = \Resource\models\ResModel::get(['select' => ['destination'], 'where' => ['res_id in (?)'], 'data' => [explode(", ", $values_str)]]);
-
-    if ($destination <> '') {
-        $aDestination = [];
-        foreach ($destination as $value) {
-            $aDestination[] = $value['destination'];
-        }
-        $templates = \Template\models\TemplateModel::getByEntity(['select' => ['t.*'], 'entities' => $aDestination]);
-    } else {
-        $templates = \Template\models\TemplateModel::get();
-    }
-    $frm_str .='<center style="font-size:15px;">'._ACTION_CONFIRM.'<br/><br/><b>'.$labelAction.' ?</b></center><br/>';
-    if ($_SESSION['current_basket']['id'] != 'IndexingBasket') {
-        $frm_str .='<b>'._PROCESS_NOTES.':</b><br/>';
-        $frm_str .= '<select name="templateNotes" id="templateNotes" style="width:98%;margin-bottom: 10px;background-color: White;border: 1px solid #999;color: #666;text-align: left;" '
-                    . 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
-                    . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-                    . '&module=templates&page=templates_ajax_content_for_notes\');document.getElementById(\'notes\').focus();">';
-        $frm_str .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
-        foreach ($templates as $value) {
-            if ($value['template_type'] == 'TXT' && ($value['template_target'] == 'notes' || $value['template_target'] == '')) {
-                $frm_str .= '<option value="';
-                $frm_str .= $value['template_id'];
-                $frm_str .= '">';
-                $frm_str .= $value['template_label'];
-            }
-            $frm_str .= '</option>';
-        }
-        $frm_str .= '</select><br />';
-
-        $frm_str .= '<textarea placeholder="motif de la clôture (optionnel) ..." style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="document.getElementById(\'note_content_to_users\').value=document.getElementById(\'notes\').value;"></textarea>';
-    }
-    $frm_str .='<div id="form2" style="border:none;">';
-    $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-    $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-    $frm_str .= '<input type="hidden" name="note_content_to_users" id="note_content_to_users" />';
-    $frm_str .='</form>';
-    $frm_str .='</div>';
-
-    $frm_str .='<div align="center">';
-    $frm_str .=' <input type="button" name="redirect_dep" value="'._VALIDATE.'" id="redirect_dep" class="button" onclick="valid_action_form( \'frm_redirect_dep\', \''.$path_manage_action.'\', \''. $id_action.'\', \''.$values_str.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');" />';
-    $frm_str .=' <input type="button" name="cancel" id="cancel" class="button"  value="'._CANCEL.'" onclick="pile_actions.action_pop();actions_status.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>';
-    $frm_str .='</div>';
-    return addslashes($frm_str);
-}
-
-function check_form($form_id, $values)
-{
-    return true;
-}
-
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form)
-{
-    if (empty($values_form) || count($arr_id) < 1) {
-        return false;
-    }
-    
-    $formValues = array();
-    for ($i=0; $i<count($values_form); $i++) {
-        $formValue       = $values_form[$i];
-        $id              = $formValue['ID'];
-        $value           = $formValue['VALUE'];
-        $formValues[$id] = $value;
-    }
-    
-    $_SESSION['action_error'] = '';
-    $result = '';
-
-    foreach ($arr_id as $res_id) {
-        $result .= $res_id.'#';
-        \Resource\models\ResModel::update(['set' => ['closing_date' => 'CURRENT_TIMESTAMP'], 'where' => ['res_id = ?'], 'data' => [$res_id]]);
-        
-        # save note
-        if ($formValues['note_content_to_users'] != '') {
-            $user = \User\models\UserModel::getByLogin(['login' => $_SESSION['user']['UserId'], 'select' => ['id']]);
-            \Note\models\NoteModel::create(['resId' => $res_id, 'user_id' => $user['id'], 'note_text' => $formValues['note_content_to_users']]);
-        }
-
-    }
-
-    return ['result' => $result, 'history_msg' => ''];
-}
diff --git a/apps/maarch_entreprise/actions/close_mail_and_index.php b/apps/maarch_entreprise/actions/close_mail_and_index.php
deleted file mode 100755
index badb9909b4e1b3516af9e1da4ce9d269beb6c627..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/close_mail_and_index.php
+++ /dev/null
@@ -1,65 +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   Action : simple confirm
-*
-* Open a modal box to confirm a status modification. Used by the core (manage_action.php page).
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup apps
-*/
-
-/**
-* $confirm  bool true
-*/
- $confirm = true;
-
-/**
-* $etapes  array Contains only one etap, the status modification
-*/
- $etapes = array('close');
-
-
-function manage_close($arr_id, $history, $id_action, $label_action, $status)
-{
-    $result = '';
-    require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php');
-    require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php');
-    $sec = new security();
-    $db = new Database();
-
-    $ind_coll = $sec->get_ind_collection($_POST['coll_id']);
-
-    for ($i=0; $i<count($arr_id); $i++) {
-        $result .= $arr_id[$i].'#';
-        $db->query("UPDATE res_letterbox SET closing_date = CURRENT_TIMESTAMP WHERE res_id = ?", array($arr_id[$i]));
-    }
-    $_SESSION['indexing']['category_id'] = 'outgoing';
-    return array(
-        'result' => $result,
-        'history_msg' => '',
-        'page_result' => $_SESSION['config']['businessappurl']
-                         . 'index.php?page=view_baskets&module=basket&baskets=IndexingBasket'
-    );
-}
diff --git a/apps/maarch_entreprise/actions/confirm_status.php b/apps/maarch_entreprise/actions/confirm_status.php
deleted file mode 100755
index d53cc7cc31d2a017643a4a68bcc1c6c3761d7fd7..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/confirm_status.php
+++ /dev/null
@@ -1,170 +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   Action : simple confirm
-*
-* Open a modal box to confirm a status modification. Used by the core (manage_action.php page).
-*
-* @file
-* @author Claire Figueras <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup apps
-*/
-
-/**
-* $confirm  bool false
-*/
-$confirm = false;
-$etapes = array('form');
-$frm_width='285px';
-$frm_height = 'auto';
-
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    $res_id=$values[0];
-    $db = new Database();
-    $labelAction = '';
-    if ($id_action <> '') {
-        $stmt = $db->query("select label_action from actions where id = ?", array($id_action));
-        $resAction = $stmt->fetchObject();
-        $labelAction = functions::show_string($resAction->label_action);
-    }
-
-    $values_str = '';
-    if (empty($_SESSION['stockCheckbox'])) {
-        for ($i=0; $i<count($values); $i++) {
-            $values_str .= $values[$i].', ';
-        }
-    } else {
-        for ($i=0; $i<count($_SESSION['stockCheckbox']); $i++) {
-            $values_str .= $_SESSION['stockCheckbox'][$i].', ';
-        }
-    }
-    $values_str = preg_replace('/, $/', '', $values_str);
-
-    require 'modules/templates/class/templates_controler.php';
-    $templatesControler = new templates_controler();
-    $templates = array();
-
-    if (is_numeric($res_id)) {
-        $stmt = $db->query("SELECT destination FROM res_letterbox WHERE res_id = (?)", [$res_id]);
-        $resultDest = $stmt->fetchObject();
-        $destination = $resultDest->destination;
-    } else {
-        $destination = '';
-    }
-
-    if ($destination <> '') {
-        $templates = $templatesControler->getAllTemplatesForProcess($destination);
-    } else {
-        $templates = $templatesControler->getAllTemplatesForSelect();
-    }
-    $frm_str ='<center style="font-size:15px;">'._ACTION_CONFIRM.'<br/><br/><b>'.$labelAction.' ?</b></center><br/>';
-    if ($_SESSION['current_basket']['id'] != 'IndexingBasket') {
-        $frm_str .='<b>'._PROCESS_NOTES.':</b><br/>';
-        $frm_str .= '<select name="templateNotes" id="templateNotes" style="width:98%;margin-bottom: 10px;background-color: White;border: 1px solid #999;color: #666;text-align: left;" '
-            . 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
-            . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-            . '&module=templates&page=templates_ajax_content_for_notes\');document.getElementById(\'notes\').focus();">';
-        $frm_str .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
-        for ($i=0; $i<count($templates); $i++) {
-            if ($templates[$i]['TYPE'] == 'TXT' && ($templates[$i]['TARGET'] == 'notes' || $templates[$i]['TARGET'] == '')) {
-                $frm_str .= '<option value="';
-                $frm_str .= $templates[$i]['ID'];
-                $frm_str .= '">';
-                $frm_str .= $templates[$i]['LABEL'];
-            }
-            $frm_str .= '</option>';
-        }
-        $frm_str .= '</select><br />';
-
-        $frm_str .= '<textarea placeholder="motif de l\'action (optionnel) ..." style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="document.getElementById(\'note_content_to_users\').value=document.getElementById(\'notes\').value;"></textarea>';
-    }
-    $frm_str .='<div id="form2" style="border:none;">';
-    $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-    $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-    $frm_str .= '<input type="hidden" name="note_content_to_users" id="note_content_to_users" />';
-    $frm_str .='</form>';
-    $frm_str .='</div>';
-
-    $frm_str .='<div align="center">';
-    $frm_str .=' <input type="button" name="redirect_dep" value="'._VALIDATE.'" id="redirect_dep" class="button" onclick="valid_action_form( \'frm_redirect_dep\', \''.$path_manage_action.'\', \''. $id_action.'\', \''.$values_str.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');" />';
-    $frm_str .=' <input type="button" name="cancel" id="cancel" class="button"  value="'._CANCEL.'" onclick="pile_actions.action_pop();actions_status.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>';
-    $frm_str .='</div>';
-    return addslashes($frm_str);
-}
-
-function check_form($form_id, $values)
-{
-    return true;
-}
-
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form)
-{
-    if (empty($values_form) || count($arr_id) < 1) {
-        return false;
-    }
-
-    require_once('modules/notes/class/notes_controler.php');
-    $note = new notes_controler();
-    
-    $formValues = array();
-    for ($i=0; $i<count($values_form); $i++) {
-        $formValue = $values_form[$i];
-        $id = $formValue['ID'];
-        $value = $formValue['VALUE'];
-        $formValues[$id] = $value;
-    }
-    
-    $_SESSION['action_error'] = '';
-    $coll_id = $_SESSION['current_basket']['coll_id'];
-
-    # save note
-    if ($formValues['note_content_to_users'] != '') {
-        //Add notes
-        $content_note = $formValues['note_content_to_users'];
-        $content_note = str_replace(";", ".", $content_note);
-        $content_note = str_replace("--", "-", $content_note);
-        foreach ($arr_id as $res_id) {
-            $note->addNote($res_id, $coll_id, $content_note);
-        }
-    }
-
-    return array('result' => implode("#", $arr_id), 'history_msg' => '');
-}
-
- /**
- * Get the value of a given field in the values returned by the form
- *
- * @param $values Array Values of the form to check
- * @param $field String the field
- * @return String the value, false if the field is not found
- **/
-function get_value_fields($values, $field)
-{
-    for ($i=0; $i<count($values); $i++) {
-        if ($values[$i]['ID'] == $field) {
-            return  $values[$i]['VALUE'];
-        }
-    }
-    return false;
-}
diff --git a/apps/maarch_entreprise/actions/confirm_status_with_update_date.php b/apps/maarch_entreprise/actions/confirm_status_with_update_date.php
deleted file mode 100755
index 99b77ffab1904539209e06b6234e43dc5a9322d3..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/confirm_status_with_update_date.php
+++ /dev/null
@@ -1,161 +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   confirm_status_with_update_date
-* @author  dev <dev@maarch.org>
-* @ingroup apps
-*/
-
-$confirm = false;
-$etapes = array('form');
-$frm_width='285px';
-$frm_height = 'auto';
-
-function get_form_txt($values, $path_manage_action,  $id_action, $table, $module, $coll_id, $mode )
-{
-
-    $res_id=$values[0];
-    $db = new Database();
-    $labelAction = '';
-    if ($id_action <> '') {
-        $stmt = $db->query("select label_action from actions where id = ?",array($id_action));
-        $resAction = $stmt->fetchObject();
-        $labelAction = functions::show_string($resAction->label_action);
-    }
-    
-    $values_str = '';
-    if (empty($_SESSION['stockCheckbox'])) {
-        for ($i=0; $i < count($values);$i++) {
-            $values_str .= $values[$i].', ';
-        }
-    } else { 
-
-        for ($i=0; $i < count($_SESSION['stockCheckbox']);$i++) {
-            $values_str .= $_SESSION['stockCheckbox'][$i].', ';
-        }
-    }
-    $values_str = preg_replace('/, $/', '', $values_str);
-  
-    include_once 'modules/templates/class/templates_controler.php';
-    $templatesControler = new templates_controler();
-    $templates = array();
-
-    $stmt = $db->query("SELECT destination FROM res_letterbox WHERE res_id = (?)", [$res_id]);
-    $resultDest = $stmt->fetchObject();
-    $destination = $resultDest->destination;
-    if ($destination <> '') {
-        $templates = $templatesControler->getAllTemplatesForProcess($destination);
-    } else {
-        $templates = $templatesControler->getAllTemplatesForSelect();
-    }
-    $frm_str ='<center style="font-size:15px;">'._ACTION_CONFIRM.'<br/><br/><b>'.strtoupper($labelAction).' ?</b></center><br/>';
-    $frm_str .='<b>'._PROCESS_NOTES.':</b><br/>';
-    $frm_str .= '<select name="templateNotes" id="templateNotes" style="width:98%;margin-bottom: 10px;background-color: White;border: 1px solid #999;color: #666;text-align: left;" '
-                . 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
-                . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-                . '&module=templates&page=templates_ajax_content_for_notes\');document.getElementById(\'notes\').focus();">';
-    $frm_str .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
-    for ($i=0;$i<count($templates);$i++) {
-        if ($templates[$i]['TYPE'] == 'TXT' && ($templates[$i]['TARGET'] == 'notes' || $templates[$i]['TARGET'] == '')) {
-            $frm_str .= '<option value="';
-            $frm_str .= $templates[$i]['ID'];
-            $frm_str .= '">';
-            $frm_str .= $templates[$i]['LABEL'];
-        }
-        $frm_str .= '</option>';
-    }
-    $frm_str .= '</select><br />';
-
-    $frm_str .= '<textarea placeholder="motif de l\'action (optionnel) ..." style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="document.getElementById(\'note_content_to_users\').value=document.getElementById(\'notes\').value;"></textarea>';
-    $frm_str .='<div id="form2" style="border:none;">';
-    $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-    $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-    $frm_str .= '<input type="hidden" name="note_content_to_users" id="note_content_to_users" />';
-        $frm_str .='</form>';
-    $frm_str .='</div>';
-
-    $frm_str .='<div align="center">';
-        $frm_str .=' <input type="button" name="redirect_dep" value="'._VALIDATE.'" id="redirect_dep" class="button" onclick="valid_action_form( \'frm_redirect_dep\', \''.$path_manage_action.'\', \''. $id_action.'\', \''.$values_str.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');" />';
-        $frm_str .=' <input type="button" name="cancel" id="cancel" class="button"  value="'._CANCEL.'" onclick="pile_actions.action_pop();actions_status.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>';
-    $frm_str .='</div>';
-    return addslashes($frm_str);
-}
-
-function check_form($form_id,$values)
-{
-    return true;
-}
-
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form )
-{
-    
-    if(empty($values_form) || count($arr_id) < 1) 
-        return false;
-
-    include_once 'modules/notes/class/notes_controler.php';
-    $note = new notes_controler();
-
-    $formValues = array();
-    for ($i=0; $i<count($values_form); $i++) {
-        $formValue = $values_form[$i];
-        $id = $formValue['ID'];
-        $value = $formValue['VALUE'];
-        $formValues[$id] = $value;
-    }
-    
-
-    $_SESSION['action_error'] = '';
-    $result = '';
-    $coll_id = $_SESSION['current_basket']['coll_id'];
-
-    include_once "core/class/class_security.php";
-    $sec = new security();
-    $table = $sec->retrieve_table_from_coll($coll_id);
-
-    $db = new Database();
-
-    //LOOP IF MASS ACTION
-    foreach ($arr_id as $res_id) {
-        $result .= $res_id.'#';
-
-        //update exp date
-        $stmt = $db->query("UPDATE res_letterbox SET departure_date = current_timestamp where res_id = ? and departure_date is null", array($res_id));
-
-        //save note
-        if ($formValues['note_content_to_users'] != '') {
-            //Add notes
-            $nb_avis = $sequence +1;
-            $userIdTypist = $_SESSION['user']['UserId'];
-            $content_note = $formValues['note_content_to_users'];
-            $content_note = str_replace(";", ".", $content_note);
-            $content_note = str_replace("--", "-", $content_note);
-            $content_note = $content_note;
-            $note->addNote($res_id, $coll_id, $content_note);
-        }
-    }
-    return array('result' => $result, 'history_msg' => '');
-}
-
-/**
-* Get the value of a given field in the values returned by the form
-*
-* @param $values Array Values of the form to check
-* @param $field String the field
-* @return String the value, false if the field is not found
-**/
-function get_value_fields($values, $field)
-{
-    for ($i=0; $i<count($values);$i++) {
-
-        if ($values[$i]['ID'] == $field) {
-
-            return  $values[$i]['VALUE'];
-        }
-    }
-    return false;
-}
-
-?>
diff --git a/apps/maarch_entreprise/actions/mark_as_read.php b/apps/maarch_entreprise/actions/mark_as_read.php
deleted file mode 100755
index c5eb4c5386a942c49fcc9ab43947c80824b5f7a2..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/mark_as_read.php
+++ /dev/null
@@ -1,57 +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   Action : mark as read
-*
-* mark as read a mail so that it doesn't appear anymore in the basket
-*
-* @file
-* @date $date$
-* @version $Revision$
-* @ingroup apps
-*/
-
-/**
-* $confirm  bool true
-*/
- $confirm = true;
-
-/**
-* $etapes  array Contains only one etap, the status modification
-*/
- $etapes = array('markAsRead');
-
-
-function manage_markAsRead($arr_id, $history, $id_action, $label_action, $status)
-{
-    $db = new Database();
-    $result = '';
-    require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php');
-    require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php');
-    $sec = new security();
-
-    $ind_coll = $sec->get_ind_collection($_POST['coll_id']);
-
-    for ($i=0; $i<count($arr_id);$i++) {
-        $result .= $arr_id[$i].'#';
-
-        $stmt = $db->query("SELECT * FROM res_mark_as_read WHERE res_id = ? AND user_id = ? AND basket_id = ?", array($arr_id[$i], $_SESSION['user']['UserId'], $_SESSION['current_basket']['id']));
-
-        $lineExist = false;
-        while ($result1 = $stmt->fetchObject()) {
-            $lineExist = true;
-        }
-        if (!$lineExist) {
-            $query = "INSERT INTO res_mark_as_read VALUES(?, ?, ?)";
-            $db->query($query, array($arr_id[$i], $_SESSION['user']['UserId'], $_SESSION['current_basket']['id']));
-        }
-    }
-    return array('result' => $result, 'history_msg' => '');
-}
diff --git a/apps/maarch_entreprise/actions/set_persistent_mode_off.php b/apps/maarch_entreprise/actions/set_persistent_mode_off.php
deleted file mode 100755
index 9ffbe4d8151822bc192c5aba5e5e2544a1c2aa6a..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/set_persistent_mode_off.php
+++ /dev/null
@@ -1,76 +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   Action : simple confirm
-*
-* Open a modal box to confirm a status modification. Used by the core (manage_action.php page).
-*
-* @file
-* @author Arnaud Veber
-* @date $date$
-* @version $Revision$
-* @ingroup apps
-*/
-
-/**
-* $confirm  bool true
-*/
- $confirm = false;
-
-/**
-* $etapes  array Contains only one etap, the status modification
-*/
- $etapes = array('persistentOff');
-
-
-function manage_persistentOff($arr_id, $history, $id_action, $label_action, $status)
-{
-    $db = new Database();
-    $result = '';
-    require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php');
-    require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php');
-    $sec = new security();
-
-    $ind_coll = $sec->get_ind_collection($_POST['coll_id']);
-
-    for($i=0; $i<count($arr_id );$i++)
-    {
-        $result .= $arr_id[$i].'#';
-
-        //on verifie si il y a déja une entrée dans la base pour ce res_id et cet user_id
-
-        $stmt = $db->query("SELECT * FROM basket_persistent_mode WHERE res_id = ? AND user_id = ?", array($arr_id[$i], $_SESSION['user']['UserId']));
-        $lineExist = false;
-        while ($result1 = $stmt->fetchObject()) {
-            $lineExist = true;
-        }
-
-        if ($lineExist) {
-            $query = "UPDATE basket_persistent_mode SET is_persistent = 'N' WHERE res_id = ? AND user_id = ?";
-            $db->query($query, array($arr_id[$i], $_SESSION['user']['UserId']));
-        } else {
-            $query = "INSERT INTO basket_persistent_mode VALUES(?, ?, 'N')";
-            $db->query($query, array($arr_id[$i], $_SESSION['user']['UserId']));
-        }
-
-    }
-    return array('result' => $result, 'history_msg' => '');
- }
diff --git a/apps/maarch_entreprise/actions/set_persistent_mode_on.php b/apps/maarch_entreprise/actions/set_persistent_mode_on.php
deleted file mode 100755
index 616f3f4633adcbe4b44325a3d41eeed522f7d15d..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/set_persistent_mode_on.php
+++ /dev/null
@@ -1,76 +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   Action : simple confirm
-*
-* Open a modal box to confirm a status modification. Used by the core (manage_action.php page).
-*
-* @file
-* @author Arnaud Veber
-* @date $date$
-* @version $Revision$
-* @ingroup apps
-*/
-
-/**
-* $confirm  bool true
-*/
- $confirm = false;
-
-/**
-* $etapes  array Contains only one etap, the status modification
-*/
- $etapes = array('persistentOn');
-
-
-function manage_persistentOn($arr_id, $history, $id_action, $label_action, $status)
-{
-    $db = new Database();
-    $result = '';
-    require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php');
-    require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php');
-    $sec = new security();
-
-    $ind_coll = $sec->get_ind_collection($_POST['coll_id']);
-
-    for($i=0; $i<count($arr_id );$i++)
-    {
-        $result .= $arr_id[$i].'#';
-
-        //on verifie si il y a déja une entrée dans la base pour ce res_id et cet user_id
-
-        $stmt = $db->query("SELECT * FROM basket_persistent_mode WHERE res_id = ? AND user_id = ?", array($arr_id[$i], $_SESSION['user']['UserId']));
-        $lineExist = false;
-        while ($result1 = $stmt->fetchObject()) {
-            $lineExist = true;
-        }
-
-        if ($lineExist) {
-            $query = "UPDATE basket_persistent_mode SET is_persistent = 'Y' WHERE res_id = ? AND user_id = ?";
-            $db->query($query, array($arr_id[$i], $_SESSION['user']['UserId']));
-        } else {
-            $query = "INSERT INTO basket_persistent_mode VALUES(?, ?, 'Y')";
-            $db->query($query, array($arr_id[$i], $_SESSION['user']['UserId']));
-        }
-
-    }
-    return array('result' => $result, 'history_msg' => '');
- }
diff --git a/apps/maarch_entreprise/actions/view.php b/apps/maarch_entreprise/actions/view.php
deleted file mode 100755
index 312c81e8b500da3b9214bfa85e31e1a9a11415f8..0000000000000000000000000000000000000000
--- a/apps/maarch_entreprise/actions/view.php
+++ /dev/null
@@ -1,44 +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   view
-* @author  dev <dev@maarch.org>
-* @ingroup apps
-*/
-
-$etapes = array('form');
-
-$frm_width='';
-
-$frm_height = '';
-
-$mode_form = 'fullscreen';
-
-/**
- * Returns the indexing form text
- *
- * @param $values Array Contains the res_id of the document to process
- * @param $path_manage_action String Path to the PHP file called in Ajax
- * @param $id_action String Action identifier
- * @param $table String Table
- * @param $module String Origin of the action
- * @param $coll_id String Collection identifier
- * @param $mode String Action mode 'mass' or 'page'
- * @return String The form content text
- **/
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    $res_id = $values[0];
-    $frm_str = '';
-    $_SESSION['doc_id'] = $res_id;
-    $frm_str .= '<div>';
-    $frm_str .= '	<center><input name="close" style="padding:5px;font-weight:600;" id="close" type="button" value="'._CLOSE.'" class="button" onClick="javascript:$(\'baskets\').style.visibility=\'visible\';destroyModal(\'modal_'.$id_action.'\');reinit();window.location.reload();"/></center>';
-    $frm_str .= '    </br>';
-    $frm_str .= '	<iframe src="../../rest/resources/'.$res_id.'/content" name="viewframe" id="viewframe"  scrolling="auto" frameborder="0" ></iframe>';
-    $frm_str .= '</div>';
-    $frm_str .= '<script type="text/javascript">resize_frame_view("modal_'.$id_action.'", "viewframe", true, true);window.scrollTo(0,0);</script>';
-    return addslashes($frm_str);
-}
diff --git a/modules/avis/avis_workflow.php b/modules/avis/avis_workflow.php
deleted file mode 100755
index 3aea35b13aee4ece0f892bac66e0d2a02f6b7a27..0000000000000000000000000000000000000000
--- a/modules/avis/avis_workflow.php
+++ /dev/null
@@ -1,307 +0,0 @@
-<?php
-$confirm = false;
-$etapes = array('form');
-$frm_width='355px';
-$frm_height = 'auto';
-require("modules/entities/entities_tables.php");
-require_once("modules/entities/class/EntityControler.php");
-require_once('modules/entities/class/class_manage_entities.php');;
-require_once "modules" . DIRECTORY_SEPARATOR . "avis" . DIRECTORY_SEPARATOR
-            . "class" . DIRECTORY_SEPARATOR
-            . "avis_controler.php";
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
-        ."class".DIRECTORY_SEPARATOR."class_lists.php";
-
- function get_form_txt($values, $path_manage_action,  $id_action, $table, $module, $coll_id, $mode )
- {
-    require_once('apps/' . $_SESSION['config']['app_id'] . '/class/class_chrono.php');
-    $cr7 = new chrono();
-    $res_id=$values[0];
-    $avis = new avis_controler();
-    $ent = new entity();
-    $entity_ctrl = new EntityControler();
-    $services = array();
-    $servicesCompare = array();
-    $db = new Database();
-    $sec = new security();
-    $labelAction = '';
-    if ($id_action <> '') {
-        $stmt = $db->query("select label_action from actions where id = ?",array($id_action));
-        $resAction = $stmt->fetchObject();
-        $labelAction = functions::show_string($resAction->label_action);
-    }
-    
-
-    $frm_str = '<div id="frm_error_'.$id_action.'" class="error"></div>';
-    if ($labelAction <> '') {
-        $frm_str .= '<h2 class="title">' . $labelAction . ' ' . _NUM;
-    } else {
-        $frm_str .= '<h2 class="title">'._REDIRECT_MAIL.' '._NUM;
-    }
-    $values_str = '';
-    if(empty($_SESSION['stockCheckbox'])){
-    for($i=0; $i < count($values);$i++)
-        {
-            $values_str .= $values[$i].', ';
-        }
-    }else{ 
-
-    for($i=0; $i < count($_SESSION['stockCheckbox']);$i++)
-        {
-            $values_str .= $_SESSION['stockCheckbox'][$i].', ';
-        }
-    }
-    $values_str = preg_replace('/, $/', '', $values_str);
-    if(_ID_TO_DISPLAY == 'res_id'){
-        $frm_str .= $values_str;
-    } else if (_ID_TO_DISPLAY == 'chrono_number'){
-        $chrono_number = $cr7->get_chrono_number($values_str, 'res_view_letterbox');
-        $frm_str .= $chrono_number;
-    }
-    $frm_str .= '</h2><br/>';
-    require 'modules/templates/class/templates_controler.php';
-    $templatesControler = new templates_controler();
-    $templates = array();
-
-      
-        $EntitiesIdExclusion = array();
-        $entities = $entity_ctrl->getAllEntities();
-        $countEntities = count($entities);
-        //var_dump($entities);
-        for ($cptAllEnt = 0;$cptAllEnt<$countEntities;$cptAllEnt++) {
-            if (!is_integer(array_search($entities[$cptAllEnt]->__get('entity_id'), $servicesCompare))) {
-                array_push($EntitiesIdExclusion, $entities[$cptAllEnt]->__get('entity_id'));
-            }
-        }
-        
-        $allEntitiesTree= array();
-        $allEntitiesTree = $ent->getShortEntityTreeAdvanced(
-            $allEntitiesTree, 'all', '', $EntitiesIdExclusion, 'all'
-        );
-        //Collection
-        if (isset($_REQUEST['coll_id']) && ! empty($_REQUEST['coll_id'])) {
-            $collId = trim($_REQUEST['coll_id']);
-            $parameters .= '&coll_id='.$_REQUEST['coll_id'];
-            $view = $sec->retrieve_view_from_coll_id($collId);
-            $table = $sec->retrieve_table_from_coll($collId);
-            //retrieve the process entity of document
-            $stmt = $db->query(
-                "SELECT destination FROM " . $table . " WHERE res_id in (?)", array($values_str)
-            );
-            $resultDest = $stmt->fetchObject();
-            $destination = $resultDest->destination;
-        }
-        if ($destination <> '') {
-            $templates = $templatesControler->getAllTemplatesForProcess($destination);
-        } else {
-            $templates = $templatesControler->getAllTemplatesForSelect();
-        }
-        $frm_str .='<br/><b>'._RECOMMENDATION_NOTE.':</b><br/>';
-        $frm_str .= '<select name="templateNotes" id="templateNotes" style="width:98%;margin-bottom: 10px;background-color: White;border: 1px solid #999;color: #666;text-align: left;" '
-                    . 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
-                    . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-                    . '&module=templates&page=templates_ajax_content_for_notes\');document.getElementById(\'notes\').focus();">';
-        $frm_str .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
-            for ($i=0;$i<count($templates);$i++) {
-                if ($templates[$i]['TYPE'] == 'TXT' && ($templates[$i]['TARGET'] == 'notes' || $templates[$i]['TARGET'] == '')) {
-                    $frm_str .= '<option value="';
-                    $frm_str .= $templates[$i]['ID'];
-                    $frm_str .= '">';
-                    $frm_str .= $templates[$i]['LABEL'];
-                }
-                $frm_str .= '</option>';
-            }
-        $frm_str .= '</select><br />';
-
-        $frm_str .= '<textarea style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="document.getElementById(\'note_content_to_users\').value=document.getElementById(\'notes\').value.replace(/[\n]/gi, \'##\' );"></textarea>';
-        //var_dump($allEntitiesTree);
-        /*$frm_str .= '<hr />';
-        $frm_str .= '<div class="error" id="divError" name="divError"></div>';
-                $frm_str .= '<div style="text-align:center;">';
-                $frm_str .= $avis->getListPopup($res_id, $coll_id, true,'AVIS_CIRCUIT');
-      
-                $frm_str .='</div>';*/
-        $frm_str .='<div id="form2" style="border:none;">';
-        $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-        $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-        $frm_str .= '<input type="hidden" name="note_content_to_users" id="note_content_to_users" />';
-            $frm_str .='</form>';
-        $frm_str .='</div>';
-    $frm_str .='<hr />';
-
-    $frm_str .='<div align="center">';
-        $frm_str .=' <input type="button" name="redirect_dep" value="'._VALIDATE.'" id="redirect_dep" class="button" onclick="valid_action_form( \'frm_redirect_dep\', \''.$path_manage_action.'\', \''. $id_action.'\', \''.$values_str.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');" />';
-        $frm_str .=' <input type="button" name="cancel" id="cancel" class="button"  value="'._CANCEL.'" onclick="pile_actions.action_pop();actions_status.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>';
-    $frm_str .='</div>';
-    return addslashes($frm_str);
- }
-
- function check_form($form_id,$values)
- {
-    $note_content_to_users = get_value_fields($values, 'note_content_to_users');
-    if($note_content_to_users == null || $note_content_to_users == ''){
-        $_SESSION['action_error'] = _AVIS_NOTE. " " . _MANDATORY;
-        return false;
-    }
-    return true;
- }
-
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form )
-{
-    /*
-        Redirect to dep:
-        $values_form = array (size=3)
-          0 => 
-            array (size=2)
-              'ID' => string 'chosen_action' (length=13)
-              'VALUE' => string 'end_action' (length=10)
-          1 => 
-            array (size=2)
-              'ID' => string 'department' (length=10)
-              'VALUE' => string 'DGA' (length=3)
-          2 => 
-            array (size=2)
-              'ID' => string 'redirect_dep' (length=12)
-              'VALUE' => string 'Rediriger' (length=9)
-        
-        Redirect to user:
-        $values_form = array (size=3)
-          0 => 
-            array (size=2)
-              'ID' => string 'chosen_action' (length=13)
-              'VALUE' => string 'end_action' (length=10)
-          1 => 
-            array (size=2)
-              'ID' => string 'user' (length=4)
-              'VALUE' => string 'aackermann' (length=10)
-          2 => 
-            array (size=2)
-              'ID' => string 'redirect_user' (length=13)
-              'VALUE' => string 'Rediriger' (length=9)
-    
-    */
-
-    if(empty($values_form) || count($arr_id) < 1) 
-        return false;
-
-    require_once('modules/notes/class/notes_controler.php');
-    require_once('modules/avis/class/avis_controler.php');
-    $note = new notes_controler();
-
-
-    $db = new Database();
-    
-    $formValues = array();
-    for($i=0; $i<count($values_form); $i++) {
-        $formValue = $values_form[$i];
-        $id = $formValue['ID'];
-        $value = $formValue['VALUE'];
-        $formValues[$id] = $value;
-    }
-    
-        
-    # save note
-    if($formValues['note_content_to_users'] != ''){
-        //Add notes
-        $userIdTypist = $_SESSION['user']['UserId'];
-        $content_note = $formValues['note_content_to_users'];
-        $content_note = str_replace("##", "\n", $content_note);
-        $content_note = str_replace(";", ".", $content_note);
-        $content_note = str_replace("--", "-", $content_note);
-        $content_note = $content_note;
-        $content_note = '[' . _TO_AVIS . '] ' . $content_note;
-        $note->addNote($res_id, $coll_id, $content_note);
-        
-    }
-    
-    $db = new Database();
-    $_SESSION['action_error'] = '';
-    $result = '';
-    $coll_id = $_SESSION['current_basket']['coll_id'];
-    $res_id = $arr_id[0];
-    require_once("core/class/class_security.php");
-    $sec = new security();
-    $table = $sec->retrieve_table_from_coll($coll_id);
-    $circuit_avis = new avis_controler();
-    $sequence = $circuit_avis->getCurrentStepAvis($res_id, $coll_id, 'AVIS_CIRCUIT');
-    $stepDetails = $circuit_avis->getStepDetailsAvis($res_id, $coll_id, 'AVIS_CIRCUIT', $sequence);
-    $message = '';
-    //enables to process the avis if i am not the item_id
-    if ($stepDetails['item_id'] <> $_SESSION['user']['UserId']) {
-        $stmt = $db->query("UPDATE listinstance SET process_date = CURRENT_TIMESTAMP "
-            . " WHERE listinstance_id = ? AND item_mode = ? AND res_id = ? AND item_id = ? AND difflist_type = ?"
-            , array($stepDetails['listinstance_id'], $stepDetails['item_mode'], $res_id, $stepDetails['item_id'], 'AVIS_CIRCUIT'));
-        $message = _AVIS_SENT . " " . _BY ." " . $_SESSION['user']['UserId'] 
-            . " " . _INSTEAD_OF . " " . $stepDetails['item_id'];
-    } else {
-        $stmt = $db->query("UPDATE listinstance SET process_date = CURRENT_TIMESTAMP "
-            . " WHERE listinstance_id = ? AND item_mode = ? AND res_id = ? AND item_id = ? AND difflist_type = ?"
-            , array($stepDetails['listinstance_id'], $stepDetails['item_mode'], $res_id, $_SESSION['user']['UserId'], 'AVIS_CIRCUIT'));
-    }
-
-
-//    if (
-//
-//        $sequence == $circuit_avis->nbAvis($res_id, $coll_id)-1
-//
-//    ){
-//
-//        $stmt = $db->query("SELECT status_id FROM groupbasket_status WHERE group_id = ? and basket_id = ? and action_id = ?"
-//
-//            ,array($_SESSION['current_basket']['group_id'],$_SESSION['current_basket']['id'],$id_action));
-//
-//
-//
-//        if($status = $stmt->fetchObject()){
-//
-//            $mailStatus = $status->status_id;
-//
-//            $stmt = $db->query("UPDATE res_letterbox SET status = ? WHERE res_id = ? ", array($mailStatus, $res_id));
-//
-//        }
-//
-//    } else {
-//
-//        //$mailStatus = 'EAVIS';
-//
-//    }
-
-    $circuit_avis->processAvis($res_id);
-
-    # save note
-        if($formValues['note_content_to_users'] != ''){
-            //Add notes
-            $nb_avis = $sequence +1;
-            $userIdTypist = $stepDetails['item_id'];
-            $content_note = $formValues['note_content_to_users'];
-            $content_note = str_replace("##", "\n", $content_note);
-            $content_note = str_replace(";", ".", $content_note);
-            $content_note = str_replace("--", "-", $content_note);
-            $content_note = $content_note;
-            $content_note = '[' . _AVIS_NB . $nb_avis . '] ' . $content_note;
-            $note->addNote($res_id, $coll_id, $content_note, $userIdTypist);
-            
-        }
-    return array('result' => $res_id.'#', 'history_msg' => $message);
-}
-
- /**
- * Get the value of a given field in the values returned by the form
- *
- * @param $values Array Values of the form to check
- * @param $field String the field
- * @return String the value, false if the field is not found
- **/
-function get_value_fields($values, $field)
-{
-    for($i=0; $i<count($values);$i++)
-    {
-        if($values[$i]['ID'] == $field)
-        {
-            return  $values[$i]['VALUE'];
-        }
-    }
-    return false;
-}
-
-?>
diff --git a/modules/avis/send_to_avis.php b/modules/avis/send_to_avis.php
deleted file mode 100755
index 4837ead3985a6346423f30ce25aa2bb00ceb02a6..0000000000000000000000000000000000000000
--- a/modules/avis/send_to_avis.php
+++ /dev/null
@@ -1,275 +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   send_to_avis
-* @author  dev <dev@maarch.org>
-* @ingroup core
-*/
-
-$confirm = false;
-$etapes = array('form');
-$frm_width = '650px';
-$frm_height = '90%';
-require "modules/entities/entities_tables.php";
-require_once "modules/entities/class/EntityControler.php";
-require_once 'modules/entities/class/class_manage_entities.php';
-require_once "modules" . DIRECTORY_SEPARATOR . "avis" . DIRECTORY_SEPARATOR
-        . "class" . DIRECTORY_SEPARATOR
-        . "avis_controler.php";
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
-        ."class".DIRECTORY_SEPARATOR."class_lists.php";
-
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    include_once 'apps/' . $_SESSION['config']['app_id'] . '/class/class_chrono.php';
-    $cr7 = new chrono();
-
-    include_once 'apps/maarch_entreprise/definition_mail_categories.php';
-
-    $res_id = $values[0];
-
-//    $data = get_general_data($coll_id, $res_id, 'minimal');
-    //print_r($data);
-    $avis = new avis_controler();
-    $ent = new entity();
-    $entity_ctrl = new EntityControler();
-    $services = array();
-    $servicesCompare = array();
-    $db = new Database();
-    $sec = new security();
-    $labelAction = '';
-    if ($id_action <> '') {
-        $stmt = $db->query("select label_action from actions where id = ?", array($id_action));
-        $resAction = $stmt->fetchObject();
-        $labelAction = functions::show_string($resAction->label_action);
-    }
-
-
-    $frm_str = '<div id="frm_error_' . $id_action . '" class="error"></div>';
-    if ($labelAction <> '') {
-        $frm_str .= '<h2 class="title">' . $labelAction . ' ' . _NUM;
-    } else {
-        $frm_str .= '<h2 class="title">' . _REDIRECT_MAIL . ' ' . _NUM;
-    }
-    $values_str = '';
-    if (empty($_SESSION['stockCheckbox'])) {
-        for ($i = 0; $i < count($values); $i++) {
-            $values_str .= $values[$i] . ', ';
-        }
-    } else {
-
-        for ($i = 0; $i < count($_SESSION['stockCheckbox']); $i++) {
-            $values_str .= $_SESSION['stockCheckbox'][$i] . ', ';
-        }
-    }
-    $values_str = preg_replace('/, $/', '', $values_str);
-    if (_ID_TO_DISPLAY == 'res_id') {
-        $frm_str .= $values_str;
-    } else if (_ID_TO_DISPLAY == 'chrono_number') {
-        $chrono_number = $cr7->get_chrono_number($values_str, 'res_view_letterbox');
-        $frm_str .= $chrono_number;
-    }
-    $frm_str .= '</h2><br/>';
-    include 'modules/templates/class/templates_controler.php';
-    $templatesControler = new templates_controler();
-    $templates = array();
-
-
-    $EntitiesIdExclusion = array();
-    $entities = $entity_ctrl->getAllEntities();
-    $countEntities = count($entities);
-    //var_dump($entities);
-    for ($cptAllEnt = 0; $cptAllEnt < $countEntities; $cptAllEnt++) {
-        if (!is_integer(array_search($entities[$cptAllEnt]->__get('entity_id'), $servicesCompare))) {
-            array_push($EntitiesIdExclusion, $entities[$cptAllEnt]->__get('entity_id'));
-        }
-    }
-
-    $allEntitiesTree = array();
-    $allEntitiesTree = $ent->getShortEntityTreeAdvanced(
-        $allEntitiesTree, 'all', '', $EntitiesIdExclusion, 'all'
-    );
-    //Collection
-    if (isset($_REQUEST['coll_id']) && ! empty($_REQUEST['coll_id'])) {
-        $collId = trim($_REQUEST['coll_id']);
-        $parameters .= '&coll_id='.$_REQUEST['coll_id'];
-        $view = $sec->retrieve_view_from_coll_id($collId);
-        $table = $sec->retrieve_table_from_coll($collId);
-        //retrieve the process entity of document
-        $stmt = $db->query(
-            "SELECT destination FROM " . $table . " WHERE res_id in (?)", array($values_str)
-        );
-        $resultDest = $stmt->fetchObject();
-        $destination = $resultDest->destination;
-    }
-    if ($destination <> '') {
-        $templates = $templatesControler->getAllTemplatesForProcess($destination);
-    } else {
-        $templates = $templatesControler->getAllTemplatesForSelect();
-    }
-    $frm_str .='<b>' . _OPINION_LIMIT_DATE . ':</b><br/>';
-    $frm_str .= '<input name="opinion_limit_date_tr" type="text" '
-            . 'id="opinion_limit_date_tr" value="" placeholder="JJ-MM-AAAA" onfocus="checkRealDateAvis();" onChange="checkRealDateAvis();"  onclick="clear_error(\'frm_error_'
-            . $actionId . '\');showCalender(this);"  onblur="document.getElementById(\'opinion_limit_date\').value=document.getElementById(\'opinion_limit_date_tr\').value;"/>';
-    $frm_str .='<br/>';
-    $frm_str .='<br/><b>' . _RECOMMENDATION_NOTE . ':</b><br/>';
-    $frm_str .= '<select name="templateNotes" id="templateNotes" style="width:98%;margin-bottom: 10px;background-color: White;border: 1px solid #999;color: #666;text-align: left;" '
-            . 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
-            . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-            . '&module=templates&page=templates_ajax_content_for_notes\');document.getElementById(\'notes\').focus();">';
-    $frm_str .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
-    for ($i = 0; $i < count($templates); $i++) {
-        if ($templates[$i]['TYPE'] == 'TXT' && ($templates[$i]['TARGET'] == 'notes' || $templates[$i]['TARGET'] == '')) {
-            $frm_str .= '<option value="';
-            $frm_str .= $templates[$i]['ID'];
-            $frm_str .= '">';
-            $frm_str .= $templates[$i]['LABEL'];
-        }
-        $frm_str .= '</option>';
-    }
-    $frm_str .= '</select><br />';
-
-    $frm_str .= '<textarea style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="document.getElementById(\'note_content_to_users\').value=document.getElementById(\'notes\').value.replace(/[\n]/gi, \'##\' );"></textarea>';
-    //var_dump($allEntitiesTree);
-    $frm_str .= '<hr />';
-    $frm_str .= '<div class="error" id="divError" name="divError"></div>';
-    $frm_str .= '<div style="text-align:center;">';
-    $frm_str .= $avis->getList($res_id, $coll_id, true, 'AVIS_CIRCUIT');
-
-    $frm_str .='</div>';
-    $frm_str .='<div id="form2" style="border:none;">';
-    $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-    $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-    $frm_str .= '<input type="hidden" name="note_content_to_users" id="note_content_to_users" />';
-    $frm_str .= '<input type="hidden" name="opinion_limit_date" id="opinion_limit_date" />';
-    $frm_str .= '<input type="hidden" name="doc_date" id="doc_date" value ="' . $data['doc_date'] . '"/>';
-    $frm_str .= '<input type="hidden" name="process_limit_date" id="process_limit_date" value ="' . $data['process_limit_date'] . '" />';
-    $frm_str .='</form>';
-    $frm_str .='</div>';
-    $frm_str .='<hr />';
-
-    $frm_str .='<div align="center">';
-    $frm_str .=' <input type="button" name="redirect_dep" value="' . _VALIDATE . '" id="redirect_dep" class="button" onclick="updateAvisWorkflow(' . $res_id . ');valid_action_form( \'frm_redirect_dep\', \'' . $path_manage_action . '\', \'' . $id_action . '\', \'' . $values_str . '\', \'' . $table . '\', \'' . $module . '\', \'' . $coll_id . '\', \'' . $mode . '\');" />';
-    $frm_str .=' <input type="button" name="cancel" id="cancel" class="button"  value="' . _CANCEL . '" onclick="pile_actions.action_pop();actions_status.action_pop();destroyModal(\'modal_' . $id_action . '\');"/>';
-    $frm_str .='</div>';
-    return addslashes($frm_str);
-}
-
-function check_form($form_id, $values)
-{
-    $opinionLimitDate = get_value_fields($values, 'opinion_limit_date');
-    $note_content_to_users = get_value_fields($values, 'note_content_to_users');
-
-    if ($opinionLimitDate == null || $opinionLimitDate == '') {
-        $_SESSION['action_error'] = _OPINION_LIMIT_DATE . " " . _MANDATORY;
-        return false;
-    } else if ($note_content_to_users == null || $note_content_to_users == '') {
-        $_SESSION['action_error'] = _NOTE . " " . _MANDATORY;
-        return false;
-    }
-
-
-    $avis = new avis_controler();
-    $curr_avis_wf = $avis->getWorkflow($_SESSION['doc_id'], $_SESSION['current_basket']['coll_id'], 'AVIS_CIRCUIT');
-
-    if (count($curr_avis_wf['avis']) == 0) {
-        $_SESSION['action_error'] = _AVIS_WORKFLOW . " " . _MANDATORY;
-        return false;
-    }
-
-    return true;
-}
-
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form)
-{
-    /*
-      Redirect to dep:
-      $values_form = array (size=3)
-      0 =>
-      array (size=2)
-      'ID' => string 'chosen_action' (length=13)
-      'VALUE' => string 'end_action' (length=10)
-      1 =>
-      array (size=2)
-      'ID' => string 'department' (length=10)
-      'VALUE' => string 'DGA' (length=3)
-      2 =>
-      array (size=2)
-      'ID' => string 'redirect_dep' (length=12)
-      'VALUE' => string 'Rediriger' (length=9)
-
-      Redirect to user:
-      $values_form = array (size=3)
-      0 =>
-      array (size=2)
-      'ID' => string 'chosen_action' (length=13)
-      'VALUE' => string 'end_action' (length=10)
-      1 =>
-      array (size=2)
-      'ID' => string 'user' (length=4)
-      'VALUE' => string 'aackermann' (length=10)
-      2 =>
-      array (size=2)
-      'ID' => string 'redirect_user' (length=13)
-      'VALUE' => string 'Rediriger' (length=9)
-
-     */
-
-    if (empty($values_form) || count($arr_id) < 1)
-        return false;
-
-    $res_id = $arr_id[0];
-    include_once 'modules/entities/class/class_manage_listdiff.php';
-    include_once 'modules/notes/class/notes_controler.php';
-    include_once 'modules/avis/class/avis_controler.php';
-    $note = new notes_controler();
-
-
-    $db = new Database();
-
-    $formValues = array();
-    for ($i = 0; $i < count($values_form); $i++) {
-        $formValue = $values_form[$i];
-        $id = $formValue['ID'];
-        $value = $formValue['VALUE'];
-        $formValues[$id] = $value;
-    }
-
-
-    //save note
-    if ($formValues['note_content_to_users'] != '') {
-        //Add notes
-        $userIdTypist = $_SESSION['user']['UserId'];
-        $content_note = $formValues['note_content_to_users'];
-        $content_note = str_replace("##", "\n", $content_note);
-        $content_note = str_replace(";", ".", $content_note);
-        $content_note = str_replace("--", "-", $content_note);
-        $content_note = $content_note;
-        $content_note = '[' . _TO_AVIS . '] ' . $content_note;
-        $note->addNote($res_id, $coll_id, $content_note);
-    }
-
-    return array('result' => implode('#', $arr_id), 'history_msg' => $message);
-}
-
-/**
- * Get the value of a given field in the values returned by the form
- *
- * @param $values Array Values of the form to check
- * @param $field String the field
- * @return String the value, false if the field is not found
- * */
-function get_value_fields($values, $field)
-{
-    for ($i = 0; $i < count($values); $i++) {
-        if ($values[$i]['ID'] == $field) {
-            return $values[$i]['VALUE'];
-        }
-    }
-    return false;
-}
-
-?>
diff --git a/modules/entities/redirect.php b/modules/entities/redirect.php
deleted file mode 100755
index 1463c7429766f04139af679611ef22c117f5f10d..0000000000000000000000000000000000000000
--- a/modules/entities/redirect.php
+++ /dev/null
@@ -1,618 +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   redirect
-* @author  dev <dev@maarch.org>
-* @ingroup entities
-*/
-
-$confirm = false;
-$etapes = array('form');
-$frm_width='400px';
-$frm_height = '90%';
-
-$destination = '';
-
-require "modules/entities/entities_tables.php";
-require_once "modules/entities/class/EntityControler.php";
-require_once 'modules/entities/class/class_manage_entities.php';
-require_once 'apps/' . $_SESSION['config']['app_id'] . '/class/class_chrono.php';
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR ."class".DIRECTORY_SEPARATOR."class_lists.php";
-
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    $ent = new entity();
-    $entity_ctrl = new EntityControler();
-    $services = array();
-    $servicesCompare = array();
-    $cr7 = new chrono();
-    $db = new Database();
-    $sec = new security();
-    $labelAction = '';
-    if ($id_action <> '') {
-        $stmt = $db->query("select label_action from actions where id = ?", array($id_action));
-        $resAction = $stmt->fetchObject();
-        $labelAction = functions::show_string($resAction->label_action);
-    }
-    
-    preg_match("'^ ,'", $_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['entities'], $out);
-    if (is_array($out[0]) && count($out[0]) == 1) {
-        $_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['entities'] = substr($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['entities'], 2, strlen($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['entities']));
-    }
-    if (!empty($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['entities'])) {
-        $stmt = $db->query("select entity_id, entity_label from ".ENT_ENTITIES." where entity_id in (".$_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['entities'].") and enabled= 'Y' order by entity_label");
-        while ($res = $stmt->fetchObject()) {
-            array_push($services, array( 'ID' => $res->entity_id, 'LABEL' => $db->show_string($res->entity_label)));
-            array_push($servicesCompare, $res->entity_id);
-        }
-    }
-    $users = array();
-    if (!empty($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['users_entities'])) {
-        $stmt = $db->query("select distinct ue.user_id, u.lastname, u.firstname from ".ENT_USERS_ENTITIES." ue, ".$_SESSION['tablename']['users']." u where ue.entity_id in (".$_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['users_entities'].") and u.user_id = ue.user_id and (u.status = 'OK' or u.status = 'ABS') order by u.lastname asc");
-        while ($res = $stmt->fetchObject()) {
-            array_push($users, array( 'ID' => $res->user_id, 'NOM' => functions::show_string($res->lastname), "PRENOM" => functions::show_string($res->firstname)));
-        }
-    }
-
-    $frm_str = '<div id="frm_error_'.$id_action.'" class="error"></div>';
-    if ($labelAction <> '') {
-        $frm_str .= '<h2 class="title">' . $labelAction . ' ' . _NUM;
-    } else {
-        $frm_str .= '<h2 class="title">'._REDIRECT_MAIL.' '._NUM;
-    }
-    $values_str = '';
-    if (empty($_SESSION['stockCheckbox'])) {
-        for ($i=0; $i<count($values); $i++) {
-            if (_ID_TO_DISPLAY == 'res_id') {
-                $values_str .= $values[$i].', ';
-            } elseif (_ID_TO_DISPLAY == 'chrono_number') {
-                $values_str      .= $values[$i].', ';
-                $chrono_number   = $cr7->get_chrono_number($values[$i], 'res_view_letterbox');
-                $values_str_chrn .= $chrono_number.', ';
-            }
-        }
-    } else {
-        for ($i=0; $i<count($_SESSION['stockCheckbox']); $i++) {
-            if (_ID_TO_DISPLAY == 'res_id') {
-                $values_str .= $_SESSION['stockCheckbox'][$i].', ';
-            } elseif (_ID_TO_DISPLAY == 'chrono_number') {
-                $values_str .= $_SESSION['stockCheckbox'][$i].', ';
-
-                $chrono_number = $cr7->get_chrono_number($_SESSION['stockCheckbox'][$i], 'res_view_letterbox');
-                $values_str_chrn .= $chrono_number.', ';
-            }
-        }
-    }
-
-    $values_str = preg_replace('/, $/', '', $values_str);
-
-    if (_ID_TO_DISPLAY == 'res_id') {
-        $frm_str .= $values_str;
-    } elseif (_ID_TO_DISPLAY == 'chrono_number') {
-        $values_str_chrn = preg_replace('/, $/', '', $values_str_chrn);
-        $frm_str .= $values_str_chrn;
-    }
-    $frm_str .= '</h2><br/><br/>';
-    include 'modules/templates/class/templates_controler.php';
-    $templatesControler = new templates_controler();
-    $templates = array();
-
-    if (!empty($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['entities'])) {
-        $EntitiesIdExclusion = array();
-        $entities            = $entity_ctrl->getAllEntities();
-        $countEntities       = count($entities);
-
-        for ($cptAllEnt=0; $cptAllEnt<$countEntities; $cptAllEnt++) {
-            if (!is_integer(array_search($entities[$cptAllEnt]->__get('entity_id'), $servicesCompare))) {
-                array_push($EntitiesIdExclusion, $entities[$cptAllEnt]->__get('entity_id'));
-            }
-        }
-        
-        $allEntitiesTree = array();
-        $allEntitiesTree = $ent->getShortEntityTreeAdvanced(
-            $allEntitiesTree,
-            'all',
-            '',
-            $EntitiesIdExclusion,
-            'all'
-        );
-        //Collection
-        if (isset($_REQUEST['coll_id']) && ! empty($_REQUEST['coll_id'])) {
-            $collId = trim($_REQUEST['coll_id']);
-            $parameters .= '&coll_id='.$_REQUEST['coll_id'];
-            $view = $sec->retrieve_view_from_coll_id($collId);
-            $table = $sec->retrieve_table_from_coll($collId);
-            //retrieve the process entity of document
-            $aResId = explode(", ", $values_str);
-            $stmt = $db->query(
-                "SELECT destination FROM " . $table . " WHERE res_id in (?)",
-                array($aResId)
-            );
-            $resultDest = $stmt->fetchObject();
-            $destination = $resultDest->destination;
-        }
-        if ($destination <> '') {
-            $templates = $templatesControler->getAllTemplatesForProcess($destination);
-        } else {
-            $templates = $templatesControler->getAllTemplatesForSelect();
-        }
-        $frm_str .='<br/><b>'._REDIRECT_NOTE.':</b><br/>';
-        $frm_str .= '<select name="templateNotes" id="templateNotes" style="width:98%;margin-bottom: 10px;background-color: White;border: 1px solid #999;color: #666;text-align: left;" '
-                    . 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
-                    . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-                    . '&module=templates&page=templates_ajax_content_for_notes\');document.getElementById(\'notes\').focus();">';
-        $frm_str .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
-        for ($i=0; $i<count($templates); $i++) {
-            if ($templates[$i]['TYPE'] == 'TXT' && ($templates[$i]['TARGET'] == 'notes' || $templates[$i]['TARGET'] == '')) {
-                $frm_str .= '<option value="';
-                $frm_str .= $templates[$i]['ID'];
-                $frm_str .= '">';
-                $frm_str .= $templates[$i]['LABEL'];
-            }
-            $frm_str .= '</option>';
-        }
-        $frm_str .= '</select><br />';
-
-        $frm_str .= '<textarea style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="setNoteRedirect()"></textarea>';
-        $frm_str .= '<hr />';
-        $frm_str .='<div id="form2" style="border:none;">';
-        $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-        $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-        $frm_str .= '<input type="hidden" name="note_content_to_dep" id="note_content_to_dep" />';
-        $frm_str .='<p>';
-        $frm_str .= '<b>'._REDIRECT_TO_OTHER_DEP.' :</b><br/>';
-        $frm_str .= '<select name="department" id="department" data-placeholder="'._CHOOSE_DEPARTMENT.'" onchange="change_entity(this.options[this.selectedIndex].value, \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=load_listinstance'.'\', \'diff_list_div_redirect\', \'redirect\');" style="float:left;">';
-        $frm_str .='<option value=""></option>';
-        $countAllEntities = count($allEntitiesTree);
-        for ($cptEntities = 0; $cptEntities<$countAllEntities; $cptEntities++) {
-            if (!$allEntitiesTree[$cptEntities]['KEYWORD']) {
-                $frm_str .= '<option data-object_type="entity_id" value="' . $allEntitiesTree[$cptEntities]['ID'] . '"';
-                if ($allEntitiesTree[$cptEntities]['ID'] == $_SESSION['user']['primaryentity']['id']) {
-                    $frm_str .= ' selected="selected"';
-                }
-                if ($allEntitiesTree[$cptEntities]['DISABLED']) {
-                    $frm_str .= ' disabled="disabled" class="disabled_entity"';
-                }
-                $frm_str .=  '>'
-                    .  $ent->show_string($allEntitiesTree[$cptEntities]['SHORT_LABEL'])
-                    . '</option>';
-            }
-        }
-        $frm_str .='</select>';
-        $frm_str .='<script>$j("#department").chosen({width: "80%", disable_search_threshold: 10, search_contains: true,allow_single_deselect: true});document.getElementById("department").onchange();$j("#department").trigger("chosen:updated");</script>';
-        $frm_str .=' <input type="button" style="float:right;margin:0px;" name="redirect_dep" value="'._REDIRECT.'" id="redirect_dep" class="button" onclick="valid_action_form( \'frm_redirect_dep\', \''.$path_manage_action.'\', \''. $id_action.'\', \''.$values_str.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');" />';
-        $frm_str .='<div style="clear:both;"></div>';
-        $frm_str .= '<div id="diff_list_div_redirect" class="scroll_div" style="height:auto;"></div>';
-        $frm_str .='</p>';
-        $frm_str .='</form>';
-        $frm_str .='</div>';
-    }
-    if (!empty($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['users_entities'])) {
-        $frm_str .='<hr />';
-        $frm_str .='<div id="form3">';
-        $frm_str .= '<form name="frm_redirect_user" id="frm_redirect_user" method="post" class="forms" action="#">';
-        $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-        $frm_str .= '<input type="hidden" name="note_content_to_user" id="note_content_to_user" value="" />';
-        $frm_str .='<p>';
-        $frm_str .='<label><b>'._REDIRECT_TO_USER.' :</b></label>';
-        $frm_str .='<select name="user" id="user" style="float:left;" data-placeholder="'._CHOOSE_USER2.'">';
-        $frm_str .='<option value=""></option>';
-        for ($i=0; $i < count($users); $i++) {
-            $frm_str .='<option value="'.$users[$i]['ID'].'">'.$users[$i]['NOM'].' '.$users[$i]['PRENOM'].'</option>';
-        }
-        $frm_str .='</select>';
-        $frm_str .='<script>$j("#user").chosen({width: "80%", disable_search_threshold: 10, search_contains: true,allow_single_deselect: true});</script>';
-        $frm_str .=' <input type="button" style="float:right;margin:0px;" name="redirect_user" id="redirect_user" value="'
-        ._REDIRECT
-        . '" class="button" onclick="valid_action_form( \'frm_redirect_user\', \''
-        . $path_manage_action . '\', \'' . $id_action . '\', \'' . $values_str . '\', \'' . $table . '\', \'' . $module . '\', \'' . $coll_id . '\', \'' . $mode . '\');"  />';
-        $frm_str .='</p>';
-        $frm_str .='<div style="clear:both;"></div>';
-        $frm_str .='</form>';
-        $frm_str .='</div>';
-    }
-    $frm_str .='<hr />';
-
-    $frm_str .='<div align="center">';
-    $frm_str .='<input type="button" name="cancel" id="cancel" class="button"  value="'._CANCEL.'" onclick="pile_actions.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>';
-    $frm_str .='</div>';
-    return addslashes($frm_str);
-}
-
-function check_form($form_id, $values)
-{
-    if ($form_id == 'frm_redirect_dep') {
-        $dep = get_value_fields($values, 'department');
-        if ($dep == '') {
-            $_SESSION['action_error'] = _MUST_CHOOSE_DEP;
-            return false;
-        } elseif (empty($_SESSION['redirect']['diff_list']['dest']['users'][0]) || ! isset($_SESSION['redirect']['diff_list']['dest']['users'][0])) {
-            $_SESSION['action_error'] = _DEST . " " . _MANDATORY;
-            return false;
-        } else {
-            return true;
-        }
-    } elseif ($form_id == 'frm_redirect_user') {
-        $user = get_value_fields($values, 'user');
-        if ($user == '') {
-            $_SESSION['action_error'] = _MUST_CHOOSE_USER;
-            return false;
-        } else {
-            return true;
-        }
-    } else {
-        $_SESSION['action_error'] = _FORM_ERROR;
-        return false;
-    }
-}
-
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form)
-{
-    /*
-        Redirect to dep:
-        $values_form = array (size=3)
-          0 =>
-            array (size=2)
-              'ID' => string 'chosen_action' (length=13)
-              'VALUE' => string 'end_action' (length=10)
-          1 =>
-            array (size=2)
-              'ID' => string 'department' (length=10)
-              'VALUE' => string 'DGA' (length=3)
-          2 =>
-            array (size=2)
-              'ID' => string 'redirect_dep' (length=12)
-              'VALUE' => string 'Rediriger' (length=9)
-
-        Redirect to user:
-        $values_form = array (size=3)
-          0 =>
-            array (size=2)
-              'ID' => string 'chosen_action' (length=13)
-              'VALUE' => string 'end_action' (length=10)
-          1 =>
-            array (size=2)
-              'ID' => string 'user' (length=4)
-              'VALUE' => string 'aackermann' (length=10)
-          2 =>
-            array (size=2)
-              'ID' => string 'redirect_user' (length=13)
-              'VALUE' => string 'Rediriger' (length=9)
-
-    */
-    
-    if (empty($values_form) || count($arr_id) < 1) {
-        return false;
-    }
-    
-    include_once 'modules/entities/class/class_manage_listdiff.php';
-    $diffList = new diffusion_list();
-    
-    $db = new Database();
-    
-    $formValues = array();
-    for ($i=0; $i<count($values_form); $i++) {
-        $formValue = $values_form[$i];
-        $id = $formValue['ID'];
-        $value = $formValue['VALUE'];
-        $formValues[$id] = $value;
-    }
-    
-    // 1 : Redirect to user :
-    //   - create new listinstance from scratch with only dest user
-    //   - do not change destination
-    if (isset($formValues['redirect_user'])) {
-        $userId = $formValues['user'];
-
-        // Select new_dest user info
-        $stmt = $db->query(
-            "select u.user_id, u.firstname, u.lastname, e.entity_id, e.entity_label "
-            . "FROM " . $_SESSION['tablename']['users'] . " u, " . ENT_ENTITIES . " e, "
-            . ENT_USERS_ENTITIES . " ue WHERE u.status <> 'DEL' and u.status != 'SPD' and"
-            . " e.entity_id = ue.entity_id and u.user_id = ue.user_id and"
-            . " e.enabled = 'Y' and ue.primary_entity='Y' and u.user_id = ?",
-            array($userId)
-        );
-        $user = $stmt->fetchObject();
-        
-        // Create new listinstance
-        $_SESSION['redirect']['diff_list'] = array();
-        $_SESSION['redirect']['diff_list']['difflist_type'] = 'entity_id';
-        $_SESSION['redirect']['diff_list']['dest']['users'][0] = array(
-            'user_id' => $userId,
-            'lastname' => $user->lastname,
-            'firstname' => $user->firstname,
-            'entity_id' => $user->entity_id,
-            'viewed' => 0,
-            'visible' => 'Y',
-            'difflist_type' => 'entity_id'
-        );
-        $message = ' (' . _REDIRECT_TO_USER_OK . ': ' . $userId . ')';
-    } elseif (isset($formValues['redirect_dep'])) {
-        // 2 : Redirect to departement (+ dest user)
-        //   - listinstance has laready been loaded when selecting entity
-        //   - get entity_id that will update destination
-        $entityId = $formValues['department'];
-
-        $stmt = $db->query("SELECT entity_label FROM entities WHERE entity_id = ?", array($entityId));
-        $list = $stmt->fetchObject();
-        $entity_label = $list->entity_label;
-        $message = " (" . _REDIRECT_TO_DEP_OK . ": " . $entity_label . ')';
-    }
-    
-    // 1 + 2 :
-    //   - update dest_user
-    //   - move former dest user to copy if requested
-    //   - finally save listinstance
-    for ($i=0; $i<count($arr_id); $i++) {
-        $new_difflist = $_SESSION['redirect']['diff_list'];
-
-        // Fix lorsque l'on redirige vers une entité qui n'a pas de liste de diffusion par défaut
-        if (empty($new_difflist['difflist_type'])) {
-            $new_difflist['difflist_type'] = 'entity_id';
-        }
-
-        $res_id = $arr_id[$i];
-        // update dest_user
-        $new_dest = $new_difflist['dest']['users'][0]['user_id'];
-        if ($new_dest) {
-            if ($formValues['note_content_to_user'] != '') {
-                //Add notes
-                $userIdTypist = $_SESSION['user']['UserId'];
-                $content_note = $formValues['note_content_to_user'];
-                $content_note = str_replace(";", ".", $content_note);
-                $content_note = str_replace("--", "-", $content_note);
-                $content_note = str_replace("___", "\n", $content_note);
-
-                $stmt = $db->query(
-                    "INSERT INTO notes (identifier, user_id, "
-                            . "creation_date, note_text ) VALUES (?,?,CURRENT_TIMESTAMP,?)",
-                    array($res_id,$userIdTypist,$content_note)
-                );
-            }
-            
-            // Update destination if needed
-            $resEntities = \User\models\UserEntityModel::get(['select' => ['entity_id', 'primary_entity'], 'where' => ['user_id = ?'], 'data' => [$new_dest]]);
-            $mailDestination = \Resource\models\ResModel::getById(['select' => ['destination'], 'resId' => $res_id]);
-
-            $entityFound = false;
-            $primaryEntity = '';
-            foreach ($resEntities as $key => $value) {
-                if ($mailDestination['destination'] == $value['entity_id']) {
-                    $entityFound = true;
-                }
-                if ($value['primary_entity'] == 'Y') {
-                    $primaryEntity = $value['entity_id'];
-                }
-            }
-            if ($entityFound) {
-                $stmt = $db->query('update res_letterbox set dest_user = ? where res_id = ?', array($new_dest, $res_id));
-            } else {
-                $stmt = $db->query('update res_letterbox set dest_user = ?, destination = ? where res_id = ?', array($new_dest, $primaryEntity, $res_id));
-            }
-
-            // If new dest was in other roles, get number of views
-            $stmt = $db->query(
-                "select viewed"
-                . " from " . $_SESSION['tablename']['ent_listinstance']
-                . " where coll_id = ? and res_id = ? and item_type = 'user_id' and item_id = ?",
-                array($coll_id,$res_id,$new_dest)
-            );
-            $res = $stmt->fetchObject();
-            $viewed = $res->viewed;
-            $new_difflist['dest']['users'][0]['viewed'] = (integer)$viewed;
-        }
-
-        if ($formValues['note_content_to_dep'] != '') {
-            //Add notes
-            $userIdTypist = $_SESSION['user']['UserId'];
-            $content_note = $formValues['note_content_to_dep'];
-            $content_note = str_replace(";", ".", $content_note);
-            $content_note = str_replace("--", "-", $content_note);
-            $content_note = str_replace("___", "\n", $content_note);
-            
-            $stmt = $db->query(
-                "INSERT INTO notes (identifier, user_id, "
-                        . "creation_date, note_text ) VALUES (?,?,CURRENT_TIMESTAMP,?)",
-                array($res_id, $userIdTypist, $content_note)
-            );
-        }
-
-        $new_difflist = $diffList->list_difflist_roles_to_keep($res_id, $coll_id, $new_difflist['difflist_type'], $new_difflist);
-        
-        // If feature activated, put old dest in copy
-        $parameter = \Parameter\models\ParameterModel::getById(['select' => ['param_value_int'], 'id' => 'keepDestForRedirection']);
-        if (!empty($parameter['param_value_int'])) {
-            // Get old dest
-            $stmt = $db->query(
-                "select * "
-                . " from " . $_SESSION['tablename']['ent_listinstance']
-                . " where coll_id = ? and res_id = ? and item_type = 'user_id' and item_mode = 'dest'",
-                array($coll_id, $res_id)
-            );
-
-            $old_dest = $stmt->fetchObject();
-            
-            if ($old_dest) {
-                // try to find old dest in copies already
-                $found = false;
-                if (isset($new_difflist['copy']['users'])) {
-                    for ($ci=0; $ci<count($new_difflist['copy']['users']); $ci++) {
-                    
-                        // If in copies before, add number of views as dest to number of views as copy
-                        if ($new_difflist['copy']['users'][$ci]['user_id'] == $old_dest->item_id) {
-                            $found = true;
-                            $new_difflist['copy']['users'][$ci]['viewed'] =
-                                $new_difflist['copy']['users'][$ci]['viewed'] + (integer)$old_dest->viewed;
-                            break;
-                        }
-                    }
-                
-                    //re-built session without dest in copy
-                    $tab=array();
-                    for ($ci=0; $ci<count($new_difflist['copy']['users']); $ci++) {
-                        if ($new_difflist['copy']['users'][$ci]['user_id'] != $new_dest) {
-                            array_push(
-                            $tab,
-                            array(
-                        'user_id' => $new_difflist['copy']['users'][$ci]['user_id'],
-                        'viewed' => (integer)$new_difflist['copy']['users'][$ci]['viewed'],
-                        'visible' => 'Y',
-                        'difflist_type' => $new_difflist['copy']['users'][$ci]['viewed']
-                            )
-                        );
-                        }
-                    }
-                    $new_difflist['copy']['users']=$tab;
-                } else {
-                    if (!isset($new_difflist['copy'])) {
-                        $new_difflist['copy'] = array();
-                    }
-                    $new_difflist['copy']['users'] = array();
-                }
-                
-                if (!$found) {
-                    array_push(
-                        $new_difflist['copy']['users'],
-                        array(
-                        'user_id'       => $old_dest->item_id,
-                        'viewed'        => (integer)$old_dest->viewed,
-                        'visible'       => 'Y',
-                        'difflist_type' => $new_difflist['difflist_type']
-                        )
-                    );
-                }
-            }
-        }
-
-        // Save listinstance
-        $diffList->save_listinstance(
-            $new_difflist,
-            $new_difflist['difflist_type'],
-            $coll_id,
-            $res_id,
-            $_SESSION['user']['UserId'],
-            $_SESSION['user']['primaryentity']['id']
-        );
-    }
-    
-    // Pb with action chain : main action page is saved after this.
-    //   if process, $_SESSION['process']['diff_list'] will override this one
-    $_SESSION['ListDiffFromRedirect'] = true;
-    $_SESSION['process']['diff_list'] = $new_difflist;
-    $_SESSION['action_error'] = $message;
-    return array('result' => implode('#', $arr_id), 'history_msg' => $message);
-
-    // OLD SCRIPT
-    $list = new diffusion_list();
-    $arr_list = '';
-
-    for ($j=0; $j<count($values_form); $j++) {
-        $queryEntityLabel = "SELECT entity_label FROM entities WHERE entity_id=?";
-        $stmt = $db->query($queryEntityLabel, array($values_form[$j]['VALUE']));
-        while ($entityLabel = $stmt->fetchObject()) {
-            $zeEntityLabel = $entityLabel->entity_label;
-        }
-        $msg = _TO." : ".$zeEntityLabel." (".$values_form[$j]['VALUE'].")";
-        if ($values_form[$j]['ID'] == "department") {
-            for ($i=0; $i < count($arr_id); $i++) {
-                $arr_list .= $arr_id[$i].'#';
-                $stmt = $db->query("update ".$table." set destination = ? where res_id = ?", array($values_form[$j]['VALUE'],$arr_id[$i]));
-                if (isset($_SESSION['redirect']['diff_list']['dest']['users'][0]['user_id']) && !empty($_SESSION['redirect']['diff_list']['dest']['users'][0]['user_id'])) {
-                    $stmt = $db->query("update ".$table." set dest_user = ? where res_id = ?", array($_SESSION['redirect']['diff_list']['dest']['user_id'],$arr_id[$i]));
-                }
-                $newDestViewed = 0;
-                // Récupère le nombre de fois où le futur destinataire principal a vu le document
-                $stmt = $db->query("select viewed from ".$_SESSION['tablename']['ent_listinstance']." where coll_id = ? and res_id = ? and item_type = 'user_id' and item_id = ?", array($coll_id,$arr_id[$i],$_SESSION['redirect']['diff_list']['dest']['users'][0]['user_id']));
-                //$db->show();
-                $res = $stmt->fetchObject();
-                if ($res->viewed <> "") {
-                    $_SESSION['redirect']['diff_list']['dest']['users'][0]['viewed'] = $res->viewed;
-                    $newDestViewed = $res->viewed;
-                }
-                $parameter = \Parameter\models\ParameterModel::getById(['select' => ['param_value_int'], 'id' => 'keepDestForRedirection']);
-                if (!empty($parameter['param_value_int'])) {
-                    $lastDestViewed = 0;
-                    // Récupère le nombre de fois où l'ancien destinataire principal a vu le document
-                    $stmt = $db->query("select viewed from ".$_SESSION['tablename']['ent_listinstance']." where coll_id = ? and res_id = ? and item_type = 'user_id' and item_mode = 'dest'", array($coll_id,$arr_id[$i]));
- 
-                    $res = $stmt->fetchObject();
-                    if ($res->viewed <> "") {
-                        $lastDestViewed = $res->viewed;
-                    }
-                    for ($cptCopy=0;$cptCopy<count($_SESSION['redirect']['diff_list']['copy']['users']);$cptCopy++) {
-                        if ($_SESSION['redirect']['diff_list']['copy']['users'][$cptCopy]['user_id'] == $_SESSION['user']['UserId']) {
-                            $_SESSION['redirect']['diff_list']['copy']['users'][$cptCopy]['viewed'] = $lastDestViewed;
-                        }
-                    }
-                    array_push($_SESSION['redirect']['diff_list']['copy']['users'], array('user_id' => $_SESSION['user']['UserId'], 'lastname' => $_SESSION['user']['LastName'], 'firstname' => $_SESSION['user']['FirstName'], 'entity_id' => $_SESSION['user']['primaryentity']['id'], 'viewed' => $lastDestViewed));
-                }
-                $params = array('mode'=> 'listinstance', 'table' => $_SESSION['tablename']['ent_listinstance'], 'coll_id' => $coll_id, 'res_id' => $arr_id[$i], 'user_id' => $_SESSION['user']['UserId'], 'concat_list' => true);
-
-                $list->load_list_db($_SESSION['redirect']['diff_list'], $params);
-            }
-            $_SESSION['action_error'] = _REDIRECT_TO_DEP_OK;
-
-            return array('result' => $arr_list, 'history_msg' => $msg );
-        } elseif ($values_form[$j]['ID'] == "user") {
-            for ($i=0;$i<count($arr_id);$i++) {
-                // Update listinstance
-                $difflist['dest'] = array();
-                $difflist['copy'] = array();
-                $difflist['copy']['users'] = array();
-                $difflist['copy']['entities'] = array();
-                $difflist['dest']['users'][0]['user_id'] = $values_form[$j]['VALUE'];
-                $arr_list .= $arr_id[$i].'#';
-                // Récupère le nombre de fois où le futur destinataire principal a vu le document
-                $stmt = $db->query("select viewed from ".$_SESSION['tablename']['ent_listinstance']." where coll_id = ? and res_id = ? and item_type = 'user_id' and item_id = ?", array($coll_id,$arr_id[$i],$difflist['dest']['users'][0]['user_id']));
-                //$db->show();
-                $res = $stmt->fetchObject();
-                $newDestViewed = 0;
-                if ($res->viewed <> "") {
-                    $difflist['dest']['users'][0]['viewed'] = $res->viewed;
-                    $newDestViewed = $res->viewed;
-                }
-                // Récupère le nombre de fois où l'ancien destinataire principal a vu le document
-                $stmt = $db->query("select viewed from ".$_SESSION['tablename']['ent_listinstance']." where coll_id = ? and res_id = ? and item_type = 'user_id' and item_mode = 'dest'", array($coll_id,$arr_id[$i]));
-
-                $res = $stmt->fetchObject();
-                $lastDestViewed = 0;
-                if ($res->viewed <> "") {
-                    $lastDestViewed = $res->viewed;
-                }
-                // Update dest_user in res table
-                $stmt = $db->query("update ".$table." set dest_user = ? where res_id = ?", array($values_form[$j]['VALUE'],$arr_id[$i]));
-                $list->set_main_dest($values_form[$j]['VALUE'], $coll_id, $arr_id[$i], 'DOC', 'user_id', $newDestViewed);
-                $parameter = \Parameter\models\ParameterModel::getById(['select' => ['param_value_int'], 'id' => 'keepDestForRedirection']);
-                if (!empty($parameter['param_value_int'])) {
-                    array_push($difflist['copy']['users'], array('user_id' => $_SESSION['user']['UserId'], 'lastname' => $_SESSION['user']['LastName'], 'firstname' => $_SESSION['user']['FirstName'], 'entity_id' => $_SESSION['user']['primaryentity']['id'], 'viewed' => $lastDestViewed));
-                }
-                $params = array('mode'=> 'listinstance', 'table' => $_SESSION['tablename']['ent_listinstance'], 'coll_id' => $coll_id, 'res_id' => $arr_id[$i], 'user_id' => $_SESSION['user']['UserId'], 'concat_list' => true);
-                $list->load_list_db($difflist, $params);
-            }
-            $_SESSION['action_error'] = _REDIRECT_TO_USER_OK;
-            return array('result' => $arr_list, 'history_msg' => $msg);
-        }
-    }
-    return false;
-}
-
- /**
- * Get the value of a given field in the values returned by the form
- *
- * @param $values Array Values of the form to check
- * @param $field String the field
- * @return String the value, false if the field is not found
- **/
-function get_value_fields($values, $field)
-{
-    for ($i=0; $i<count($values);$i++) {
-        if ($values[$i]['ID'] == $field) {
-            return  $values[$i]['VALUE'];
-        }
-    }
-    return false;
-}
diff --git a/modules/visa/interrupt_visa.php b/modules/visa/interrupt_visa.php
deleted file mode 100755
index d2d72334f8141f3f3c7584609715bd49d1350ded..0000000000000000000000000000000000000000
--- a/modules/visa/interrupt_visa.php
+++ /dev/null
@@ -1,52 +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   interrupt_visa
-* @author  dev <dev@maarch.org>
-* @ingroup visa
-*/
-
-require_once 'modules/visa/class/class_modules_tools.php';
-$visa = new visa();
-
-if ($visa->currentUserSignRequired($_SESSION['doc_id']) == 'true') {
-    $label_action .=" ("._NO_USER_SIGNED_DOC.")";
-}
-
-$confirm = true;
-$etapes = ['empty_error'];
-
-function manage_empty_error($arr_id, $history, $id_action, $label_action, $status)
-{
-    $db = new Database();
-    $_SESSION['action_error'] = '';
-    $coll_id = $_SESSION['current_basket']['coll_id'];
-    $res_id = $arr_id[0];
-    $circuit_visa = new visa();
-    $sequence = $circuit_visa->getCurrentStep($res_id, $coll_id, 'VISA_CIRCUIT');
-    $stepDetails = $circuit_visa->getStepDetails($res_id, $coll_id, 'VISA_CIRCUIT', $sequence);
-
-    // Person who ends the workflow
-    if ($stepDetails['listinstance_id']) {
-        $db->query(
-            'UPDATE listinstance SET process_date = CURRENT_TIMESTAMP, process_comment = ? WHERE listinstance_id = ? AND item_id = ? AND res_id = ? AND difflist_type = ?',
-            ["A terminé le circuit avec l'action {$label_action}", $stepDetails['listinstance_id'], $stepDetails['item_id'], $res_id, 'VISA_CIRCUIT']
-        );
-    } else {
-        $db->query(
-            'UPDATE listinstance SET process_date = CURRENT_TIMESTAMP, process_comment = ? WHERE res_id = ? AND difflist_type = ? AND item_mode = ?',
-            ["A terminé le circuit avec l'action {$label_action}", $res_id, 'VISA_CIRCUIT', 'sign']
-        );
-    }
-
-    // People remaining in the workflow
-    $db->query(
-        'UPDATE listinstance SET process_date = CURRENT_TIMESTAMP, process_comment = ? WHERE res_id = ? AND difflist_type = ? AND process_date IS NULL',
-        ['Circuit Interrompu', $res_id, 'VISA_CIRCUIT']
-    );
-    return array('result' => $res_id.'#', 'history_msg' => '');
-}
-?>
diff --git a/modules/visa/rejection_visa_previous.php b/modules/visa/rejection_visa_previous.php
deleted file mode 100755
index 9409f082aab1af741f5d54212068af192fa1e806..0000000000000000000000000000000000000000
--- a/modules/visa/rejection_visa_previous.php
+++ /dev/null
@@ -1,162 +0,0 @@
-<?php
-
-
-$confirm    = false;
-$etapes     = ['form', 'empty_error'];
-$frm_width  = '355px';
-$frm_height = 'auto';
-
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    require('modules/entities/entities_tables.php');
-    require_once('modules/entities/class/EntityControler.php');
-    require_once('apps/' . $_SESSION['config']['app_id'] . '/class/class_chrono.php');
-
-    $db                 = new Database();
-    $cr7                = new chrono();
-    $entity_ctrl        = new EntityControler();
-
-    $servicesCompare    = [];
-    $labelAction        = '';
-
-    if ($id_action != '') {
-        $stmt = $db->query('select label_action from actions where id = ?', [$id_action]);
-        $resAction = $stmt->fetchObject();
-        $labelAction = functions::show_string($resAction->label_action);
-    }
-
-    $frm_str = '<div id="frm_error_'.$id_action.'" class="error"></div>';
-    if ($labelAction != '') {
-        $frm_str .= '<h2 class="title">' . $labelAction . ' ' . _NUM;
-    } else {
-        $frm_str .= '<h2 class="title">' . _REDIRECT_MAIL . ' ' ._NUM;
-    }
-    $values_str = '';
-    if(empty($_SESSION['stockCheckbox'])) {
-        for($i=0; $i < count($values); $i++)
-        {
-            $values_str .= $values[$i] . ', ';
-        }
-    } else {
-
-        for($i=0; $i < count($_SESSION['stockCheckbox']); $i++)
-        {
-            $values_str .= $_SESSION['stockCheckbox'][$i].', ';
-        }
-    }
-
-    $values_str = preg_replace('/, $/', '', $values_str);
-    if(_ID_TO_DISPLAY == 'res_id'){
-        $frm_str .= $values_str;
-    } else if (_ID_TO_DISPLAY == 'chrono_number'){
-        $chrono_number = $cr7->get_chrono_number($values_str, 'res_view_letterbox');
-        $frm_str .= $chrono_number;
-    }
-
-    $frm_str .= '</h2><br/>';
-    require 'modules/templates/class/templates_controler.php';
-    $templatesControler = new templates_controler();
-
-    $EntitiesIdExclusion = [];
-    $entities = $entity_ctrl->getAllEntities();
-    $countEntities = count($entities);
-
-    for ($cptAllEnt = 0;$cptAllEnt<$countEntities;$cptAllEnt++) {
-        if (!is_integer(array_search($entities[$cptAllEnt]->__get('entity_id'), $servicesCompare))) {
-            array_push($EntitiesIdExclusion, $entities[$cptAllEnt]->__get('entity_id'));
-        }
-    }
-
-    $templates = $templatesControler->getAllTemplatesForSelect();
-    $frm_str .='<br/><b>'. _NOTES .':</b><br/>';
-    $frm_str .= '<select name="templateNotes" id="templateNotes" style="width:98%;margin-bottom: 10px;background-color: White;border: 1px solid #999;color: #666;text-align: left;" '
-        . 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
-        . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-        . '&module=templates&page=templates_ajax_content_for_notes\');document.getElementById(\'notes\').focus();">';
-    $frm_str .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
-    for ($i=0;$i<count($templates);$i++) {
-        if ($templates[$i]['TYPE'] == 'TXT' && ($templates[$i]['TARGET'] == 'notes' || $templates[$i]['TARGET'] == '')) {
-            $frm_str .= '<option value="';
-            $frm_str .= $templates[$i]['ID'];
-            $frm_str .= '">';
-            $frm_str .= $templates[$i]['LABEL'];
-        }
-        $frm_str .= '</option>';
-    }
-    $frm_str .= '</select><br />';
-
-    $frm_str .= '<textarea style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="document.getElementById(\'note_content_to_users\').value = document.getElementById(\'notes\').value;"></textarea>';
-    $frm_str .= '<div id="form2" style="border:none;">';
-    $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-    $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-    $frm_str .= '<input type="hidden" name="note_content_to_users" id="note_content_to_users" />';
-    $frm_str .= '</form>';
-    $frm_str .= '</div>';
-    $frm_str .= '<hr />';
-
-    $frm_str .= '<div align="center">';
-    $frm_str .= ' <input type="button" name="redirect_dep" value="'._VALIDATE.'" id="redirect_dep" class="button" onclick="valid_action_form( \'frm_redirect_dep\', \''.$path_manage_action.'\', \''. $id_action.'\', \''.$values_str.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');" />';
-    $frm_str .= ' <input type="button" name="cancel" id="cancel" class="button"  value="'._CANCEL.'" onclick="pile_actions.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>';
-    $frm_str .= '</div>';
-
-    return addslashes($frm_str);
-}
-
-function check_form($form_id, $values)
-{
-    return true;
-}
-
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form )
-{
-    if(empty($values_form) || count($arr_id) < 1)
-        return false;
-
-    require_once('modules/notes/class/notes_controler.php');
-    $note = new notes_controler();
-
-    $coll_id    = $_SESSION['current_basket']['coll_id'];
-    $res_id     = $arr_id[0];
-
-    $formValues = [];
-    for($i = 0; $i < count($values_form); $i++) {
-        $id = $values_form[$i]['ID'];
-        $formValues[$id] = $values_form[$i]['VALUE'];
-    }
-
-    # save note
-    if($formValues['note_content_to_users'] != ''){
-        //Add notes
-        $note->addNote($res_id, $coll_id, $formValues['note_content_to_users']);
-    }
-
-    return array('result' => $res_id.'#', 'history_msg' => '');
-}
-
-function manage_empty_error($arr_id, $history, $id_action, $label_action, $status)
-{
-    $db = new Database();
-    $_SESSION['action_error'] = '';
-    $res_id = $arr_id[0];
-
-    $where = "res_id = ? and difflist_type = ? AND process_date IS NOT NULL";
-    $order = "ORDER BY process_date DESC";
-    $query = $db->limit_select(0, 1, 'listinstance_id, requested_signature', 'listinstance', $where, '', '', $order);
-
-    $stmt = $db->query($query,[$res_id, 'VISA_CIRCUIT']);
-
-    if ($stmt->rowCount() > 0) {
-        $listInstance = $stmt->fetchObject();
-        $db->query('UPDATE listinstance SET process_date = NULL WHERE res_id = ? AND difflist_type = ? AND listinstance_id = ?',
-            [$res_id, 'VISA_CIRCUIT', $listInstance->listinstance_id]);
-        if ($listInstance->requested_signature) {
-            $newStatus = 'ESIG';
-        } else {
-            $newStatus = 'EVIS';
-        }
-        $db->query("UPDATE res_letterbox SET status = ? WHERE res_id = ? ", [$newStatus, $res_id]);
-    }
-
-    return array('result' => $res_id.'#', 'history_msg' => $label_action);
-}
-
diff --git a/modules/visa/rejection_visa_redactor.php b/modules/visa/rejection_visa_redactor.php
deleted file mode 100755
index f71f07e0dd429040ea041776d141bed2564bd0ca..0000000000000000000000000000000000000000
--- a/modules/visa/rejection_visa_redactor.php
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-
-$confirm    = false;
-$etapes     = ['form', 'empty_error'];
-$frm_width  = '355px';
-$frm_height = 'auto';
-
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    require('modules/entities/entities_tables.php');
-    require_once('modules/entities/class/EntityControler.php');
-    require_once('apps/' . $_SESSION['config']['app_id'] . '/class/class_chrono.php');
-
-    $db                 = new Database();
-    $cr7                = new chrono();
-    $entity_ctrl        = new EntityControler();
-
-    $servicesCompare    = [];
-    $labelAction        = '';
-
-    if ($id_action != '') {
-        $stmt = $db->query('select label_action from actions where id = ?', [$id_action]);
-        $resAction = $stmt->fetchObject();
-        $labelAction = functions::show_string($resAction->label_action);
-    }
-
-    $frm_str = '<div id="frm_error_'.$id_action.'" class="error"></div>';
-    if ($labelAction != '') {
-        $frm_str .= '<h2 class="title">' . $labelAction . ' ' . _NUM;
-    } else {
-        $frm_str .= '<h2 class="title">' . _REDIRECT_MAIL . ' ' ._NUM;
-    }
-    $values_str = '';
-    if (empty($_SESSION['stockCheckbox'])) {
-        for ($i=0; $i < count($values); $i++) {
-            $values_str .= $values[$i] . ', ';
-        }
-    } else {
-        for ($i=0; $i < count($_SESSION['stockCheckbox']); $i++) {
-            $values_str .= $_SESSION['stockCheckbox'][$i].', ';
-        }
-    }
-
-    $values_str = preg_replace('/, $/', '', $values_str);
-    if (_ID_TO_DISPLAY == 'res_id') {
-        $frm_str .= $values_str;
-    } elseif (_ID_TO_DISPLAY == 'chrono_number') {
-        $chrono_number = $cr7->get_chrono_number($values_str, 'res_view_letterbox');
-        $frm_str .= $chrono_number;
-    }
-
-    $frm_str .= '</h2><br/>';
-    require 'modules/templates/class/templates_controler.php';
-    $templatesControler = new templates_controler();
-
-    $EntitiesIdExclusion = [];
-    $entities = $entity_ctrl->getAllEntities();
-    $countEntities = count($entities);
-
-    for ($cptAllEnt = 0;$cptAllEnt<$countEntities;$cptAllEnt++) {
-        if (!is_integer(array_search($entities[$cptAllEnt]->__get('entity_id'), $servicesCompare))) {
-            array_push($EntitiesIdExclusion, $entities[$cptAllEnt]->__get('entity_id'));
-        }
-    }
-
-    $templates = $templatesControler->getAllTemplatesForSelect();
-    $frm_str .='<br/><b>'. _NOTES .':</b><br/>';
-    $frm_str .= '<select name="templateNotes" id="templateNotes" style="width:98%;margin-bottom: 10px;background-color: White;border: 1px solid #999;color: #666;text-align: left;" '
-        . 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
-        . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-        . '&module=templates&page=templates_ajax_content_for_notes\');document.getElementById(\'notes\').focus();">';
-    $frm_str .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
-    for ($i=0;$i<count($templates);$i++) {
-        if ($templates[$i]['TYPE'] == 'TXT' && ($templates[$i]['TARGET'] == 'notes' || $templates[$i]['TARGET'] == '')) {
-            $frm_str .= '<option value="';
-            $frm_str .= $templates[$i]['ID'];
-            $frm_str .= '">';
-            $frm_str .= $templates[$i]['LABEL'];
-        }
-        $frm_str .= '</option>';
-    }
-    $frm_str .= '</select><br />';
-
-    $frm_str .= '<textarea style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="document.getElementById(\'note_content_to_users\').value = document.getElementById(\'notes\').value;"></textarea>';
-    $frm_str .= '<div id="form2" style="border:none;">';
-    $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-    $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-    $frm_str .= '<input type="hidden" name="note_content_to_users" id="note_content_to_users" />';
-    $frm_str .= '</form>';
-    $frm_str .= '</div>';
-    $frm_str .= '<hr />';
-
-    $frm_str .= '<div align="center">';
-    $frm_str .= ' <input type="button" name="redirect_dep" value="'._VALIDATE.'" id="redirect_dep" class="button" onclick="valid_action_form( \'frm_redirect_dep\', \''.$path_manage_action.'\', \''. $id_action.'\', \''.$values_str.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');" />';
-    $frm_str .= ' <input type="button" name="cancel" id="cancel" class="button"  value="'._CANCEL.'" onclick="pile_actions.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>';
-    $frm_str .= '</div>';
-
-    return addslashes($frm_str);
-}
-
-function check_form($form_id, $values)
-{
-    return true;
-}
-
-function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form)
-{
-    if (empty($values_form) || count($arr_id) < 1) {
-        return false;
-    }
-
-    require_once('modules/notes/class/notes_controler.php');
-    $note = new notes_controler();
-
-    $coll_id    = $_SESSION['current_basket']['coll_id'];
-    $res_id     = $arr_id[0];
-
-    $formValues = [];
-    for ($i = 0; $i < count($values_form); $i++) {
-        $id = $values_form[$i]['ID'];
-        $formValues[$id] = $values_form[$i]['VALUE'];
-    }
-
-    # save note
-    if ($formValues['note_content_to_users'] != '') {
-        //Add notes
-        $note->addNote($res_id, $coll_id, $formValues['note_content_to_users']);
-    }
-
-    return array('result' => $res_id.'#', 'history_msg' => '');
-}
-
-function manage_empty_error($arr_id, $history, $id_action, $label_action, $status)
-{
-    $db = new Database();
-    $_SESSION['action_error'] = '';
-    $res_id = $arr_id[0];
-
-    $db->query('UPDATE listinstance SET process_date = NULL WHERE res_id = ? AND difflist_type = ?', [$res_id, 'VISA_CIRCUIT']);
-
-    return array('result' => $res_id.'#', 'history_msg' => '');
-}
diff --git a/modules/visa/send_to_visa.php b/modules/visa/send_to_visa.php
deleted file mode 100755
index e05d705c7924a4f8e6553d6a13e22e17af4faf14..0000000000000000000000000000000000000000
--- a/modules/visa/send_to_visa.php
+++ /dev/null
@@ -1,78 +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 "modules" . DIRECTORY_SEPARATOR . "visa" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php";
-/**
-* $confirm  bool true
-*/
- 
-$error_visa = false;
-$error_visa_response_project = false;
-
-if (isset($_SESSION['error_visa']) && $_SESSION['error_visa'] <> '') {
-    $error_visa = true;
-}
-
-$visa = new visa();
-$curr_visa_wf = $visa->getWorkflow($_SESSION['doc_id'], $_SESSION['current_basket']['coll_id'], 'VISA_CIRCUIT');
-
-if (empty($curr_visa_wf['visa']) && empty($curr_visa_wf['sign'])) {
-    $error_visa = true;
-    //IF NO VISA WF CHECK VISA MODEL
-    include_once "modules/entities/class/class_manage_listdiff.php";
-    $diff_list = new diffusion_list();
-    $db = new Database();
-    $stmt = $db->query("SELECT destination from res_letterbox WHERE res_id = ?", array($_SESSION['doc_id']));
-    $res = $stmt->fetchObject();
-    $listModel = $diff_list->get_listmodel('VISA_CIRCUIT', $res->destination);
-    if ($listModel != false) {
-        $visa->saveWorkflow($_SESSION['doc_id'], 'letterbox_coll', $listModel, 'VISA_CIRCUIT');
-        $error_visa = false;
-    }
-}
-
-
-$visa->checkResponseProject($_SESSION['doc_id'], $_SESSION['current_basket']['coll_id']);
-if ($visa->errorMessageVisa) {
-    $error_visa_response_project = true;
-}
-
-$confirm = true;
-/**
-* $etapes  array Contains only one etap, the status modification
-*/
-$etapes = array('empty_error');
- 
-function manage_empty_error($arr_id, $history, $id_action, $label_action, $status)
-{
-    $_SESSION['action_error'] = '';
-    $result = '';
-    $res_id = $arr_id[0];
-
-    $visa = new visa();
-    $visa->setStatusVisa($_SESSION['doc_id'], $_SESSION['current_basket']['coll_id']);
-
-    // for($i=0; $i<count($arr_id );$i++)
-    // {
-    // 	$result .= $arr_id[$i].'#';
-    // }
-    return array('result' => $res_id.'#', 'history_msg' => '');
-}
diff --git a/modules/visa/visa_workflow.php b/modules/visa/visa_workflow.php
deleted file mode 100755
index 13003cc724365210a9faa077384e53f90c596963..0000000000000000000000000000000000000000
--- a/modules/visa/visa_workflow.php
+++ /dev/null
@@ -1,85 +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   visa_workflow
-*
-* @author  dev <dev@maarch.org>
-* @ingroup visa
-*/
-require_once 'modules/visa/class/class_modules_tools.php';
-$db = new Database();
-$visa = new visa();
-$confirm = true;
-$warnMsg = '';
-
-$error_visa_workflow_signature_book = false;
-$isMailingAttach = \Attachment\controllers\AttachmentController::isMailingAttach(["resIdMaster" => $_SESSION['doc_id'], "login" => $_SESSION['user']['UserId']]);
-
-if ($visa->isAllAttachementSigned($_SESSION['doc_id']) == 'noAttachment') {
-    $error_visa_workflow_signature_book = true;
-} elseif ($visa->currentUserSignRequired($_SESSION['doc_id']) == 'true') {
-    $warnMsg = _NO_USER_SIGNED_DOC;
-} else if ($isMailingAttach != false) {
-    $warnMsg = $isMailingAttach['nbContacts'] . " " . _RESPONSES_WILL_BE_GENERATED;
-}
-
-$stmt = $db->query("SELECT 1 FROM listinstance WHERE res_id = ? AND (item_mode = 'visa' OR item_mode = 'sign') AND process_date IS NULL", [$_SESSION['doc_id']]);
-$res = $stmt->fetchAll();
-if (empty($res) || count($res) < 2) {
-    $error_visa_workflow = true;
-}
-
-$etapes = ['empty_error'];
-
-function manage_empty_error($arr_id, $history, $id_action, $label_action, $status)
-{
-    $db = new Database();
-    $result = '';
-
-    if (!empty($_SESSION['stockCheckbox'])) {
-        $arr_id = $_SESSION['stockCheckbox'];
-    }
-
-    for ($i = 0; $i < count($arr_id); ++$i) {
-        $_SESSION['action_error'] = '';
-        $coll_id = $_SESSION['current_basket']['coll_id'];
-        $res_id = $arr_id[$i];
-        include_once 'core/class/class_security.php';
-        $sec = new security();
-        include_once 'core/class/class_history.php';
-        $history = new history();
-        $table = $sec->retrieve_table_from_coll($coll_id);
-        $circuit_visa = new visa();
-        $sequence = $circuit_visa->getCurrentStep($res_id, $coll_id, 'VISA_CIRCUIT');
-        $stepDetails = array();
-        $stepDetails = $circuit_visa->getStepDetails($res_id, $coll_id, 'VISA_CIRCUIT', $sequence);
-
-        $message = $circuit_visa->processVisaWorkflow(['stepDetails' => $stepDetails, 'res_id' => $res_id]);
-
-        $stmt = $db->query('SELECT status FROM res_letterbox WHERE res_id = ?', array($res_id));
-        $resource = $stmt->fetchObject();
-        if ($resource->status == 'EVIS' || $resource->status == 'ESIG') {
-            $circuit_visa->setStatusVisa($res_id, 'letterbox_coll');
-        }
-
-        //USEFULL FOR SPM PARAM (can set SIGN WITH OTHER STATUS)
-        $stmt = $db->query(
-            'select count(1) as total FROM listinstance '
-            .' WHERE item_mode = ? AND res_id = ? AND difflist_type = ? AND requested_signature = ?',
-            array('sign', $res_id, 'VISA_CIRCUIT', true)
-        );
-        $res = $stmt->fetchObject();
-        if ($res->total > 0 && $circuit_visa->getCurrentStep($res_id, $coll_id, 'VISA_CIRCUIT') == $circuit_visa->nbVisa($res_id, $coll_id)) {
-            $mailStatus = 'ESIG';
-            $db->query('UPDATE res_letterbox SET status = ? WHERE res_id = ? ', [$mailStatus, $res_id]);
-        }
-
-        $result .= $arr_id[$i].'#';
-    }
-
-    return array('result' => $result, 'history_msg' => $message);
-}