diff --git a/apps/maarch_entreprise/admin/history_batch/history_batch.php b/apps/maarch_entreprise/admin/history_batch/history_batch.php
index e914e278eddf1dcc61d39e02338782a84fed7031..f6792c92b55c455422da25920f75ce442a76edb4 100644
--- a/apps/maarch_entreprise/admin/history_batch/history_batch.php
+++ b/apps/maarch_entreprise/admin/history_batch/history_batch.php
@@ -1,7 +1,15 @@
 <?php
-require_once 'apps/' . $_SESSION['config']['app_id']
-    . '/class/class_list_show.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.
+*
+*/
+
+require_once 'apps/' . $_SESSION['config']['app_id'] . '/class/class_list_show.php';
 require_once 'core/class/class_request.php';
+
 $core_tools2 = new core_tools();
 $core_tools2->test_admin('view_history_batch', 'apps');
 /****************Management of the location bar  ************/
@@ -15,126 +23,111 @@ if (isset($_REQUEST['level'])
         || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) {
     $level = $_REQUEST['level'];
 }
-$page_path = $_SESSION['config']['businessappurl'].'index.php?page='
-           . 'history_batch&admin=history_batch';
+$page_path  = $_SESSION['config']['businessappurl'].'index.php?page=' . 'history_batch&admin=history_batch';
 $page_label = _VIEW_HISTORY_BATCH2;
-$page_id = 'history_batch';
+$page_id    = 'history_batch';
 $core_tools2->manage_location_bar(
     $page_path, $page_label, $page_id, $init, $level
 );
 /***********************************************************/
 $db = new Database();
 
-$where = '';
+$where    = '';
 $arrayPDO = array();
-$label = '';
-$tab = array();
-$modules = array();
-$stmt = $db->query(
-    'SELECT DISTINCT module_name FROM '.$_SESSION['tablename']['history_batch']
-);
+$label    = '';
+$tab      = array();
+$modules  = array();
+$stmt     = $db->query('SELECT DISTINCT module_name FROM history_batch');
+
 while ($res = $stmt->fetchObject()) {
     if ($res->module_name == 'admin') {
         array_push(
             $modules, array(
-                'id' => 'admin',
+                'id'    => 'admin',
                 'label' => _ADMIN
             )
         );
-    } else if (isset($_SESSION['modules_loaded'][$res->module_name]['comment'])
+    } elseif (isset($_SESSION['modules_loaded'][$res->module_name]['comment'])
         && !empty($_SESSION['modules_loaded'][$res->module_name]['comment'])) {
         array_push(
             $modules, array(
-                'id' => $res->module_name,
-                'label' =>
-                    $_SESSION['modules_loaded'][$res->module_name]['comment']
+                'id'    => $res->module_name,
+                'label' => $_SESSION['modules_loaded'][$res->module_name]['comment']
             )
         );
     } else {
         array_push(
             $modules, array(
-                'id' => $res->module_name,
+                'id'    => $res->module_name,
                 'label' => $res->module_name
             )
         );
     }
 }
