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