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