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