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