From dcfd0be5266f2faeeec5d4c89161646b35d04c40 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Wed, 5 Jul 2017 17:17:06 +0100
Subject: [PATCH] FEAT #5661 status administration MVC => historique

---
 .../admin/status/status_list_by_name.php      |  61 ---
 .../admin/status/status_management.php        | 212 ---------
 .../status/status_management_controler.php    | 413 ------------------
 .../xml/IVS/requests_definitions.xml          |  11 -
 apps/maarch_entreprise/xml/services.xml       |   3 +-
 apps/maarch_entreprise/xml/status.xml         |  75 ----
 core/Controllers/HistoryController.php        |   6 +-
 7 files changed, 5 insertions(+), 776 deletions(-)
 delete mode 100644 apps/maarch_entreprise/admin/status/status_list_by_name.php
 delete mode 100755 apps/maarch_entreprise/admin/status/status_management.php
 delete mode 100755 apps/maarch_entreprise/admin/status/status_management_controler.php
 delete mode 100644 apps/maarch_entreprise/xml/status.xml

diff --git a/apps/maarch_entreprise/admin/status/status_list_by_name.php b/apps/maarch_entreprise/admin/status/status_list_by_name.php
deleted file mode 100644
index 0a56d047e0d..00000000000
--- a/apps/maarch_entreprise/admin/status/status_list_by_name.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-/*
-*    Copyright 2008,2009 Maarch
-*
-*  This file is part of Maarch Framework.
-*
-*   Maarch Framework is free software: you can redistribute it and/or modify
-*   it under the terms of the GNU General Public License as published by
-*   the Free Software Foundation, either version 3 of the License, or
-*   (at your option) any later version.
-*
-*   Maarch Framework is distributed in the hope that it will be useful,
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*   GNU General Public License for more details.
-*
-*   You should have received a copy of the GNU General Public License
-*    along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/**
-* @brief List of status for autocompletion
-*
-*
-* @file
-* @author  Laurent Giovannoni  <dev@maarch.org>
-* @date $date$
-* @version $Revision$
-* @ingroup admin
-*/
-
-require_once('core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR
-             . 'class_request.php');
-$db = new Database();
-
-$stmt = $db->query(
-        'SELECT label_status as tag FROM ' .
-        $_SESSION['tablename']['status'] . " WHERE lower(label_status) like lower(?) order by label_status",
-        array($_REQUEST['what'].'%')
-    );
-$listArray = array();
-while ($line = $stmt->fetchObject()) {
-    array_push($listArray, $line->tag);
-}
-echo '<ul>';
-$authViewList = 0;
-
-foreach ($listArray as $what) {
-    if ($authViewList >= 10) {
-        $flagAuthView = true;
-    }
-    if (stripos($what, $_REQUEST['what']) === 0) {
-        echo '<li>'.$what.'</li>';
-        if (isset($flagAuthView) && $flagAuthView) {
-            echo '<li>...</li>\n';
-            break;
-        }
-        $authViewList++;
-    }
-}
-echo '</ul>';
\ No newline at end of file
diff --git a/apps/maarch_entreprise/admin/status/status_management.php b/apps/maarch_entreprise/admin/status/status_management.php
deleted file mode 100755
index a06891c8804..00000000000
--- a/apps/maarch_entreprise/admin/status/status_management.php
+++ /dev/null
@@ -1,212 +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.
-*
-*/
-
-/*RÊcupÊration de status*/
-require_once 'core/class/class_manage_status.php';
-if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR."apps".DIRECTORY_SEPARATOR."maarch_entreprise"
-    .DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."status.xml"))
-{
-  $path = $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR."apps".DIRECTORY_SEPARATOR."maarch_entreprise"
-  .DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."status.xml";
-} else {
-  $path = "apps".DIRECTORY_SEPARATOR."maarch_entreprise".DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."status.xml";
-}
-$xmlconfig = simplexml_load_file($path);
-
-if ($xmlconfig <> false) {
-	$result = $xmlconfig->xpath('/ROOT/status');
-    foreach ($result as $key => $value) {
-      $status_img[]=$value->img_filename;
-  }
-} 
-
-$status_obj = new manage_status();
-$i=0;
-
-/* Affichage */
-if ($mode == 'list') {
-    $list = new list_show();
-    $list->admin_list(
-        $statusList['tab'],
-        count($statusList['tab']),
-        $statusList['title'],
-        'id',
-        'status_management_controler&mode=list',
-        'status','id',
-        true,
-        $statusList['page_name_up'],
-        $statusList['page_name_val'],
-        $statusList['page_name_ban'],
-        $statusList['page_name_del'],
-        $statusList['page_name_add'],
-        $statusList['label_add'],
-        false,
-        false,
-        _ALL_STATUS,
-        _STATUS,
-        'check-circle',
-        false,
-        true,
-        false,
-        true,
-        $statusList['what'],
-        true,
-        $statusList['autoCompletionArray']
-        );
-} elseif ($mode == 'up' || $mode == 'add') {
-    ?><h1><i class="fa fa-check-circle fa-2x"></i>
-    <?php
-    if ($mode == 'up') {
-        echo _MODIFY_STATUS;
-    } elseif ($mode == 'add') {
-        echo _ADD_STATUS;
-    }?>
-</h1>
-<div id="inner_content" class="clearfix" align="center">
-    <?php
-    if ($state == false) {
-        echo '<br /><br /><br /><br />' . _THE_STATUS . ' ' . _UNKNOWN
-        . '<br /><br /><br /><br />';
-    } else {?>
-    <div class="block">
-        <form name="frmstatus" id="frmstatus" method="post" action="<?php
-        echo $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-        . '&amp;admin=status&amp;page=status_management_controler&amp;mode='
-        . $mode;?>" class="forms addforms">
-        <input type="hidden" name="display" value="true" />
-        <input type="hidden" name="admin" value="status" />
-        <input type="hidden" name="page" value="status_management_controler" />
-        <input type="hidden" name="mode" value="<?php functions::xecho($mode);?>" />
-
-        <input type="hidden" name="order" id="order" value="<?php
-        functions::xecho($_REQUEST['order']);?>" />
-        <input type="hidden" name="order_field" id="order_field" value="<?php
-        functions::xecho($_REQUEST['order_field']);?>" />
-        <input type="hidden" name="what" id="what" value="<?php
-        functions::xecho($_REQUEST['what']);?>" />
-        <input type="hidden" name="start" id="start" value="<?php
-        functions::xecho($_REQUEST['start']);?>" />
-        <input type="hidden" name="is_system" id="is_system" value="<?php
-        functions::xecho($_SESSION['m_admin']['status']['is_system']);?>" />
-        <p>
-            <label for="status_id"><?php echo _ID;?> : </label>
-            <input name="status_id" type="text"  id="status_id" value="<?php
-            echo functions::show_str(
-                $_SESSION['m_admin']['status']['id']
-                );?>" <?php
-if ($mode == 'up') {
-    echo 'readonly="readonly" class="readonly"';
-}?>/>
-</p>
-<p>
-    <label for="label"><?php echo _DESC;?> : </label>
-    <input name="label" type="text"  id="label" value="<?php
-    echo functions::show_str(
-        $_SESSION['m_admin']['status']['label_status']
-        );?>"/>
-    </p>
-    <p>
-        <label ><?php echo _CAN_BE_SEARCHED;?> : </label>
-        <input type="radio"  class="check" name="can_be_searched" value="Y"<?php
-        if ($_SESSION['m_admin']['status']['can_be_searched'] == 'Y') {
-           ?> checked="checked"<?php
-       } ?> /><?php echo _YES;?>
-       <input type="radio" name="can_be_searched" class="check" value="N"
-       <?php
-       if ($_SESSION['m_admin']['status']['can_be_searched'] == 'N') {
-         ?> checked="checked"<?php
-     } ?> /><?php echo _NO;?>
- </p>
- <p>
-    <label ><?php echo _CAN_BE_MODIFIED;?> : </label>
-    <input type="radio"  class="check" name="can_be_modified" value="Y"
-    <?php
-    if ($_SESSION['m_admin']['status']['can_be_modified'] == 'Y') {
-        ?> checked="checked"<?php
-    } ?> /><?php echo _YES;?>
-    <input type="radio" name="can_be_modified" class="check"  value="N"
-    <?php
-    if ($_SESSION['m_admin']['status']['can_be_modified'] == 'N') {
-     ?> checked="checked"<?php
- } ?> /><?php echo _NO;?>
- 
- <input name="img_filename" type="hidden"  id="img_filename" value="<?php
- echo functions::show_str(
-    $_SESSION['m_admin']['status']['img_filename']
-    );?>" <?php
-                /* if ($mode == 'up') {
-                    echo 'readonly="readonly" class="readonly"';
-                } */?>/>
-            </p>
-            <?php
-            $core_tools = new core_tools();
-            if ($core_tools->is_module_loaded('folder')) {
-                ?>
-                <p>
-                    <label ><?php echo _IS_FOLDER_STATUS;?> : </label>
-                    <input type="radio"  class="check" name="is_folder_status" value="Y"
-                    <?php
-                    if ($_SESSION['m_admin']['status']['is_folder_status'] == 'Y') {
-                        ?> checked="checked"<?php
-                    } ?> /><?php echo _YES;?>
-                    <input type="radio" name="is_folder_status" class="check"  value="N"
-                    <?php
-                    if ($_SESSION['m_admin']['status']['is_folder_status'] == 'N') {
-                     ?> checked="checked"<?php
-                 } ?> /><?php echo _NO;?>
-             </p>
-             <?php } ?>
-             <div>
-                <label ><?php echo _IMG_RELATED;?> : </label>
-                <ul style="  width: auto;text-align: left;float: left;margin-left: 40px;height: auto;overflow: auto;">
-                    <?php 
-                    $nb_status=count($status_img);
-                    for ($i=0;$i<$nb_status;$i++) {  ?>  
-                        <li style="display:inline-block;width:50px;padding:5px;" title="fm <?php functions::xecho($status_img[$i]);?>" onclick="check_status('<?php functions::xecho($nb_status);?>', '<?php functions::xecho($i);?>')"> 	
-                          <input type="radio" style="visibility:hidden;" id="radio_<?php functions::xecho($i);?>" class="check" name="img_related" value="<?php functions::xecho($status_img[$i])?>" 
-                          <?php if ($_SESSION['m_admin']['status']['img_filename'] == $status_img[$i]) { ?> checked="checked" <?php } ?> onload="check_status('<?php functions::xecho($nb_status);?>', '<?php functions::xecho($i);?>')" /><?php
-                          $img = "<label for='".$status_img[$i]."' ><i id='img_".$i."' class = 'fm ".$status_img[$i]."' style='font-size:20px;'></i></label>";
-                          if ($_SESSION['m_admin']['status']['img_filename'] == $status_img[$i]) {
-                            $img = "<label for='".$status_img[$i]."' ><i id='img_".$i."' class = 'fm ".$status_img[$i]."' style='font-size:20px;color:#009dc5;'></i></label>";
-                        }else{
-                            $img = "<label for='".$status_img[$i]."' ><i id='img_".$i."' class = 'fm ".$status_img[$i]."' style='font-size:20px;'></i></label>"; 
-                        }
-
-                        echo $img;
-                        echo "</li>";
-                    } ?>
-         </ul>
-     </div>	
-     
-     <p class="buttons">
-
-        <input type="submit" class="button"  name="status_submit" value="<?php echo _VALIDATE;?>" />
-
-        <input type="button" class="button"  name="cancel" value="<?php
-        echo _CANCEL;?>" onclick="javascript:window.location.href='<?php
-        echo $_SESSION['config']['businessappurl'];
-        ?>index.php?page=status_management_controler&amp;mode=list&amp;admin=status';"/>
-    </p>
-</form >
-</div>
-<?php
-}
-?></div>
-<script>
-    function check_status(nb_status,selected_status){
-        for(i=0;i<nb_status;i++){
-            document.getElementById('img_'+i).style.color='#666';
-        }
-        document.getElementById('img_'+selected_status).style.color='#009dc5';
-        document.getElementById('radio_'+selected_status).checked = true;
-    }
-</script>
-
-<?php
-}
diff --git a/apps/maarch_entreprise/admin/status/status_management_controler.php b/apps/maarch_entreprise/admin/status/status_management_controler.php
deleted file mode 100755
index 89e62f23ac0..00000000000
--- a/apps/maarch_entreprise/admin/status/status_management_controler.php
+++ /dev/null
@@ -1,413 +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.
-*
-*/
-
-core_tools::load_lang();
-$core_tools = new core_tools();
-$core_tools->test_admin('admin_status', 'apps');
-
-// Default mode is add
-$mode = 'add';
-if (isset($_REQUEST['mode']) && !empty($_REQUEST['mode'])) {
-    $mode = $_REQUEST['mode'];
-}
-
-try{
-    require_once 'core/class/StatusControler.php' ;
-    if ($mode == 'list') {
-        require_once 'core/class/class_request.php' ;
-        require_once 'apps' . DIRECTORY_SEPARATOR
-                     . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR
-                     . 'class' . DIRECTORY_SEPARATOR . 'class_list_show.php' ;
-    }
-} catch (Exception $e) {
-    functions::xecho($e->getMessage());
-}
-
-if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
-    $statusId = $_REQUEST['id'];
-}
-
-if (isset($_REQUEST['status_submit'])) {
-    // Action to do with db
-    validate_status_submit();
-
-} else {
-    // Display to do
-    $state = true;
-    switch ($mode) {
-        case 'up' :
-            $state = display_up($statusId);
-            $_SESSION['service_tag'] = 'status_init';
-            core_tools::execute_modules_services(
-                $_SESSION['modules_services'], 'status_init', 'include'
-            );
-            location_bar_management($mode);
-            break;
-        case 'add' :
-            display_add();
-            $_SESSION['service_tag'] = 'status_init';
-            core_tools::execute_modules_services(
-                $_SESSION['modules_services'], 'status_init', 'include'
-            );
-            location_bar_management($mode);
-            break;
-        case 'del' :
-            display_del($statusId);
-            break;
-        case 'list' :
-            $statusList = display_list();
-            location_bar_management($mode);
-            break;
-    }
-    include('status_management.php');
-}
-
-/**
- * Management of the location bar
- */
-function location_bar_management($mode)
-{
-    $pageLabels = array('add'  => _ADDITION,
-                    'up'   => _MODIFICATION,
-                    'list' => _STATUS_LIST
-               );
-    $pageIds = array('add' => 'status_add',
-                  'up' => 'status_up',
-                  'list' => 'status_list'
-            );
-    $init = false;
-    if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == 'true') {
-        $init = true;
-    }
-
-    $level = '';
-    if (isset($_REQUEST['level'])
-        && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3
-            || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) {
-        $level = $_REQUEST['level'];
-    }
-
-    $pagePath = $_SESSION['config']['businessappurl'] . 'index.php?page='
-               . 'status_management_controler&admin=status&mode=' . $mode ;
-    $pageLabel = $pageLabels[$mode];
-    $pageId = $pageIds[$mode];
-    $ct = new core_tools();
-    $ct->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level);
-}
-
-/**
- * Initialize session parameters for update display
- * @param String $statusId
- */
-function display_up($statusId)
-{
-    $statusCtrl = new Maarch_Core_Class_StatusControler();
-    $state = true;
-    $status = $statusCtrl->get($statusId);
-
-    if (empty($status)) {
-        $state = false;
-    } else {
-        put_in_session('status', $status->getArray());
-    }
-    return $state;
-}
-
-/**
- * Initialize session parameters for add display
- */
-function display_add()
-{
-    if (!isset($_SESSION['m_admin']['init'])) {
-        init_session();
-    }
-}
-
-/**
- * Initialize session parameters for list display
- */
-function display_list()
-{
-    $_SESSION['m_admin'] = array();
-    $list = new list_show();
-    $func = new functions();
-    init_session();
-
-    $select[STATUS_TABLE] = array();
-    array_push($select[STATUS_TABLE], 'id', 'label_status','img_filename');
-    $where = '';
-    $what = '';
-    $arrayPDO = array();
-    if (isset($_REQUEST['what'])) {
-        $what = $_REQUEST['what'];
-		$where .= " (lower(label_status) like lower(?)  or id like ?) ";
-        $arrayPDO = array($what.'%', $what.'%');
-    }
-
-    // Checking order and order_field values
-    $order = 'asc';
-    if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
-        $order = trim($_REQUEST['order']);
-    }
-
-    $field = 'label_status';
-    if (isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field'])) {
-        $field = trim($_REQUEST['order_field']);
-    }
-
-    $orderstr = $list->define_order($order, $field);
-    $request = new request();
-    $tab = $request->PDOselect(
-        $select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype']
-    );
-
-
-    for ($i=0;$i<count($tab);$i++) {
-        foreach ($tab[$i] as &$item) {
-            switch ($item['column']) {
-                case 'id':
-                    format_item(
-                        $item, _ID, '18', 'left', 'left', 'bottom', true
-                    );
-                    break;
-                case 'label_status':
-                    format_item(
-                        $item, _DESC, '55', 'left', 'left', 'bottom', true
-                    );
-                    break;
-            }
-        }
-    }
-    $_SESSION['m_admin']['init'] = true;
-    $result = array(
-        'tab'                 => $tab,
-        'what'                => $what,
-        'page_name'           => 'status_management_controler&mode=list',
-        'page_name_add'       => 'status_management_controler&mode=add',
-        'page_name_up'        => 'status_management_controler&mode=up',
-        'page_name_del'       => 'status_management_controler&mode=del',
-        'page_name_val'       => '',
-        'page_name_ban'       => '',
-        'label_add'           => _ADD_STATUS,
-        'title'               => _STATUS_LIST . ' : ' . $i . ' ' . _STATUS_PLUR,
-        'autoCompletionArray' => array(
-                                     'list_script_url'  =>
-                                        $_SESSION['config']['businessappurl']
-                                        . 'index.php?display=true&admin=status'
-                                        . '&page=status_list_by_name',
-                                     'number_to_begin'  => 1
-                                 ),
-
-    );
-    return $result;
-}
-
-/**
- * Delete given status if exists and initialize session parameters
- * @param string $statusId
- */
-function display_del($statusId)
-{
-    $statusCtrl = new Maarch_Core_Class_StatusControler();
-    $status = $statusCtrl->get($statusId);
-    if (isset($status)) {
-        // Deletion
-        $control = array();
-        $params  = array( 'log_status_del' => $_SESSION['history']['statusdel'],
-                         'databasetype' => $_SESSION['config']['databasetype']
-                        );
-        $control = $statusCtrl->delete($status, $params);
-        if (!empty($control['error']) && $control['error'] <> 1) {
-            $_SESSION['error'] = str_replace("#", "<br />", $control['error']);
-        } else {
-            $_SESSION['info'] = _STATUS_DELETED.' : '.$statusId;
-        }
-        ?><script type="text/javascript">window.top.location='<?php
-            echo $_SESSION['config']['businessappurl']
-                . 'index.php?page=status_management_controler&mode=list&admin='
-                . 'status&order=' . $_REQUEST['order'] . '&order_field='
-                . $_REQUEST['order_field'] . '&start=' . $_REQUEST['start']
-                . '&what=' . addslashes($_REQUEST['what']);
-        ?>';</script>
-        <?php
-        exit();
-    } else {
-        // Error management
-        $_SESSION['error'] = _STATUS.' '._UNKNOWN;
-    }
-}
-
-/**
- * Format given item with given values, according with HTML formating.
- * NOTE: given item needs to be an array with at least 2 keys:
- * 'column' and 'value'.
- * NOTE: given item is modified consequently.
- * @param $item
- * @param $label
- * @param $size
- * @param $labelAlign
- * @param $align
- * @param $valign
- * @param $show
- */
-function format_item(
-    &$item, $label, $size, $labelAlign, $align, $valign, $show, $order = true
-)
-{
-    $func = new functions();
-    $item['value'] = $func->show_string($item['value']);
-    $item[$item['column']] = $item['value'];
-    $item['label'] = $label;
-    $item['size'] = $size;
-    $item['label_align'] = $labelAlign;
-    $item['align'] = $align;
-    $item['valign'] = $valign;
-    $item['show'] = $show;
-    if ($order) {
-        $item['order'] = $item['value'];
-    } else {
-        $item['order'] = '';
-    }
-}
-
-/**
- * Validate a submit (add or up),
- * up to saving object
- */
-function validate_status_submit()
-{
-    $statusCtrl = new Maarch_Core_Class_StatusControler();
-    $pageName = 'status_management_controler';
-
-    $mode = $_REQUEST['mode'];
-    $statusObj = new Status();
-    $statusObj->id = $_REQUEST['status_id'];
-    $statusObj->label_status = $_REQUEST['label'];
-    $statusObj->is_system = 'N';
-    if (isset($_REQUEST['is_system']) && !empty($_REQUEST['is_system'])) {
-        $statusObj->is_system = $_REQUEST['is_system'];
-    }
-    $statusObj->img_filename = $_REQUEST['img_related'];
-    $statusObj->maarch_module = 'apps';
-    $statusObj->can_be_searched = 'Y';
-    if (isset($_REQUEST['can_be_searched'])) {
-        $statusObj->can_be_searched = $_REQUEST['can_be_searched'];
-    }
-    $statusObj->can_be_modified = 'Y';
-    if (isset($_REQUEST['can_be_modified'])) {
-        $statusObj->can_be_modified = $_REQUEST['can_be_modified'];
-    }
-    $statusObj->is_folder_status = 'N';
-    if (isset($_REQUEST['is_folder_status'])) {
-        $statusObj->is_folder_status = $_REQUEST['is_folder_status'];
-    }
-    if (isset($_REQUEST['img_related'])) {
-        $statusObj->img_filename = $_REQUEST['img_related'];
-    }
-
-	//print_r($statusObj);exit;
-    $status = array();
-    $status['order'] = $_REQUEST['order'];
-    $status['order_field'] = $_REQUEST['order_field'];
-    $status['what'] = $_REQUEST['what'];
-    $status['start'] = $_REQUEST['start'];
-
-    $control = array();
-    $params = array('modules_services' => $_SESSION['modules_services'],
-                    'log_status_up' => $_SESSION['history']['statusup'],
-                    'log_status_add' => $_SESSION['history']['statusadd'],
-                    'databasetype' => $_SESSION['config']['databasetype']
-               );
-
-    $control = $statusCtrl->save($statusObj, $mode, $params);
-
-    if (!empty($control['error']) && $control['error'] <> 1) {
-        // Error management depending of mode
-        $_SESSION['error'] = str_replace("#", "<br />", $control['error']);
-
-        put_in_session('status', $status);
-        put_in_session('status', $statusObj->getArray());
-
-        switch ($mode) {
-            case 'up':
-                if (!empty($status->id)) {
-                    header(
-                        'location: ' . $_SESSION['config']['businessappurl']
-                        . 'index.php?page=' . $pageName . '&mode=up&id='
-                        . $statusObj->id . '&admin=status'
-                    );
-                } else {
-                    header(
-                        'location: ' . $_SESSION['config']['businessappurl']
-                        . 'index.php?page=' . $pageName . '&mode=list&admin='
-                        .'status&order=' . $status['order'] . '&order_field='
-                        . $status['order_field'] . '&start=' . $status['start']
-                        . '&what=' . $status['what']
-                    );
-                }
-                exit();
-            case 'add':
-                header(
-                    'location: ' . $_SESSION['config']['businessappurl']
-                    . 'index.php?page=' . $pageName . '&mode=add&admin=status'
-                );
-                exit();
-        }
-    } else {
-        if ($mode == 'add') {
-            $_SESSION['info'] = _STATUS_ADDED;
-        } else {
-            $_SESSION['info'] = _STATUS_MODIFIED;
-        }
-        unset($_SESSION['m_admin']);
-
-        header(
-            'location: ' . $_SESSION['config']['businessappurl']
-            . 'index.php?page=' . $pageName . '&mode=list&admin=status&order='
-            . $status['order'] . '&order_field=' . $status['order_field']
-            . '&start=' . $status['start'] . '&what=' . $status['what']
-        );
-    }
-}
-
-function init_session()
-{
-    $_SESSION['m_admin']['status'] = array(
-        'id'              => '',
-        'label_status'    => '',
-        'is_system'       => 'N',
-        'img_filename'    => '',
-        'module'          => 'apps',
-        'can_be_searched' => 'Y',
-        'can_be_modified' => 'Y',
-        'is_folder_status'=> 'N'
-    );
-}
-
-/**
- * Put given object in session, according with given type
- * NOTE: given object needs to be at least hashable
- * @param string $type
- * @param hashable $hashable
- */
-function put_in_session($type, $hashable, $showString = true)
-{
-
-    $func = new functions();
-    foreach ($hashable as $key=>$value) {
-        if ($showString) {
-            $_SESSION['m_admin'][$type][$key]=$func->show_string($value);
-        } else {
-            $_SESSION['m_admin'][$type][$key]=$value;
-        }
-			
-
-    }
-
-}
diff --git a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml
index 0607e2d6942..b04d363c80a 100755
--- a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml
+++ b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml
@@ -344,17 +344,6 @@
       <parameter name="page" value="history_batch"/>
     </requestDefinition>
 
