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 $hookmanager->initHooks(array(
'takeposfrontend'));
58 if (empty($_SESSION[
"takeposterminal"])) {
60 $_SESSION[
"takeposterminal"] = 1;
61 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
62 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
66 if ($setterminal > 0) {
67 $_SESSION[
"takeposterminal"] = $setterminal;
68 setcookie(
"takeposterminal", $setterminal, (time() + (86400 * 354)),
'/',
null, (empty($dolibarr_main_force_https) ?
false :
true),
true);
71 if ($setcurrency !=
"") {
72 $_SESSION[
"takeposcustomercurrency"] = $setcurrency;
76 $_SESSION[
"urlfrom"] =
'/takepos/index.php';
78 $langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter",
"banks"));
82 $maxcategbydefaultforthisdevice = 12;
83 $maxproductbydefaultforthisdevice = 24;
84 if ($conf->browser->layout ==
'phone') {
85 $maxcategbydefaultforthisdevice = 8;
86 $maxproductbydefaultforthisdevice = 16;
88 if ($_SESSION[
"takeposterminal"] !=
"" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) {
89 $_SESSION[
"basiclayout"] = 1;
90 header(
"Location: phone.php?mobilepage=invoice");
94 $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
95 $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
117 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
118 $arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
121 $arrayofcss[] =
'/takepos/css/colorful.css';
126 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
127 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
128 $title =
'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
130 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
131 <meta name="apple-mobile-web-app-capable" content="yes">
132 <meta name="mobile-web-app-capable" content="yes">
133 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
134 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
137 $categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
142 $levelofrootcategory = 0;
144 foreach ($categories as $key => $categorycursor) {
145 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
146 $levelofrootcategory = $categorycursor[
'level'];
152 $levelofmaincategories = $levelofrootcategory + 1;
154 $maincategories = array();
155 $subcategories = array();
156 foreach ($categories as $key => $categorycursor) {
157 if ($categorycursor[
'level'] == $levelofmaincategories) {
158 $maincategories[$key] = $categorycursor;
160 $subcategories[$key] = $categorycursor;
168 <body
class=
"bodytakepos" style=
"overflow: hidden;">
171 var categories = <?php echo json_encode($maincategories); ?>;
172 var subcategories = <?php echo json_encode($subcategories); ?>;
176 var pagecategories=0;
178 var place=
"<?php echo $place; ?>";
179 var editaction=
"qty";
182 var search2_timer=
null;
201 function ClearSearch() {
202 console.log(
"ClearSearch");
203 $(
"#search").val(
'');
204 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
205 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
206 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
207 <?php
if ($conf->browser->layout ==
'classic') { ?>
208 setFocusOnSearchField();
213 function setFocusOnSearchField() {
214 console.log(
"Call setFocusOnSearchField in page index.php");
215 <?php
if ($conf->browser->layout ==
'classic') { ?>
216 console.log(
"has keyboard from localStorage, so we can force focus on search field");
217 $(
"#search").focus();
221 function PrintCategories(first) {
222 console.log(
"PrintCategories");
223 for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
224 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
226 $(
"#catdivdesc"+i).hide();
227 $(
"#catdesc"+i).text(
"");
228 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
229 $(
"#catwatermark"+i).hide();
230 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
233 $(
"#catdivdesc"+i).show();
236 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
238 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
240 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
241 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
242 $(
"#catdiv"+i).attr(
'class',
'wrapper');
243 $(
"#catwatermark"+i).show();
247 function MoreCategories(moreorless) {
248 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
249 if (moreorless ==
"more") {
250 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
251 $(
'#catimg15').animate({opacity:
'1'}, 100);
252 pagecategories=pagecategories+1;
254 if (moreorless ==
"less") {
255 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
256 $(
'#catimg14').animate({opacity:
'1'}, 100);
257 if (pagecategories==0)
return;
258 pagecategories=pagecategories-1;
260 if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
261 pagecategories=pagecategories-1;
265 for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
266 if (typeof (categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
268 console.log(
"complete with empty record");
269 $(
"#catdivdesc"+i).hide();
270 $(
"#catdesc"+i).text(
"");
271 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
272 $(
"#catwatermark"+i).hide();
275 $(
"#catdivdesc"+i).show();
278 $(
"#catdesc"+i).html(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'description']);
280 $(
"#catdesc"+i).text(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'label']);
282 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
283 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
284 $(
"#catwatermark"+i).show();
291 function LoadProducts(
position, issubcat) {
292 console.log(
"LoadProducts");
293 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
295 if (
position==
"supplements") currentcat=
"supplements";
298 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
299 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
300 if (issubcat==
true) currentcat=$(
'#prodiv'+
position).data(
'rowid');
301 else currentcat=$(
'#catdiv'+
position).data(
'rowid');
303 if (currentcat == undefined)
return;
307 jQuery.each(subcategories,
function(i, val) {
308 if (currentcat==val.fk_parent) {
309 $(
"#prodivdesc"+ishow).show();
311 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
312 $(
"#probutton"+ishow).html(val.label);
314 $(
"#prodesc"+ishow).text(val.label);
315 $(
"#probutton"+ishow).text(val.label);
317 $(
"#probutton"+ishow).show();
318 $(
"#proprice"+ishow).attr(
"class",
"hidden");
319 $(
"#proprice"+ishow).html(
"");
320 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
321 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
322 $(
"#prodiv"+ishow).data(
"iscat",1);
323 $(
"#prowatermark"+ishow).show();
330 if (maxproduct >= 1) {
331 limit = maxproduct-1;
334 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset=0',
function(data) {
335 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
337 while (ishow < maxproduct) {
339 console.log(data[idata]);
340 if (typeof (data[idata]) ==
"undefined") {
342 echo
'$("#prodivdesc"+ishow).hide();';
343 echo
'$("#prodesc"+ishow).text("");';
344 echo
'$("#proimg"+ishow).attr("title","");';
345 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
347 echo
'$("#probutton"+ishow).hide();';
348 echo
'$("#probutton"+ishow).text("");';
350 $(
"#proprice"+ishow).attr(
"class",
"hidden");
351 $(
"#proprice"+ishow).html(
"");
352 $(
"#prodiv"+ishow).data(
"rowid",
"");
353 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
356 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
357 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
359 var titlestring = <?php echo $titlestring; ?>;
361 echo
'$("#prodivdesc"+ishow).show();';
363 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
365 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
367 echo
'$("#proimg"+ishow).attr("title", titlestring);';
368 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
370 echo
'$("#probutton"+ishow).show();';
371 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
374 if (data[parseInt(idata)][
'price_formated']) {
375 $(
"#proprice"+ishow).attr(
"class",
"productprice");
376 $(
"#proprice"+ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
378 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
379 console.log($(
"#prodiv"+ishow));
381 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
382 console.log($(
'#prodiv4').data(
'rowid'));
383 $(
"#prodiv"+ishow).data(
"iscat", 0);
384 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
389 $parameters[
'caller'] =
'loadProducts';
390 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
391 print $hookmanager->resPrint;
394 $(
"#prowatermark"+ishow).hide();
403 function MoreProducts(moreorless) {
404 console.log(
"MoreProducts");
406 if ($(
'#search_pagination').val() !=
'') {
407 return Search2(
'<?php echo (isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
410 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
412 if (moreorless==
"more"){
413 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
414 $(
'#proimg31').animate({opacity:
'1'}, 100);
415 pageproducts=pageproducts+1;
417 if (moreorless==
"less"){
418 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
419 $(
'#proimg30').animate({opacity:
'1'}, 100);
420 if (pageproducts==0)
return;
421 pageproducts=pageproducts-1;
427 if (maxproduct >= 1) {
428 limit = maxproduct-1;
430 var offset = <?php echo ($MAXPRODUCT - 2); ?> * pageproducts;
432 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset='+offset,
function(data) {
433 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
435 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
436 pageproducts=pageproducts-1;
440 while (ishow < maxproduct) {
441 if (typeof (data[idata]) ==
"undefined") {
442 $(
"#prodivdesc"+ishow).hide();
443 $(
"#prodesc"+ishow).text(
"");
444 $(
"#probutton"+ishow).text(
"");
445 $(
"#probutton"+ishow).hide();
446 $(
"#proprice"+ishow).attr(
"class",
"");
447 $(
"#proprice"+ishow).html(
"");
448 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
449 $(
"#prodiv"+ishow).data(
"rowid",
"");
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");
462 $(
"#proprice"+ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
464 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
465 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
466 $(
"#prodiv"+ishow).data(
"iscat",0);
468 $(
"#prowatermark"+ishow).hide();
477 function ClickProduct(
position, qty = 1) {
478 console.log(
"ClickProduct at position"+
position);
479 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
480 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
481 if ($(
'#prodiv'+
position).data(
'iscat')==1){
482 console.log(
"Click on a category at position "+
position);
486 console.log($(
'#prodiv4').data(
'rowid'));
487 idproduct=$(
'#prodiv'+
position).data(
'rowid');
488 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty);
489 if (idproduct==
"")
return;
491 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+
"&idproduct="+idproduct+
"&selectedline="+selectedline+
"&qty="+qty,
function() {
492 <?php
if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo
"CustomerDisplay();";?>
499 function ChangeThirdparty(idcustomer) {
500 console.log(
"ChangeThirdparty");
502 $(
"#poslines").load(
"../societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+
"&place="+place+
"",
function() {
508 function deleteline() {
509 console.log(
"Delete line");
510 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
516 function Customer() {
517 console.log(
"Open box to select the thirdparty place="+place);
518 $.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
"); ?>"});
523 console.log(
"Open box to select the history");
524 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
527 function Reduction() {
528 invoiceid = $(
"#invoiceid").val();
529 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
530 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
533 function CloseBill() {
534 invoiceid = $(
"#invoiceid").val();
535 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
536 $.colorbox({href:
"pay.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
540 invoiceid = $(
"#invoiceid").val();
541 console.log(
"Open popup to split on invoiceid="+invoiceid);
542 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
546 console.log(
"Open box to select floor place="+place);
547 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
550 function FreeZone() {
551 console.log(
"Open box to enter a free product");
552 $.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
"); ?>"});
555 function TakeposOrderNotes() {
556 console.log(
"Open box to order notes");
557 ModalBox(
'ModalNote');
558 $(
"#textinput").focus();
562 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
563 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
570 invoiceid = $(
"#invoiceid").val();
572 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
574 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
577 if (parseInt(data[
'paye']) === 1) {
580 r = confirm(
'<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
585 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
600 function Search2(keyCodeForEnter, moreorless) {
601 var eventKeyCode = window.event.keyCode;
603 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
605 var search_term = $(
'#search').val();
606 var search_start = 0;
607 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
608 if (moreorless !=
null) {
609 search_term = $(
'#search_pagination').val();
610 search_start = $(
'#search_start_'+moreorless).val();
613 console.log(
"search_term="+search_term);
615 if (search_term ==
'') {
616 $(
"[id^=prowatermark]").html(
"");
617 $(
"[id^=prodesc]").text(
"");
618 $(
"[id^=probutton]").text(
"");
619 $(
"[id^=probutton]").hide();
620 $(
"[id^=proprice]").attr(
"class",
"hidden");
621 $(
"[id^=proprice]").html(
"");
622 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
623 $(
"[id^=prodiv]").data(
"rowid",
"");
628 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
632 if (search ===
true) {
636 clearTimeout(search2_timer);
640 search2_timer = setTimeout(
function(){
642 jQuery(
".wrapper2 .catwatermark").hide();
643 var nbsearchresults = 0;
644 $.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) {
645 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
646 if (typeof (data[i]) ==
"undefined") {
647 $(
"#prowatermark" + i).html(
"");
648 $(
"#prodesc" + i).text(
"");
649 $(
"#probutton" + i).text(
"");
650 $(
"#probutton" + i).hide();
651 $(
"#proprice" + i).attr(
"class",
"hidden");
652 $(
"#proprice" + i).html(
"");
653 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
654 $(
"#prodiv" + i).data(
"rowid",
"");
658 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
659 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
661 var titlestring = <?php echo $titlestring; ?>;
664 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
666 $(
"#prodesc" + i).html(data[i][
'label']);
668 $(
"#prodivdesc" + i).show();
669 $(
"#probutton" + i).html(data[i][
'label']);
670 $(
"#probutton" + i).show();
671 if (data[i][
'price_formated']) {
672 $(
"#proprice" + i).attr(
"class",
"productprice");
673 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
675 $(
"#proimg" + i).attr(
"title", titlestring);
676 if( undefined !== data[i][
'img']) {
677 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
680 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
682 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
683 $(
"#prodiv" + i).data(
"iscat", 0);
688 $parameters[
'caller'] =
'search2';
689 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
690 print $hookmanager->resPrint;
695 }).always(
function (data) {
697 if ($(
'#search').val().length > 0 && data.length == 1) {
698 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
699 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
700 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
701 ChangeThirdparty(data[0][
'rowid']);
703 else if ($(
'#search').val() == data[0][
'barcode'] &&
'product' == data[0][
'object']) {
704 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']);
705 ClickProduct(0, data[0][
'qty']);
708 if (eventKeyCode == keyCodeForEnter){
709 if (data.length == 0) {
710 $(
'#search').val(
'<?php
711 $langs->load('errors
');
712 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
713 ?> ('+search_term+
')');
714 $(
'#search').select();
719 $(
"#search_pagination").val($(
"#search").val());
720 if (search_start == 0) {
721 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
724 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
725 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
726 $(
"#search_start_less").val(search_start_less);
728 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
729 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
732 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
733 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
734 $(
"#search_start_more").val(search_start_more);
743 function Edit(number) {
744 console.log(
"We click on PAD on key="+number);
746 if (typeof(selectedtext) ==
"undefined") {
750 var text=selectedtext+
"<br> ";
756 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
757 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
758 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
760 }
else if (number==
'qty') {
761 if (editaction==
'qty' && editnumber !=
'') {
762 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
765 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
768 setFocusOnSearchField();
774 }
else if (number==
'p') {
775 if (editaction==
'p' && editnumber!=
"") {
776 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
779 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
788 }
else if (number==
'r') {
789 if (editaction==
'r' && editnumber!=
"") {
790 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
793 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
804 editnumber=editnumber+number;
806 if (editaction==
'qty'){
807 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
808 $(
"#qty").html(
"OK").addClass(
"clicked");
809 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
810 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
812 if (editaction==
'p'){
813 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
814 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
815 $(
"#price").html(
"OK").addClass(
"clicked");
816 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
818 if (editaction==
'r'){
819 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("ReductionShort
").":
"; ?>";
820 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
821 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
822 $(
"#reduction").html(
"OK").addClass(
"clicked");
824 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
828 function TakeposPrintingOrder(){
829 console.log(
"TakeposPrintingOrder");
830 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
835 function TakeposPrintingTemp(){
836 console.log(
"TakeposPrintingTemp");
837 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
842 function OpenDrawer(){
843 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
846 data: { token:
'notrequired' },
848 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
849 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
851 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
858 function DolibarrOpenDrawer() {
859 console.log(
"DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal
"]); ?>");
862 data: { token:
'<?php echo currentToken(); ?>' },
863 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode($_SESSION["takeposterminal
"]); ?>",
867 function MoreActions(totalactions){
870 for (i = 0; i <= totalactions; i++){
871 if (i<12) $(
"#action"+i).hide();
872 else $(
"#action"+i).show();
875 else if (pageactions==1){
877 for (i = 0; i <= totalactions; i++){
878 if (i<12) $(
"#action"+i).show();
879 else $(
"#action"+i).hide();
886 function ControlCashOpening()
888 $.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
"); ?>"});
891 function CloseCashFence(
rowid)
893 $.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
"); ?>"});
896 function CashReport(
rowid)
898 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+
rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
902 function ModalBox(ModalID)
904 var modal = document.getElementById(ModalID);
905 modal.style.display =
"block";
908 function DirectPayment(){
909 console.log(
"DirectPayment");
910 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
914 function FullScreen() {
915 document.documentElement.requestFullscreen();
918 function WeighingScale(){
919 console.log(
"Weighing Scale");
922 data: { token:
'notrequired' },
923 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
925 .done(
function( editnumber ) {
926 $(
"#poslines").load(
"invoice.php?&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
932 $( document ).ready(
function() {
938 if ($_SESSION[
"takeposterminal"] ==
"") {
939 print
"ModalBox('ModalTerminal');";
943 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
944 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
945 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
947 $resql = $db->query(
$sql);
949 $obj = $db->fetch_object($resql);
951 if (!isset($obj->rowid) || is_null($obj->rowid)) {
952 print
"ControlCashOpening();";
959 var elem1 = $(
"#topnav-left")[0];
960 var elem2 = $(
"#topnav-right")[0];
961 var checkOverflow =
function() {
962 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
963 else $(
"#topnav").removeClass(
"overflow");
966 var scrollBars =
function(){
967 var container= $(
'#topnav')[0];
969 vertical:container.scrollHeight > container.clientHeight,
970 horizontal:container.scrollWidth > container.clientWidth
974 $(window).resize(
function(){
978 let resizeObserver =
new ResizeObserver(() => {
981 resizeObserver.observe(elem1);
982 resizeObserver.observe(elem2);
989 $(
".indicator").mousedown(
function(){
990 direction = $(
this).hasClass(
"left") ? -1 : 1;
992 pressTimer.push(setInterval(scrollTo, 100));
995 $(
".indicator").mouseup(
function(){
996 pressTimer.forEach(clearInterval);
999 $(
"body").mouseup(
function(){
1000 pressTimer.forEach(clearInterval);
1001 console.log(
"body");
1004 function scrollTo(){
1005 console.log(
"here");
1006 var pos = $(
"#topnav").scrollLeft();
1007 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1010 $(
"#topnav").scroll(
function(){
1011 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1020 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1022 <div
class=
"container">
1025 if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1027 <div
class=
"header">
1028 <div
id=
"topnav" class=
"topnav">
1029 <div
id=
"topnav-left" class=
"topnav-left">
1030 <div
class=
"inline-block valignmiddle">
1031 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1032 <span
class=
"fa fa-cash-register"></span>
1033 <span
class=
"hideonsmartphone">
1034 <?php echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"])); ?>
1037 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>';
1042 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1043 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1048 <!-- section
for customer -->
1049 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1050 <!-- section
for shopping carts -->
1051 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1052 <!-- More info about customer -->
1053 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1057 <!-- More info about warehouse -->
1058 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1063 <div
id=
"topnav-right" class=
"topnav-right">
1065 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1066 if ($reshook == 0) {
1067 <div
class=
"login_block_other">
1068 <input
type=
"text" id=
"search" name=
"search" class=
"input-nobottom" onkeyup=
"Search2('<?php echo dol_escape_js($keyCodeForEnter); ?>', null);" placeholder=
"<?php echo dol_escape_htmltag($langs->trans("Search
")); ?>" autofocus>
1069 <a onclick=
"ClearSearch();"><span
class=
"fa fa-backspace"></span></a>
1070 <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 -->
1071 <span
class=
"fas fa-home"></span></a>
1072 <?php
if (empty($conf->dol_use_jmobile)) {?>
1073 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1078 <div
class=
"login_block_user">
1084 <div
class=
"arrows">
1085 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1086 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1094 <!-- Modal terminal box -->
1095 <div
id=
"ModalTerminal" class=
"modal">
1096 <div
class=
"modal-content">
1097 <div
class=
"modal-header">
1099 if (empty($conf->global->TAKEPOS_FORCE_TERMINAL_SELECT)) {
1101 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1103 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1105 <div
class=
"modal-body">
1106 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1109 for ($i = 2; $i <= $nbloop; $i++) {
1110 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1117 <!-- Modal multicurrency box -->
1118 <?php if (isModEnabled('multicurrency')) { ?>
1119 <div id="ModalCurrency
" class="modal
">
1120 <div class="modal-content
">
1121 <div class="modal-header
">
1122 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1123 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1125 <div class="modal-body
">
1127 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1128 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1129 $resql = $db->query($sql);
1131 while ($obj = $db->fetch_object($resql)) {
1132 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1141 <!-- Modal terminal Credit Note -->
1142 <div id="ModalCreditNote
" class="modal
">
1143 <div class="modal-content
">
1144 <div class="modal-header
">
1145 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1146 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1148 <div class="modal-body
">
1149 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1150 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1156 <div id="ModalNote
" class="modal
">
1157 <div class="modal-content
">
1158 <div class="modal-header
">
1159 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1160 <h3><?php print $langs->trans("Note
"); ?></h3>
1162 <div class="modal-body
">
1163 <input type="text
" class="block
" id="textinput
">
1164 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1169 <div class="row1<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1173 <div id="poslines
" class="div1
">
1177 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1178 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1179 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1180 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1181 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1182 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1183 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1184 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1185 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1186 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1187 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1188 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("ReductionShort
"); ?></button>
1189 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1190 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1191 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1192 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1197 // TakePOS setup check
1198 if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1199 $sql = "SELECT
code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1200 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1201 $sql .= " AND active = 1
";
1202 $sql .= " ORDER BY libelle
";
1204 $resql = $db->query($sql);
1205 $paiementsModes = array();
1207 while ( $obj = $db->fetch_object($resql) ) {
1208 $paycode = $obj->code;
1209 if ($paycode == 'LIQ') {
1212 if ($paycode == 'CHQ') {
1213 $paycode = 'CHEQUE';
1216 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1217 //var_dump($constantforkey.' '.$conf->global->$constantforkey);
1218 if ( !empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) {
1219 array_push($paiementsModes, $obj);
1224 if (empty($paiementsModes) && isModEnabled("banque
")) {
1225 $langs->load('errors');
1226 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1227 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1231 if (count($maincategories) == 0) {
1232 if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
1233 $tmpcategory = new Categorie($db);
1234 $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
1235 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1237 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1240 // User menu and external TakePOS modules
1244 if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) {
1245 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action'=>'New();');
1247 // BAR RESTAURANT specific menu
1248 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action'=>'Floors();');
1251 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1252 $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action'=>'Customer();');
1254 if ( ! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1255 $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action'=>'History();');
1257 $menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action'=>'FreeZone();');
1258 $menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Reduction
").'</div>', 'action'=>'Reduction();');
1259 $menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action'=>'CloseBill();');
1261 if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1262 $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();');
1265 $menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action'=>'Split();');
1267 // BAR RESTAURANT specific menu
1268 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1269 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1270 $menus[$r++] = array('title'=>'<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action'=>'TakeposPrintingOrder();');
1272 //Button to print receipt before payment
1273 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1274 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1275 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1276 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposConnector(placeid);');
1278 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposPrinting(placeid);');
1280 } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1281 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
1283 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'Print(placeid);');
1286 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1287 $menus[$r++] = array('title'=>'<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action'=>'TakeposOrderNotes();');
1289 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1290 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action'=>'LoadProducts(\'supplements\');');
1294 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1295 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action'=>'OpenDrawer();');
1297 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1298 $menus[$r++] = array(
1299 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1300 'action' => 'DolibarrOpenDrawer();',
1304 $sql = "SELECT
rowid, status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1305 $sql .= " entity =
".((int) $conf->entity)." AND
";
1306 $sql .= " posnumber =
".((int) $_SESSION["takeposterminal
"])." AND
";
1307 $sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1309 $resql = $db->query($sql);
1311 $num = $db->num_rows($resql);
1313 $obj = $db->fetch_object($resql);
1314 $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
1315 if ($obj->status == 0) {
1316 $menus[$r++] = array('title'=>'<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');');
1321 $parameters = array('menus'=>$menus);
1322 $reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1323 if ($reshook == 0) { //add buttons
1324 if (is_array($hookmanager->resArray) ) {
1325 foreach ($hookmanager->resArray as $resArray) {
1326 foreach ($resArray as $butmenu) {
1327 $menus[$r++] = $butmenu;
1330 } elseif ($reshook == 1) {
1331 $r = 0; //replace buttons
1332 if (is_array($hookmanager->resArray) ) {
1333 foreach ($hookmanager->resArray as $resArray) {
1334 foreach ($resArray as $butmenu) {
1335 $menus[$r++] = $butmenu;
1343 $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
1346 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1347 $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().'\';');
1350 if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
1351 $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action'=>'WeighingScale();');
1355 <!-- Show buttons -->
1359 foreach ($menus as $menu) {
1361 if (count($menus) > 12 and $i == 12) {
1362 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1363 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1364 } elseif ($i > 12) {
1365 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1367 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1371 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1372 print '<!-- Show the search input text -->'."\n
";
1373 print '<div class="margintoponly
">';
1374 print '<input type="text
" id="search
" class="input-nobottom
" name="search
" onkeyup="Search2(\
''.
dol_escape_js($keyCodeForEnter).
'\',
null);
" style="width: 80%; width:calc(100% - 51px); font-size: 150%;
" placeholder="'.dol_escape_htmltag($langs->trans("Search")).'" autofocus> ';
1375 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch();
">'.img_picto('', 'searchclear').'</a>';
1382 <div class="row2<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1386 <!-- Show categories -->
1388 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1389 print '<div class="div4
" style= "display: none;
">';
1391 print '<div class="div4
">';
1395 while ($count < $MAXCATEG) {
1397 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1398 echo 'onclick="MoreCategories(\
'less\')"';
1399 } elseif ($count == ($MAXCATEG - 1)) {
1400 echo
'onclick="MoreCategories(\'more\')"';
1402 echo
'onclick="LoadProducts('.$count.
')"';
1403 } ?>
id=
"catdiv<?php echo $count; ?>">
1405 if ($count == ($MAXCATEG - 2)) {
1407 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1408 } elseif ($count == ($MAXCATEG - 1)) {
1410 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1413 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1417 <?php
if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?>
1418 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1419 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1422 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1430 <!-- Show product -->
1431 <div
class=
"div5"<?php
if (
getDolGlobalInt(
'TAKEPOS_HIDE_CATEGORIES') == 1) {
1432 print
' style="width:100%;"';
1436 while ($count < $MAXPRODUCT) {
1437 print
'<div class="wrapper2 arrow" id="prodiv'.$count.
'" ';
1439 <?php
if ($count == ($MAXPRODUCT - 2)) {
1440 ?> onclick=
"MoreProducts('less')" <?php
1441 }
if ($count == ($MAXPRODUCT - 1)) {
1442 ?> onclick=
"MoreProducts('more')" <?php
1444 echo
'onclick="ClickProduct('.$count.
')"';
1447 if ($count == ($MAXPRODUCT - 2)) {
1449 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1450 } elseif ($count == ($MAXPRODUCT - 1)) {
1452 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1455 echo
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1457 print
'<div class="" id="proprice'.$count.
'"></div>';
1458 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1462 <?php
if ($count != ($MAXPRODUCT - 2) && $count != ($MAXPRODUCT - 1) && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1463 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1464 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1467 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1473 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1474 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1475 <input
type=
"hidden" id=
"search_pagination" value=
"">
Class to manage categories.
if(isModEnabled('facture') && $user->hasRight('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') && $user->hasRight('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)) $sql
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.
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,...