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';
53require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
59require_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;
94$MAXCATEG =
getDolGlobalInt(
'TAKEPOS_NB_MAXCATEG', $maxcategbydefaultforthisdevice);
95$MAXPRODUCT =
getDolGlobalInt(
'TAKEPOS_NB_MAXPRODUCT', $maxproductbydefaultforthisdevice);
97$term = empty($_SESSION[
'takeposterminal']) ? 1 : $_SESSION[
'takeposterminal'];
118$form =
new Form($db);
122$arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
123$arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
126 $arrayofcss[] =
'/takepos/css/colorful.css';
131$title =
'TakePOS - Dolibarr '.DOL_VERSION;
135$head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
136<meta name="apple-mobile-web-app-capable" content="yes">
137<meta name="mobile-web-app-capable" content="yes">
138<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
140top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
143$categories = $categorie->get_full_arbo(
'product',
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID'), 1);
148$levelofrootcategory = 0;
150 foreach ($categories as $key => $categorycursor) {
152 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
153 $levelofrootcategory = $categorycursor[
'level'];
159$levelofmaincategories = $levelofrootcategory + 1;
161$maincategories = array();
162$subcategories = array();
163foreach ($categories as $key => $categorycursor) {
164 if ($categorycursor[
'level'] == $levelofmaincategories) {
165 $maincategories[$key] = $categorycursor;
166 } elseif ($categorycursor[
'level'] > $levelofmaincategories) {
167 $subcategories[$key] = $categorycursor;
175$keyCodeForEnter =
'';
176if (!empty($_SESSION[
'takeposterminal'])) {
177 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalString(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
181<body
class=
"bodytakepos" style=
"overflow: hidden;">
184var categories = <?php echo json_encode($maincategories); ?>;
185var subcategories = <?php echo json_encode($subcategories); ?>;
189var currentsubcategories=[];
192var place=
"<?php echo $place; ?>";
196var search2_timer=
null;
215function ClearSearch(clearSearchResults) {
216 console.log(
"ClearSearch");
217 $(
"#search").val(
'');
218 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
219 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
220 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
221 <?php
if ($conf->browser->layout ==
'classic') { ?>
222 setFocusOnSearchField();
224 if (clearSearchResults) {
225 $(
"#search").trigger(
'keyup');
230function setFocusOnSearchField() {
231 console.log(
"Call setFocusOnSearchField in page index.php");
232 <?php
if ($conf->browser->layout ==
'classic') { ?>
233 console.log(
"has keyboard from localStorage, so we can force focus on search field");
234 $(
"#search").focus();
238function PrintCategories(first) {
239 console.log(
"PrintCategories");
240 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
241 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
243 $(
"#catdivdesc"+i).hide();
244 $(
"#catdesc"+i).text(
"");
245 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
246 $(
"#catwatermark"+i).hide();
247 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
250 $(
"#catdivdesc"+i).show();
253 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
255 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
257 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
258 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
259 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
260 $(
"#catdiv"+i).attr(
'class',
'wrapper');
261 $(
"#catwatermark"+i).show();
265function MoreCategories(moreorless) {
266 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
267 if (moreorless ==
"more") {
268 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
269 $(
'#catimg15').animate({opacity:
'1'}, 100);
270 pagecategories=pagecategories+1;
272 if (moreorless ==
"less") {
273 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
274 $(
'#catimg14').animate({opacity:
'1'}, 100);
275 if (pagecategories==0)
return;
276 pagecategories=pagecategories-1;
278 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
279 pagecategories=pagecategories-1;
283 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
284 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
286 console.log(
"complete with empty record");
287 $(
"#catdivdesc"+i).hide();
288 $(
"#catdesc"+i).text(
"");
289 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
290 $(
"#catwatermark"+i).hide();
293 $(
"#catdivdesc"+i).show();
296 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
298 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
300 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
301 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
302 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
303 $(
"#catwatermark"+i).show();
310function PrintSubCategory(ishow, val) {
311 $(
"#prodivdesc"+ishow).show();
313 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
314 $(
"#probutton"+ishow).html(val.label);
316 $(
"#prodesc"+ishow).text(val.label);
317 $(
"#probutton"+ishow).text(val.label);
319 $(
"#probutton"+ishow).show();
320 $(
"#proprice"+ishow).attr(
"class",
"hidden");
321 $(
"#proprice"+ishow).html(
"");
322 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
323 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
324 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
325 $(
"#prodiv"+ishow).data(
"iscat", 1);
326 $(
"#prodiv"+ishow).attr(
"data-iscat", 1);
327 $(
"#prodiv"+ishow).removeClass(
"divempty");
328 $(
"#prowatermark"+ishow).show();
332function LoadProducts(
position, issubcat) {
333 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
334 var maxproduct = <?php echo (
int) ($MAXPRODUCT - 2); ?>;
337 currentcat =
"supplements";
339 if (subcategories.count == 0) {
340 alert(
"No product found into categories level 2 or more");
343 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
344 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
345 if (issubcat ==
true) {
346 currentcat = $(
'#prodiv'+
position).data(
'rowid');
349 currentcat = $(
'#catdiv'+
position).data(
'rowid');
350 console.log(
"currentcat="+currentcat);
353 if (currentcat == undefined) {
359 currentsubcategories = [];
360 if (currentcat !=
"supplements") {
361 console.log(
"Loop on each category level 2 or more");
362 jQuery.each(subcategories,
function(i, val) {
363 if (currentcat == val.fk_parent) {
364 currentsubcategories.push(val);
369 while (ishow < currentsubcategories.length && ishow < maxproduct) {
370 PrintSubCategory(ishow, currentsubcategories[ishow]);
376 if (maxproduct >= 1) {
377 limit = maxproduct - 1;
381 let socid = jQuery(
'#thirdpartyid').val();
382 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
383 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
387 $.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) {
389 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
390 console.log(
"Found "+data.length+
" record");
392 if (data.length == 0 && currentcat ==
"supplements") {
393 alert(
"No supplements found into the supplement category. Check the module setup and your product categories.");
396 while (ishow < maxproduct) {
397 console.log(
"ishow"+ishow+
" idata="+idata);
398 console.log(data[idata]);
400 if (typeof (data[idata]) ==
"undefined") {
402 echo
'$("#prodivdesc"+ishow).hide();';
403 echo
'$("#prodesc"+ishow).text("");';
404 echo
'$("#proimg"+ishow).attr("title","");';
405 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
407 echo
'$("#probutton"+ishow).hide();';
408 echo
'$("#probutton"+ishow).text("");';
410 $(
"#proprice"+ishow).attr(
"class",
"hidden");
411 $(
"#proprice"+ishow).html(
"");
413 $(
"#prodiv"+ishow).data(
"rowid",
"");
414 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
416 $(
"#prodiv"+ishow).data(
"iscat",
"0");
417 $(
"#prodiv"+ishow).attr(
"data-iscat",
"0");
419 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
422 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
423 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
425 var titlestring = <?php echo $titlestring; ?>;
427 echo
'$("#prodivdesc"+ishow).show();';
429 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
431 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
433 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
435 echo
'$("#proimg"+ishow).attr("title", titlestring);';
436 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
438 echo
'$("#probutton"+ishow).show();';
439 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
442 if (data[parseInt(idata)][
'price_formated']) {
443 $(
"#proprice" + ishow).attr(
"class",
"productprice");
447 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
451 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
456 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
458 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
459 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
460 console.log($(
'#prodiv4').data(
'rowid'));
462 $(
"#prodiv"+ishow).data(
"iscat", 0);
463 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
465 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
469 $parameters = array();
470 $parameters[
'caller'] =
'loadProducts';
471 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
472 print $hookmanager->resPrint;
475 $(
"#prowatermark"+ishow).hide();
484function MoreProducts(moreorless) {
485 console.log(
"MoreProducts");
487 if ($(
'#search_pagination').val() !=
'') {
488 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
491 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
493 if (moreorless==
"more"){
494 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
495 $(
'#proimg31').animate({opacity:
'1'}, 100);
496 pageproducts=pageproducts+1;
498 if (moreorless==
"less"){
499 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
500 $(
'#proimg30').animate({opacity:
'1'}, 100);
501 if (pageproducts==0)
return;
502 pageproducts=pageproducts-1;
508 if (maxproduct >= 1) {
509 limit = maxproduct-1;
513 var first = maxproduct * pageproducts;
514 var offset = Math.max(0, first - currentsubcategories.length);
517 let socid = jQuery(
'#thirdpartyid').val();
518 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
519 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
523 $.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) {
524 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
526 if (typeof (data[0]) ==
"undefined" && first >= currentsubcategories.length && moreorless==
"more"){
527 pageproducts=pageproducts-1;
531 while (ishow < maxproduct && first + ishow < currentsubcategories.length) {
532 PrintSubCategory(ishow, currentsubcategories[first + ishow]);
536 while (ishow < maxproduct) {
537 if (typeof (data[idata]) ==
"undefined") {
538 $(
"#prodivdesc"+ishow).hide();
539 $(
"#prodesc"+ishow).text(
"");
540 $(
"#probutton"+ishow).text(
"");
541 $(
"#probutton"+ishow).hide();
542 $(
"#proprice"+ishow).attr(
"class",
"");
543 $(
"#proprice"+ishow).html(
"");
544 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
545 $(
"#prodiv"+ishow).data(
"rowid",
"");
546 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
547 $(
"#prodiv"+ishow).data(
"iscat",0);
548 $(
"#prodiv"+ishow).attr(
"data-iscat",0);
550 $(
"#prodivdesc"+ishow).show();
552 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
553 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
554 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
556 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
558 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
559 $(
"#probutton"+ishow).show();
560 if (data[parseInt(idata)][
'price_formated']) {
561 $(
"#proprice" + ishow).attr(
"class",
"productprice");
565 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
569 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
574 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
575 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
576 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
577 $(
"#prodiv"+ishow).data(
"iscat",0);
578 $(
"#prodiv"+ishow).attr(
"data-iscat",0);
580 $(
"#prowatermark"+ishow).hide();
589function ClickProduct(
position, qty = 1) {
590 console.log(
"ClickProduct at position"+
position);
591 if ($(
'#invoiceid').val() ==
"") {
592 invoiceid = $(
'#invoiceid').val();
595 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
596 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
597 if ($(
'#prodiv'+
position).data(
'iscat') == 1){
598 console.log(
"Click on a category at position "+
position);
602 console.log($(
'#prodiv4').data(
'rowid'));
603 invoiceid = $(
"#invoiceid").val();
604 idproduct=$(
'#prodiv'+
position).data(
'rowid');
605 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
606 if (idproduct ==
"") {
610 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&selectedline="+selectedline+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
612 echo
"CustomerDisplay();";
620function ChangeThirdparty(idcustomer) {
621 console.log(
"ChangeThirdparty");
623 $(
"#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() {
629function deleteline() {
630 invoiceid = $(
"#invoiceid").val();
631 console.log(
"Delete line invoiceid="+invoiceid);
632 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
639 console.log(
"Open box to select the thirdparty place="+place);
640 $.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
"); ?>"});
644 console.log(
"Open box to select the contact place="+place);
645 $.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"); ?>"});
650 console.log(
"Open box to select the history");
651 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist&search_module_source=takepos", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
654function Reduction() {
655 invoiceid = $(
"#invoiceid").val();
656 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
657 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
660var closeBillParams=
"";
661function CloseBill() {
663 $parameters = array();
664 $reshook = $hookmanager->executeHooks(
'paramsForCloseBill', $parameters, $obj, $action);
666 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
667 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".dol_escape_js($langs->transnoentitiesnoconv(
"Customer")).
"') { ";
668 echo
"alert('".dol_escape_js($langs->transnoentitiesnoconv(
"NoClientErrorMessage")).
"'); ";
672 invoiceid = $(
"#invoiceid").val();
673 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
675 if ($(
"#idcustomer").val() ==
"") {
676 alert(
"<?php echo dol_escape_js($langs->transnoentitiesnoconv('TakePosCustomerMandatory'), 2); ?>");
687 if (empty($alternative_payurl)) {
693 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid+closeBillParams, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
697 invoiceid = $(
"#invoiceid").val();
698 console.log(
"Open popup to split on invoiceid="+invoiceid);
699 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
703 console.log(
"Open box to select floor place="+place);
704 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
708 invoiceid = $(
"#invoiceid").val();
709 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
710 $.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
"); ?>"});
713function TakeposOrderNotes() {
714 console.log(
"Open box to order notes");
715 ModalBox(
'ModalNote');
716 $(
"#textinput").focus();
720 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
721 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
728 invoiceid = $(
"#invoiceid").val();
730 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
732 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
735 if (parseInt(data[
'paye']) === 1) {
738 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
743 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
748 $(
"#idcustomer").val(
"");
760function Search2(keyCodeForEnter, moreorless) {
761 var eventKeyCode =
null;
763 if (window.event && window.event.keyCode) {
764 eventKeyCode = window.event.keyCode;
766 if (eventKeyCode ===
null && keyCodeForEnter !==
'') {
771 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
773 var search_term = $(
'#search').val();
774 var search_start = 0;
775 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
776 if (moreorless !=
null) {
777 search_term = $(
'#search_pagination').val();
778 search_start = $(
'#search_start_'+moreorless).val();
781 console.log(
"search_term="+search_term);
783 if (search_term ==
'') {
784 $(
"[id^=prowatermark]").html(
"");
785 $(
"[id^=prodesc]").text(
"");
786 $(
"[id^=probutton]").text(
"");
787 $(
"[id^=probutton]").hide();
788 $(
"[id^=proprice]").attr(
"class",
"hidden");
789 $(
"[id^=proprice]").html(
"");
790 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
791 $(
"[id^=prodiv]").data(
"rowid",
"");
792 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
797 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
801 if (search ===
true) {
805 clearTimeout(search2_timer);
809 search2_timer = setTimeout(
function(){
811 jQuery(
".wrapper2 .catwatermark").hide();
812 var nbsearchresults = 0;
815 let socid = jQuery(
'#thirdpartyid').val();
816 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
817 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
820 $.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) {
821 for (i = 0; i < <?php echo($MAXPRODUCT - 2); ?>; i++) {
822 if (typeof (data[i]) ==
"undefined") {
823 $(
"#prowatermark" + i).html(
"");
824 $(
"#prodesc" + i).text(
"");
825 $(
"#probutton" + i).text(
"");
826 $(
"#probutton" + i).hide();
827 $(
"#proprice" + i).attr(
"class",
"hidden");
828 $(
"#proprice" + i).html(
"");
829 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
830 $(
"#prodiv" + i).data(
"rowid",
"");
831 $(
"#prodiv" + i).attr(
"data-rowid",
"");
835 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
836 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
838 var titlestring = <?php echo $titlestring; ?>;
840 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
841 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
842 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
844 $(
"#prodesc" + i).html(data[i][
'label']);
846 $(
"#prodivdesc" + i).show();
847 $(
"#probutton" + i).html(data[i][
'label']);
848 $(
"#probutton" + i).show();
849 if (data[i][
'price_formated']) {
850 $(
"#proprice" + i).attr(
"class",
"productprice");
854 $(
"#proprice" + i).html(data[i][
'price_formated']);
858 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
863 $(
"#proimg" + i).attr(
"title", titlestring);
864 if( undefined !== data[i][
'img']) {
865 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
868 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
870 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
871 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
872 $(
"#prodiv" + i).data(
"iscat", 0);
873 $(
"#prodiv" + i).attr(
"data-iscat", 0);
877 $parameters = array();
878 $parameters[
'caller'] =
'search2';
879 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
880 print $hookmanager->resPrint;
885 }).always(
function (data) {
887 if ($(
'#search').val().length > 0 && data.length == 1) {
888 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
889 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
890 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
891 ChangeThirdparty(data[0][
'rowid']);
893 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
894 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']);
895 ClickProduct(0, data[0][
'qty']);
898 if (eventKeyCode == keyCodeForEnter){
899 if (data.length == 0) {
900 $(
'#search').val(
'<?php
901 $langs->load('errors
');
902 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
903 ?> ('+search_term+
')');
904 $(
'#search').select();
906 else ClearSearch(
false);
909 $(
"#search_pagination").val($(
"#search").val());
910 if (search_start == 0) {
911 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
914 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
915 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
916 $(
"#search_start_less").val(search_start_less);
918 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
919 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
922 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
923 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
924 $(
"#search_start_more").val(search_start_more);
933function Edit(number) {
934 console.log(
"We click on PAD on key="+number);
936 if (typeof(selectedtext) ==
"undefined") {
940 var text=selectedtext+
"<br> ";
946 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
947 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
948 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
950 }
else if (number==
'qty') {
951 if (editaction==
'qty' && editnumber !=
'') {
952 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
955 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
958 setFocusOnSearchField();
964 }
else if (number==
'p') {
965 if (editaction==
'p' && editnumber!=
"") {
966 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
969 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
978 }
else if (number==
'r') {
979 if (editaction==
'r' && editnumber!=
"") {
980 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
983 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
994 editnumber=editnumber+number;
996 if (editaction==
'qty'){
997 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
998 $(
"#qty").html(
"OK").addClass(
"clicked");
999 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
1000 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
1002 if (editaction==
'p'){
1003 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
1004 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
1005 $(
"#price").html(
"OK").addClass(
"clicked");
1006 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
1008 if (editaction==
'r'){
1009 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
1010 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
1011 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
1012 $(
"#reduction").html(
"OK").addClass(
"clicked");
1014 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
1018function TakeposPrintingOrder(){
1019 console.log(
"TakeposPrintingOrder output invoice to print order");
1020 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
1025function TakeposPrintingTemp(){
1026 console.log(
"TakeposPrintingTemp");
1027 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
1032function OpenDrawer(){
1033 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
1036 data: { token:
'notrequired' },
1038 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1039 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
1041 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
1049function DolibarrOpenDrawer() {
1050 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
"]); ?>");
1053 data: { token:
'<?php echo currentToken(); ?>' },
1054 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
1058function MoreActions(totalactions) {
1059 for (i = 0; i <= totalactions; i++) {
1060 $(
"#action" + i).toggle();
1062 $(
"#actionnext").toggle();
1063 $(
"#actionprevious").toggle();
1066function ControlCashOpening()
1068 $.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
"); ?>"});
1071function CloseCashFence(rowid)
1073 $.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
"); ?>"});
1076function CashReport(rowid)
1078 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1082function ModalBox(ModalID)
1084 var modal = document.getElementById(ModalID);
1085 modal.style.display =
"block";
1088function DirectPayment(){
1089 console.log(
"DirectPayment");
1090 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1091 $(
'#invoiceid').val(
"");
1095function FullScreen() {
1096 document.documentElement.requestFullscreen();
1099function WeighingScale(){
1100 console.log(
"Weighing Scale");
1103 data: { token:
'notrequired' },
1104 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1106 .done(
function( editnumber ) {
1107 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1113$( document ).ready(
function() {
1119 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1120 print
"ModalBox('ModalTerminal');";
1128 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1129 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
1130 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1132 $resql = $db->query($sql);
1134 $obj = $db->fetch_object($resql);
1136 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1137 print
"ControlCashOpening();";
1144 var elem1 = $(
"#topnav-left")[0];
1145 var elem2 = $(
"#topnav-right")[0];
1146 var checkOverflow =
function() {
1147 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1148 else $(
"#topnav").removeClass(
"overflow");
1151 var scrollBars =
function(){
1152 var container= $(
'#topnav')[0];
1154 vertical:container.scrollHeight > container.clientHeight,
1155 horizontal:container.scrollWidth > container.clientWidth
1159 $(window).resize(
function(){
1163 let resizeObserver =
new ResizeObserver(() => {
1166 resizeObserver.observe(elem1);
1167 resizeObserver.observe(elem2);
1170 var pressTimer = [];
1174 $(
".indicator").mousedown(
function(){
1175 direction = $(
this).hasClass(
"left") ? -1 : 1;
1177 pressTimer.push(setInterval(scrollTo, 100));
1180 $(
".indicator").mouseup(
function(){
1181 pressTimer.forEach(clearInterval);
1184 $(
"body").mouseup(
function(){
1185 pressTimer.forEach(clearInterval);
1186 console.log(
"body mouseup");
1189 function scrollTo(){
1190 console.log(
"here");
1191 var pos = $(
"#topnav").scrollLeft();
1192 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1195 $(
"#topnav").scroll(
function(){
1196 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1204<div
class=
"container">
1209 <div
class=
"header">
1210 <div
id=
"topnav" class=
"topnav">
1211 <div
id=
"topnav-left" class=
"topnav-left">
1212 <div
class=
"inline-block valignmiddle">
1213 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1214 <span
class=
"fa fa-cash-register"></span>
1215 <span
class=
"hideonsmartphone">
1217 if (!empty($_SESSION[
"takeposterminal"])) {
1218 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1223 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1227 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1228 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1232 <!-- section
for customer -->
1233 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1234 <input
type=
"hidden" id=
"idcustomer" value=
"">
1235 <!-- section
for shopping carts -->
1236 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1237 <!-- More info about customer -->
1238 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1242 <!-- More info about warehouse -->
1243 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1247 <div
id=
"topnav-right" class=
"topnav-right">
1249 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1250 if ($reshook == 0) {
1252 <div
class=
"login_block_other takepos">
1253 <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>
1254 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1255 <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 -->
1256 <span
class=
"fas fa-home"></span></a>
1257 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1258 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1264 <div
class=
"login_block_user">
1266 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1270 <div
class=
"arrows">
1271 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1272 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1280<!-- Modal terminal box -->
1281<div
id=
"ModalTerminal" class=
"modal">
1282 <div
class=
"modal-content">
1283 <div
class=
"modal-header">
1287 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1290 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1292 <div
class=
"modal-body">
1293 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1296 for ($i = 2; $i <= $nbloop; $i++) {
1297 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1304<!-- Modal multicurrency box -->
1305<?php if (isModEnabled('multicurrency')) { ?>
1306<div id="ModalCurrency
" class="modal
">
1307 <div class="modal-content
">
1308 <div class="modal-header
">
1309 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1310 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1312 <div class="modal-body
">
1314 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1315 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1316 $resql = $db->query($sql);
1318 while ($obj = $db->fetch_object($resql)) {
1319 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1328<!-- Modal terminal Credit Note -->
1329<div id="ModalCreditNote
" class="modal
">
1330 <div class="modal-content
">
1331 <div class="modal-header
">
1332 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1333 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1335 <div class="modal-body
">
1336 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1337 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1343<div id="ModalNote
" class="modal
">
1344 <div class="modal-content
">
1345 <div class="modal-header
">
1346 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1347 <h3><?php print $langs->trans("Note
"); ?></h3>
1349 <div class="modal-body
">
1350 <input type="text
" class="block
" id="textinput
">
1351 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1360 <div id="poslines
" class="div1
">
1364 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1365 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1366 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1367 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1368 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1369 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1370 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1371 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1372 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1373 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1374 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1375 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1376 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1377 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1378 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1379 <?php if ($user->hasRight('takepos', 'editlines')) { ?>
1380 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1386// Dependency modulecheck
1387if (!isModEnabled('invoice')) {
1388 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("Invoice
")), null, 'errors');
1391// TakePOS setup check
1392if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1393 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1394 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1395 $sql .= " AND
active = 1
";
1396 $sql .= " ORDER BY libelle
";
1398 $resql = $db->query($sql);
1399 $paiementsModes = array();
1401 while ($obj = $db->fetch_object($resql)) {
1402 $paycode = $obj->code;
1403 if ($paycode == 'LIQ') {
1406 if ($paycode == 'CHQ') {
1407 $paycode = 'CHEQUE';
1410 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1411 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1412 if (getDolGlobalInt($constantforkey) > 0) {
1413 array_push($paiementsModes, $obj);
1418 if (empty($paiementsModes) && isModEnabled("bank
")) {
1419 $langs->load('errors');
1420 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1421 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1425if (count($maincategories) == 0) {
1426 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1427 $tmpcategory = new Categorie($db);
1428 $tmpcategory->fetch(getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID'));
1429 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1431 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1434// User menu and external TakePOS modules
1438if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1439 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1442if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1443 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1444 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1446 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1450if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1451 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1453 // BAR RESTAURANT specific menu
1454 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1457// Add a non predefined product
1458$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1460// BAR RESTAURANT specific menu "Print on kitchen/order printer
"
1461if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1462 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1463 $menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1466 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1467 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SentOrderToKitchen
").'</span>', 'action' => 'TakeposPrintingOrder();');
1472$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1474if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1475 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1478// Last action that close the sell (payments)
1479$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1480if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1481 $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();');
1484$customprinterallowed = false;
1486// BAR RESTAURANT specific menu
1487if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1488 // Button to print receipt before payment
1489 $customprinterallowed = true;
1490 $customprinttemplateallowed = true;
1491 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1492 if (isALNERunningVersion()) { // No need to show this option because it has no effect when isALNERunningVersion is true.
1493 $customprinttemplateallowed = false; // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
1497// Button to print receipt
1498if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") { // deprecated method
1499 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
1500 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div>', 'action' => 'TakeposConnector(placeid);');
1502 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1504} elseif ($customprinterallowed && (isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") { // @phpstan-ignore-line
1505 // Button Print Receipt on special printer
1506 $nameOfPrinter = dol_getIdFromCode($db, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term), 'printer_receipt', 'rowid', 'name', 1);
1507 $menus[$r++] = array('title' => '<div title="'.dolPrintHTMLForAttribute($langs->trans("PrintOn", $nameOfPrinter)).'"><span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div></div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1509 // Button Print Receipt on browser
1510 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div>', 'action' => 'Print(placeid);');
1513if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1514 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1518if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1519 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1521if (getDolGlobalInt('TAKEPOS_ADD_BUTTON_OPEN_DRAWER'.$term) > 0) {
1522 $menus[$r++] = array(
1523 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1524 'action' => 'DolibarrOpenDrawer();',
1528$sql = "SELECT rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1529$sql .= " entity =
".((int) $conf->entity)." AND
";
1530$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1531$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1532$sql .= " AND
status = 0
";
1534$resql = $db->query($sql);
1536 $num = $db->num_rows($resql);
1538 $obj = $db->fetch_object($resql);
1539 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1540 if ($obj->status == 0) {
1541 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1546if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1547 $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().'\';');
1550if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1551 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1554$parameters = array('menus' => $menus);
1555$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1556if ($reshook == 0) { //add buttons
1557 if (is_array($hookmanager->resArray)) {
1558 foreach ($hookmanager->resArray as $resArray) {
1559 foreach ($resArray as $butmenu) {
1560 $menus[$r++] = $butmenu;
1564} elseif ($reshook == 1) {
1565 $r = 0; //replace buttons
1566 if (is_array($hookmanager->resArray) ) {
1567 foreach ($hookmanager->resArray as $resArray) {
1568 foreach ($resArray as $butmenu) {
1569 $menus[$r++] = $butmenu;
1576 <!-- Show buttons -->
1577 <div id="dialogforpopuptakepos
"></div>
1579 /* Style de la popup */
1580 #dialogforpopuptakepos {
1589 box-shadow: 0 0 10px rgba(0,0,0,0.3);
1591 font-family: sans-serif;
1598 foreach ($menus as $menu) {
1600 if (count($menus) > 12 and $i == 12) {
1601 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1602 echo '<button style="display: none;
" type="button" id="actionprevious
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Previous
").'</button>';
1603 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1604 } elseif ($i > 12) {
1605 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1606 // TODO keep style but hide button
1608 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1612 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1613 print '<!-- Show the search input text -->'."\n
";
1614 print '<div class="margintoponly
">';
1615 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> ';
1616 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear.png').'</a>';
1627 <!-- Show categories -->
1629 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1630 print '<div class="div4
" style= "display: none;
">';
1632 print '<div class="div4
">';
1636 while ($count < $MAXCATEG) {
1638 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1639 echo 'onclick="MoreCategories(\
'less\')"';
1640 } elseif ($count == ($MAXCATEG - 1)) {
1641 echo
'onclick="MoreCategories(\'more\')"';
1643 echo
'onclick="LoadProducts('.$count.
')"';
1644 } ?>
id=
"catdiv<?php echo $count; ?>">
1646 if ($count == ($MAXCATEG - 2)) {
1648 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1649 } elseif ($count == ($MAXCATEG - 1)) {
1651 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1654 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1657 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1658 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1659 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1662 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1670 <!-- Show product -->
1671 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1672 print ' centpercent';
1677 while ($count < $MAXPRODUCT) {
1678 print
'<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ?
' arrow' :
'').
'" id="prodiv'.$count.
'" '; ?>
1679 <?php
if ($count == ($MAXPRODUCT - 2)) {
1680 ?> onclick=
"MoreProducts('less')" <?php
1682 if ($count == ($MAXPRODUCT - 1)) {
1683 ?> onclick=
"MoreProducts('more')" <?php
1685 echo
'onclick="ClickProduct('.((int) $count).
')"';
1688 if ($count == ($MAXPRODUCT - 2)) {
1690 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1691 } elseif ($count == ($MAXPRODUCT - 1)) {
1693 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1696 print
'<div class="" id="proprice'.$count.
'"></div>';
1699 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1701 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1704 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1705 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1706 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1709 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1715 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1716 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1717 <input
type=
"hidden" id=
"search_pagination" value=
"">
while( $i< min( $num, $limit))
The main.inc.php has been included so the following variable are now defined:
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)
dol_now($mode='gmt')
Return date for now.
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.
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.
isModEnabled($module)
Is Dolibarr module enabled.
multi select 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.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$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.