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