-    <!-- Admin status -->
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="admin_ajax_search" >
-      <parameter name="admin" value="status"/>
-      <parameter name="page" value="status_list_by_name"/>
-      <parameter name="display" value="true"/>
-    </requestDefinition>
-    <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="admin_status" >
-      <parameter name="admin" value="status"/>
-      <parameter name="page" value="status_management_controler"/>
-    </requestDefinition>
-
     <!-- Admin parameters -->
     <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="admin_parameters" >
       <parameter name="admin" value="parameter"/>
diff --git a/apps/maarch_entreprise/xml/services.xml b/apps/maarch_entreprise/xml/services.xml
index 315ad6b6126..847449c3dfc 100644
--- a/apps/maarch_entreprise/xml/services.xml
+++ b/apps/maarch_entreprise/xml/services.xml
@@ -96,10 +96,11 @@
    <id>admin_status</id>
    <name>_ADMIN_STATUS</name>
    <comment>_ADMIN_STATUS_DESC</comment>
-   <servicepage>index.php?page=status_management_controler&amp;mode=list&amp;admin=status</servicepage>
+   <servicepage>/administration/status</servicepage>
    <servicetype>admin</servicetype>
    <style>fa fa-check-circle</style>
    <system_service>false</system_service>
+   <angular>true</angular>
    <enabled>true</enabled>
  </SERVICE>
   <SERVICE>
