* Copyright (C) 2019 Josep LluĂ­s Amador * Copyright (C) 2020 Thibault FOUCART * * This program 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. * * This program 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 this program. If not, see . */ /** * \file htdocs/takepos/index.php * \ingroup takepos * \brief Main TakePOS screen */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Bar or Restaurant or multiple sales $action = GETPOST('action', 'aZ09'); $setterminal = GETPOST('setterminal', 'int'); $setcurrency = GETPOST('setcurrency', 'aZ09'); if ($_SESSION["takeposterminal"] == "") { if ($conf->global->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 } if ($setterminal > 0) { $_SESSION["takeposterminal"] = $setterminal; setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, false, true); // Permanent takeposterminal var in a cookie } if ($setcurrency != "") { $_SESSION["takeposcustomercurrency"] = $setcurrency; } $_SESSION["urlfrom"] = '/takepos/index.php'; $langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter", "banks")); $categorie = new Categorie($db); $maxcategbydefaultforthisdevice = 12; $maxproductbydefaultforthisdevice = 24; if ($conf->browser->layout == 'phone') { $maxcategbydefaultforthisdevice = 8; $maxproductbydefaultforthisdevice = 16; //REDIRECT TO BASIC LAYOUT IF TERMINAL SELECTED AND BASIC MOBILE LAYOUT ENABLED if ($_SESSION["takeposterminal"] != "" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) { $_SESSION["basiclayout"] = 1; header("Location: phone.php?mobilepage=invoice"); exit; } } $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG); $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT); /* $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $soc = new Societe($db); if ($invoice->socid > 0) $soc->fetch($invoice->socid); else $soc->fetch($conf->global->$constforcompanyid); */ // Security check $result = restrictedArea($user, 'takepos', 0, ''); /* * View */ $form = new Form($db); // Title $title = 'TakePOS - Dolibarr '.DOL_VERSION; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; $head = ' '; top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); ?> global->TAKEPOS_COLOR_THEME == 1) print ''; ?> global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} > 0 ? $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} : ''; ?>
global->TAKEPOS_HIDE_HEAD_BAR)) { ?>
multicurrency->enabled)) { ?>
query($sql); $paiementsModes = array(); if ($resql) { while ($obj = $db->fetch_object($resql)) { $paycode = $obj->code; if ($paycode == 'LIQ') $paycode = 'CASH'; if ($paycode == 'CHQ') $paycode = 'CHEQUE'; $constantforkey = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; //var_dump($constantforkey.' '.$conf->global->$constantforkey); if (!empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) array_push($paiementsModes, $obj); } } if (empty($paiementsModes)) { $langs->load('errors'); setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors'); setEventMessages($langs->trans("ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"]), null, 'errors'); } if (count($maincategories) == 0) { if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { $tmpcategory = new Categorie($db); $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID); setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory", $tmpcategory->label), null, 'errors'); } else { setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors'); } } // User menu and external TakePOS modules $menus = array(); $r = 0; if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) { $menus[$r++] = array('title'=>'
'.$langs->trans("New").'
', 'action'=>'New();'); } else { // BAR RESTAURANT specific menu $menus[$r++] = array('title'=>'
'.$langs->trans("Place").'
', 'action'=>'Floors();'); } if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { $menus[$r++] = array('title'=>'
'.$langs->trans("Customer").'
', 'action'=>'Customer();'); } $menus[$r++] = array('title'=>'
'.$langs->trans("History").'
', 'action'=>'History();'); $menus[$r++] = array('title'=>'
'.$langs->trans("FreeZone").'
', 'action'=>'FreeZone();'); $menus[$r++] = array('title'=>'
'.$langs->trans("Reduction").'
', 'action'=>'Reduction();'); $menus[$r++] = array('title'=>'
'.$langs->trans("Payment").'
', 'action'=>'CloseBill();'); if ($conf->global->TAKEPOS_DIRECT_PAYMENT) { $menus[$r++] = array('title'=>'
'.$langs->trans("DirectPayment").' ('.$langs->trans("Cash").')
', 'action'=>'DirectPayment();'); } // BAR RESTAURANT specific menu if ($conf->global->TAKEPOS_BAR_RESTAURANT) { if ($conf->global->TAKEPOS_ORDER_PRINTERS) { $menus[$r++] = array('title'=>$langs->trans("Order"), 'action'=>'TakeposPrintingOrder();'); } //Button to print receipt before payment if ($conf->global->TAKEPOS_BAR_RESTAURANT) { if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) $menus[$r++] = array('title'=>'
'.$langs->trans("Receipt").'
', 'action'=>'TakeposConnector(placeid);'); else $menus[$r++] = array('title'=>'
'.$langs->trans("Receipt").'
', 'action'=>'TakeposPrinting(placeid);'); } elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { $menus[$r++] = array('title'=>'
'.$langs->trans("Receipt").'
', 'action'=>'DolibarrTakeposPrinting(placeid);'); } else { $menus[$r++] = array('title'=>'
'.$langs->trans("Receipt").'
', 'action'=>'Print(placeid);'); } } if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && $conf->global->TAKEPOS_ORDER_NOTES == 1) { $menus[$r++] = array('title'=>'
'.$langs->trans("OrderNotes").'
', 'action'=>'TakeposOrderNotes();'); } if ($conf->global->TAKEPOS_SUPPLEMENTS) { $menus[$r++] = array('title'=>'
'.$langs->trans("ProductSupplements").'
', 'action'=>'LoadProducts(\'supplements\');'); } } if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { $menus[$r++] = array('title'=>'
'.$langs->trans("DOL_OPEN_DRAWER").'
', 'action'=>'OpenDrawer();'); } if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { $menus[$r++] = array( 'title' => '
'.$langs->trans("DOL_OPEN_DRAWER").'
', 'action' => 'DolibarrOpenDrawer();', ); } $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".$conf->entity." AND "; $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { $obj = $db->fetch_object($resql); $menus[$r++] = array('title'=>'
'.$langs->trans("CashReport").'
', 'action'=>'CashReport('.$obj->rowid.');'); if ($obj->status == 0) $menus[$r++] = array('title'=>'
'.$langs->trans("CloseCashFence").'
', 'action'=>'CloseCashFence('.$obj->rowid.');'); } } $hookmanager->initHooks(array('takeposfrontend')); $reshook = $hookmanager->executeHooks('ActionButtons'); if (!empty($reshook)) { if (is_array($reshook) && !isset($reshook['title'])) { foreach ($reshook as $reshook) { $menus[$r++] = $reshook; } } else { $menus[$r++] = $reshook; } } if ($r % 3 == 2) $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;'); if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { $menus[$r++] = array('title'=>'
'.$langs->trans("Logout").'
', 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';'); } if ($conf->global->TAKEPOS_WEIGHING_SCALE) { $menus[$r++] = array('title'=>'
'.$langs->trans("WeighingScale").'
', 'action'=>'WeighingScale();'); } ?>
12 and $i == 12) { echo ''; echo ''; } elseif ($i > 12) echo ''; else echo ''; } if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { print ''."\n"; print '
'; print ' '; print ''.img_picto('', 'searchclear').''; print '
'; } ?>
id="catdiv"> '; echo ''; } elseif ($count == ($MAXCATEG - 1)) { //echo ''; echo ''; } else { if (!$conf->global->TAKEPOS_HIDE_CATEGORY_IMAGES) echo ''; } ?>
...
onclick="MoreProducts('less');" onclick="MoreProducts('more');" > '; print ''; } elseif ($count == ($MAXPRODUCT - 1)) { //echo ''; print ''; } else { if ($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) echo ''; else { print '
'; print ''; } } ?> global->TAKEPOS_HIDE_PRODUCT_IMAGES) { ?>
...
close();