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) ?
false : true), 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) {
149 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
150 $levelofrootcategory = $categorycursor[
'level'];
156$levelofmaincategories = $levelofrootcategory + 1;
158$maincategories = array();
159$subcategories = array();
160foreach ($categories as $key => $categorycursor) {
161 if ($categorycursor[
'level'] == $levelofmaincategories) {
162 $maincategories[$key] = $categorycursor;
164 $subcategories[$key] = $categorycursor;
172<body
class=
"bodytakepos" style=
"overflow: hidden;">
175var categories = <?php echo json_encode($maincategories); ?>;
176var subcategories = <?php echo json_encode($subcategories); ?>;
182var place=
"<?php echo $place; ?>";
186var search2_timer=
null;
205function ClearSearch(clearSearchResults) {
206 console.log(
"ClearSearch");
207 $(
"#search").val(
'');
208 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
209 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
210 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
211 <?php
if ($conf->browser->layout ==
'classic') { ?>
212 setFocusOnSearchField();
214 if (clearSearchResults) {
215 $(
"#search").trigger(
'keyup');
220function setFocusOnSearchField() {
221 console.log(
"Call setFocusOnSearchField in page index.php");
222 <?php
if ($conf->browser->layout ==
'classic') { ?>
223 console.log(
"has keyboard from localStorage, so we can force focus on search field");
224 $(
"#search").focus();
228function PrintCategories(first) {
229 console.log(
"PrintCategories");
230 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
231 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
233 $(
"#catdivdesc"+i).hide();
234 $(
"#catdesc"+i).text(
"");
235 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
236 $(
"#catwatermark"+i).hide();
237 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
240 $(
"#catdivdesc"+i).show();
243 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
245 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
247 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
248 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
249 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
250 $(
"#catdiv"+i).attr(
'class',
'wrapper');
251 $(
"#catwatermark"+i).show();
255function MoreCategories(moreorless) {
256 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
257 if (moreorless ==
"more") {
258 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
259 $(
'#catimg15').animate({opacity:
'1'}, 100);
260 pagecategories=pagecategories+1;
262 if (moreorless ==
"less") {
263 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
264 $(
'#catimg14').animate({opacity:
'1'}, 100);
265 if (pagecategories==0)
return;
266 pagecategories=pagecategories-1;
268 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
269 pagecategories=pagecategories-1;
273 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
274 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
276 console.log(
"complete with empty record");
277 $(
"#catdivdesc"+i).hide();
278 $(
"#catdesc"+i).text(
"");
279 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
280 $(
"#catwatermark"+i).hide();
283 $(
"#catdivdesc"+i).show();
286 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
288 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
290 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
291 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
292 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
293 $(
"#catwatermark"+i).show();
300function LoadProducts(
position, issubcat) {
301 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
302 var maxproduct = <?php echo (
int) ($MAXPRODUCT - 2); ?>;
305 currentcat=
"supplements";
307 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
308 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
309 if (issubcat ==
true) {
310 currentcat=$(
'#prodiv'+
position).data(
'rowid');
313 currentcat=$(
'#catdiv'+
position).data(
'rowid');
314 console.log(
"currentcat="+currentcat);
317 if (currentcat == undefined) {
323 jQuery.each(subcategories,
function(i, val) {
324 if (currentcat==val.fk_parent) {
325 $(
"#prodivdesc"+ishow).show();
326 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
327 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
328 $(
"#probutton"+ishow).html(val.label);
330 $(
"#prodesc"+ishow).text(val.label);
331 $(
"#probutton"+ishow).text(val.label);
333 $(
"#probutton"+ishow).show();
334 $(
"#proprice"+ishow).attr(
"class",
"hidden");
335 $(
"#proprice"+ishow).html(
"");
336 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
337 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
338 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
339 $(
"#prodiv"+ishow).data(
"iscat", 1);
340 $(
"#prodiv"+ishow).attr(
"data-iscat", 1);
341 $(
"#prodiv"+ishow).removeClass(
"divempty");
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).data(
"iscat",
"0");
378 $(
"#prodiv"+ishow).attr(
"data-iscat",
"0");
380 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
383 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
384 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
386 var titlestring = <?php echo $titlestring; ?>;
388 echo
'$("#prodivdesc"+ishow).show();';
390 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
392 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
394 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
396 echo
'$("#proimg"+ishow).attr("title", titlestring);';
397 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
399 echo
'$("#probutton"+ishow).show();';
400 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
403 if (data[parseInt(idata)][
'price_formated']) {
404 $(
"#proprice" + ishow).attr(
"class",
"productprice");
408 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
412 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
417 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
419 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
420 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
421 console.log($(
'#prodiv4').data(
'rowid'));
423 $(
"#prodiv"+ishow).data(
"iscat", 0);
424 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
426 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
430 $parameters = array();
431 $parameters[
'caller'] =
'loadProducts';
432 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
433 print $hookmanager->resPrint;
436 $(
"#prowatermark"+ishow).hide();
445function MoreProducts(moreorless) {
446 console.log(
"MoreProducts");
448 if ($(
'#search_pagination').val() !=
'') {
449 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
452 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
454 if (moreorless==
"more"){
455 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
456 $(
'#proimg31').animate({opacity:
'1'}, 100);
457 pageproducts=pageproducts+1;
459 if (moreorless==
"less"){
460 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
461 $(
'#proimg30').animate({opacity:
'1'}, 100);
462 if (pageproducts==0)
return;
463 pageproducts=pageproducts-1;
469 if (maxproduct >= 1) {
470 limit = maxproduct-1;
472 var nb_cat_shown = $(
'.div5 div.wrapper2[data-iscat=1]').length;
473 var offset = <?php echo($MAXPRODUCT - 2); ?> * pageproducts - nb_cat_shown;
475 $.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) {
476 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
478 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
479 pageproducts=pageproducts-1;
483 while (ishow < maxproduct) {
484 if (typeof (data[idata]) ==
"undefined") {
485 $(
"#prodivdesc"+ishow).hide();
486 $(
"#prodesc"+ishow).text(
"");
487 $(
"#probutton"+ishow).text(
"");
488 $(
"#probutton"+ishow).hide();
489 $(
"#proprice"+ishow).attr(
"class",
"");
490 $(
"#proprice"+ishow).html(
"");
491 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
492 $(
"#prodiv"+ishow).data(
"rowid",
"");
493 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
495 $(
"#prodivdesc"+ishow).show();
497 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
498 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
499 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
501 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
503 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
504 $(
"#probutton"+ishow).show();
505 if (data[parseInt(idata)][
'price_formated']) {
506 $(
"#proprice" + ishow).attr(
"class",
"productprice");
510 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
514 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
519 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
520 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
521 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
522 $(
"#prodiv"+ishow).data(
"iscat",0);
524 $(
"#prowatermark"+ishow).hide();
533function ClickProduct(
position, qty = 1) {
534 console.log(
"ClickProduct at position"+
position);
535 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
536 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
537 if ($(
'#prodiv'+
position).data(
'iscat') == 1){
538 console.log(
"Click on a category at position "+
position);
542 console.log($(
'#prodiv4').data(
'rowid'));
543 invoiceid = $(
"#invoiceid").val();
544 idproduct=$(
'#prodiv'+
position).data(
'rowid');
545 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
546 if (idproduct ==
"") {
550 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
552 echo
"CustomerDisplay();";
560function ChangeThirdparty(idcustomer) {
561 console.log(
"ChangeThirdparty");
563 $(
"#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() {
569function deleteline() {
570 invoiceid = $(
"#invoiceid").val();
571 console.log(
"Delete line invoiceid="+invoiceid);
572 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
579 console.log(
"Open box to select the thirdparty place="+place);
580 $.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
"); ?>"});
584 console.log(
"Open box to select the contact place="+place);
585 $.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"); ?>"});
590 console.log(
"Open box to select the history");
591 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
594function Reduction() {
595 invoiceid = $(
"#invoiceid").val();
596 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
597 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
600function CloseBill() {
602 if (!empty($conf->global->TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER)) {
603 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
604 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
605 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
609 invoiceid = $(
"#invoiceid").val();
610 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
612 if ($(
"#idcustomer").val() ==
"") {
613 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
624 if (empty($alternative_payurl)) {
630 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
634 invoiceid = $(
"#invoiceid").val();
635 console.log(
"Open popup to split on invoiceid="+invoiceid);
636 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
640 console.log(
"Open box to select floor place="+place);
641 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
645 invoiceid = $(
"#invoiceid").val();
646 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
647 $.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
"); ?>"});
650function TakeposOrderNotes() {
651 console.log(
"Open box to order notes");
652 ModalBox(
'ModalNote');
653 $(
"#textinput").focus();
657 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
658 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
665 invoiceid = $(
"#invoiceid").val();
667 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
669 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
672 if (parseInt(data[
'paye']) === 1) {
675 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
680 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
685 $(
"#idcustomer").val(
"");
697function Search2(keyCodeForEnter, moreorless) {
698 var eventKeyCode = window.event.keyCode;
700 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
702 var search_term = $(
'#search').val();
703 var search_start = 0;
704 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
705 if (moreorless !=
null) {
706 search_term = $(
'#search_pagination').val();
707 search_start = $(
'#search_start_'+moreorless).val();
710 console.log(
"search_term="+search_term);
712 if (search_term ==
'') {
713 $(
"[id^=prowatermark]").html(
"");
714 $(
"[id^=prodesc]").text(
"");
715 $(
"[id^=probutton]").text(
"");
716 $(
"[id^=probutton]").hide();
717 $(
"[id^=proprice]").attr(
"class",
"hidden");
718 $(
"[id^=proprice]").html(
"");
719 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
720 $(
"[id^=prodiv]").data(
"rowid",
"");
721 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
726 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
730 if (search ===
true) {
734 clearTimeout(search2_timer);
738 search2_timer = setTimeout(
function(){
740 jQuery(
".wrapper2 .catwatermark").hide();
741 var nbsearchresults = 0;
742 $.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) {
743 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
744 if (typeof (data[i]) ==
"undefined") {
745 $(
"#prowatermark" + i).html(
"");
746 $(
"#prodesc" + i).text(
"");
747 $(
"#probutton" + i).text(
"");
748 $(
"#probutton" + i).hide();
749 $(
"#proprice" + i).attr(
"class",
"hidden");
750 $(
"#proprice" + i).html(
"");
751 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
752 $(
"#prodiv" + i).data(
"rowid",
"");
753 $(
"#prodiv" + i).attr(
"data-rowid",
"");
757 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
758 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
760 var titlestring = <?php echo $titlestring; ?>;
762 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
763 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
764 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
766 $(
"#prodesc" + i).html(data[i][
'label']);
768 $(
"#prodivdesc" + i).show();
769 $(
"#probutton" + i).html(data[i][
'label']);
770 $(
"#probutton" + i).show();
771 if (data[i][
'price_formated']) {
772 $(
"#proprice" + i).attr(
"class",
"productprice");
776 $(
"#proprice" + i).html(data[i][
'price_formated']);
780 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
785 $(
"#proimg" + i).attr(
"title", titlestring);
786 if( undefined !== data[i][
'img']) {
787 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
790 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
792 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
793 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
794 $(
"#prodiv" + i).data(
"iscat", 0);
795 $(
"#prodiv" + i).attr(
"data-iscat", 0);
799 $parameters = array();
800 $parameters[
'caller'] =
'search2';
801 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
802 print $hookmanager->resPrint;
807 }).always(
function (data) {
809 if ($(
'#search').val().length > 0 && data.length == 1) {
810 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
811 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
812 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
813 ChangeThirdparty(data[0][
'rowid']);
815 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
816 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']);
817 ClickProduct(0, data[0][
'qty']);
820 if (eventKeyCode == keyCodeForEnter){
821 if (data.length == 0) {
822 $(
'#search').val(
'<?php
823 $langs->load('errors
');
824 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
825 ?> ('+search_term+
')');
826 $(
'#search').select();
828 else ClearSearch(
false);
831 $(
"#search_pagination").val($(
"#search").val());
832 if (search_start == 0) {
833 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
836 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
837 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
838 $(
"#search_start_less").val(search_start_less);
840 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
841 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
844 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
845 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
846 $(
"#search_start_more").val(search_start_more);
855function Edit(number) {
856 console.log(
"We click on PAD on key="+number);
858 if (typeof(selectedtext) ==
"undefined") {
862 var text=selectedtext+
"<br> ";
868 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
869 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
870 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
872 }
else if (number==
'qty') {
873 if (editaction==
'qty' && editnumber !=
'') {
874 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
877 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
880 setFocusOnSearchField();
886 }
else if (number==
'p') {
887 if (editaction==
'p' && editnumber!=
"") {
888 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
891 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
900 }
else if (number==
'r') {
901 if (editaction==
'r' && editnumber!=
"") {
902 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
905 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
916 editnumber=editnumber+number;
918 if (editaction==
'qty'){
919 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
920 $(
"#qty").html(
"OK").addClass(
"clicked");
921 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
922 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
924 if (editaction==
'p'){
925 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
926 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
927 $(
"#price").html(
"OK").addClass(
"clicked");
928 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
930 if (editaction==
'r'){
931 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
932 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
933 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
934 $(
"#reduction").html(
"OK").addClass(
"clicked");
936 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
940function TakeposPrintingOrder(){
941 console.log(
"TakeposPrintingOrder");
942 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
947function TakeposPrintingTemp(){
948 console.log(
"TakeposPrintingTemp");
949 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
954function OpenDrawer(){
955 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
958 data: { token:
'notrequired' },
960 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
961 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
963 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
970function DolibarrOpenDrawer() {
971 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
"]); ?>");
974 data: { token:
'<?php echo currentToken(); ?>' },
975 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
979function MoreActions(totalactions){
982 for (i = 0; i <= totalactions; i++){
983 if (i<12) $(
"#action"+i).hide();
984 else $(
"#action"+i).show();
987 else if (pageactions==1){
989 for (i = 0; i <= totalactions; i++){
990 if (i<12) $(
"#action"+i).show();
991 else $(
"#action"+i).hide();
998function ControlCashOpening()
1000 $.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
"); ?>"});
1003function CloseCashFence(
rowid)
1005 $.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
"); ?>"});
1008function CashReport(
rowid)
1010 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+
rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1014function ModalBox(ModalID)
1016 var modal = document.getElementById(ModalID);
1017 modal.style.display =
"block";
1020function DirectPayment(){
1021 console.log(
"DirectPayment");
1022 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1026function FullScreen() {
1027 document.documentElement.requestFullscreen();
1030function WeighingScale(){
1031 console.log(
"Weighing Scale");
1034 data: { token:
'notrequired' },
1035 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1037 .done(
function( editnumber ) {
1038 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1044$( document ).ready(
function() {
1050 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1051 print
"ModalBox('ModalTerminal');";
1055 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1056 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
1057 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1059 $resql = $db->query($sql);
1061 $obj = $db->fetch_object($resql);
1063 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1064 print
"ControlCashOpening();";
1071 var elem1 = $(
"#topnav-left")[0];
1072 var elem2 = $(
"#topnav-right")[0];
1073 var checkOverflow =
function() {
1074 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1075 else $(
"#topnav").removeClass(
"overflow");
1078 var scrollBars =
function(){
1079 var container= $(
'#topnav')[0];
1081 vertical:container.scrollHeight > container.clientHeight,
1082 horizontal:container.scrollWidth > container.clientWidth
1086 $(window).resize(
function(){
1090 let resizeObserver =
new ResizeObserver(() => {
1093 resizeObserver.observe(elem1);
1094 resizeObserver.observe(elem2);
1097 var pressTimer = [];
1101 $(
".indicator").mousedown(
function(){
1102 direction = $(
this).hasClass(
"left") ? -1 : 1;
1104 pressTimer.push(setInterval(scrollTo, 100));
1107 $(
".indicator").mouseup(
function(){
1108 pressTimer.forEach(clearInterval);
1111 $(
"body").mouseup(
function(){
1112 pressTimer.forEach(clearInterval);
1113 console.log(
"body mouseup");
1116 function scrollTo(){
1117 console.log(
"here");
1118 var pos = $(
"#topnav").scrollLeft();
1119 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1122 $(
"#topnav").scroll(
function(){
1123 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1132$keyCodeForEnter =
'';
1133if (!empty($_SESSION[
'takeposterminal'])) {
1134 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalString(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1137<div
class=
"container">
1142 <div
class=
"header">
1143 <div
id=
"topnav" class=
"topnav">
1144 <div
id=
"topnav-left" class=
"topnav-left">
1145 <div
class=
"inline-block valignmiddle">
1146 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1147 <span
class=
"fa fa-cash-register"></span>
1148 <span
class=
"hideonsmartphone">
1150 if (!empty($_SESSION[
"takeposterminal"])) {
1151 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1156 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1159 if (isModEnabled(
'multicurrency')) {
1160 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1161 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1165 <!-- section
for customer -->
1166 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1167 <input
type=
"hidden" id=
"idcustomer" value=
"">
1168 <!-- section
for shopping carts -->
1169 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1170 <!-- More info about customer -->
1171 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1173 if (isModEnabled(
'stock')) {
1175 <!-- More info about warehouse -->
1176 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1180 <div
id=
"topnav-right" class=
"topnav-right">
1182 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1183 if ($reshook == 0) {
1185 <div
class=
"login_block_other takepos">
1186 <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>
1187 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1188 <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 -->
1189 <span
class=
"fas fa-home"></span></a>
1190 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1191 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1197 <div
class=
"login_block_user">
1199 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1203 <div
class=
"arrows">
1204 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1205 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1213<!-- Modal terminal box -->
1214<div
id=
"ModalTerminal" class=
"modal">
1215 <div
class=
"modal-content">
1216 <div
class=
"modal-header">
1220 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1223 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1225 <div
class=
"modal-body">
1226 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1229 for ($i = 2; $i <= $nbloop; $i++) {
1230 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1237<!-- Modal multicurrency box -->
1238<?php if (isModEnabled('multicurrency')) { ?>
1239<div id="ModalCurrency
" class="modal
">
1240 <div class="modal-content
">
1241 <div class="modal-header
">
1242 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1243 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1245 <div class="modal-body
">
1247 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1248 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1249 $resql = $db->query($sql);
1251 while ($obj = $db->fetch_object($resql)) {
1252 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1261<!-- Modal terminal Credit Note -->
1262<div id="ModalCreditNote
" class="modal
">
1263 <div class="modal-content
">
1264 <div class="modal-header
">
1265 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1266 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1268 <div class="modal-body
">
1269 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1270 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1276<div id="ModalNote
" class="modal
">
1277 <div class="modal-content
">
1278 <div class="modal-header
">
1279 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1280 <h3><?php print $langs->trans("Note
"); ?></h3>
1282 <div class="modal-body
">
1283 <input type="text
" class="block
" id="textinput
">
1284 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1293 <div id="poslines
" class="div1
">
1297 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1298 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1299 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1300 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1301 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1302 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1303 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1304 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1305 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1306 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1307 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1308 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1309 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1310 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1311 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1312 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1317// TakePOS setup check
1318if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1319 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1320 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1321 $sql .= " AND active = 1
";
1322 $sql .= " ORDER BY libelle
";
1324 $resql = $db->query($sql);
1325 $paiementsModes = array();
1327 while ($obj = $db->fetch_object($resql)) {
1328 $paycode = $obj->code;
1329 if ($paycode == 'LIQ') {
1332 if ($paycode == 'CHQ') {
1333 $paycode = 'CHEQUE';
1336 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1337 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1338 if (getDolGlobalInt($constantforkey) > 0) {
1339 array_push($paiementsModes, $obj);
1344 if (empty($paiementsModes) && isModEnabled("bank
")) {
1345 $langs->load('errors');
1346 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1347 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1351if (count($maincategories) == 0) {
1352 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1353 $tmpcategory = new Categorie($db);
1354 $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID'));
1355 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1357 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1360// User menu and external TakePOS modules
1364if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1365 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1367 // BAR RESTAURANT specific menu
1368 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1371if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1372 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1373 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1375 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1378if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1379 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1381$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1382$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1384if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1385 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1388// BAR RESTAURANT specific menu
1389if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1390 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1391 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action' => 'TakeposPrintingOrder();');
1395// Last action that close the sell (payments)
1396$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1397if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1398 $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();');
1401// BAR RESTAURANT specific menu
1402if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1403 //Button to print receipt before payment
1404 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1405 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1406 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1407 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposConnector(placeid);');
1409 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1411 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1412 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1414 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'Print(placeid);');
1417 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1418 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1420 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1421 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1425if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1426 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1428if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1429 $menus[$r++] = array(
1430 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1431 'action' => 'DolibarrOpenDrawer();',
1435$sql = "SELECT
rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1436$sql .= " entity =
".((int) $conf->entity)." AND
";
1437$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1438$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1440$resql = $db->query($sql);
1442 $num = $db->num_rows($resql);
1444 $obj = $db->fetch_object($resql);
1445 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1446 if ($obj->status == 0) {
1447 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1452$parameters = array('menus' => $menus);
1453$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1454if ($reshook == 0) { //add buttons
1455 if (is_array($hookmanager->resArray)) {
1456 foreach ($hookmanager->resArray as $resArray) {
1457 foreach ($resArray as $butmenu) {
1458 $menus[$r++] = $butmenu;
1461 } elseif ($reshook == 1) {
1462 $r = 0; //replace buttons
1463 if (is_array($hookmanager->resArray)) {
1464 foreach ($hookmanager->resArray as $resArray) {
1465 foreach ($resArray as $butmenu) {
1466 $menus[$r++] = $butmenu;
1474 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1477if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1478 $menus[$r++] = array('title' => '<span class="fa fa-sign-out-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Logout
").'</div>', 'action' => 'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php?token='.newToken().'\';');
1481if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1482 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale paddingrightonly
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1486 <!-- Show buttons -->
1490 foreach ($menus as $menu) {
1492 if (count($menus) > 12 and $i == 12) {
1493 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1494 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1495 } elseif ($i > 12) {
1496 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1498 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1502 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1503 print '<!-- Show the search input text -->'."\n
";
1504 print '<div class="margintoponly
">';
1505 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> ';
1506 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear').'</a>';
1517 <!-- Show categories -->
1519 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1520 print '<div class="div4
" style= "display: none;
">';
1522 print '<div class="div4
">';
1526 while ($count < $MAXCATEG) {
1528 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1529 echo 'onclick="MoreCategories(\
'less\')"';
1530 } elseif ($count == ($MAXCATEG - 1)) {
1531 echo
'onclick="MoreCategories(\'more\')"';
1533 echo
'onclick="LoadProducts('.$count.
')"';
1534 } ?>
id=
"catdiv<?php echo $count; ?>">
1536 if ($count == ($MAXCATEG - 2)) {
1538 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1539 } elseif ($count == ($MAXCATEG - 1)) {
1541 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1544 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1547 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1548 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1549 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1552 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1560 <!-- Show product -->
1561 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1562 print ' centpercent';
1567 while ($count < $MAXPRODUCT) {
1568 print
'<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ?
' arrow' :
'').
'" id="prodiv'.$count.
'" '; ?>
1569 <?php
if ($count == ($MAXPRODUCT - 2)) {
1570 ?> onclick=
"MoreProducts('less')" <?php
1572 if ($count == ($MAXPRODUCT - 1)) {
1573 ?> onclick=
"MoreProducts('more')" <?php
1575 echo
'onclick="ClickProduct('.$count.
')"';
1578 if ($count == ($MAXPRODUCT - 2)) {
1580 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1581 } elseif ($count == ($MAXPRODUCT - 1)) {
1583 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1586 print
'<div class="" id="proprice'.$count.
'"></div>';
1589 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1591 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1594 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1595 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1596 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1599 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1605 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1606 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1607 <input
type=
"hidden" id=
"search_pagination" value=
"">
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Class to manage categories.
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 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.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e rowid