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