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