31if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
42require
'../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
53$action =
GETPOST(
'action',
'aZ09');
54$setterminal =
GETPOST(
'setterminal',
'int');
55$setcurrency =
GETPOST(
'setcurrency',
'aZ09');
57$hookmanager->initHooks(array(
'takeposfrontend'));
58if (empty($_SESSION[
"takeposterminal"])) {
60 $_SESSION[
"takeposterminal"] = 1;
61 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
62 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
66if ($setterminal > 0) {
67 $_SESSION[
"takeposterminal"] = $setterminal;
68 setcookie(
"takeposterminal", $setterminal, (time() + (86400 * 354)),
'/',
null, (empty($dolibarr_main_force_https) ?
false : true), true);
71if ($setcurrency !=
"") {
72 $_SESSION[
"takeposcustomercurrency"] = $setcurrency;
77$langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter",
"banks"));
81$maxcategbydefaultforthisdevice = 12;
82$maxproductbydefaultforthisdevice = 24;
83if ($conf->browser->layout ==
'phone') {
84 $maxcategbydefaultforthisdevice = 8;
85 $maxproductbydefaultforthisdevice = 16;
88 $_SESSION[
"basiclayout"] = 1;
89 header(
"Location: phone.php?mobilepage=invoice");
93 unset($_SESSION[
"basiclayout"]);
95$MAXCATEG = (!
getDolGlobalString(
'TAKEPOS_NB_MAXCATEG') ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
96$MAXPRODUCT = (!
getDolGlobalString(
'TAKEPOS_NB_MAXPRODUCT') ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
98$term = empty($_SESSION[
'takeposterminal']) ? 1 : $_SESSION[
'takeposterminal'];
117$form =
new Form($db);
121$arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
122$arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
125 $arrayofcss[] =
'/takepos/css/colorful.css';
130$title =
'TakePOS - Dolibarr '.DOL_VERSION;
134$head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
135<meta name="apple-mobile-web-app-capable" content="yes">
136<meta name="mobile-web-app-capable" content="yes">
137<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
138top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
141$categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
146$levelofrootcategory = 0;
148 foreach ($categories as $key => $categorycursor) {
149 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
150 $levelofrootcategory = $categorycursor[
'level'];
156$levelofmaincategories = $levelofrootcategory + 1;
158$maincategories = array();
159$subcategories = array();
160foreach ($categories as $key => $categorycursor) {
161 if ($categorycursor[
'level'] == $levelofmaincategories) {
162 $maincategories[$key] = $categorycursor;
164 $subcategories[$key] = $categorycursor;
172<body
class=
"bodytakepos" style=
"overflow: hidden;">
175var categories = <?php echo json_encode($maincategories); ?>;
176var subcategories = <?php echo json_encode($subcategories); ?>;
182var place=
"<?php echo $place; ?>";
186var search2_timer=
null;
205function ClearSearch() {
206 console.log(
"ClearSearch");
207 $(
"#search").val(
'');
208 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
209 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
210 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
211 <?php
if ($conf->browser->layout ==
'classic') { ?>
212 setFocusOnSearchField();
217function setFocusOnSearchField() {
218 console.log(
"Call setFocusOnSearchField in page index.php");
219 <?php
if ($conf->browser->layout ==
'classic') { ?>
220 console.log(
"has keyboard from localStorage, so we can force focus on search field");
221 $(
"#search").focus();
225function PrintCategories(first) {
226 console.log(
"PrintCategories");
227 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
228 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
230 $(
"#catdivdesc"+i).hide();
231 $(
"#catdesc"+i).text(
"");
232 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
233 $(
"#catwatermark"+i).hide();
234 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
237 $(
"#catdivdesc"+i).show();
240 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
242 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
244 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
245 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
246 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
247 $(
"#catdiv"+i).attr(
'class',
'wrapper');
248 $(
"#catwatermark"+i).show();
252function MoreCategories(moreorless) {
253 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
254 if (moreorless ==
"more") {
255 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
256 $(
'#catimg15').animate({opacity:
'1'}, 100);
257 pagecategories=pagecategories+1;
259 if (moreorless ==
"less") {
260 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
261 $(
'#catimg14').animate({opacity:
'1'}, 100);
262 if (pagecategories==0)
return;
263 pagecategories=pagecategories-1;
265 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
266 pagecategories=pagecategories-1;
270 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
271 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
273 console.log(
"complete with empty record");
274 $(
"#catdivdesc"+i).hide();
275 $(
"#catdesc"+i).text(
"");
276 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
277 $(
"#catwatermark"+i).hide();
280 $(
"#catdivdesc"+i).show();
283 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
285 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
287 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
288 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
289 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
290 $(
"#catwatermark"+i).show();
297function LoadProducts(
position, issubcat) {
298 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
299 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
302 currentcat=
"supplements";
304 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
305 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
306 if (issubcat ==
true) {
307 currentcat=$(
'#prodiv'+
position).data(
'rowid');
310 currentcat=$(
'#catdiv'+
position).data(
'rowid');
311 console.log(
"currentcat="+currentcat);
314 if (currentcat == undefined) {
320 jQuery.each(subcategories,
function(i, val) {
321 if (currentcat==val.fk_parent) {
322 $(
"#prodivdesc"+ishow).show();
323 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
324 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
325 $(
"#probutton"+ishow).html(val.label);
327 $(
"#prodesc"+ishow).text(val.label);
328 $(
"#probutton"+ishow).text(val.label);
330 $(
"#probutton"+ishow).show();
331 $(
"#proprice"+ishow).attr(
"class",
"hidden");
332 $(
"#proprice"+ishow).html(
"");
333 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
334 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
335 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
336 $(
"#prodiv"+ishow).data(
"iscat",1);
337 $(
"#prodiv"+ishow).attr(
"data-iscat",1);
338 $(
"#prowatermark"+ishow).show();
345 if (maxproduct >= 1) {
346 limit = maxproduct-1;
350 let socid = jQuery(
'#thirdpartyid').val();
351 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
352 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
356 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + socid +
'&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset=0',
function(data) {
357 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
360 while (ishow < maxproduct) {
361 console.log(
"ishow"+ishow+
" idata="+idata);
364 if (typeof (data[idata]) ==
"undefined") {
366 echo
'$("#prodivdesc"+ishow).hide();';
367 echo
'$("#prodesc"+ishow).text("");';
368 echo
'$("#proimg"+ishow).attr("title","");';
369 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
371 echo
'$("#probutton"+ishow).hide();';
372 echo
'$("#probutton"+ishow).text("");';
374 $(
"#proprice"+ishow).attr(
"class",
"hidden");
375 $(
"#proprice"+ishow).html(
"");
377 $(
"#prodiv"+ishow).data(
"rowid",
"");
378 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
380 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
383 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
384 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
386 var titlestring = <?php echo $titlestring; ?>;
388 echo
'$("#prodivdesc"+ishow).show();';
390 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
392 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
394 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
396 echo
'$("#proimg"+ishow).attr("title", titlestring);';
397 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
399 echo
'$("#probutton"+ishow).show();';
400 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
403 if (data[parseInt(idata)][
'price_formated']) {
404 $(
"#proprice" + ishow).attr(
"class",
"productprice");
408 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
412 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
417 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
419 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
420 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
421 console.log($(
'#prodiv4').data(
'rowid'));
423 $(
"#prodiv"+ishow).data(
"iscat", 0);
424 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
426 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
431 $parameters[
'caller'] =
'loadProducts';
432 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
433 print $hookmanager->resPrint;
436 $(
"#prowatermark"+ishow).hide();
445function MoreProducts(moreorless) {
446 console.log(
"MoreProducts");
448 if ($(
'#search_pagination').val() !=
'') {
449 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
452 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
454 if (moreorless==
"more"){
455 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
456 $(
'#proimg31').animate({opacity:
'1'}, 100);
457 pageproducts=pageproducts+1;
459 if (moreorless==
"less"){
460 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
461 $(
'#proimg30').animate({opacity:
'1'}, 100);
462 if (pageproducts==0)
return;
463 pageproducts=pageproducts-1;
469 if (maxproduct >= 1) {
470 limit = maxproduct-1;
472 var offset = <?php echo ($MAXPRODUCT - 2); ?> * pageproducts;
475 let socid = jQuery(
'#thirdpartyid').val();
476 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
477 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
481 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + socid +
'&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset='+offset,
function(data) {
482 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
484 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
485 pageproducts=pageproducts-1;
489 while (ishow < maxproduct) {
490 if (typeof (data[idata]) ==
"undefined") {
491 $(
"#prodivdesc"+ishow).hide();
492 $(
"#prodesc"+ishow).text(
"");
493 $(
"#probutton"+ishow).text(
"");
494 $(
"#probutton"+ishow).hide();
495 $(
"#proprice"+ishow).attr(
"class",
"");
496 $(
"#proprice"+ishow).html(
"");
497 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
498 $(
"#prodiv"+ishow).data(
"rowid",
"");
499 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
501 $(
"#prodivdesc"+ishow).show();
503 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
504 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
505 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
507 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
509 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
510 $(
"#probutton"+ishow).show();
511 if (data[parseInt(idata)][
'price_formated']) {
512 $(
"#proprice" + ishow).attr(
"class",
"productprice");
516 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
520 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
525 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
526 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
527 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
528 $(
"#prodiv"+ishow).data(
"iscat",0);
530 $(
"#prowatermark"+ishow).hide();
539function ClickProduct(
position, qty = 1) {
540 console.log(
"ClickProduct at position"+
position);
541 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
542 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
543 if ($(
'#prodiv'+
position).data(
'iscat')==1){
544 console.log(
"Click on a category at position "+
position);
548 console.log($(
'#prodiv4').data(
'rowid'));
549 invoiceid = $(
"#invoiceid").val();
550 idproduct=$(
'#prodiv'+
position).data(
'rowid');
551 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoicdeid="+invoiceid);
552 if (idproduct==
"")
return;
554 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
556 echo
"CustomerDisplay();";
564function ChangeThirdparty(idcustomer) {
565 console.log(
"ChangeThirdparty");
567 $(
"#poslines").load(
"<?php echo DOL_URL_ROOT ?>/societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+
"&place="+place+
"",
function() {
573function deleteline() {
574 invoiceid = $(
"#invoiceid").val();
575 console.log(
"Delete line invoiceid="+invoiceid);
576 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
583 console.log(
"Open box to select the thirdparty place="+place);
584 $.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
"); ?>"});
588 console.log(
"Open box to select the contact place="+place);
589 $.colorbox({href:
"../contact/list.php?type=c&contextpage=poslist&nomassaction=1&place="+place, width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Contact"); ?>"});
594 console.log(
"Open box to select the history");
595 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
598function Reduction() {
599 invoiceid = $(
"#invoiceid").val();
600 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
601 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
604function CloseBill() {
605 invoiceid = $(
"#invoiceid").val();
606 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
607 $.colorbox({href:
"pay.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
611 invoiceid = $(
"#invoiceid").val();
612 console.log(
"Open popup to split on invoiceid="+invoiceid);
613 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
617 console.log(
"Open box to select floor place="+place);
618 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
622 invoiceid = $(
"#invoiceid").val();
623 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
624 $.colorbox({href:
"freezone.php?action=freezone&token=<?php echo newToken(); ?>&place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"40%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("FreeZone
"); ?>"});
627function TakeposOrderNotes() {
628 console.log(
"Open box to order notes");
629 ModalBox(
'ModalNote');
630 $(
"#textinput").focus();
634 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
635 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
642 invoiceid = $(
"#invoiceid").val();
644 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
646 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
649 if (parseInt(data[
'paye']) === 1) {
652 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
657 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
672function Search2(keyCodeForEnter, moreorless) {
673 var eventKeyCode = window.event.keyCode;
675 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
677 var search_term = $(
'#search').val();
678 var search_start = 0;
679 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
680 if (moreorless !=
null) {
681 search_term = $(
'#search_pagination').val();
682 search_start = $(
'#search_start_'+moreorless).val();
685 console.log(
"search_term="+search_term);
687 if (search_term ==
'') {
688 $(
"[id^=prowatermark]").html(
"");
689 $(
"[id^=prodesc]").text(
"");
690 $(
"[id^=probutton]").text(
"");
691 $(
"[id^=probutton]").hide();
692 $(
"[id^=proprice]").attr(
"class",
"hidden");
693 $(
"[id^=proprice]").html(
"");
694 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
695 $(
"[id^=prodiv]").data(
"rowid",
"");
696 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
701 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
705 if (search ===
true) {
709 clearTimeout(search2_timer);
713 search2_timer = setTimeout(
function(){
715 jQuery(
".wrapper2 .catwatermark").hide();
716 var nbsearchresults = 0;
719 let socid = jQuery(
'#thirdpartyid').val();
720 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
721 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
724 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term +
'&thirdpartyid=' + socid +
'&search_start=' + search_start +
'&search_limit=' + search_limit,
function (data) {
725 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
726 if (typeof (data[i]) ==
"undefined") {
727 $(
"#prowatermark" + i).html(
"");
728 $(
"#prodesc" + i).text(
"");
729 $(
"#probutton" + i).text(
"");
730 $(
"#probutton" + i).hide();
731 $(
"#proprice" + i).attr(
"class",
"hidden");
732 $(
"#proprice" + i).html(
"");
733 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
734 $(
"#prodiv" + i).data(
"rowid",
"");
735 $(
"#prodiv" + i).attr(
"data-rowid",
"");
739 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
740 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
742 var titlestring = <?php echo $titlestring; ?>;
744 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
745 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
746 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
748 $(
"#prodesc" + i).html(data[i][
'label']);
750 $(
"#prodivdesc" + i).show();
751 $(
"#probutton" + i).html(data[i][
'label']);
752 $(
"#probutton" + i).show();
753 if (data[i][
'price_formated']) {
754 $(
"#proprice" + i).attr(
"class",
"productprice");
758 $(
"#proprice" + i).html(data[i][
'price_formated']);
762 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
767 $(
"#proimg" + i).attr(
"title", titlestring);
768 if( undefined !== data[i][
'img']) {
769 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
772 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
774 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
775 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
776 $(
"#prodiv" + i).data(
"iscat", 0);
777 $(
"#prodiv" + i).attr(
"data-iscat", 0);
782 $parameters[
'caller'] =
'search2';
783 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
784 print $hookmanager->resPrint;
789 }).always(
function (data) {
791 if ($(
'#search').val().length > 0 && data.length == 1) {
792 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
793 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
794 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
795 ChangeThirdparty(data[0][
'rowid']);
797 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
798 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']);
799 ClickProduct(0, data[0][
'qty']);
802 if (eventKeyCode == keyCodeForEnter){
803 if (data.length == 0) {
804 $(
'#search').val(
'<?php
805 $langs->load('errors
');
806 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
807 ?> ('+search_term+
')');
808 $(
'#search').select();
813 $(
"#search_pagination").val($(
"#search").val());
814 if (search_start == 0) {
815 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
818 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
819 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
820 $(
"#search_start_less").val(search_start_less);
822 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
823 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
826 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
827 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
828 $(
"#search_start_more").val(search_start_more);
837function Edit(number) {
838 console.log(
"We click on PAD on key="+number);
840 if (typeof(selectedtext) ==
"undefined") {
844 var text=selectedtext+
"<br> ";
850 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
851 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
852 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
854 }
else if (number==
'qty') {
855 if (editaction==
'qty' && editnumber !=
'') {
856 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
859 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
862 setFocusOnSearchField();
868 }
else if (number==
'p') {
869 if (editaction==
'p' && editnumber!=
"") {
870 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
873 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
882 }
else if (number==
'r') {
883 if (editaction==
'r' && editnumber!=
"") {
884 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
887 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
898 editnumber=editnumber+number;
900 if (editaction==
'qty'){
901 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
902 $(
"#qty").html(
"OK").addClass(
"clicked");
903 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
904 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
906 if (editaction==
'p'){
907 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
908 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
909 $(
"#price").html(
"OK").addClass(
"clicked");
910 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
912 if (editaction==
'r'){
913 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
914 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
915 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
916 $(
"#reduction").html(
"OK").addClass(
"clicked");
918 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
922function TakeposPrintingOrder(){
923 console.log(
"TakeposPrintingOrder");
924 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
929function TakeposPrintingTemp(){
930 console.log(
"TakeposPrintingTemp");
931 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
936function OpenDrawer(){
937 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
940 data: { token:
'notrequired' },
942 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
943 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
945 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
952function DolibarrOpenDrawer() {
953 console.log(
"DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal
"]); ?>");
956 data: { token:
'<?php echo currentToken(); ?>' },
957 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode($_SESSION["takeposterminal
"]); ?>",
961function MoreActions(totalactions){
964 for (i = 0; i <= totalactions; i++){
965 if (i<12) $(
"#action"+i).hide();
966 else $(
"#action"+i).show();
969 else if (pageactions==1){
971 for (i = 0; i <= totalactions; i++){
972 if (i<12) $(
"#action"+i).show();
973 else $(
"#action"+i).hide();
980function ControlCashOpening()
982 $.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
"); ?>"});
985function CloseCashFence(
rowid)
987 $.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
"); ?>"});
990function CashReport(
rowid)
992 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+
rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
996function ModalBox(ModalID)
998 var modal = document.getElementById(ModalID);
999 modal.style.display =
"block";
1002function DirectPayment(){
1003 console.log(
"DirectPayment");
1004 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1008function FullScreen() {
1009 document.documentElement.requestFullscreen();
1012function WeighingScale(){
1013 console.log(
"Weighing Scale");
1016 data: { token:
'notrequired' },
1017 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1019 .done(
function( editnumber ) {
1020 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1026$( document ).ready(
function() {
1032 if ($_SESSION[
"takeposterminal"] ==
"") {
1033 print
"ModalBox('ModalTerminal');";
1037 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1038 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
1039 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1041 $resql = $db->query($sql);
1043 $obj = $db->fetch_object($resql);
1045 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1046 print
"ControlCashOpening();";
1053 var elem1 = $(
"#topnav-left")[0];
1054 var elem2 = $(
"#topnav-right")[0];
1055 var checkOverflow =
function() {
1056 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1057 else $(
"#topnav").removeClass(
"overflow");
1060 var scrollBars =
function(){
1061 var container= $(
'#topnav')[0];
1063 vertical:container.scrollHeight > container.clientHeight,
1064 horizontal:container.scrollWidth > container.clientWidth
1068 $(window).resize(
function(){
1072 let resizeObserver =
new ResizeObserver(() => {
1075 resizeObserver.observe(elem1);
1076 resizeObserver.observe(elem2);
1079 var pressTimer = [];
1083 $(
".indicator").mousedown(
function(){
1084 direction = $(
this).hasClass(
"left") ? -1 : 1;
1086 pressTimer.push(setInterval(scrollTo, 100));
1089 $(
".indicator").mouseup(
function(){
1090 pressTimer.forEach(clearInterval);
1093 $(
"body").mouseup(
function(){
1094 pressTimer.forEach(clearInterval);
1095 console.log(
"body");
1098 function scrollTo(){
1099 console.log(
"here");
1100 var pos = $(
"#topnav").scrollLeft();
1101 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1104 $(
"#topnav").scroll(
function(){
1105 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1114$keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1116<div
class=
"container">
1121 <div
class=
"header">
1122 <div
id=
"topnav" class=
"topnav">
1123 <div
id=
"topnav-left" class=
"topnav-left">
1124 <div
class=
"inline-block valignmiddle">
1125 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1126 <span
class=
"fa fa-cash-register"></span>
1127 <span
class=
"hideonsmartphone">
1128 <?php echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"])); ?>
1131 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1134 if (isModEnabled(
'multicurrency')) {
1135 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1136 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1140 <!-- section
for customer -->
1141 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1142 <!-- section
for shopping carts -->
1143 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1144 <!-- More info about customer -->
1145 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1147 if (isModEnabled(
'stock')) {
1149 <!-- More info about warehouse -->
1150 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1154 <div
id=
"topnav-right" class=
"topnav-right">
1156 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1157 if ($reshook == 0) {
1159 <div
class=
"login_block_other">
1160 <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>
1161 <a onclick=
"ClearSearch();" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1162 <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 -->
1163 <span
class=
"fas fa-home"></span></a>
1164 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1165 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1171 <div
class=
"login_block_user">
1173 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.newtoken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1177 <div
class=
"arrows">
1178 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1179 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1187<!-- Modal terminal box -->
1188<div
id=
"ModalTerminal" class=
"modal">
1189 <div
class=
"modal-content">
1190 <div
class=
"modal-header">
1194 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1197 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1199 <div
class=
"modal-body">
1200 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1203 for ($i = 2; $i <= $nbloop; $i++) {
1204 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1211<!-- Modal multicurrency box -->
1212<?php if (isModEnabled('multicurrency')) { ?>
1213<div id="ModalCurrency
" class="modal
">
1214 <div class="modal-content
">
1215 <div class="modal-header
">
1216 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1217 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1219 <div class="modal-body
">
1221 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1222 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1223 $resql = $db->query($sql);
1225 while ($obj = $db->fetch_object($resql)) {
1226 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1235<!-- Modal terminal Credit Note -->
1236<div id="ModalCreditNote
" class="modal
">
1237 <div class="modal-content
">
1238 <div class="modal-header
">
1239 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1240 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1242 <div class="modal-body
">
1243 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1244 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1250<div id="ModalNote
" class="modal
">
1251 <div class="modal-content
">
1252 <div class="modal-header
">
1253 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1254 <h3><?php print $langs->trans("Note
"); ?></h3>
1256 <div class="modal-body
">
1257 <input type="text
" class="block
" id="textinput
">
1258 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1267 <div id="poslines
" class="div1
">
1271 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1272 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1273 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1274 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1275 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1276 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1277 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1278 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1279 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1280 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1281 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1282 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1283 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1284 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1285 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1286 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1291// TakePOS setup check
1292if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1293 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1294 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1295 $sql .= " AND active = 1
";
1296 $sql .= " ORDER BY libelle
";
1298 $resql = $db->query($sql);
1299 $paiementsModes = array();
1301 while ($obj = $db->fetch_object($resql)) {
1302 $paycode = $obj->code;
1303 if ($paycode == 'LIQ') {
1306 if ($paycode == 'CHQ') {
1307 $paycode = 'CHEQUE';
1310 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1311 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1312 if (getDolGlobalInt($constantforkey) > 0) {
1313 array_push($paiementsModes, $obj);
1318 if (empty($paiementsModes) && isModEnabled("banque
")) {
1319 $langs->load('errors');
1320 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1321 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1325if (count($maincategories) == 0) {
1326 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1327 $tmpcategory = new Categorie($db);
1328 $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
1329 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1331 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1334// User menu and external TakePOS modules
1338if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1339 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action'=>'New();');
1341 // BAR RESTAURANT specific menu
1342 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action'=>'Floors();');
1345if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1346 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1347 $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action'=>'Contact();');
1349 $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action'=>'Customer();');
1352if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1353 $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action'=>'History();');
1355$menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action'=>'FreeZone();');
1356$menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action'=>'Reduction();');
1357$menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action'=>'CloseBill();');
1359if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1360 $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();');
1363$menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action'=>'Split();');
1365// BAR RESTAURANT specific menu
1366if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1367 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1368 $menus[$r++] = array('title'=>'<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action'=>'TakeposPrintingOrder();');
1370 //Button to print receipt before payment
1371 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1372 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1373 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1374 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposConnector(placeid);');
1376 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposPrinting(placeid);');
1378 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1379 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
1381 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'Print(placeid);');
1384 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1385 $menus[$r++] = array('title'=>'<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action'=>'TakeposOrderNotes();');
1387 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1388 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action'=>'LoadProducts(\'supplements\');');
1392if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1393 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action'=>'OpenDrawer();');
1395if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1396 $menus[$r++] = array(
1397 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1398 'action' => 'DolibarrOpenDrawer();',
1402$sql = "SELECT
rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1403$sql .= " entity =
".((int) $conf->entity)." AND
";
1404$sql .= " posnumber =
".((int) $_SESSION["takeposterminal
"])." AND
";
1405$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1407$resql = $db->query($sql);
1409 $num = $db->num_rows($resql);
1411 $obj = $db->fetch_object($resql);
1412 $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
1413 if ($obj->status == 0) {
1414 $menus[$r++] = array('title'=>'<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');');
1419$parameters = array('menus'=>$menus);
1420$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1421if ($reshook == 0) { //add buttons
1422 if (is_array($hookmanager->resArray)) {
1423 foreach ($hookmanager->resArray as $resArray) {
1424 foreach ($resArray as $butmenu) {
1425 $menus[$r++] = $butmenu;
1429} elseif ($reshook == 1) {
1430 $r = 0; //replace buttons
1431 if (is_array($hookmanager->resArray) ) {
1432 foreach ($hookmanager->resArray as $resArray) {
1433 foreach ($resArray as $butmenu) {
1434 $menus[$r++] = $butmenu;
1441 $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
1444if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1445 $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().'\';');
1448if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1449 $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action'=>'WeighingScale();');
1453 <!-- Show buttons -->
1457 foreach ($menus as $menu) {
1459 if (count($menus) > 12 and $i == 12) {
1460 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1461 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1462 } elseif ($i > 12) {
1463 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1465 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1469 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1470 print '<!-- Show the search input text -->'."\n
";
1471 print '<div class="margintoponly
">';
1472 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> ';
1473 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch();
">'.img_picto('', 'searchclear').'</a>';
1484 <!-- Show categories -->
1486 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1487 print '<div class="div4
" style= "display: none;
">';
1489 print '<div class="div4
">';
1493 while ($count < $MAXCATEG) {
1495 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1496 echo 'onclick="MoreCategories(\
'less\')"';
1497 } elseif ($count == ($MAXCATEG - 1)) {
1498 echo
'onclick="MoreCategories(\'more\')"';
1500 echo
'onclick="LoadProducts('.$count.
')"';
1501 } ?>
id=
"catdiv<?php echo $count; ?>">
1503 if ($count == ($MAXCATEG - 2)) {
1505 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1506 } elseif ($count == ($MAXCATEG - 1)) {
1508 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1511 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1514 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1515 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1516 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1519 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1527 <!-- Show product -->
1528 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1529 print ' centpercent';
1533 while ($count < $MAXPRODUCT) {
1534 print
'<div class="wrapper2 arrow" id="prodiv'.$count.
'" '; ?>
1535 <?php
if ($count == ($MAXPRODUCT - 2)) {
1536 ?> onclick=
"MoreProducts('less')" <?php
1538 if ($count == ($MAXPRODUCT - 1)) {
1539 ?> onclick=
"MoreProducts('more')" <?php
1541 echo
'onclick="ClickProduct('.$count.
')"';
1544 if ($count == ($MAXPRODUCT - 2)) {
1546 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1547 } elseif ($count == ($MAXPRODUCT - 1)) {
1549 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1552 print
'<div class="" id="proprice'.$count.
'"></div>';
1555 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1557 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1560 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1561 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1562 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1565 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1571 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1572 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1573 <input
type=
"hidden" id=
"search_pagination" value=
"">
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Class to manage categories.
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)
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 a 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.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e rowid
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
top_menu_user($hideloginname=0, $urllogout='')
Build the tooltip on user login.
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui 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.
Search2(keyCodeForEnter, moreorless)
Search products.