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