33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
39if (!defined(
'NOREQUIREAJAX')) {
40 define(
'NOREQUIREAJAX',
'1');
44require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
62$langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter",
"banks"));
65$action =
GETPOST(
'action',
'aZ09');
67$setcurrency =
GETPOST(
'setcurrency',
'aZ09');
69$hookmanager->initHooks(array(
'takeposfrontend'));
70if (empty($_SESSION[
"takeposterminal"])) {
72 $_SESSION[
"takeposterminal"] = 1;
73 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
74 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
78if ($setterminal > 0) {
79 $_SESSION[
"takeposterminal"] = $setterminal;
80 setcookie(
"takeposterminal", (
string) $setterminal, (time() + (86400 * 354)),
'/',
'', !empty($dolibarr_main_force_https),
true);
83if ($setcurrency !=
"") {
84 $_SESSION[
"takeposcustomercurrency"] = $setcurrency;
91$maxcategbydefaultforthisdevice = 12;
92$maxproductbydefaultforthisdevice = 24;
93if (
$conf->browser->layout ==
'phone') {
94 $maxcategbydefaultforthisdevice = 8;
95 $maxproductbydefaultforthisdevice = 16;
98 $_SESSION[
"basiclayout"] = 1;
99 header(
"Location: phone.php?mobilepage=invoice");
103 unset($_SESSION[
"basiclayout"]);
105$MAXCATEG = (!
getDolGlobalString(
'TAKEPOS_NB_MAXCATEG') ? $maxcategbydefaultforthisdevice :
$conf->global->TAKEPOS_NB_MAXCATEG);
106$MAXPRODUCT = (!
getDolGlobalString(
'TAKEPOS_NB_MAXPRODUCT') ? $maxproductbydefaultforthisdevice :
$conf->global->TAKEPOS_NB_MAXPRODUCT);
108$term = empty($_SESSION[
'takeposterminal']) ? 1 : $_SESSION[
'takeposterminal'];
126$form =
new Form($db);
130$arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
131$arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
134 $arrayofcss[] =
'/takepos/css/colorful.css';
139$title =
'TakePOS - Dolibarr '.DOL_VERSION;
143$head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
144<meta name="apple-mobile-web-app-capable" content="yes">
145<meta name="mobile-web-app-capable" content="yes">
146<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
147top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
150$categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
155$levelofrootcategory = 0;
157 foreach ($categories as $key => $categorycursor) {
159 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
160 $levelofrootcategory = $categorycursor[
'level'];
166$levelofmaincategories = $levelofrootcategory + 1;
168$maincategories = array();
169$subcategories = array();
170foreach ($categories as $key => $categorycursor) {
171 if ($categorycursor[
'level'] == $levelofmaincategories) {
172 $maincategories[$key] = $categorycursor;
174 $subcategories[$key] = $categorycursor;
182<body
class=
"bodytakepos" style=
"overflow: hidden;">
185var categories = <?php echo json_encode($maincategories); ?>;
186var subcategories = <?php echo json_encode($subcategories); ?>;
192var place=
"<?php echo $place; ?>";
196var search2_timer=
null;
215function ClearSearch(clearSearchResults) {
216 console.log(
"ClearSearch");
217 $(
"#search").val(
'');
218 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
219 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
220 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
221 <?php
if (
$conf->browser->layout ==
'classic') { ?>
222 setFocusOnSearchField();
224 if (clearSearchResults) {
225 $(
"#search").trigger(
'keyup');
230function setFocusOnSearchField() {
231 console.log(
"Call setFocusOnSearchField in page index.php");
232 <?php
if (
$conf->browser->layout ==
'classic') { ?>
233 console.log(
"has keyboard from localStorage, so we can force focus on search field");
234 $(
"#search").focus();
238function PrintCategories(first) {
239 console.log(
"PrintCategories");
240 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
241 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
243 $(
"#catdivdesc"+i).hide();
244 $(
"#catdesc"+i).text(
"");
245 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
246 $(
"#catwatermark"+i).hide();
247 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
250 $(
"#catdivdesc"+i).show();
253 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
255 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
257 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
258 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
259 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
260 $(
"#catdiv"+i).attr(
'class',
'wrapper');
261 $(
"#catwatermark"+i).show();
265function MoreCategories(moreorless) {
266 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
267 if (moreorless ==
"more") {
268 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
269 $(
'#catimg15').animate({opacity:
'1'}, 100);
270 pagecategories=pagecategories+1;
272 if (moreorless ==
"less") {
273 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
274 $(
'#catimg14').animate({opacity:
'1'}, 100);
275 if (pagecategories==0)
return;
276 pagecategories=pagecategories-1;
278 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
279 pagecategories=pagecategories-1;
283 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
284 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
286 console.log(
"complete with empty record");
287 $(
"#catdivdesc"+i).hide();
288 $(
"#catdesc"+i).text(
"");
289 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
290 $(
"#catwatermark"+i).hide();
293 $(
"#catdivdesc"+i).show();
296 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
298 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
300 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
301 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
302 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
303 $(
"#catwatermark"+i).show();
310function LoadProducts(
position, issubcat) {
311 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
312 var maxproduct = <?php echo (
int) ($MAXPRODUCT - 2); ?>;
315 currentcat=
"supplements";
317 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
318 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
319 if (issubcat ==
true) {
320 currentcat=$(
'#prodiv'+
position).data(
'rowid');
323 currentcat=$(
'#catdiv'+
position).data(
'rowid');
324 console.log(
"currentcat="+currentcat);
327 if (currentcat == undefined) {
333 jQuery.each(subcategories,
function(i, val) {
334 if (currentcat==val.fk_parent) {
335 $(
"#prodivdesc"+ishow).show();
336 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
337 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
338 $(
"#probutton"+ishow).html(val.label);
340 $(
"#prodesc"+ishow).text(val.label);
341 $(
"#probutton"+ishow).text(val.label);
343 $(
"#probutton"+ishow).show();
344 $(
"#proprice"+ishow).attr(
"class",
"hidden");
345 $(
"#proprice"+ishow).html(
"");
346 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
347 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
348 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
349 $(
"#prodiv"+ishow).data(
"iscat", 1);
350 $(
"#prodiv"+ishow).attr(
"data-iscat", 1);
351 $(
"#prodiv"+ishow).removeClass(
"divempty");
352 $(
"#prowatermark"+ishow).show();
359 if (maxproduct >= 1) {
360 limit = maxproduct - 1;
363 $.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) {
364 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
367 while (ishow < maxproduct) {
368 console.log(
"ishow"+ishow+
" idata="+idata);
371 if (typeof (data[idata]) ==
"undefined") {
373 echo
'$("#prodivdesc"+ishow).hide();';
374 echo
'$("#prodesc"+ishow).text("");';
375 echo
'$("#proimg"+ishow).attr("title","");';
376 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
378 echo
'$("#probutton"+ishow).hide();';
379 echo
'$("#probutton"+ishow).text("");';
381 $(
"#proprice"+ishow).attr(
"class",
"hidden");
382 $(
"#proprice"+ishow).html(
"");
384 $(
"#prodiv"+ishow).data(
"rowid",
"");
385 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
387 $(
"#prodiv"+ishow).data(
"iscat",
"0");
388 $(
"#prodiv"+ishow).attr(
"data-iscat",
"0");
390 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
393 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
394 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
396 var titlestring = <?php echo $titlestring; ?>;
398 echo
'$("#prodivdesc"+ishow).show();';
400 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
402 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
404 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
406 echo
'$("#proimg"+ishow).attr("title", titlestring);';
407 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
409 echo
'$("#probutton"+ishow).show();';
410 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
413 if (data[parseInt(idata)][
'price_formated']) {
414 $(
"#proprice" + ishow).attr(
"class",
"productprice");
418 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
422 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
427 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
429 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
430 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
431 console.log($(
'#prodiv4').data(
'rowid'));
433 $(
"#prodiv"+ishow).data(
"iscat", 0);
434 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
436 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
440 $parameters = array();
441 $parameters[
'caller'] =
'loadProducts';
442 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
443 print $hookmanager->resPrint;
446 $(
"#prowatermark"+ishow).hide();
455function MoreProducts(moreorless) {
456 console.log(
"MoreProducts");
458 if ($(
'#search_pagination').val() !=
'') {
459 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
462 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
464 if (moreorless==
"more"){
465 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
466 $(
'#proimg31').animate({opacity:
'1'}, 100);
467 pageproducts=pageproducts+1;
469 if (moreorless==
"less"){
470 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
471 $(
'#proimg30').animate({opacity:
'1'}, 100);
472 if (pageproducts==0)
return;
473 pageproducts=pageproducts-1;
479 if (maxproduct >= 1) {
480 limit = maxproduct-1;
482 var nb_cat_shown = $(
'.div5 div.wrapper2[data-iscat=1]').length;
483 var offset = <?php echo($MAXPRODUCT - 2); ?> * pageproducts - nb_cat_shown;
485 $.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) {
486 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
488 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
489 pageproducts=pageproducts-1;
493 while (ishow < maxproduct) {
494 if (typeof (data[idata]) ==
"undefined") {
495 $(
"#prodivdesc"+ishow).hide();
496 $(
"#prodesc"+ishow).text(
"");
497 $(
"#probutton"+ishow).text(
"");
498 $(
"#probutton"+ishow).hide();
499 $(
"#proprice"+ishow).attr(
"class",
"");
500 $(
"#proprice"+ishow).html(
"");
501 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
502 $(
"#prodiv"+ishow).data(
"rowid",
"");
503 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
505 $(
"#prodivdesc"+ishow).show();
507 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
508 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
509 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
511 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
513 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
514 $(
"#probutton"+ishow).show();
515 if (data[parseInt(idata)][
'price_formated']) {
516 $(
"#proprice" + ishow).attr(
"class",
"productprice");
520 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
524 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
529 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
530 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
531 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
532 $(
"#prodiv"+ishow).data(
"iscat",0);
534 $(
"#prowatermark"+ishow).hide();
543function ClickProduct(
position, qty = 1) {
544 console.log(
"ClickProduct at position"+
position);
545 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
546 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
547 if ($(
'#prodiv'+
position).data(
'iscat') == 1){
548 console.log(
"Click on a category at position "+
position);
552 console.log($(
'#prodiv4').data(
'rowid'));
553 invoiceid = $(
"#invoiceid").val();
554 idproduct=$(
'#prodiv'+
position).data(
'rowid');
555 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
556 if (idproduct ==
"") {
560 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
562 echo
"CustomerDisplay();";
570function ChangeThirdparty(idcustomer) {
571 console.log(
"ChangeThirdparty");
573 $(
"#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() {
579function deleteline() {
580 invoiceid = $(
"#invoiceid").val();
581 console.log(
"Delete line invoiceid="+invoiceid);
582 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
589 console.log(
"Open box to select the thirdparty place="+place);
590 $.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
"); ?>"});
594 console.log(
"Open box to select the contact place="+place);
595 $.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"); ?>"});
600 console.log(
"Open box to select the history");
601 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
604function Reduction() {
605 invoiceid = $(
"#invoiceid").val();
606 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
607 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
610function CloseBill() {
613 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
614 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
615 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
619 invoiceid = $(
"#invoiceid").val();
620 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
622 if ($(
"#idcustomer").val() ==
"") {
623 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
634 if (empty($alternative_payurl)) {
640 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
644 invoiceid = $(
"#invoiceid").val();
645 console.log(
"Open popup to split on invoiceid="+invoiceid);
646 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
650 console.log(
"Open box to select floor place="+place);
651 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
655 invoiceid = $(
"#invoiceid").val();
656 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
657 $.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
"); ?>"});
660function TakeposOrderNotes() {
661 console.log(
"Open box to order notes");
662 ModalBox(
'ModalNote');
663 $(
"#textinput").focus();
667 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
668 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
675 invoiceid = $(
"#invoiceid").val();
677 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
679 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
682 if (parseInt(data[
'paye']) === 1) {
685 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
690 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
695 $(
"#idcustomer").val(
"");
707function Search2(keyCodeForEnter, moreorless) {
708 var eventKeyCode = window.event.keyCode;
710 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
712 var search_term = $(
'#search').val();
713 var search_start = 0;
714 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
715 if (moreorless !=
null) {
716 search_term = $(
'#search_pagination').val();
717 search_start = $(
'#search_start_'+moreorless).val();
720 console.log(
"search_term="+search_term);
722 if (search_term ==
'') {
723 $(
"[id^=prowatermark]").html(
"");
724 $(
"[id^=prodesc]").text(
"");
725 $(
"[id^=probutton]").text(
"");
726 $(
"[id^=probutton]").hide();
727 $(
"[id^=proprice]").attr(
"class",
"hidden");
728 $(
"[id^=proprice]").html(
"");
729 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
730 $(
"[id^=prodiv]").data(
"rowid",
"");
731 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
736 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
740 if (search ===
true) {
744 clearTimeout(search2_timer);
748 search2_timer = setTimeout(
function(){
750 jQuery(
".wrapper2 .catwatermark").hide();
751 var nbsearchresults = 0;
752 $.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) {
753 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
754 if (typeof (data[i]) ==
"undefined") {
755 $(
"#prowatermark" + i).html(
"");
756 $(
"#prodesc" + i).text(
"");
757 $(
"#probutton" + i).text(
"");
758 $(
"#probutton" + i).hide();
759 $(
"#proprice" + i).attr(
"class",
"hidden");
760 $(
"#proprice" + i).html(
"");
761 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
762 $(
"#prodiv" + i).data(
"rowid",
"");
763 $(
"#prodiv" + i).attr(
"data-rowid",
"");
767 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
768 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
770 var titlestring = <?php echo $titlestring; ?>;
772 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
773 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
774 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
776 $(
"#prodesc" + i).html(data[i][
'label']);
778 $(
"#prodivdesc" + i).show();
779 $(
"#probutton" + i).html(data[i][
'label']);
780 $(
"#probutton" + i).show();
781 if (data[i][
'price_formated']) {
782 $(
"#proprice" + i).attr(
"class",
"productprice");
786 $(
"#proprice" + i).html(data[i][
'price_formated']);
790 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
795 $(
"#proimg" + i).attr(
"title", titlestring);
796 if( undefined !== data[i][
'img']) {
797 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
800 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
802 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
803 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
804 $(
"#prodiv" + i).data(
"iscat", 0);
805 $(
"#prodiv" + i).attr(
"data-iscat", 0);
809 $parameters = array();
810 $parameters[
'caller'] =
'search2';
811 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
812 print $hookmanager->resPrint;
817 }).always(
function (data) {
819 if ($(
'#search').val().length > 0 && data.length == 1) {
820 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
821 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
822 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
823 ChangeThirdparty(data[0][
'rowid']);
825 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
826 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']);
827 ClickProduct(0, data[0][
'qty']);
830 if (eventKeyCode == keyCodeForEnter){
831 if (data.length == 0) {
832 $(
'#search').val(
'<?php
833 $langs->load('errors
');
834 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
835 ?> ('+search_term+
')');
836 $(
'#search').select();
838 else ClearSearch(
false);
841 $(
"#search_pagination").val($(
"#search").val());
842 if (search_start == 0) {
843 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
846 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
847 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
848 $(
"#search_start_less").val(search_start_less);
850 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
851 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
854 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
855 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
856 $(
"#search_start_more").val(search_start_more);
865function Edit(number) {
866 console.log(
"We click on PAD on key="+number);
868 if (typeof(selectedtext) ==
"undefined") {
872 var text=selectedtext+
"<br> ";
878 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
879 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
880 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
882 }
else if (number==
'qty') {
883 if (editaction==
'qty' && editnumber !=
'') {
884 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
887 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
890 setFocusOnSearchField();
896 }
else if (number==
'p') {
897 if (editaction==
'p' && editnumber!=
"") {
898 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
901 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
910 }
else if (number==
'r') {
911 if (editaction==
'r' && editnumber!=
"") {
912 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
915 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
926 editnumber=editnumber+number;
928 if (editaction==
'qty'){
929 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
930 $(
"#qty").html(
"OK").addClass(
"clicked");
931 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
932 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
934 if (editaction==
'p'){
935 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
936 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
937 $(
"#price").html(
"OK").addClass(
"clicked");
938 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
940 if (editaction==
'r'){
941 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
942 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
943 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
944 $(
"#reduction").html(
"OK").addClass(
"clicked");
946 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
950function TakeposPrintingOrder(){
951 console.log(
"TakeposPrintingOrder");
952 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
957function TakeposPrintingTemp(){
958 console.log(
"TakeposPrintingTemp");
959 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
964function OpenDrawer(){
965 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
968 data: { token:
'notrequired' },
970 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var(
$conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
971 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
973 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
980function DolibarrOpenDrawer() {
981 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
"]); ?>");
984 data: { token:
'<?php echo currentToken(); ?>' },
985 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
989function MoreActions(totalactions){
992 for (i = 0; i <= totalactions; i++){
993 if (i<12) $(
"#action"+i).hide();
994 else $(
"#action"+i).show();
997 else if (pageactions==1){
999 for (i = 0; i <= totalactions; i++){
1000 if (i<12) $(
"#action"+i).show();
1001 else $(
"#action"+i).hide();
1008function ControlCashOpening()
1010 $.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
"); ?>"});
1013function CloseCashFence(rowid)
1015 $.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
"); ?>"});
1018function CashReport(rowid)
1020 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1024function ModalBox(ModalID)
1026 var modal = document.getElementById(ModalID);
1027 modal.style.display =
"block";
1030function DirectPayment(){
1031 console.log(
"DirectPayment");
1032 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1036function FullScreen() {
1037 document.documentElement.requestFullscreen();
1040function WeighingScale(){
1041 console.log(
"Weighing Scale");
1044 data: { token:
'notrequired' },
1045 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1047 .done(
function( editnumber ) {
1048 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1054$( document ).ready(
function() {
1060 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1061 print
"ModalBox('ModalTerminal');";
1065 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1066 $sql .=
" entity = ".((int)
$conf->entity).
" AND ";
1067 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1069 $resql = $db->query($sql);
1071 $obj = $db->fetch_object($resql);
1073 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1074 print
"ControlCashOpening();";
1081 var elem1 = $(
"#topnav-left")[0];
1082 var elem2 = $(
"#topnav-right")[0];
1083 var checkOverflow =
function() {
1084 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1085 else $(
"#topnav").removeClass(
"overflow");
1088 var scrollBars =
function(){
1089 var container= $(
'#topnav')[0];
1091 vertical:container.scrollHeight > container.clientHeight,
1092 horizontal:container.scrollWidth > container.clientWidth
1096 $(window).resize(
function(){
1100 let resizeObserver =
new ResizeObserver(() => {
1103 resizeObserver.observe(elem1);
1104 resizeObserver.observe(elem2);
1107 var pressTimer = [];
1111 $(
".indicator").mousedown(
function(){
1112 direction = $(
this).hasClass(
"left") ? -1 : 1;
1114 pressTimer.push(setInterval(scrollTo, 100));
1117 $(
".indicator").mouseup(
function(){
1118 pressTimer.forEach(clearInterval);
1121 $(
"body").mouseup(
function(){
1122 pressTimer.forEach(clearInterval);
1123 console.log(
"body mouseup");
1126 function scrollTo(){
1127 console.log(
"here");
1128 var pos = $(
"#topnav").scrollLeft();
1129 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1132 $(
"#topnav").scroll(
function(){
1133 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1142$keyCodeForEnter =
'';
1143if (!empty($_SESSION[
'takeposterminal'])) {
1144 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalString(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1147<div
class=
"container">
1152 <div
class=
"header">
1153 <div
id=
"topnav" class=
"topnav">
1154 <div
id=
"topnav-left" class=
"topnav-left">
1155 <div
class=
"inline-block valignmiddle">
1156 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1157 <span
class=
"fa fa-cash-register"></span>
1158 <span
class=
"hideonsmartphone">
1160 if (!empty($_SESSION[
"takeposterminal"])) {
1161 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1166 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1169 if (isModEnabled(
'multicurrency')) {
1170 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1171 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1175 <!-- section
for customer -->
1176 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1177 <input
type=
"hidden" id=
"idcustomer" value=
"">
1178 <!-- section
for shopping carts -->
1179 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1180 <!-- More info about customer -->
1181 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1183 if (isModEnabled(
'stock')) {
1185 <!-- More info about warehouse -->
1186 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1190 <div
id=
"topnav-right" class=
"topnav-right">
1192 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1193 if ($reshook == 0) {
1195 <div
class=
"login_block_other takepos">
1196 <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>
1197 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1198 <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 -->
1199 <span
class=
"fas fa-home"></span></a>
1200 <?php
if (empty(
$conf->dol_use_jmobile)) { ?>
1201 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1207 <div
class=
"login_block_user">
1209 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1213 <div
class=
"arrows">
1214 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1215 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1223<!-- Modal terminal box -->
1224<div
id=
"ModalTerminal" class=
"modal">
1225 <div
class=
"modal-content">
1226 <div
class=
"modal-header">
1230 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1233 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1235 <div
class=
"modal-body">
1236 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1239 for ($i = 2; $i <= $nbloop; $i++) {
1240 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1247<!-- Modal multicurrency box -->
1248<?php if (isModEnabled('multicurrency')) { ?>
1249<div id="ModalCurrency
" class="modal
">
1250 <div class="modal-content
">
1251 <div class="modal-header
">
1252 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1253 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1255 <div class="modal-body
">
1257 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1258 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1259 $resql = $db->query($sql);
1261 while ($obj = $db->fetch_object($resql)) {
1262 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1271<!-- Modal terminal Credit Note -->
1272<div id="ModalCreditNote
" class="modal
">
1273 <div class="modal-content
">
1274 <div class="modal-header
">
1275 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1276 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1278 <div class="modal-body
">
1279 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1280 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1286<div id="ModalNote
" class="modal
">
1287 <div class="modal-content
">
1288 <div class="modal-header
">
1289 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1290 <h3><?php print $langs->trans("Note
"); ?></h3>
1292 <div class="modal-body
">
1293 <input type="text
" class="block
" id="textinput
">
1294 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1303 <div id="poslines
" class="div1
">
1307 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1308 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1309 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1310 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1311 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1312 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1313 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1314 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1315 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1316 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1317 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1318 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1319 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1320 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1321 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1322 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1327// TakePOS setup check
1328if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1329 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1330 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1331 $sql .= " AND active = 1
";
1332 $sql .= " ORDER BY libelle
";
1334 $resql = $db->query($sql);
1335 $paiementsModes = array();
1337 while ($obj = $db->fetch_object($resql)) {
1338 $paycode = $obj->code;
1339 if ($paycode == 'LIQ') {
1342 if ($paycode == 'CHQ') {
1343 $paycode = 'CHEQUE';
1346 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1347 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1348 if (getDolGlobalInt($constantforkey) > 0) {
1349 array_push($paiementsModes, $obj);
1354 if (empty($paiementsModes) && isModEnabled("bank
")) {
1355 $langs->load('errors');
1356 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1357 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1361if (count($maincategories) == 0) {
1362 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1363 $tmpcategory = new Categorie($db);
1364 $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID'));
1365 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1367 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1370// User menu and external TakePOS modules
1374if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1375 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1377 // BAR RESTAURANT specific menu
1378 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1381if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1382 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1383 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1385 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1388if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1389 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1391$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1392$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1394if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1395 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1398// BAR RESTAURANT specific menu
1399if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1400 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1401 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action' => 'TakeposPrintingOrder();');
1405// Last action that close the sell (payments)
1406$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1407if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1408 $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();');
1411// BAR RESTAURANT specific menu
1412if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1413 //Button to print receipt before payment
1414 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1415 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1416 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1417 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposConnector(placeid);');
1419 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1421 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1422 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1424 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'Print(placeid);');
1427 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1428 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1430 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1431 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1435if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1436 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1438if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1439 $menus[$r++] = array(
1440 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1441 'action' => 'DolibarrOpenDrawer();',
1445$sql = "SELECT rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1446$sql .= " entity =
".((int) $conf->entity)." AND
";
1447$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1448$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1450$resql = $db->query($sql);
1452 $num = $db->num_rows($resql);
1454 $obj = $db->fetch_object($resql);
1455 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1456 if ($obj->status == 0) {
1457 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1462$parameters = array('menus' => $menus);
1463$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1464if ($reshook == 0) { //add buttons
1465 if (is_array($hookmanager->resArray)) {
1466 foreach ($hookmanager->resArray as $resArray) {
1467 foreach ($resArray as $butmenu) {
1468 $menus[$r++] = $butmenu;
1471 } elseif ($reshook == 1) {
1472 $r = 0; //replace buttons
1473 if (is_array($hookmanager->resArray)) {
1474 foreach ($hookmanager->resArray as $resArray) {
1475 foreach ($resArray as $butmenu) {
1476 $menus[$r++] = $butmenu;
1484 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1487if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1488 $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().'\';');
1491if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1492 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1496 <!-- Show buttons -->
1500 foreach ($menus as $menu) {
1502 if (count($menus) > 12 and $i == 12) {
1503 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1504 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1505 } elseif ($i > 12) {
1506 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1508 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1512 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1513 print '<!-- Show the search input text -->'."\n
";
1514 print '<div class="margintoponly
">';
1515 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> ';
1516 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear').'</a>';
1527 <!-- Show categories -->
1529 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1530 print '<div class="div4
" style= "display: none;
">';
1532 print '<div class="div4
">';
1536 while ($count < $MAXCATEG) {
1538 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1539 echo 'onclick="MoreCategories(\
'less\')"';
1540 } elseif ($count == ($MAXCATEG - 1)) {
1541 echo
'onclick="MoreCategories(\'more\')"';
1543 echo
'onclick="LoadProducts('.$count.
')"';
1544 } ?>
id=
"catdiv<?php echo $count; ?>">
1546 if ($count == ($MAXCATEG - 2)) {
1548 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1549 } elseif ($count == ($MAXCATEG - 1)) {
1551 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1554 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1557 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1558 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1559 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1562 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1570 <!-- Show product -->
1571 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1572 print ' centpercent';
1577 while ($count < $MAXPRODUCT) {
1578 print
'<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ?
' arrow' :
'').
'" id="prodiv'.$count.
'" '; ?>
1579 <?php
if ($count == ($MAXPRODUCT - 2)) {
1580 ?> onclick=
"MoreProducts('less')" <?php
1582 if ($count == ($MAXPRODUCT - 1)) {
1583 ?> onclick=
"MoreProducts('more')" <?php
1585 echo
'onclick="ClickProduct('.$count.
')"';
1588 if ($count == ($MAXPRODUCT - 2)) {
1590 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1591 } elseif ($count == ($MAXPRODUCT - 1)) {
1593 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1596 print
'<div class="" id="proprice'.$count.
'"></div>';
1599 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1601 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1604 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1605 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1606 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1609 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1615 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1616 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1617 <input
type=
"hidden" id=
"search_pagination" value=
"">
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Class to manage categories.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
top_menu_user($hideloginname=0, $urllogout='')
Build the tooltip on user login.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.