* Copyright (C) 2019 Josep LluĂ­s Amador * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2024 MDW * * 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('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } // Load Dolibarr environment 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.'/core/class/hookmanager.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.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.'/societe/class/societe.class.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 = GETPOSTINT('setterminal'); $setcurrency = GETPOST('setcurrency', 'aZ09'); $hookmanager->initHooks(array('takeposfrontend')); 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 } } if ($setterminal > 0) { $_SESSION["takeposterminal"] = $setterminal; setcookie("takeposterminal", (string) $setterminal, (time() + (86400 * 354)), '/', '', !empty($dolibarr_main_force_https), true); // Permanent takeposterminal var in a cookie } if ($setcurrency != "") { $_SESSION["takeposcustomercurrency"] = $setcurrency; // We will recalculate amount for foreign currency at next call of invoice.php when $_SESSION["takeposcustomercurrency"] differs from invoice->multicurrency_code. } $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 FORCED if (!empty($_SESSION["takeposterminal"]) && getDolGlobalString('TAKEPOS_BAR_RESTAURANT') && getDolGlobalInt('TAKEPOS_PHONE_BASIC_LAYOUT') == 1) { $_SESSION["basiclayout"] = 1; header("Location: phone.php?mobilepage=invoice"); exit; } } else { unset($_SESSION["basiclayout"]); } $MAXCATEG = (!getDolGlobalString('TAKEPOS_NB_MAXCATEG') ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG); $MAXPRODUCT = (!getDolGlobalString('TAKEPOS_NB_MAXPRODUCT') ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT); $term = empty($_SESSION['takeposterminal']) ? 1 : $_SESSION['takeposterminal']; /* $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $soc = new Societe($db); if ($invoice->socid > 0) $soc->fetch($invoice->socid); else $soc->fetch(getDolGlobalInt($constforcompanyid)); */ // Security check $result = restrictedArea($user, 'takepos', 0, ''); /* * View */ $form = new Form($db); $disablejs = 0; $disablehead = 0; $arrayofjs = array('/takepos/js/jquery.colorbox-min.js'); // TODO It seems we don't need this $arrayofcss = array('/takepos/css/pos.css.php', '/takepos/css/colorbox.css'); if (getDolGlobalInt('TAKEPOS_COLOR_THEME') == 1) { $arrayofcss[] = '/takepos/css/colorful.css'; } // Title $title = 'TakePOS - Dolibarr '.DOL_VERSION; if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { $title = 'TakePOS - ' . getDolGlobalString('MAIN_APPLICATION_TITLE'); } $head = ' '; top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); $categories = $categorie->get_full_arbo('product', ((getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) ? getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') : 0), 1); // Search root category to know its level //$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0; $levelofrootcategory = 0; if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) { foreach ($categories as $key => $categorycursor) { if ($categorycursor['id'] == getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID')) { $levelofrootcategory = $categorycursor['level']; break; } } } $levelofmaincategories = $levelofrootcategory + 1; $maincategories = array(); $subcategories = array(); foreach ($categories as $key => $categorycursor) { if ($categorycursor['level'] == $levelofmaincategories) { $maincategories[$key] = $categorycursor; } else { $subcategories[$key] = $categorycursor; } } $maincategories = dol_sort_array($maincategories, 'label'); $subcategories = dol_sort_array($subcategories, 'label'); ?> 0 ? getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) : ''; } ?>
executeHooks('takepos_login_block_other'); if ($reshook == 0) { //Search method ?>
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.' '.getDolGlobalInt($constantforkey)); if (getDolGlobalInt($constantforkey) > 0) { array_push($paiementsModes, $obj); } } } if (empty($paiementsModes) && isModEnabled("bank")) { $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 (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) { $tmpcategory = new Categorie($db); $tmpcategory->fetch(getDolGlobalString('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 (!getDolGlobalString('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 (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) { if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) { $menus[$r++] = array('title' => '
'.$langs->trans("Contact").'
', 'action' => 'Contact();'); } else { $menus[$r++] = array('title' => '
'.$langs->trans("Customer").'
', 'action' => 'Customer();'); } } if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) { $menus[$r++] = array('title' => '
'.$langs->trans("History").'
', 'action' => 'History();'); } $menus[$r++] = array('title' => '
'.$langs->trans("FreeZone").'
', 'action' => 'FreeZone();'); $menus[$r++] = array('title' => '
'.$langs->trans("InvoiceDiscountShort").'
', 'action' => 'Reduction();'); if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) { $menus[$r++] = array('title' => '
'.$langs->trans("SplitSale").'
', 'action' => 'Split();'); } // BAR RESTAURANT specific menu if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) { if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) { $menus[$r++] = array('title' => '
'.$langs->trans("Order").'', 'action' => 'TakeposPrintingOrder();'); } } // Last action that close the sell (payments) $menus[$r++] = array('title' => '
'.$langs->trans("Payment").'
', 'action' => 'CloseBill();'); if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) { $menus[$r++] = array('title' => '
'.$langs->trans("DirectPayment").' ('.$langs->trans("Cash").')
', 'action' => 'DirectPayment();'); } // BAR RESTAURANT specific menu if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) { //Button to print receipt before payment if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) { if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && 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 ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('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 (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) { $menus[$r++] = array('title' => '
'.$langs->trans("OrderNotes").'
', 'action' => 'TakeposOrderNotes();'); } if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) { $menus[$r++] = array('title' => '
'.$langs->trans("ProductSupplements").'
', 'action' => 'LoadProducts(\'supplements\');'); } } if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { $menus[$r++] = array('title' => '
'.$langs->trans("DOL_OPEN_DRAWER").'
', 'action' => 'OpenDrawer();'); } if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('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 = ".((int) $conf->entity)." AND "; $sql .= " posnumber = ".((int) empty($_SESSION["takeposterminal"]) ? 0 : $_SESSION["takeposterminal"])." 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.');'); } } } $parameters = array('menus' => $menus); $reshook = $hookmanager->executeHooks('ActionButtons', $parameters); if ($reshook == 0) { //add buttons if (is_array($hookmanager->resArray)) { foreach ($hookmanager->resArray as $resArray) { foreach ($resArray as $butmenu) { $menus[$r++] = $butmenu; } } } elseif ($reshook == 1) { $r = 0; //replace buttons if (is_array($hookmanager->resArray)) { foreach ($hookmanager->resArray as $resArray) { foreach ($resArray as $butmenu) { $menus[$r++] = $butmenu; } } } } } if ($r % 3 == 2) { $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;'); } if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) { $menus[$r++] = array('title' => '
'.$langs->trans("Logout").'
', 'action' => 'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php?token='.newToken().'\';'); } if (getDolGlobalString('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 (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) { print ''."\n"; print '
'; print ' '; print ''.img_picto('', 'searchclear').''; print '
'; } ?>
'; } else { print '
'; } $count = 0; while ($count < $MAXCATEG) { ?>
id="catdiv"> '; echo ''; } elseif ($count == ($MAXCATEG - 1)) { //echo ''; echo ''; } else { if (!getDolGlobalString('TAKEPOS_HIDE_CATEGORY_IMAGES')) { echo ''; } } ?>
...
onclick="MoreProducts('less')" onclick="MoreProducts('more')" > '; print ''; } elseif ($count == ($MAXPRODUCT - 1)) { //echo ''; print ''; } else { if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_PRICES')) { print '
'; } if (getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) { print ''; } else { print ''; } } ?>
...
close();