* 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, (empty($dolibarr_main_force_https) ? false : true), 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. } $_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 ''; } ?> 0 ? getDolGlobalInt('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 (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) { $menus[$r++] = array('title'=>'
'.$langs->trans("DirectPayment").' ('.$langs->trans("Cash").')
', 'action'=>'DirectPayment();'); } $menus[$r++] = array('title'=>'
'.$langs->trans("SplitSale").'
', 'action'=>'Split();'); // BAR RESTAURANT specific menu if (getDolGlobalString('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 (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 (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 (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) $_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.');'); } } } $hookmanager->initHooks(array('takeposfrontend')); $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 (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { $menus[$r++] = array('title'=>'
'.$langs->trans("Logout").'
', 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php?token='.newToken().'\';'); } if (!empty($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 (!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_IMAGES')) { echo ''; } else { print '
'; print ''; } } ?>
...
close();