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 offset = <?php echo($MAXPRODUCT - 2); ?> * pageproducts;
474 $.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) {
475 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
477 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
478 pageproducts=pageproducts-1;
482 while (ishow < maxproduct) {
483 if (typeof (data[idata]) ==
"undefined") {
484 $(
"#prodivdesc"+ishow).hide();
485 $(
"#prodesc"+ishow).text(
"");
486 $(
"#probutton"+ishow).text(
"");
487 $(
"#probutton"+ishow).hide();
488 $(
"#proprice"+ishow).attr(
"class",
"");
489 $(
"#proprice"+ishow).html(
"");
490 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
491 $(
"#prodiv"+ishow).data(
"rowid",
"");
492 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
494 $(
"#prodivdesc"+ishow).show();
496 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
497 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
498 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
500 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
502 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
503 $(
"#probutton"+ishow).show();
504 if (data[parseInt(idata)][
'price_formated']) {
505 $(
"#proprice" + ishow).attr(
"class",
"productprice");
509 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
513 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
518 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
519 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
520 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
521 $(
"#prodiv"+ishow).data(
"iscat",0);
523 $(
"#prowatermark"+ishow).hide();
532function ClickProduct(
position, qty = 1) {
533 console.log(
"ClickProduct at position"+
position);
534 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
535 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
536 if ($(
'#prodiv'+
position).data(
'iscat') == 1){
537 console.log(
"Click on a category at position "+
position);
541 console.log($(
'#prodiv4').data(
'rowid'));
542 invoiceid = $(
"#invoiceid").val();
543 idproduct=$(
'#prodiv'+
position).data(
'rowid');
544 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
545 if (idproduct ==
"") {
549 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
551 echo
"CustomerDisplay();";
559function ChangeThirdparty(idcustomer) {
560 console.log(
"ChangeThirdparty");
562 $(
"#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() {
568function deleteline() {
569 invoiceid = $(
"#invoiceid").val();
570 console.log(
"Delete line invoiceid="+invoiceid);
571 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
578 console.log(
"Open box to select the thirdparty place="+place);
579 $.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
"); ?>"});
583 console.log(
"Open box to select the contact place="+place);
584 $.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"); ?>"});
589 console.log(
"Open box to select the history");
590 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
593function Reduction() {
594 invoiceid = $(
"#invoiceid").val();
595 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
596 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
599function CloseBill() {
601 if (!empty($conf->global->TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER)) {
602 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
603 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
604 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
608 invoiceid = $(
"#invoiceid").val();
609 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
611 if ($(
"#idcustomer").val() ==
"") {
612 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
623 if (empty($alternative_payurl)) {
629 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
633 invoiceid = $(
"#invoiceid").val();
634 console.log(
"Open popup to split on invoiceid="+invoiceid);
635 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
639 console.log(
"Open box to select floor place="+place);
640 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
644 invoiceid = $(
"#invoiceid").val();
645 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
646 $.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
"); ?>"});
649function TakeposOrderNotes() {
650 console.log(
"Open box to order notes");
651 ModalBox(
'ModalNote');
652 $(
"#textinput").focus();
656 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
657 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
664 invoiceid = $(
"#invoiceid").val();
666 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
668 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
671 if (parseInt(data[
'paye']) === 1) {
674 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
679 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
684 $(
"#idcustomer").val(
"");
696function Search2(keyCodeForEnter, moreorless) {
697 var eventKeyCode = window.event.keyCode;
699 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
701 var search_term = $(
'#search').val();
702 var search_start = 0;
703 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
704 if (moreorless !=
null) {
705 search_term = $(
'#search_pagination').val();
706 search_start = $(
'#search_start_'+moreorless).val();
709 console.log(
"search_term="+search_term);
711 if (search_term ==
'') {
712 $(
"[id^=prowatermark]").html(
"");
713 $(
"[id^=prodesc]").text(
"");
714 $(
"[id^=probutton]").text(
"");
715 $(
"[id^=probutton]").hide();
716 $(
"[id^=proprice]").attr(
"class",
"hidden");
717 $(
"[id^=proprice]").html(
"");
718 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
719 $(
"[id^=prodiv]").data(
"rowid",
"");
720 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
725 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
729 if (search ===
true) {
733 clearTimeout(search2_timer);
737 search2_timer = setTimeout(
function(){
739 jQuery(
".wrapper2 .catwatermark").hide();
740 var nbsearchresults = 0;
741 $.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) {
742 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
743 if (typeof (data[i]) ==
"undefined") {
744 $(
"#prowatermark" + i).html(
"");
745 $(
"#prodesc" + i).text(
"");
746 $(
"#probutton" + i).text(
"");
747 $(
"#probutton" + i).hide();
748 $(
"#proprice" + i).attr(
"class",
"hidden");
749 $(
"#proprice" + i).html(
"");
750 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
751 $(
"#prodiv" + i).data(
"rowid",
"");
752 $(
"#prodiv" + i).attr(
"data-rowid",
"");
756 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
757 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
759 var titlestring = <?php echo $titlestring; ?>;
761 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
762 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
763 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
765 $(
"#prodesc" + i).html(data[i][
'label']);
767 $(
"#prodivdesc" + i).show();
768 $(
"#probutton" + i).html(data[i][
'label']);
769 $(
"#probutton" + i).show();
770 if (data[i][
'price_formated']) {
771 $(
"#proprice" + i).attr(
"class",
"productprice");
775 $(
"#proprice" + i).html(data[i][
'price_formated']);
779 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
784 $(
"#proimg" + i).attr(
"title", titlestring);
785 if( undefined !== data[i][
'img']) {
786 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
789 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
791 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
792 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
793 $(
"#prodiv" + i).data(
"iscat", 0);
794 $(
"#prodiv" + i).attr(
"data-iscat", 0);
798 $parameters = array();
799 $parameters[
'caller'] =
'search2';
800 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
801 print $hookmanager->resPrint;
806 }).always(
function (data) {
808 if ($(
'#search').val().length > 0 && data.length == 1) {
809 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
810 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
811 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
812 ChangeThirdparty(data[0][
'rowid']);
814 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
815 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']);
816 ClickProduct(0, data[0][
'qty']);
819 if (eventKeyCode == keyCodeForEnter){
820 if (data.length == 0) {
821 $(
'#search').val(
'<?php
822 $langs->load('errors
');
823 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
824 ?> ('+search_term+
')');
825 $(
'#search').select();
827 else ClearSearch(
false);
830 $(
"#search_pagination").val($(
"#search").val());
831 if (search_start == 0) {
832 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
835 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
836 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
837 $(
"#search_start_less").val(search_start_less);
839 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
840 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
843 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
844 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
845 $(
"#search_start_more").val(search_start_more);
854function Edit(number) {
855 console.log(
"We click on PAD on key="+number);
857 if (typeof(selectedtext) ==
"undefined") {
861 var text=selectedtext+
"<br> ";
867 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
868 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
869 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
871 }
else if (number==
'qty') {
872 if (editaction==
'qty' && editnumber !=
'') {
873 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
876 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
879 setFocusOnSearchField();
885 }
else if (number==
'p') {
886 if (editaction==
'p' && editnumber!=
"") {
887 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
890 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
899 }
else if (number==
'r') {
900 if (editaction==
'r' && editnumber!=
"") {
901 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
904 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
915 editnumber=editnumber+number;
917 if (editaction==
'qty'){
918 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
919 $(
"#qty").html(
"OK").addClass(
"clicked");
920 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
921 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
923 if (editaction==
'p'){
924 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
925 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
926 $(
"#price").html(
"OK").addClass(
"clicked");
927 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
929 if (editaction==
'r'){
930 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
931 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
932 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
933 $(
"#reduction").html(
"OK").addClass(
"clicked");
935 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
939function TakeposPrintingOrder(){
940 console.log(
"TakeposPrintingOrder");
941 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
946function TakeposPrintingTemp(){
947 console.log(
"TakeposPrintingTemp");
948 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
953function OpenDrawer(){
954 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
957 data: { token:
'notrequired' },
959 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
960 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
962 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
969function DolibarrOpenDrawer() {
970 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
"]); ?>");
973 data: { token:
'<?php echo currentToken(); ?>' },
974 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
978function MoreActions(totalactions){
981 for (i = 0; i <= totalactions; i++){
982 if (i<12) $(
"#action"+i).hide();
983 else $(
"#action"+i).show();
986 else if (pageactions==1){
988 for (i = 0; i <= totalactions; i++){
989 if (i<12) $(
"#action"+i).show();
990 else $(
"#action"+i).hide();
997function ControlCashOpening()
999 $.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
"); ?>"});
1002function CloseCashFence(
rowid)
1004 $.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
"); ?>"});
1007function CashReport(
rowid)
1009 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+
rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1013function ModalBox(ModalID)
1015 var modal = document.getElementById(ModalID);
1016 modal.style.display =
"block";
1019function DirectPayment(){
1020 console.log(
"DirectPayment");
1021 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1025function FullScreen() {
1026 document.documentElement.requestFullscreen();
1029function WeighingScale(){
1030 console.log(
"Weighing Scale");
1033 data: { token:
'notrequired' },
1034 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1036 .done(
function( editnumber ) {
1037 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1043$( document ).ready(
function() {
1049 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1050 print
"ModalBox('ModalTerminal');";
1054 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1055 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
1056 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1058 $resql = $db->query($sql);
1060 $obj = $db->fetch_object($resql);
1062 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1063 print
"ControlCashOpening();";
1070 var elem1 = $(
"#topnav-left")[0];
1071 var elem2 = $(
"#topnav-right")[0];
1072 var checkOverflow =
function() {
1073 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1074 else $(
"#topnav").removeClass(
"overflow");
1077 var scrollBars =
function(){
1078 var container= $(
'#topnav')[0];
1080 vertical:container.scrollHeight > container.clientHeight,
1081 horizontal:container.scrollWidth > container.clientWidth
1085 $(window).resize(
function(){
1089 let resizeObserver =
new ResizeObserver(() => {
1092 resizeObserver.observe(elem1);
1093 resizeObserver.observe(elem2);
1096 var pressTimer = [];
1100 $(
".indicator").mousedown(
function(){
1101 direction = $(
this).hasClass(
"left") ? -1 : 1;
1103 pressTimer.push(setInterval(scrollTo, 100));
1106 $(
".indicator").mouseup(
function(){
1107 pressTimer.forEach(clearInterval);
1110 $(
"body").mouseup(
function(){
1111 pressTimer.forEach(clearInterval);
1112 console.log(
"body mouseup");
1115 function scrollTo(){
1116 console.log(
"here");
1117 var pos = $(
"#topnav").scrollLeft();
1118 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1121 $(
"#topnav").scroll(
function(){
1122 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1131$keyCodeForEnter =
'';
1132if (!empty($_SESSION[
'takeposterminal'])) {
1133 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalString(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1136<div
class=
"container">
1141 <div
class=
"header">
1142 <div
id=
"topnav" class=
"topnav">
1143 <div
id=
"topnav-left" class=
"topnav-left">
1144 <div
class=
"inline-block valignmiddle">
1145 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1146 <span
class=
"fa fa-cash-register"></span>
1147 <span
class=
"hideonsmartphone">
1149 if (!empty($_SESSION[
"takeposterminal"])) {
1150 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1155 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1158 if (isModEnabled(
'multicurrency')) {
1159 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1160 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1164 <!-- section
for customer -->
1165 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1166 <input
type=
"hidden" id=
"idcustomer" value=
"">
1167 <!-- section
for shopping carts -->
1168 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1169 <!-- More info about customer -->
1170 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1172 if (isModEnabled(
'stock')) {
1174 <!-- More info about warehouse -->
1175 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1179 <div
id=
"topnav-right" class=
"topnav-right">
1181 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1182 if ($reshook == 0) {
1184 <div
class=
"login_block_other takepos">
1185 <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>
1186 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1187 <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 -->
1188 <span
class=
"fas fa-home"></span></a>
1189 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1190 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1196 <div
class=
"login_block_user">
1198 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1202 <div
class=
"arrows">
1203 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1204 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1212<!-- Modal terminal box -->
1213<div
id=
"ModalTerminal" class=
"modal">
1214 <div
class=
"modal-content">
1215 <div
class=
"modal-header">
1219 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1222 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1224 <div
class=
"modal-body">
1225 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1228 for ($i = 2; $i <= $nbloop; $i++) {
1229 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1236<!-- Modal multicurrency box -->
1237<?php if (isModEnabled('multicurrency')) { ?>
1238<div id="ModalCurrency
" class="modal
">
1239 <div class="modal-content
">
1240 <div class="modal-header
">
1241 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1242 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1244 <div class="modal-body
">
1246 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1247 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1248 $resql = $db->query($sql);
1250 while ($obj = $db->fetch_object($resql)) {
1251 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1260<!-- Modal terminal Credit Note -->
1261<div id="ModalCreditNote
" class="modal
">
1262 <div class="modal-content
">
1263 <div class="modal-header
">
1264 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1265 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1267 <div class="modal-body
">
1268 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1269 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1275<div id="ModalNote
" class="modal
">
1276 <div class="modal-content
">
1277 <div class="modal-header
">
1278 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1279 <h3><?php print $langs->trans("Note
"); ?></h3>
1281 <div class="modal-body
">
1282 <input type="text
" class="block
" id="textinput
">
1283 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1292 <div id="poslines
" class="div1
">
1296 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1297 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1298 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1299 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1300 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1301 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1302 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1303 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1304 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1305 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1306 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1307 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1308 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1309 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1310 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1311 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1316// TakePOS setup check
1317if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1318 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1319 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1320 $sql .= " AND active = 1
";
1321 $sql .= " ORDER BY libelle
";
1323 $resql = $db->query($sql);
1324 $paiementsModes = array();
1326 while ($obj = $db->fetch_object($resql)) {
1327 $paycode = $obj->code;
1328 if ($paycode == 'LIQ') {
1331 if ($paycode == 'CHQ') {
1332 $paycode = 'CHEQUE';
1335 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1336 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1337 if (getDolGlobalInt($constantforkey) > 0) {
1338 array_push($paiementsModes, $obj);
1343 if (empty($paiementsModes) && isModEnabled("bank
")) {
1344 $langs->load('errors');
1345 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1346 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1350if (count($maincategories) == 0) {
1351 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1352 $tmpcategory = new Categorie($db);
1353 $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID'));
1354 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1356 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1359// User menu and external TakePOS modules
1363if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1364 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1366 // BAR RESTAURANT specific menu
1367 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1370if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1371 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1372 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1374 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1377if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1378 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1380$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1381$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1383if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1384 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1387// BAR RESTAURANT specific menu
1388if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1389 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1390 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action' => 'TakeposPrintingOrder();');
1394// Last action that close the sell (payments)
1395$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1396if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1397 $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();');
1400// BAR RESTAURANT specific menu
1401if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1402 //Button to print receipt before payment
1403 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1404 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1405 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1406 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposConnector(placeid);');
1408 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1410 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1411 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1413 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'Print(placeid);');
1416 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1417 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1419 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1420 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1424if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1425 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1427if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1428 $menus[$r++] = array(
1429 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1430 'action' => 'DolibarrOpenDrawer();',
1434$sql = "SELECT
rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1435$sql .= " entity =
".((int) $conf->entity)." AND
";
1436$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1437$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1439$resql = $db->query($sql);
1441 $num = $db->num_rows($resql);
1443 $obj = $db->fetch_object($resql);
1444 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1445 if ($obj->status == 0) {
1446 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1451$parameters = array('menus' => $menus);
1452$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1453if ($reshook == 0) { //add buttons
1454 if (is_array($hookmanager->resArray)) {
1455 foreach ($hookmanager->resArray as $resArray) {
1456 foreach ($resArray as $butmenu) {
1457 $menus[$r++] = $butmenu;
1460 } elseif ($reshook == 1) {
1461 $r = 0; //replace buttons
1462 if (is_array($hookmanager->resArray)) {
1463 foreach ($hookmanager->resArray as $resArray) {
1464 foreach ($resArray as $butmenu) {
1465 $menus[$r++] = $butmenu;
1473 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1476if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1477 $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().'\';');
1480if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1481 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale paddingrightonly
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1485 <!-- Show buttons -->
1489 foreach ($menus as $menu) {
1491 if (count($menus) > 12 and $i == 12) {
1492 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1493 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1494 } elseif ($i > 12) {
1495 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1497 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1501 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1502 print '<!-- Show the search input text -->'."\n
";
1503 print '<div class="margintoponly
">';
1504 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> ';
1505 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear').'</a>';
1516 <!-- Show categories -->
1518 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1519 print '<div class="div4
" style= "display: none;
">';
1521 print '<div class="div4
">';
1525 while ($count < $MAXCATEG) {
1527 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1528 echo 'onclick="MoreCategories(\
'less\')"';
1529 } elseif ($count == ($MAXCATEG - 1)) {
1530 echo
'onclick="MoreCategories(\'more\')"';
1532 echo
'onclick="LoadProducts('.$count.
')"';
1533 } ?>
id=
"catdiv<?php echo $count; ?>">
1535 if ($count == ($MAXCATEG - 2)) {
1537 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1538 } elseif ($count == ($MAXCATEG - 1)) {
1540 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1543 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1546 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1547 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1548 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1551 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1559 <!-- Show product -->
1560 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1561 print ' centpercent';
1566 while ($count < $MAXPRODUCT) {
1567 print
'<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ?
' arrow' :
'').
'" id="prodiv'.$count.
'" '; ?>
1568 <?php
if ($count == ($MAXPRODUCT - 2)) {
1569 ?> onclick=
"MoreProducts('less')" <?php
1571 if ($count == ($MAXPRODUCT - 1)) {
1572 ?> onclick=
"MoreProducts('more')" <?php
1574 echo
'onclick="ClickProduct('.$count.
')"';
1577 if ($count == ($MAXPRODUCT - 2)) {
1579 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1580 } elseif ($count == ($MAXPRODUCT - 1)) {
1582 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1585 print
'<div class="" id="proprice'.$count.
'"></div>';
1588 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1590 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1593 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1594 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1595 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1598 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1604 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1605 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1606 <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