32if (!defined(
'NOREQUIREMENU')) {
33 define(
'NOREQUIREMENU',
'1');
35if (!defined(
'NOREQUIREHTML')) {
36 define(
'NOREQUIREHTML',
'1');
38if (!defined(
'NOREQUIREAJAX')) {
39 define(
'NOREQUIREAJAX',
'1');
43require
'../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
54$action =
GETPOST(
'action',
'aZ09');
56$setcurrency =
GETPOST(
'setcurrency',
'aZ09');
58$hookmanager->initHooks(array(
'takeposfrontend'));
59if (empty($_SESSION[
"takeposterminal"])) {
61 $_SESSION[
"takeposterminal"] = 1;
62 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
63 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
67if ($setterminal > 0) {
68 $_SESSION[
"takeposterminal"] = $setterminal;
69 setcookie(
"takeposterminal", (
string) $setterminal, (time() + (86400 * 354)),
'/',
'', !empty($dolibarr_main_force_https),
true);
72if ($setcurrency !=
"") {
73 $_SESSION[
"takeposcustomercurrency"] = $setcurrency;
78$langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter",
"banks"));
82$maxcategbydefaultforthisdevice = 12;
83$maxproductbydefaultforthisdevice = 24;
84if ($conf->browser->layout ==
'phone') {
85 $maxcategbydefaultforthisdevice = 8;
86 $maxproductbydefaultforthisdevice = 16;
89 $_SESSION[
"basiclayout"] = 1;
90 header(
"Location: phone.php?mobilepage=invoice");
94 unset($_SESSION[
"basiclayout"]);
96$MAXCATEG = (!
getDolGlobalString(
'TAKEPOS_NB_MAXCATEG') ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
97$MAXPRODUCT = (!
getDolGlobalString(
'TAKEPOS_NB_MAXPRODUCT') ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
99$term = empty($_SESSION[
'takeposterminal']) ? 1 : $_SESSION[
'takeposterminal'];
117$form =
new Form($db);
121$arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
122$arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
125 $arrayofcss[] =
'/takepos/css/colorful.css';
130$title =
'TakePOS - Dolibarr '.DOL_VERSION;
134$head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
135<meta name="apple-mobile-web-app-capable" content="yes">
136<meta name="mobile-web-app-capable" content="yes">
137<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
138top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
141$categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
146$levelofrootcategory = 0;
148 foreach ($categories as $key => $categorycursor) {
150 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
151 $levelofrootcategory = $categorycursor[
'level'];
157$levelofmaincategories = $levelofrootcategory + 1;
159$maincategories = array();
160$subcategories = array();
161foreach ($categories as $key => $categorycursor) {
162 if ($categorycursor[
'level'] == $levelofmaincategories) {
163 $maincategories[$key] = $categorycursor;
165 $subcategories[$key] = $categorycursor;
173<body
class=
"bodytakepos" style=
"overflow: hidden;">
176var categories = <?php echo json_encode($maincategories); ?>;
177var subcategories = <?php echo json_encode($subcategories); ?>;
183var place=
"<?php echo $place; ?>";
187var search2_timer=
null;
206function ClearSearch(clearSearchResults) {
207 console.log(
"ClearSearch");
208 $(
"#search").val(
'');
209 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
210 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
211 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
212 <?php
if ($conf->browser->layout ==
'classic') { ?>
213 setFocusOnSearchField();
215 if (clearSearchResults) {
216 $(
"#search").trigger(
'keyup');
221function setFocusOnSearchField() {
222 console.log(
"Call setFocusOnSearchField in page index.php");
223 <?php
if ($conf->browser->layout ==
'classic') { ?>
224 console.log(
"has keyboard from localStorage, so we can force focus on search field");
225 $(
"#search").focus();
229function PrintCategories(first) {
230 console.log(
"PrintCategories");
231 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
232 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
234 $(
"#catdivdesc"+i).hide();
235 $(
"#catdesc"+i).text(
"");
236 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
237 $(
"#catwatermark"+i).hide();
238 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
241 $(
"#catdivdesc"+i).show();
244 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
246 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
248 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
249 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
250 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
251 $(
"#catdiv"+i).attr(
'class',
'wrapper');
252 $(
"#catwatermark"+i).show();
256function MoreCategories(moreorless) {
257 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
258 if (moreorless ==
"more") {
259 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
260 $(
'#catimg15').animate({opacity:
'1'}, 100);
261 pagecategories=pagecategories+1;
263 if (moreorless ==
"less") {
264 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
265 $(
'#catimg14').animate({opacity:
'1'}, 100);
266 if (pagecategories==0)
return;
267 pagecategories=pagecategories-1;
269 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
270 pagecategories=pagecategories-1;
274 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
275 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
277 console.log(
"complete with empty record");
278 $(
"#catdivdesc"+i).hide();
279 $(
"#catdesc"+i).text(
"");
280 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
281 $(
"#catwatermark"+i).hide();
284 $(
"#catdivdesc"+i).show();
287 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
289 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
291 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
292 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
293 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
294 $(
"#catwatermark"+i).show();
301function LoadProducts(
position, issubcat) {
302 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
303 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
306 currentcat=
"supplements";
308 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
309 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
310 if (issubcat ==
true) {
311 currentcat=$(
'#prodiv'+
position).data(
'rowid');
314 currentcat=$(
'#catdiv'+
position).data(
'rowid');
315 console.log(
"currentcat="+currentcat);
318 if (currentcat == undefined) {
324 jQuery.each(subcategories,
function(i, val) {
325 if (currentcat==val.fk_parent) {
326 $(
"#prodivdesc"+ishow).show();
327 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
328 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
329 $(
"#probutton"+ishow).html(val.label);
331 $(
"#prodesc"+ishow).text(val.label);
332 $(
"#probutton"+ishow).text(val.label);
334 $(
"#probutton"+ishow).show();
335 $(
"#proprice"+ishow).attr(
"class",
"hidden");
336 $(
"#proprice"+ishow).html(
"");
337 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
338 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
339 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
340 $(
"#prodiv"+ishow).data(
"iscat",1);
341 $(
"#prodiv"+ishow).attr(
"data-iscat",1);
342 $(
"#prowatermark"+ishow).show();
349 if (maxproduct >= 1) {
350 limit = maxproduct-1;
353 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + jQuery(
'#thirdpartyid').val() +
'&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset=0',
function(data) {
354 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
357 while (ishow < maxproduct) {
358 console.log(
"ishow"+ishow+
" idata="+idata);
361 if (typeof (data[idata]) ==
"undefined") {
363 echo
'$("#prodivdesc"+ishow).hide();';
364 echo
'$("#prodesc"+ishow).text("");';
365 echo
'$("#proimg"+ishow).attr("title","");';
366 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
368 echo
'$("#probutton"+ishow).hide();';
369 echo
'$("#probutton"+ishow).text("");';
371 $(
"#proprice"+ishow).attr(
"class",
"hidden");
372 $(
"#proprice"+ishow).html(
"");
374 $(
"#prodiv"+ishow).data(
"rowid",
"");
375 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
377 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
380 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
381 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
383 var titlestring = <?php echo $titlestring; ?>;
385 echo
'$("#prodivdesc"+ishow).show();';
387 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
389 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
391 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
393 echo
'$("#proimg"+ishow).attr("title", titlestring);';
394 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
396 echo
'$("#probutton"+ishow).show();';
397 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
400 if (data[parseInt(idata)][
'price_formated']) {
401 $(
"#proprice" + ishow).attr(
"class",
"productprice");
405 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
409 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
414 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
416 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
417 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
418 console.log($(
'#prodiv4').data(
'rowid'));
420 $(
"#prodiv"+ishow).data(
"iscat", 0);
421 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
423 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
427 $parameters = array();
428 $parameters[
'caller'] =
'loadProducts';
429 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
430 print $hookmanager->resPrint;
433 $(
"#prowatermark"+ishow).hide();
442function MoreProducts(moreorless) {
443 console.log(
"MoreProducts");
445 if ($(
'#search_pagination').val() !=
'') {
446 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
449 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
451 if (moreorless==
"more"){
452 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
453 $(
'#proimg31').animate({opacity:
'1'}, 100);
454 pageproducts=pageproducts+1;
456 if (moreorless==
"less"){
457 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
458 $(
'#proimg30').animate({opacity:
'1'}, 100);
459 if (pageproducts==0)
return;
460 pageproducts=pageproducts-1;
466 if (maxproduct >= 1) {
467 limit = maxproduct-1;
469 var offset = <?php echo($MAXPRODUCT - 2); ?> * pageproducts;
471 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset='+offset,
function(data) {
472 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
474 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
475 pageproducts=pageproducts-1;
479 while (ishow < maxproduct) {
480 if (typeof (data[idata]) ==
"undefined") {
481 $(
"#prodivdesc"+ishow).hide();
482 $(
"#prodesc"+ishow).text(
"");
483 $(
"#probutton"+ishow).text(
"");
484 $(
"#probutton"+ishow).hide();
485 $(
"#proprice"+ishow).attr(
"class",
"");
486 $(
"#proprice"+ishow).html(
"");
487 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
488 $(
"#prodiv"+ishow).data(
"rowid",
"");
489 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
491 $(
"#prodivdesc"+ishow).show();
493 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
494 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
495 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
497 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
499 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
500 $(
"#probutton"+ishow).show();
501 if (data[parseInt(idata)][
'price_formated']) {
502 $(
"#proprice" + ishow).attr(
"class",
"productprice");
506 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
510 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
515 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
516 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
517 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
518 $(
"#prodiv"+ishow).data(
"iscat",0);
520 $(
"#prowatermark"+ishow).hide();
529function ClickProduct(
position, qty = 1) {
530 console.log(
"ClickProduct at position"+
position);
531 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
532 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
533 if ($(
'#prodiv'+
position).data(
'iscat')==1){
534 console.log(
"Click on a category at position "+
position);
538 console.log($(
'#prodiv4').data(
'rowid'));
539 invoiceid = $(
"#invoiceid").val();
540 idproduct=$(
'#prodiv'+
position).data(
'rowid');
541 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
542 if (idproduct ==
"") {
546 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
548 echo
"CustomerDisplay();";
556function ChangeThirdparty(idcustomer) {
557 console.log(
"ChangeThirdparty");
559 $(
"#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() {
565function deleteline() {
566 invoiceid = $(
"#invoiceid").val();
567 console.log(
"Delete line invoiceid="+invoiceid);
568 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
575 console.log(
"Open box to select the thirdparty place="+place);
576 $.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
"); ?>"});
580 console.log(
"Open box to select the contact place="+place);
581 $.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"); ?>"});
586 console.log(
"Open box to select the history");
587 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
590function Reduction() {
591 invoiceid = $(
"#invoiceid").val();
592 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
593 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
596function CloseBill() {
598 if (!empty($conf->global->TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER)) {
599 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
600 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
601 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
605 invoiceid = $(
"#invoiceid").val();
606 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
608 if ($(
"#idcustomer").val() ==
"") {
609 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
620 if (empty($alternative_payurl)) {
626 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
630 invoiceid = $(
"#invoiceid").val();
631 console.log(
"Open popup to split on invoiceid="+invoiceid);
632 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
636 console.log(
"Open box to select floor place="+place);
637 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
641 invoiceid = $(
"#invoiceid").val();
642 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
643 $.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
"); ?>"});
646function TakeposOrderNotes() {
647 console.log(
"Open box to order notes");
648 ModalBox(
'ModalNote');
649 $(
"#textinput").focus();
653 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
654 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
661 invoiceid = $(
"#invoiceid").val();
663 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
665 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
668 if (parseInt(data[
'paye']) === 1) {
671 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
676 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
681 $(
"#idcustomer").val(
"");
693function Search2(keyCodeForEnter, moreorless) {
694 var eventKeyCode = window.event.keyCode;
696 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
698 var search_term = $(
'#search').val();
699 var search_start = 0;
700 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
701 if (moreorless !=
null) {
702 search_term = $(
'#search_pagination').val();
703 search_start = $(
'#search_start_'+moreorless).val();
706 console.log(
"search_term="+search_term);
708 if (search_term ==
'') {
709 $(
"[id^=prowatermark]").html(
"");
710 $(
"[id^=prodesc]").text(
"");
711 $(
"[id^=probutton]").text(
"");
712 $(
"[id^=probutton]").hide();
713 $(
"[id^=proprice]").attr(
"class",
"hidden");
714 $(
"[id^=proprice]").html(
"");
715 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
716 $(
"[id^=prodiv]").data(
"rowid",
"");
717 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
722 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
726 if (search ===
true) {
730 clearTimeout(search2_timer);
734 search2_timer = setTimeout(
function(){
736 jQuery(
".wrapper2 .catwatermark").hide();
737 var nbsearchresults = 0;
738 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term +
'&thirdpartyid=' + jQuery(
'#thirdpartyid').val() +
'&search_start=' + search_start +
'&search_limit=' + search_limit,
function (data) {
739 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
740 if (typeof (data[i]) ==
"undefined") {
741 $(
"#prowatermark" + i).html(
"");
742 $(
"#prodesc" + i).text(
"");
743 $(
"#probutton" + i).text(
"");
744 $(
"#probutton" + i).hide();
745 $(
"#proprice" + i).attr(
"class",
"hidden");
746 $(
"#proprice" + i).html(
"");
747 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
748 $(
"#prodiv" + i).data(
"rowid",
"");
749 $(
"#prodiv" + i).attr(
"data-rowid",
"");
753 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
754 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
756 var titlestring = <?php echo $titlestring; ?>;
758 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
759 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
760 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
762 $(
"#prodesc" + i).html(data[i][
'label']);
764 $(
"#prodivdesc" + i).show();
765 $(
"#probutton" + i).html(data[i][
'label']);
766 $(
"#probutton" + i).show();
767 if (data[i][
'price_formated']) {
768 $(
"#proprice" + i).attr(
"class",
"productprice");
772 $(
"#proprice" + i).html(data[i][
'price_formated']);
776 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
781 $(
"#proimg" + i).attr(
"title", titlestring);
782 if( undefined !== data[i][
'img']) {
783 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
786 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
788 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
789 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
790 $(
"#prodiv" + i).data(
"iscat", 0);
791 $(
"#prodiv" + i).attr(
"data-iscat", 0);
795 $parameters = array();
796 $parameters[
'caller'] =
'search2';
797 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
798 print $hookmanager->resPrint;
803 }).always(
function (data) {
805 if ($(
'#search').val().length > 0 && data.length == 1) {
806 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
807 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
808 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
809 ChangeThirdparty(data[0][
'rowid']);
811 else if ($(
'#search').val() == data[0][
'barcode'] &&
'product' == data[0][
'object']) {
812 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']);
813 ClickProduct(0, data[0][
'qty']);
816 if (eventKeyCode == keyCodeForEnter){
817 if (data.length == 0) {
818 $(
'#search').val(
'<?php
819 $langs->load('errors
');
820 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
821 ?> ('+search_term+
')');
822 $(
'#search').select();
824 else ClearSearch(
false);
827 $(
"#search_pagination").val($(
"#search").val());
828 if (search_start == 0) {
829 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
832 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
833 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
834 $(
"#search_start_less").val(search_start_less);
836 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
837 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
840 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
841 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
842 $(
"#search_start_more").val(search_start_more);
851function Edit(number) {
852 console.log(
"We click on PAD on key="+number);
854 if (typeof(selectedtext) ==
"undefined") {
858 var text=selectedtext+
"<br> ";
864 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
865 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
866 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
868 }
else if (number==
'qty') {
869 if (editaction==
'qty' && editnumber !=
'') {
870 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
873 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
876 setFocusOnSearchField();
882 }
else if (number==
'p') {
883 if (editaction==
'p' && editnumber!=
"") {
884 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
887 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
896 }
else if (number==
'r') {
897 if (editaction==
'r' && editnumber!=
"") {
898 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
901 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
912 editnumber=editnumber+number;
914 if (editaction==
'qty'){
915 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
916 $(
"#qty").html(
"OK").addClass(
"clicked");
917 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
918 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
920 if (editaction==
'p'){
921 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
922 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
923 $(
"#price").html(
"OK").addClass(
"clicked");
924 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
926 if (editaction==
'r'){
927 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
928 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
929 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
930 $(
"#reduction").html(
"OK").addClass(
"clicked");
932 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
936function TakeposPrintingOrder(){
937 console.log(
"TakeposPrintingOrder");
938 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
943function TakeposPrintingTemp(){
944 console.log(
"TakeposPrintingTemp");
945 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
950function OpenDrawer(){
951 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
954 data: { token:
'notrequired' },
956 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
957 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
959 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
966function DolibarrOpenDrawer() {
967 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
"]); ?>");
970 data: { token:
'<?php echo currentToken(); ?>' },
971 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
975function MoreActions(totalactions){
978 for (i = 0; i <= totalactions; i++){
979 if (i<12) $(
"#action"+i).hide();
980 else $(
"#action"+i).show();
983 else if (pageactions==1){
985 for (i = 0; i <= totalactions; i++){
986 if (i<12) $(
"#action"+i).show();
987 else $(
"#action"+i).hide();
994function ControlCashOpening()
996 $.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
"); ?>"});
999function CloseCashFence(rowid)
1001 $.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
"); ?>"});
1004function CashReport(rowid)
1006 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1010function ModalBox(ModalID)
1012 var modal = document.getElementById(ModalID);
1013 modal.style.display =
"block";
1016function DirectPayment(){
1017 console.log(
"DirectPayment");
1018 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1022function FullScreen() {
1023 document.documentElement.requestFullscreen();
1026function WeighingScale(){
1027 console.log(
"Weighing Scale");
1030 data: { token:
'notrequired' },
1031 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1033 .done(
function( editnumber ) {
1034 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1040$( document ).ready(
function() {
1046 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1047 print
"ModalBox('ModalTerminal');";
1051 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1052 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
1053 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1055 $resql = $db->query($sql);
1057 $obj = $db->fetch_object($resql);
1059 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1060 print
"ControlCashOpening();";
1067 var elem1 = $(
"#topnav-left")[0];
1068 var elem2 = $(
"#topnav-right")[0];
1069 var checkOverflow =
function() {
1070 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1071 else $(
"#topnav").removeClass(
"overflow");
1074 var scrollBars =
function(){
1075 var container= $(
'#topnav')[0];
1077 vertical:container.scrollHeight > container.clientHeight,
1078 horizontal:container.scrollWidth > container.clientWidth
1082 $(window).resize(
function(){
1086 let resizeObserver =
new ResizeObserver(() => {
1089 resizeObserver.observe(elem1);
1090 resizeObserver.observe(elem2);
1093 var pressTimer = [];
1097 $(
".indicator").mousedown(
function(){
1098 direction = $(
this).hasClass(
"left") ? -1 : 1;
1100 pressTimer.push(setInterval(scrollTo, 100));
1103 $(
".indicator").mouseup(
function(){
1104 pressTimer.forEach(clearInterval);
1107 $(
"body").mouseup(
function(){
1108 pressTimer.forEach(clearInterval);
1109 console.log(
"body mouseup");
1112 function scrollTo(){
1113 console.log(
"here");
1114 var pos = $(
"#topnav").scrollLeft();
1115 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1118 $(
"#topnav").scroll(
function(){
1119 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1128$keyCodeForEnter =
'';
1129if (!empty($_SESSION[
'takeposterminal'])) {
1130 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalString(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1133<div
class=
"container">
1138 <div
class=
"header">
1139 <div
id=
"topnav" class=
"topnav">
1140 <div
id=
"topnav-left" class=
"topnav-left">
1141 <div
class=
"inline-block valignmiddle">
1142 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1143 <span
class=
"fa fa-cash-register"></span>
1144 <span
class=
"hideonsmartphone">
1146 if (!empty($_SESSION[
"takeposterminal"])) {
1147 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1152 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1155 if (isModEnabled(
'multicurrency')) {
1156 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1157 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1161 <!-- section
for customer -->
1162 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1163 <input
type=
"hidden" id=
"idcustomer" value=
"">
1164 <!-- section
for shopping carts -->
1165 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1166 <!-- More info about customer -->
1167 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1169 if (isModEnabled(
'stock')) {
1171 <!-- More info about warehouse -->
1172 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1176 <div
id=
"topnav-right" class=
"topnav-right">
1178 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1179 if ($reshook == 0) {
1181 <div
class=
"login_block_other takepos">
1182 <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>
1183 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1184 <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 -->
1185 <span
class=
"fas fa-home"></span></a>
1186 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1187 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1193 <div
class=
"login_block_user">
1195 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1199 <div
class=
"arrows">
1200 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1201 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1209<!-- Modal terminal box -->
1210<div
id=
"ModalTerminal" class=
"modal">
1211 <div
class=
"modal-content">
1212 <div
class=
"modal-header">
1216 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1219 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1221 <div
class=
"modal-body">
1222 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1225 for ($i = 2; $i <= $nbloop; $i++) {
1226 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1233<!-- Modal multicurrency box -->
1234<?php if (isModEnabled('multicurrency')) { ?>
1235<div id="ModalCurrency
" class="modal
">
1236 <div class="modal-content
">
1237 <div class="modal-header
">
1238 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1239 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1241 <div class="modal-body
">
1243 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1244 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1245 $resql = $db->query($sql);
1247 while ($obj = $db->fetch_object($resql)) {
1248 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1257<!-- Modal terminal Credit Note -->
1258<div id="ModalCreditNote
" class="modal
">
1259 <div class="modal-content
">
1260 <div class="modal-header
">
1261 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1262 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1264 <div class="modal-body
">
1265 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1266 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1272<div id="ModalNote
" class="modal
">
1273 <div class="modal-content
">
1274 <div class="modal-header
">
1275 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1276 <h3><?php print $langs->trans("Note
"); ?></h3>
1278 <div class="modal-body
">
1279 <input type="text
" class="block
" id="textinput
">
1280 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1289 <div id="poslines
" class="div1
">
1293 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1294 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1295 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1296 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1297 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1298 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1299 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1300 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1301 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1302 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1303 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1304 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1305 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1306 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1307 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1308 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1313// TakePOS setup check
1314if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1315 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1316 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1317 $sql .= " AND active = 1
";
1318 $sql .= " ORDER BY libelle
";
1320 $resql = $db->query($sql);
1321 $paiementsModes = array();
1323 while ($obj = $db->fetch_object($resql)) {
1324 $paycode = $obj->code;
1325 if ($paycode == 'LIQ') {
1328 if ($paycode == 'CHQ') {
1329 $paycode = 'CHEQUE';
1332 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1333 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1334 if (getDolGlobalInt($constantforkey) > 0) {
1335 array_push($paiementsModes, $obj);
1340 if (empty($paiementsModes) && isModEnabled("bank
")) {
1341 $langs->load('errors');
1342 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1343 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1347if (count($maincategories) == 0) {
1348 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1349 $tmpcategory = new Categorie($db);
1350 $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID'));
1351 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1353 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1356// User menu and external TakePOS modules
1360if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1361 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1363 // BAR RESTAURANT specific menu
1364 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1367if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1368 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1369 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1371 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1374if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1375 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1377$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1378$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1380if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1381 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1384// BAR RESTAURANT specific menu
1385if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1386 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1387 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action' => 'TakeposPrintingOrder();');
1391// Last action that close the sell (payments)
1392$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1393if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1394 $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();');
1397// BAR RESTAURANT specific menu
1398if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1399 //Button to print receipt before payment
1400 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1401 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1402 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1403 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposConnector(placeid);');
1405 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1407 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1408 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1410 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'Print(placeid);');
1413 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1414 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1416 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1417 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1421if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1422 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1424if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1425 $menus[$r++] = array(
1426 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1427 'action' => 'DolibarrOpenDrawer();',
1431$sql = "SELECT rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1432$sql .= " entity =
".((int) $conf->entity)." AND
";
1433$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1434$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1436$resql = $db->query($sql);
1438 $num = $db->num_rows($resql);
1440 $obj = $db->fetch_object($resql);
1441 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1442 if ($obj->status == 0) {
1443 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1448$parameters = array('menus' => $menus);
1449$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1450if ($reshook == 0) { //add buttons
1451 if (is_array($hookmanager->resArray)) {
1452 foreach ($hookmanager->resArray as $resArray) {
1453 foreach ($resArray as $butmenu) {
1454 $menus[$r++] = $butmenu;
1457 } elseif ($reshook == 1) {
1458 $r = 0; //replace buttons
1459 if (is_array($hookmanager->resArray)) {
1460 foreach ($hookmanager->resArray as $resArray) {
1461 foreach ($resArray as $butmenu) {
1462 $menus[$r++] = $butmenu;
1470 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1473if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1474 $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().'\';');
1477if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1478 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1482 <!-- Show buttons -->
1486 foreach ($menus as $menu) {
1488 if (count($menus) > 12 and $i == 12) {
1489 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1490 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1491 } elseif ($i > 12) {
1492 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1494 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1498 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1499 print '<!-- Show the search input text -->'."\n
";
1500 print '<div class="margintoponly
">';
1501 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> ';
1502 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear').'</a>';
1513 <!-- Show categories -->
1515 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1516 print '<div class="div4
" style= "display: none;
">';
1518 print '<div class="div4
">';
1522 while ($count < $MAXCATEG) {
1524 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1525 echo 'onclick="MoreCategories(\
'less\')"';
1526 } elseif ($count == ($MAXCATEG - 1)) {
1527 echo
'onclick="MoreCategories(\'more\')"';
1529 echo
'onclick="LoadProducts('.$count.
')"';
1530 } ?>
id=
"catdiv<?php echo $count; ?>">
1532 if ($count == ($MAXCATEG - 2)) {
1534 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1535 } elseif ($count == ($MAXCATEG - 1)) {
1537 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1540 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1543 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1544 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1545 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1548 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1556 <!-- Show product -->
1557 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1558 print ' centpercent';
1562 while ($count < $MAXPRODUCT) {
1563 print
'<div class="wrapper2 arrow" id="prodiv'.$count.
'" '; ?>
1564 <?php
if ($count == ($MAXPRODUCT - 2)) {
1565 ?> onclick=
"MoreProducts('less')" <?php
1567 if ($count == ($MAXPRODUCT - 1)) {
1568 ?> onclick=
"MoreProducts('more')" <?php
1570 echo
'onclick="ClickProduct('.$count.
')"';
1573 if ($count == ($MAXPRODUCT - 2)) {
1575 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1576 } elseif ($count == ($MAXPRODUCT - 1)) {
1578 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1581 print
'<div class="" id="proprice'.$count.
'"></div>';
1584 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1586 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1589 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1590 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1591 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1594 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1600 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1601 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1602 <input
type=
"hidden" id=
"search_pagination" value=
"">
Class to manage categories.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
top_menu_user($hideloginname=0, $urllogout='')
Build the tooltip on user login.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.