diff --git a/apps/maarch_entreprise/xml/status.xml b/apps/maarch_entreprise/xml/status.xml
deleted file mode 100644
index b1c5cc0eafb..00000000000
--- a/apps/maarch_entreprise/xml/status.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ROOT>
-	<status>
-        <img_filename>fm-letter-status-new</img_filename>
-    </status>
-    <status> 
-        <img_filename>fm-letter-status-inprogress</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-info</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-wait</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-validated</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-rejected</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-end</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-newmail</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-attr</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-arev</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-aval</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-aimp</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-imp</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-aenv</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-acla</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-status-aarch</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-add</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-search</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-del</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-incoming</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-outgoing</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-letter-internal</img_filename>
-    </status>
-    <status>
-        <img_filename>fm-file-fingerprint</img_filename>
-    </status>
-</ROOT>
diff --git a/core/Controllers/HistoryController.php b/core/Controllers/HistoryController.php
index 02a20b02620..1f24411ced7 100644
--- a/core/Controllers/HistoryController.php
+++ b/core/Controllers/HistoryController.php
@@ -210,7 +210,7 @@ class HistoryController
             $aArgs['charset'] = 'utf-8';
         }
         $charset = $aArgs['charset'];
-        
+
         $str = htmlentities($aArgs['string'], ENT_NOQUOTES, $charset);
 
         $str = preg_replace(
@@ -238,8 +238,8 @@ class HistoryController
 
         $filePath = $aArgs['filePath'];
 
-        if (file_exists($_SESSION['config']['corepath'].'custom/'.$filePath)) {
-            $pathToXml = $_SESSION['config']['corepath'].'custom/'.$filePath;
+        if (file_exists($_SESSION['config']['corepath'].'custom/'.$_SESSION['custom_override_id'].'/'.$filePath)) {
+            $pathToXml = $_SESSION['config']['corepath'].'custom/'.$_SESSION['custom_override_id'].'/'.$filePath;
         } elseif (file_exists($_SESSION['config']['corepath'].$filePath)) {
             $pathToXml = $_SESSION['config']['corepath'].$filePath;
         } else {
-- 
GitLab