dolibarr 21.0.4
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
3 * Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
4 * Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 * 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 setcookie("takeposterminal", (string) $setterminal, (time() + (86400 * 354)), '/', '', !empty($dolibarr_main_force_https), true); // Permanent takeposterminal var in a 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 $('#proimg'+position).animate({opacity: '0.5'}, 1);
564 $('#proimg'+position).animate({opacity: '1'}, 100);
565 if ($('#prodiv'+position).data('iscat') == 1){
566 console.log("Click on a category at position "+position);
567 LoadProducts(position, true);
568 }
569 else{
570 console.log($('#prodiv4').data('rowid'));
571 invoiceid = $("#invoiceid").val();
572 idproduct=$('#prodiv'+position).data('rowid');
573 console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty+" invoiceid="+invoiceid);
574 if (idproduct == "") {
575 return;
576 }
577 // Call page invoice.php to generate the section with product lines
578 $("#poslines").load("invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+"&idproduct="+idproduct+"&qty="+qty+"&invoiceid="+invoiceid, function() {
579 <?php if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
580 echo "CustomerDisplay();";
581 }?>
582 });
583 }
584
585 ClearSearch(false);
586}
587
588function ChangeThirdparty(idcustomer) {
589 console.log("ChangeThirdparty");
590 // Call page list.php to change customer
591 $("#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() {
592 });
593
594 ClearSearch(false);
595}
596
597function deleteline() {
598 invoiceid = $("#invoiceid").val();
599 console.log("Delete line invoiceid="+invoiceid);
600 $("#poslines").load("invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&invoiceid="+invoiceid, function() {
601 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
602 });
603 ClearSearch(false);
604}
605
606function Customer() {
607 console.log("Open box to select the thirdparty place="+place);
608 $.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"); ?>"});
609}
610
611function Contact() {
612 console.log("Open box to select the contact place="+place);
613 $.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"); ?>"});
614}
615
616function History()
617{
618 console.log("Open box to select the history");
619 $.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("History"); ?>"});
620}
621
622function Reduction() {
623 invoiceid = $("#invoiceid").val();
624 console.log("Open popup to enter reduction on invoiceid="+invoiceid);
625 $.colorbox({href:"reduction.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
626}
627
628function CloseBill() {
629 <?php
630 if (getDolGlobalString('TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER')) {
631 echo "customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
632 echo "if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans("Customer")."') { ";
633 echo "alert('".dol_escape_js($langs->trans("NoClientErrorMessage"))."'); ";
634 echo "return; } \n";
635 }
636 ?>
637 invoiceid = $("#invoiceid").val();
638 console.log("Open popup to enter payment on invoiceid="+invoiceid);
639 <?php if (getDolGlobalInt("TAKEPOS_NO_GENERIC_THIRDPARTY")) { ?>
640 if ($("#idcustomer").val() == "") {
641 alert("<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
642 <?php if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) { ?>
643 Contact();
644 <?php } else { ?>
645 Customer();
646 <?php } ?>
647 return;
648 }
649 <?php } ?>
650 <?php
651 $alternative_payurl = getDolGlobalString('TAKEPOS_ALTERNATIVE_PAYMENT_SCREEN');
652 if (empty($alternative_payurl)) {
653 $payurl = "pay.php";
654 } else {
655 $payurl = dol_buildpath($alternative_payurl, 1);
656 }
657 ?>
658 $.colorbox({href:"<?php echo $payurl; ?>?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
659}
660
661function Split() {
662 invoiceid = $("#invoiceid").val();
663 console.log("Open popup to split on invoiceid="+invoiceid);
664 $.colorbox({href:"split.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
665}
666
667function Floors() {
668 console.log("Open box to select floor place="+place);
669 $.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors"); ?>"});
670}
671
672function FreeZone() {
673 invoiceid = $("#invoiceid").val();
674 console.log("Open box to enter a free product on invoiceid="+invoiceid);
675 $.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"); ?>"});
676}
677
678function TakeposOrderNotes() {
679 console.log("Open box to order notes");
680 ModalBox('ModalNote');
681 $("#textinput").focus();
682}
683
684function Refresh() {
685 console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid);
686 $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() {
687 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
688 });
689}
690
691function New() {
692 // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
693 invoiceid = $("#invoiceid").val(); // This is a hidden field added by invoice.php
694
695 console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid);
696
697 $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid, function(data) {
698 var r;
699
700 if (parseInt(data['paye']) === 1) {
701 r = true;
702 } else {
703 r = confirm('<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
704 }
705
706 if (r == true) {
707 // Reload section with invoice lines
708 $("#poslines").load("invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place, function () {
709 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
710 });
711
712 ClearSearch(false);
713 $("#idcustomer").val("");
714 }
715 });
716}
717
725function Search2(keyCodeForEnter, moreorless) {
726 var eventKeyCode = window.event.keyCode;
727
728 console.log("Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+", eventKeyCode="+eventKeyCode);
729
730 var search_term = $('#search').val();
731 var search_start = 0;
732 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
733 if (moreorless != null) {
734 search_term = $('#search_pagination').val();
735 search_start = $('#search_start_'+moreorless).val();
736 }
737
738 console.log("search_term="+search_term);
739
740 if (search_term == '') {
741 $("[id^=prowatermark]").html("");
742 $("[id^=prodesc]").text("");
743 $("[id^=probutton]").text("");
744 $("[id^=probutton]").hide();
745 $("[id^=proprice]").attr("class", "hidden");
746 $("[id^=proprice]").html("");
747 $("[id^=proimg]").attr("src", "genimg/empty.png");
748 $("[id^=prodiv]").data("rowid", "");
749 $("[id^=prodiv]").attr("data-rowid", "");
750 return;
751 }
752
753 var search = false;
754 if (keyCodeForEnter == '' || eventKeyCode == keyCodeForEnter) {
755 search = true;
756 }
757
758 if (search === true) {
759 // if a timer has been already started (search2_timer is a global js variable), we cancel it now
760 // we click onto another key, we will restart another timer just after
761 if (search2_timer) {
762 clearTimeout(search2_timer);
763 }
764
765 // temporization time to give time to type
766 search2_timer = setTimeout(function(){
767 pageproducts = 0;
768 jQuery(".wrapper2 .catwatermark").hide();
769 var nbsearchresults = 0;
770
771 // Only show products for sale (tosell=1)
772 let socid = jQuery('#thirdpartyid').val();
773 if ((socid === undefined || socid === "") && parseInt("<?php echo dol_escape_js($socid) ?>") > 0) {
774 socid = parseInt("<?php echo dol_escape_js($socid); ?>");
775 }
776
777 $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term + '&thirdpartyid=' + socid + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {
778 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
779 if (typeof (data[i]) == "undefined") {
780 $("#prowatermark" + i).html("");
781 $("#prodesc" + i).text("");
782 $("#probutton" + i).text("");
783 $("#probutton" + i).hide();
784 $("#proprice" + i).attr("class", "hidden");
785 $("#proprice" + i).html("");
786 $("#proimg" + i).attr("src", "genimg/empty.png");
787 $("#prodiv" + i).data("rowid", "");
788 $("#prodiv" + i).attr("data-rowid", "");
789 continue;
790 }
791 <?php
792 $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[i]['ref']";
793 $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']";
794 ?>
795 var titlestring = <?php echo $titlestring; ?>;
796 <?php if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?>
797 $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']);
798 <?php } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
799 $("#prodesc" + i).html(data[i]['ref'].bold());
800 <?php } else { ?>
801 $("#prodesc" + i).html(data[i]['label']);
802 <?php } ?>
803 $("#prodivdesc" + i).show();
804 $("#probutton" + i).html(data[i]['label']);
805 $("#probutton" + i).show();
806 if (data[i]['price_formated']) {
807 $("#proprice" + i).attr("class", "productprice");
808 <?php
809 if (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT')) {
810 ?>
811 $("#proprice" + i).html(data[i]['price_formated']);
812 <?php
813 } else {
814 ?>
815 $("#proprice" + i).html(data[i]['price_ttc_formated']);
816 <?php
817 }
818 ?>
819 }
820 $("#proimg" + i).attr("title", titlestring);
821 if( undefined !== data[i]['img']) {
822 $("#proimg" + i).attr("src", data[i]['img']);
823 }
824 else {
825 $("#proimg" + i).attr("src", "genimg/index.php?query=pro&id=" + data[i]['rowid']);
826 }
827 $("#prodiv" + i).data("rowid", data[i]['rowid']);
828 $("#prodiv" + i).attr("data-rowid", data[i]['rowid']);
829 $("#prodiv" + i).data("iscat", 0);
830 $("#prodiv" + i).attr("data-iscat", 0);
831
832 <?php
833 // Add js from hooks
834 $parameters = array();
835 $parameters['caller'] = 'search2';
836 $hookmanager->executeHooks('completeJSProductDisplay', $parameters);
837 print $hookmanager->resPrint;
838 ?>
839
840 nbsearchresults++;
841 }
842 }).always(function (data) {
843 // If there is only 1 answer
844 if ($('#search').val().length > 0 && data.length == 1) {
845 console.log($('#search').val()+' - '+data[0]['barcode']);
846 if ($('#search').val() == data[0]['barcode'] && 'thirdparty' == data[0]['object']) {
847 console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']);
848 ChangeThirdparty(data[0]['rowid']);
849 }
850 else if ('product' == data[0]['object'] && $('#search').val() == data[0]['barcode']) {
851 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']);
852 ClickProduct(0, data[0]['qty']);
853 }
854 }
855 if (eventKeyCode == keyCodeForEnter){
856 if (data.length == 0) {
857 $('#search').val('<?php
858 $langs->load('errors');
859 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
860 ?> ('+search_term+')');
861 $('#search').select();
862 }
863 else ClearSearch(false);
864 }
865 // memorize search_term and start for pagination
866 $("#search_pagination").val($("#search").val());
867 if (search_start == 0) {
868 $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
869 }
870 else {
871 $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
872 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
873 $("#search_start_less").val(search_start_less);
874 }
875 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
876 $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
877 }
878 else {
879 $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
880 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
881 $("#search_start_more").val(search_start_more);
882 }
883 });
884 }, 500); // 500ms delay
885 }
886
887}
888
889/* Function called on an action into the PAD */
890function Edit(number) {
891 console.log("We click on PAD on key="+number);
892
893 if (typeof(selectedtext) == "undefined") {
894 return; // We click on an action on the number pad but there is no line selected
895 }
896
897 var text=selectedtext+"<br> ";
898
899
900 if (number=='c') {
901 editnumber='';
902 Refresh();
903 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
904 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
905 $("#reduction").html("<?php echo $langs->trans("LineDiscountShort"); ?>").removeClass('clicked');
906 return;
907 } else if (number=='qty') {
908 if (editaction=='qty' && editnumber != '') {
909 $("#poslines").load("invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
910 editnumber="";
911 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
912 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
913 });
914
915 setFocusOnSearchField();
916 return;
917 }
918 else {
919 editaction="qty";
920 }
921 } else if (number=='p') {
922 if (editaction=='p' && editnumber!="") {
923 $("#poslines").load("invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
924 editnumber="";
925 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
926 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
927 });
928
929 ClearSearch(false);
930 return;
931 }
932 else {
933 editaction="p";
934 }
935 } else if (number=='r') {
936 if (editaction=='r' && editnumber!="") {
937 $("#poslines").load("invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
938 editnumber="";
939 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
940 $("#reduction").html("<?php echo $langs->trans("LineDiscountShort"); ?>").removeClass('clicked');
941 });
942
943 ClearSearch(false);
944 return;
945 }
946 else {
947 editaction="r";
948 }
949 }
950 else {
951 editnumber=editnumber+number;
952 }
953 if (editaction=='qty'){
954 text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Qty").": "; ?>";
955 $("#qty").html("OK").addClass("clicked");
956 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
957 $("#reduction").html("<?php echo $langs->trans("LineDiscountShort"); ?>").removeClass('clicked');
958 }
959 if (editaction=='p'){
960 text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Price").": "; ?>";
961 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
962 $("#price").html("OK").addClass("clicked");
963 $("#reduction").html("<?php echo $langs->trans("LineDiscountShort"); ?>").removeClass('clicked');
964 }
965 if (editaction=='r'){
966 text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("LineDiscountShort").": "; ?>";
967 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
968 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
969 $("#reduction").html("OK").addClass("clicked");
970 }
971 $('#'+selectedline).find("td:first").html(text+editnumber);
972}
973
974
975function TakeposPrintingOrder(){
976 console.log("TakeposPrintingOrder");
977 $("#poslines").load("invoice.php?action=order&token=<?php echo newToken();?>&place="+place, function() {
978 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
979 });
980}
981
982function TakeposPrintingTemp(){
983 console.log("TakeposPrintingTemp");
984 $("#poslines").load("invoice.php?action=temp&token=<?php echo newToken();?>&place="+place, function() {
985 //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
986 });
987}
988
989function OpenDrawer(){
990 console.log("OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
991 $.ajax({
992 type: "POST",
993 data: { token: 'notrequired' },
994 <?php
995 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
996 echo "url: '".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost')."/printer/drawer.php',";
997 } else {
998 echo "url: 'http://".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost').":8111/print',";
999 }
1000 ?>
1001 data: "opendrawer"
1002 });
1003}
1004
1005function DolibarrOpenDrawer() {
1006 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"]); ?>");
1007 $.ajax({
1008 type: "GET",
1009 data: { token: '<?php echo currentToken(); ?>' },
1010 url: "<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal"]) ? '' : $_SESSION["takeposterminal"]); ?>",
1011 });
1012}
1013
1014function MoreActions(totalactions){
1015 if (pageactions==0){
1016 pageactions=1;
1017 for (i = 0; i <= totalactions; i++){
1018 if (i<12) $("#action"+i).hide();
1019 else $("#action"+i).show();
1020 }
1021 }
1022 else if (pageactions==1){
1023 pageactions=0;
1024 for (i = 0; i <= totalactions; i++){
1025 if (i<12) $("#action"+i).show();
1026 else $("#action"+i).hide();
1027 }
1028 }
1029
1030 return true;
1031}
1032
1033function ControlCashOpening()
1034{
1035 $.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"); ?>"});
1036}
1037
1038function CloseCashFence(rowid)
1039{
1040 $.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"); ?>"});
1041}
1042
1043function CashReport(rowid)
1044{
1045 $.colorbox({href:"../compta/cashcontrol/report.php?id="+rowid+"&contextpage=takepos", width:"60%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("CashReport"); ?>"});
1046}
1047
1048// TakePOS Popup
1049function ModalBox(ModalID)
1050{
1051 var modal = document.getElementById(ModalID);
1052 modal.style.display = "block";
1053}
1054
1055function DirectPayment(){
1056 console.log("DirectPayment");
1057 $("#poslines").load("invoice.php?place="+place+"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ", function() {
1058 });
1059}
1060
1061function FullScreen() {
1062 document.documentElement.requestFullscreen();
1063}
1064
1065function WeighingScale(){
1066 console.log("Weighing Scale");
1067 $.ajax({
1068 type: "POST",
1069 data: { token: 'notrequired' },
1070 url: '<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>/scale/index.php',
1071 })
1072 .done(function( editnumber ) {
1073 $("#poslines").load("invoice.php?token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
1074 editnumber="";
1075 });
1076 });
1077}
1078
1079$( document ).ready(function() {
1080 PrintCategories(0);
1081 LoadProducts(0);
1082 Refresh();
1083 <?php
1084 // IF NO TERMINAL SELECTED
1085 if (empty($_SESSION["takeposterminal"]) || $_SESSION["takeposterminal"] == "") {
1086 print "ModalBox('ModalTerminal');";
1087 }
1088
1089 if (getDolGlobalString('TAKEPOS_CONTROL_CASH_OPENING')) {
1090 $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
1091 $sql .= " entity = ".((int) $conf->entity)." AND ";
1092 $sql .= " posnumber = ".((int) $_SESSION["takeposterminal"])." AND ";
1093 $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
1094 $resql = $db->query($sql);
1095 if ($resql) {
1096 $obj = $db->fetch_object($resql);
1097 // If there is no cash control from today open it
1098 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1099 print "ControlCashOpening();";
1100 }
1101 }
1102 }
1103 ?>
1104
1105 /* For Header Scroll */
1106 var elem1 = $("#topnav-left")[0];
1107 var elem2 = $("#topnav-right")[0];
1108 var checkOverflow = function() {
1109 if (scrollBars().horizontal) $("#topnav").addClass("overflow");
1110 else $("#topnav").removeClass("overflow");
1111 }
1112
1113 var scrollBars = function(){
1114 var container= $('#topnav')[0];
1115 return {
1116 vertical:container.scrollHeight > container.clientHeight,
1117 horizontal:container.scrollWidth > container.clientWidth
1118 }
1119 }
1120
1121 $(window).resize(function(){
1122 checkOverflow();
1123 });
1124
1125 let resizeObserver = new ResizeObserver(() => {
1126 checkOverflow();
1127 });
1128 resizeObserver.observe(elem1);
1129 resizeObserver.observe(elem2);
1130 checkOverflow();
1131
1132 var pressTimer = [];
1133 var direction = 1;
1134 var step = 200;
1135
1136 $(".indicator").mousedown(function(){
1137 direction = $(this).hasClass("left") ? -1 : 1;
1138 scrollTo();
1139 pressTimer.push(setInterval(scrollTo, 100));
1140 });
1141
1142 $(".indicator").mouseup(function(){
1143 pressTimer.forEach(clearInterval);
1144 });
1145
1146 $("body").mouseup(function(){
1147 pressTimer.forEach(clearInterval);
1148 console.log("body mouseup");
1149 });
1150
1151 function scrollTo(){
1152 console.log("here");
1153 var pos = $("#topnav").scrollLeft();
1154 document.getElementById("topnav").scrollTo({ left: $("#topnav").scrollLeft() + direction * step, behavior: 'smooth' })
1155 }
1156
1157 $("#topnav").scroll(function(){
1158 if (($("#topnav").offsetWidth + $("#topnav").scrollLeft >= $("#topnav").scrollWidth)) {
1159 console.log("end");
1160 }
1161 });
1162 /* End Header Scroll */
1163});
1164</script>
1165
1166<?php
1167$keyCodeForEnter = '';
1168if (!empty($_SESSION['takeposterminal'])) {
1169 $keyCodeForEnter = getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) > 0 ? getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) : '';
1170}
1171?>
1172<div class="container">
1173
1174<?php
1175if (!getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1176 ?>
1177 <div class="header">
1178 <div id="topnav" class="topnav">
1179 <div id="topnav-left" class="topnav-left">
1180 <div class="inline-block valignmiddle">
1181 <a class="topnav-terminalhour" onclick="ModalBox('ModalTerminal')">
1182 <span class="fa fa-cash-register"></span>
1183 <span class="hideonsmartphone">
1184 <?php
1185 if (!empty($_SESSION["takeposterminal"])) {
1186 echo getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$_SESSION["takeposterminal"], $langs->trans("TerminalName", $_SESSION["takeposterminal"]));
1187 }
1188 ?>
1189 </span>
1190 <?php
1191 echo '<span class="hideonsmartphone"> - '.dol_print_date(dol_now(), "day").'</span>'; ?>
1192 </a>
1193 <?php
1194 if (isModEnabled('multicurrency')) {
1195 print '<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1196 print '<span class="hideonsmartphone">'.$langs->trans("Currency").'</span>';
1197 print '</a>';
1198 } ?>
1199 </div>
1200 <!-- section for customer -->
1201 <div class="inline-block valignmiddle" id="customerandsales"></div>
1202 <input type="hidden" id="idcustomer" value="">
1203 <!-- section for shopping carts -->
1204 <div class="inline-block valignmiddle" id="shoppingcart"></div>
1205 <!-- More info about customer -->
1206 <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="moreinfo"></div>
1207 <?php
1208 if (isModEnabled('stock')) {
1209 ?>
1210 <!-- More info about warehouse -->
1211 <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="infowarehouse"></div>
1212 <?php
1213 } ?>
1214 </div>
1215 <div id="topnav-right" class="topnav-right">
1216 <?php
1217 $reshook = $hookmanager->executeHooks('takepos_login_block_other');
1218 if ($reshook == 0) { //Search method
1219 ?>
1220 <div class="login_block_other takepos">
1221 <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>
1222 <a onclick="ClearSearch(false);" class="nohover"><span class="fa fa-backspace"></span></a>
1223 <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 -->
1224 <span class="fas fa-home"></span></a>
1225 <?php if (empty($conf->dol_use_jmobile)) { ?>
1226 <a class="hideonsmartphone" onclick="FullScreen();" title="<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave")); ?>"><span class="fa fa-expand-arrows-alt"></span></a>
1227 <?php } ?>
1228 </div>
1229 <?php
1230 }
1231 ?>
1232 <div class="login_block_user">
1233 <?php
1234 print top_menu_user(1, DOL_URL_ROOT.'/user/logout.php?token='.newToken().'&urlfrom='.urlencode('/takepos/?setterminal='.((int) $term)));
1235 ?>
1236 </div>
1237 </div>
1238 <div class="arrows">
1239 <span class="indicator left"><i class="fa fa-arrow-left"></i></span>
1240 <span class="indicator right"><i class="fa fa-arrow-right"></i></span>
1241 </div>
1242 </div>
1243 </div>
1244 <?php
1245}
1246?>
1247
1248<!-- Modal terminal box -->
1249<div id="ModalTerminal" class="modal">
1250 <div class="modal-content">
1251 <div class="modal-header">
1252 <?php
1253 if (!getDolGlobalString('TAKEPOS_FORCE_TERMINAL_SELECT')) {
1254 ?>
1255 <span class="close" href="#" onclick="document.getElementById('ModalTerminal').style.display = 'none';">&times;</span>
1256 <?php
1257 } ?>
1258 <h3><?php print $langs->trans("TerminalSelect"); ?></h3>
1259 </div>
1260 <div class="modal-body">
1261 <button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print getDolGlobalString("TAKEPOS_TERMINAL_NAME_1", $langs->trans("TerminalName", 1)); ?></button>
1262 <?php
1263 $nbloop = getDolGlobalInt('TAKEPOS_NUM_TERMINALS');
1264 for ($i = 2; $i <= $nbloop; $i++) {
1265 print '<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$i, $langs->trans("TerminalName", $i)).'</button>';
1266 }
1267 ?>
1268 </div>
1269</div>
1270</div>
1271
1272<!-- Modal multicurrency box -->
1273<?php if (isModEnabled('multicurrency')) { ?>
1274<div id="ModalCurrency" class="modal">
1275 <div class="modal-content">
1276 <div class="modal-header">
1277 <span class="close" href="#" onclick="document.getElementById('ModalCurrency').style.display = 'none';">&times;</span>
1278 <h3><?php print $langs->trans("SetMultiCurrencyCode"); ?></h3>
1279 </div>
1280 <div class="modal-body">
1281 <?php
1282 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1283 $sql .= " WHERE entity IN ('".getEntity('multicurrency')."')";
1284 $resql = $db->query($sql);
1285 if ($resql) {
1286 while ($obj = $db->fetch_object($resql)) {
1287 print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>';
1288 }
1289 }
1290 ?>
1291 </div>
1292 </div>
1293</div>
1294<?php } ?>
1295
1296<!-- Modal terminal Credit Note -->
1297<div id="ModalCreditNote" class="modal">
1298 <div class="modal-content">
1299 <div class="modal-header">
1300 <span class="close" href="#" onclick="document.getElementById('ModalCreditNote').style.display = 'none';">&times;</span>
1301 <h3><?php print $langs->trans("invoiceAvoirWithLines"); ?></h3>
1302 </div>
1303 <div class="modal-body">
1304 <button type="button" class="block" onclick="CreditNote(); document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("Yes"); ?></button>
1305 <button type="button" class="block" onclick="document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("No"); ?></button>
1306 </div>
1307</div>
1308</div>
1309
1310<!-- Modal Note -->
1311<div id="ModalNote" class="modal">
1312 <div class="modal-content">
1313 <div class="modal-header">
1314 <span class="close" href="#" onclick="document.getElementById('ModalNote').style.display = 'none';">&times;</span>
1315 <h3><?php print $langs->trans("Note"); ?></h3>
1316 </div>
1317 <div class="modal-body">
1318 <input type="text" class="block" id="textinput">
1319 <button type="button" class="block" onclick="SetNote(); document.getElementById('ModalNote').style.display = 'none';">OK</button>
1320 </div>
1321</div>
1322</div>
1323
1324 <div class="row1<?php if (!getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1325 print 'withhead';
1326 } ?>">
1327
1328 <div id="poslines" class="div1">
1329 </div>
1330
1331 <div class="div2">
1332 <button type="button" class="calcbutton" onclick="Edit(7);">7</button>
1333 <button type="button" class="calcbutton" onclick="Edit(8);">8</button>
1334 <button type="button" class="calcbutton" onclick="Edit(9);">9</button>
1335 <button type="button" id="qty" class="calcbutton2" onclick="Edit('qty')"><?php echo $langs->trans("Qty"); ?></button>
1336 <button type="button" class="calcbutton" onclick="Edit(4);">4</button>
1337 <button type="button" class="calcbutton" onclick="Edit(5);">5</button>
1338 <button type="button" class="calcbutton" onclick="Edit(6);">6</button>
1339 <button type="button" id="price" class="calcbutton2" onclick="Edit('p')"><?php echo $langs->trans("Price"); ?></button>
1340 <button type="button" class="calcbutton" onclick="Edit(1);">1</button>
1341 <button type="button" class="calcbutton" onclick="Edit(2);">2</button>
1342 <button type="button" class="calcbutton" onclick="Edit(3);">3</button>
1343 <button type="button" id="reduction" class="calcbutton2" onclick="Edit('r')"><?php echo $langs->trans("LineDiscountShort"); ?></button>
1344 <button type="button" class="calcbutton" onclick="Edit(0);">0</button>
1345 <button type="button" class="calcbutton" onclick="Edit('.')">.</button>
1346 <button type="button" class="calcbutton poscolorblue" onclick="Edit('c')">C</button>
1347 <button type="button" class="calcbutton2 poscolordelete" id="delete" onclick="deleteline()"><span class="fa fa-trash"></span></button>
1348 </div>
1349
1350<?php
1351
1352// TakePOS setup check
1353if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) {
1354 $sql = "SELECT code, libelle FROM " . MAIN_DB_PREFIX . "c_paiement";
1355 $sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")";
1356 $sql .= " AND active = 1";
1357 $sql .= " ORDER BY libelle";
1358
1359 $resql = $db->query($sql);
1360 $paiementsModes = array();
1361 if ($resql) {
1362 while ($obj = $db->fetch_object($resql)) {
1363 $paycode = $obj->code;
1364 if ($paycode == 'LIQ') {
1365 $paycode = 'CASH';
1366 }
1367 if ($paycode == 'CHQ') {
1368 $paycode = 'CHEQUE';
1369 }
1370
1371 $constantforkey = "CASHDESK_ID_BANKACCOUNT_" . $paycode . $_SESSION["takeposterminal"];
1372 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1373 if (getDolGlobalInt($constantforkey) > 0) {
1374 array_push($paiementsModes, $obj);
1375 }
1376 }
1377 }
1378
1379 if (empty($paiementsModes) && isModEnabled("bank")) {
1380 $langs->load('errors');
1381 setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors');
1382 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"]), null, 'errors');
1383 }
1384}
1385
1386if (count($maincategories) == 0) {
1387 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1388 $tmpcategory = new Categorie($db);
1389 $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID'));
1390 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory", $tmpcategory->label), null, 'errors');
1391 } else {
1392 setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors');
1393 }
1394}
1395// User menu and external TakePOS modules
1396$menus = array();
1397$r = 0;
1398
1399if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1400 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("New").'</div>', 'action' => 'New();');
1401} else {
1402 // BAR RESTAURANT specific menu
1403 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("Place").'</div>', 'action' => 'Floors();');
1404}
1405
1406if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1407 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1408 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1409 } else {
1410 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Customer").'</div>', 'action' => 'Customer();');
1411 }
1412}
1413if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1414 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly"></span><div class="trunc">'.$langs->trans("History").'</div>', 'action' => 'History();');
1415}
1416$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly"></span><div class="trunc">'.$langs->trans("FreeZone").'</div>', 'action' => 'FreeZone();');
1417$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly"></span><div class="trunc">'.$langs->trans("InvoiceDiscountShort").'</div>', 'action' => 'Reduction();');
1418
1419if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1420 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly"></span><div class="trunc">'.$langs->trans("SplitSale").'</div>', 'action' => 'Split();');
1421}
1422
1423// BAR RESTAURANT specific menu
1424if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1425 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1426 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly"></span><div class="trunc">'.$langs->trans("Order").'</span>', 'action' => 'TakeposPrintingOrder();');
1427 }
1428}
1429
1430// Last action that close the sell (payments)
1431$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("Payment").'</div>', 'action' => 'CloseBill();');
1432if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1433 $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();');
1434}
1435
1436// BAR RESTAURANT specific menu
1437if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1438 //Button to print receipt before payment
1439 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1440 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
1441 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1442 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action' => 'TakeposConnector(placeid);');
1443 } else {
1444 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action' => 'TakeposPrinting(placeid);');
1445 }
1446 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
1447 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1448 } else {
1449 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action' => 'Print(placeid);');
1450 }
1451 }
1452 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1453 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action' => 'TakeposOrderNotes();');
1454 }
1455 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1456 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1457 }
1458}
1459
1460if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
1461 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>', 'action' => 'OpenDrawer();');
1462}
1463if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
1464 $menus[$r++] = array(
1465 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>',
1466 'action' => 'DolibarrOpenDrawer();',
1467 );
1468}
1469
1470$sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
1471$sql .= " entity = ".((int) $conf->entity)." AND ";
1472$sql .= " posnumber = ".((int) empty($_SESSION["takeposterminal"]) ? 0 : $_SESSION["takeposterminal"])." AND ";
1473$sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
1474
1475$resql = $db->query($sql);
1476if ($resql) {
1477 $num = $db->num_rows($resql);
1478 if ($num) {
1479 $obj = $db->fetch_object($resql);
1480 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly"></span><div class="trunc">'.$langs->trans("CashReport").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1481 if ($obj->status == 0) {
1482 $menus[$r++] = array('title' => '<span class="fas fa-cash-register paddingrightonly"></span><div class="trunc">'.$langs->trans("CloseCashFence").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1483 }
1484 }
1485}
1486
1487$parameters = array('menus' => $menus);
1488$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1489if ($reshook == 0) { //add buttons
1490 if (is_array($hookmanager->resArray)) {
1491 foreach ($hookmanager->resArray as $resArray) {
1492 foreach ($resArray as $butmenu) {
1493 $menus[$r++] = $butmenu;
1494 }
1495 }
1496 }
1497} elseif ($reshook == 1) {
1498 $r = 0; //replace buttons
1499 if (is_array($hookmanager->resArray) ) {
1500 foreach ($hookmanager->resArray as $resArray) {
1501 foreach ($resArray as $butmenu) {
1502 $menus[$r++] = $butmenu;
1503 }
1504 }
1505 }
1506}
1507
1508if ($r % 3 == 2) {
1509 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1510}
1511
1512if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1513 $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().'\';');
1514}
1515
1516if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1517 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale pictofixedwidth"></span><div class="trunc">'.$langs->trans("WeighingScale").'</div>', 'action' => 'WeighingScale();');
1518}
1519
1520?>
1521 <!-- Show buttons -->
1522 <div class="div3">
1523 <?php
1524 $i = 0;
1525 foreach ($menus as $menu) {
1526 $i++;
1527 if (count($menus) > 12 and $i == 12) {
1528 echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="actionnext" class="actionbutton" onclick="MoreActions('.count($menus).')">'.$langs->trans("Next").'</button>';
1529 echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
1530 } elseif ($i > 12) {
1531 echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
1532 } else {
1533 echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
1534 }
1535 }
1536
1537 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1538 print '<!-- Show the search input text -->'."\n";
1539 print '<div class="margintoponly">';
1540 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> ';
1541 print '<a class="marginleftonly hideonsmartphone" onclick="ClearSearch(false);">'.img_picto('', 'searchclear').'</a>';
1542 print '</div>';
1543 }
1544 ?>
1545 </div>
1546 </div>
1547
1548 <div class="row2<?php if (!getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1549 print 'withhead';
1550 } ?>">
1551
1552 <!-- Show categories -->
1553 <?php
1554 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1555 print '<div class="div4" style= "display: none;">';
1556 } else {
1557 print '<div class="div4">';
1558 }
1559
1560 $count = 0;
1561 while ($count < $MAXCATEG) {
1562 ?>
1563 <div class="wrapper" <?php if ($count == ($MAXCATEG - 2)) {
1564 echo 'onclick="MoreCategories(\'less\')"';
1565 } elseif ($count == ($MAXCATEG - 1)) {
1566 echo 'onclick="MoreCategories(\'more\')"';
1567 } else {
1568 echo 'onclick="LoadProducts('.$count.')"';
1569 } ?> id="catdiv<?php echo $count; ?>">
1570 <?php
1571 if ($count == ($MAXCATEG - 2)) {
1572 //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="catimg'.$count.'" />';
1573 echo '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1574 } elseif ($count == ($MAXCATEG - 1)) {
1575 //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="catimg'.$count.'" />';
1576 echo '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1577 } else {
1578 if (!getDolGlobalString('TAKEPOS_HIDE_CATEGORY_IMAGES')) {
1579 echo '<img class="imgwrapper" id="catimg'.$count.'" />';
1580 }
1581 } ?>
1582 <?php if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1583 <div class="description" id="catdivdesc<?php echo $count; ?>">
1584 <div class="description_content" id="catdesc<?php echo $count; ?>"></div>
1585 </div>
1586 <?php } ?>
1587 <div class="catwatermark" id='catwatermark<?php echo $count; ?>'>...</div>
1588 </div>
1589 <?php
1590 $count++;
1591 }
1592 ?>
1593 </div>
1594
1595 <!-- Show product -->
1596 <div class="div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1597 print ' centpercent';
1598 } ?>">
1599 <?php
1600 $count = 0;
1601
1602 while ($count < $MAXPRODUCT) {
1603 print '<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ? ' arrow' : '').'" id="prodiv'.$count.'" '; ?>
1604 <?php if ($count == ($MAXPRODUCT - 2)) {
1605 ?> onclick="MoreProducts('less')" <?php
1606 }
1607 if ($count == ($MAXPRODUCT - 1)) {
1608 ?> onclick="MoreProducts('more')" <?php
1609 } else {
1610 echo 'onclick="ClickProduct('.$count.')"';
1611 } ?>>
1612 <?php
1613 if ($count == ($MAXPRODUCT - 2)) {
1614 //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';
1615 print '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1616 } elseif ($count == ($MAXPRODUCT - 1)) {
1617 //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="proimg'.$count.'" />';
1618 print '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1619 } else {
1620 if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_PRICES')) {
1621 print '<div class="" id="proprice'.$count.'"></div>';
1622 }
1623 if (getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
1624 print '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>';
1625 } else {
1626 print '<img class="imgwrapper" title="" id="proimg'.$count.'">';
1627 }
1628 } ?>
1629 <?php if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1630 <div class="description" id="prodivdesc<?php echo $count; ?>">
1631 <div class="description_content" id="prodesc<?php echo $count; ?>"></div>
1632 </div>
1633 <?php } ?>
1634 <div class="catwatermark" id='prowatermark<?php echo $count; ?>'>...</div>
1635 </div>
1636 <?php
1637 $count++;
1638 }
1639 ?>
1640 <input type="hidden" id="search_start_less" value="0">
1641 <input type="hidden" id="search_start_more" value="0">
1642 <input type="hidden" id="search_pagination" value="">
1643 </div>
1644 </div>
1645</div>
1646</body>
1647<?php
1648
1649llxFooter();
1650
1651$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
print $object position
Definition edit.php:204
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.
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:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:150
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:153
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.