1<?php 2/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com> 3 * Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat> 4 * Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 20/** 21 * \file htdocs/takepos/index.php 22 * \ingroup takepos 23 * \brief Main TakePOS screen 24 */ 25 26//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language 27//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language 28//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); 29//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); 30if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); 31if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); 32if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); 33if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); 34if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); 35 36require '../main.inc.php'; // Load $user and permissions 37require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; 38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; 39require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; 40require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; 41require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; 42require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; 43require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; 44 45$place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Bar or Restaurant or multiple sales 46$action = GETPOST('action', 'aZ09'); 47$setterminal = GETPOST('setterminal', 'int'); 48$setcurrency = GETPOST('setcurrency', 'aZ09'); 49 50if ($_SESSION["takeposterminal"] == "") 51{ 52 if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal 53 elseif (!empty($_COOKIE["takeposterminal"])) $_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session 54} 55 56if ($setterminal > 0) 57{ 58 $_SESSION["takeposterminal"] = $setterminal; 59 setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, false, true); // Permanent takeposterminal var in a cookie 60} 61 62if ($setcurrency != "") 63{ 64 $_SESSION["takeposcustomercurrency"] = $setcurrency; 65} 66 67$_SESSION["urlfrom"] = '/takepos/index.php'; 68 69$langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter", "banks")); 70 71$categorie = new Categorie($db); 72 73$maxcategbydefaultforthisdevice = 12; 74$maxproductbydefaultforthisdevice = 24; 75if ($conf->browser->layout == 'phone') 76{ 77 $maxcategbydefaultforthisdevice = 8; 78 $maxproductbydefaultforthisdevice = 16; 79 //REDIRECT TO BASIC LAYOUT IF TERMINAL SELECTED AND BASIC MOBILE LAYOUT ENABLED 80 if ($_SESSION["takeposterminal"] != "" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) 81 { 82 $_SESSION["basiclayout"] = 1; 83 header("Location: phone.php?mobilepage=invoice"); 84 exit; 85 } 86} 87$MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG); 88$MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT); 89 90/* 91$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; 92$soc = new Societe($db); 93if ($invoice->socid > 0) $soc->fetch($invoice->socid); 94else $soc->fetch($conf->global->$constforcompanyid); 95*/ 96 97// Security check 98$result = restrictedArea($user, 'takepos', 0, ''); 99 100 101 102/* 103 * View 104 */ 105 106$form = new Form($db); 107 108// Title 109$title = 'TakePOS - Dolibarr '.DOL_VERSION; 110if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; 111$head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/> 112<meta name="apple-mobile-web-app-capable" content="yes"> 113<meta name="mobile-web-app-capable" content="yes"> 114<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>'; 115top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); 116 117?> 118<link rel="stylesheet" href="css/pos.css.php"> 119<link rel="stylesheet" href="css/colorbox.css" type="text/css" media="screen" /> 120<?php 121if ($conf->global->TAKEPOS_COLOR_THEME == 1) print '<link rel="stylesheet" href="css/colorful.css">'; 122?> 123<script type="text/javascript" src="js/jquery.colorbox-min.js"></script> <!-- TODO It seems we don't need this --> 124<script language="javascript"> 125<?php 126$categories = $categorie->get_full_arbo('product', (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) ? $conf->global->TAKEPOS_ROOT_CATEGORY_ID : 0), 1); 127 128 129// Search root category to know its level 130//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0; 131$levelofrootcategory = 0; 132if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) 133{ 134 foreach ($categories as $key => $categorycursor) 135 { 136 if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) 137 { 138 $levelofrootcategory = $categorycursor['level']; 139 break; 140 } 141 } 142} 143 144$levelofmaincategories = $levelofrootcategory + 1; 145 146$maincategories = array(); 147$subcategories = array(); 148foreach ($categories as $key => $categorycursor) 149{ 150 if ($categorycursor['level'] == $levelofmaincategories) 151 { 152 $maincategories[$key] = $categorycursor; 153 } else { 154 $subcategories[$key] = $categorycursor; 155 } 156} 157 158$maincategories = dol_sort_array($maincategories, 'label'); 159$subcategories = dol_sort_array($subcategories, 'label'); 160?> 161 162var categories = <?php echo json_encode($maincategories); ?>; 163var subcategories = <?php echo json_encode($subcategories); ?>; 164 165var currentcat; 166var pageproducts=0; 167var pagecategories=0; 168var pageactions=0; 169var place="<?php echo $place; ?>"; 170var editaction="qty"; 171var editnumber=""; 172var invoiceid=0; 173 174/* 175var app = this; 176app.hasKeyboard = false; 177this.keyboardPress = function() { 178 app.hasKeyboard = true; 179 $(window).unbind("keyup", app.keyboardPress); 180 localStorage.hasKeyboard = true; 181 console.log("has keyboard!") 182} 183$(window).on("keyup", app.keyboardPress) 184if(localStorage.hasKeyboard) { 185 app.hasKeyboard = true; 186 $(window).unbind("keyup", app.keyboardPress); 187 console.log("has keyboard from localStorage") 188} 189*/ 190 191function ClearSearch() { 192 console.log("ClearSearch"); 193 $("#search").val(''); 194 <?php if ($conf->browser->layout == 'classic') { ?> 195 setFocusOnSearchField(); 196 <?php } ?> 197} 198 199// 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 200function setFocusOnSearchField() { 201 console.log("Call setFocusOnSearchField in page index.php"); 202 <?php if ($conf->browser->layout == 'classic') { ?> 203 console.log("has keyboard from localStorage, so we can force focus on search field"); 204 $("#search").focus(); 205 <?php } ?> 206} 207 208function PrintCategories(first) { 209 console.log("PrintCategories"); 210 for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) { 211 if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined") 212 { 213 $("#catdivdesc"+i).hide(); 214 $("#catdesc"+i).text(""); 215 $("#catimg"+i).attr("src","genimg/empty.png"); 216 $("#catwatermark"+i).hide(); 217 $("#catdiv"+i).attr('class', 'wrapper divempty'); 218 continue; 219 } 220 $("#catdivdesc"+i).show(); 221 $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); 222 $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']); 223 $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']); 224 $("#catdiv"+i).attr('class', 'wrapper'); 225 $("#catwatermark"+i).show(); 226 } 227} 228 229function MoreCategories(moreorless) { 230 console.log("MoreCategories moreorless="+moreorless+" pagecategories="+pagecategories); 231 if (moreorless=="more") { 232 $('#catimg15').animate({opacity: '0.5'}, 1); 233 $('#catimg15').animate({opacity: '1'}, 100); 234 pagecategories=pagecategories+1; 235 } 236 if (moreorless=="less") { 237 $('#catimg14').animate({opacity: '0.5'}, 1); 238 $('#catimg14').animate({opacity: '1'}, 100); 239 if (pagecategories==0) return; //Return if no less pages 240 pagecategories=pagecategories-1; 241 } 242 if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless=="more") == "undefined"){ // Return if no more pages 243 pagecategories=pagecategories-1; 244 return; 245 } 246 for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) { 247 if (typeof (categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]) == "undefined") { 248 $("#catdivdesc"+i).hide(); 249 $("#catdesc"+i).text(""); 250 $("#catimg"+i).attr("src","genimg/empty.png"); 251 $("#catwatermark"+i).hide(); 252 continue; 253 } 254 $("#catdivdesc"+i).show(); 255 $("#catdesc"+i).text(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['label']); 256 $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']); 257 $("#catdiv"+i).data("rowid",categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']); 258 $("#catwatermark"+i).show(); 259 } 260 261 ClearSearch(); 262} 263 264// LoadProducts 265function LoadProducts(position, issubcat) { 266 console.log("LoadProducts"); 267 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>; 268 269 if (position=="supplements") currentcat="supplements"; 270 else 271 { 272 $('#catimg'+position).animate({opacity: '0.5'}, 1); 273 $('#catimg'+position).animate({opacity: '1'}, 100); 274 if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid'); 275 else currentcat=$('#catdiv'+position).data('rowid'); 276 } 277 if (currentcat == undefined) return; 278 pageproducts=0; 279 ishow=0; //product to show counter 280 281 jQuery.each(subcategories, function(i, val) { 282 if (currentcat==val.fk_parent) { 283 $("#prodivdesc"+ishow).show(); 284 $("#prodesc"+ishow).text(val.label); 285 $("#proprice"+ishow).attr("class", "hidden"); 286 $("#proprice"+ishow).html(""); 287 $("#proimg"+ishow).attr("src","genimg/index.php?query=cat&id="+val.rowid); 288 $("#prodiv"+ishow).data("rowid",val.rowid); 289 $("#prodiv"+ishow).data("iscat",1); 290 $("#prowatermark"+ishow).show(); 291 ishow++; 292 } 293 }); 294 295 idata=0; //product data counter 296 $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&category='+currentcat, function(data) { 297 console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs"); 298 console.log(data); 299 while (ishow < maxproduct) { 300 //console.log("ishow"+ishow+" idata="+idata); 301 console.log(data[idata]); 302 if (typeof (data[idata]) == "undefined") { 303 <?php if (!$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) 304 { 305 echo '$("#prodivdesc"+ishow).hide();'; 306 echo '$("#prodesc"+ishow).text("");'; 307 echo '$("#proimg"+ishow).attr("title","");'; 308 echo '$("#proimg"+ishow).attr("src","genimg/empty.png");'; 309 } else { 310 echo '$("#probutton"+ishow).hide();'; 311 echo '$("#probutton"+ishow).text("");'; 312 }?> 313 $("#proprice"+ishow).attr("class", "hidden"); 314 $("#proprice"+ishow).html(""); 315 $("#prodiv"+ishow).data("rowid",""); 316 $("#prodiv"+ishow).attr("class","wrapper2 divempty"); 317 $("#prowatermark"+ishow).hide(); 318 ishow++; //Next product to show after print data product 319 } 320 else if ((data[idata]['status']) == "1") { // Only show products with status=1 (for sell) 321 <?php 322 $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[idata]['ref']"; 323 $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']"; 324 ?> 325 var titlestring = <?php echo $titlestring; ?>; 326 <?php if (!$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) 327 { 328 echo '$("#prodivdesc"+ishow).show();'; 329 echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);'; 330 echo '$("#proimg"+ishow).attr("title", titlestring);'; 331 echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);'; 332 } 333 else { 334 echo '$("#probutton"+ishow).show();'; 335 echo '$("#probutton"+ishow).text(data[parseInt(idata)][\'label\']);'; 336 } 337 ?> 338 if (data[parseInt(idata)]['price_formated']) { 339 $("#proprice"+ishow).attr("class", "productprice"); 340 $("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']); 341 } 342 $("#prodiv"+ishow).data("rowid", data[idata]['id']); 343 $("#prodiv"+ishow).data("iscat", 0); 344 $("#prodiv"+ishow).attr("class","wrapper2"); 345 $("#prowatermark"+ishow).hide(); 346 ishow++; //Next product to show after print data product 347 } 348 //console.log("Hide the prowatermark for ishow="+ishow); 349 idata++; //Next data everytime 350 } 351 }); 352 353 ClearSearch(); 354} 355 356function MoreProducts(moreorless) { 357 console.log("MoreProducts"); 358 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>; 359 360 if (moreorless=="more"){ 361 $('#proimg31').animate({opacity: '0.5'}, 1); 362 $('#proimg31').animate({opacity: '1'}, 100); 363 pageproducts=pageproducts+1; 364 } 365 if (moreorless=="less"){ 366 $('#proimg30').animate({opacity: '0.5'}, 1); 367 $('#proimg30').animate({opacity: '1'}, 100); 368 if (pageproducts==0) return; //Return if no less pages 369 pageproducts=pageproducts-1; 370 } 371 $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&category='+currentcat, function(data) { 372 console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat); 373 374 if (typeof (data[(maxproduct * pageproducts)]) == "undefined" && moreorless=="more"){ // Return if no more pages 375 pageproducts=pageproducts-1; 376 return; 377 } 378 idata=<?php echo ($MAXPRODUCT - 2); ?> * pageproducts; //product data counter 379 ishow=0; //product to show counter 380 381 while (ishow < maxproduct) { 382 if (typeof (data[idata]) == "undefined") { 383 $("#prodivdesc"+ishow).hide(); 384 $("#prodesc"+ishow).text(""); 385 $("#proprice"+ishow).attr("class", ""); 386 $("#proprice"+ishow).html(""); 387 $("#proimg"+ishow).attr("src","genimg/empty.png"); 388 $("#prodiv"+ishow).data("rowid",""); 389 ishow++; //Next product to show after print data product 390 } 391 else if ((data[idata]['status']) == "1") { 392 //Only show products with status=1 (for sell) 393 $("#prodivdesc"+ishow).show(); 394 $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); 395 if (data[parseInt(idata)]['price_formated']) { 396 $("#proprice"+ishow).attr("class", "productprice"); 397 $("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']); 398 } 399 $("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']); 400 $("#prodiv"+ishow).data("rowid",data[idata]['id']); 401 $("#prodiv"+ishow).data("iscat",0); 402 ishow++; //Next product to show after print data product 403 } 404 $("#prowatermark"+ishow).hide(); 405 idata++; //Next data everytime 406 } 407 }); 408 409 ClearSearch(); 410} 411 412function ClickProduct(position) { 413 console.log("ClickProduct"); 414 $('#proimg'+position).animate({opacity: '0.5'}, 1); 415 $('#proimg'+position).animate({opacity: '1'}, 100); 416 if ($('#prodiv'+position).data('iscat')==1){ 417 console.log("Click on a category at position "+position); 418 LoadProducts(position, true); 419 } 420 else{ 421 idproduct=$('#prodiv'+position).data('rowid'); 422 console.log("Click on product at position "+position+" for idproduct "+idproduct); 423 if (idproduct=="") return; 424 // Call page invoice.php to generate the section with product lines 425 $("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline, function() { 426 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); 427 }); 428 } 429 430 ClearSearch(); 431} 432 433function ChangeThirdparty(idcustomer) { 434 console.log("ChangeThirdparty"); 435 // Call page list.php to change customer 436 $("#poslines").load("../societe/list.php?action=change&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() { 437 }); 438 439 ClearSearch(); 440} 441 442function deleteline() { 443 console.log("Delete line"); 444 $("#poslines").load("invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline, function() { 445 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); 446 }); 447 ClearSearch(); 448} 449 450function Customer() { 451 console.log("Open box to select the thirdparty place="+place); 452 $.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"); ?>"}); 453} 454 455function History() 456{ 457 console.log("Open box to select the history"); 458 $.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("History"); ?>"}); 459} 460 461function Reduction() { 462 invoiceid = $("#invoiceid").val(); 463 console.log("Open popup to enter reduction on invoiceid="+invoiceid); 464 $.colorbox({href:"reduction.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""}); 465} 466 467function CloseBill() { 468 invoiceid = $("#invoiceid").val(); 469 console.log("Open popup to enter payment on invoiceid="+invoiceid); 470 $.colorbox({href:"pay.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""}); 471} 472 473function Floors() { 474 console.log("Open box to select floor place="+place); 475 $.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors"); ?>"}); 476} 477 478function FreeZone() { 479 console.log("Open box to enter a free product"); 480 $.colorbox({href:"freezone.php?action=freezone&place="+place, onClosed: function () { Refresh(); },width:"80%", height:"200px", transition:"none", iframe:"true", title:"<?php echo $langs->trans("FreeZone"); ?>"}); 481} 482 483function TakeposOrderNotes() { 484 console.log("Open box to order notes"); 485 $.colorbox({href:"freezone.php?action=addnote&place="+place+"&idline="+selectedline, onClosed: function () { Refresh(); },width:"80%", height:"250px", transition:"none", iframe:"true", title:"<?php echo $langs->trans("OrderNotes"); ?>"}); 486} 487 488function Refresh() { 489 console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid); 490 $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() { 491 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); 492 }); 493} 494 495function New() { 496 // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined 497 invoiceid = $("#invoiceid").val(); 498 499 console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid); 500 501 $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&id='+invoiceid, function(data) { 502 var r; 503 504 if (parseInt(data['paye']) === 1) { 505 r = true; 506 } else { 507 r = confirm('<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>'); 508 } 509 510 if (r == true) { 511 // Reload section with invoice lines 512 $("#poslines").load("invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place, function () { 513 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); 514 }); 515 ClearSearch(); 516 } 517 }); 518} 519 520/** 521 * Search products 522 * 523 * @param {int} keyCodeForEnter Key code for "enter" 524 * return {void} 525 */ 526function Search2(keyCodeForEnter) { 527 console.log("Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter); 528 529 var search = false; 530 var eventKeyCode = window.event.keyCode; 531 if (typeof keyCodeForEnter === 'undefined' || eventKeyCode == keyCodeForEnter) { 532 search = true; 533 } 534 535 if (search === true) { 536 pageproducts = 0; 537 jQuery(".wrapper2 .catwatermark").hide(); 538 $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&term=' + $('#search').val(), function (data) { 539 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) { 540 if (typeof (data[i]) == "undefined") { 541 $("#prodesc" + i).text(""); 542 $("#proprice" + i).attr("class", "hidden"); 543 $("#proprice" + i).html(""); 544 $("#proimg" + i).attr("src", "genimg/empty.png"); 545 $("#prodiv" + i).data("rowid", ""); 546 continue; 547 } 548 <?php 549 $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[i]['ref']"; 550 $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']"; 551 ?> 552 var titlestring = <?php echo $titlestring; ?>; 553 $("#prodesc" + i).text(data[i]['label']); 554 $("#prodivdesc" + i).show(); 555 if (data[i]['price_formated']) { 556 $("#proprice" + i).attr("class", "productprice"); 557 $("#proprice" + i).html(data[i]['price_formated']); 558 } 559 $("#proimg" + i).attr("title", titlestring); 560 $("#proimg" + i).attr("src", "genimg/index.php?query=pro&id=" + data[i]['rowid']); 561 $("#prodiv" + i).data("rowid", data[i]['rowid']); 562 $("#prodiv" + i).data("iscat", 0); 563 } 564 }).always(function (data) { 565 // If there is only 1 answer 566 if ($('#search').val().length > 0 && data.length == 1) { 567 console.log($('#search').val()+' - '+data[0]['barcode']); 568 if ($('#search').val() == data[0]['barcode'] && 'thirdparty' == data[0]['object']) { 569 console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']); 570 ChangeThirdparty(data[0]['rowid']); 571 } 572 else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) { 573 console.log("There is only 1 answer with barcode matching the search, so we add the product in basket"); 574 ClickProduct(0); 575 } 576 } 577 if (eventKeyCode == keyCodeForEnter){ 578 if (data.length == 0) { 579 $('#search').val('<?php 580 $langs->load('errors'); 581 echo dol_escape_js($langs->trans("ErrorRecordNotFound")); 582 ?>'); 583 $('#search').select(); 584 } 585 else ClearSearch(); 586 } 587 }); 588 } 589 590} 591 592function Edit(number) { 593 594 if (typeof(selectedtext) == "undefined") return; // We click on an action on the number pad but there is no line selected 595 596 var text=selectedtext+"<br> "; 597 598 if (number=='c'){ 599 editnumber=""; 600 Refresh(); 601 return; 602 } 603 else if (number=='qty'){ 604 console.log("Edit "+number); 605 if (editaction=='qty' && editnumber!=""){ 606 $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { 607 editnumber=""; 608 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); 609 $("#qty").html("<?php echo $langs->trans("Qty"); ?>"); 610 }); 611 612 setFocusOnSearchField(); 613 return; 614 } 615 else { 616 editaction="qty"; 617 } 618 } 619 else if (number=='p'){ 620 console.log("Edit "+number); 621 if (editaction=='p' && editnumber!=""){ 622 $("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { 623 editnumber=""; 624 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); 625 $("#price").html("<?php echo $langs->trans("Price"); ?>"); 626 }); 627 628 ClearSearch(); 629 return; 630 } 631 else { 632 editaction="p"; 633 } 634 } 635 else if (number=='r'){ 636 console.log("Edit "+number); 637 if (editaction=='r' && editnumber!=""){ 638 $("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { 639 editnumber=""; 640 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); 641 $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>"); 642 }); 643 644 ClearSearch(); 645 return; 646 } 647 else { 648 editaction="r"; 649 } 650 } 651 else { 652 editnumber=editnumber+number; 653 } 654 if (editaction=='qty'){ 655 text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Qty").": "; ?>"; 656 $("#qty").html("OK"); 657 $("#price").html("<?php echo $langs->trans("Price"); ?>"); 658 $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>"); 659 } 660 if (editaction=='p'){ 661 text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Price").": "; ?>"; 662 $("#qty").html("<?php echo $langs->trans("Qty"); ?>"); 663 $("#price").html("OK"); 664 $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>"); 665 } 666 if (editaction=='r'){ 667 text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("ReductionShort").": "; ?>"; 668 $("#qty").html("<?php echo $langs->trans("Qty"); ?>"); 669 $("#price").html("<?php echo $langs->trans("Price"); ?>"); 670 $("#reduction").html("OK"); 671 } 672 $('#'+selectedline).find("td:first").html(text+editnumber); 673} 674 675function TakeposPrintingOrder(){ 676 console.log("TakeposPrintingOrder"); 677 $("#poslines").load("invoice.php?action=order&place="+place, function() { 678 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); 679 }); 680} 681 682function TakeposPrintingTemp(){ 683 console.log("TakeposPrintingTemp"); 684 $("#poslines").load("invoice.php?action=temp&place="+place, function() { 685 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); 686 }); 687} 688 689function OpenDrawer(){ 690 console.log("OpenDrawer call ajax url http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print"); 691 $.ajax({ 692 type: "POST", 693 <?php 694 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) echo "url: '".$conf->global->TAKEPOS_PRINT_SERVER."/printer/drawer.php',"; 695 else echo "url: 'http://".$conf->global->TAKEPOS_PRINT_SERVER.":8111/print',"; 696 ?> 697 data: "opendrawer" 698 }); 699} 700 701function DolibarrOpenDrawer() { 702 console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&term=<?php print $_SESSION["takeposterminal"] ?>"); 703 $.ajax({ 704 type: "GET", 705 url: "<?php print dol_buildpath('/takepos/ajax/ajax.php', 1).'?action=opendrawer&term='.$_SESSION["takeposterminal"]; ?>", 706 }); 707} 708 709function MoreActions(totalactions){ 710 if (pageactions==0){ 711 pageactions=1; 712 for (i = 0; i <= totalactions; i++){ 713 if (i<12) $("#action"+i).hide(); 714 else $("#action"+i).show(); 715 } 716 } 717 else if (pageactions==1){ 718 pageactions=0; 719 for (i = 0; i <= totalactions; i++){ 720 if (i<12) $("#action"+i).show(); 721 else $("#action"+i).hide(); 722 } 723 } 724} 725 726function ControlCashOpening() 727{ 728 $.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"); ?>"}); 729} 730 731function CloseCashFence(rowid) 732{ 733 $.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"); ?>"}); 734} 735 736function CashReport(rowid) 737{ 738 $.colorbox({href:"../compta/cashcontrol/report.php?id="+rowid+"&contextpage=takepos", width:"60%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("CashReport"); ?>"}); 739} 740 741// TakePOS Popup 742function ModalBox(ModalID) 743{ 744 var modal = document.getElementById(ModalID); 745 modal.style.display = "block"; 746} 747 748function DirectPayment(){ 749 console.log("DirectPayment"); 750 $("#poslines").load("invoice.php?place="+place+"&action=valid&pay=<?php echo $langs->trans("cash"); ?>", function() { 751 }); 752} 753 754function FullScreen() { 755 document.documentElement.requestFullscreen(); 756} 757 758function WeighingScale(){ 759 console.log("Weighing Scale"); 760 $.ajax({ 761 type: "POST", 762 url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/scale/index.php', 763 }) 764 .done(function( editnumber ) { 765 $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { 766 editnumber=""; 767 }); 768 }); 769} 770 771$( document ).ready(function() { 772 PrintCategories(0); 773 LoadProducts(0); 774 Refresh(); 775 <?php 776 //IF NO TERMINAL SELECTED 777 if ($_SESSION["takeposterminal"] == "") 778 { 779 print "ModalBox('ModalTerminal');"; 780 } 781 if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { 782 $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; 783 $sql .= " entity = ".$conf->entity." AND "; 784 $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; 785 $resql = $db->query($sql); 786 if ($resql) { 787 $obj = $db->fetch_object($resql); 788 // If there is no cash control from today open it 789 if ($obj->rowid == null) print "ControlCashOpening();"; 790 } 791 } 792 ?> 793}); 794</script> 795 796<body class="bodytakepos" style="overflow: hidden;"> 797<?php 798$keyCodeForEnter = $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} > 0 ? $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} : ''; 799?> 800<div class="container"> 801 802<?php 803if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { 804 ?> 805 <div class="header"> 806 <div class="topnav"> 807 <div class="topnav-left"> 808 <div class="inline-block valignmiddle"> 809 <a class="topnav-terminalhour" onclick="ModalBox('ModalTerminal');"> 810 <span class="fa fa-cash-register"></span> 811 <span class="hideonsmartphone"> 812 <?php echo $langs->trans("Terminal"); ?> 813 </span> 814 <?php echo " "; 815 if ($_SESSION["takeposterminal"] == "") echo "1"; 816 else echo $_SESSION["takeposterminal"]; 817 echo '<span class="hideonsmartphone"> - '.dol_print_date(dol_now(), "day").'</span>'; 818 ?> 819 </a> 820 <?php 821 if (!empty($conf->multicurrency->enabled)) { 822 print '<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\');" title=""><span class="fas fa-coins paddingrightonly"></span>'; 823 print '<span class="hideonsmartphone">'.$langs->trans("Currency").'</span>'; 824 print '</a>'; 825 } 826 ?> 827 </div> 828 <!-- section for customer and open sales --> 829 <div class="inline-block valignmiddle" id="customerandsales"> 830 </div> 831 <!-- More info about customer --> 832 <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="moreinfo"></div> 833 <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="infowarehouse"></div> 834 </div> 835 <div class="topnav-right"> 836 <div class="login_block_other"> 837 <input type="text" id="search" name="search" onkeyup="Search2(<?php echo $keyCodeForEnter; ?>);" placeholder="<?php echo $langs->trans("Search"); ?>" autofocus> 838 <a onclick="ClearSearch();"><span class="fa fa-backspace"></span></a> 839 <a onclick="window.location.href='<?php echo DOL_URL_ROOT.'/'; ?>';"><span class="fas fa-home"></span></a> 840 <?php if (empty($conf->dol_use_jmobile)) { ?> 841 <a class="hideonsmartphone" onclick="FullScreen();"><span class="fa fa-expand-arrows-alt"></span></a> 842 <?php } ?> 843 </div> 844 <div class="login_block_user"> 845 <?php 846 print top_menu_user(1, DOL_URL_ROOT.'/user/logout.php'); 847 ?> 848 </div> 849 </div> 850 </div> 851 </div> 852 <?php 853} 854?> 855 856<!-- Modal terminal box --> 857<div id="ModalTerminal" class="modal"> 858 <div class="modal-content"> 859 <div class="modal-header"> 860 <span class="close" href="#" onclick="document.getElementById('ModalTerminal').style.display = 'none';">×</span> 861 <h3><?php print $langs->trans("TerminalSelect"); ?></h3> 862 </div> 863 <div class="modal-body"> 864 <button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print $langs->trans("Terminal"); ?> 1</button> 865 <?php 866 for ($i = 2; $i <= $conf->global->TAKEPOS_NUM_TERMINALS; $i++) 867 { 868 print '<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.'\'">'.$langs->trans("Terminal").' '.$i.'</button>'; 869 } 870 ?> 871 </div> 872</div> 873</div> 874 875<!-- Modal multicurrency box --> 876<?php if (!empty($conf->multicurrency->enabled)) { ?> 877<div id="ModalCurrency" class="modal"> 878 <div class="modal-content"> 879 <div class="modal-header"> 880 <span class="close" href="#" onclick="document.getElementById('ModalCurrency').style.display = 'none';">×</span> 881 <h3><?php print $langs->trans("SetMultiCurrencyCode"); ?></h3> 882 </div> 883 <div class="modal-body"> 884 <?php 885 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; 886 $sql .= " WHERE entity IN ('".getEntity('multicurrency')."')"; 887 $resql = $db->query($sql); 888 if ($resql) 889 { 890 while ($obj = $db->fetch_object($resql)) 891 print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>'; 892 } 893 ?> 894 </div> 895 </div> 896</div> 897<?php } ?> 898 899<!-- Modal terminal Credit Note --> 900<div id="ModalCreditNote" class="modal"> 901 <div class="modal-content"> 902 <div class="modal-header"> 903 <span class="close" href="#" onclick="document.getElementById('ModalCreditNote').style.display = 'none';">×</span> 904 <h3><?php print $langs->trans("invoiceAvoirWithLines"); ?></h3> 905 </div> 906 <div class="modal-body"> 907 <button type="button" class="block" onclick="CreditNote(); document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("Yes"); ?></button> 908 <button type="button" class="block" onclick="document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("No"); ?></button> 909 </div> 910</div> 911</div> 912 913 <div class="row1<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) print 'withhead'; ?>"> 914 915 <div id="poslines" class="div1"> 916 </div> 917 918 <div class="div2"> 919 <button type="button" class="calcbutton" onclick="Edit(7);">7</button> 920 <button type="button" class="calcbutton" onclick="Edit(8);">8</button> 921 <button type="button" class="calcbutton" onclick="Edit(9);">9</button> 922 <button type="button" id="qty" class="calcbutton2" onclick="Edit('qty');"><?php echo $langs->trans("Qty"); ?></button> 923 <button type="button" class="calcbutton" onclick="Edit(4);">4</button> 924 <button type="button" class="calcbutton" onclick="Edit(5);">5</button> 925 <button type="button" class="calcbutton" onclick="Edit(6);">6</button> 926 <button type="button" id="price" class="calcbutton2" onclick="Edit('p');"><?php echo $langs->trans("Price"); ?></button> 927 <button type="button" class="calcbutton" onclick="Edit(1);">1</button> 928 <button type="button" class="calcbutton" onclick="Edit(2);">2</button> 929 <button type="button" class="calcbutton" onclick="Edit(3);">3</button> 930 <button type="button" id="reduction" class="calcbutton2" onclick="Edit('r');"><?php echo $langs->trans("ReductionShort"); ?></button> 931 <button type="button" class="calcbutton" onclick="Edit(0);">0</button> 932 <button type="button" class="calcbutton" onclick="Edit('.');">.</button> 933 <button type="button" class="calcbutton poscolorblue" onclick="Edit('c');">C</button> 934 <button type="button" class="calcbutton2 poscolordelete" id="delete" onclick="deleteline();"><span class="fa fa-trash"></span></button> 935 </div> 936 937<?php 938 939// TakePOS setup check 940$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; 941$sql .= " WHERE entity IN (".getEntity('c_paiement').")"; 942$sql .= " AND active = 1"; 943$sql .= " ORDER BY libelle"; 944 945$resql = $db->query($sql); 946$paiementsModes = array(); 947if ($resql) { 948 while ($obj = $db->fetch_object($resql)) { 949 $paycode = $obj->code; 950 if ($paycode == 'LIQ') $paycode = 'CASH'; 951 if ($paycode == 'CHQ') $paycode = 'CHEQUE'; 952 953 $constantforkey = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; 954 //var_dump($constantforkey.' '.$conf->global->$constantforkey); 955 if (!empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) array_push($paiementsModes, $obj); 956 } 957} 958 959if (empty($paiementsModes)) { 960 $langs->load('errors'); 961 setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors'); 962 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"]), null, 'errors'); 963} 964if (count($maincategories) == 0) { 965 if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { 966 $tmpcategory = new Categorie($db); 967 $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID); 968 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory", $tmpcategory->label), null, 'errors'); 969 } else { 970 setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors'); 971 } 972} 973// User menu and external TakePOS modules 974$menus = array(); 975$r = 0; 976 977if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) 978{ 979 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("New").'</div>', 'action'=>'New();'); 980} else { 981 // BAR RESTAURANT specific menu 982 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("Place").'</div>', 'action'=>'Floors();'); 983} 984 985if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { 986 $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Customer").'</div>', 'action'=>'Customer();'); 987} 988$menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly"></span><div class="trunc">'.$langs->trans("History").'</div>', 'action'=>'History();'); 989$menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly"></span><div class="trunc">'.$langs->trans("FreeZone").'</div>', 'action'=>'FreeZone();'); 990$menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly"></span><div class="trunc">'.$langs->trans("Reduction").'</div>', 'action'=>'Reduction();'); 991$menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("Payment").'</div>', 'action'=>'CloseBill();'); 992 993if ($conf->global->TAKEPOS_DIRECT_PAYMENT) { 994 $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();'); 995} 996 997// BAR RESTAURANT specific menu 998if ($conf->global->TAKEPOS_BAR_RESTAURANT) 999{ 1000 if ($conf->global->TAKEPOS_ORDER_PRINTERS) 1001 { 1002 $menus[$r++] = array('title'=>$langs->trans("Order"), 'action'=>'TakeposPrintingOrder();'); 1003 } 1004 //Button to print receipt before payment 1005 if ($conf->global->TAKEPOS_BAR_RESTAURANT) 1006 { 1007 if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { 1008 if (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);'); 1009 else $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposPrinting(placeid);'); 1010 } elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { 1011 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);'); 1012 } else { 1013 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'Print(placeid);'); 1014 } 1015 } 1016 if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && $conf->global->TAKEPOS_ORDER_NOTES == 1) 1017 { 1018 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action'=>'TakeposOrderNotes();'); 1019 } 1020 if ($conf->global->TAKEPOS_SUPPLEMENTS) 1021 { 1022 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action'=>'LoadProducts(\'supplements\');'); 1023 } 1024} 1025 1026if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { 1027 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>', 'action'=>'OpenDrawer();'); 1028} 1029if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { 1030 $menus[$r++] = array( 1031 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>', 1032 'action' => 'DolibarrOpenDrawer();', 1033 ); 1034} 1035 1036$sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; 1037$sql .= " entity = ".$conf->entity." AND "; 1038$sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; 1039$resql = $db->query($sql); 1040if ($resql) 1041{ 1042 $num = $db->num_rows($resql); 1043 if ($num) 1044 { 1045 $obj = $db->fetch_object($resql); 1046 $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly"></span><div class="trunc">'.$langs->trans("CashReport").'</div>', 'action'=>'CashReport('.$obj->rowid.');'); 1047 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.');'); 1048 } 1049} 1050 1051$hookmanager->initHooks(array('takeposfrontend')); 1052$reshook = $hookmanager->executeHooks('ActionButtons'); 1053if (!empty($reshook)) { 1054 if (is_array($reshook) && !isset($reshook['title'])) { 1055 foreach ($reshook as $reshook) { 1056 $menus[$r++] = $reshook; 1057 } 1058 } else { 1059 $menus[$r++] = $reshook; 1060 } 1061} 1062 1063if ($r % 3 == 2) $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;'); 1064 1065if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { 1066 $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\';'); 1067} 1068 1069if ($conf->global->TAKEPOS_WEIGHING_SCALE) 1070{ 1071 $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly"></span><div class="trunc">'.$langs->trans("WeighingScale").'</div>', 'action'=>'WeighingScale();'); 1072} 1073 1074?> 1075 <!-- Show buttons --> 1076 <div class="div3"> 1077 <?php 1078 $i = 0; 1079 foreach ($menus as $menu) 1080 { 1081 $i++; 1082 if (count($menus) > 12 and $i == 12) 1083 { 1084 echo '<button style="'.$menu['style'].'" type="button" id="actionnext" class="actionbutton" onclick="MoreActions('.count($menus).');">'.$langs->trans("Next").'</button>'; 1085 echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>'; 1086 } elseif ($i > 12) echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>'; 1087 else echo '<button style="'.$menu['style'].'" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>'; 1088 } 1089 1090 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { 1091 print '<!-- Show the search input text -->'."\n"; 1092 print '<div class="margintoponly">'; 1093 print '<input type="text" id="search" name="search" onkeyup="Search2('.$keyCodeForEnter.');" style="width:80%;width:calc(100% - 51px);font-size: 150%;" placeholder="'.$langs->trans("Search").'" autofocus> '; 1094 print '<a class="marginleftonly hideonsmartphone" onclick="ClearSearch();">'.img_picto('', 'searchclear').'</a>'; 1095 print '</div>'; 1096 } 1097 ?> 1098 </div> 1099 </div> 1100 1101 <div class="row2<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) print 'withhead'; ?>"> 1102 1103 <!-- Show categories --> 1104 <div class="div4"> 1105 <?php 1106 $count = 0; 1107 while ($count < $MAXCATEG) 1108 { 1109 ?> 1110 <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; ?>"> 1111 <?php 1112 if ($count == ($MAXCATEG - 2)) { 1113 //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="catimg'.$count.'" />'; 1114 echo '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em;"></span>'; 1115 } elseif ($count == ($MAXCATEG - 1)) { 1116 //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="catimg'.$count.'" />'; 1117 echo '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em;"></span>'; 1118 } else { 1119 if (!$conf->global->TAKEPOS_HIDE_CATEGORY_IMAGES) echo '<img class="imgwrapper" height="100%" id="catimg'.$count.'" />'; 1120 } 1121 ?> 1122 <?php if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?> 1123 <div class="description" id="catdivdesc<?php echo $count; ?>"> 1124 <div class="description_content" id="catdesc<?php echo $count; ?>"></div> 1125 </div> 1126 <?php } ?> 1127 <div class="catwatermark" id='catwatermark<?php echo $count; ?>'>...</div> 1128 </div> 1129 <?php 1130 $count++; 1131 } 1132 ?> 1133 </div> 1134 1135 <!-- Show product --> 1136 <div class="div5"> 1137 <?php 1138 $count = 0; 1139 while ($count < $MAXPRODUCT) 1140 { 1141 ?> 1142 <div class="wrapper2" id='prodiv<?php echo $count; ?>' <?php if ($count == ($MAXPRODUCT - 2)) {?> onclick="MoreProducts('less');" <?php } if ($count == ($MAXPRODUCT - 1)) {?> onclick="MoreProducts('more');" <?php } else echo 'onclick="ClickProduct('.$count.');"'; ?>> 1143 <?php 1144 if ($count == ($MAXPRODUCT - 2)) { 1145 //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />'; 1146 print '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em;"></span>'; 1147 } elseif ($count == ($MAXPRODUCT - 1)) { 1148 //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="proimg'.$count.'" />'; 1149 print '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em;"></span>'; 1150 } else { 1151 if ($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) echo '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>'; 1152 else { 1153 print '<div class="" id="proprice'.$count.'"></div>'; 1154 print '<img class="imgwrapper" height="100%" title="" id="proimg'.$count.'">'; 1155 } 1156 } 1157 ?> 1158 <?php if ($count != ($MAXPRODUCT - 2) && $count != ($MAXPRODUCT - 1) && !$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) { ?> 1159 <div class="description" id="prodivdesc<?php echo $count; ?>"> 1160 <div class="description_content" id="prodesc<?php echo $count; ?>"></div> 1161 </div> 1162 <?php } ?> 1163 <div class="catwatermark" id='prowatermark<?php echo $count; ?>'>...</div> 1164 </div> 1165 <?php 1166 $count++; 1167 } 1168 ?> 1169 </div> 1170 </div> 1171</div> 1172</body> 1173<?php 1174 1175llxFooter(); 1176 1177$db->close(); 1178