* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect
if (!defined('NOREQUIREMENU')) {
    define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
    define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
    define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
    define('NOREQUIRESOC', '1');
}
$res = @(include "../../main.inc.php");
// For root directory
if (!$res) {
    $res = @(include "../../../main.inc.php");
}
// For "custom" directory
dol_include_once('/pos/class/cash.class.php');
// This destroy tag that say "Point of Sale session is on".
global $db;
$terminal = new Cash($db);
$terminal->fetch($_SESSION['TERMINAL_ID']);
$terminal->set_unused($user);
unset($_SESSION['uid']);
unset($_SESSION['TERMINAL_ID']);
header('Location: ' . dol_buildpath('/pos/frontend/index.php', 1));
exit;
}
if ($page == -1) {
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$langs->load("pos@pos");
/*
 * Actions
 */
//free terminal
if ($action == 'freeterminal') {
    $cash = new Cash($db);
    $cash->fetch(GETPOST('id', 'int'));
    $cash->set_unused($user);
}
if ($action == 'blockterminal') {
    $cash = new Cash($db);
    $cash->fetch(GETPOST('id', 'int'));
    $cash->set_used($user);
}
// Recherche
$mode = GETPOST('mode');
$modesearch = GETPOST('mode-search');
if ($mode == 'search') {
    $_POST["search_name"] = $cashname;
    $sql = "SELECT rowid";
    $sql .= " FROM " . MAIN_DB_PREFIX . "pos_cash";
    $sql .= " WHERE (";
    $sql .= " name like '%" . $db->escape($cashname) . "%'";