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