-if ((isset($_REQUEST['search']) && $_REQUEST['search']) ||
-    (! empty($_SESSION['m_admin']['history_batch_action'])
-        && isset($_SESSION['m_admin']['history_batch_action']))
-    || (! empty($_SESSION['m_admin']['history_batch_module'])
-        && isset($_SESSION['m_admin']['history_batch_module']))
-    || (!empty($_SESSION['m_admin']['onlyerrors'])
-        && isset($_SESSION['m_admin']['onlyerrors']))
-    || (isset($_REQUEST['datestart']) && ! empty($_REQUEST['datestart']))
-    || (isset($_REQUEST['dateend']) && ! empty($_REQUEST['dateend']))) {
-    $pattern = '/^[0-3][0-9]-[0-1][0-9]-[1-2][0-9][0-9][0-9]$/';
-    if ((isset($_REQUEST['module']) && ! empty($_REQUEST['module']))
-        || (! empty($_SESSION['m_admin']['history_batch_module'])
-            && isset($_SESSION['m_admin']['history_batch_module']))) {
-        if (isset($_REQUEST['module']) && !empty($_REQUEST['module'])) {
-            $_SESSION['m_admin']['history_batch_module'] = $_REQUEST['module'];
-        }
-        $where .= ' ' . $_SESSION['tablename']['history_batch']
-               . ".module_name = ? and";
-        $arrayPDO = array_merge($arrayPDO, array($_SESSION['m_admin']['history_batch_module']));
-        $_SESSION['m_admin']['history_batch_module'] = '';
+
+$pattern = '/^[0-3][0-9]-[0-1][0-9]-[1-2][0-9][0-9][0-9]$/';
+
+if ($_REQUEST['module'] == 'no_module') {
+    $_SESSION['m_admin']['history_batch_module'] = "";
+} elseif (!empty($_REQUEST['module']) || !empty($_SESSION['m_admin']['history_batch_module'])) {
+    if (!empty($_REQUEST['module'])) {
+        $_SESSION['m_admin']['history_batch_module'] = $_REQUEST['module'];
     }
-    if ((isset($_REQUEST['onlyerrors']) && ! empty($_REQUEST['onlyerrors']))
-        || (! empty($_SESSION['m_admin']['onlyerrors'])
-            && isset($_SESSION['m_admin']['onlyerrors']))) {
-        if (isset($_REQUEST['onlyerrors']) && !empty($_REQUEST['onlyerrors'])) {
-            $_SESSION['m_admin']['onlyerrors'] = $_REQUEST['onlyerrors'];
-        }
-        if ($_REQUEST['onlyerrors'] == 'yes') {
-            $where .= "  " . $_SESSION['tablename']['history_batch']
-                   . ".total_errors > 0 and";
-        }
-        $_SESSION['m_admin']['onlyerrors'] = '';
+    $where   .= ' module_name = ? and';
+    $arrayPDO = array_merge($arrayPDO, array($_SESSION['m_admin']['history_batch_module']));
+}
+
+if (!empty($_REQUEST['onlyerrors']) || !empty($_SESSION['m_admin']['onlyerrors'])) {
+    if (!empty($_REQUEST['onlyerrors'])) {
+        $_SESSION['m_admin']['onlyerrors'] = $_REQUEST['onlyerrors'];
     }
-    if ((isset($_REQUEST['datestart']) && ! empty($_REQUEST['datestart']))
-        || (!empty($_SESSION['m_admin']['history_batch_datestart'])
-            && isset($_SESSION['m_admin']['history_batch_datestart']))) {
-        if (preg_match($pattern,$_REQUEST['datestart']) == false
-            && (! isset($_SESSION['m_admin']['history_batch_datestart'])
-                || empty($_SESSION['m_admin']['history_batch_datestart']))) {
-            $_SESSION['error'] = _DATE . ' ' . _WRONG_FORMAT;
-        } else {
-            if (isset($_REQUEST['datestart'])
-                && ! empty($_REQUEST['datestart'])) {
-                $_SESSION['m_admin']['history_batch_datestart'] =
-                    $core_tools2->format_date_db($_REQUEST['datestart']);
-            }
-            $where .= " (" . $_SESSION['tablename']['history_batch']
-                   . ".event_date >= ?) and ";
-            $arrayPDO = array_merge($arrayPDO, array($_SESSION['m_admin']['history_batch_datestart']));
-            $_SESSION['m_admin']['history_batch_datestart'] = '';
+    if ($_SESSION['m_admin']['onlyerrors'] == 'yes') {
+        $where .= " total_errors > 0 and";
+    }
+}
+
+if (isset($_REQUEST['datestart']) && $_REQUEST['datestart'] == "") {
+    $_SESSION['m_admin']['history_batch_datestart']       = "";
+    $_SESSION['m_admin']['history_batch_datestart_value'] = "";
+} elseif (!empty($_REQUEST['datestart']) || !empty($_SESSION['m_admin']['history_batch_datestart'])) {
+    if (preg_match($pattern, $_REQUEST['datestart']) == false
+        && (!isset($_SESSION['m_admin']['history_batch_datestart']) || empty($_SESSION['m_admin']['history_batch_datestart']))
+    ) {
+        $_SESSION['error'] = _DATE . ' ' . _WRONG_FORMAT;
+    } else {
+        if (!empty($_REQUEST['datestart'])) {
+            $_SESSION['m_admin']['history_batch_datestart_value'] = $_REQUEST['datestart'];
+            $_SESSION['m_admin']['history_batch_datestart']       = $core_tools2->format_date_db($_REQUEST['datestart']);
         }
+        $where .= " (event_date >= ?) and ";
+        $arrayPDO = array_merge($arrayPDO, array($_SESSION['m_admin']['history_batch_datestart']));
     }
-    if ((isset($_REQUEST['dateend']) && ! empty($_REQUEST['dateend']))
-        || (! empty($_SESSION['m_admin']['history_batch_dateend'])
-            && isset($_SESSION['m_admin']['history_batch_dateend']))){
-        if (preg_match($pattern, $_REQUEST['dateend']) == false
-            && (! isset($_SESSION['m_admin']['history_batch_dateend'])
-                || empty($_SESSION['m_admin']['history_batch_dateend']))) {
-            $_SESSION['error'] = _DATE . ' ' . _WRONG_FORMAT;
-        } else {
-            if (isset($_REQUEST['dateend']) && ! empty($_REQUEST['dateend'])) {
-                $_SESSION['m_admin']['history_batch_dateend'] =
-                    $core_tools2->format_date_db($_REQUEST['dateend']);
-            }
-            $where .= " ( " . $_SESSION['tablename']['history_batch']
-                   . ".event_date <= ?) and ";
-            $arrayPDO = array_merge($arrayPDO, array($_SESSION['m_admin']['history_batch_dateend']));
-            $_SESSION['m_admin']['history_batch_dateend'] = '';
+}
+
+if (isset($_REQUEST['dateend']) && $_REQUEST['dateend'] == "") {
+    $_SESSION['m_admin']['history_batch_dateend']       = "";
+    $_SESSION['m_admin']['history_batch_dateend_value'] = "";
+} elseif (!empty($_REQUEST['dateend']) || !empty($_SESSION['m_admin']['history_batch_dateend'])) {
+    if (preg_match($pattern, $_REQUEST['dateend']) == false
+        && (!isset($_SESSION['m_admin']['history_batch_dateend']) || empty($_SESSION['m_admin']['history_batch_dateend']))
+    ) {
+        $_SESSION['error'] = _DATE . ' ' . _WRONG_FORMAT;
+    } else {
+        if (!empty($_REQUEST['dateend'])) {
+            $_SESSION['m_admin']['history_batch_dateend_value'] = $_REQUEST['dateend'];
+            $_SESSION['m_admin']['history_batch_dateend']       = $core_tools2->format_date_db($_REQUEST['dateend']);
         }
+        $where .= " (event_date <= ?) and ";
+        $arrayPDO = array_merge($arrayPDO, array($_SESSION['m_admin']['history_batch_dateend']));
     }
-    $where = trim($where);
-    $where = preg_replace('/and$/', '', $where);
 }
-$select[$_SESSION['tablename']['history_batch']] = array();
+
+$where = trim($where);
+$where = preg_replace('/and$/', '', $where);
+
+$select['history_batch'] = array();
 array_push(
-    $select[$_SESSION['tablename']['history_batch']], 'id', 'event_date',
+    $select['history_batch'], 'id', 'event_date',
     'batch_id', 'module_name', 'total_processed', 'total_errors', 'info'
 );
 
@@ -151,95 +144,90 @@ if (isset($_REQUEST['order_field']) && ! empty($_REQUEST['order_field'])) {
 $orderstr = $list->define_order($order, $field);
 
 $req = new request();
-$tab = $req->PDOselect(
-    $select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype'],
-    '500', false, $_SESSION['tablename']['history_batch']
-);
-//$req->show();
-for ($i = 0; $i < count($tab); $i ++) {
+$tab = $req->PDOselect($select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype'], '500', false, 'history_batch');
+
+$countTab = count($tab);
+for ($i = 0; $i < $countTab; $i ++) {
     for ($j = 0; $j < count($tab[$i]); $j ++) {
         foreach (array_keys($tab[$i][$j]) as $value) {
             if ($tab[$i][$j][$value] == 'id') {
-                $tab[$i][$j]['id'] = $tab[$i][$j]['value'];
+                $tab[$i][$j]['id']   = $tab[$i][$j]['value'];
                 $tab[$i][$j]['show'] = false;
             }
             if ($tab[$i][$j][$value] == 'event_date') {
-            	$tab[$i][$j]['value'] = $core_tools2->format_date_db($tab[$i][$j]["value"], false, '', true);
-                $tab[$i][$j]['event_date'] = $tab[$i][$j]['value'];
-                $tab[$i][$j]['label'] = _DATE;
-                $tab[$i][$j]['size'] = '12';
+                $tab[$i][$j]['value']       = $core_tools2->format_date_db($tab[$i][$j]["value"], false, '', true);
+                $tab[$i][$j]['event_date']  = $tab[$i][$j]['value'];
+                $tab[$i][$j]['label']       = _DATE;
+                $tab[$i][$j]['size']        = '12';
                 $tab[$i][$j]['label_align'] = 'left';
-                $tab[$i][$j]['align'] = 'left';
-                $tab[$i][$j]['valign'] = 'bottom';
-                $tab[$i][$j]['show'] = true;
-                $tab[$i][$j]['order'] = 'event_date';
+                $tab[$i][$j]['align']       = 'left';
+                $tab[$i][$j]['valign']      = 'bottom';
+                $tab[$i][$j]['show']        = true;
+                $tab[$i][$j]['order']       = 'event_date';
             }
             if ($tab[$i][$j][$value] == 'module_name') {
-                $tab[$i][$j]['batch_id'] = $tab[$i][$j]['value'];
-                $tab[$i][$j]['label'] = _BATCH_NAME;
-                $tab[$i][$j]['size'] = '10';
+                $tab[$i][$j]['batch_id']    = $tab[$i][$j]['value'];
+                $tab[$i][$j]['label']       = _BATCH_NAME;
+                $tab[$i][$j]['size']        = '10';
                 $tab[$i][$j]['label_align'] = 'left';
-                $tab[$i][$j]['align'] = 'left';
-                $tab[$i][$j]['valign'] = 'bottom';
-                $tab[$i][$j]['show'] = true;
-                $tab[$i][$j]['order'] = 'module_name';
+                $tab[$i][$j]['align']       = 'left';
+                $tab[$i][$j]['valign']      = 'bottom';
+                $tab[$i][$j]['show']        = true;
+                $tab[$i][$j]['order']       = 'module_name';
             }
             if ($tab[$i][$j][$value] == 'batch_id') {
-                $tab[$i][$j]['batch_id'] = $tab[$i][$j]['value'];
-                $tab[$i][$j]['label'] =_BATCH_ID;
-                $tab[$i][$j]['size'] = '10';
+                $tab[$i][$j]['batch_id']    = $tab[$i][$j]['value'];
+                $tab[$i][$j]['label']       =_BATCH_ID;
+                $tab[$i][$j]['size']        = '10';
                 $tab[$i][$j]['label_align'] = 'left';
-                $tab[$i][$j]['align'] = 'left';
-                $tab[$i][$j]['valign'] = 'bottom';
-                $tab[$i][$j]['show'] = true;
-                $tab[$i][$j]['order'] = 'batch_id';
+                $tab[$i][$j]['align']       = 'left';
+                $tab[$i][$j]['valign']      = 'bottom';
+                $tab[$i][$j]['show']        = true;
+                $tab[$i][$j]['order']       = 'batch_id';
             }
             if ($tab[$i][$j][$value] == 'total_processed') {
-                $tab[$i][$j]['value'] = $tab[$i][$j]['value'];
+                $tab[$i][$j]['value']           = $tab[$i][$j]['value'];
                 $tab[$i][$j]['total_processed'] = $tab[$i][$j]['value'];
-                $tab[$i][$j]['label'] =_TOTAL_PROCESSED;
-                $tab[$i][$j]['size'] = '8';
-                $tab[$i][$j]['label_align'] = 'left';
-                $tab[$i][$j]['align'] = 'left';
-                $tab[$i][$j]['valign'] = 'bottom';
-                $tab[$i][$j]['show'] = true;
-                $tab[$i][$j]['order'] = 'total_processed';
+                $tab[$i][$j]['label']           =_TOTAL_PROCESSED;
+                $tab[$i][$j]['size']            = '8';
+                $tab[$i][$j]['label_align']     = 'left';
+                $tab[$i][$j]['align']           = 'left';
+                $tab[$i][$j]['valign']          = 'bottom';
+                $tab[$i][$j]['show']            = true;
+                $tab[$i][$j]['order']           = 'total_processed';
             }
             if ($tab[$i][$j][$value] == 'total_errors') {
-                $tab[$i][$j]['value'] = $tab[$i][$j]['value'];
+                $tab[$i][$j]['value']           = $tab[$i][$j]['value'];
                 $tab[$i][$j]['total_processed'] = $tab[$i][$j]['value'];
-                $tab[$i][$j]['label'] =_TOTAL_ERRORS;
-                $tab[$i][$j]['size'] = '8';
-                $tab[$i][$j]['label_align'] = 'left';
-                $tab[$i][$j]['align'] = 'left';
-                $tab[$i][$j]['valign'] = 'bottom';
-                $tab[$i][$j]['show'] = true;
-                $tab[$i][$j]['order'] = 'total_errors';
+                $tab[$i][$j]['label']           =_TOTAL_ERRORS;
+                $tab[$i][$j]['size']            = '8';
+                $tab[$i][$j]['label_align']     = 'left';
+                $tab[$i][$j]['align']           = 'left';
+                $tab[$i][$j]['valign']          = 'bottom';
+                $tab[$i][$j]['show']            = true;
+                $tab[$i][$j]['order']           = 'total_errors';
             }
             if ($tab[$i][$j][$value] == 'info') {
-                $tab[$i][$j]['value'] = $this->show_string(
-                    $tab[$i][$j]['value']
-                );
-                $tab[$i][$j]['info'] = $tab[$i][$j]['value'];
-                $tab[$i][$j]['label'] = _INFOS;
-                $tab[$i][$j]['size'] = '40';
+                $tab[$i][$j]['value']       = $this->show_string($tab[$i][$j]['value']);
+                $tab[$i][$j]['info']        = $tab[$i][$j]['value'];
+                $tab[$i][$j]['label']       = _INFOS;
+                $tab[$i][$j]['size']        = '40';
                 $tab[$i][$j]['label_align'] = 'left';
-                $tab[$i][$j]['align'] = 'left';
-                $tab[$i][$j]['valign'] = 'bottom';
-                $tab[$i][$j]['show'] = true;
-                $tab[$i][$j]['order'] = 'info';
+                $tab[$i][$j]['align']       = 'left';
+                $tab[$i][$j]['valign']      = 'bottom';
+                $tab[$i][$j]['show']        = true;
+                $tab[$i][$j]['order']       = 'info';
             }
         }
     }
 }
 $list = new list_show();
-$nb = count($tab);
 ?>
-<h1><i class="fa fa-history fa-2x"></i> <?php echo _HISTORY_BATCH_TITLE.' : '. $nb.' '._RESULTS;?></h1>
+<h1><i class="fa fa-history fa-2x"></i> <?php echo _HISTORY_BATCH_TITLE.' : '. $countTab.' '._RESULTS;?></h1>
 <div id="inner_content">
 <?php
 $list->admin_list(
-    $tab, $nb, '', 'id', 'history_batch', 'history_batch', 'id', true, '', '',
+    $tab, $countTab, '', 'id', 'history_batch', 'history_batch', 'id', true, '', '',
     '', '', '', '', TRUE, FALSE, '', '', '', false, false
 );
 ?>
@@ -253,30 +241,32 @@ $list->admin_list(
         <p>
             <label for="module"><?php echo _BATCH_NAME;?> :</label>
             <select name="module">
-                <option value=""><?php echo _CHOOSE_BATCH;?></option>
+                <option value="no_module"><?php echo _CHOOSE_BATCH;?></option>
                 <?php
-                for ($i = 0; $i < count($modules); $i ++)
-                {
+                for ($i = 0; $i < count($modules); $i ++) {
                     ?>
-                    <option value="<?php functions::xecho($modules[$i]['id']);?>"><?php
-                        functions::xecho($modules[$i]['label']);?></option>
-                    <?php
-                }
-                ?>
+                    <option value="<?php functions::xecho($modules[$i]['id']); ?>" <?php if ($modules[$i]['id'] == $_SESSION['m_admin']['history_batch_module']) {
+                        echo "selected";
+                    } ?> >
+                        <?php functions::xecho($modules[$i]['label']); ?>
+                    </option><?php
+
+                }?>
             </select>
         </p>
         <p>
             <label for="datestart"><?php echo _SINCE;?> :</label>
-            <input name="datestart" type="text" id="datestart" onclick='showCalender(this);'/>
+            <input name="datestart" type="text" id="datestart" onclick='showCalender(this);' value="<?php echo $_SESSION['m_admin']['history_batch_datestart_value'];?>"/>
         </p>
         <p>
             <label for="dateend"><?php echo _FOR;?> :</label>
-            <input name="dateend" type="text" id="dateend" onclick="showCalender(this);"/>
+            <input name="dateend" type="text" id="dateend" onclick="showCalender(this);" value="<?php echo $_SESSION['m_admin']['history_batch_dateend_value'];?>"/>
         </p>
         <p>
             <label for="onlyerrors"><?php echo _ONLY_ERRORS;?> :</label>
-            <?php echo _YES;?><input name="onlyerrors"  class="check" type="radio" id="onlyerrors" value="yes" checked="checked"/> &nbsp;
-            <?php echo _NO;?><input name="onlyerrors"  class="check" type="radio" id="onlyerrors" value="no"/>
+            <?php echo _YES;?><input name="onlyerrors" class="check" type="radio" id="onlyerrors" value="yes" <?php if ($_SESSION['m_admin']['onlyerrors'] == "yes") {
+                    echo "checked";}?> /> &nbsp;
+            <?php echo _NO;?><input name="onlyerrors" class="check" type="radio" id="onlyerrors" value="no" <?php if ($_SESSION['m_admin']['onlyerrors'] == "no" || empty($_SESSION['m_admin']['onlyerrors'])) { echo "checked";}?> />
         </p>
         <p class="button">
             <input type="submit" name="search" value="<?php echo _SEARCH;?>" class="button"/>