dolibarr 20.0.0
index.php
Go to the documentation of this file.
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
28// if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
29// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
30// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
31
32if (!defined('NOREQUIREMENU')) {
33 define('NOREQUIREMENU', '1');
34}
35if (!defined('NOREQUIREHTML')) {
36 define('NOREQUIREHTML', '1');
37}
38if (!defined('NOREQUIREAJAX')) {
39 define('NOREQUIREAJAX', '1');
40}
41
42// Load Dolibarr environment
43require '../main.inc.php'; // Load $user and permissions
44require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
49require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
50require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
51
52
53$place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Bar or Restaurant or multiple sales
54$action = GETPOST('action', 'aZ09');
55$setterminal = GETPOSTINT('setterminal');
56$setcurrency = GETPOST('setcurrency', 'aZ09');
57
58$hookmanager->initHooks(array('takeposfrontend'));
59if (empty($_SESSION["takeposterminal"])) {
60 if (getDolGlobalInt('TAKEPOS_NUM_TERMINALS') == 1) {
61 $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal
62 } elseif (!empty($_COOKIE["takeposterminal"])) {
63 $_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session
64 }
65}
66
67if ($setterminal > 0) {
68 $_SESSION["takeposterminal"] = $setterminal;
69 setcookie("takeposterminal", (string) $setterminal, (time() + (86400 * 354)), '/', '', (empty($dolibarr_main_force_https) ? false : true), true); // Permanent takeposterminal var in a cookie
70}
71
72if ($setcurrency != "") {
73 $_SESSION["takeposcustomercurrency"] = $setcurrency;
74 // We will recalculate amount for foreign currency at next call of invoice.php when $_SESSION["takeposcustomercurrency"] differs from invoice->multicurrency_code.
75}
76
77
78$langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter", "banks"));
79
80$categorie = new Categorie($db);
81
82$maxcategbydefaultforthisdevice = 12;
83$maxproductbydefaultforthisdevice = 24;
84if ($conf->browser->layout == 'phone') {
85 $maxcategbydefaultforthisdevice = 8;
86 $maxproductbydefaultforthisdevice = 16;
87 //REDIRECT TO BASIC LAYOUT IF TERMINAL SELECTED AND BASIC MOBILE LAYOUT FORCED
88 if (!empty($_SESSION["takeposterminal"]) && getDolGlobalString('TAKEPOS_BAR_RESTAURANT') && getDolGlobalInt('TAKEPOS_PHONE_BASIC_LAYOUT') == 1) {
89 $_SESSION["basiclayout"] = 1;
90 header("Location: phone.php?mobilepage=invoice");
91 exit;
92 }
93} else {
94 unset($_SESSION["basiclayout"]);
95}
96$MAXCATEG = (!getDolGlobalString('TAKEPOS_NB_MAXCATEG') ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
97$MAXPRODUCT = (!getDolGlobalString('TAKEPOS_NB_MAXPRODUCT') ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
98
99$term = empty($_SESSION['takeposterminal']) ? 1 : $_SESSION['takeposterminal'];
100
101/*
102 $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
103 $soc = new Societe($db);
104 if ($invoice->socid > 0) $soc->fetch($invoice->socid);
105 else $soc->fetch(getDolGlobalInt($constforcompanyid));
106 */
107
108// Security check
109$result = restrictedArea($user, 'takepos', 0, '');
110
111
112
113/*
114 * View
115 */
116
117$form = new Form($db);
118
119$disablejs = 0;
120$disablehead = 0;
121$arrayofjs = array('/takepos/js/jquery.colorbox-min.js'); // TODO It seems we don't need this
122$arrayofcss = array('/takepos/css/pos.css.php', '/takepos/css/colorbox.css');
123
124if (getDolGlobalInt('TAKEPOS_COLOR_THEME') == 1) {
125 $arrayofcss[] = '/takepos/css/colorful.css';
126}
127
128
129// Title
130$title = 'TakePOS - Dolibarr '.DOL_VERSION;
131if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
132 $title = 'TakePOS - ' . getDolGlobalString('MAIN_APPLICATION_TITLE');
133}
134$head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
135<meta name="apple-mobile-web-app-capable" content="yes">
136<meta name="mobile-web-app-capable" content="yes">
137<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
138top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
139
140
141$categories = $categorie->get_full_arbo('product', ((getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) ? getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
142
143
144// Search root category to know its level
145//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
146$levelofrootcategory = 0;
147if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
148 foreach ($categories as $key => $categorycursor) {
149 if ($categorycursor['id'] == getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID')) {
150 $levelofrootcategory = $categorycursor['level'];
151 break;
152 }
153 }
154}
155
156$levelofmaincategories = $levelofrootcategory + 1;
157
158$maincategories = array();
159$subcategories = array();
160foreach ($categories as $key => $categorycursor) {
161 if ($categorycursor['level'] == $levelofmaincategories) {
162 $maincategories[$key] = $categorycursor;
163 } else {
164 $subcategories[$key] = $categorycursor;
165 }
166}
167
168$maincategories = dol_sort_array($maincategories, 'label');
169$subcategories = dol_sort_array($subcategories, 'label');
170?>
171
172<body class="bodytakepos" style="overflow: hidden;">
173
174<script>
175var categories = <?php echo json_encode($maincategories); ?>;
176var subcategories = <?php echo json_encode($subcategories); ?>;
177
178var currentcat;
179var pageproducts=0;
180var pagecategories=0;
181var pageactions=0;
182var place="<?php echo $place; ?>";
183var editaction="qty";
184var editnumber="";
185var invoiceid=0;
186var search2_timer=null;
187
188/*
189var app = this;
190app.hasKeyboard = false;
191this.keyboardPress = function() {
192 app.hasKeyboard = true;
193 $(window).unbind("keyup", app.keyboardPress);
194 localStorage.hasKeyboard = true;
195 console.log("has keyboard!")
196}
197$(window).on("keyup", app.keyboardPress)
198if(localStorage.hasKeyboard) {
199 app.hasKeyboard = true;
200 $(window).unbind("keyup", app.keyboardPress);
201 console.log("has keyboard from localStorage")
202}
203*/
204
205function ClearSearch(clearSearchResults) {
206 console.log("ClearSearch");
207 $("#search").val('');
208 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
209 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
210 $("#reduction").html("<?php echo $langs->trans("LineDiscountShort"); ?>").removeClass('clicked');
211 <?php if ($conf->browser->layout == 'classic') { ?>
212 setFocusOnSearchField();
213 <?php } ?>
214 if (clearSearchResults) {
215 $("#search").trigger('keyup');
216 }
217}
218
219// 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
220function setFocusOnSearchField() {
221 console.log("Call setFocusOnSearchField in page index.php");
222 <?php if ($conf->browser->layout == 'classic') { ?>
223 console.log("has keyboard from localStorage, so we can force focus on search field");
224 $("#search").focus();
225 <?php } ?>
226}
227
228function PrintCategories(first) {
229 console.log("PrintCategories");
230 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
231 if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined")
232 {
233 $("#catdivdesc"+i).hide();
234 $("#catdesc"+i).text("");
235 $("#catimg"+i).attr("src","genimg/empty.png");
236 $("#catwatermark"+i).hide();
237 $("#catdiv"+i).attr('class', 'wrapper divempty');
238 continue;
239 }
240 $("#catdivdesc"+i).show();
241 <?php
242 if (getDolGlobalString('TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
243 $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label'].bold() + ' - ' + categories[parseInt(i)+parseInt(first)]['description']);
244 <?php } else { ?>
245 $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']);
246 <?php } ?>
247 $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']);
248 $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']);
249 $("#catdiv"+i).attr("data-rowid",categories[parseInt(i)+parseInt(first)]['rowid']);
250 $("#catdiv"+i).attr('class', 'wrapper');
251 $("#catwatermark"+i).show();
252 }
253}
254
255function MoreCategories(moreorless) {
256 console.log("MoreCategories moreorless="+moreorless+" pagecategories="+pagecategories);
257 if (moreorless == "more") {
258 $('#catimg15').animate({opacity: '0.5'}, 1);
259 $('#catimg15').animate({opacity: '1'}, 100);
260 pagecategories=pagecategories+1;
261 }
262 if (moreorless == "less") {
263 $('#catimg14').animate({opacity: '0.5'}, 1);
264 $('#catimg14').animate({opacity: '1'}, 100);
265 if (pagecategories==0) return; //Return if no less pages
266 pagecategories=pagecategories-1;
267 }
268 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless == "more") == "undefined") { // Return if no more pages
269 pagecategories=pagecategories-1;
270 return;
271 }
272
273 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
274 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) == "undefined") {
275 // complete with empty record
276 console.log("complete with empty record");
277 $("#catdivdesc"+i).hide();
278 $("#catdesc"+i).text("");
279 $("#catimg"+i).attr("src","genimg/empty.png");
280 $("#catwatermark"+i).hide();
281 continue;
282 }
283 $("#catdivdesc"+i).show();
284 <?php
285 if (getDolGlobalString('TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
286 $("#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]['label'].bold() + ' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]['description']);
287 <?php } else { ?>
288 $("#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]['label']);
289 <?php } ?>
290 $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
291 $("#catdiv"+i).data("rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
292 $("#catdiv"+i).attr("data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
293 $("#catwatermark"+i).show();
294 }
295
296 ClearSearch(false);
297}
298
299// LoadProducts
300function LoadProducts(position, issubcat) {
301 console.log("LoadProducts position="+position+" issubcat="+issubcat);
302 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
303
304 if (position=="supplements") {
305 currentcat="supplements";
306 } else {
307 $('#catimg'+position).animate({opacity: '0.5'}, 1);
308 $('#catimg'+position).animate({opacity: '1'}, 100);
309 if (issubcat == true) {
310 currentcat=$('#prodiv'+position).data('rowid');
311 } else {
312 console.log('#catdiv'+position);
313 currentcat=$('#catdiv'+position).data('rowid');
314 console.log("currentcat="+currentcat);
315 }
316 }
317 if (currentcat == undefined) {
318 return;
319 }
320 pageproducts=0;
321 ishow=0; //product to show counter
322
323 jQuery.each(subcategories, function(i, val) {
324 if (currentcat==val.fk_parent) {
325 $("#prodivdesc"+ishow).show();
326 <?php if (getDolGlobalString('TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
327 $("#prodesc"+ishow).html(val.label.bold() + ' - ' + val.description);
328 $("#probutton"+ishow).html(val.label);
329 <?php } else { ?>
330 $("#prodesc"+ishow).text(val.label);
331 $("#probutton"+ishow).text(val.label);
332 <?php } ?>
333 $("#probutton"+ishow).show();
334 $("#proprice"+ishow).attr("class", "hidden");
335 $("#proprice"+ishow).html("");
336 $("#proimg"+ishow).attr("src","genimg/index.php?query=cat&id="+val.rowid);
337 $("#prodiv"+ishow).data("rowid",val.rowid);
338 $("#prodiv"+ishow).attr("data-rowid",val.rowid);
339 $("#prodiv"+ishow).data("iscat",1);
340 $("#prodiv"+ishow).attr("data-iscat",1);
341 $("#prowatermark"+ishow).show();
342 ishow++;
343 }
344 });
345
346 idata=0; //product data counter
347 var limit = 0;
348 if (maxproduct >= 1) {
349 limit = maxproduct-1;
350 }
351 // Only show products for sale (tosell=1)
352 $.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) {
353 console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs");
354 console.log(data);
355
356 while (ishow < maxproduct) {
357 console.log("ishow"+ishow+" idata="+idata);
358 //console.log(data[idata]);
359
360 if (typeof (data[idata]) == "undefined") {
361 <?php if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
362 echo '$("#prodivdesc"+ishow).hide();';
363 echo '$("#prodesc"+ishow).text("");';
364 echo '$("#proimg"+ishow).attr("title","");';
365 echo '$("#proimg"+ishow).attr("src","genimg/empty.png");';
366 } else {
367 echo '$("#probutton"+ishow).hide();';
368 echo '$("#probutton"+ishow).text("");';
369 }?>
370 $("#proprice"+ishow).attr("class", "hidden");
371 $("#proprice"+ishow).html("");
372
373 $("#prodiv"+ishow).data("rowid","");
374 $("#prodiv"+ishow).attr("data-rowid","");
375
376 $("#prodiv"+ishow).attr("class","wrapper2 divempty");
377 } else {
378 <?php
379 $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[idata]['ref']";
380 $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']";
381 ?>
382 var titlestring = <?php echo $titlestring; ?>;
383 <?php if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
384 echo '$("#prodivdesc"+ishow).show();';
385 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
386 echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
387 } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
388 echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
389 } else {
390 echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
391 }
392 echo '$("#proimg"+ishow).attr("title", titlestring);';
393 echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
394 } else {
395 echo '$("#probutton"+ishow).show();';
396 echo '$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
397 }
398 ?>
399 if (data[parseInt(idata)]['price_formated']) {
400 $("#proprice" + ishow).attr("class", "productprice");
401 <?php
402 if (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT')) {
403 ?>
404 $("#proprice" + ishow).html(data[parseInt(idata)]['price_formated']);
405 <?php
406 } else {
407 ?>
408 $("#proprice" + ishow).html(data[parseInt(idata)]['price_ttc_formated']);
409 <?php
410 }
411 ?>
412 }
413 console.log("#prodiv"+ishow+".data(rowid)="+data[idata]['id']);
414
415 $("#prodiv"+ishow).data("rowid", data[idata]['id']);
416 $("#prodiv"+ishow).attr("data-rowid", data[idata]['id']);
417 console.log($('#prodiv4').data('rowid'));
418
419 $("#prodiv"+ishow).data("iscat", 0);
420 $("#prodiv"+ishow).attr("data-iscat", 0);
421
422 $("#prodiv"+ishow).attr("class","wrapper2");
423
424 <?php
425 // Add js from hooks
426 $parameters = array();
427 $parameters['caller'] = 'loadProducts';
428 $hookmanager->executeHooks('completeJSProductDisplay', $parameters);
429 print $hookmanager->resPrint;
430 ?>
431 }
432 $("#prowatermark"+ishow).hide();
433 ishow++; //Next product to show after print data product
434 idata++; //Next data every time
435 }
436 });
437
438 ClearSearch(false);
439}
440
441function MoreProducts(moreorless) {
442 console.log("MoreProducts");
443
444 if ($('#search_pagination').val() != '') {
445 return Search2('<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
446 }
447
448 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
449
450 if (moreorless=="more"){
451 $('#proimg31').animate({opacity: '0.5'}, 1);
452 $('#proimg31').animate({opacity: '1'}, 100);
453 pageproducts=pageproducts+1;
454 }
455 if (moreorless=="less"){
456 $('#proimg30').animate({opacity: '0.5'}, 1);
457 $('#proimg30').animate({opacity: '1'}, 100);
458 if (pageproducts==0) return; //Return if no less pages
459 pageproducts=pageproducts-1;
460 }
461
462 ishow=0; //product to show counter
463 idata=0; //product data counter
464 var limit = 0;
465 if (maxproduct >= 1) {
466 limit = maxproduct-1;
467 }
468 var offset = <?php echo($MAXPRODUCT - 2); ?> * pageproducts;
469 // Only show products for sale (tosell=1)
470 $.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) {
471 console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
472
473 if (typeof (data[0]) == "undefined" && moreorless=="more"){ // Return if no more pages
474 pageproducts=pageproducts-1;
475 return;
476 }
477
478 while (ishow < maxproduct) {
479 if (typeof (data[idata]) == "undefined") {
480 $("#prodivdesc"+ishow).hide();
481 $("#prodesc"+ishow).text("");
482 $("#probutton"+ishow).text("");
483 $("#probutton"+ishow).hide();
484 $("#proprice"+ishow).attr("class", "");
485 $("#proprice"+ishow).html("");
486 $("#proimg"+ishow).attr("src","genimg/empty.png");
487 $("#prodiv"+ishow).data("rowid","");
488 $("#prodiv"+ishow).attr("data-rowid","");
489 } else {
490 $("#prodivdesc"+ishow).show();
491 <?php if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?>
492 $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']);
493 <?php } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
494 $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold());
495 <?php } else { ?>
496 $("#prodesc"+ishow).html(data[parseInt(idata)]['label']);
497 <?php } ?>
498 $("#probutton"+ishow).html(data[parseInt(idata)]['label']);
499 $("#probutton"+ishow).show();
500 if (data[parseInt(idata)]['price_formated']) {
501 $("#proprice" + ishow).attr("class", "productprice");
502 <?php
503 if (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT')) {
504 ?>
505 $("#proprice" + ishow).html(data[parseInt(idata)]['price_formated']);
506 <?php
507 } else {
508 ?>
509 $("#proprice" + ishow).html(data[parseInt(idata)]['price_ttc_formated']);
510 <?php
511 }
512 ?>
513 }
514 $("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']);
515 $("#prodiv"+ishow).data("rowid",data[idata]['id']);
516 $("#prodiv"+ishow).attr("data-rowid",data[idata]['id']);
517 $("#prodiv"+ishow).data("iscat",0);
518 }
519 $("#prowatermark"+ishow).hide();
520 ishow++; //Next product to show after print data product
521 idata++; //Next data every time
522 }
523 });
524
525 ClearSearch(false);
526}
527
528function ClickProduct(position, qty = 1) {
529 console.log("ClickProduct at position"+position);
530 $('#proimg'+position).animate({opacity: '0.5'}, 1);
531 $('#proimg'+position).animate({opacity: '1'}, 100);
532 if ($('#prodiv'+position).data('iscat')==1){
533 console.log("Click on a category at position "+position);
534 LoadProducts(position, true);
535 }
536 else{
537 console.log($('#prodiv4').data('rowid'));
538 invoiceid = $("#invoiceid").val();
539 idproduct=$('#prodiv'+position).data('rowid');
540 console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty+" invoiceid="+invoiceid);
541 if (idproduct == "") {
542 return;
543 }
544 // Call page invoice.php to generate the section with product lines
545 $("#poslines").load("invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+"&idproduct="+idproduct+"&qty="+qty+"&invoiceid="+invoiceid, function() {
546 <?php if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
547 echo "CustomerDisplay();";
548 }?>
549 });
550 }
551
552 ClearSearch(false);
553}
554
555function ChangeThirdparty(idcustomer) {
556 console.log("ChangeThirdparty");
557 // Call page list.php to change customer
558 $("#poslines").load("<?php echo DOL_URL_ROOT ?>/societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() {
559 });
560
561 ClearSearch(false);
562}
563
564function deleteline() {
565 invoiceid = $("#invoiceid").val();
566 console.log("Delete line invoiceid="+invoiceid);
567 $("#poslines").load("invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&invoiceid="+invoiceid, function() {
568 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
569 });
570 ClearSearch(false);
571}
572
573function Customer() {
574 console.log("Open box to select the thirdparty place="+place);
575 $.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"); ?>"});
576}
577
578function Contact() {
579 console.log("Open box to select the contact place="+place);
580 $.colorbox({href:"../contact/list.php?type=c&contextpage=poslist&nomassaction=1&place="+place, width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Contact"); ?>"});
581}
582
583function History()
584{
585 console.log("Open box to select the history");
586 $.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("History"); ?>"});
587}
588
589function Reduction() {
590 invoiceid = $("#invoiceid").val();
591 console.log("Open popup to enter reduction on invoiceid="+invoiceid);
592 $.colorbox({href:"reduction.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
593}
594
595function CloseBill() {
596 <?php
597 if (!empty($conf->global->TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER)) {
598 echo "customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
599 echo "if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans("Customer")."') { ";
600 echo "alert('".$langs->trans("NoClientErrorMessage")."'); ";
601 echo "return; } \n";
602 }
603 ?>
604 invoiceid = $("#invoiceid").val();
605 console.log("Open popup to enter payment on invoiceid="+invoiceid);
606 <?php if (getDolGlobalInt("TAKEPOS_NO_GENERIC_THIRDPARTY")) { ?>
607 if ($("#idcustomer").val() == "") {
608 alert("<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
609 <?php if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) { ?>
610 Contact();
611 <?php } else { ?>
612 Customer();
613 <?php } ?>
614 return;
615 }
616 <?php } ?>
617 <?php
618 $alternative_payurl = getDolGlobalString('TAKEPOS_ALTERNATIVE_PAYMENT_SCREEN');
619 if (empty($alternative_payurl)) {
620 $payurl = "pay.php";
621 } else {
622 $payurl = dol_buildpath($alternative_payurl, 1);
623 }
624 ?>
625 $.colorbox({href:"<?php echo $payurl; ?>?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
626}
627
628function Split() {
629 invoiceid = $("#invoiceid").val();
630 console.log("Open popup to split on invoiceid="+invoiceid);
631 $.colorbox({href:"split.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
632}
633
634function Floors() {
635 console.log("Open box to select floor place="+place);
636 $.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors"); ?>"});
637}
638
639function FreeZone() {
640 invoiceid = $("#invoiceid").val();
641 console.log("Open box to enter a free product on invoiceid="+invoiceid);
642 $.colorbox({href:"freezone.php?action=freezone&token=<?php echo newToken(); ?>&place="+place+"&invoiceid="+invoiceid, width:"80%", height:"40%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("FreeZone"); ?>"});
643}
644
645function TakeposOrderNotes() {
646 console.log("Open box to order notes");
647 ModalBox('ModalNote');
648 $("#textinput").focus();
649}
650
651function Refresh() {
652 console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid);
653 $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() {
654 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
655 });
656}
657
658function New() {
659 // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
660 invoiceid = $("#invoiceid").val(); // This is a hidden field added by invoice.php
661
662 console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid);
663
664 $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid, function(data) {
665 var r;
666
667 if (parseInt(data['paye']) === 1) {
668 r = true;
669 } else {
670 r = confirm('<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
671 }
672
673 if (r == true) {
674 // Reload section with invoice lines
675 $("#poslines").load("invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place, function () {
676 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
677 });
678
679 ClearSearch(false);
680 $("#idcustomer").val("");
681 }
682 });
683}
684
692function Search2(keyCodeForEnter, moreorless) {
693 var eventKeyCode = window.event.keyCode;
694
695 console.log("Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+", eventKeyCode="+eventKeyCode);
696
697 var search_term = $('#search').val();
698 var search_start = 0;
699 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
700 if (moreorless != null) {
701 search_term = $('#search_pagination').val();
702 search_start = $('#search_start_'+moreorless).val();
703 }
704
705 console.log("search_term="+search_term);
706
707 if (search_term == '') {
708 $("[id^=prowatermark]").html("");
709 $("[id^=prodesc]").text("");
710 $("[id^=probutton]").text("");
711 $("[id^=probutton]").hide();
712 $("[id^=proprice]").attr("class", "hidden");
713 $("[id^=proprice]").html("");
714 $("[id^=proimg]").attr("src", "genimg/empty.png");
715 $("[id^=prodiv]").data("rowid", "");
716 $("[id^=prodiv]").attr("data-rowid", "");
717 return;
718 }
719
720 var search = false;
721 if (keyCodeForEnter == '' || eventKeyCode == keyCodeForEnter) {
722 search = true;
723 }
724
725 if (search === true) {
726 // if a timer has been already started (search2_timer is a global js variable), we cancel it now
727 // we click onto another key, we will restart another timer just after
728 if (search2_timer) {
729 clearTimeout(search2_timer);
730 }
731
732 // temporization time to give time to type
733 search2_timer = setTimeout(function(){
734 pageproducts = 0;
735 jQuery(".wrapper2 .catwatermark").hide();
736 var nbsearchresults = 0;
737 $.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) {
738 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
739 if (typeof (data[i]) == "undefined") {
740 $("#prowatermark" + i).html("");
741 $("#prodesc" + i).text("");
742 $("#probutton" + i).text("");
743 $("#probutton" + i).hide();
744 $("#proprice" + i).attr("class", "hidden");
745 $("#proprice" + i).html("");
746 $("#proimg" + i).attr("src", "genimg/empty.png");
747 $("#prodiv" + i).data("rowid", "");
748 $("#prodiv" + i).attr("data-rowid", "");
749 continue;
750 }
751 <?php
752 $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[i]['ref']";
753 $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']";
754 ?>
755 var titlestring = <?php echo $titlestring; ?>;
756 <?php if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?>
757 $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']);
758 <?php } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
759 $("#prodesc" + i).html(data[i]['ref'].bold());
760 <?php } else { ?>
761 $("#prodesc" + i).html(data[i]['label']);
762 <?php } ?>
763 $("#prodivdesc" + i).show();
764 $("#probutton" + i).html(data[i]['label']);
765 $("#probutton" + i).show();
766 if (data[i]['price_formated']) {
767 $("#proprice" + i).attr("class", "productprice");
768 <?php
769 if (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT')) {
770 ?>
771 $("#proprice" + i).html(data[i]['price_formated']);
772 <?php
773 } else {
774 ?>
775 $("#proprice" + i).html(data[i]['price_ttc_formated']);
776 <?php
777 }
778 ?>
779 }
780 $("#proimg" + i).attr("title", titlestring);
781 if( undefined !== data[i]['img']) {
782 $("#proimg" + i).attr("src", data[i]['img']);
783 }
784 else {
785 $("#proimg" + i).attr("src", "genimg/index.php?query=pro&id=" + data[i]['rowid']);
786 }
787 $("#prodiv" + i).data("rowid", data[i]['rowid']);
788 $("#prodiv" + i).attr("data-rowid", data[i]['rowid']);
789 $("#prodiv" + i).data("iscat", 0);
790 $("#prodiv" + i).attr("data-iscat", 0);
791
792 <?php
793 // Add js from hooks
794 $parameters = array();
795 $parameters['caller'] = 'search2';
796 $hookmanager->executeHooks('completeJSProductDisplay', $parameters);
797 print $hookmanager->resPrint;
798 ?>
799
800 nbsearchresults++;
801 }
802 }).always(function (data) {
803 // If there is only 1 answer
804 if ($('#search').val().length > 0 && data.length == 1) {
805 console.log($('#search').val()+' - '+data[0]['barcode']);
806 if ($('#search').val() == data[0]['barcode'] && 'thirdparty' == data[0]['object']) {
807 console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']);
808 ChangeThirdparty(data[0]['rowid']);
809 }
810 else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) {
811 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']);
812 ClickProduct(0, data[0]['qty']);
813 }
814 }
815 if (eventKeyCode == keyCodeForEnter){
816 if (data.length == 0) {
817 $('#search').val('<?php
818 $langs->load('errors');
819 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
820 ?> ('+search_term+')');
821 $('#search').select();
822 }
823 else ClearSearch(false);
824 }
825 // memorize search_term and start for pagination
826 $("#search_pagination").val($("#search").val());
827 if (search_start == 0) {
828 $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
829 }
830 else {
831 $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
832 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
833 $("#search_start_less").val(search_start_less);
834 }
835 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
836 $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
837 }
838 else {
839 $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
840 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
841 $("#search_start_more").val(search_start_more);
842 }
843 });
844 }, 500); // 500ms delay
845 }
846
847}
848
849/* Function called on an action into the PAD */
850function Edit(number) {
851 console.log("We click on PAD on key="+number);
852
853 if (typeof(selectedtext) == "undefined") {
854 return; // We click on an action on the number pad but there is no line selected
855 }
856
857 var text=selectedtext+"<br> ";
858
859
860 if (number=='c') {
861 editnumber='';
862 Refresh();
863 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
864 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
865 $("#reduction").html("<?php echo $langs->trans("LineDiscountShort"); ?>").removeClass('clicked');
866 return;
867 } else if (number=='qty') {
868 if (editaction=='qty' && editnumber != '') {
869 $("#poslines").load("invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
870 editnumber="";
871 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
872 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
873 });
874
875 setFocusOnSearchField();
876 return;
877 }
878 else {
879 editaction="qty";
880 }
881 } else if (number=='p') {
882 if (editaction=='p' && editnumber!="") {
883 $("#poslines").load("invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
884 editnumber="";
885 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
886 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
887 });
888
889 ClearSearch(false);
890 return;
891 }
892 else {
893 editaction="p";
894 }
895 } else if (number=='r') {
896 if (editaction=='r' && editnumber!="") {
897 $("#poslines").load("invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
898 editnumber="";
899 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
900 $("#reduction").html("<?php echo $langs->trans("LineDiscountShort"); ?>").removeClass('clicked');
901 });
902
903 ClearSearch(false);
904 return;
905 }
906 else {
907 editaction="r";
908 }
909 }
910 else {
911 editnumber=editnumber+number;
912 }
913 if (editaction=='qty'){
914 text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Qty").": "; ?>";
915 $("#qty").html("OK").addClass("clicked");
916 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
917 $("#reduction").html("<?php echo $langs->trans("LineDiscountShort"); ?>").removeClass('clicked');
918 }
919 if (editaction=='p'){
920 text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Price").": "; ?>";
921 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
922 $("#price").html("OK").addClass("clicked");
923 $("#reduction").html("<?php echo $langs->trans("LineDiscountShort"); ?>").removeClass('clicked');
924 }
925 if (editaction=='r'){
926 text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("LineDiscountShort").": "; ?>";
927 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
928 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
929 $("#reduction").html("OK").addClass("clicked");
930 }
931 $('#'+selectedline).find("td:first").html(text+editnumber);
932}
933
934
935function TakeposPrintingOrder(){
936 console.log("TakeposPrintingOrder");
937 $("#poslines").load("invoice.php?action=order&token=<?php echo newToken();?>&place="+place, function() {
938 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
939 });
940}
941
942function TakeposPrintingTemp(){
943 console.log("TakeposPrintingTemp");
944 $("#poslines").load("invoice.php?action=temp&token=<?php echo newToken();?>&place="+place, function() {
945 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
946 });
947}
948
949function OpenDrawer(){
950 console.log("OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
951 $.ajax({
952 type: "POST",
953 data: { token: 'notrequired' },
954 <?php
955 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
956 echo "url: '".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost')."/printer/drawer.php',";
957 } else {
958 echo "url: 'http://".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost').":8111/print',";
959 }
960 ?>
961 data: "opendrawer"
962 });
963}
964
965function DolibarrOpenDrawer() {
966 console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode(empty($_SESSION["takeposterminal"]) ? '' : $_SESSION["takeposterminal"]); ?>");
967 $.ajax({
968 type: "GET",
969 data: { token: '<?php echo currentToken(); ?>' },
970 url: "<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal"]) ? '' : $_SESSION["takeposterminal"]); ?>",
971 });
972}
973
974function MoreActions(totalactions){
975 if (pageactions==0){
976 pageactions=1;
977 for (i = 0; i <= totalactions; i++){
978 if (i<12) $("#action"+i).hide();
979 else $("#action"+i).show();
980 }
981 }
982 else if (pageactions==1){
983 pageactions=0;
984 for (i = 0; i <= totalactions; i++){
985 if (i<12) $("#action"+i).show();
986 else $("#action"+i).hide();
987 }
988 }
989
990 return true;
991}
992
993function ControlCashOpening()
994{
995 $.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"); ?>"});
996}
997
998function CloseCashFence(rowid)
999{
1000 $.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"); ?>"});
1001}
1002
1003function CashReport(rowid)
1004{
1005 $.colorbox({href:"../compta/cashcontrol/report.php?id="+rowid+"&contextpage=takepos", width:"60%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("CashReport"); ?>"});
1006}
1007
1008// TakePOS Popup
1009function ModalBox(ModalID)
1010{
1011 var modal = document.getElementById(ModalID);
1012 modal.style.display = "block";
1013}
1014
1015function DirectPayment(){
1016 console.log("DirectPayment");
1017 $("#poslines").load("invoice.php?place="+place+"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ", function() {
1018 });
1019}
1020
1021function FullScreen() {
1022 document.documentElement.requestFullscreen();
1023}
1024
1025function WeighingScale(){
1026 console.log("Weighing Scale");
1027 $.ajax({
1028 type: "POST",
1029 data: { token: 'notrequired' },
1030 url: '<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>/scale/index.php',
1031 })
1032 .done(function( editnumber ) {
1033 $("#poslines").load("invoice.php?token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
1034 editnumber="";
1035 });
1036 });
1037}
1038
1039$( document ).ready(function() {
1040 PrintCategories(0);
1041 LoadProducts(0);
1042 Refresh();
1043 <?php
1044 // IF NO TERMINAL SELECTED
1045 if (empty($_SESSION["takeposterminal"]) || $_SESSION["takeposterminal"] == "") {
1046 print "ModalBox('ModalTerminal');";
1047 }
1048
1049 if (getDolGlobalString('TAKEPOS_CONTROL_CASH_OPENING')) {
1050 $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
1051 $sql .= " entity = ".((int) $conf->entity)." AND ";
1052 $sql .= " posnumber = ".((int) $_SESSION["takeposterminal"])." AND ";
1053 $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
1054 $resql = $db->query($sql);
1055 if ($resql) {
1056 $obj = $db->fetch_object($resql);
1057 // If there is no cash control from today open it
1058 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1059 print "ControlCashOpening();";
1060 }
1061 }
1062 }
1063 ?>
1064
1065 /* For Header Scroll */
1066 var elem1 = $("#topnav-left")[0];
1067 var elem2 = $("#topnav-right")[0];
1068 var checkOverflow = function() {
1069 if (scrollBars().horizontal) $("#topnav").addClass("overflow");
1070 else $("#topnav").removeClass("overflow");
1071 }
1072
1073 var scrollBars = function(){
1074 var container= $('#topnav')[0];
1075 return {
1076 vertical:container.scrollHeight > container.clientHeight,
1077 horizontal:container.scrollWidth > container.clientWidth
1078 }
1079 }
1080
1081 $(window).resize(function(){
1082 checkOverflow();
1083 });
1084
1085 let resizeObserver = new ResizeObserver(() => {
1086 checkOverflow();
1087 });
1088 resizeObserver.observe(elem1);
1089 resizeObserver.observe(elem2);
1090 checkOverflow();
1091
1092 var pressTimer = [];
1093 var direction = 1;
1094 var step = 200;
1095
1096 $(".indicator").mousedown(function(){
1097 direction = $(this).hasClass("left") ? -1 : 1;
1098 scrollTo();
1099 pressTimer.push(setInterval(scrollTo, 100));
1100 });
1101
1102 $(".indicator").mouseup(function(){
1103 pressTimer.forEach(clearInterval);
1104 });
1105
1106 $("body").mouseup(function(){
1107 pressTimer.forEach(clearInterval);
1108 console.log("body mouseup");
1109 });
1110
1111 function scrollTo(){
1112 console.log("here");
1113 var pos = $("#topnav").scrollLeft();
1114 document.getElementById("topnav").scrollTo({ left: $("#topnav").scrollLeft() + direction * step, behavior: 'smooth' })
1115 }
1116
1117 $("#topnav").scroll(function(){
1118 if (($("#topnav").offsetWidth + $("#topnav").scrollLeft >= $("#topnav").scrollWidth)) {
1119 console.log("end");
1120 }
1121 });
1122 /* End Header Scroll */
1123});
1124</script>
1125
1126<?php
1127$keyCodeForEnter = '';
1128if (!empty($_SESSION['takeposterminal'])) {
1129 $keyCodeForEnter = getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) > 0 ? getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) : '';
1130}
1131?>
1132<div class="container">
1133
1134<?php
1135if (!getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1136 ?>
1137 <div class="header">
1138 <div id="topnav" class="topnav">
1139 <div id="topnav-left" class="topnav-left">
1140 <div class="inline-block valignmiddle">
1141 <a class="topnav-terminalhour" onclick="ModalBox('ModalTerminal')">
1142 <span class="fa fa-cash-register"></span>
1143 <span class="hideonsmartphone">
1144 <?php
1145 if (!empty($_SESSION["takeposterminal"])) {
1146 echo getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$_SESSION["takeposterminal"], $langs->trans("TerminalName", $_SESSION["takeposterminal"]));
1147 }
1148 ?>
1149 </span>
1150 <?php
1151 echo '<span class="hideonsmartphone"> - '.dol_print_date(dol_now(), "day").'</span>'; ?>
1152 </a>
1153 <?php
1154 if (isModEnabled('multicurrency')) {
1155 print '<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1156 print '<span class="hideonsmartphone">'.$langs->trans("Currency").'</span>';
1157 print '</a>';
1158 } ?>
1159 </div>
1160 <!-- section for customer -->
1161 <div class="inline-block valignmiddle" id="customerandsales"></div>
1162 <input type="hidden" id="idcustomer" value="">
1163 <!-- section for shopping carts -->
1164 <div class="inline-block valignmiddle" id="shoppingcart"></div>
1165 <!-- More info about customer -->
1166 <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="moreinfo"></div>
1167 <?php
1168 if (isModEnabled('stock')) {
1169 ?>
1170 <!-- More info about warehouse -->
1171 <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="infowarehouse"></div>
1172 <?php
1173 } ?>
1174 </div>
1175 <div id="topnav-right" class="topnav-right">
1176 <?php
1177 $reshook = $hookmanager->executeHooks('takepos_login_block_other');
1178 if ($reshook == 0) { //Search method
1179 ?>
1180 <div class="login_block_other takepos">
1181 <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>
1182 <a onclick="ClearSearch(false);" class="nohover"><span class="fa fa-backspace"></span></a>
1183 <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 -->
1184 <span class="fas fa-home"></span></a>
1185 <?php if (empty($conf->dol_use_jmobile)) { ?>
1186 <a class="hideonsmartphone" onclick="FullScreen();" title="<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave")); ?>"><span class="fa fa-expand-arrows-alt"></span></a>
1187 <?php } ?>
1188 </div>
1189 <?php
1190 }
1191 ?>
1192 <div class="login_block_user">
1193 <?php
1194 print top_menu_user(1, DOL_URL_ROOT.'/user/logout.php?token='.newToken().'&urlfrom='.urlencode('/takepos/?setterminal='.((int) $term)));
1195 ?>
1196 </div>
1197 </div>
1198 <div class="arrows">
1199 <span class="indicator left"><i class="fa fa-arrow-left"></i></span>
1200 <span class="indicator right"><i class="fa fa-arrow-right"></i></span>
1201 </div>
1202 </div>
1203 </div>
1204 <?php
1205}
1206?>
1207
1208<!-- Modal terminal box -->
1209<div id="ModalTerminal" class="modal">
1210 <div class="modal-content">
1211 <div class="modal-header">
1212 <?php
1213 if (!getDolGlobalString('TAKEPOS_FORCE_TERMINAL_SELECT')) {
1214 ?>
1215 <span class="close" href="#" onclick="document.getElementById('ModalTerminal').style.display = 'none';">&times;</span>
1216 <?php
1217 } ?>
1218 <h3><?php print $langs->trans("TerminalSelect"); ?></h3>
1219 </div>
1220 <div class="modal-body">
1221 <button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print getDolGlobalString("TAKEPOS_TERMINAL_NAME_1", $langs->trans("TerminalName", 1)); ?></button>
1222 <?php
1223 $nbloop = getDolGlobalInt('TAKEPOS_NUM_TERMINALS');
1224 for ($i = 2; $i <= $nbloop; $i++) {
1225 print '<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$i, $langs->trans("TerminalName", $i)).'</button>';
1226 }
1227 ?>
1228 </div>
1229</div>
1230</div>
1231
1232<!-- Modal multicurrency box -->
1233<?php if (isModEnabled('multicurrency')) { ?>
1234<div id="ModalCurrency" class="modal">
1235 <div class="modal-content">
1236 <div class="modal-header">
1237 <span class="close" href="#" onclick="document.getElementById('ModalCurrency').style.display = 'none';">&times;</span>
1238 <h3><?php print $langs->trans("SetMultiCurrencyCode"); ?></h3>
1239 </div>
1240 <div class="modal-body">
1241 <?php
1242 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1243 $sql .= " WHERE entity IN ('".getEntity('multicurrency')."')";
1244 $resql = $db->query($sql);
1245 if ($resql) {
1246 while ($obj = $db->fetch_object($resql)) {
1247 print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>';
1248 }
1249 }
1250 ?>
1251 </div>
1252 </div>
1253</div>
1254<?php } ?>
1255
1256<!-- Modal terminal Credit Note -->
1257<div id="ModalCreditNote" class="modal">
1258 <div class="modal-content">
1259 <div class="modal-header">
1260 <span class="close" href="#" onclick="document.getElementById('ModalCreditNote').style.display = 'none';">&times;</span>
1261 <h3><?php print $langs->trans("invoiceAvoirWithLines"); ?></h3>
1262 </div>
1263 <div class="modal-body">
1264 <button type="button" class="block" onclick="CreditNote(); document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("Yes"); ?></button>
1265 <button type="button" class="block" onclick="document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("No"); ?></button>
1266 </div>
1267</div>
1268</div>
1269
1270<!-- Modal Note -->
1271<div id="ModalNote" class="modal">
1272 <div class="modal-content">
1273 <div class="modal-header">
1274 <span class="close" href="#" onclick="document.getElementById('ModalNote').style.display = 'none';">&times;</span>
1275 <h3><?php print $langs->trans("Note"); ?></h3>
1276 </div>
1277 <div class="modal-body">
1278 <input type="text" class="block" id="textinput">
1279 <button type="button" class="block" onclick="SetNote(); document.getElementById('ModalNote').style.display = 'none';">OK</button>
1280 </div>
1281</div>
1282</div>
1283
1284 <div class="row1<?php if (!getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1285 print 'withhead';
1286 } ?>">
1287
1288 <div id="poslines" class="div1">
1289 </div>
1290
1291 <div class="div2">
1292 <button type="button" class="calcbutton" onclick="Edit(7);">7</button>
1293 <button type="button" class="calcbutton" onclick="Edit(8);">8</button>
1294 <button type="button" class="calcbutton" onclick="Edit(9);">9</button>
1295 <button type="button" id="qty" class="calcbutton2" onclick="Edit('qty')"><?php echo $langs->trans("Qty"); ?></button>
1296 <button type="button" class="calcbutton" onclick="Edit(4);">4</button>
1297 <button type="button" class="calcbutton" onclick="Edit(5);">5</button>
1298 <button type="button" class="calcbutton" onclick="Edit(6);">6</button>
1299 <button type="button" id="price" class="calcbutton2" onclick="Edit('p')"><?php echo $langs->trans("Price"); ?></button>
1300 <button type="button" class="calcbutton" onclick="Edit(1);">1</button>
1301 <button type="button" class="calcbutton" onclick="Edit(2);">2</button>
1302 <button type="button" class="calcbutton" onclick="Edit(3);">3</button>
1303 <button type="button" id="reduction" class="calcbutton2" onclick="Edit('r')"><?php echo $langs->trans("LineDiscountShort"); ?></button>
1304 <button type="button" class="calcbutton" onclick="Edit(0);">0</button>
1305 <button type="button" class="calcbutton" onclick="Edit('.')">.</button>
1306 <button type="button" class="calcbutton poscolorblue" onclick="Edit('c')">C</button>
1307 <button type="button" class="calcbutton2 poscolordelete" id="delete" onclick="deleteline()"><span class="fa fa-trash"></span></button>
1308 </div>
1309
1310<?php
1311
1312// TakePOS setup check
1313if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) {
1314 $sql = "SELECT code, libelle FROM " . MAIN_DB_PREFIX . "c_paiement";
1315 $sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")";
1316 $sql .= " AND active = 1";
1317 $sql .= " ORDER BY libelle";
1318
1319 $resql = $db->query($sql);
1320 $paiementsModes = array();
1321 if ($resql) {
1322 while ($obj = $db->fetch_object($resql)) {
1323 $paycode = $obj->code;
1324 if ($paycode == 'LIQ') {
1325 $paycode = 'CASH';
1326 }
1327 if ($paycode == 'CHQ') {
1328 $paycode = 'CHEQUE';
1329 }
1330
1331 $constantforkey = "CASHDESK_ID_BANKACCOUNT_" . $paycode . $_SESSION["takeposterminal"];
1332 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1333 if (getDolGlobalInt($constantforkey) > 0) {
1334 array_push($paiementsModes, $obj);
1335 }
1336 }
1337 }
1338
1339 if (empty($paiementsModes) && isModEnabled("bank")) {
1340 $langs->load('errors');
1341 setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors');
1342 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"]), null, 'errors');
1343 }
1344}
1345
1346if (count($maincategories) == 0) {
1347 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1348 $tmpcategory = new Categorie($db);
1349 $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID'));
1350 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory", $tmpcategory->label), null, 'errors');
1351 } else {
1352 setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors');
1353 }
1354}
1355// User menu and external TakePOS modules
1356$menus = array();
1357$r = 0;
1358
1359if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1360 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("New").'</div>', 'action' => 'New();');
1361} else {
1362 // BAR RESTAURANT specific menu
1363 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("Place").'</div>', 'action' => 'Floors();');
1364}
1365
1366if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1367 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1368 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1369 } else {
1370 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Customer").'</div>', 'action' => 'Customer();');
1371 }
1372}
1373if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1374 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly"></span><div class="trunc">'.$langs->trans("History").'</div>', 'action' => 'History();');
1375}
1376$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly"></span><div class="trunc">'.$langs->trans("FreeZone").'</div>', 'action' => 'FreeZone();');
1377$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly"></span><div class="trunc">'.$langs->trans("InvoiceDiscountShort").'</div>', 'action' => 'Reduction();');
1378
1379if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1380 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly"></span><div class="trunc">'.$langs->trans("SplitSale").'</div>', 'action' => 'Split();');
1381}
1382
1383// BAR RESTAURANT specific menu
1384if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1385 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1386 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly"></span><div class="trunc">'.$langs->trans("Order").'</span>', 'action' => 'TakeposPrintingOrder();');
1387 }
1388}
1389
1390// Last action that close the sell (payments)
1391$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("Payment").'</div>', 'action' => 'CloseBill();');
1392if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1393 $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();');
1394}
1395
1396// BAR RESTAURANT specific menu
1397if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1398 //Button to print receipt before payment
1399 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1400 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
1401 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1402 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action' => 'TakeposConnector(placeid);');
1403 } else {
1404 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action' => 'TakeposPrinting(placeid);');
1405 }
1406 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
1407 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1408 } else {
1409 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action' => 'Print(placeid);');
1410 }
1411 }
1412 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1413 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action' => 'TakeposOrderNotes();');
1414 }
1415 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1416 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1417 }
1418}
1419
1420if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
1421 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>', 'action' => 'OpenDrawer();');
1422}
1423if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
1424 $menus[$r++] = array(
1425 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>',
1426 'action' => 'DolibarrOpenDrawer();',
1427 );
1428}
1429
1430$sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
1431$sql .= " entity = ".((int) $conf->entity)." AND ";
1432$sql .= " posnumber = ".((int) empty($_SESSION["takeposterminal"]) ? 0 : $_SESSION["takeposterminal"])." AND ";
1433$sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
1434
1435$resql = $db->query($sql);
1436if ($resql) {
1437 $num = $db->num_rows($resql);
1438 if ($num) {
1439 $obj = $db->fetch_object($resql);
1440 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly"></span><div class="trunc">'.$langs->trans("CashReport").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1441 if ($obj->status == 0) {
1442 $menus[$r++] = array('title' => '<span class="fas fa-cash-register paddingrightonly"></span><div class="trunc">'.$langs->trans("CloseCashFence").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1443 }
1444 }
1445}
1446
1447$parameters = array('menus' => $menus);
1448$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1449if ($reshook == 0) { //add buttons
1450 if (is_array($hookmanager->resArray)) {
1451 foreach ($hookmanager->resArray as $resArray) {
1452 foreach ($resArray as $butmenu) {
1453 $menus[$r++] = $butmenu;
1454 }
1455 }
1456 } elseif ($reshook == 1) {
1457 $r = 0; //replace buttons
1458 if (is_array($hookmanager->resArray)) {
1459 foreach ($hookmanager->resArray as $resArray) {
1460 foreach ($resArray as $butmenu) {
1461 $menus[$r++] = $butmenu;
1462 }
1463 }
1464 }
1465 }
1466}
1467
1468if ($r % 3 == 2) {
1469 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1470}
1471
1472if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1473 $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().'\';');
1474}
1475
1476if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1477 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale paddingrightonly"></span><div class="trunc">'.$langs->trans("WeighingScale").'</div>', 'action' => 'WeighingScale();');
1478}
1479
1480?>
1481 <!-- Show buttons -->
1482 <div class="div3">
1483 <?php
1484 $i = 0;
1485 foreach ($menus as $menu) {
1486 $i++;
1487 if (count($menus) > 12 and $i == 12) {
1488 echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="actionnext" class="actionbutton" onclick="MoreActions('.count($menus).')">'.$langs->trans("Next").'</button>';
1489 echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
1490 } elseif ($i > 12) {
1491 echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
1492 } else {
1493 echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
1494 }
1495 }
1496
1497 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1498 print '<!-- Show the search input text -->'."\n";
1499 print '<div class="margintoponly">';
1500 print '<input type="text" id="search" class="input-search-takepos 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> ';
1501 print '<a class="marginleftonly hideonsmartphone" onclick="ClearSearch(false);">'.img_picto('', 'searchclear').'</a>';
1502 print '</div>';
1503 }
1504 ?>
1505 </div>
1506 </div>
1507
1508 <div class="row2<?php if (!getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1509 print 'withhead';
1510 } ?>">
1511
1512 <!-- Show categories -->
1513 <?php
1514 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1515 print '<div class="div4" style= "display: none;">';
1516 } else {
1517 print '<div class="div4">';
1518 }
1519
1520 $count = 0;
1521 while ($count < $MAXCATEG) {
1522 ?>
1523 <div class="wrapper" <?php if ($count == ($MAXCATEG - 2)) {
1524 echo 'onclick="MoreCategories(\'less\')"';
1525 } elseif ($count == ($MAXCATEG - 1)) {
1526 echo 'onclick="MoreCategories(\'more\')"';
1527 } else {
1528 echo 'onclick="LoadProducts('.$count.')"';
1529 } ?> id="catdiv<?php echo $count; ?>">
1530 <?php
1531 if ($count == ($MAXCATEG - 2)) {
1532 //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="catimg'.$count.'" />';
1533 echo '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1534 } elseif ($count == ($MAXCATEG - 1)) {
1535 //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="catimg'.$count.'" />';
1536 echo '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1537 } else {
1538 if (!getDolGlobalString('TAKEPOS_HIDE_CATEGORY_IMAGES')) {
1539 echo '<img class="imgwrapper" id="catimg'.$count.'" />';
1540 }
1541 } ?>
1542 <?php if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1543 <div class="description" id="catdivdesc<?php echo $count; ?>">
1544 <div class="description_content" id="catdesc<?php echo $count; ?>"></div>
1545 </div>
1546 <?php } ?>
1547 <div class="catwatermark" id='catwatermark<?php echo $count; ?>'>...</div>
1548 </div>
1549 <?php
1550 $count++;
1551 }
1552 ?>
1553 </div>
1554
1555 <!-- Show product -->
1556 <div class="div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1557 print ' centpercent';
1558 } ?>">
1559 <?php
1560 $count = 0;
1561 while ($count < $MAXPRODUCT) {
1562 print '<div class="wrapper2 arrow" id="prodiv'.$count.'" '; ?>
1563 <?php if ($count == ($MAXPRODUCT - 2)) {
1564 ?> onclick="MoreProducts('less')" <?php
1565 }
1566 if ($count == ($MAXPRODUCT - 1)) {
1567 ?> onclick="MoreProducts('more')" <?php
1568 } else {
1569 echo 'onclick="ClickProduct('.$count.')"';
1570 } ?>>
1571 <?php
1572 if ($count == ($MAXPRODUCT - 2)) {
1573 //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';
1574 print '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1575 } elseif ($count == ($MAXPRODUCT - 1)) {
1576 //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="proimg'.$count.'" />';
1577 print '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1578 } else {
1579 if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_PRICES')) {
1580 print '<div class="" id="proprice'.$count.'"></div>';
1581 }
1582 if (getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
1583 print '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>';
1584 } else {
1585 print '<img class="imgwrapper" title="" id="proimg'.$count.'">';
1586 }
1587 } ?>
1588 <?php if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1589 <div class="description" id="prodivdesc<?php echo $count; ?>">
1590 <div class="description_content" id="prodesc<?php echo $count; ?>"></div>
1591 </div>
1592 <?php } ?>
1593 <div class="catwatermark" id='prowatermark<?php echo $count; ?>'>...</div>
1594 </div>
1595 <?php
1596 $count++;
1597 }
1598 ?>
1599 <input type="hidden" id="search_start_less" value="0">
1600 <input type="hidden" id="search_start_more" value="0">
1601 <input type="hidden" id="search_pagination" value="">
1602 </div>
1603 </div>
1604</div>
1605</body>
1606<?php
1607
1608llxFooter();
1609
1610$db->close();
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:636
llxFooter()
Empty footer.
Definition wrapper.php:69
print $object position
Definition edit.php:195
Class to manage categories.
Class to manage contact/addresses.
Class to manage generation of HTML components Only common components must be here.
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
Definition date.lib.php:654
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
top_menu_user($hideloginname=0, $urllogout='')
Build the tooltip on user login.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:139
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:142
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e rowid
Definition invoice.php:1991