diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index d2d92188662..29601c95dcf 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -78,6 +78,23 @@ if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->la } } +// When session has expired (selected terminal has been lost from session), redirect to the terminal selection. +if (empty($_SESSION["takeposterminal"])) { + if (getDolGlobalInt('TAKEPOS_NUM_TERMINALS') == 1) { + $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal + } elseif (!empty($_COOKIE["takeposterminal"])) { + $_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session + } else { + print << +SCRIPT; + exit; + } +} /** * Abort invoice creationg with a given error message