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); ?>;
191var place=
"<?php echo $place; ?>";
195var search2_timer=
null;
214function ClearSearch(clearSearchResults) {
215 console.log(
"ClearSearch");
216 $(
"#search").val(
'');
217 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
218 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
219 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
220 <?php
if ($conf->browser->layout ==
'classic') { ?>
221 setFocusOnSearchField();
223 if (clearSearchResults) {
224 $(
"#search").trigger(
'keyup');
229function setFocusOnSearchField() {
230 console.log(
"Call setFocusOnSearchField in page index.php");
231 <?php
if ($conf->browser->layout ==
'classic') { ?>
232 console.log(
"has keyboard from localStorage, so we can force focus on search field");
233 $(
"#search").focus();
237function PrintCategories(first) {
238 console.log(
"PrintCategories");
239 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
240 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
242 $(
"#catdivdesc"+i).hide();
243 $(
"#catdesc"+i).text(
"");
244 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
245 $(
"#catwatermark"+i).hide();
246 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
249 $(
"#catdivdesc"+i).show();
252 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
254 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
256 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
257 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
258 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
259 $(
"#catdiv"+i).attr(
'class',
'wrapper');
260 $(
"#catwatermark"+i).show();
264function MoreCategories(moreorless) {
265 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
266 if (moreorless ==
"more") {
267 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
268 $(
'#catimg15').animate({opacity:
'1'}, 100);
269 pagecategories=pagecategories+1;
271 if (moreorless ==
"less") {
272 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
273 $(
'#catimg14').animate({opacity:
'1'}, 100);
274 if (pagecategories==0)
return;
275 pagecategories=pagecategories-1;
277 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
278 pagecategories=pagecategories-1;
282 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
283 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
285 console.log(
"complete with empty record");
286 $(
"#catdivdesc"+i).hide();
287 $(
"#catdesc"+i).text(
"");
288 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
289 $(
"#catwatermark"+i).hide();
292 $(
"#catdivdesc"+i).show();
295 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
297 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
299 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
300 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
301 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
302 $(
"#catwatermark"+i).show();
309function LoadProducts(
position, issubcat) {
310 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
311 var maxproduct = <?php echo (
int) ($MAXPRODUCT - 2); ?>;
314 currentcat =
"supplements";
316 if (subcategories.count == 0) {
317 alert(
"No product found into categories level 2 or more");
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 if (currentcat !=
"supplements") {
337 console.log(
"Loop on each category level 2 or more");
338 jQuery.each(subcategories,
function(i, val) {
339 if (currentcat == val.fk_parent) {
340 $(
"#prodivdesc"+ishow).show();
341 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
342 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
343 $(
"#probutton"+ishow).html(val.label);
345 $(
"#prodesc"+ishow).text(val.label);
346 $(
"#probutton"+ishow).text(val.label);
348 $(
"#probutton"+ishow).show();
349 $(
"#proprice"+ishow).attr(
"class",
"hidden");
350 $(
"#proprice"+ishow).html(
"");
351 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
352 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
353 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
354 $(
"#prodiv"+ishow).data(
"iscat", 1);
355 $(
"#prodiv"+ishow).attr(
"data-iscat", 1);
356 $(
"#prodiv"+ishow).removeClass(
"divempty");
357 $(
"#prowatermark"+ishow).show();
365 if (maxproduct >= 1) {
366 limit = maxproduct - 1;
370 let socid = jQuery(
'#thirdpartyid').val();
371 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
372 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
376 $.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) {
378 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
379 console.log(
"Found "+data.length+
" record");
381 if (data.length == 0 && currentcat ==
"supplements") {
382 alert(
"No supplements found into the supplement category. Check the module setup and your product categories.");
385 while (ishow < maxproduct) {
386 console.log(
"ishow"+ishow+
" idata="+idata);
387 console.log(data[idata]);
389 if (typeof (data[idata]) ==
"undefined") {
391 echo
'$("#prodivdesc"+ishow).hide();';
392 echo
'$("#prodesc"+ishow).text("");';
393 echo
'$("#proimg"+ishow).attr("title","");';
394 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
396 echo
'$("#probutton"+ishow).hide();';
397 echo
'$("#probutton"+ishow).text("");';
399 $(
"#proprice"+ishow).attr(
"class",
"hidden");
400 $(
"#proprice"+ishow).html(
"");
402 $(
"#prodiv"+ishow).data(
"rowid",
"");
403 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
405 $(
"#prodiv"+ishow).data(
"iscat",
"0");
406 $(
"#prodiv"+ishow).attr(
"data-iscat",
"0");
408 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
411 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
412 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
414 var titlestring = <?php echo $titlestring; ?>;
416 echo
'$("#prodivdesc"+ishow).show();';
418 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
420 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
422 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
424 echo
'$("#proimg"+ishow).attr("title", titlestring);';
425 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
427 echo
'$("#probutton"+ishow).show();';
428 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
431 if (data[parseInt(idata)][
'price_formated']) {
432 $(
"#proprice" + ishow).attr(
"class",
"productprice");
436 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
440 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
445 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
447 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
448 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
449 console.log($(
'#prodiv4').data(
'rowid'));
451 $(
"#prodiv"+ishow).data(
"iscat", 0);
452 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
454 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
458 $parameters = array();
459 $parameters[
'caller'] =
'loadProducts';
460 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
461 print $hookmanager->resPrint;
464 $(
"#prowatermark"+ishow).hide();
473function MoreProducts(moreorless) {
474 console.log(
"MoreProducts");
476 if ($(
'#search_pagination').val() !=
'') {
477 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
480 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
482 if (moreorless==
"more"){
483 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
484 $(
'#proimg31').animate({opacity:
'1'}, 100);
485 pageproducts=pageproducts+1;
487 if (moreorless==
"less"){
488 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
489 $(
'#proimg30').animate({opacity:
'1'}, 100);
490 if (pageproducts==0)
return;
491 pageproducts=pageproducts-1;
497 if (maxproduct >= 1) {
498 limit = maxproduct-1;
501 var nb_cat_shown = $(
'.div5 div.wrapper2[data-iscat=1]').length;
502 var offset = <?php echo ($MAXPRODUCT - 2); ?> * pageproducts - nb_cat_shown;
505 let socid = jQuery(
'#thirdpartyid').val();
506 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
507 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
511 $.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) {
512 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
514 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
515 pageproducts=pageproducts-1;
519 while (ishow < maxproduct) {
520 if (typeof (data[idata]) ==
"undefined") {
521 $(
"#prodivdesc"+ishow).hide();
522 $(
"#prodesc"+ishow).text(
"");
523 $(
"#probutton"+ishow).text(
"");
524 $(
"#probutton"+ishow).hide();
525 $(
"#proprice"+ishow).attr(
"class",
"");
526 $(
"#proprice"+ishow).html(
"");
527 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
528 $(
"#prodiv"+ishow).data(
"rowid",
"");
529 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
531 $(
"#prodivdesc"+ishow).show();
533 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
534 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
535 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
537 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
539 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
540 $(
"#probutton"+ishow).show();
541 if (data[parseInt(idata)][
'price_formated']) {
542 $(
"#proprice" + ishow).attr(
"class",
"productprice");
546 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
550 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
555 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
556 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
557 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
558 $(
"#prodiv"+ishow).data(
"iscat",0);
560 $(
"#prowatermark"+ishow).hide();
569function ClickProduct(
position, qty = 1) {
570 console.log(
"ClickProduct at position"+
position);
571 if ($(
'#invoiceid').val() ==
"") {
572 invoiceid = $(
'#invoiceid').val();
575 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
576 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
577 if ($(
'#prodiv'+
position).data(
'iscat') == 1){
578 console.log(
"Click on a category at position "+
position);
582 console.log($(
'#prodiv4').data(
'rowid'));
583 invoiceid = $(
"#invoiceid").val();
584 idproduct=$(
'#prodiv'+
position).data(
'rowid');
585 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
586 if (idproduct ==
"") {
590 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&selectedline="+selectedline+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
592 echo
"CustomerDisplay();";
600function ChangeThirdparty(idcustomer) {
601 console.log(
"ChangeThirdparty");
603 $(
"#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() {
609function deleteline() {
610 invoiceid = $(
"#invoiceid").val();
611 console.log(
"Delete line invoiceid="+invoiceid);
612 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
619 console.log(
"Open box to select the thirdparty place="+place);
620 $.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
"); ?>"});
624 console.log(
"Open box to select the contact place="+place);
625 $.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"); ?>"});
630 console.log(
"Open box to select the history");
631 $.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
"); ?>"});
634function Reduction() {
635 invoiceid = $(
"#invoiceid").val();
636 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
637 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
640var closeBillParams=
"";
641function CloseBill() {
643 $parameters = array();
644 $reshook = $hookmanager->executeHooks(
'paramsForCloseBill', $parameters, $obj, $action);
646 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
647 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
648 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
652 invoiceid = $(
"#invoiceid").val();
653 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
655 if ($(
"#idcustomer").val() ==
"") {
656 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
667 if (empty($alternative_payurl)) {
673 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid+closeBillParams, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
677 invoiceid = $(
"#invoiceid").val();
678 console.log(
"Open popup to split on invoiceid="+invoiceid);
679 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
683 console.log(
"Open box to select floor place="+place);
684 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
688 invoiceid = $(
"#invoiceid").val();
689 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
690 $.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
"); ?>"});
693function TakeposOrderNotes() {
694 console.log(
"Open box to order notes");
695 ModalBox(
'ModalNote');
696 $(
"#textinput").focus();
700 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
701 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
708 invoiceid = $(
"#invoiceid").val();
710 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
712 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
715 if (parseInt(data[
'paye']) === 1) {
718 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
723 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
728 $(
"#idcustomer").val(
"");
740function Search2(keyCodeForEnter, moreorless) {
741 var eventKeyCode =
null;
743 if (window.event && window.event.keyCode) {
744 eventKeyCode = window.event.keyCode;
746 if (eventKeyCode ===
null && keyCodeForEnter !==
'') {
751 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
753 var search_term = $(
'#search').val();
754 var search_start = 0;
755 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
756 if (moreorless !=
null) {
757 search_term = $(
'#search_pagination').val();
758 search_start = $(
'#search_start_'+moreorless).val();
761 console.log(
"search_term="+search_term);
763 if (search_term ==
'') {
764 $(
"[id^=prowatermark]").html(
"");
765 $(
"[id^=prodesc]").text(
"");
766 $(
"[id^=probutton]").text(
"");
767 $(
"[id^=probutton]").hide();
768 $(
"[id^=proprice]").attr(
"class",
"hidden");
769 $(
"[id^=proprice]").html(
"");
770 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
771 $(
"[id^=prodiv]").data(
"rowid",
"");
772 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
777 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
781 if (search ===
true) {
785 clearTimeout(search2_timer);
789 search2_timer = setTimeout(
function(){
791 jQuery(
".wrapper2 .catwatermark").hide();
792 var nbsearchresults = 0;
795 let socid = jQuery(
'#thirdpartyid').val();
796 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
797 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
800 $.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) {
801 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
802 if (typeof (data[i]) ==
"undefined") {
803 $(
"#prowatermark" + i).html(
"");
804 $(
"#prodesc" + i).text(
"");
805 $(
"#probutton" + i).text(
"");
806 $(
"#probutton" + i).hide();
807 $(
"#proprice" + i).attr(
"class",
"hidden");
808 $(
"#proprice" + i).html(
"");
809 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
810 $(
"#prodiv" + i).data(
"rowid",
"");
811 $(
"#prodiv" + i).attr(
"data-rowid",
"");
815 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
816 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
818 var titlestring = <?php echo $titlestring; ?>;
820 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
821 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
822 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
824 $(
"#prodesc" + i).html(data[i][
'label']);
826 $(
"#prodivdesc" + i).show();
827 $(
"#probutton" + i).html(data[i][
'label']);
828 $(
"#probutton" + i).show();
829 if (data[i][
'price_formated']) {
830 $(
"#proprice" + i).attr(
"class",
"productprice");
834 $(
"#proprice" + i).html(data[i][
'price_formated']);
838 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
843 $(
"#proimg" + i).attr(
"title", titlestring);
844 if( undefined !== data[i][
'img']) {
845 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
848 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
850 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
851 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
852 $(
"#prodiv" + i).data(
"iscat", 0);
853 $(
"#prodiv" + i).attr(
"data-iscat", 0);
857 $parameters = array();
858 $parameters[
'caller'] =
'search2';
859 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
860 print $hookmanager->resPrint;
865 }).always(
function (data) {
867 if ($(
'#search').val().length > 0 && data.length == 1) {
868 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
869 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
870 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
871 ChangeThirdparty(data[0][
'rowid']);
873 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
874 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']);
875 ClickProduct(0, data[0][
'qty']);
878 if (eventKeyCode == keyCodeForEnter){
879 if (data.length == 0) {
880 $(
'#search').val(
'<?php
881 $langs->load('errors
');
882 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
883 ?> ('+search_term+
')');
884 $(
'#search').select();
886 else ClearSearch(
false);
889 $(
"#search_pagination").val($(
"#search").val());
890 if (search_start == 0) {
891 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
894 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
895 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
896 $(
"#search_start_less").val(search_start_less);
898 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
899 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
902 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
903 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
904 $(
"#search_start_more").val(search_start_more);
913function Edit(number) {
914 console.log(
"We click on PAD on key="+number);
916 if (typeof(selectedtext) ==
"undefined") {
920 var text=selectedtext+
"<br> ";
926 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
927 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
928 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
930 }
else if (number==
'qty') {
931 if (editaction==
'qty' && editnumber !=
'') {
932 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
935 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
938 setFocusOnSearchField();
944 }
else if (number==
'p') {
945 if (editaction==
'p' && editnumber!=
"") {
946 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
949 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
958 }
else if (number==
'r') {
959 if (editaction==
'r' && editnumber!=
"") {
960 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
963 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
974 editnumber=editnumber+number;
976 if (editaction==
'qty'){
977 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
978 $(
"#qty").html(
"OK").addClass(
"clicked");
979 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
980 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
982 if (editaction==
'p'){
983 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
984 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
985 $(
"#price").html(
"OK").addClass(
"clicked");
986 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
988 if (editaction==
'r'){
989 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
990 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
991 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
992 $(
"#reduction").html(
"OK").addClass(
"clicked");
994 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
998function TakeposPrintingOrder(){
999 console.log(
"TakeposPrintingOrder output invoice to print order");
1000 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
1005function TakeposPrintingTemp(){
1006 console.log(
"TakeposPrintingTemp");
1007 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
1012function OpenDrawer(){
1013 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
1016 data: { token:
'notrequired' },
1018 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1019 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
1021 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
1029function DolibarrOpenDrawer() {
1030 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
"]); ?>");
1033 data: { token:
'<?php echo currentToken(); ?>' },
1034 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
1038function MoreActions(totalactions) {
1039 for (i = 0; i <= totalactions; i++) {
1040 $(
"#action" + i).toggle();
1042 $(
"#actionnext").toggle();
1043 $(
"#actionprevious").toggle();
1046function ControlCashOpening()
1048 $.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
"); ?>"});
1051function CloseCashFence(rowid)
1053 $.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
"); ?>"});
1056function CashReport(rowid)
1058 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1062function ModalBox(ModalID)
1064 var modal = document.getElementById(ModalID);
1065 modal.style.display =
"block";
1068function DirectPayment(){
1069 console.log(
"DirectPayment");
1070 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1071 $(
'#invoiceid').val(
"");
1075function FullScreen() {
1076 document.documentElement.requestFullscreen();
1079function WeighingScale(){
1080 console.log(
"Weighing Scale");
1083 data: { token:
'notrequired' },
1084 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1086 .done(
function( editnumber ) {
1087 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1093$( document ).ready(
function() {
1099 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1100 print
"ModalBox('ModalTerminal');";
1108 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1109 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
1110 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1112 $resql = $db->query($sql);
1114 $obj = $db->fetch_object($resql);
1116 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1117 print
"ControlCashOpening();";
1124 var elem1 = $(
"#topnav-left")[0];
1125 var elem2 = $(
"#topnav-right")[0];
1126 var checkOverflow =
function() {
1127 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1128 else $(
"#topnav").removeClass(
"overflow");
1131 var scrollBars =
function(){
1132 var container= $(
'#topnav')[0];
1134 vertical:container.scrollHeight > container.clientHeight,
1135 horizontal:container.scrollWidth > container.clientWidth
1139 $(window).resize(
function(){
1143 let resizeObserver =
new ResizeObserver(() => {
1146 resizeObserver.observe(elem1);
1147 resizeObserver.observe(elem2);
1150 var pressTimer = [];
1154 $(
".indicator").mousedown(
function(){
1155 direction = $(
this).hasClass(
"left") ? -1 : 1;
1157 pressTimer.push(setInterval(scrollTo, 100));
1160 $(
".indicator").mouseup(
function(){
1161 pressTimer.forEach(clearInterval);
1164 $(
"body").mouseup(
function(){
1165 pressTimer.forEach(clearInterval);
1166 console.log(
"body mouseup");
1169 function scrollTo(){
1170 console.log(
"here");
1171 var pos = $(
"#topnav").scrollLeft();
1172 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1175 $(
"#topnav").scroll(
function(){
1176 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1184<div
class=
"container">
1189 <div
class=
"header">
1190 <div
id=
"topnav" class=
"topnav">
1191 <div
id=
"topnav-left" class=
"topnav-left">
1192 <div
class=
"inline-block valignmiddle">
1193 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1194 <span
class=
"fa fa-cash-register"></span>
1195 <span
class=
"hideonsmartphone">
1197 if (!empty($_SESSION[
"takeposterminal"])) {
1198 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1203 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1207 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1208 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1212 <!-- section
for customer -->
1213 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1214 <input
type=
"hidden" id=
"idcustomer" value=
"">
1215 <!-- section
for shopping carts -->
1216 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1217 <!-- More info about customer -->
1218 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1222 <!-- More info about warehouse -->
1223 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1227 <div
id=
"topnav-right" class=
"topnav-right">
1229 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1230 if ($reshook == 0) {
1232 <div
class=
"login_block_other takepos">
1233 <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>
1234 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1235 <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 -->
1236 <span
class=
"fas fa-home"></span></a>
1237 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1238 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1244 <div
class=
"login_block_user">
1246 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1250 <div
class=
"arrows">
1251 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1252 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1260<!-- Modal terminal box -->
1261<div
id=
"ModalTerminal" class=
"modal">
1262 <div
class=
"modal-content">
1263 <div
class=
"modal-header">
1267 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1270 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1272 <div
class=
"modal-body">
1273 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1276 for ($i = 2; $i <= $nbloop; $i++) {
1277 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1284<!-- Modal multicurrency box -->
1285<?php if (isModEnabled('multicurrency')) { ?>
1286<div id="ModalCurrency
" class="modal
">
1287 <div class="modal-content
">
1288 <div class="modal-header
">
1289 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1290 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1292 <div class="modal-body
">
1294 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1295 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1296 $resql = $db->query($sql);
1298 while ($obj = $db->fetch_object($resql)) {
1299 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1308<!-- Modal terminal Credit Note -->
1309<div id="ModalCreditNote
" class="modal
">
1310 <div class="modal-content
">
1311 <div class="modal-header
">
1312 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1313 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1315 <div class="modal-body
">
1316 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1317 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1323<div id="ModalNote
" class="modal
">
1324 <div class="modal-content
">
1325 <div class="modal-header
">
1326 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1327 <h3><?php print $langs->trans("Note
"); ?></h3>
1329 <div class="modal-body
">
1330 <input type="text
" class="block
" id="textinput
">
1331 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1340 <div id="poslines
" class="div1
">
1344 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1345 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1346 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1347 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1348 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1349 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1350 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1351 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1352 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1353 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1354 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1355 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1356 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1357 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1358 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1359 <?php if ($user->hasRight('takepos', 'editlines')) { ?>
1360 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1366// Dependency modulecheck
1367if (!isModEnabled('invoice')) {
1368 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("Invoice
")), null, 'errors');
1371// TakePOS setup check
1372if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1373 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1374 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1375 $sql .= " AND
active = 1
";
1376 $sql .= " ORDER BY libelle
";
1378 $resql = $db->query($sql);
1379 $paiementsModes = array();
1381 while ($obj = $db->fetch_object($resql)) {
1382 $paycode = $obj->code;
1383 if ($paycode == 'LIQ') {
1386 if ($paycode == 'CHQ') {
1387 $paycode = 'CHEQUE';
1390 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1391 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1392 if (getDolGlobalInt($constantforkey) > 0) {
1393 array_push($paiementsModes, $obj);
1398 if (empty($paiementsModes) && isModEnabled("bank
")) {
1399 $langs->load('errors');
1400 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1401 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1405if (count($maincategories) == 0) {
1406 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1407 $tmpcategory = new Categorie($db);
1408 $tmpcategory->fetch(getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID'));
1409 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1411 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1414// User menu and external TakePOS modules
1418if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1419 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1422if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1423 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1424 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1426 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1430if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1431 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1433 // BAR RESTAURANT specific menu
1434 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1437// Add a non predefined product
1438$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1440// BAR RESTAURANT specific menu "Print on kitchen/order printer
"
1441if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1442 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1443 $menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1446 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1447 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SentOrderToKitchen
").'</span>', 'action' => 'TakeposPrintingOrder();');
1452$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1454if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1455 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1458// Last action that close the sell (payments)
1459$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1460if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1461 $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();');
1464$customprinterallowed = false;
1466// BAR RESTAURANT specific menu
1467if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1468 // Button to print receipt before payment
1469 $customprinterallowed = true;
1470 $customprinttemplateallowed = true;
1471 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1472 if (isALNERunningVersion()) { // No need to show this option because it has no effect when isALNERunningVersion is true.
1473 $customprinttemplateallowed = false; // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
1477// Button to print receipt
1478if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") { // deprecated method
1479 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
1480 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div>', 'action' => 'TakeposConnector(placeid);');
1482 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1484} elseif ($customprinterallowed && (isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") { // @phpstan-ignore-line
1485 // Button Print Receipt on special printer
1486 $nameOfPrinter = dol_getIdFromCode($db, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term), 'printer_receipt', 'rowid', 'name', 1);
1487 $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);');
1489 // Button Print Receipt on browser
1490 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div>', 'action' => 'Print(placeid);');
1493if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1494 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1498if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1499 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1501if (getDolGlobalInt('TAKEPOS_ADD_BUTTON_OPEN_DRAWER'.$term) > 0) {
1502 $menus[$r++] = array(
1503 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1504 'action' => 'DolibarrOpenDrawer();',
1508$sql = "SELECT rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1509$sql .= " entity =
".((int) $conf->entity)." AND
";
1510$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1511$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1512$sql .= " AND
status = 0
";
1514$resql = $db->query($sql);
1516 $num = $db->num_rows($resql);
1518 $obj = $db->fetch_object($resql);
1519 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1520 if ($obj->status == 0) {
1521 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1526if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1527 $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().'\';');
1530if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1531 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1534$parameters = array('menus' => $menus);
1535$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1536if ($reshook == 0) { //add buttons
1537 if (is_array($hookmanager->resArray)) {
1538 foreach ($hookmanager->resArray as $resArray) {
1539 foreach ($resArray as $butmenu) {
1540 $menus[$r++] = $butmenu;
1544} elseif ($reshook == 1) {
1545 $r = 0; //replace buttons
1546 if (is_array($hookmanager->resArray) ) {
1547 foreach ($hookmanager->resArray as $resArray) {
1548 foreach ($resArray as $butmenu) {
1549 $menus[$r++] = $butmenu;
1556 <!-- Show buttons -->
1557 <div id="dialogforpopuptakepos
"></div>
1559 /* Style de la popup */
1560 #dialogforpopuptakepos {
1569 box-shadow: 0 0 10px rgba(0,0,0,0.3);
1571 font-family: sans-serif;
1578 foreach ($menus as $menu) {
1580 if (count($menus) > 12 and $i == 12) {
1581 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1582 echo '<button style="display: none;
" type="button" id="actionprevious
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Previous
").'</button>';
1583 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1584 } elseif ($i > 12) {
1585 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1586 // TODO keep style but hide button
1588 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1592 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1593 print '<!-- Show the search input text -->'."\n
";
1594 print '<div class="margintoponly
">';
1595 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> ';
1596 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear.png').'</a>';
1607 <!-- Show categories -->
1609 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1610 print '<div class="div4
" style= "display: none;
">';
1612 print '<div class="div4
">';
1616 while ($count < $MAXCATEG) {
1618 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1619 echo 'onclick="MoreCategories(\
'less\')"';
1620 } elseif ($count == ($MAXCATEG - 1)) {
1621 echo
'onclick="MoreCategories(\'more\')"';
1623 echo
'onclick="LoadProducts('.$count.
')"';
1624 } ?>
id=
"catdiv<?php echo $count; ?>">
1626 if ($count == ($MAXCATEG - 2)) {
1628 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1629 } elseif ($count == ($MAXCATEG - 1)) {
1631 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1634 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1637 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1638 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1639 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1642 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1650 <!-- Show product -->
1651 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1652 print ' centpercent';
1657 while ($count < $MAXPRODUCT) {
1658 print
'<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ?
' arrow' :
'').
'" id="prodiv'.$count.
'" '; ?>
1659 <?php
if ($count == ($MAXPRODUCT - 2)) {
1660 ?> onclick=
"MoreProducts('less')" <?php
1662 if ($count == ($MAXPRODUCT - 1)) {
1663 ?> onclick=
"MoreProducts('more')" <?php
1665 echo
'onclick="ClickProduct('.((int) $count).
')"';
1668 if ($count == ($MAXPRODUCT - 2)) {
1670 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1671 } elseif ($count == ($MAXPRODUCT - 1)) {
1673 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1676 print
'<div class="" id="proprice'.$count.
'"></div>';
1679 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1681 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1684 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1685 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1686 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1689 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1695 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1696 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1697 <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)
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.