33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
39if (!defined(
'NOREQUIREAJAX')) {
40 define(
'NOREQUIREAJAX',
'1');
44require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
62$langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter",
"banks"));
65$action =
GETPOST(
'action',
'aZ09');
67$setcurrency =
GETPOST(
'setcurrency',
'aZ09');
69$hookmanager->initHooks(array(
'takeposfrontend'));
70if (empty($_SESSION[
"takeposterminal"])) {
72 $_SESSION[
"takeposterminal"] = 1;
73 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
74 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
78if ($setterminal > 0) {
79 $_SESSION[
"takeposterminal"] = $setterminal;
80 dolSetCookie(
"takeposterminal", (
string) $setterminal, -1);
83if ($setcurrency !=
"") {
84 $_SESSION[
"takeposcustomercurrency"] = $setcurrency;
91$maxcategbydefaultforthisdevice = 12;
92$maxproductbydefaultforthisdevice = 24;
93if (
$conf->browser->layout ==
'phone') {
94 $maxcategbydefaultforthisdevice = 8;
95 $maxproductbydefaultforthisdevice = 16;
98 $_SESSION[
"basiclayout"] = 1;
99 header(
"Location: phone.php?mobilepage=invoice");
103 unset($_SESSION[
"basiclayout"]);
105$MAXCATEG = (!
getDolGlobalString(
'TAKEPOS_NB_MAXCATEG') ? $maxcategbydefaultforthisdevice :
$conf->global->TAKEPOS_NB_MAXCATEG);
106$MAXPRODUCT = (!
getDolGlobalString(
'TAKEPOS_NB_MAXPRODUCT') ? $maxproductbydefaultforthisdevice :
$conf->global->TAKEPOS_NB_MAXPRODUCT);
108$term = empty($_SESSION[
'takeposterminal']) ? 1 : $_SESSION[
'takeposterminal'];
129$form =
new Form($db);
133$arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
134$arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
137 $arrayofcss[] =
'/takepos/css/colorful.css';
142$title =
'TakePOS - Dolibarr '.DOL_VERSION;
146$head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
147<meta name="apple-mobile-web-app-capable" content="yes">
148<meta name="mobile-web-app-capable" content="yes">
149<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
150top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
153$categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
158$levelofrootcategory = 0;
160 foreach ($categories as $key => $categorycursor) {
162 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
163 $levelofrootcategory = $categorycursor[
'level'];
169$levelofmaincategories = $levelofrootcategory + 1;
171$maincategories = array();
172$subcategories = array();
173foreach ($categories as $key => $categorycursor) {
174 if ($categorycursor[
'level'] == $levelofmaincategories) {
175 $maincategories[$key] = $categorycursor;
177 $subcategories[$key] = $categorycursor;
185<body
class=
"bodytakepos" style=
"overflow: hidden;">
188var categories = <?php echo json_encode($maincategories); ?>;
189var subcategories = <?php echo json_encode($subcategories); ?>;
195var place=
"<?php echo $place; ?>";
199var search2_timer=
null;
218function ClearSearch(clearSearchResults) {
219 console.log(
"ClearSearch");
220 $(
"#search").val(
'');
221 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
222 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
223 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
224 <?php
if (
$conf->browser->layout ==
'classic') { ?>
225 setFocusOnSearchField();
227 if (clearSearchResults) {
228 $(
"#search").trigger(
'keyup');
233function setFocusOnSearchField() {
234 console.log(
"Call setFocusOnSearchField in page index.php");
235 <?php
if (
$conf->browser->layout ==
'classic') { ?>
236 console.log(
"has keyboard from localStorage, so we can force focus on search field");
237 $(
"#search").focus();
241function PrintCategories(first) {
242 console.log(
"PrintCategories");
243 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
244 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
246 $(
"#catdivdesc"+i).hide();
247 $(
"#catdesc"+i).text(
"");
248 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
249 $(
"#catwatermark"+i).hide();
250 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
253 $(
"#catdivdesc"+i).show();
256 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
258 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
260 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
261 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
262 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
263 $(
"#catdiv"+i).attr(
'class',
'wrapper');
264 $(
"#catwatermark"+i).show();
268function MoreCategories(moreorless) {
269 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
270 if (moreorless ==
"more") {
271 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
272 $(
'#catimg15').animate({opacity:
'1'}, 100);
273 pagecategories=pagecategories+1;
275 if (moreorless ==
"less") {
276 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
277 $(
'#catimg14').animate({opacity:
'1'}, 100);
278 if (pagecategories==0)
return;
279 pagecategories=pagecategories-1;
281 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
282 pagecategories=pagecategories-1;
286 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
287 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
289 console.log(
"complete with empty record");
290 $(
"#catdivdesc"+i).hide();
291 $(
"#catdesc"+i).text(
"");
292 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
293 $(
"#catwatermark"+i).hide();
296 $(
"#catdivdesc"+i).show();
299 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
301 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
303 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
304 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
305 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
306 $(
"#catwatermark"+i).show();
313function LoadProducts(
position, issubcat) {
314 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
315 var maxproduct = <?php echo (
int) ($MAXPRODUCT - 2); ?>;
318 currentcat=
"supplements";
320 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
321 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
322 if (issubcat ==
true) {
323 currentcat=$(
'#prodiv'+
position).data(
'rowid');
326 currentcat=$(
'#catdiv'+
position).data(
'rowid');
327 console.log(
"currentcat="+currentcat);
330 if (currentcat == undefined) {
336 jQuery.each(subcategories,
function(i, val) {
337 if (currentcat==val.fk_parent) {
338 $(
"#prodivdesc"+ishow).show();
339 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
340 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
341 $(
"#probutton"+ishow).html(val.label);
343 $(
"#prodesc"+ishow).text(val.label);
344 $(
"#probutton"+ishow).text(val.label);
346 $(
"#probutton"+ishow).show();
347 $(
"#proprice"+ishow).attr(
"class",
"hidden");
348 $(
"#proprice"+ishow).html(
"");
349 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
350 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
351 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
352 $(
"#prodiv"+ishow).data(
"iscat", 1);
353 $(
"#prodiv"+ishow).attr(
"data-iscat", 1);
354 $(
"#prodiv"+ishow).removeClass(
"divempty");
355 $(
"#prowatermark"+ishow).show();
362 if (maxproduct >= 1) {
363 limit = maxproduct - 1;
367 let socid = jQuery(
'#thirdpartyid').val();
368 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
369 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
373 $.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) {
374 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
377 while (ishow < maxproduct) {
378 console.log(
"ishow"+ishow+
" idata="+idata);
379 console.log(data[idata]);
381 if (typeof (data[idata]) ==
"undefined") {
383 echo
'$("#prodivdesc"+ishow).hide();';
384 echo
'$("#prodesc"+ishow).text("");';
385 echo
'$("#proimg"+ishow).attr("title","");';
386 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
388 echo
'$("#probutton"+ishow).hide();';
389 echo
'$("#probutton"+ishow).text("");';
391 $(
"#proprice"+ishow).attr(
"class",
"hidden");
392 $(
"#proprice"+ishow).html(
"");
394 $(
"#prodiv"+ishow).data(
"rowid",
"");
395 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
397 $(
"#prodiv"+ishow).data(
"iscat",
"0");
398 $(
"#prodiv"+ishow).attr(
"data-iscat",
"0");
400 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
403 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
404 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
406 var titlestring = <?php echo $titlestring; ?>;
408 echo
'$("#prodivdesc"+ishow).show();';
410 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
412 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
414 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
416 echo
'$("#proimg"+ishow).attr("title", titlestring);';
417 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
419 echo
'$("#probutton"+ishow).show();';
420 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
423 if (data[parseInt(idata)][
'price_formated']) {
424 $(
"#proprice" + ishow).attr(
"class",
"productprice");
428 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
432 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
437 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
439 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
440 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
441 console.log($(
'#prodiv4').data(
'rowid'));
443 $(
"#prodiv"+ishow).data(
"iscat", 0);
444 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
446 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
450 $parameters = array();
451 $parameters[
'caller'] =
'loadProducts';
452 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
453 print $hookmanager->resPrint;
456 $(
"#prowatermark"+ishow).hide();
465function MoreProducts(moreorless) {
466 console.log(
"MoreProducts");
468 if ($(
'#search_pagination').val() !=
'') {
469 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
472 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
474 if (moreorless==
"more"){
475 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
476 $(
'#proimg31').animate({opacity:
'1'}, 100);
477 pageproducts=pageproducts+1;
479 if (moreorless==
"less"){
480 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
481 $(
'#proimg30').animate({opacity:
'1'}, 100);
482 if (pageproducts==0)
return;
483 pageproducts=pageproducts-1;
489 if (maxproduct >= 1) {
490 limit = maxproduct-1;
493 var nb_cat_shown = $(
'.div5 div.wrapper2[data-iscat=1]').length;
494 var offset = <?php echo ($MAXPRODUCT - 2); ?> * pageproducts - nb_cat_shown;
497 let socid = jQuery(
'#thirdpartyid').val();
498 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
499 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
503 $.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) {
504 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
506 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
507 pageproducts=pageproducts-1;
511 while (ishow < maxproduct) {
512 if (typeof (data[idata]) ==
"undefined") {
513 $(
"#prodivdesc"+ishow).hide();
514 $(
"#prodesc"+ishow).text(
"");
515 $(
"#probutton"+ishow).text(
"");
516 $(
"#probutton"+ishow).hide();
517 $(
"#proprice"+ishow).attr(
"class",
"");
518 $(
"#proprice"+ishow).html(
"");
519 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
520 $(
"#prodiv"+ishow).data(
"rowid",
"");
521 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
523 $(
"#prodivdesc"+ishow).show();
525 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
526 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
527 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
529 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
531 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
532 $(
"#probutton"+ishow).show();
533 if (data[parseInt(idata)][
'price_formated']) {
534 $(
"#proprice" + ishow).attr(
"class",
"productprice");
538 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
542 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
547 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
548 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
549 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
550 $(
"#prodiv"+ishow).data(
"iscat",0);
552 $(
"#prowatermark"+ishow).hide();
561function ClickProduct(
position, qty = 1) {
562 console.log(
"ClickProduct at position"+
position);
563 if ($(
'#invoiceid').val() ==
"") {
564 invoiceid = $(
'#invoiceid').val();
567 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
568 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
569 if ($(
'#prodiv'+
position).data(
'iscat') == 1){
570 console.log(
"Click on a category at position "+
position);
574 console.log($(
'#prodiv4').data(
'rowid'));
575 invoiceid = $(
"#invoiceid").val();
576 idproduct=$(
'#prodiv'+
position).data(
'rowid');
577 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
578 if (idproduct ==
"") {
582 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
584 echo
"CustomerDisplay();";
592function ChangeThirdparty(idcustomer) {
593 console.log(
"ChangeThirdparty");
595 $(
"#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() {
601function deleteline() {
602 invoiceid = $(
"#invoiceid").val();
603 console.log(
"Delete line invoiceid="+invoiceid);
604 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
611 console.log(
"Open box to select the thirdparty place="+place);
612 $.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
"); ?>"});
616 console.log(
"Open box to select the contact place="+place);
617 $.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"); ?>"});
622 console.log(
"Open box to select the history");
623 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
626function Reduction() {
627 invoiceid = $(
"#invoiceid").val();
628 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
629 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
631var closeBillParams=
"";
632function CloseBill() {
634 $parameters = array();
635 $reshook = $hookmanager->executeHooks(
'paramsForCloseBill', $parameters, $obj, $action);
637 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
638 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
639 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
643 invoiceid = $(
"#invoiceid").val();
644 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
646 if ($(
"#idcustomer").val() ==
"") {
647 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
658 if (empty($alternative_payurl)) {
664 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid+closeBillParams, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
668 invoiceid = $(
"#invoiceid").val();
669 console.log(
"Open popup to split on invoiceid="+invoiceid);
670 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
674 console.log(
"Open box to select floor place="+place);
675 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
679 invoiceid = $(
"#invoiceid").val();
680 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
681 $.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
"); ?>"});
684function TakeposOrderNotes() {
685 console.log(
"Open box to order notes");
686 ModalBox(
'ModalNote');
687 $(
"#textinput").focus();
691 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
692 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
699 invoiceid = $(
"#invoiceid").val();
701 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
703 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
706 if (parseInt(data[
'paye']) === 1) {
709 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
714 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
719 $(
"#idcustomer").val(
"");
731function Search2(keyCodeForEnter, moreorless) {
732 var eventKeyCode =
null;
734 if (window.event && window.event.keyCode) {
735 eventKeyCode = window.event.keyCode;
737 if (eventKeyCode ===
null && keyCodeForEnter !==
'') {
742 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
744 var search_term = $(
'#search').val();
745 var search_start = 0;
746 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
747 if (moreorless !=
null) {
748 search_term = $(
'#search_pagination').val();
749 search_start = $(
'#search_start_'+moreorless).val();
752 console.log(
"search_term="+search_term);
754 if (search_term ==
'') {
755 $(
"[id^=prowatermark]").html(
"");
756 $(
"[id^=prodesc]").text(
"");
757 $(
"[id^=probutton]").text(
"");
758 $(
"[id^=probutton]").hide();
759 $(
"[id^=proprice]").attr(
"class",
"hidden");
760 $(
"[id^=proprice]").html(
"");
761 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
762 $(
"[id^=prodiv]").data(
"rowid",
"");
763 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
768 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
772 if (search ===
true) {
776 clearTimeout(search2_timer);
780 search2_timer = setTimeout(
function(){
782 jQuery(
".wrapper2 .catwatermark").hide();
783 var nbsearchresults = 0;
786 let socid = jQuery(
'#thirdpartyid').val();
787 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
788 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
791 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&search_term=' + search_term +
'&thirdpartyid=' + socid +
'&search_start=' + search_start +
'&search_limit=' + search_limit,
function (data) {
792 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
793 if (typeof (data[i]) ==
"undefined") {
794 $(
"#prowatermark" + i).html(
"");
795 $(
"#prodesc" + i).text(
"");
796 $(
"#probutton" + i).text(
"");
797 $(
"#probutton" + i).hide();
798 $(
"#proprice" + i).attr(
"class",
"hidden");
799 $(
"#proprice" + i).html(
"");
800 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
801 $(
"#prodiv" + i).data(
"rowid",
"");
802 $(
"#prodiv" + i).attr(
"data-rowid",
"");
806 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
807 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
809 var titlestring = <?php echo $titlestring; ?>;
811 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
812 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
813 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
815 $(
"#prodesc" + i).html(data[i][
'label']);
817 $(
"#prodivdesc" + i).show();
818 $(
"#probutton" + i).html(data[i][
'label']);
819 $(
"#probutton" + i).show();
820 if (data[i][
'price_formated']) {
821 $(
"#proprice" + i).attr(
"class",
"productprice");
825 $(
"#proprice" + i).html(data[i][
'price_formated']);
829 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
834 $(
"#proimg" + i).attr(
"title", titlestring);
835 if( undefined !== data[i][
'img']) {
836 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
839 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
841 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
842 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
843 $(
"#prodiv" + i).data(
"iscat", 0);
844 $(
"#prodiv" + i).attr(
"data-iscat", 0);
848 $parameters = array();
849 $parameters[
'caller'] =
'search2';
850 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
851 print $hookmanager->resPrint;
856 }).always(
function (data) {
858 if ($(
'#search').val().length > 0 && data.length == 1) {
859 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
860 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
861 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
862 ChangeThirdparty(data[0][
'rowid']);
864 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
865 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']);
866 ClickProduct(0, data[0][
'qty']);
869 if (eventKeyCode == keyCodeForEnter){
870 if (data.length == 0) {
871 $(
'#search').val(
'<?php
872 $langs->load('errors
');
873 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
874 ?> ('+search_term+
')');
875 $(
'#search').select();
877 else ClearSearch(
false);
880 $(
"#search_pagination").val($(
"#search").val());
881 if (search_start == 0) {
882 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
885 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
886 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
887 $(
"#search_start_less").val(search_start_less);
889 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
890 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
893 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
894 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
895 $(
"#search_start_more").val(search_start_more);
904function Edit(number) {
905 console.log(
"We click on PAD on key="+number);
907 if (typeof(selectedtext) ==
"undefined") {
911 var text=selectedtext+
"<br> ";
917 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
918 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
919 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
921 }
else if (number==
'qty') {
922 if (editaction==
'qty' && editnumber !=
'') {
923 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
926 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
929 setFocusOnSearchField();
935 }
else if (number==
'p') {
936 if (editaction==
'p' && editnumber!=
"") {
937 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
940 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
949 }
else if (number==
'r') {
950 if (editaction==
'r' && editnumber!=
"") {
951 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
954 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
965 editnumber=editnumber+number;
967 if (editaction==
'qty'){
968 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
969 $(
"#qty").html(
"OK").addClass(
"clicked");
970 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
971 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
973 if (editaction==
'p'){
974 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
975 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
976 $(
"#price").html(
"OK").addClass(
"clicked");
977 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
979 if (editaction==
'r'){
980 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
981 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
982 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
983 $(
"#reduction").html(
"OK").addClass(
"clicked");
985 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
989function TakeposPrintingOrder(){
990 console.log(
"TakeposPrintingOrder");
991 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
996function TakeposPrintingTemp(){
997 console.log(
"TakeposPrintingTemp");
998 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
1003function OpenDrawer(){
1004 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
1007 data: { token:
'notrequired' },
1009 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var(
$conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1010 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
1012 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
1019function DolibarrOpenDrawer() {
1020 console.log(
"DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>");
1023 data: { token:
'<?php echo currentToken(); ?>' },
1024 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
1028function MoreActions(totalactions){
1029 if (pageactions==0){
1031 for (i = 0; i <= totalactions; i++){
1032 if (i<12) $(
"#action"+i).hide();
1033 else $(
"#action"+i).show();
1036 else if (pageactions==1){
1038 for (i = 0; i <= totalactions; i++){
1039 if (i<12) $(
"#action"+i).show();
1040 else $(
"#action"+i).hide();
1047function ControlCashOpening()
1049 $.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
"); ?>"});
1052function CloseCashFence(rowid)
1054 $.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
"); ?>"});
1057function CashReport(rowid)
1059 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1063function ModalBox(ModalID)
1065 var modal = document.getElementById(ModalID);
1066 modal.style.display =
"block";
1069function DirectPayment(){
1070 console.log(
"DirectPayment");
1071 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1072 $(
'#invoiceid').val(
"");
1076function FullScreen() {
1077 document.documentElement.requestFullscreen();
1080function WeighingScale(){
1081 console.log(
"Weighing Scale");
1084 data: { token:
'notrequired' },
1085 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1087 .done(
function( editnumber ) {
1088 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1094$( document ).ready(
function() {
1100 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1101 print
"ModalBox('ModalTerminal');";
1105 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1106 $sql .=
" entity = ".((int)
$conf->entity).
" AND ";
1107 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1109 $sql .=
" AND status = 0 ";
1110 $resql = $db->query($sql);
1112 $obj = $db->fetch_object($resql);
1114 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1115 print
"ControlCashOpening();";
1122 var elem1 = $(
"#topnav-left")[0];
1123 var elem2 = $(
"#topnav-right")[0];
1124 var checkOverflow =
function() {
1125 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1126 else $(
"#topnav").removeClass(
"overflow");
1129 var scrollBars =
function(){
1130 var container= $(
'#topnav')[0];
1132 vertical:container.scrollHeight > container.clientHeight,
1133 horizontal:container.scrollWidth > container.clientWidth
1137 $(window).resize(
function(){
1141 let resizeObserver =
new ResizeObserver(() => {
1144 resizeObserver.observe(elem1);
1145 resizeObserver.observe(elem2);
1148 var pressTimer = [];
1152 $(
".indicator").mousedown(
function(){
1153 direction = $(
this).hasClass(
"left") ? -1 : 1;
1155 pressTimer.push(setInterval(scrollTo, 100));
1158 $(
".indicator").mouseup(
function(){
1159 pressTimer.forEach(clearInterval);
1162 $(
"body").mouseup(
function(){
1163 pressTimer.forEach(clearInterval);
1164 console.log(
"body mouseup");
1167 function scrollTo(){
1168 console.log(
"here");
1169 var pos = $(
"#topnav").scrollLeft();
1170 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1173 $(
"#topnav").scroll(
function(){
1174 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1183$keyCodeForEnter =
'';
1184if (!empty($_SESSION[
'takeposterminal'])) {
1185 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalString(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1188<div
class=
"container">
1193 <div
class=
"header">
1194 <div
id=
"topnav" class=
"topnav">
1195 <div
id=
"topnav-left" class=
"topnav-left">
1196 <div
class=
"inline-block valignmiddle">
1197 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1198 <span
class=
"fa fa-cash-register"></span>
1199 <span
class=
"hideonsmartphone">
1201 if (!empty($_SESSION[
"takeposterminal"])) {
1202 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1207 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1210 if (isModEnabled(
'multicurrency')) {
1211 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1212 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1216 <!-- section
for customer -->
1217 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1218 <input
type=
"hidden" id=
"idcustomer" value=
"">
1219 <!-- section
for shopping carts -->
1220 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1221 <!-- More info about customer -->
1222 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1224 if (isModEnabled(
'stock')) {
1226 <!-- More info about warehouse -->
1227 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1231 <div
id=
"topnav-right" class=
"topnav-right">
1233 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1234 if ($reshook == 0) {
1236 <div
class=
"login_block_other takepos">
1237 <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>
1238 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1239 <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 -->
1240 <span
class=
"fas fa-home"></span></a>
1241 <?php
if (empty(
$conf->dol_use_jmobile)) { ?>
1242 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1248 <div
class=
"login_block_user">
1250 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1254 <div
class=
"arrows">
1255 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1256 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1264<!-- Modal terminal box -->
1265<div
id=
"ModalTerminal" class=
"modal">
1266 <div
class=
"modal-content">
1267 <div
class=
"modal-header">
1271 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1274 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1276 <div
class=
"modal-body">
1277 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1280 for ($i = 2; $i <= $nbloop; $i++) {
1281 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1288<!-- Modal multicurrency box -->
1289<?php if (isModEnabled('multicurrency')) { ?>
1290<div id="ModalCurrency
" class="modal
">
1291 <div class="modal-content
">
1292 <div class="modal-header
">
1293 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1294 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1296 <div class="modal-body
">
1298 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1299 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1300 $resql = $db->query($sql);
1302 while ($obj = $db->fetch_object($resql)) {
1303 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1312<!-- Modal terminal Credit Note -->
1313<div id="ModalCreditNote
" class="modal
">
1314 <div class="modal-content
">
1315 <div class="modal-header
">
1316 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1317 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1319 <div class="modal-body
">
1320 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1321 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1327<div id="ModalNote
" class="modal
">
1328 <div class="modal-content
">
1329 <div class="modal-header
">
1330 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1331 <h3><?php print $langs->trans("Note
"); ?></h3>
1333 <div class="modal-body
">
1334 <input type="text
" class="block
" id="textinput
">
1335 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1344 <div id="poslines
" class="div1
">
1348 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1349 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1350 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1351 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1352 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1353 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1354 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1355 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1356 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1357 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1358 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1359 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1360 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1361 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1362 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1363 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1368// TakePOS setup check
1369if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1370 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1371 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1372 $sql .= " AND active = 1
";
1373 $sql .= " ORDER BY libelle
";
1375 $resql = $db->query($sql);
1376 $paiementsModes = array();
1378 while ($obj = $db->fetch_object($resql)) {
1379 $paycode = $obj->code;
1380 if ($paycode == 'LIQ') {
1383 if ($paycode == 'CHQ') {
1384 $paycode = 'CHEQUE';
1387 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1388 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1389 if (getDolGlobalInt($constantforkey) > 0) {
1390 array_push($paiementsModes, $obj);
1395 if (empty($paiementsModes) && isModEnabled("bank
")) {
1396 $langs->load('errors');
1397 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1398 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1402if (count($maincategories) == 0) {
1403 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1404 $tmpcategory = new Categorie($db);
1405 $tmpcategory->fetch(getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID'));
1406 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1408 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1411// User menu and external TakePOS modules
1415if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1416 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1418 // BAR RESTAURANT specific menu
1419 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1422if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1423 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1424 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1426 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1429if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1430 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1432$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1433$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1435if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1436 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1439// BAR RESTAURANT specific menu
1440if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1441 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1442 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action' => 'TakeposPrintingOrder();');
1446// Last action that close the sell (payments)
1447$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1448if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1449 $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();');
1452// BAR RESTAURANT specific menu
1453if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1454 //Button to print receipt before payment
1455 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1456 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1457 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1458 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposConnector(placeid);');
1460 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1462 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1463 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1465 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'Print(placeid);');
1468 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1469 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1471 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1472 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1476if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1477 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1479if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1480 $menus[$r++] = array(
1481 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1482 'action' => 'DolibarrOpenDrawer();',
1486$sql = "SELECT rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1487$sql .= " entity =
".((int) $conf->entity)." AND
";
1488$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1489$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1490$sql .= " AND
status = 0
";
1492$resql = $db->query($sql);
1494 $num = $db->num_rows($resql);
1496 $obj = $db->fetch_object($resql);
1497 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1498 if ($obj->status == 0) {
1499 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1504$parameters = array('menus' => $menus);
1505$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1506if ($reshook == 0) { //add buttons
1507 if (is_array($hookmanager->resArray)) {
1508 foreach ($hookmanager->resArray as $resArray) {
1509 foreach ($resArray as $butmenu) {
1510 $menus[$r++] = $butmenu;
1514} elseif ($reshook == 1) {
1515 $r = 0; //replace buttons
1516 if (is_array($hookmanager->resArray) ) {
1517 foreach ($hookmanager->resArray as $resArray) {
1518 foreach ($resArray as $butmenu) {
1519 $menus[$r++] = $butmenu;
1526 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1529if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1530 $menus[$r++] = array('title' => '<span class="fa fa-sign-out-alt pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("Logout
").'</div>', 'action' => 'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php?token='.newToken().'\';');
1533if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1534 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1538 <!-- Show buttons -->
1542 foreach ($menus as $menu) {
1544 if (count($menus) > 12 and $i == 12) {
1545 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1546 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1547 } elseif ($i > 12) {
1548 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1550 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1554 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1555 print '<!-- Show the search input text -->'."\n
";
1556 print '<div class="margintoponly
">';
1557 print '<input type="text
" id="search
" class="input-search-takepos 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> ';
1558 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear').'</a>';
1569 <!-- Show categories -->
1571 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1572 print '<div class="div4
" style= "display: none;
">';
1574 print '<div class="div4
">';
1578 while ($count < $MAXCATEG) {
1580 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1581 echo 'onclick="MoreCategories(\
'less\')"';
1582 } elseif ($count == ($MAXCATEG - 1)) {
1583 echo
'onclick="MoreCategories(\'more\')"';
1585 echo
'onclick="LoadProducts('.$count.
')"';
1586 } ?>
id=
"catdiv<?php echo $count; ?>">
1588 if ($count == ($MAXCATEG - 2)) {
1590 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1591 } elseif ($count == ($MAXCATEG - 1)) {
1593 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1596 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1599 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1600 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1601 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1604 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1612 <!-- Show product -->
1613 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1614 print ' centpercent';
1619 while ($count < $MAXPRODUCT) {
1620 print
'<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ?
' arrow' :
'').
'" id="prodiv'.$count.
'" '; ?>
1621 <?php
if ($count == ($MAXPRODUCT - 2)) {
1622 ?> onclick=
"MoreProducts('less')" <?php
1624 if ($count == ($MAXPRODUCT - 1)) {
1625 ?> onclick=
"MoreProducts('more')" <?php
1627 echo
'onclick="ClickProduct('.((int) $count).
')"';
1630 if ($count == ($MAXPRODUCT - 2)) {
1632 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1633 } elseif ($count == ($MAXPRODUCT - 1)) {
1635 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1638 print
'<div class="" id="proprice'.$count.
'"></div>';
1641 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1643 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1646 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1647 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1648 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1651 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1657 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1658 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1659 <input
type=
"hidden" id=
"search_pagination" value=
"">
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Class to manage categories.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dolSetCookie(string $cookiename, string $cookievalue, int $expire=-1)
Set a cookie.
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 the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
top_menu_user($hideloginname=0, $urllogout='')
Build the tooltip on user login.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
if(preg_match('/(crypted|dolcrypt):/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.