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'];
120$form =
new Form($db);
124$arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
125$arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
128 $arrayofcss[] =
'/takepos/css/colorful.css';
133$title =
'TakePOS - Dolibarr '.DOL_VERSION;
137$head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
138<meta name="apple-mobile-web-app-capable" content="yes">
139<meta name="mobile-web-app-capable" content="yes">
140<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
141top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
144$categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
149$levelofrootcategory = 0;
151 foreach ($categories as $key => $categorycursor) {
152 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
153 $levelofrootcategory = $categorycursor[
'level'];
159$levelofmaincategories = $levelofrootcategory + 1;
161$maincategories = array();
162$subcategories = array();
163foreach ($categories as $key => $categorycursor) {
164 if ($categorycursor[
'level'] == $levelofmaincategories) {
165 $maincategories[$key] = $categorycursor;
167 $subcategories[$key] = $categorycursor;
175<body
class=
"bodytakepos" style=
"overflow: hidden;">
178var categories = <?php echo json_encode($maincategories); ?>;
179var subcategories = <?php echo json_encode($subcategories); ?>;
185var place=
"<?php echo $place; ?>";
189var search2_timer=
null;
208function ClearSearch(clearSearchResults) {
209 console.log(
"ClearSearch");
210 $(
"#search").val(
'');
211 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
212 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
213 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
214 <?php
if ($conf->browser->layout ==
'classic') { ?>
215 setFocusOnSearchField();
217 if (clearSearchResults) {
218 $(
"#search").trigger(
'keyup');
223function setFocusOnSearchField() {
224 console.log(
"Call setFocusOnSearchField in page index.php");
225 <?php
if ($conf->browser->layout ==
'classic') { ?>
226 console.log(
"has keyboard from localStorage, so we can force focus on search field");
227 $(
"#search").focus();
231function PrintCategories(first) {
232 console.log(
"PrintCategories");
233 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
234 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
236 $(
"#catdivdesc"+i).hide();
237 $(
"#catdesc"+i).text(
"");
238 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
239 $(
"#catwatermark"+i).hide();
240 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
243 $(
"#catdivdesc"+i).show();
246 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
248 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
250 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
251 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
252 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
253 $(
"#catdiv"+i).attr(
'class',
'wrapper');
254 $(
"#catwatermark"+i).show();
258function MoreCategories(moreorless) {
259 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
260 if (moreorless ==
"more") {
261 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
262 $(
'#catimg15').animate({opacity:
'1'}, 100);
263 pagecategories=pagecategories+1;
265 if (moreorless ==
"less") {
266 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
267 $(
'#catimg14').animate({opacity:
'1'}, 100);
268 if (pagecategories==0)
return;
269 pagecategories=pagecategories-1;
271 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
272 pagecategories=pagecategories-1;
276 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
277 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
279 console.log(
"complete with empty record");
280 $(
"#catdivdesc"+i).hide();
281 $(
"#catdesc"+i).text(
"");
282 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
283 $(
"#catwatermark"+i).hide();
286 $(
"#catdivdesc"+i).show();
289 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
291 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
293 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
294 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
295 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
296 $(
"#catwatermark"+i).show();
303function LoadProducts(
position, issubcat) {
304 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
305 var maxproduct = <?php echo (
int) ($MAXPRODUCT - 2); ?>;
308 currentcat=
"supplements";
310 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
311 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
312 if (issubcat ==
true) {
313 currentcat=$(
'#prodiv'+
position).data(
'rowid');
316 currentcat=$(
'#catdiv'+
position).data(
'rowid');
317 console.log(
"currentcat="+currentcat);
320 if (currentcat == undefined) {
326 jQuery.each(subcategories,
function(i, val) {
327 if (currentcat==val.fk_parent) {
328 $(
"#prodivdesc"+ishow).show();
329 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
330 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
331 $(
"#probutton"+ishow).html(val.label);
333 $(
"#prodesc"+ishow).text(val.label);
334 $(
"#probutton"+ishow).text(val.label);
336 $(
"#probutton"+ishow).show();
337 $(
"#proprice"+ishow).attr(
"class",
"hidden");
338 $(
"#proprice"+ishow).html(
"");
339 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
340 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
341 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
342 $(
"#prodiv"+ishow).data(
"iscat", 1);
343 $(
"#prodiv"+ishow).attr(
"data-iscat", 1);
344 $(
"#prodiv"+ishow).removeClass(
"divempty");
345 $(
"#prowatermark"+ishow).show();
352 if (maxproduct >= 1) {
353 limit = maxproduct - 1;
357 let socid = jQuery(
'#thirdpartyid').val();
358 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
359 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
363 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + socid +
'&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset=0',
function(data) {
364 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
367 while (ishow < maxproduct) {
368 console.log(
"ishow"+ishow+
" idata="+idata);
371 if (typeof (data[idata]) ==
"undefined") {
373 echo
'$("#prodivdesc"+ishow).hide();';
374 echo
'$("#prodesc"+ishow).text("");';
375 echo
'$("#proimg"+ishow).attr("title","");';
376 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
378 echo
'$("#probutton"+ishow).hide();';
379 echo
'$("#probutton"+ishow).text("");';
381 $(
"#proprice"+ishow).attr(
"class",
"hidden");
382 $(
"#proprice"+ishow).html(
"");
384 $(
"#prodiv"+ishow).data(
"rowid",
"");
385 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
387 $(
"#prodiv"+ishow).data(
"iscat",
"0");
388 $(
"#prodiv"+ishow).attr(
"data-iscat",
"0");
390 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
393 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
394 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
396 var titlestring = <?php echo $titlestring; ?>;
398 echo
'$("#prodivdesc"+ishow).show();';
400 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
402 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
404 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
406 echo
'$("#proimg"+ishow).attr("title", titlestring);';
407 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
409 echo
'$("#probutton"+ishow).show();';
410 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
413 if (data[parseInt(idata)][
'price_formated']) {
414 $(
"#proprice" + ishow).attr(
"class",
"productprice");
418 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
422 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
427 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
429 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
430 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
431 console.log($(
'#prodiv4').data(
'rowid'));
433 $(
"#prodiv"+ishow).data(
"iscat", 0);
434 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
436 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
440 $parameters = array();
441 $parameters[
'caller'] =
'loadProducts';
442 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
443 print $hookmanager->resPrint;
446 $(
"#prowatermark"+ishow).hide();
455function MoreProducts(moreorless) {
456 console.log(
"MoreProducts");
458 if ($(
'#search_pagination').val() !=
'') {
459 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
462 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
464 if (moreorless==
"more"){
465 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
466 $(
'#proimg31').animate({opacity:
'1'}, 100);
467 pageproducts=pageproducts+1;
469 if (moreorless==
"less"){
470 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
471 $(
'#proimg30').animate({opacity:
'1'}, 100);
472 if (pageproducts==0)
return;
473 pageproducts=pageproducts-1;
479 if (maxproduct >= 1) {
480 limit = maxproduct-1;
483 var nb_cat_shown = $(
'.div5 div.wrapper2[data-iscat=1]').length;
484 var offset = <?php echo ($MAXPRODUCT - 2); ?> * pageproducts - nb_cat_shown;
487 let socid = jQuery(
'#thirdpartyid').val();
488 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
489 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
493 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + socid +
'&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset='+offset,
function(data) {
494 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
496 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
497 pageproducts=pageproducts-1;
501 while (ishow < maxproduct) {
502 if (typeof (data[idata]) ==
"undefined") {
503 $(
"#prodivdesc"+ishow).hide();
504 $(
"#prodesc"+ishow).text(
"");
505 $(
"#probutton"+ishow).text(
"");
506 $(
"#probutton"+ishow).hide();
507 $(
"#proprice"+ishow).attr(
"class",
"");
508 $(
"#proprice"+ishow).html(
"");
509 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
510 $(
"#prodiv"+ishow).data(
"rowid",
"");
511 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
513 $(
"#prodivdesc"+ishow).show();
515 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
516 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
517 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
519 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
521 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
522 $(
"#probutton"+ishow).show();
523 if (data[parseInt(idata)][
'price_formated']) {
524 $(
"#proprice" + ishow).attr(
"class",
"productprice");
528 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
532 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
537 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
538 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
539 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
540 $(
"#prodiv"+ishow).data(
"iscat",0);
542 $(
"#prowatermark"+ishow).hide();
551function ClickProduct(
position, qty = 1) {
552 console.log(
"ClickProduct at position"+
position);
553 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
554 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
555 if ($(
'#prodiv'+
position).data(
'iscat') == 1){
556 console.log(
"Click on a category at position "+
position);
560 console.log($(
'#prodiv4').data(
'rowid'));
561 invoiceid = $(
"#invoiceid").val();
562 idproduct=$(
'#prodiv'+
position).data(
'rowid');
563 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
564 if (idproduct ==
"") {
568 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
570 echo
"CustomerDisplay();";
578function ChangeThirdparty(idcustomer) {
579 console.log(
"ChangeThirdparty");
581 $(
"#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() {
587function deleteline() {
588 invoiceid = $(
"#invoiceid").val();
589 console.log(
"Delete line invoiceid="+invoiceid);
590 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
597 console.log(
"Open box to select the thirdparty place="+place);
598 $.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
"); ?>"});
602 console.log(
"Open box to select the contact place="+place);
603 $.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"); ?>"});
608 console.log(
"Open box to select the history");
609 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
612function Reduction() {
613 invoiceid = $(
"#invoiceid").val();
614 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
615 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
618function CloseBill() {
620 if (!empty($conf->global->TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER)) {
621 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
622 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
623 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
627 invoiceid = $(
"#invoiceid").val();
628 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
630 if ($(
"#idcustomer").val() ==
"") {
631 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
642 if (empty($alternative_payurl)) {
648 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
652 invoiceid = $(
"#invoiceid").val();
653 console.log(
"Open popup to split on invoiceid="+invoiceid);
654 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
658 console.log(
"Open box to select floor place="+place);
659 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
663 invoiceid = $(
"#invoiceid").val();
664 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
665 $.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
"); ?>"});
668function TakeposOrderNotes() {
669 console.log(
"Open box to order notes");
670 ModalBox(
'ModalNote');
671 $(
"#textinput").focus();
675 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
676 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
683 invoiceid = $(
"#invoiceid").val();
685 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
687 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
690 if (parseInt(data[
'paye']) === 1) {
693 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
698 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
703 $(
"#idcustomer").val(
"");
715function Search2(keyCodeForEnter, moreorless) {
716 var eventKeyCode = window.event.keyCode;
718 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
720 var search_term = $(
'#search').val();
721 var search_start = 0;
722 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
723 if (moreorless !=
null) {
724 search_term = $(
'#search_pagination').val();
725 search_start = $(
'#search_start_'+moreorless).val();
728 console.log(
"search_term="+search_term);
730 if (search_term ==
'') {
731 $(
"[id^=prowatermark]").html(
"");
732 $(
"[id^=prodesc]").text(
"");
733 $(
"[id^=probutton]").text(
"");
734 $(
"[id^=probutton]").hide();
735 $(
"[id^=proprice]").attr(
"class",
"hidden");
736 $(
"[id^=proprice]").html(
"");
737 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
738 $(
"[id^=prodiv]").data(
"rowid",
"");
739 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
744 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
748 if (search ===
true) {
752 clearTimeout(search2_timer);
756 search2_timer = setTimeout(
function(){
758 jQuery(
".wrapper2 .catwatermark").hide();
759 var nbsearchresults = 0;
762 let socid = jQuery(
'#thirdpartyid').val();
763 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
764 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
767 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term +
'&thirdpartyid=' + socid +
'&search_start=' + search_start +
'&search_limit=' + search_limit,
function (data) {
768 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
769 if (typeof (data[i]) ==
"undefined") {
770 $(
"#prowatermark" + i).html(
"");
771 $(
"#prodesc" + i).text(
"");
772 $(
"#probutton" + i).text(
"");
773 $(
"#probutton" + i).hide();
774 $(
"#proprice" + i).attr(
"class",
"hidden");
775 $(
"#proprice" + i).html(
"");
776 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
777 $(
"#prodiv" + i).data(
"rowid",
"");
778 $(
"#prodiv" + i).attr(
"data-rowid",
"");
782 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
783 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
785 var titlestring = <?php echo $titlestring; ?>;
787 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
788 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
789 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
791 $(
"#prodesc" + i).html(data[i][
'label']);
793 $(
"#prodivdesc" + i).show();
794 $(
"#probutton" + i).html(data[i][
'label']);
795 $(
"#probutton" + i).show();
796 if (data[i][
'price_formated']) {
797 $(
"#proprice" + i).attr(
"class",
"productprice");
801 $(
"#proprice" + i).html(data[i][
'price_formated']);
805 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
810 $(
"#proimg" + i).attr(
"title", titlestring);
811 if( undefined !== data[i][
'img']) {
812 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
815 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
817 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
818 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
819 $(
"#prodiv" + i).data(
"iscat", 0);
820 $(
"#prodiv" + i).attr(
"data-iscat", 0);
824 $parameters = array();
825 $parameters[
'caller'] =
'search2';
826 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
827 print $hookmanager->resPrint;
832 }).always(
function (data) {
834 if ($(
'#search').val().length > 0 && data.length == 1) {
835 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
836 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
837 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
838 ChangeThirdparty(data[0][
'rowid']);
840 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
841 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']);
842 ClickProduct(0, data[0][
'qty']);
845 if (eventKeyCode == keyCodeForEnter){
846 if (data.length == 0) {
847 $(
'#search').val(
'<?php
848 $langs->load('errors
');
849 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
850 ?> ('+search_term+
')');
851 $(
'#search').select();
853 else ClearSearch(
false);
856 $(
"#search_pagination").val($(
"#search").val());
857 if (search_start == 0) {
858 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
861 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
862 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
863 $(
"#search_start_less").val(search_start_less);
865 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
866 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
869 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
870 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
871 $(
"#search_start_more").val(search_start_more);
880function Edit(number) {
881 console.log(
"We click on PAD on key="+number);
883 if (typeof(selectedtext) ==
"undefined") {
887 var text=selectedtext+
"<br> ";
893 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
894 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
895 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
897 }
else if (number==
'qty') {
898 if (editaction==
'qty' && editnumber !=
'') {
899 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
902 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
905 setFocusOnSearchField();
911 }
else if (number==
'p') {
912 if (editaction==
'p' && editnumber!=
"") {
913 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
916 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
925 }
else if (number==
'r') {
926 if (editaction==
'r' && editnumber!=
"") {
927 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
930 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
941 editnumber=editnumber+number;
943 if (editaction==
'qty'){
944 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
945 $(
"#qty").html(
"OK").addClass(
"clicked");
946 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
947 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
949 if (editaction==
'p'){
950 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
951 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
952 $(
"#price").html(
"OK").addClass(
"clicked");
953 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
955 if (editaction==
'r'){
956 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
957 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
958 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
959 $(
"#reduction").html(
"OK").addClass(
"clicked");
961 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
965function TakeposPrintingOrder(){
966 console.log(
"TakeposPrintingOrder");
967 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
972function TakeposPrintingTemp(){
973 console.log(
"TakeposPrintingTemp");
974 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
979function OpenDrawer(){
980 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
983 data: { token:
'notrequired' },
985 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
986 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
988 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
995function DolibarrOpenDrawer() {
996 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
"]); ?>");
999 data: { token:
'<?php echo currentToken(); ?>' },
1000 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
1004function MoreActions(totalactions){
1005 if (pageactions==0){
1007 for (i = 0; i <= totalactions; i++){
1008 if (i<12) $(
"#action"+i).hide();
1009 else $(
"#action"+i).show();
1012 else if (pageactions==1){
1014 for (i = 0; i <= totalactions; i++){
1015 if (i<12) $(
"#action"+i).show();
1016 else $(
"#action"+i).hide();
1023function ControlCashOpening()
1025 $.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
"); ?>"});
1028function CloseCashFence(
rowid)
1030 $.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
"); ?>"});
1033function CashReport(
rowid)
1035 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+
rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1039function ModalBox(ModalID)
1041 var modal = document.getElementById(ModalID);
1042 modal.style.display =
"block";
1045function DirectPayment(){
1046 console.log(
"DirectPayment");
1047 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1051function FullScreen() {
1052 document.documentElement.requestFullscreen();
1055function WeighingScale(){
1056 console.log(
"Weighing Scale");
1059 data: { token:
'notrequired' },
1060 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1062 .done(
function( editnumber ) {
1063 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1069$( document ).ready(
function() {
1075 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1076 print
"ModalBox('ModalTerminal');";
1080 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1081 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
1082 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1084 $resql = $db->query($sql);
1086 $obj = $db->fetch_object($resql);
1088 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1089 print
"ControlCashOpening();";
1096 var elem1 = $(
"#topnav-left")[0];
1097 var elem2 = $(
"#topnav-right")[0];
1098 var checkOverflow =
function() {
1099 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1100 else $(
"#topnav").removeClass(
"overflow");
1103 var scrollBars =
function(){
1104 var container= $(
'#topnav')[0];
1106 vertical:container.scrollHeight > container.clientHeight,
1107 horizontal:container.scrollWidth > container.clientWidth
1111 $(window).resize(
function(){
1115 let resizeObserver =
new ResizeObserver(() => {
1118 resizeObserver.observe(elem1);
1119 resizeObserver.observe(elem2);
1122 var pressTimer = [];
1126 $(
".indicator").mousedown(
function(){
1127 direction = $(
this).hasClass(
"left") ? -1 : 1;
1129 pressTimer.push(setInterval(scrollTo, 100));
1132 $(
".indicator").mouseup(
function(){
1133 pressTimer.forEach(clearInterval);
1136 $(
"body").mouseup(
function(){
1137 pressTimer.forEach(clearInterval);
1138 console.log(
"body mouseup");
1141 function scrollTo(){
1142 console.log(
"here");
1143 var pos = $(
"#topnav").scrollLeft();
1144 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1147 $(
"#topnav").scroll(
function(){
1148 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1157$keyCodeForEnter =
'';
1158if (!empty($_SESSION[
'takeposterminal'])) {
1159 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalString(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1162<div
class=
"container">
1167 <div
class=
"header">
1168 <div
id=
"topnav" class=
"topnav">
1169 <div
id=
"topnav-left" class=
"topnav-left">
1170 <div
class=
"inline-block valignmiddle">
1171 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1172 <span
class=
"fa fa-cash-register"></span>
1173 <span
class=
"hideonsmartphone">
1175 if (!empty($_SESSION[
"takeposterminal"])) {
1176 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1181 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1184 if (isModEnabled(
'multicurrency')) {
1185 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1186 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1190 <!-- section
for customer -->
1191 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1192 <input
type=
"hidden" id=
"idcustomer" value=
"">
1193 <!-- section
for shopping carts -->
1194 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1195 <!-- More info about customer -->
1196 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1198 if (isModEnabled(
'stock')) {
1200 <!-- More info about warehouse -->
1201 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1205 <div
id=
"topnav-right" class=
"topnav-right">
1207 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1208 if ($reshook == 0) {
1210 <div
class=
"login_block_other takepos">
1211 <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>
1212 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1213 <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 -->
1214 <span
class=
"fas fa-home"></span></a>
1215 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1216 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1222 <div
class=
"login_block_user">
1224 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1228 <div
class=
"arrows">
1229 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1230 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1238<!-- Modal terminal box -->
1239<div
id=
"ModalTerminal" class=
"modal">
1240 <div
class=
"modal-content">
1241 <div
class=
"modal-header">
1245 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1248 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1250 <div
class=
"modal-body">
1251 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1254 for ($i = 2; $i <= $nbloop; $i++) {
1255 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1262<!-- Modal multicurrency box -->
1263<?php if (isModEnabled('multicurrency')) { ?>
1264<div id="ModalCurrency
" class="modal
">
1265 <div class="modal-content
">
1266 <div class="modal-header
">
1267 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1268 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1270 <div class="modal-body
">
1272 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1273 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1274 $resql = $db->query($sql);
1276 while ($obj = $db->fetch_object($resql)) {
1277 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1286<!-- Modal terminal Credit Note -->
1287<div id="ModalCreditNote
" class="modal
">
1288 <div class="modal-content
">
1289 <div class="modal-header
">
1290 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1291 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1293 <div class="modal-body
">
1294 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1295 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1301<div id="ModalNote
" class="modal
">
1302 <div class="modal-content
">
1303 <div class="modal-header
">
1304 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1305 <h3><?php print $langs->trans("Note
"); ?></h3>
1307 <div class="modal-body
">
1308 <input type="text
" class="block
" id="textinput
">
1309 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1318 <div id="poslines
" class="div1
">
1322 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1323 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1324 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1325 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1326 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1327 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1328 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1329 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1330 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1331 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1332 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1333 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1334 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1335 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1336 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1337 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1342// TakePOS setup check
1343if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1344 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1345 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1346 $sql .= " AND active = 1
";
1347 $sql .= " ORDER BY libelle
";
1349 $resql = $db->query($sql);
1350 $paiementsModes = array();
1352 while ($obj = $db->fetch_object($resql)) {
1353 $paycode = $obj->code;
1354 if ($paycode == 'LIQ') {
1357 if ($paycode == 'CHQ') {
1358 $paycode = 'CHEQUE';
1361 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1362 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1363 if (getDolGlobalInt($constantforkey) > 0) {
1364 array_push($paiementsModes, $obj);
1369 if (empty($paiementsModes) && isModEnabled("bank
")) {
1370 $langs->load('errors');
1371 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1372 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1376if (count($maincategories) == 0) {
1377 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1378 $tmpcategory = new Categorie($db);
1379 $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID'));
1380 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1382 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1385// User menu and external TakePOS modules
1389if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1390 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1392 // BAR RESTAURANT specific menu
1393 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1396if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1397 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1398 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1400 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1403if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1404 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1406$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1407$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1409if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1410 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1413// BAR RESTAURANT specific menu
1414if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1415 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1416 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action' => 'TakeposPrintingOrder();');
1420// Last action that close the sell (payments)
1421$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1422if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1423 $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();');
1426// BAR RESTAURANT specific menu
1427if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1428 //Button to print receipt before payment
1429 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1430 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1431 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1432 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposConnector(placeid);');
1434 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1436 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1437 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1439 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'Print(placeid);');
1442 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1443 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1445 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1446 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1450if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1451 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1453if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1454 $menus[$r++] = array(
1455 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1456 'action' => 'DolibarrOpenDrawer();',
1460$sql = "SELECT
rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1461$sql .= " entity =
".((int) $conf->entity)." AND
";
1462$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1463$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1465$resql = $db->query($sql);
1467 $num = $db->num_rows($resql);
1469 $obj = $db->fetch_object($resql);
1470 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1471 if ($obj->status == 0) {
1472 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1477$parameters = array('menus' => $menus);
1478$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1479if ($reshook == 0) { //add buttons
1480 if (is_array($hookmanager->resArray)) {
1481 foreach ($hookmanager->resArray as $resArray) {
1482 foreach ($resArray as $butmenu) {
1483 $menus[$r++] = $butmenu;
1487} elseif ($reshook == 1) {
1488 $r = 0; //replace buttons
1489 if (is_array($hookmanager->resArray) ) {
1490 foreach ($hookmanager->resArray as $resArray) {
1491 foreach ($resArray as $butmenu) {
1492 $menus[$r++] = $butmenu;
1499 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1502if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1503 $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().'\';');
1506if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1507 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale paddingrightonly
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1511 <!-- Show buttons -->
1515 foreach ($menus as $menu) {
1517 if (count($menus) > 12 and $i == 12) {
1518 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1519 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1520 } elseif ($i > 12) {
1521 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1523 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1527 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1528 print '<!-- Show the search input text -->'."\n
";
1529 print '<div class="margintoponly
">';
1530 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> ';
1531 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear').'</a>';
1542 <!-- Show categories -->
1544 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1545 print '<div class="div4
" style= "display: none;
">';
1547 print '<div class="div4
">';
1551 while ($count < $MAXCATEG) {
1553 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1554 echo 'onclick="MoreCategories(\
'less\')"';
1555 } elseif ($count == ($MAXCATEG - 1)) {
1556 echo
'onclick="MoreCategories(\'more\')"';
1558 echo
'onclick="LoadProducts('.$count.
')"';
1559 } ?>
id=
"catdiv<?php echo $count; ?>">
1561 if ($count == ($MAXCATEG - 2)) {
1563 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1564 } elseif ($count == ($MAXCATEG - 1)) {
1566 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1569 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1572 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1573 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1574 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1577 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1585 <!-- Show product -->
1586 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1587 print ' centpercent';
1592 while ($count < $MAXPRODUCT) {
1593 print
'<div class="wrapper2'.(($count >= ($MAXPRODUCT - 2)) ?
' arrow' :
'').
'" id="prodiv'.$count.
'" '; ?>
1594 <?php
if ($count == ($MAXPRODUCT - 2)) {
1595 ?> onclick=
"MoreProducts('less')" <?php
1597 if ($count == ($MAXPRODUCT - 1)) {
1598 ?> onclick=
"MoreProducts('more')" <?php
1600 echo
'onclick="ClickProduct('.$count.
')"';
1603 if ($count == ($MAXPRODUCT - 2)) {
1605 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1606 } elseif ($count == ($MAXPRODUCT - 1)) {
1608 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1611 print
'<div class="" id="proprice'.$count.
'"></div>';
1614 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1616 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1619 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1620 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1621 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1624 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1630 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1631 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1632 <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