12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490 |
- <?php
- /* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
- * Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
- * Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
- *
- * 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 <https://www.gnu.org/licenses/>.
- */
- /**
- * \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 = GETPOST('setterminal', 'int');
- $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", $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"] != "" && getDolGlobalInt('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(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 (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
- $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
- }
- $head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="mobile-web-app-capable" content="yes">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
- 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');
- ?>
- <body class="bodytakepos" style="overflow: hidden;">
- <script>
- var categories = <?php echo json_encode($maincategories); ?>;
- var subcategories = <?php echo json_encode($subcategories); ?>;
- var currentcat;
- var pageproducts=0;
- var pagecategories=0;
- var pageactions=0;
- var place="<?php echo $place; ?>";
- var editaction="qty";
- var editnumber="";
- var invoiceid=0;
- var search2_timer=null;
- /*
- var app = this;
- app.hasKeyboard = false;
- this.keyboardPress = function() {
- app.hasKeyboard = true;
- $(window).unbind("keyup", app.keyboardPress);
- localStorage.hasKeyboard = true;
- console.log("has keyboard!")
- }
- $(window).on("keyup", app.keyboardPress)
- if(localStorage.hasKeyboard) {
- app.hasKeyboard = true;
- $(window).unbind("keyup", app.keyboardPress);
- console.log("has keyboard from localStorage")
- }
- */
- function ClearSearch() {
- console.log("ClearSearch");
- $("#search").val('');
- $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
- $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
- $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
- <?php if ($conf->browser->layout == 'classic') { ?>
- setFocusOnSearchField();
- <?php } ?>
- }
- // Set the focus on search field but only on desktop. On tablet or smartphone, we don't to avoid to have the keyboard open automatically
- function setFocusOnSearchField() {
- console.log("Call setFocusOnSearchField in page index.php");
- <?php if ($conf->browser->layout == 'classic') { ?>
- console.log("has keyboard from localStorage, so we can force focus on search field");
- $("#search").focus();
- <?php } ?>
- }
- function PrintCategories(first) {
- console.log("PrintCategories");
- for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
- if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined")
- {
- $("#catdivdesc"+i).hide();
- $("#catdesc"+i).text("");
- $("#catimg"+i).attr("src","genimg/empty.png");
- $("#catwatermark"+i).hide();
- $("#catdiv"+i).attr('class', 'wrapper divempty');
- continue;
- }
- $("#catdivdesc"+i).show();
- <?php
- if (getDolGlobalString('TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
- $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label'].bold() + ' - ' + categories[parseInt(i)+parseInt(first)]['description']);
- <?php } else { ?>
- $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']);
- <?php } ?>
- $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']);
- $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']);
- $("#catdiv"+i).attr('class', 'wrapper');
- $("#catwatermark"+i).show();
- }
- }
- function MoreCategories(moreorless) {
- console.log("MoreCategories moreorless="+moreorless+" pagecategories="+pagecategories);
- if (moreorless == "more") {
- $('#catimg15').animate({opacity: '0.5'}, 1);
- $('#catimg15').animate({opacity: '1'}, 100);
- pagecategories=pagecategories+1;
- }
- if (moreorless == "less") {
- $('#catimg14').animate({opacity: '0.5'}, 1);
- $('#catimg14').animate({opacity: '1'}, 100);
- if (pagecategories==0) return; //Return if no less pages
- pagecategories=pagecategories-1;
- }
- if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless == "more") == "undefined") { // Return if no more pages
- pagecategories=pagecategories-1;
- return;
- }
- for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
- if (typeof (categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]) == "undefined") {
- // complete with empty record
- console.log("complete with empty record");
- $("#catdivdesc"+i).hide();
- $("#catdesc"+i).text("");
- $("#catimg"+i).attr("src","genimg/empty.png");
- $("#catwatermark"+i).hide();
- continue;
- }
- $("#catdivdesc"+i).show();
- <?php
- if (getDolGlobalString('TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
- $("#catdesc"+i).html(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['label'].bold() + ' - ' + categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['description']);
- <?php } else { ?>
- $("#catdesc"+i).text(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['label']);
- <?php } ?>
- $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
- $("#catdiv"+i).data("rowid",categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
- $("#catwatermark"+i).show();
- }
- ClearSearch();
- }
- // LoadProducts
- function LoadProducts(position, issubcat) {
- console.log("LoadProducts");
- var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
- if (position=="supplements") currentcat="supplements";
- else
- {
- $('#catimg'+position).animate({opacity: '0.5'}, 1);
- $('#catimg'+position).animate({opacity: '1'}, 100);
- if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid');
- else currentcat=$('#catdiv'+position).data('rowid');
- }
- if (currentcat == undefined) return;
- pageproducts=0;
- ishow=0; //product to show counter
- jQuery.each(subcategories, function(i, val) {
- if (currentcat==val.fk_parent) {
- $("#prodivdesc"+ishow).show();
- <?php if (getDolGlobalString('TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
- $("#prodesc"+ishow).html(val.label.bold() + ' - ' + val.description);
- $("#probutton"+ishow).html(val.label);
- <?php } else { ?>
- $("#prodesc"+ishow).text(val.label);
- $("#probutton"+ishow).text(val.label);
- <?php } ?>
- $("#probutton"+ishow).show();
- $("#proprice"+ishow).attr("class", "hidden");
- $("#proprice"+ishow).html("");
- $("#proimg"+ishow).attr("src","genimg/index.php?query=cat&id="+val.rowid);
- $("#prodiv"+ishow).data("rowid",val.rowid);
- $("#prodiv"+ishow).data("iscat",1);
- $("#prowatermark"+ishow).show();
- ishow++;
- }
- });
- idata=0; //product data counter
- var limit = 0;
- if (maxproduct >= 1) {
- limit = maxproduct-1;
- }
- // Only show products for sale (tosell=1)
- $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) {
- console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs");
- console.log(data);
- while (ishow < maxproduct) {
- //console.log("ishow"+ishow+" idata="+idata);
- console.log(data[idata]);
- if (typeof (data[idata]) == "undefined") {
- <?php if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
- echo '$("#prodivdesc"+ishow).hide();';
- echo '$("#prodesc"+ishow).text("");';
- echo '$("#proimg"+ishow).attr("title","");';
- echo '$("#proimg"+ishow).attr("src","genimg/empty.png");';
- } else {
- echo '$("#probutton"+ishow).hide();';
- echo '$("#probutton"+ishow).text("");';
- }?>
- $("#proprice"+ishow).attr("class", "hidden");
- $("#proprice"+ishow).html("");
- $("#prodiv"+ishow).data("rowid","");
- $("#prodiv"+ishow).attr("class","wrapper2 divempty");
- } else {
- <?php
- $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[idata]['ref']";
- $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']";
- ?>
- var titlestring = <?php echo $titlestring; ?>;
- <?php if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
- echo '$("#prodivdesc"+ishow).show();';
- if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
- echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
- } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
- echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
- } else {
- echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
- }
- echo '$("#proimg"+ishow).attr("title", titlestring);';
- echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
- } else {
- echo '$("#probutton"+ishow).show();';
- echo '$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
- }
- ?>
- if (data[parseInt(idata)]['price_formated']) {
- $("#proprice"+ishow).attr("class", "productprice");
- $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']);
- }
- console.log("#prodiv"+ishow+".data(rowid)="+data[idata]['id']);
- console.log($("#prodiv"+ishow));
- $("#prodiv"+ishow).data("rowid", data[idata]['id']);
- console.log($('#prodiv4').data('rowid'));
- $("#prodiv"+ishow).data("iscat", 0);
- $("#prodiv"+ishow).attr("class","wrapper2");
- <?php
- // Add js from hooks
- $parameters=array();
- $parameters['caller'] = 'loadProducts';
- $hookmanager->executeHooks('completeJSProductDisplay', $parameters);
- print $hookmanager->resPrint;
- ?>
- }
- $("#prowatermark"+ishow).hide();
- ishow++; //Next product to show after print data product
- idata++; //Next data everytime
- }
- });
- ClearSearch();
- }
- function MoreProducts(moreorless) {
- console.log("MoreProducts");
- if ($('#search_pagination').val() != '') {
- return Search2('<?php echo (isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
- }
- var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
- if (moreorless=="more"){
- $('#proimg31').animate({opacity: '0.5'}, 1);
- $('#proimg31').animate({opacity: '1'}, 100);
- pageproducts=pageproducts+1;
- }
- if (moreorless=="less"){
- $('#proimg30').animate({opacity: '0.5'}, 1);
- $('#proimg30').animate({opacity: '1'}, 100);
- if (pageproducts==0) return; //Return if no less pages
- pageproducts=pageproducts-1;
- }
- ishow=0; //product to show counter
- idata=0; //product data counter
- var limit = 0;
- if (maxproduct >= 1) {
- limit = maxproduct-1;
- }
- var offset = <?php echo ($MAXPRODUCT - 2); ?> * pageproducts;
- // Only show products for sale (tosell=1)
- $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat+'&tosell=1&limit='+limit+'&offset='+offset, function(data) {
- console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
- if (typeof (data[0]) == "undefined" && moreorless=="more"){ // Return if no more pages
- pageproducts=pageproducts-1;
- return;
- }
- while (ishow < maxproduct) {
- if (typeof (data[idata]) == "undefined") {
- $("#prodivdesc"+ishow).hide();
- $("#prodesc"+ishow).text("");
- $("#probutton"+ishow).text("");
- $("#probutton"+ishow).hide();
- $("#proprice"+ishow).attr("class", "");
- $("#proprice"+ishow).html("");
- $("#proimg"+ishow).attr("src","genimg/empty.png");
- $("#prodiv"+ishow).data("rowid","");
- } else {
- $("#prodivdesc"+ishow).show();
- <?php if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?>
- $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']);
- <?php } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
- $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold());
- <?php } else { ?>
- $("#prodesc"+ishow).html(data[parseInt(idata)]['label']);
- <?php } ?>
- $("#probutton"+ishow).html(data[parseInt(idata)]['label']);
- $("#probutton"+ishow).show();
- if (data[parseInt(idata)]['price_formated']) {
- $("#proprice"+ishow).attr("class", "productprice");
- $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']);
- }
- $("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']);
- $("#prodiv"+ishow).data("rowid",data[idata]['id']);
- $("#prodiv"+ishow).data("iscat",0);
- }
- $("#prowatermark"+ishow).hide();
- ishow++; //Next product to show after print data product
- idata++; //Next data everytime
- }
- });
- ClearSearch();
- }
- function ClickProduct(position, qty = 1) {
- console.log("ClickProduct at position"+position);
- $('#proimg'+position).animate({opacity: '0.5'}, 1);
- $('#proimg'+position).animate({opacity: '1'}, 100);
- if ($('#prodiv'+position).data('iscat')==1){
- console.log("Click on a category at position "+position);
- LoadProducts(position, true);
- }
- else{
- console.log($('#prodiv4').data('rowid'));
- idproduct=$('#prodiv'+position).data('rowid');
- console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty);
- if (idproduct=="") return;
- // Call page invoice.php to generate the section with product lines
- $("#poslines").load("invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline+"&qty="+qty, function() {
- <?php if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo "CustomerDisplay();";?>
- });
- }
- ClearSearch();
- }
- function ChangeThirdparty(idcustomer) {
- console.log("ChangeThirdparty");
- // Call page list.php to change customer
- $("#poslines").load("../societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() {
- });
- ClearSearch();
- }
- function deleteline() {
- console.log("Delete line");
- $("#poslines").load("invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline, function() {
- //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- ClearSearch();
- }
- function Customer() {
- console.log("Open box to select the thirdparty place="+place);
- $.colorbox({href:"../societe/list.php?type=t&contextpage=poslist&nomassaction=1&place="+place, width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Customer"); ?>"});
- }
- function History()
- {
- console.log("Open box to select the history");
- $.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("History"); ?>"});
- }
- function Reduction() {
- invoiceid = $("#invoiceid").val();
- console.log("Open popup to enter reduction on invoiceid="+invoiceid);
- $.colorbox({href:"reduction.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
- }
- function CloseBill() {
- invoiceid = $("#invoiceid").val();
- console.log("Open popup to enter payment on invoiceid="+invoiceid);
- $.colorbox({href:"pay.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
- }
- function Split() {
- invoiceid = $("#invoiceid").val();
- console.log("Open popup to split on invoiceid="+invoiceid);
- $.colorbox({href:"split.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
- }
- function Floors() {
- console.log("Open box to select floor place="+place);
- $.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors"); ?>"});
- }
- function FreeZone() {
- console.log("Open box to enter a free product");
- $.colorbox({href:"freezone.php?action=freezone&token=<?php echo newToken(); ?>&place="+place, width:"80%", height:"200px", transition:"none", iframe:"true", title:"<?php echo $langs->trans("FreeZone"); ?>"});
- }
- function TakeposOrderNotes() {
- console.log("Open box to order notes");
- ModalBox('ModalNote');
- $("#textinput").focus();
- }
- function Refresh() {
- console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid);
- $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() {
- //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- }
- function New() {
- // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
- invoiceid = $("#invoiceid").val(); // This is a hidden field added by invoice.php
- console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid);
- $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid, function(data) {
- var r;
- if (parseInt(data['paye']) === 1) {
- r = true;
- } else {
- r = confirm('<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
- }
- if (r == true) {
- // Reload section with invoice lines
- $("#poslines").load("invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place, function () {
- //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- ClearSearch();
- }
- });
- }
- /**
- * Search products
- *
- * @param keyCodeForEnter Key code for "enter" or '' if not
- * @param moreorless "more" or "less"
- * return void
- */
- function Search2(keyCodeForEnter, moreorless) {
- var eventKeyCode = window.event.keyCode;
- console.log("Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+", eventKeyCode="+eventKeyCode);
- var search_term = $('#search').val();
- var search_start = 0;
- var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
- if (moreorless != null) {
- search_term = $('#search_pagination').val();
- search_start = $('#search_start_'+moreorless).val();
- }
- console.log("search_term="+search_term);
- if (search_term == '') {
- $("[id^=prowatermark]").html("");
- $("[id^=prodesc]").text("");
- $("[id^=probutton]").text("");
- $("[id^=probutton]").hide();
- $("[id^=proprice]").attr("class", "hidden");
- $("[id^=proprice]").html("");
- $("[id^=proimg]").attr("src", "genimg/empty.png");
- $("[id^=prodiv]").data("rowid", "");
- return;
- }
- var search = false;
- if (keyCodeForEnter == '' || eventKeyCode == keyCodeForEnter) {
- search = true;
- }
- if (search === true) {
- // if a timer has been already started (search2_timer is a global js variable), we cancel it now
- // we click onto another key, we will restart another timer just after
- if (search2_timer) {
- clearTimeout(search2_timer);
- }
- // temporization time to give time to type
- search2_timer = setTimeout(function(){
- pageproducts = 0;
- jQuery(".wrapper2 .catwatermark").hide();
- var nbsearchresults = 0;
- $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {
- for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
- if (typeof (data[i]) == "undefined") {
- $("#prowatermark" + i).html("");
- $("#prodesc" + i).text("");
- $("#probutton" + i).text("");
- $("#probutton" + i).hide();
- $("#proprice" + i).attr("class", "hidden");
- $("#proprice" + i).html("");
- $("#proimg" + i).attr("src", "genimg/empty.png");
- $("#prodiv" + i).data("rowid", "");
- continue;
- }
- <?php
- $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[i]['ref']";
- $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']";
- ?>
- var titlestring = <?php echo $titlestring; ?>;
- <?php if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?>
- $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']);
- <?php } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
- $("#prodesc" + i).html(data[i]['ref'].bold());
- <?php } else { ?>
- $("#prodesc" + i).html(data[i]['label']);
- <?php } ?>
- $("#prodivdesc" + i).show();
- $("#probutton" + i).html(data[i]['label']);
- $("#probutton" + i).show();
- if (data[i]['price_formated']) {
- $("#proprice" + i).attr("class", "productprice");
- $("#proprice" + i).html(data[i]['price_ttc_formated']);
- }
- $("#proimg" + i).attr("title", titlestring);
- if( undefined !== data[i]['img']) {
- $("#proimg" + i).attr("src", data[i]['img']);
- }
- else {
- $("#proimg" + i).attr("src", "genimg/index.php?query=pro&id=" + data[i]['rowid']);
- }
- $("#prodiv" + i).data("rowid", data[i]['rowid']);
- $("#prodiv" + i).data("iscat", 0);
- <?php
- // Add js from hooks
- $parameters=array();
- $parameters['caller'] = 'search2';
- $hookmanager->executeHooks('completeJSProductDisplay', $parameters);
- print $hookmanager->resPrint;
- ?>
- nbsearchresults++;
- }
- }).always(function (data) {
- // If there is only 1 answer
- if ($('#search').val().length > 0 && data.length == 1) {
- console.log($('#search').val()+' - '+data[0]['barcode']);
- if ($('#search').val() == data[0]['barcode'] && 'thirdparty' == data[0]['object']) {
- console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']);
- ChangeThirdparty(data[0]['rowid']);
- }
- else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) {
- console.log("There is only 1 answer and we found search on a barcode, so we add the product in basket, qty="+data[0]['qty']);
- ClickProduct(0, data[0]['qty']);
- }
- }
- if (eventKeyCode == keyCodeForEnter){
- if (data.length == 0) {
- $('#search').val('<?php
- $langs->load('errors');
- echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
- ?> ('+search_term+')');
- $('#search').select();
- }
- else ClearSearch();
- }
- // memorize search_term and start for pagination
- $("#search_pagination").val($("#search").val());
- if (search_start == 0) {
- $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
- }
- else {
- $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
- var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
- $("#search_start_less").val(search_start_less);
- }
- if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
- $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
- }
- else {
- $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
- var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
- $("#search_start_more").val(search_start_more);
- }
- });
- }, 500); // 500ms delay
- }
- }
- /* Function called on an action into the PAD */
- function Edit(number) {
- console.log("We click on PAD on key="+number);
- if (typeof(selectedtext) == "undefined") {
- return; // We click on an action on the number pad but there is no line selected
- }
- var text=selectedtext+"<br> ";
- if (number=='c') {
- editnumber='';
- Refresh();
- $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
- $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
- $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
- return;
- } else if (number=='qty') {
- if (editaction=='qty' && editnumber != '') {
- $("#poslines").load("invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
- editnumber="";
- //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
- });
- setFocusOnSearchField();
- return;
- }
- else {
- editaction="qty";
- }
- } else if (number=='p') {
- if (editaction=='p' && editnumber!="") {
- $("#poslines").load("invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
- editnumber="";
- //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
- });
- ClearSearch();
- return;
- }
- else {
- editaction="p";
- }
- } else if (number=='r') {
- if (editaction=='r' && editnumber!="") {
- $("#poslines").load("invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
- editnumber="";
- //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
- });
- ClearSearch();
- return;
- }
- else {
- editaction="r";
- }
- }
- else {
- editnumber=editnumber+number;
- }
- if (editaction=='qty'){
- text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Qty").": "; ?>";
- $("#qty").html("OK").addClass("clicked");
- $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
- $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
- }
- if (editaction=='p'){
- text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Price").": "; ?>";
- $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
- $("#price").html("OK").addClass("clicked");
- $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
- }
- if (editaction=='r'){
- text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("ReductionShort").": "; ?>";
- $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
- $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
- $("#reduction").html("OK").addClass("clicked");
- }
- $('#'+selectedline).find("td:first").html(text+editnumber);
- }
- function TakeposPrintingOrder(){
- console.log("TakeposPrintingOrder");
- $("#poslines").load("invoice.php?action=order&token=<?php echo newToken();?>&place="+place, function() {
- //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- }
- function TakeposPrintingTemp(){
- console.log("TakeposPrintingTemp");
- $("#poslines").load("invoice.php?action=temp&token=<?php echo newToken();?>&place="+place, function() {
- //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- }
- function OpenDrawer(){
- console.log("OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
- $.ajax({
- type: "POST",
- data: { token: 'notrequired' },
- <?php
- if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
- echo "url: '".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost')."/printer/drawer.php',";
- } else {
- echo "url: 'http://".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost').":8111/print',";
- }
- ?>
- data: "opendrawer"
- });
- }
- function DolibarrOpenDrawer() {
- console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal"]); ?>");
- $.ajax({
- type: "GET",
- data: { token: '<?php echo currentToken(); ?>' },
- url: "<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode($_SESSION["takeposterminal"]); ?>",
- });
- }
- function MoreActions(totalactions){
- if (pageactions==0){
- pageactions=1;
- for (i = 0; i <= totalactions; i++){
- if (i<12) $("#action"+i).hide();
- else $("#action"+i).show();
- }
- }
- else if (pageactions==1){
- pageactions=0;
- for (i = 0; i <= totalactions; i++){
- if (i<12) $("#action"+i).show();
- else $("#action"+i).hide();
- }
- }
- return true;
- }
- function ControlCashOpening()
- {
- $.colorbox({href:"../compta/cashcontrol/cashcontrol_card.php?action=create&contextpage=takepos", width:"90%", height:"60%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("NewCashFence"); ?>"});
- }
- function CloseCashFence(rowid)
- {
- $.colorbox({href:"../compta/cashcontrol/cashcontrol_card.php?id="+rowid+"&contextpage=takepos", width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("NewCashFence"); ?>"});
- }
- function CashReport(rowid)
- {
- $.colorbox({href:"../compta/cashcontrol/report.php?id="+rowid+"&contextpage=takepos", width:"60%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("CashReport"); ?>"});
- }
- // TakePOS Popup
- function ModalBox(ModalID)
- {
- var modal = document.getElementById(ModalID);
- modal.style.display = "block";
- }
- function DirectPayment(){
- console.log("DirectPayment");
- $("#poslines").load("invoice.php?place="+place+"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ", function() {
- });
- }
- function FullScreen() {
- document.documentElement.requestFullscreen();
- }
- function WeighingScale(){
- console.log("Weighing Scale");
- $.ajax({
- type: "POST",
- data: { token: 'notrequired' },
- url: '<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>/scale/index.php',
- })
- .done(function( editnumber ) {
- $("#poslines").load("invoice.php?&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
- editnumber="";
- });
- });
- }
- $( document ).ready(function() {
- PrintCategories(0);
- LoadProducts(0);
- Refresh();
- <?php
- //IF NO TERMINAL SELECTED
- if ($_SESSION["takeposterminal"] == "") {
- print "ModalBox('ModalTerminal');";
- }
- if (getDolGlobalString('TAKEPOS_CONTROL_CASH_OPENING')) {
- $sql = "SELECT rowid, status 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) {
- $obj = $db->fetch_object($resql);
- // If there is no cash control from today open it
- if (!isset($obj->rowid) || is_null($obj->rowid)) {
- print "ControlCashOpening();";
- }
- }
- }
- ?>
- /* For Header Scroll */
- var elem1 = $("#topnav-left")[0];
- var elem2 = $("#topnav-right")[0];
- var checkOverflow = function() {
- if (scrollBars().horizontal) $("#topnav").addClass("overflow");
- else $("#topnav").removeClass("overflow");
- }
- var scrollBars = function(){
- var container= $('#topnav')[0];
- return {
- vertical:container.scrollHeight > container.clientHeight,
- horizontal:container.scrollWidth > container.clientWidth
- }
- }
- $(window).resize(function(){
- checkOverflow();
- });
- let resizeObserver = new ResizeObserver(() => {
- checkOverflow();
- });
- resizeObserver.observe(elem1);
- resizeObserver.observe(elem2);
- checkOverflow();
- var pressTimer = [];
- var direction = 1;
- var step = 200;
- $(".indicator").mousedown(function(){
- direction = $(this).hasClass("left") ? -1 : 1;
- scrollTo();
- pressTimer.push(setInterval(scrollTo, 100));
- });
- $(".indicator").mouseup(function(){
- pressTimer.forEach(clearInterval);
- });
- $("body").mouseup(function(){
- pressTimer.forEach(clearInterval);
- console.log("body");
- });
- function scrollTo(){
- console.log("here");
- var pos = $("#topnav").scrollLeft();
- document.getElementById("topnav").scrollTo({ left: $("#topnav").scrollLeft() + direction * step, behavior: 'smooth' })
- }
- $("#topnav").scroll(function(){
- if (($("#topnav").offsetWidth + $("#topnav").scrollLeft >= $("#topnav").scrollWidth)) {
- console.log("end");
- }
- });
- /* End Header Scroll */
- });
- </script>
- <?php
- $keyCodeForEnter = getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) > 0 ? getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) : '';
- ?>
- <div class="container">
- <?php
- if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
- ?>
- <div class="header">
- <div id="topnav" class="topnav">
- <div id="topnav-left" class="topnav-left">
- <div class="inline-block valignmiddle">
- <a class="topnav-terminalhour" onclick="ModalBox('ModalTerminal')">
- <span class="fa fa-cash-register"></span>
- <span class="hideonsmartphone">
- <?php echo getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$_SESSION["takeposterminal"], $langs->trans("TerminalName", $_SESSION["takeposterminal"])); ?>
- </span>
- <?php
- echo '<span class="hideonsmartphone"> - '.dol_print_date(dol_now(), "day").'</span>';
- ?>
- </a>
- <?php
- if (isModEnabled('multicurrency')) {
- print '<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
- print '<span class="hideonsmartphone">'.$langs->trans("Currency").'</span>';
- print '</a>';
- }
- ?>
- </div>
- <!-- section for customer -->
- <div class="inline-block valignmiddle" id="customerandsales"></div>
- <!-- section for shopping carts -->
- <div class="inline-block valignmiddle" id="shoppingcart"></div>
- <!-- More info about customer -->
- <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="moreinfo"></div>
- <?php
- if (isModEnabled('stock')) {
- ?>
- <!-- More info about warehouse -->
- <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="infowarehouse"></div>
- <?php
- }
- ?>
- </div>
- <div id="topnav-right" class="topnav-right">
- <?php
- $reshook = $hookmanager->executeHooks('takepos_login_block_other');
- if ($reshook == 0) { //Search method ?>
- <div class="login_block_other">
- <input type="text" id="search" name="search" class="input-nobottom" onkeyup="Search2('<?php echo dol_escape_js($keyCodeForEnter); ?>', null);" placeholder="<?php echo dol_escape_htmltag($langs->trans("Search")); ?>" autofocus>
- <a onclick="ClearSearch();"><span class="fa fa-backspace"></span></a>
- <a href="<?php echo DOL_URL_ROOT.'/'; ?>" target="backoffice" rel="opener"><!-- we need rel="opener" here, we are on same domain and we need to be able to reuse this tab several times -->
- <span class="fas fa-home"></span></a>
- <?php if (empty($conf->dol_use_jmobile)) {?>
- <a class="hideonsmartphone" onclick="FullScreen();" title="<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave")); ?>"><span class="fa fa-expand-arrows-alt"></span></a>
- <?php }?>
- </div>
- <?php
- }?>
- <div class="login_block_user">
- <?php
- print top_menu_user(1);
- ?>
- </div>
- </div>
- <div class="arrows">
- <span class="indicator left"><i class="fa fa-arrow-left"></i></span>
- <span class="indicator right"><i class="fa fa-arrow-right"></i></span>
- </div>
- </div>
- </div>
- <?php
- }
- ?>
- <!-- Modal terminal box -->
- <div id="ModalTerminal" class="modal">
- <div class="modal-content">
- <div class="modal-header">
- <?php
- if (empty($conf->global->TAKEPOS_FORCE_TERMINAL_SELECT)) {
- ?>
- <span class="close" href="#" onclick="document.getElementById('ModalTerminal').style.display = 'none';">×</span>
- <?php } ?>
- <h3><?php print $langs->trans("TerminalSelect"); ?></h3>
- </div>
- <div class="modal-body">
- <button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print getDolGlobalString("TAKEPOS_TERMINAL_NAME_1", $langs->trans("TerminalName", 1)); ?></button>
- <?php
- $nbloop = getDolGlobalInt('TAKEPOS_NUM_TERMINALS');
- for ($i = 2; $i <= $nbloop; $i++) {
- print '<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$i, $langs->trans("TerminalName", $i)).'</button>';
- }
- ?>
- </div>
- </div>
- </div>
- <!-- Modal multicurrency box -->
- <?php if (isModEnabled('multicurrency')) { ?>
- <div id="ModalCurrency" class="modal">
- <div class="modal-content">
- <div class="modal-header">
- <span class="close" href="#" onclick="document.getElementById('ModalCurrency').style.display = 'none';">×</span>
- <h3><?php print $langs->trans("SetMultiCurrencyCode"); ?></h3>
- </div>
- <div class="modal-body">
- <?php
- $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
- $sql .= " WHERE entity IN ('".getEntity('multicurrency')."')";
- $resql = $db->query($sql);
- if ($resql) {
- while ($obj = $db->fetch_object($resql)) {
- print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>';
- }
- }
- ?>
- </div>
- </div>
- </div>
- <?php } ?>
- <!-- Modal terminal Credit Note -->
- <div id="ModalCreditNote" class="modal">
- <div class="modal-content">
- <div class="modal-header">
- <span class="close" href="#" onclick="document.getElementById('ModalCreditNote').style.display = 'none';">×</span>
- <h3><?php print $langs->trans("invoiceAvoirWithLines"); ?></h3>
- </div>
- <div class="modal-body">
- <button type="button" class="block" onclick="CreditNote(); document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("Yes"); ?></button>
- <button type="button" class="block" onclick="document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("No"); ?></button>
- </div>
- </div>
- </div>
- <!-- Modal Note -->
- <div id="ModalNote" class="modal">
- <div class="modal-content">
- <div class="modal-header">
- <span class="close" href="#" onclick="document.getElementById('ModalNote').style.display = 'none';">×</span>
- <h3><?php print $langs->trans("Note"); ?></h3>
- </div>
- <div class="modal-body">
- <input type="text" class="block" id="textinput">
- <button type="button" class="block" onclick="SetNote(); document.getElementById('ModalNote').style.display = 'none';">OK</button>
- </div>
- </div>
- </div>
- <div class="row1<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
- print 'withhead';
- } ?>">
- <div id="poslines" class="div1">
- </div>
- <div class="div2">
- <button type="button" class="calcbutton" onclick="Edit(7);">7</button>
- <button type="button" class="calcbutton" onclick="Edit(8);">8</button>
- <button type="button" class="calcbutton" onclick="Edit(9);">9</button>
- <button type="button" id="qty" class="calcbutton2" onclick="Edit('qty')"><?php echo $langs->trans("Qty"); ?></button>
- <button type="button" class="calcbutton" onclick="Edit(4);">4</button>
- <button type="button" class="calcbutton" onclick="Edit(5);">5</button>
- <button type="button" class="calcbutton" onclick="Edit(6);">6</button>
- <button type="button" id="price" class="calcbutton2" onclick="Edit('p')"><?php echo $langs->trans("Price"); ?></button>
- <button type="button" class="calcbutton" onclick="Edit(1);">1</button>
- <button type="button" class="calcbutton" onclick="Edit(2);">2</button>
- <button type="button" class="calcbutton" onclick="Edit(3);">3</button>
- <button type="button" id="reduction" class="calcbutton2" onclick="Edit('r')"><?php echo $langs->trans("ReductionShort"); ?></button>
- <button type="button" class="calcbutton" onclick="Edit(0);">0</button>
- <button type="button" class="calcbutton" onclick="Edit('.')">.</button>
- <button type="button" class="calcbutton poscolorblue" onclick="Edit('c')">C</button>
- <button type="button" class="calcbutton2 poscolordelete" id="delete" onclick="deleteline()"><span class="fa fa-trash"></span></button>
- </div>
- <?php
- // TakePOS setup check
- if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) {
- $sql = "SELECT code, libelle FROM " . MAIN_DB_PREFIX . "c_paiement";
- $sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")";
- $sql .= " AND active = 1";
- $sql .= " ORDER BY libelle";
- $resql = $db->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 ( !empty($conf->global->$constantforkey) && getDolGlobalInt($constantforkey) > 0) {
- array_push($paiementsModes, $obj);
- }
- }
- }
- if (empty($paiementsModes) && isModEnabled("banque")) {
- $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'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("New").'</div>', 'action'=>'New();');
- } else {
- // BAR RESTAURANT specific menu
- $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("Place").'</div>', 'action'=>'Floors();');
- }
- if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
- $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Customer").'</div>', 'action'=>'Customer();');
- }
- if ( ! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
- $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly"></span><div class="trunc">'.$langs->trans("History").'</div>', 'action'=>'History();');
- }
- $menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly"></span><div class="trunc">'.$langs->trans("FreeZone").'</div>', 'action'=>'FreeZone();');
- $menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly"></span><div class="trunc">'.$langs->trans("Reduction").'</div>', 'action'=>'Reduction();');
- $menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("Payment").'</div>', 'action'=>'CloseBill();');
- if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
- $menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("DirectPayment").' <span class="opacitymedium">('.$langs->trans("Cash").')</span></div>', 'action'=>'DirectPayment();');
- }
- $menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly"></span><div class="trunc">'.$langs->trans("SplitSale").'</div>', 'action'=>'Split();');
- // BAR RESTAURANT specific menu
- if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
- if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
- $menus[$r++] = array('title'=>'<span class="fa fa-blender-phone paddingrightonly"></span><div class="trunc">'.$langs->trans("Order").'</span>', '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'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposConnector(placeid);');
- } else {
- $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposPrinting(placeid);');
- }
- } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
- $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
- } else {
- $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'Print(placeid);');
- }
- }
- if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
- $menus[$r++] = array('title'=>'<span class="fa fa-sticky-note paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action'=>'TakeposOrderNotes();');
- }
- if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
- $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action'=>'LoadProducts(\'supplements\');');
- }
- }
- if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
- $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>', 'action'=>'OpenDrawer();');
- }
- if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
- $menus[$r++] = array(
- 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>',
- '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'=>'<span class="fas fa-file-invoice-dollar paddingrightonly"></span><div class="trunc">'.$langs->trans("CashReport").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
- if ($obj->status == 0) {
- $menus[$r++] = array('title'=>'<span class="fas fa-cash-register paddingrightonly"></span><div class="trunc">'.$langs->trans("CloseCashFence").'</div>', '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 (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
- $menus[$r++] = array('title'=>'<span class="fa fa-sign-out-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("Logout").'</div>', 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php?token='.newToken().'\';');
- }
- if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
- $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly"></span><div class="trunc">'.$langs->trans("WeighingScale").'</div>', 'action'=>'WeighingScale();');
- }
- ?>
- <!-- Show buttons -->
- <div class="div3">
- <?php
- $i = 0;
- foreach ($menus as $menu) {
- $i++;
- if (count($menus) > 12 and $i == 12) {
- echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="actionnext" class="actionbutton" onclick="MoreActions('.count($menus).')">'.$langs->trans("Next").'</button>';
- echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
- } elseif ($i > 12) {
- echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
- } else {
- echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
- }
- }
- if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
- print '<!-- Show the search input text -->'."\n";
- print '<div class="margintoponly">';
- print '<input type="text" id="search" class="input-nobottom" name="search" onkeyup="Search2(\''.dol_escape_js($keyCodeForEnter).'\', null);" style="width: 80%; width:calc(100% - 51px); font-size: 150%;" placeholder="'.dol_escape_htmltag($langs->trans("Search")).'" autofocus> ';
- print '<a class="marginleftonly hideonsmartphone" onclick="ClearSearch();">'.img_picto('', 'searchclear').'</a>';
- print '</div>';
- }
- ?>
- </div>
- </div>
- <div class="row2<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
- print 'withhead';
- } ?>">
- <!-- Show categories -->
- <?php
- if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
- print '<div class="div4" style= "display: none;">';
- } else {
- print '<div class="div4">';
- }
- $count = 0;
- while ($count < $MAXCATEG) {
- ?>
- <div class="wrapper" <?php if ($count == ($MAXCATEG - 2)) {
- echo 'onclick="MoreCategories(\'less\')"';
- } elseif ($count == ($MAXCATEG - 1)) {
- echo 'onclick="MoreCategories(\'more\')"';
- } else {
- echo 'onclick="LoadProducts('.$count.')"';
- } ?> id="catdiv<?php echo $count; ?>">
- <?php
- if ($count == ($MAXCATEG - 2)) {
- //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="catimg'.$count.'" />';
- echo '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
- } elseif ($count == ($MAXCATEG - 1)) {
- //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="catimg'.$count.'" />';
- echo '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
- } else {
- if (!getDolGlobalString('TAKEPOS_HIDE_CATEGORY_IMAGES')) {
- echo '<img class="imgwrapper" id="catimg'.$count.'" />';
- }
- }
- ?>
- <?php if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?>
- <div class="description" id="catdivdesc<?php echo $count; ?>">
- <div class="description_content" id="catdesc<?php echo $count; ?>"></div>
- </div>
- <?php } ?>
- <div class="catwatermark" id='catwatermark<?php echo $count; ?>'>...</div>
- </div>
- <?php
- $count++;
- }
- ?>
- </div>
- <!-- Show product -->
- <div class="div5"<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
- print ' style="width:100%;"';
- } ?>>
- <?php
- $count = 0;
- while ($count < $MAXPRODUCT) {
- print '<div class="wrapper2 arrow" id="prodiv'.$count.'" ';
- ?>
- <?php if ($count == ($MAXPRODUCT - 2)) {
- ?> onclick="MoreProducts('less')" <?php
- } if ($count == ($MAXPRODUCT - 1)) {
- ?> onclick="MoreProducts('more')" <?php
- } else {
- echo 'onclick="ClickProduct('.$count.')"';
- } ?>>
- <?php
- if ($count == ($MAXPRODUCT - 2)) {
- //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';
- print '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
- } elseif ($count == ($MAXPRODUCT - 1)) {
- //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="proimg'.$count.'" />';
- print '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
- } else {
- if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_PRICES')) {
- print '<div class="" id="proprice'.$count.'"></div>';
- }
- if (getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
- print '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>';
- } else {
- print '<img class="imgwrapper" title="" id="proimg'.$count.'">';
- }
- }
- ?>
- <?php if ($count != ($MAXPRODUCT - 2) && $count != ($MAXPRODUCT - 1) && !getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
- <div class="description" id="prodivdesc<?php echo $count; ?>">
- <div class="description_content" id="prodesc<?php echo $count; ?>"></div>
- </div>
- <?php } ?>
- <div class="catwatermark" id='prowatermark<?php echo $count; ?>'>...</div>
- </div>
- <?php
- $count++;
- }
- ?>
- <input type="hidden" id="search_start_less" value="0">
- <input type="hidden" id="search_start_more" value="0">
- <input type="hidden" id="search_pagination" value="">
- </div>
- </div>
- </div>
- </body>
- <?php
- llxFooter();
- $db->close();
|