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