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 setcookie(
"takeposterminal", (
string) $setterminal, (time() + (86400 * 354)),
'/',
'', !empty($dolibarr_main_force_https),
true);
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);
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 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
564 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
565 if ($(
'#prodiv'+
position).data(
'iscat') == 1){
566 console.log(
"Click on a category at position "+
position);
570 console.log($(
'#prodiv4').data(
'rowid'));
571 invoiceid = $(
"#invoiceid").val();
572 idproduct=$(
'#prodiv'+
position).data(
'rowid');
573 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
574 if (idproduct ==
"") {
578 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
580 echo
"CustomerDisplay();";
588function ChangeThirdparty(idcustomer) {
589 console.log(
"ChangeThirdparty");
591 $(
"#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() {
597function deleteline() {
598 invoiceid = $(
"#invoiceid").val();
599 console.log(
"Delete line invoiceid="+invoiceid);
600 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
607 console.log(
"Open box to select the thirdparty place="+place);
608 $.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
"); ?>"});
612 console.log(
"Open box to select the contact place="+place);
613 $.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"); ?>"});
618 console.log(
"Open box to select the history");
619 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
622function Reduction() {
623 invoiceid = $(
"#invoiceid").val();
624 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
625 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
628function CloseBill() {
631 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
632 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
633 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
637 invoiceid = $(
"#invoiceid").val();
638 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
640 if ($(
"#idcustomer").val() ==
"") {
641 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
652 if (empty($alternative_payurl)) {
658 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
662 invoiceid = $(
"#invoiceid").val();
663 console.log(
"Open popup to split on invoiceid="+invoiceid);
664 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
668 console.log(
"Open box to select floor place="+place);
669 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
673 invoiceid = $(
"#invoiceid").val();
674 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
675 $.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
"); ?>"});
678function TakeposOrderNotes() {
679 console.log(
"Open box to order notes");
680 ModalBox(
'ModalNote');
681 $(
"#textinput").focus();
685 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
686 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
693 invoiceid = $(
"#invoiceid").val();
695 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
697 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
700 if (parseInt(data[
'paye']) === 1) {
703 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
708 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
713 $(
"#idcustomer").val(
"");
725function Search2(keyCodeForEnter, moreorless) {
726 var eventKeyCode = window.event.keyCode;
728 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
730 var search_term = $(
'#search').val();
731 var search_start = 0;
732 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
733 if (moreorless !=
null) {
734 search_term = $(
'#search_pagination').val();
735 search_start = $(
'#search_start_'+moreorless).val();
738 console.log(
"search_term="+search_term);
740 if (search_term ==
'') {
741 $(
"[id^=prowatermark]").html(
"");
742 $(
"[id^=prodesc]").text(
"");
743 $(
"[id^=probutton]").text(
"");
744 $(
"[id^=probutton]").hide();
745 $(
"[id^=proprice]").attr(
"class",
"hidden");
746 $(
"[id^=proprice]").html(
"");
747 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
748 $(
"[id^=prodiv]").data(
"rowid",
"");
749 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
754 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
758 if (search ===
true) {
762 clearTimeout(search2_timer);
766 search2_timer = setTimeout(
function(){
768 jQuery(
".wrapper2 .catwatermark").hide();
769 var nbsearchresults = 0;
772 let socid = jQuery(
'#thirdpartyid').val();
773 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
774 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
777 $.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) {
778 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
779 if (typeof (data[i]) ==
"undefined") {
780 $(
"#prowatermark" + i).html(
"");
781 $(
"#prodesc" + i).text(
"");
782 $(
"#probutton" + i).text(
"");
783 $(
"#probutton" + i).hide();
784 $(
"#proprice" + i).attr(
"class",
"hidden");
785 $(
"#proprice" + i).html(
"");
786 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
787 $(
"#prodiv" + i).data(
"rowid",
"");
788 $(
"#prodiv" + i).attr(
"data-rowid",
"");
792 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
793 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
795 var titlestring = <?php echo $titlestring; ?>;
797 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
798 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
799 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
801 $(
"#prodesc" + i).html(data[i][
'label']);
803 $(
"#prodivdesc" + i).show();
804 $(
"#probutton" + i).html(data[i][
'label']);
805 $(
"#probutton" + i).show();
806 if (data[i][
'price_formated']) {
807 $(
"#proprice" + i).attr(
"class",
"productprice");
811 $(
"#proprice" + i).html(data[i][
'price_formated']);
815 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
820 $(
"#proimg" + i).attr(
"title", titlestring);
821 if( undefined !== data[i][
'img']) {
822 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
825 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
827 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
828 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
829 $(
"#prodiv" + i).data(
"iscat", 0);
830 $(
"#prodiv" + i).attr(
"data-iscat", 0);
834 $parameters = array();
835 $parameters[
'caller'] =
'search2';
836 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
837 print $hookmanager->resPrint;
842 }).always(
function (data) {
844 if ($(
'#search').val().length > 0 && data.length == 1) {
845 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
846 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
847 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
848 ChangeThirdparty(data[0][
'rowid']);
850 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
851 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']);
852 ClickProduct(0, data[0][
'qty']);
855 if (eventKeyCode == keyCodeForEnter){
856 if (data.length == 0) {
857 $(
'#search').val(
'<?php
858 $langs->load('errors
');
859 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
860 ?> ('+search_term+
')');
861 $(
'#search').select();
863 else ClearSearch(
false);
866 $(
"#search_pagination").val($(
"#search").val());
867 if (search_start == 0) {
868 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
871 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
872 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
873 $(
"#search_start_less").val(search_start_less);
875 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
876 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
879 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
880 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
881 $(
"#search_start_more").val(search_start_more);
890function Edit(number) {
891 console.log(
"We click on PAD on key="+number);
893 if (typeof(selectedtext) ==
"undefined") {
897 var text=selectedtext+
"<br> ";
903 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
904 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
905 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
907 }
else if (number==
'qty') {
908 if (editaction==
'qty' && editnumber !=
'') {
909 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
912 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
915 setFocusOnSearchField();
921 }
else if (number==
'p') {
922 if (editaction==
'p' && editnumber!=
"") {
923 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
926 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
935 }
else if (number==
'r') {
936 if (editaction==
'r' && editnumber!=
"") {
937 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
940 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
951 editnumber=editnumber+number;
953 if (editaction==
'qty'){
954 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
955 $(
"#qty").html(
"OK").addClass(
"clicked");
956 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
957 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
959 if (editaction==
'p'){
960 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
961 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
962 $(
"#price").html(
"OK").addClass(
"clicked");
963 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
965 if (editaction==
'r'){
966 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
967 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
968 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
969 $(
"#reduction").html(
"OK").addClass(
"clicked");
971 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
975function TakeposPrintingOrder(){
976 console.log(
"TakeposPrintingOrder");
977 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
982function TakeposPrintingTemp(){
983 console.log(
"TakeposPrintingTemp");
984 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
989function OpenDrawer(){
990 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
993 data: { token:
'notrequired' },
995 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var(
$conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
996 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
998 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
1005function DolibarrOpenDrawer() {
1006 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
"]); ?>");
1009 data: { token:
'<?php echo currentToken(); ?>' },
1010 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
1014function MoreActions(totalactions){
1015 if (pageactions==0){
1017 for (i = 0; i <= totalactions; i++){
1018 if (i<12) $(
"#action"+i).hide();
1019 else $(
"#action"+i).show();
1022 else if (pageactions==1){
1024 for (i = 0; i <= totalactions; i++){
1025 if (i<12) $(
"#action"+i).show();
1026 else $(
"#action"+i).hide();
1033function ControlCashOpening()
1035 $.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
"); ?>"});
1038function CloseCashFence(rowid)
1040 $.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
"); ?>"});
1043function CashReport(rowid)
1045 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1049function ModalBox(ModalID)
1051 var modal = document.getElementById(ModalID);
1052 modal.style.display =
"block";
1055function DirectPayment(){
1056 console.log(
"DirectPayment");
1057 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1061function FullScreen() {
1062 document.documentElement.requestFullscreen();
1065function WeighingScale(){
1066 console.log(
"Weighing Scale");
1069 data: { token:
'notrequired' },
1070 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1072 .done(
function( editnumber ) {
1073 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1079$( document ).ready(
function() {
1085 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1086 print
"ModalBox('ModalTerminal');";
1090 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1091 $sql .=
" entity = ".((int)
$conf->entity).
" AND ";
1092 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1094 $resql = $db->query($sql);
1096 $obj = $db->fetch_object($resql);
1098 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1099 print
"ControlCashOpening();";
1106 var elem1 = $(
"#topnav-left")[0];
1107 var elem2 = $(
"#topnav-right")[0];
1108 var checkOverflow =
function() {
1109 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1110 else $(
"#topnav").removeClass(
"overflow");
1113 var scrollBars =
function(){
1114 var container= $(
'#topnav')[0];
1116 vertical:container.scrollHeight > container.clientHeight,
1117 horizontal:container.scrollWidth > container.clientWidth
1121 $(window).resize(
function(){
1125 let resizeObserver =
new ResizeObserver(() => {
1128 resizeObserver.observe(elem1);
1129 resizeObserver.observe(elem2);
1132 var pressTimer = [];
1136 $(
".indicator").mousedown(
function(){
1137 direction = $(
this).hasClass(
"left") ? -1 : 1;
1139 pressTimer.push(setInterval(scrollTo, 100));
1142 $(
".indicator").mouseup(
function(){
1143 pressTimer.forEach(clearInterval);
1146 $(
"body").mouseup(
function(){
1147 pressTimer.forEach(clearInterval);
1148 console.log(
"body mouseup");
1151 function scrollTo(){
1152 console.log(
"here");
1153 var pos = $(
"#topnav").scrollLeft();
1154 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1157 $(
"#topnav").scroll(
function(){
1158 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1167$keyCodeForEnter =
'';
1168if (!empty($_SESSION[
'takeposterminal'])) {
1169 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalString(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1172<div
class=
"container">
1177 <div
class=
"header">
1178 <div
id=
"topnav" class=
"topnav">
1179 <div
id=
"topnav-left" class=
"topnav-left">
1180 <div
class=
"inline-block valignmiddle">
1181 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1182 <span
class=
"fa fa-cash-register"></span>
1183 <span
class=
"hideonsmartphone">
1185 if (!empty($_SESSION[
"takeposterminal"])) {
1186 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1191 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1194 if (isModEnabled(
'multicurrency')) {
1195 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1196 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1200 <!-- section
for customer -->
1201 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1202 <input
type=
"hidden" id=
"idcustomer" value=
"">
1203 <!-- section
for shopping carts -->
1204 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1205 <!-- More info about customer -->
1206 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1208 if (isModEnabled(
'stock')) {
1210 <!-- More info about warehouse -->
1211 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1215 <div
id=
"topnav-right" class=
"topnav-right">
1217 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1218 if ($reshook == 0) {
1220 <div
class=
"login_block_other takepos">
1221 <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>
1222 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1223 <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 -->
1224 <span
class=
"fas fa-home"></span></a>
1225 <?php
if (empty(
$conf->dol_use_jmobile)) { ?>
1226 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1232 <div
class=
"login_block_user">
1234 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1238 <div
class=
"arrows">
1239 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1240 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1248<!-- Modal terminal box -->
1249<div
id=
"ModalTerminal" class=
"modal">
1250 <div
class=
"modal-content">
1251 <div
class=
"modal-header">
1255 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1258 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1260 <div
class=
"modal-body">
1261 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1264 for ($i = 2; $i <= $nbloop; $i++) {
1265 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1272<!-- Modal multicurrency box -->
1273<?php if (isModEnabled('multicurrency')) { ?>
1274<div id="ModalCurrency
" class="modal
">
1275 <div class="modal-content
">
1276 <div class="modal-header
">
1277 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1278 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1280 <div class="modal-body
">
1282 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1283 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1284 $resql = $db->query($sql);
1286 while ($obj = $db->fetch_object($resql)) {
1287 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1296<!-- Modal terminal Credit Note -->
1297<div id="ModalCreditNote
" class="modal
">
1298 <div class="modal-content
">
1299 <div class="modal-header
">
1300 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1301 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1303 <div class="modal-body
">
1304 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1305 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1311<div id="ModalNote
" class="modal
">
1312 <div class="modal-content
">
1313 <div class="modal-header
">
1314 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1315 <h3><?php print $langs->trans("Note
"); ?></h3>
1317 <div class="modal-body
">
1318 <input type="text
" class="block
" id="textinput
">
1319 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1328 <div id="poslines
" class="div1
">
1332 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1333 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1334 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1335 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1336 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1337 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1338 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1339 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1340 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1341 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1342 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1343 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1344 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1345 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1346 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1347 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1352// TakePOS setup check
1353if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1354 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1355 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1356 $sql .= " AND active = 1
";
1357 $sql .= " ORDER BY libelle
";
1359 $resql = $db->query($sql);
1360 $paiementsModes = array();
1362 while ($obj = $db->fetch_object($resql)) {
1363 $paycode = $obj->code;
1364 if ($paycode == 'LIQ') {
1367 if ($paycode == 'CHQ') {
1368 $paycode = 'CHEQUE';
1371 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1372 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1373 if (getDolGlobalInt($constantforkey) > 0) {
1374 array_push($paiementsModes, $obj);
1379 if (empty($paiementsModes) && isModEnabled("bank
")) {
1380 $langs->load('errors');
1381 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1382 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1386if (count($maincategories) == 0) {
1387 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1388 $tmpcategory = new Categorie($db);
1389 $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID'));
1390 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1392 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1395// User menu and external TakePOS modules
1399if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1400 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1402 // BAR RESTAURANT specific menu
1403 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1406if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1407 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1408 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1410 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1413if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1414 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1416$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1417$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1419if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1420 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1423// BAR RESTAURANT specific menu
1424if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1425 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1426 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action' => 'TakeposPrintingOrder();');
1430// Last action that close the sell (payments)
1431$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1432if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1433 $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();');
1436// BAR RESTAURANT specific menu
1437if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1438 //Button to print receipt before payment
1439 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1440 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1441 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1442 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposConnector(placeid);');
1444 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1446 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1447 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1449 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'Print(placeid);');
1452 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1453 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1455 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1456 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1460if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1461 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1463if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1464 $menus[$r++] = array(
1465 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1466 'action' => 'DolibarrOpenDrawer();',
1470$sql = "SELECT rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1471$sql .= " entity =
".((int) $conf->entity)." AND
";
1472$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1473$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1475$resql = $db->query($sql);
1477 $num = $db->num_rows($resql);
1479 $obj = $db->fetch_object($resql);
1480 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1481 if ($obj->status == 0) {
1482 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1487$parameters = array('menus' => $menus);
1488$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1489if ($reshook == 0) { //add buttons
1490 if (is_array($hookmanager->resArray)) {
1491 foreach ($hookmanager->resArray as $resArray) {
1492 foreach ($resArray as $butmenu) {
1493 $menus[$r++] = $butmenu;
1497} elseif ($reshook == 1) {
1498 $r = 0; //replace buttons
1499 if (is_array($hookmanager->resArray) ) {
1500 foreach ($hookmanager->resArray as $resArray) {
1501 foreach ($resArray as $butmenu) {
1502 $menus[$r++] = $butmenu;
1509 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1512if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1513 $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().'\';');
1516if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1517 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1521 <!-- Show buttons -->
1525 foreach ($menus as $menu) {
1527 if (count($menus) > 12 and $i == 12) {
1528 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1529 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1530 } elseif ($i > 12) {
1531 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1533 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1537 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1538 print '<!-- Show the search input text -->'."\n
";
1539 print '<div class="margintoponly
">';
1540 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> ';
1541 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear').'</a>';
1552 <!-- Show categories -->
1554 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1555 print '<div class="div4
" style= "display: none;
">';
1557 print '<div class="div4
">';
1561 while ($count < $MAXCATEG) {
1563 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1564 echo 'onclick="MoreCategories(\
'less\')"';
1565 } elseif ($count == ($MAXCATEG - 1)) {
1566 echo
'onclick="MoreCategories(\'more\')"';
1568 echo
'onclick="LoadProducts('.$count.
')"';
1569 } ?>
id=
"catdiv<?php echo $count; ?>">
1571 if ($count == ($MAXCATEG - 2)) {
1573 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1574 } elseif ($count == ($MAXCATEG - 1)) {
1576 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1579 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1582 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1583 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1584 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1587 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1595 <!-- Show product -->
1596 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1597 print ' centpercent';
1602 while ($count < $MAXPRODUCT) {
1603 print
'<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ?
' arrow' :
'').
'" id="prodiv'.$count.
'" '; ?>
1604 <?php
if ($count == ($MAXPRODUCT - 2)) {
1605 ?> onclick=
"MoreProducts('less')" <?php
1607 if ($count == ($MAXPRODUCT - 1)) {
1608 ?> onclick=
"MoreProducts('more')" <?php
1610 echo
'onclick="ClickProduct('.$count.
')"';
1613 if ($count == ($MAXPRODUCT - 2)) {
1615 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1616 } elseif ($count == ($MAXPRODUCT - 1)) {
1618 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1621 print
'<div class="" id="proprice'.$count.
'"></div>';
1624 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1626 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1629 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1630 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1631 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1634 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1640 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1641 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1642 <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.
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:/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.