31 if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34 if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37 if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
42 require
'../main.inc.php';
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';
52 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') : 0);
53 $action =
GETPOST(
'action',
'aZ09');
54 $setterminal =
GETPOST(
'setterminal',
'int');
55 $setcurrency =
GETPOST(
'setcurrency',
'aZ09');
57 if (empty($_SESSION[
"takeposterminal"])) {
59 $_SESSION[
"takeposterminal"] = 1;
60 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
61 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
65 if ($setterminal > 0) {
66 $_SESSION[
"takeposterminal"] = $setterminal;
67 setcookie(
"takeposterminal", $setterminal, (time() + (86400 * 354)),
'/',
null, (empty($dolibarr_main_force_https) ?
false :
true),
true);
70 if ($setcurrency !=
"") {
71 $_SESSION[
"takeposcustomercurrency"] = $setcurrency;
75 $_SESSION[
"urlfrom"] =
'/takepos/index.php';
77 $langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter",
"banks"));
81 $maxcategbydefaultforthisdevice = 12;
82 $maxproductbydefaultforthisdevice = 24;
83 if ($conf->browser->layout ==
'phone') {
84 $maxcategbydefaultforthisdevice = 8;
85 $maxproductbydefaultforthisdevice = 16;
87 if ($_SESSION[
"takeposterminal"] !=
"" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) {
88 $_SESSION[
"basiclayout"] = 1;
89 header(
"Location: phone.php?mobilepage=invoice");
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);
116 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
117 $arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
120 $arrayofcss[] =
'/takepos/css/colorful.css';
125 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
126 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
127 $title =
'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
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);
136 $categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
141 $levelofrootcategory = 0;
143 foreach ($categories as $key => $categorycursor) {
144 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
145 $levelofrootcategory = $categorycursor[
'level'];
151 $levelofmaincategories = $levelofrootcategory + 1;
153 $maincategories = array();
154 $subcategories = array();
155 foreach ($categories as $key => $categorycursor) {
156 if ($categorycursor[
'level'] == $levelofmaincategories) {
157 $maincategories[$key] = $categorycursor;
159 $subcategories[$key] = $categorycursor;
167 <body
class=
"bodytakepos" style=
"overflow: hidden;">
170 var categories = <?php echo json_encode($maincategories); ?>;
171 var subcategories = <?php echo json_encode($subcategories); ?>;
175 var pagecategories=0;
177 var place=
"<?php echo $place; ?>";
178 var editaction=
"qty";
181 var search2_timer=
null;
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();
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();
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")
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');
232 $(
"#catdivdesc"+i).show();
235 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
237 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
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();
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;
253 if (moreorless==
"less") {
254 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
255 $(
'#catimg14').animate({opacity:
'1'}, 100);
256 if (pagecategories==0)
return;
257 pagecategories=pagecategories-1;
259 if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless==
"more") ==
"undefined"){
260 pagecategories=pagecategories-1;
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();
271 $(
"#catdivdesc"+i).show();
274 $(
"#catdesc"+i).html(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'description']);
276 $(
"#catdesc"+i).text(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'label']);
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();
287 function LoadProducts(position, issubcat) {
288 console.log(
"LoadProducts");
289 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
291 if (position==
"supplements") currentcat=
"supplements";
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');
299 if (currentcat == undefined)
return;
303 jQuery.each(subcategories,
function(i, val) {
304 if (currentcat==val.fk_parent) {
305 $(
"#prodivdesc"+ishow).show();
307 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
308 $(
"#probutton"+ishow).html(val.label);
310 $(
"#prodesc"+ishow).text(val.label);
311 $(
"#probutton"+ishow).text(val.label);
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();
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");
328 while (ishow < maxproduct) {
330 console.log(data[idata]);
331 if (typeof (data[idata]) ==
"undefined") {
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");';
338 echo
'$("#probutton"+ishow).hide();';
339 echo
'$("#probutton"+ishow).text("");';
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();
348 else if ((data[idata][
'status']) ==
"1") {
350 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
351 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
353 var titlestring = <?php echo $titlestring; ?>;
355 echo
'$("#prodivdesc"+ishow).show();';
357 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
359 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
361 echo
'$("#proimg"+ishow).attr("title", titlestring);';
362 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
364 echo
'$("#probutton"+ishow).show();';
365 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
368 if (data[parseInt(idata)][
'price_formated']) {
369 $(
"#proprice"+ishow).attr(
"class",
"productprice");
370 $(
"#proprice"+ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
372 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
373 console.log($(
"#prodiv"+ishow));
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();
384 $parameters[
'caller'] =
'loadProducts';
385 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
386 print $hookmanager->resPrint;
397 function MoreProducts(moreorless) {
398 console.log(
"MoreProducts");
400 if ($(
'#search_pagination').val() !=
'') {
401 return Search2(
'<?php echo (isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
404 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
406 if (moreorless==
"more"){
407 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
408 $(
'#proimg31').animate({opacity:
'1'}, 100);
409 pageproducts=pageproducts+1;
411 if (moreorless==
"less"){
412 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
413 $(
'#proimg30').animate({opacity:
'1'}, 100);
414 if (pageproducts==0)
return;
415 pageproducts=pageproducts-1;
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);
420 if (typeof (data[(maxproduct * pageproducts)]) ==
"undefined" && moreorless==
"more"){
421 pageproducts=pageproducts-1;
424 idata=<?php echo ($MAXPRODUCT - 2); ?> * pageproducts;
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",
"");
439 else if ((data[idata][
'status']) ==
"1") {
441 $(
"#prodivdesc"+ishow).show();
444 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
446 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
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']);
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);
459 $(
"#prowatermark"+ishow).hide();
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);
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;
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();";?>
489 function ChangeThirdparty(idcustomer) {
490 console.log(
"ChangeThirdparty");
492 $(
"#poslines").load(
"../societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+
"&place="+place+
"",
function() {
498 function deleteline() {
499 console.log(
"Delete line");
500 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
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
"); ?>"});
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
"); ?>"});
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:
""});
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:
""});
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:
""});
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
"); ?>"});
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
"); ?>"});
545 function TakeposOrderNotes() {
546 console.log(
"Open box to order notes");
547 ModalBox(
'ModalNote');
548 $(
"#textinput").focus();
552 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
553 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
560 invoiceid = $(
"#invoiceid").val();
562 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
564 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
567 if (parseInt(data[
'paye']) === 1) {
570 r = confirm(
'<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
575 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
590 function Search2(keyCodeForEnter, moreorless) {
591 var eventKeyCode = window.event.keyCode;
593 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
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();
603 console.log(
"search_term="+search_term);
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",
"");
618 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
622 if (search ===
true) {
626 clearTimeout(search2_timer);
630 search2_timer = setTimeout(
function(){
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",
"");
648 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
649 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
651 var titlestring = <?php echo $titlestring; ?>;
654 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
656 $(
"#prodesc" + i).html(data[i][
'label']);
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']);
665 $(
"#proimg" + i).attr(
"title", titlestring);
666 if( undefined !== data[i][
'img']) {
667 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
670 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
672 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
673 $(
"#prodiv" + i).data(
"iscat", 0);
678 $parameters[
'caller'] =
'search2';
679 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
680 print $hookmanager->resPrint;
685 }).always(
function (data) {
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']);
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']);
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();
709 $(
"#search_pagination").val($(
"#search").val());
710 if (search_start == 0) {
711 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
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);
718 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
719 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
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);
733 function Edit(number) {
734 console.log(
"We click on PAD on key="+number);
736 if (typeof(selectedtext) ==
"undefined") {
740 var text=selectedtext+
"<br> ";
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');
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() {
755 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
758 setFocusOnSearchField();
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() {
769 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
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() {
783 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
794 editnumber=editnumber+number;
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');
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');
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");
814 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
818 function TakeposPrintingOrder(){
819 console.log(
"TakeposPrintingOrder");
820 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
825 function TakeposPrintingTemp(){
826 console.log(
"TakeposPrintingTemp");
827 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
832 function OpenDrawer(){
833 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
836 data: { token:
'notrequired' },
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',";
841 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
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
"]); ?>");
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
"]); ?>",
857 function MoreActions(totalactions){
860 for (i = 0; i <= totalactions; i++){
861 if (i<12) $(
"#action"+i).hide();
862 else $(
"#action"+i).show();
865 else if (pageactions==1){
867 for (i = 0; i <= totalactions; i++){
868 if (i<12) $(
"#action"+i).show();
869 else $(
"#action"+i).hide();
874 function ControlCashOpening()
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
"); ?>"});
879 function CloseCashFence(
rowid)
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
"); ?>"});
884 function CashReport(
rowid)
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
"); ?>"});
890 function ModalBox(ModalID)
892 var modal = document.getElementById(ModalID);
893 modal.style.display =
"block";
896 function DirectPayment(){
897 console.log(
"DirectPayment");
898 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
902 function FullScreen() {
903 document.documentElement.requestFullscreen();
906 function WeighingScale(){
907 console.log(
"Weighing Scale");
910 data: { token:
'notrequired' },
911 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
913 .done(
function( editnumber ) {
914 $(
"#poslines").load(
"invoice.php?&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
920 $( document ).ready(
function() {
926 if ($_SESSION[
"takeposterminal"] ==
"") {
927 print
"ModalBox('ModalTerminal');";
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 ";
935 $resql = $db->query($sql);
937 $obj = $db->fetch_object(
$resql);
939 if ($obj->rowid ==
null) {
940 print
"ControlCashOpening();";
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");
954 var scrollBars =
function(){
955 var container= $(
'#topnav')[0];
957 vertical:container.scrollHeight > container.clientHeight,
958 horizontal:container.scrollWidth > container.clientWidth
962 $(window).resize(
function(){
966 let resizeObserver =
new ResizeObserver(() => {
969 resizeObserver.observe(elem1);
970 resizeObserver.observe(elem2);
977 $(
".indicator").mousedown(
function(){
978 direction = $(
this).hasClass(
"left") ? -1 : 1;
980 pressTimer.push(setInterval(scrollTo, 100));
983 $(
".indicator").mouseup(
function(){
984 pressTimer.forEach(clearInterval);
987 $(
"body").mouseup(
function(){
988 pressTimer.forEach(clearInterval);
994 var pos = $(
"#topnav").scrollLeft();
995 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
998 $(
"#topnav").scroll(
function(){
999 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1008 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1010 <div
class=
"container">
1013 if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
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"])); ?>
1025 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>';
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>';
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>
1045 <!-- More info about warehouse -->
1046 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></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>
1061 <div
class=
"login_block_user">
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>
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';">×</span>
1082 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
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>
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>';
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';
">×</span>
1102 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1104 <div class="modal-body
">
1106 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1107 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1108 $resql = $db->query($sql);
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>';
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';
">×</span>
1125 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
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>
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';
">×</span>
1139 <h3><?php print $langs->trans("Note
"); ?></h3>
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>
1148 <div class="row1<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1152 <div id="poslines
" class="div1
">
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>
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
";
1183 $resql = $db->query($sql);
1184 $paiementsModes = array();
1186 while ( $obj = $db->fetch_object($resql) ) {
1187 $paycode = $obj->code;
1188 if ($paycode == 'LIQ') {
1191 if ($paycode == 'CHQ') {
1192 $paycode = 'CHEQUE';
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);
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');
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');
1216 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1219 // User menu and external TakePOS modules
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();');
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();');
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();');
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();');
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();');
1242 $menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action'=>'Split();');
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();');
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);');
1255 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposPrinting(placeid);');
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);');
1260 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'Print(placeid);');
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();');
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\');');
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();');
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();',
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()))."'";
1286 $resql = $db->query($sql);
1288 $num = $db->num_rows($resql);
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.');');
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;
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;
1321 $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
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().'\';');
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();');
1333 <!-- Show buttons -->
1337 foreach ($menus as $menu) {
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>';
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>';
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>';
1360 <div class="row2<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1364 <!-- Show categories -->
1366 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1367 print '<div class="div4
" style= "display: none;
">';
1369 print '<div class="div4
">';
1373 while ($count < $MAXCATEG) {
1375 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1376 echo 'onclick="MoreCategories(\
'less\');"';
1377 } elseif ($count == ($MAXCATEG - 1)) {
1378 echo
'onclick="MoreCategories(\'more\');"';
1380 echo
'onclick="LoadProducts('.$count.
');"';
1381 } ?>
id=
"catdiv<?php echo $count; ?>">
1383 if ($count == ($MAXCATEG - 2)) {
1385 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1386 } elseif ($count == ($MAXCATEG - 1)) {
1388 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1391 echo
'<img class="imgwrapper" height="100%" id="catimg'.$count.
'" />';
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>
1400 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1408 <!-- Show product -->
1409 <div
class=
"div5"<?php
if (
getDolGlobalInt(
'TAKEPOS_HIDE_CATEGORIES') == 1) {
1410 print
' style="width:100%;"';
1414 while ($count < $MAXPRODUCT) {
1415 print
'<div class="wrapper2 arrow" id="prodiv'.$count.
'" ';
1417 <?php
if ($count == ($MAXPRODUCT - 2)) {
1418 ?> onclick=
"MoreProducts('less');" <?php
1419 }
if ($count == ($MAXPRODUCT - 1)) {
1420 ?> onclick=
"MoreProducts('more');" <?php
1422 echo
'onclick="ClickProduct('.$count.
');"';
1425 if ($count == ($MAXPRODUCT - 2)) {
1427 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1428 } elseif ($count == ($MAXPRODUCT - 1)) {
1430 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1433 echo
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1435 print
'<div class="" id="proprice'.$count.
'"></div>';
1436 print
'<img class="imgwrapper" height="100%" title="" id="proimg'.$count.
'">';
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>
1445 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
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=
"">
Class to manage categories.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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)
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.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
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,...