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'];
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, qty_std = 0) {
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 invoiceid = $(
"#invoiceid").val();
583 idproduct=$(
'#prodiv'+
position).data(
'rowid');
584 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
585 if (idproduct ==
"") {
589 addInvoiceLine =
function(qty, qty_std_inner = 0) {
591 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&selectedline="+selectedline+
"&qty="+qty+
"&invoiceid="+invoiceid+(qty_std_inner ?
'&qty_std=1' :
''), function() {
594 echo
"CustomerDisplay();";
601 if ($(
'#prodiv'+
position).data(
'unit') == 2) {
602 WeighingScale(addInvoiceLine);
604 addInvoiceLine(qty, qty_std);
607 addInvoiceLine(qty, qty_std);
614function ChangeThirdparty(idcustomer) {
615 console.log(
"ChangeThirdparty");
617 $(
"#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() {
623function deleteline() {
624 invoiceid = $(
"#invoiceid").val();
625 console.log(
"Delete line invoiceid="+invoiceid);
626 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
633 console.log(
"Open box to select the thirdparty place="+place);
634 $.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
"); ?>"});
638 console.log(
"Open box to select the contact place="+place);
639 $.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"); ?>"});
644 console.log(
"Open box to select the history");
645 $.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
"); ?>"});
648function Reduction() {
649 invoiceid = $(
"#invoiceid").val();
650 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
651 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
654var closeBillParams=
"";
655function CloseBill() {
657 $parameters = array();
658 $reshook = $hookmanager->executeHooks(
'paramsForCloseBill', $parameters, $obj, $action);
660 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
661 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
662 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
666 invoiceid = $(
"#invoiceid").val();
667 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
669 if ($(
"#idcustomer").val() ==
"") {
670 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
681 if (empty($alternative_payurl)) {
687 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid+closeBillParams, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
691 invoiceid = $(
"#invoiceid").val();
692 console.log(
"Open popup to split on invoiceid="+invoiceid);
693 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
697 console.log(
"Open box to select floor place="+place);
698 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
702 invoiceid = $(
"#invoiceid").val();
703 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
704 $.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
"); ?>"});
707function TakeposOrderNotes() {
708 console.log(
"Open box to order notes");
709 ModalBox(
'ModalNote');
710 $(
"#textinput").focus();
714 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
715 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
722 invoiceid = $(
"#invoiceid").val();
724 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
726 if (invoiceid ==
'') {
727 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
732 $(
"#idcustomer").val(
"");
736 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
739 if (parseInt(data[
'paye']) === 1) {
742 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
747 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
752 $(
"#idcustomer").val(
"");
763function Search2(keyCodeForEnter, moreorless) {
764 var eventKeyCode =
null;
766 if (window.event && window.event.keyCode) {
767 eventKeyCode = window.event.keyCode;
769 if (eventKeyCode ===
null && keyCodeForEnter !==
'') {
774 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
776 var search_term = $(
'#search').val();
777 var search_start = 0;
778 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
779 if (moreorless !=
null) {
780 search_term = $(
'#search_pagination').val();
781 search_start = $(
'#search_start_'+moreorless).val();
784 console.log(
"search_term="+search_term);
786 if (search_term ==
'') {
787 $(
"[id^=prowatermark]").html(
"");
788 $(
"[id^=prodesc]").text(
"");
789 $(
"[id^=probutton]").text(
"");
790 $(
"[id^=probutton]").hide();
791 $(
"[id^=proprice]").attr(
"class",
"hidden");
792 $(
"[id^=proprice]").html(
"");
793 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
794 $(
"[id^=prodiv]").data(
"rowid",
"");
795 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
800 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
804 if (search ===
true) {
808 clearTimeout(search2_timer);
812 search2_timer = setTimeout(
function(){
814 jQuery(
".wrapper2 .catwatermark").hide();
815 var nbsearchresults = 0;
818 let socid = jQuery(
'#thirdpartyid').val();
819 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
820 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
823 $.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) {
824 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
825 if (typeof (data[i]) ==
"undefined") {
826 $(
"#prowatermark" + i).html(
"");
827 $(
"#prodesc" + i).text(
"");
828 $(
"#probutton" + i).text(
"");
829 $(
"#probutton" + i).hide();
830 $(
"#proprice" + i).attr(
"class",
"hidden");
831 $(
"#proprice" + i).html(
"");
832 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
833 $(
"#prodiv" + i).data(
"rowid",
"");
834 $(
"#prodiv" + i).attr(
"data-rowid",
"");
838 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
839 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
841 var titlestring = <?php echo $titlestring; ?>;
843 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
844 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
845 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
847 $(
"#prodesc" + i).html(data[i][
'label']);
849 $(
"#prodivdesc" + i).show();
850 $(
"#probutton" + i).html(data[i][
'label']);
851 $(
"#probutton" + i).show();
852 if (data[i][
'price_formated']) {
853 $(
"#proprice" + i).attr(
"class",
"productprice");
857 $(
"#proprice" + i).html(data[i][
'price_formated']);
861 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
866 $(
"#proimg" + i).attr(
"title", titlestring);
867 if( undefined !== data[i][
'img']) {
868 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
871 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
873 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
874 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
875 $(
"#prodiv" + i).data(
"iscat", 0);
876 $(
"#prodiv" + i).attr(
"data-iscat", 0);
880 $parameters = array();
881 $parameters[
'caller'] =
'search2';
882 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
883 print $hookmanager->resPrint;
888 }).always(
function (data) {
890 if ($(
'#search').val().length > 0 && data.length == 1) {
891 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
892 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
893 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
894 ChangeThirdparty(data[0][
'rowid']);
896 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
897 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']);
898 ClickProduct(0, data[0][
'qty'], 1);
901 if (eventKeyCode == keyCodeForEnter){
902 if (data.length == 0) {
903 $(
'#search').val(
'<?php
904 $langs->load('errors
');
905 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
906 ?> ('+search_term+
')');
907 $(
'#search').select();
909 else ClearSearch(
false);
912 $(
"#search_pagination").val($(
"#search").val());
913 if (search_start == 0) {
914 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
917 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
918 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
919 $(
"#search_start_less").val(search_start_less);
921 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
922 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
925 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
926 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
927 $(
"#search_start_more").val(search_start_more);
936function Edit(number) {
937 console.log(
"We click on PAD on key="+number);
939 if (typeof(selectedtext) ==
"undefined") {
943 var text=selectedtext+
"<br> ";
949 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
950 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
951 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
953 }
else if (number==
'qty') {
954 if (editaction==
'qty' && editnumber !=
'') {
955 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
958 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
961 setFocusOnSearchField();
967 }
else if (number==
'p') {
968 if (editaction==
'p' && editnumber!=
"") {
969 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
972 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
981 }
else if (number==
'r') {
982 if (editaction==
'r' && editnumber!=
"") {
983 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
986 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
997 editnumber=editnumber+number;
999 if (editaction==
'qty'){
1000 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
1001 $(
"#qty").html(
"OK").addClass(
"clicked");
1002 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
1003 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
1005 if (editaction==
'p'){
1006 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
1007 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
1008 $(
"#price").html(
"OK").addClass(
"clicked");
1009 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
1011 if (editaction==
'r'){
1012 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
1013 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
1014 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
1015 $(
"#reduction").html(
"OK").addClass(
"clicked");
1017 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
1021function TakeposPrintingOrder(){
1022 console.log(
"TakeposPrintingOrder output invoice to print order");
1023 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
1028function TakeposPrintingTemp(){
1029 console.log(
"TakeposPrintingTemp");
1030 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
1035function OpenDrawer(){
1036 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
1039 data: { token:
'notrequired' },
1041 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var(
$conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1042 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
1044 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
1052function DolibarrOpenDrawer() {
1053 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
"]); ?>");
1056 data: { token:
'<?php echo currentToken(); ?>' },
1057 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
1061function MoreActions(totalactions) {
1062 for (i = 0; i <= totalactions; i++) {
1063 $(
"#action" + i).toggle();
1065 $(
"#actionnext").toggle();
1066 $(
"#actionprevious").toggle();
1069function ControlCashOpening()
1071 $.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
"); ?>"});
1074function CloseCashFence(rowid)
1076 $.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
"); ?>"});
1079function CashReport(rowid)
1081 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1088function ModalBox(ModalID)
1090 var modal = document.getElementById(ModalID);
1091 modal.style.display =
"block";
1094function DirectPayment(){
1095 console.log(
"DirectPayment");
1096 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1097 $(
'#invoiceid').val(
"");
1101function FullScreen() {
1102 document.documentElement.requestFullscreen();
1105function WeighingScale(callback) {
1106 console.log(
"Weighing Scale: invoiceid = " + placeid +
", lineid = " + selectedline);
1111 if (idproduct ==
"" && selectedline > 0) {
1112 urlProduct =
"<?php echo DOL_URL_ROOT; ?>/api/index.php/takeposconnector/invoices/" + placeid +
"/lines/" + selectedline +
"/product";
1114 urlProduct =
"<?php echo DOL_URL_ROOT; ?>/api/index.php/products/" + idproduct;
1118 headers: {
"DOLAPIKEY":
'<?php echo $user->api_key; ?>' },
1121 .done(
function(product) {
1122 if (callback === undefined) {
1123 callback =
function(qty) {
1124 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&action=updateqty&place="+place+
"&idline="+selectedline+
"&number="+qty);
1127 if (product.fk_unit ==
"2") {
1128 askForWeight(product.multiprices_ttc[1], callback, function (errorMessage) {
1129 console.log(
"Erreur: " + errorMessage);
1135 editnumber = globalWeight;
1136 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&action=updateqty&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1143 data: { token:
'notrequired' },
1144 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1146 .done(
function( editnumber ) {
1147 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&action=updateqty&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1154$( document ).ready(
function() {
1160 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1161 print
"ModalBox('ModalTerminal');";
1169 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1170 $sql .=
" entity = ".((int)
$conf->entity).
" AND ";
1171 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1173 $resql =
$db->query($sql);
1175 $obj =
$db->fetch_object($resql);
1177 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1178 print
"ControlCashOpening();";
1185 var elem1 = $(
"#topnav-left")[0];
1186 var elem2 = $(
"#topnav-right")[0];
1187 var checkOverflow =
function() {
1188 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1189 else $(
"#topnav").removeClass(
"overflow");
1192 var scrollBars =
function(){
1193 var container= $(
'#topnav')[0];
1195 vertical:container.scrollHeight > container.clientHeight,
1196 horizontal:container.scrollWidth > container.clientWidth
1200 $(window).resize(
function(){
1204 let resizeObserver =
new ResizeObserver(() => {
1207 resizeObserver.observe(elem1);
1208 resizeObserver.observe(elem2);
1211 var pressTimer = [];
1215 $(
".indicator").mousedown(
function(){
1216 direction = $(
this).hasClass(
"left") ? -1 : 1;
1218 pressTimer.push(setInterval(scrollTo, 100));
1221 $(
".indicator").mouseup(
function(){
1222 pressTimer.forEach(clearInterval);
1225 $(
"body").mouseup(
function(){
1226 pressTimer.forEach(clearInterval);
1227 console.log(
"body mouseup");
1230 function scrollTo(){
1231 console.log(
"here");
1232 var pos = $(
"#topnav").scrollLeft();
1233 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1236 $(
"#topnav").scroll(
function(){
1237 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1245<div
class=
"container">
1250 <div
class=
"header">
1251 <div
id=
"topnav" class=
"topnav">
1252 <div
id=
"topnav-left" class=
"topnav-left">
1253 <div
class=
"inline-block valignmiddle">
1254 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1255 <span
class=
"fa fa-cash-register"></span>
1256 <span
class=
"hideonsmartphone">
1258 if (!empty($_SESSION[
"takeposterminal"])) {
1259 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1264 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1268 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1269 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1273 <!-- section
for customer -->
1274 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1275 <input
type=
"hidden" id=
"idcustomer" value=
"">
1276 <!-- section
for shopping carts -->
1277 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1278 <!-- More info about customer -->
1279 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1283 <!-- More info about warehouse -->
1284 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1288 <div
id=
"topnav-right" class=
"topnav-right">
1290 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1291 if ($reshook == 0) {
1293 <div
class=
"login_block_other takepos">
1294 <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>
1295 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1296 <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 -->
1297 <span
class=
"fas fa-home"></span></a>
1298 <?php
if (empty(
$conf->dol_use_jmobile)) { ?>
1299 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1305 <div
class=
"login_block_user">
1307 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1311 <div
class=
"arrows">
1312 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1313 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1321<!-- Modal terminal box -->
1322<div
id=
"ModalTerminal" class=
"modal">
1323 <div
class=
"modal-content">
1324 <div
class=
"modal-header">
1328 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1331 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1333 <div
class=
"modal-body">
1334 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1337 for ($i = 2; $i <= $nbloop; $i++) {
1338 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1345<!-- Modal multicurrency box -->
1346<?php if (isModEnabled('multicurrency')) { ?>
1347<div id="ModalCurrency
" class="modal
">
1348 <div class="modal-content
">
1349 <div class="modal-header
">
1350 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1351 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1353 <div class="modal-body
">
1355 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1356 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1357 $resql = $db->query($sql);
1359 while ($obj = $db->fetch_object($resql)) {
1360 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.urlencode($obj->code).
'\'">'.$obj->code.'</button>';
1369<!-- Modal popup to create a Credit Note -->
1370<div id="ModalCreditNote
" class="modal
">
1371 <div class="modal-content
">
1372 <div class="modal-header
">
1373 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1374 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1376 <div class="modal-body
">
1377 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1378 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1384<div id="ModalNote
" class="modal
">
1385 <div class="modal-content
">
1386 <div class="modal-header
">
1387 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1388 <h3><?php print $langs->trans("Note
"); ?></h3>
1390 <div class="modal-body
">
1391 <input type="text
" class="block
" id="textinput
">
1392 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1401 <div id="poslines
" class="div1
">
1405 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1406 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1407 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1408 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1409 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1410 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1411 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1412 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1413 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1414 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1415 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1416 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1417 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1418 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1419 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1420 <?php if ($user->hasRight('takepos', 'editlines')) { ?>
1421 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1427// Dependency modulecheck
1428if (!isModEnabled('invoice')) {
1429 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("Invoice
")), null, 'errors');
1432// TakePOS setup check
1433if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1434 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1435 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1436 $sql .= " AND
active = 1
";
1437 $sql .= " ORDER BY libelle
";
1439 $resql = $db->query($sql);
1440 $paiementsModes = array();
1442 while ($obj = $db->fetch_object($resql)) {
1443 $paycode = $obj->code;
1444 if ($paycode == 'LIQ') {
1447 if ($paycode == 'CHQ') {
1448 $paycode = 'CHEQUE';
1451 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1452 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1453 if (getDolGlobalInt($constantforkey) > 0) {
1454 array_push($paiementsModes, $obj);
1459 if (empty($paiementsModes) && isModEnabled("bank
")) {
1460 $langs->load('errors');
1461 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1462 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1466if (count($maincategories) == 0) {
1467 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1468 $tmpcategory = new Categorie($db);
1469 $tmpcategory->fetch(getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID'));
1470 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1472 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1475// User menu and external TakePOS modules
1479if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1480 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1483if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1484 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1485 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1487 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1491if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1492 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1494 // BAR RESTAURANT specific menu
1495 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1498// Add a non predefined product
1499if (!getDolGlobalString('TAKEPOS_NO_FREE_ZONE_PRODUCT')) {
1500 $menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1503// BAR RESTAURANT specific menu "Print on kitchen/order printer
"
1504if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1505 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1506 $menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1509 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1510 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SentOrderToKitchen
").'</span>', 'action' => 'TakeposPrintingOrder();');
1515$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1517if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1518 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1521// Last action that close the sell (payments)
1522$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1523if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1524 $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();');
1527$customprinterallowed = false;
1528$customprinttemplateallowed = true;
1530// BAR RESTAURANT specific menu
1531if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1532 // Button to print receipt before payment
1533 $customprinterallowed = true;
1534 $customprinttemplateallowed = true;
1537include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1538if (isALNERunningVersion()) {
1539 // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
1540 $customprinttemplateallowed = false;
1543// Button to print receipt
1544// This section should be same than into invoice.php
1545if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") { // deprecated method
1546 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
1547 // If TAKEPOS_PRINT_SERVER is an URL
1548 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div>', 'action' => 'PrintByESCPOSOld(placeid);');
1550 // If TAKEPOS_PRINT_SERVER is an IP
1551 // Print by calling the receipt.php to get HTML content and send the HTML content to TAKEPOS_PRINT_SERVER:8111/print
1552 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div>', 'action' => 'PrintHTMLToSlashPrint(placeid);');
1554} elseif ($customprinterallowed && $customprinttemplateallowed && (isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") { // @phpstan-ignore-line
1555 // Button Print Receipt on special custom printer using custom template
1556 $nameOfPrinter = dol_getIdFromCode($db, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term), 'printer_receipt', 'rowid', 'name', 1);
1557 $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' => 'PrintByESCPOS(placeid);');
1559 // Button Print Receipt on browser
1560 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("PrintTicket
").'</div>', 'action' => 'PrintByBrowser(placeid);');
1563if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1564 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1568if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1569 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1571if (getDolGlobalInt('TAKEPOS_ADD_BUTTON_OPEN_DRAWER'.$term) > 0) {
1572 $menus[$r++] = array(
1573 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1574 'action' => 'DolibarrOpenDrawer();',
1578// If there is an open cash control started
1579$sql = "SELECT rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1580$sql .= " entity =
".((int) $conf->entity)." AND
";
1581$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1582$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1583$sql .= " AND
status = 0
";
1585$resql = $db->query($sql);
1587 $num = $db->num_rows($resql);
1589 $obj = $db->fetch_object($resql);
1590 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1591 if ($obj->status == 0) {
1592 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1597if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1598 $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().'\';');
1601if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1602 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1605$parameters = array('menus' => $menus);
1606$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1607if ($reshook == 0) { //add buttons
1608 if (is_array($hookmanager->resArray)) {
1609 foreach ($hookmanager->resArray as $resArray) {
1610 foreach ($resArray as $butmenu) {
1611 $menus[$r++] = $butmenu;
1615} elseif ($reshook == 1) {
1616 $r = 0; //replace buttons
1617 if (is_array($hookmanager->resArray)) {
1618 foreach ($hookmanager->resArray as $resArray) {
1619 foreach ($resArray as $butmenu) {
1620 $menus[$r++] = $butmenu;
1627 <!-- Show buttons -->
1628 <div id="dialogforpopuptakepos
"></div>
1630 /* Style de la popup */
1631 #dialogforpopuptakepos {
1640 box-shadow: 0 0 10px rgba(0,0,0,0.3);
1642 font-family: sans-serif;
1649 foreach ($menus as $menu) {
1651 if (count($menus) > 12 and $i == 12) {
1652 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1653 echo '<button style="display: none;
" type="button" id="actionprevious
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Previous
").'</button>';
1654 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1655 } elseif ($i > 12) {
1656 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1657 // TODO keep style but hide button
1659 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1663 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1664 print '<!-- Show the search input text -->'."\n
";
1665 print '<div class="margintoponly
">';
1666 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> ';
1667 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear.png').'</a>';
1678 <!-- Show categories -->
1680 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1681 print '<div class="div4
" style= "display: none;
">';
1683 print '<div class="div4
">';
1687 while ($count < $MAXCATEG) {
1689 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1690 echo 'onclick="MoreCategories(\
'less\')"';
1691 } elseif ($count == ($MAXCATEG - 1)) {
1692 echo
'onclick="MoreCategories(\'more\')"';
1694 echo
'onclick="LoadProducts('.$count.
')"';
1695 } ?>
id=
"catdiv<?php echo $count; ?>">
1697 if ($count == ($MAXCATEG - 2)) {
1699 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1700 } elseif ($count == ($MAXCATEG - 1)) {
1702 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1705 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1708 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1709 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1710 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1713 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1721 <!-- Show product -->
1722 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1723 print ' centpercent';
1728 while ($count < $MAXPRODUCT) {
1729 print
'<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ?
' arrow' :
'').
'" id="prodiv'.$count.
'" '; ?>
1730 <?php
if ($count == ($MAXPRODUCT - 2)) {
1731 ?> onclick=
"MoreProducts('less')" <?php
1733 if ($count == ($MAXPRODUCT - 1)) {
1734 ?> onclick=
"MoreProducts('more')" <?php
1736 echo
'onclick="ClickProduct('.((int) $count).
')"';
1739 if ($count == ($MAXPRODUCT - 2)) {
1741 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1742 } elseif ($count == ($MAXPRODUCT - 1)) {
1744 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1747 print
'<div class="" id="proprice'.$count.
'"></div>';
1750 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1752 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1755 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1756 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1757 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1760 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1766 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1767 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1768 <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...
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.