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();?>&thirdpartyid=' + jQuery(
'#thirdpartyid').val() +
'&category='+currentcat,
function(data) {
326 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
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");
373 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
377 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
382 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
383 console.log($(
"#prodiv"+ishow));
385 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
386 console.log($(
'#prodiv4').data(
'rowid'));
387 $(
"#prodiv"+ishow).data(
"iscat", 0);
388 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
389 $(
"#prowatermark"+ishow).hide();
394 $parameters[
'caller'] =
'loadProducts';
395 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
396 print $hookmanager->resPrint;
407 function MoreProducts(moreorless) {
408 console.log(
"MoreProducts");
410 if ($(
'#search_pagination').val() !=
'') {
411 return Search2(
'<?php echo (isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
414 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
416 if (moreorless==
"more"){
417 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
418 $(
'#proimg31').animate({opacity:
'1'}, 100);
419 pageproducts=pageproducts+1;
421 if (moreorless==
"less"){
422 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
423 $(
'#proimg30').animate({opacity:
'1'}, 100);
424 if (pageproducts==0)
return;
425 pageproducts=pageproducts-1;
427 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat,
function(data) {
428 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
430 if (typeof (data[(maxproduct * pageproducts)]) ==
"undefined" && moreorless==
"more"){
431 pageproducts=pageproducts-1;
434 idata=<?php echo ($MAXPRODUCT - 2); ?> * pageproducts;
437 while (ishow < maxproduct) {
438 if (typeof (data[idata]) ==
"undefined") {
439 $(
"#prodivdesc"+ishow).hide();
440 $(
"#prodesc"+ishow).text(
"");
441 $(
"#probutton"+ishow).text(
"");
442 $(
"#probutton"+ishow).hide();
443 $(
"#proprice"+ishow).attr(
"class",
"");
444 $(
"#proprice"+ishow).html(
"");
445 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
446 $(
"#prodiv"+ishow).data(
"rowid",
"");
449 else if ((data[idata][
'status']) ==
"1") {
451 $(
"#prodivdesc"+ishow).show();
454 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
456 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
458 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
459 $(
"#probutton"+ishow).show();
460 if (data[parseInt(idata)][
'price_formated']) {
461 $(
"#proprice" + ishow).attr(
"class",
"productprice");
465 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
469 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
474 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
475 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
476 $(
"#prodiv"+ishow).data(
"iscat",0);
479 $(
"#prowatermark"+ishow).hide();
487 function ClickProduct(position, qty = 1) {
488 console.log(
"ClickProduct at position"+position);
489 $(
'#proimg'+position).animate({opacity:
'0.5'}, 1);
490 $(
'#proimg'+position).animate({opacity:
'1'}, 100);
491 if ($(
'#prodiv'+position).data(
'iscat')==1){
492 console.log(
"Click on a category at position "+position);
493 LoadProducts(position,
true);
496 console.log($(
'#prodiv4').data(
'rowid'));
497 idproduct=$(
'#prodiv'+position).data(
'rowid');
498 console.log(
"Click on product at position "+position+
" for idproduct "+idproduct+
", qty="+qty);
499 if (idproduct==
"")
return;
501 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+
"&idproduct="+idproduct+
"&selectedline="+selectedline+
"&qty="+qty,
function() {
502 <?php
if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo
"CustomerDisplay();";?>
509 function ChangeThirdparty(idcustomer) {
510 console.log(
"ChangeThirdparty");
512 $(
"#poslines").load(
"../societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+
"&place="+place+
"",
function() {
518 function deleteline() {
519 console.log(
"Delete line");
520 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
526 function Customer() {
527 console.log(
"Open box to select the thirdparty place="+place);
528 $.colorbox({href:
"../societe/list.php?type=t&contextpage=poslist&nomassaction=1&place="+place, width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Customer
"); ?>"});
533 console.log(
"Open box to select the history");
534 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
537 function Reduction() {
538 invoiceid = $(
"#invoiceid").val();
539 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
540 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
543 function CloseBill() {
544 invoiceid = $(
"#invoiceid").val();
545 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
546 $.colorbox({href:
"pay.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
550 invoiceid = $(
"#invoiceid").val();
551 console.log(
"Open popup to split on invoiceid="+invoiceid);
552 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
556 console.log(
"Open box to select floor place="+place);
557 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
560 function FreeZone() {
561 console.log(
"Open box to enter a free product");
562 $.colorbox({href:
"freezone.php?action=freezone&token=<?php echo newToken(); ?>&place="+place, width:
"80%", height:
"200px", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("FreeZone
"); ?>"});
565 function TakeposOrderNotes() {
566 console.log(
"Open box to order notes");
567 ModalBox(
'ModalNote');
568 $(
"#textinput").focus();
572 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
573 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
580 invoiceid = $(
"#invoiceid").val();
582 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
584 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
587 if (parseInt(data[
'paye']) === 1) {
590 r = confirm(
'<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
595 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
610 function Search2(keyCodeForEnter, moreorless) {
611 var eventKeyCode = window.event.keyCode;
613 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
615 var search_term = $(
'#search').val();
616 var search_start = 0;
617 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
618 if (moreorless !=
null) {
619 search_term = $(
'#search_pagination').val();
620 search_start = $(
'#search_start_'+moreorless).val();
623 console.log(
"search_term="+search_term);
625 if (search_term ==
'') {
626 $(
"[id^=prowatermark]").html(
"");
627 $(
"[id^=prodesc]").text(
"");
628 $(
"[id^=probutton]").text(
"");
629 $(
"[id^=probutton]").hide();
630 $(
"[id^=proprice]").attr(
"class",
"hidden");
631 $(
"[id^=proprice]").html(
"");
632 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
633 $(
"[id^=prodiv]").data(
"rowid",
"");
638 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
642 if (search ===
true) {
646 clearTimeout(search2_timer);
650 search2_timer = setTimeout(
function(){
652 jQuery(
".wrapper2 .catwatermark").hide();
653 var nbsearchresults = 0;
654 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term +
'&thirdpartyid=' + jQuery(
'#thirdpartyid').val() +
'&search_start=' + search_start +
'&search_limit=' + search_limit,
function (data) {
655 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
656 if (typeof (data[i]) ==
"undefined") {
657 $(
"#prowatermark" + i).html(
"");
658 $(
"#prodesc" + i).text(
"");
659 $(
"#probutton" + i).text(
"");
660 $(
"#probutton" + i).hide();
661 $(
"#proprice" + i).attr(
"class",
"hidden");
662 $(
"#proprice" + i).html(
"");
663 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
664 $(
"#prodiv" + i).data(
"rowid",
"");
668 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
669 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
671 var titlestring = <?php echo $titlestring; ?>;
674 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
676 $(
"#prodesc" + i).html(data[i][
'label']);
678 $(
"#prodivdesc" + i).show();
679 $(
"#probutton" + i).html(data[i][
'label']);
680 $(
"#probutton" + i).show();
681 if (data[i][
'price_formated']) {
682 $(
"#proprice" + i).attr(
"class",
"productprice");
686 $(
"#proprice" + i).html(data[i][
'price_formated']);
690 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
695 $(
"#proimg" + i).attr(
"title", titlestring);
696 if( undefined !== data[i][
'img']) {
697 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
700 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
702 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
703 $(
"#prodiv" + i).data(
"iscat", 0);
708 $parameters[
'caller'] =
'search2';
709 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
710 print $hookmanager->resPrint;
715 }).always(
function (data) {
717 if ($(
'#search').val().length > 0 && data.length == 1) {
718 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
719 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
720 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
721 ChangeThirdparty(data[0][
'rowid']);
723 else if ($(
'#search').val() == data[0][
'barcode'] &&
'product' == data[0][
'object']) {
724 console.log(
"There is only 1 answer and we found search on a barcode, so we add the product in basket, qty="+data[0][
'qty']);
725 ClickProduct(0, data[0][
'qty']);
728 if (eventKeyCode == keyCodeForEnter){
729 if (data.length == 0) {
730 $(
'#search').val(
'<?php
731 $langs->load('errors
');
732 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
733 ?> ('+search_term+
')');
734 $(
'#search').select();
739 $(
"#search_pagination").val($(
"#search").val());
740 if (search_start == 0) {
741 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
744 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
745 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
746 $(
"#search_start_less").val(search_start_less);
748 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
749 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
752 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
753 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
754 $(
"#search_start_more").val(search_start_more);
763 function Edit(number) {
764 console.log(
"We click on PAD on key="+number);
766 if (typeof(selectedtext) ==
"undefined") {
770 var text=selectedtext+
"<br> ";
776 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
777 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
778 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
780 }
else if (number==
'qty') {
781 if (editaction==
'qty' && editnumber !=
'') {
782 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
785 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
788 setFocusOnSearchField();
794 }
else if (number==
'p') {
795 if (editaction==
'p' && editnumber!=
"") {
796 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
799 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
808 }
else if (number==
'r') {
809 if (editaction==
'r' && editnumber!=
"") {
810 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
813 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
824 editnumber=editnumber+number;
826 if (editaction==
'qty'){
827 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
828 $(
"#qty").html(
"OK").addClass(
"clicked");
829 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
830 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
832 if (editaction==
'p'){
833 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
834 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
835 $(
"#price").html(
"OK").addClass(
"clicked");
836 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
838 if (editaction==
'r'){
839 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("ReductionShort
").":
"; ?>";
840 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
841 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
842 $(
"#reduction").html(
"OK").addClass(
"clicked");
844 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
848 function TakeposPrintingOrder(){
849 console.log(
"TakeposPrintingOrder");
850 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
855 function TakeposPrintingTemp(){
856 console.log(
"TakeposPrintingTemp");
857 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
862 function OpenDrawer(){
863 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
866 data: { token:
'notrequired' },
868 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
869 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
871 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
878 function DolibarrOpenDrawer() {
879 console.log(
"DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal
"]); ?>");
882 data: { token:
'<?php echo currentToken(); ?>' },
883 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode($_SESSION["takeposterminal
"]); ?>",
887 function MoreActions(totalactions){
890 for (i = 0; i <= totalactions; i++){
891 if (i<12) $(
"#action"+i).hide();
892 else $(
"#action"+i).show();
895 else if (pageactions==1){
897 for (i = 0; i <= totalactions; i++){
898 if (i<12) $(
"#action"+i).show();
899 else $(
"#action"+i).hide();
904 function ControlCashOpening()
906 $.colorbox({href:
"../compta/cashcontrol/cashcontrol_card.php?action=create&contextpage=takepos", width:
"90%", height:
"60%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("NewCashFence
"); ?>"});
909 function CloseCashFence(
rowid)
911 $.colorbox({href:
"../compta/cashcontrol/cashcontrol_card.php?id="+
rowid+
"&contextpage=takepos", width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("NewCashFence
"); ?>"});
914 function CashReport(
rowid)
916 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+
rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
920 function ModalBox(ModalID)
922 var modal = document.getElementById(ModalID);
923 modal.style.display =
"block";
926 function DirectPayment(){
927 console.log(
"DirectPayment");
928 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
932 function FullScreen() {
933 document.documentElement.requestFullscreen();
936 function WeighingScale(){
937 console.log(
"Weighing Scale");
940 data: { token:
'notrequired' },
941 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
943 .done(
function( editnumber ) {
944 $(
"#poslines").load(
"invoice.php?&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
950 $( document ).ready(
function() {
956 if ($_SESSION[
"takeposterminal"] ==
"") {
957 print
"ModalBox('ModalTerminal');";
961 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
962 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
963 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
965 $resql = $db->query($sql);
967 $obj = $db->fetch_object(
$resql);
969 if (!isset($obj->rowid) || is_null($obj->rowid)) {
970 print
"ControlCashOpening();";
977 var elem1 = $(
"#topnav-left")[0];
978 var elem2 = $(
"#topnav-right")[0];
979 var checkOverflow =
function() {
980 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
981 else $(
"#topnav").removeClass(
"overflow");
984 var scrollBars =
function(){
985 var container= $(
'#topnav')[0];
987 vertical:container.scrollHeight > container.clientHeight,
988 horizontal:container.scrollWidth > container.clientWidth
992 $(window).resize(
function(){
996 let resizeObserver =
new ResizeObserver(() => {
999 resizeObserver.observe(elem1);
1000 resizeObserver.observe(elem2);
1003 var pressTimer = [];
1007 $(
".indicator").mousedown(
function(){
1008 direction = $(
this).hasClass(
"left") ? -1 : 1;
1010 pressTimer.push(setInterval(scrollTo, 100));
1013 $(
".indicator").mouseup(
function(){
1014 pressTimer.forEach(clearInterval);
1017 $(
"body").mouseup(
function(){
1018 pressTimer.forEach(clearInterval);
1019 console.log(
"body");
1022 function scrollTo(){
1023 console.log(
"here");
1024 var pos = $(
"#topnav").scrollLeft();
1025 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1028 $(
"#topnav").scroll(
function(){
1029 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1038 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1040 <div
class=
"container">
1043 if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1045 <div
class=
"header">
1046 <div
id=
"topnav" class=
"topnav">
1047 <div
id=
"topnav-left" class=
"topnav-left">
1048 <div
class=
"inline-block valignmiddle">
1049 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal');">
1050 <span
class=
"fa fa-cash-register"></span>
1051 <span
class=
"hideonsmartphone">
1052 <?php echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"])); ?>
1055 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>';
1060 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\');" title=""><span class="fas fa-coins paddingrightonly"></span>';
1061 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1066 <!-- section
for customer -->
1067 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1068 <!-- section
for shopping carts -->
1069 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1070 <!-- More info about customer -->
1071 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1075 <!-- More info about warehouse -->
1076 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1081 <div
id=
"topnav-right" class=
"topnav-right">
1082 <div
class=
"login_block_other">
1083 <input
type=
"text" id=
"search" name=
"search" class=
"input-search-takepos" onkeyup=
"Search2('<?php echo dol_escape_js($keyCodeForEnter); ?>', null);" placeholder=
"<?php echo dol_escape_htmltag($langs->trans("Search
")); ?>" autofocus>
1084 <a onclick=
"ClearSearch();"><span
class=
"fa fa-backspace"></span></a>
1085 <a href=
"<?php echo DOL_URL_ROOT.'/'; ?>" target=
"backoffice" rel=
"opener"><!-- we need rel=
"opener" here, we are on same domain and we need to be able to reuse
this tab several times -->
1086 <span
class=
"fas fa-home"></span></a>
1087 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1088 <a
class=
"hideonsmartphone" onclick=
"FullScreen();"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1091 <div
class=
"login_block_user">
1097 <div
class=
"arrows">
1098 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1099 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1107 <!-- Modal terminal box -->
1108 <div
id=
"ModalTerminal" class=
"modal">
1109 <div
class=
"modal-content">
1110 <div
class=
"modal-header">
1111 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1112 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1114 <div
class=
"modal-body">
1115 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1118 for ($i = 2; $i <= $nbloop; $i++) {
1119 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1126 <!-- Modal multicurrency box -->
1127 <?php if (isModEnabled('multicurrency')) { ?>
1128 <div id="ModalCurrency
" class="modal
">
1129 <div class="modal-content
">
1130 <div class="modal-header
">
1131 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1132 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1134 <div class="modal-body
">
1136 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1137 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1138 $resql = $db->query($sql);
1140 while ($obj = $db->fetch_object($resql)) {
1141 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1150 <!-- Modal terminal Credit Note -->
1151 <div id="ModalCreditNote
" class="modal
">
1152 <div class="modal-content
">
1153 <div class="modal-header
">
1154 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1155 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1157 <div class="modal-body
">
1158 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1159 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1165 <div id="ModalNote
" class="modal
">
1166 <div class="modal-content
">
1167 <div class="modal-header
">
1168 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1169 <h3><?php print $langs->trans("Note
"); ?></h3>
1171 <div class="modal-body
">
1172 <input type="text
" class="block
" id="textinput
">
1173 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1178 <div class="row1<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1182 <div id="poslines
" class="div1
">
1186 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1187 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1188 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1189 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty');
"><?php echo $langs->trans("Qty
"); ?></button>
1190 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1191 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1192 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1193 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p');
"><?php echo $langs->trans("Price
"); ?></button>
1194 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1195 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1196 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1197 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r');
"><?php echo $langs->trans("ReductionShort
"); ?></button>
1198 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1199 <button type="button" class="calcbutton
" onclick="Edit(
'.');
">.</button>
1200 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c');
">C</button>
1201 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline();
"><span class="fa fa-trash
"></span></button>
1206 // TakePOS setup check
1207 if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1208 $sql = "SELECT
code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1209 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1210 $sql .= " AND active = 1
";
1211 $sql .= " ORDER BY libelle
";
1213 $resql = $db->query($sql);
1214 $paiementsModes = array();
1216 while ( $obj = $db->fetch_object($resql) ) {
1217 $paycode = $obj->code;
1218 if ($paycode == 'LIQ') {
1221 if ($paycode == 'CHQ') {
1222 $paycode = 'CHEQUE';
1225 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1226 //var_dump($constantforkey.' '.$conf->global->$constantforkey);
1227 if ( !empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) {
1228 array_push($paiementsModes, $obj);
1233 if (empty($paiementsModes) && isModEnabled("banque
")) {
1234 $langs->load('errors');
1235 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1236 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1240 if (count($maincategories) == 0) {
1241 if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
1242 $tmpcategory = new Categorie($db);
1243 $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
1244 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1246 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1249 // User menu and external TakePOS modules
1253 if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) {
1254 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action'=>'New();');
1256 // BAR RESTAURANT specific menu
1257 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action'=>'Floors();');
1260 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1261 $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action'=>'Customer();');
1263 $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action'=>'History();');
1264 $menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action'=>'FreeZone();');
1265 $menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Reduction
").'</div>', 'action'=>'Reduction();');
1266 $menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action'=>'CloseBill();');
1268 if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1269 $menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DirectPayment
").' <span class="opacitymedium
">('.$langs->trans("Cash
").')</span></div>', 'action'=>'DirectPayment();');
1272 $menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action'=>'Split();');
1274 // BAR RESTAURANT specific menu
1275 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1276 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1277 $menus[$r++] = array('title'=>'<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action'=>'TakeposPrintingOrder();');
1279 //Button to print receipt before payment
1280 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1281 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1282 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1283 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposConnector(placeid);');
1285 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposPrinting(placeid);');
1287 } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1288 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
1290 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'Print(placeid);');
1293 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1294 $menus[$r++] = array('title'=>'<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action'=>'TakeposOrderNotes();');
1296 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1297 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action'=>'LoadProducts(\'supplements\');');
1301 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1302 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action'=>'OpenDrawer();');
1304 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1305 $menus[$r++] = array(
1306 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1307 'action' => 'DolibarrOpenDrawer();',
1311 $sql = "SELECT
rowid, status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1312 $sql .= " entity =
".((int) $conf->entity)." AND
";
1313 $sql .= " posnumber =
".((int) $_SESSION["takeposterminal
"])." AND
";
1314 $sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1316 $resql = $db->query($sql);
1318 $num = $db->num_rows($resql);
1320 $obj = $db->fetch_object($resql);
1321 $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
1322 if ($obj->status == 0) {
1323 $menus[$r++] = array('title'=>'<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');');
1328 $hookmanager->initHooks(array('takeposfrontend'));
1329 $parameters = array('menus'=>$menus);
1330 $reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1331 if ($reshook == 0) { //add buttons
1332 if (is_array($hookmanager->resArray) ) {
1333 foreach ($hookmanager->resArray as $resArray) {
1334 foreach ($resArray as $butmenu) {
1335 $menus[$r++] = $butmenu;
1338 } elseif ($reshook == 1) {
1339 $r = 0; //replace buttons
1340 if (is_array($hookmanager->resArray) ) {
1341 foreach ($hookmanager->resArray as $resArray) {
1342 foreach ($resArray as $butmenu) {
1343 $menus[$r++] = $butmenu;
1351 $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
1354 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1355 $menus[$r++] = array('title'=>'<span class="fa fa-sign-out-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Logout
").'</div>', 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php?token='.newToken().'\';');
1358 if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
1359 $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action'=>'WeighingScale();');
1363 <!-- Show buttons -->
1367 foreach ($menus as $menu) {
1369 if (count($menus) > 12 and $i == 12) {
1370 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).');
">'.$langs->trans("Next
").'</button>';
1371 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1372 } elseif ($i > 12) {
1373 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1375 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1379 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1380 print '<!-- Show the search input text -->'."\n
";
1381 print '<div class="margintoponly
">';
1382 print '<input type="text
" id="search
" class="input-search-takepos
" name="search
" onkeyup="Search2(\
''.
dol_escape_js($keyCodeForEnter).
'\',
null);
" style="width: 80%; width:calc(100% - 51px); font-size: 150%;
" placeholder="'.dol_escape_htmltag($langs->trans("Search")).'" autofocus> ';
1383 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch();
">'.img_picto('', 'searchclear').'</a>';
1390 <div class="row2<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1394 <!-- Show categories -->
1396 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1397 print '<div class="div4
" style= "display: none;
">';
1399 print '<div class="div4
">';
1403 while ($count < $MAXCATEG) {
1405 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1406 echo 'onclick="MoreCategories(\
'less\');"';
1407 } elseif ($count == ($MAXCATEG - 1)) {
1408 echo
'onclick="MoreCategories(\'more\');"';
1410 echo
'onclick="LoadProducts('.$count.
');"';
1411 } ?>
id=
"catdiv<?php echo $count; ?>">
1413 if ($count == ($MAXCATEG - 2)) {
1415 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1416 } elseif ($count == ($MAXCATEG - 1)) {
1418 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1421 echo
'<img class="imgwrapper" height="100%" id="catimg'.$count.
'" />';
1425 <?php
if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?>
1426 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1427 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1430 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1438 <!-- Show product -->
1439 <div
class=
"div5"<?php
if (
getDolGlobalInt(
'TAKEPOS_HIDE_CATEGORIES') == 1) {
1440 print
' style="width:100%;"';
1444 while ($count < $MAXPRODUCT) {
1445 print
'<div class="wrapper2 arrow" id="prodiv'.$count.
'" ';
1447 <?php
if ($count == ($MAXPRODUCT - 2)) {
1448 ?> onclick=
"MoreProducts('less');" <?php
1449 }
if ($count == ($MAXPRODUCT - 1)) {
1450 ?> onclick=
"MoreProducts('more');" <?php
1452 echo
'onclick="ClickProduct('.$count.
');"';
1455 if ($count == ($MAXPRODUCT - 2)) {
1457 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1458 } elseif ($count == ($MAXPRODUCT - 1)) {
1460 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1463 echo
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1465 print
'<div class="" id="proprice'.$count.
'"></div>';
1466 print
'<img class="imgwrapper" height="100%" title="" id="proimg'.$count.
'">';
1470 <?php
if ($count != ($MAXPRODUCT - 2) && $count != ($MAXPRODUCT - 1) && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1471 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1472 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1475 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1481 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1482 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1483 <input
type=
"hidden" id=
"search_pagination" value=
"">
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,...