33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
39if (!defined(
'NOREQUIREAJAX')) {
40 define(
'NOREQUIREAJAX',
'1');
44require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
62$langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter",
"banks"));
65$action =
GETPOST(
'action',
'aZ09');
67$setcurrency =
GETPOST(
'setcurrency',
'aZ09');
69$hookmanager->initHooks(array(
'takeposfrontend'));
70if (empty($_SESSION[
"takeposterminal"])) {
72 $_SESSION[
"takeposterminal"] = 1;
73 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
74 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
78if ($setterminal > 0) {
79 $_SESSION[
"takeposterminal"] = $setterminal;
80 setcookie(
"takeposterminal", (
string) $setterminal, (time() + (86400 * 354)),
'/',
'', !empty($dolibarr_main_force_https),
true);
83if ($setcurrency !=
"") {
84 $_SESSION[
"takeposcustomercurrency"] = $setcurrency;
91$maxcategbydefaultforthisdevice = 12;
92$maxproductbydefaultforthisdevice = 24;
93if (
$conf->browser->layout ==
'phone') {
94 $maxcategbydefaultforthisdevice = 8;
95 $maxproductbydefaultforthisdevice = 16;
98 $_SESSION[
"basiclayout"] = 1;
99 header(
"Location: phone.php?mobilepage=invoice");
103 unset($_SESSION[
"basiclayout"]);
105$MAXCATEG = (!
getDolGlobalString(
'TAKEPOS_NB_MAXCATEG') ? $maxcategbydefaultforthisdevice :
$conf->global->TAKEPOS_NB_MAXCATEG);
106$MAXPRODUCT = (!
getDolGlobalString(
'TAKEPOS_NB_MAXPRODUCT') ? $maxproductbydefaultforthisdevice :
$conf->global->TAKEPOS_NB_MAXPRODUCT);
108$term = empty($_SESSION[
'takeposterminal']) ? 1 : $_SESSION[
'takeposterminal'];
126$form =
new Form($db);
130$arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
131$arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
134 $arrayofcss[] =
'/takepos/css/colorful.css';
139$title =
'TakePOS - Dolibarr '.DOL_VERSION;
143$head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
144<meta name="apple-mobile-web-app-capable" content="yes">
145<meta name="mobile-web-app-capable" content="yes">
146<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
147top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
150$categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
155$levelofrootcategory = 0;
157 foreach ($categories as $key => $categorycursor) {
159 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
160 $levelofrootcategory = $categorycursor[
'level'];
166$levelofmaincategories = $levelofrootcategory + 1;
168$maincategories = array();
169$subcategories = array();
170foreach ($categories as $key => $categorycursor) {
171 if ($categorycursor[
'level'] == $levelofmaincategories) {
172 $maincategories[$key] = $categorycursor;
174 $subcategories[$key] = $categorycursor;
182<body
class=
"bodytakepos" style=
"overflow: hidden;">
185var categories = <?php echo json_encode($maincategories); ?>;
186var subcategories = <?php echo json_encode($subcategories); ?>;
192var place=
"<?php echo $place; ?>";
196var search2_timer=
null;
215function ClearSearch(clearSearchResults) {
216 console.log(
"ClearSearch");
217 $(
"#search").val(
'');
218 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
219 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
220 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
221 <?php
if (
$conf->browser->layout ==
'classic') { ?>
222 setFocusOnSearchField();
224 if (clearSearchResults) {
225 $(
"#search").trigger(
'keyup');
230function setFocusOnSearchField() {
231 console.log(
"Call setFocusOnSearchField in page index.php");
232 <?php
if (
$conf->browser->layout ==
'classic') { ?>
233 console.log(
"has keyboard from localStorage, so we can force focus on search field");
234 $(
"#search").focus();
238function PrintCategories(first) {
239 console.log(
"PrintCategories");
240 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
241 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
243 $(
"#catdivdesc"+i).hide();
244 $(
"#catdesc"+i).text(
"");
245 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
246 $(
"#catwatermark"+i).hide();
247 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
250 $(
"#catdivdesc"+i).show();
253 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
255 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
257 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
258 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
259 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
260 $(
"#catdiv"+i).attr(
'class',
'wrapper');
261 $(
"#catwatermark"+i).show();
265function MoreCategories(moreorless) {
266 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
267 if (moreorless ==
"more") {
268 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
269 $(
'#catimg15').animate({opacity:
'1'}, 100);
270 pagecategories=pagecategories+1;
272 if (moreorless ==
"less") {
273 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
274 $(
'#catimg14').animate({opacity:
'1'}, 100);
275 if (pagecategories==0)
return;
276 pagecategories=pagecategories-1;
278 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
279 pagecategories=pagecategories-1;
283 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
284 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
286 console.log(
"complete with empty record");
287 $(
"#catdivdesc"+i).hide();
288 $(
"#catdesc"+i).text(
"");
289 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
290 $(
"#catwatermark"+i).hide();
293 $(
"#catdivdesc"+i).show();
296 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
298 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
300 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
301 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
302 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
303 $(
"#catwatermark"+i).show();
310function LoadProducts(
position, issubcat) {
311 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
312 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
315 currentcat=
"supplements";
317 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
318 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
319 if (issubcat ==
true) {
320 currentcat=$(
'#prodiv'+
position).data(
'rowid');
323 currentcat=$(
'#catdiv'+
position).data(
'rowid');
324 console.log(
"currentcat="+currentcat);
327 if (currentcat == undefined) {
333 jQuery.each(subcategories,
function(i, val) {
334 if (currentcat==val.fk_parent) {
335 $(
"#prodivdesc"+ishow).show();
336 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
337 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
338 $(
"#probutton"+ishow).html(val.label);
340 $(
"#prodesc"+ishow).text(val.label);
341 $(
"#probutton"+ishow).text(val.label);
343 $(
"#probutton"+ishow).show();
344 $(
"#proprice"+ishow).attr(
"class",
"hidden");
345 $(
"#proprice"+ishow).html(
"");
346 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
347 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
348 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
349 $(
"#prodiv"+ishow).data(
"iscat",1);
350 $(
"#prodiv"+ishow).attr(
"data-iscat",1);
351 $(
"#prowatermark"+ishow).show();
358 if (maxproduct >= 1) {
359 limit = maxproduct-1;
362 $.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) {
363 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
366 while (ishow < maxproduct) {
367 console.log(
"ishow"+ishow+
" idata="+idata);
370 if (typeof (data[idata]) ==
"undefined") {
372 echo
'$("#prodivdesc"+ishow).hide();';
373 echo
'$("#prodesc"+ishow).text("");';
374 echo
'$("#proimg"+ishow).attr("title","");';
375 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
377 echo
'$("#probutton"+ishow).hide();';
378 echo
'$("#probutton"+ishow).text("");';
380 $(
"#proprice"+ishow).attr(
"class",
"hidden");
381 $(
"#proprice"+ishow).html(
"");
383 $(
"#prodiv"+ishow).data(
"rowid",
"");
384 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
386 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
389 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
390 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
392 var titlestring = <?php echo $titlestring; ?>;
394 echo
'$("#prodivdesc"+ishow).show();';
396 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
398 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
400 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
402 echo
'$("#proimg"+ishow).attr("title", titlestring);';
403 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
405 echo
'$("#probutton"+ishow).show();';
406 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
409 if (data[parseInt(idata)][
'price_formated']) {
410 $(
"#proprice" + ishow).attr(
"class",
"productprice");
414 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
418 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
423 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
425 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
426 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
427 console.log($(
'#prodiv4').data(
'rowid'));
429 $(
"#prodiv"+ishow).data(
"iscat", 0);
430 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
432 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
436 $parameters = array();
437 $parameters[
'caller'] =
'loadProducts';
438 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
439 print $hookmanager->resPrint;
442 $(
"#prowatermark"+ishow).hide();
451function MoreProducts(moreorless) {
452 console.log(
"MoreProducts");
454 if ($(
'#search_pagination').val() !=
'') {
455 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
458 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
460 if (moreorless==
"more"){
461 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
462 $(
'#proimg31').animate({opacity:
'1'}, 100);
463 pageproducts=pageproducts+1;
465 if (moreorless==
"less"){
466 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
467 $(
'#proimg30').animate({opacity:
'1'}, 100);
468 if (pageproducts==0)
return;
469 pageproducts=pageproducts-1;
475 if (maxproduct >= 1) {
476 limit = maxproduct-1;
478 var offset = <?php echo($MAXPRODUCT - 2); ?> * pageproducts;
480 $.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) {
481 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
483 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
484 pageproducts=pageproducts-1;
488 while (ishow < maxproduct) {
489 if (typeof (data[idata]) ==
"undefined") {
490 $(
"#prodivdesc"+ishow).hide();
491 $(
"#prodesc"+ishow).text(
"");
492 $(
"#probutton"+ishow).text(
"");
493 $(
"#probutton"+ishow).hide();
494 $(
"#proprice"+ishow).attr(
"class",
"");
495 $(
"#proprice"+ishow).html(
"");
496 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
497 $(
"#prodiv"+ishow).data(
"rowid",
"");
498 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
500 $(
"#prodivdesc"+ishow).show();
502 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
503 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
504 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
506 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
508 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
509 $(
"#probutton"+ishow).show();
510 if (data[parseInt(idata)][
'price_formated']) {
511 $(
"#proprice" + ishow).attr(
"class",
"productprice");
515 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
519 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
524 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
525 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
526 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
527 $(
"#prodiv"+ishow).data(
"iscat",0);
529 $(
"#prowatermark"+ishow).hide();
538function ClickProduct(
position, qty = 1) {
539 console.log(
"ClickProduct at position"+
position);
540 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
541 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
542 if ($(
'#prodiv'+
position).data(
'iscat')==1){
543 console.log(
"Click on a category at position "+
position);
547 console.log($(
'#prodiv4').data(
'rowid'));
548 invoiceid = $(
"#invoiceid").val();
549 idproduct=$(
'#prodiv'+
position).data(
'rowid');
550 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoiceid="+invoiceid);
551 if (idproduct ==
"") {
555 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
557 echo
"CustomerDisplay();";
565function ChangeThirdparty(idcustomer) {
566 console.log(
"ChangeThirdparty");
568 $(
"#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() {
574function deleteline() {
575 invoiceid = $(
"#invoiceid").val();
576 console.log(
"Delete line invoiceid="+invoiceid);
577 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
584 console.log(
"Open box to select the thirdparty place="+place);
585 $.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
"); ?>"});
589 console.log(
"Open box to select the contact place="+place);
590 $.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"); ?>"});
595 console.log(
"Open box to select the history");
596 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
599function Reduction() {
600 invoiceid = $(
"#invoiceid").val();
601 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
602 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
605function CloseBill() {
607 if (!empty(
$conf->global->TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER)) {
608 echo
"customerAnchorTag = document.querySelector('a[id=\"customer\"]'); ";
609 echo
"if (customerAnchorTag && customerAnchorTag.innerText.trim() === '".$langs->trans(
"Customer").
"') { ";
610 echo
"alert('".dol_escape_js($langs->trans(
"NoClientErrorMessage")).
"'); ";
614 invoiceid = $(
"#invoiceid").val();
615 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
617 if ($(
"#idcustomer").val() ==
"") {
618 alert(
"<?php echo $langs->trans('TakePosCustomerMandatory'); ?>");
629 if (empty($alternative_payurl)) {
635 $.colorbox({href:
"<?php echo $payurl; ?>?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
639 invoiceid = $(
"#invoiceid").val();
640 console.log(
"Open popup to split on invoiceid="+invoiceid);
641 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
645 console.log(
"Open box to select floor place="+place);
646 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
650 invoiceid = $(
"#invoiceid").val();
651 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
652 $.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
"); ?>"});
655function TakeposOrderNotes() {
656 console.log(
"Open box to order notes");
657 ModalBox(
'ModalNote');
658 $(
"#textinput").focus();
662 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
663 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
670 invoiceid = $(
"#invoiceid").val();
672 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
674 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
677 if (parseInt(data[
'paye']) === 1) {
680 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
685 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
690 $(
"#idcustomer").val(
"");
702function Search2(keyCodeForEnter, moreorless) {
703 var eventKeyCode = window.event.keyCode;
705 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
707 var search_term = $(
'#search').val();
708 var search_start = 0;
709 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
710 if (moreorless !=
null) {
711 search_term = $(
'#search_pagination').val();
712 search_start = $(
'#search_start_'+moreorless).val();
715 console.log(
"search_term="+search_term);
717 if (search_term ==
'') {
718 $(
"[id^=prowatermark]").html(
"");
719 $(
"[id^=prodesc]").text(
"");
720 $(
"[id^=probutton]").text(
"");
721 $(
"[id^=probutton]").hide();
722 $(
"[id^=proprice]").attr(
"class",
"hidden");
723 $(
"[id^=proprice]").html(
"");
724 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
725 $(
"[id^=prodiv]").data(
"rowid",
"");
726 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
731 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
735 if (search ===
true) {
739 clearTimeout(search2_timer);
743 search2_timer = setTimeout(
function(){
745 jQuery(
".wrapper2 .catwatermark").hide();
746 var nbsearchresults = 0;
747 $.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) {
748 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
749 if (typeof (data[i]) ==
"undefined") {
750 $(
"#prowatermark" + i).html(
"");
751 $(
"#prodesc" + i).text(
"");
752 $(
"#probutton" + i).text(
"");
753 $(
"#probutton" + i).hide();
754 $(
"#proprice" + i).attr(
"class",
"hidden");
755 $(
"#proprice" + i).html(
"");
756 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
757 $(
"#prodiv" + i).data(
"rowid",
"");
758 $(
"#prodiv" + i).attr(
"data-rowid",
"");
762 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
763 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
765 var titlestring = <?php echo $titlestring; ?>;
767 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
768 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
769 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
771 $(
"#prodesc" + i).html(data[i][
'label']);
773 $(
"#prodivdesc" + i).show();
774 $(
"#probutton" + i).html(data[i][
'label']);
775 $(
"#probutton" + i).show();
776 if (data[i][
'price_formated']) {
777 $(
"#proprice" + i).attr(
"class",
"productprice");
781 $(
"#proprice" + i).html(data[i][
'price_formated']);
785 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
790 $(
"#proimg" + i).attr(
"title", titlestring);
791 if( undefined !== data[i][
'img']) {
792 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
795 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
797 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
798 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
799 $(
"#prodiv" + i).data(
"iscat", 0);
800 $(
"#prodiv" + i).attr(
"data-iscat", 0);
804 $parameters = array();
805 $parameters[
'caller'] =
'search2';
806 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
807 print $hookmanager->resPrint;
812 }).always(
function (data) {
814 if ($(
'#search').val().length > 0 && data.length == 1) {
815 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
816 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
817 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
818 ChangeThirdparty(data[0][
'rowid']);
820 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
821 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']);
822 ClickProduct(0, data[0][
'qty']);
825 if (eventKeyCode == keyCodeForEnter){
826 if (data.length == 0) {
827 $(
'#search').val(
'<?php
828 $langs->load('errors
');
829 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
830 ?> ('+search_term+
')');
831 $(
'#search').select();
833 else ClearSearch(
false);
836 $(
"#search_pagination").val($(
"#search").val());
837 if (search_start == 0) {
838 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
841 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
842 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
843 $(
"#search_start_less").val(search_start_less);
845 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
846 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
849 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
850 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
851 $(
"#search_start_more").val(search_start_more);
860function Edit(number) {
861 console.log(
"We click on PAD on key="+number);
863 if (typeof(selectedtext) ==
"undefined") {
867 var text=selectedtext+
"<br> ";
873 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
874 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
875 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
877 }
else if (number==
'qty') {
878 if (editaction==
'qty' && editnumber !=
'') {
879 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
882 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
885 setFocusOnSearchField();
891 }
else if (number==
'p') {
892 if (editaction==
'p' && editnumber!=
"") {
893 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
896 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
905 }
else if (number==
'r') {
906 if (editaction==
'r' && editnumber!=
"") {
907 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
910 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
921 editnumber=editnumber+number;
923 if (editaction==
'qty'){
924 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
925 $(
"#qty").html(
"OK").addClass(
"clicked");
926 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
927 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
929 if (editaction==
'p'){
930 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
931 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
932 $(
"#price").html(
"OK").addClass(
"clicked");
933 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
935 if (editaction==
'r'){
936 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
937 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
938 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
939 $(
"#reduction").html(
"OK").addClass(
"clicked");
941 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
945function TakeposPrintingOrder(){
946 console.log(
"TakeposPrintingOrder");
947 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
952function TakeposPrintingTemp(){
953 console.log(
"TakeposPrintingTemp");
954 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
959function OpenDrawer(){
960 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
963 data: { token:
'notrequired' },
965 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var(
$conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
966 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
968 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
975function DolibarrOpenDrawer() {
976 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
"]); ?>");
979 data: { token:
'<?php echo currentToken(); ?>' },
980 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode(empty($_SESSION["takeposterminal
"]) ? '' : $_SESSION["takeposterminal
"]); ?>",
984function MoreActions(totalactions){
987 for (i = 0; i <= totalactions; i++){
988 if (i<12) $(
"#action"+i).hide();
989 else $(
"#action"+i).show();
992 else if (pageactions==1){
994 for (i = 0; i <= totalactions; i++){
995 if (i<12) $(
"#action"+i).show();
996 else $(
"#action"+i).hide();
1003function ControlCashOpening()
1005 $.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
"); ?>"});
1008function CloseCashFence(rowid)
1010 $.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
"); ?>"});
1013function CashReport(rowid)
1015 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
1019function ModalBox(ModalID)
1021 var modal = document.getElementById(ModalID);
1022 modal.style.display =
"block";
1025function DirectPayment(){
1026 console.log(
"DirectPayment");
1027 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
1031function FullScreen() {
1032 document.documentElement.requestFullscreen();
1035function WeighingScale(){
1036 console.log(
"Weighing Scale");
1039 data: { token:
'notrequired' },
1040 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
1042 .done(
function( editnumber ) {
1043 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1049$( document ).ready(
function() {
1055 if (empty($_SESSION[
"takeposterminal"]) || $_SESSION[
"takeposterminal"] ==
"") {
1056 print
"ModalBox('ModalTerminal');";
1060 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1061 $sql .=
" entity = ".((int)
$conf->entity).
" AND ";
1062 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1064 $resql = $db->query($sql);
1066 $obj = $db->fetch_object($resql);
1068 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1069 print
"ControlCashOpening();";
1076 var elem1 = $(
"#topnav-left")[0];
1077 var elem2 = $(
"#topnav-right")[0];
1078 var checkOverflow =
function() {
1079 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1080 else $(
"#topnav").removeClass(
"overflow");
1083 var scrollBars =
function(){
1084 var container= $(
'#topnav')[0];
1086 vertical:container.scrollHeight > container.clientHeight,
1087 horizontal:container.scrollWidth > container.clientWidth
1091 $(window).resize(
function(){
1095 let resizeObserver =
new ResizeObserver(() => {
1098 resizeObserver.observe(elem1);
1099 resizeObserver.observe(elem2);
1102 var pressTimer = [];
1106 $(
".indicator").mousedown(
function(){
1107 direction = $(
this).hasClass(
"left") ? -1 : 1;
1109 pressTimer.push(setInterval(scrollTo, 100));
1112 $(
".indicator").mouseup(
function(){
1113 pressTimer.forEach(clearInterval);
1116 $(
"body").mouseup(
function(){
1117 pressTimer.forEach(clearInterval);
1118 console.log(
"body mouseup");
1121 function scrollTo(){
1122 console.log(
"here");
1123 var pos = $(
"#topnav").scrollLeft();
1124 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1127 $(
"#topnav").scroll(
function(){
1128 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1137$keyCodeForEnter =
'';
1138if (!empty($_SESSION[
'takeposterminal'])) {
1139 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalString(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1142<div
class=
"container">
1147 <div
class=
"header">
1148 <div
id=
"topnav" class=
"topnav">
1149 <div
id=
"topnav-left" class=
"topnav-left">
1150 <div
class=
"inline-block valignmiddle">
1151 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1152 <span
class=
"fa fa-cash-register"></span>
1153 <span
class=
"hideonsmartphone">
1155 if (!empty($_SESSION[
"takeposterminal"])) {
1156 echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"]));
1161 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1164 if (isModEnabled(
'multicurrency')) {
1165 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1166 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1170 <!-- section
for customer -->
1171 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1172 <input
type=
"hidden" id=
"idcustomer" value=
"">
1173 <!-- section
for shopping carts -->
1174 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1175 <!-- More info about customer -->
1176 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1178 if (isModEnabled(
'stock')) {
1180 <!-- More info about warehouse -->
1181 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1185 <div
id=
"topnav-right" class=
"topnav-right">
1187 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1188 if ($reshook == 0) {
1190 <div
class=
"login_block_other takepos">
1191 <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>
1192 <a onclick=
"ClearSearch(false);" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1193 <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 -->
1194 <span
class=
"fas fa-home"></span></a>
1195 <?php
if (empty(
$conf->dol_use_jmobile)) { ?>
1196 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1202 <div
class=
"login_block_user">
1204 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1208 <div
class=
"arrows">
1209 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1210 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1218<!-- Modal terminal box -->
1219<div
id=
"ModalTerminal" class=
"modal">
1220 <div
class=
"modal-content">
1221 <div
class=
"modal-header">
1225 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1228 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1230 <div
class=
"modal-body">
1231 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1234 for ($i = 2; $i <= $nbloop; $i++) {
1235 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1242<!-- Modal multicurrency box -->
1243<?php if (isModEnabled('multicurrency')) { ?>
1244<div id="ModalCurrency
" class="modal
">
1245 <div class="modal-content
">
1246 <div class="modal-header
">
1247 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1248 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1250 <div class="modal-body
">
1252 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1253 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1254 $resql = $db->query($sql);
1256 while ($obj = $db->fetch_object($resql)) {
1257 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1266<!-- Modal terminal Credit Note -->
1267<div id="ModalCreditNote
" class="modal
">
1268 <div class="modal-content
">
1269 <div class="modal-header
">
1270 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1271 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1273 <div class="modal-body
">
1274 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1275 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1281<div id="ModalNote
" class="modal
">
1282 <div class="modal-content
">
1283 <div class="modal-header
">
1284 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1285 <h3><?php print $langs->trans("Note
"); ?></h3>
1287 <div class="modal-body
">
1288 <input type="text
" class="block
" id="textinput
">
1289 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1298 <div id="poslines
" class="div1
">
1302 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1303 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1304 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1305 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1306 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1307 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1308 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1309 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1310 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1311 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1312 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1313 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1314 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1315 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1316 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1317 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1322// TakePOS setup check
1323if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1324 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1325 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1326 $sql .= " AND active = 1
";
1327 $sql .= " ORDER BY libelle
";
1329 $resql = $db->query($sql);
1330 $paiementsModes = array();
1332 while ($obj = $db->fetch_object($resql)) {
1333 $paycode = $obj->code;
1334 if ($paycode == 'LIQ') {
1337 if ($paycode == 'CHQ') {
1338 $paycode = 'CHEQUE';
1341 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1342 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1343 if (getDolGlobalInt($constantforkey) > 0) {
1344 array_push($paiementsModes, $obj);
1349 if (empty($paiementsModes) && isModEnabled("bank
")) {
1350 $langs->load('errors');
1351 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1352 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1356if (count($maincategories) == 0) {
1357 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1358 $tmpcategory = new Categorie($db);
1359 $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID'));
1360 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1362 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1365// User menu and external TakePOS modules
1369if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1370 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action' => 'New();');
1372 // BAR RESTAURANT specific menu
1373 $menus[$r++] = array('title' => '<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action' => 'Floors();');
1376if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1377 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1378 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action' => 'Contact();');
1380 $menus[$r++] = array('title' => '<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action' => 'Customer();');
1383if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1384 $menus[$r++] = array('title' => '<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action' => 'History();');
1386$menus[$r++] = array('title' => '<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action' => 'FreeZone();');
1387$menus[$r++] = array('title' => '<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action' => 'Reduction();');
1389if (!getDolGlobalString('TAKEPOS_NO_SPLIT_SALE')) {
1390 $menus[$r++] = array('title' => '<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action' => 'Split();');
1393// BAR RESTAURANT specific menu
1394if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1395 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1396 $menus[$r++] = array('title' => '<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action' => 'TakeposPrintingOrder();');
1400// Last action that close the sell (payments)
1401$menus[$r++] = array('title' => '<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action' => 'CloseBill();');
1402if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1403 $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();');
1406// BAR RESTAURANT specific menu
1407if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1408 //Button to print receipt before payment
1409 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1410 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1411 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1412 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposConnector(placeid);');
1414 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'TakeposPrinting(placeid);');
1416 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1417 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'DolibarrTakeposPrinting(placeid);');
1419 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action' => 'Print(placeid);');
1422 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1423 $menus[$r++] = array('title' => '<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action' => 'TakeposOrderNotes();');
1425 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1426 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action' => 'LoadProducts(\'supplements\');');
1430if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1431 $menus[$r++] = array('title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action' => 'OpenDrawer();');
1433if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1434 $menus[$r++] = array(
1435 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1436 'action' => 'DolibarrOpenDrawer();',
1440$sql = "SELECT rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1441$sql .= " entity =
".((int) $conf->entity)." AND
";
1442$sql .= " posnumber =
".((int) empty($_SESSION["takeposterminal
"]) ? 0 : $_SESSION["takeposterminal
"])." AND
";
1443$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1445$resql = $db->query($sql);
1447 $num = $db->num_rows($resql);
1449 $obj = $db->fetch_object($resql);
1450 $menus[$r++] = array('title' => '<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action' => 'CashReport('.$obj->rowid.');');
1451 if ($obj->status == 0) {
1452 $menus[$r++] = array('title' => '<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action' => 'CloseCashFence('.$obj->rowid.');');
1457$parameters = array('menus' => $menus);
1458$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1459if ($reshook == 0) { //add buttons
1460 if (is_array($hookmanager->resArray)) {
1461 foreach ($hookmanager->resArray as $resArray) {
1462 foreach ($resArray as $butmenu) {
1463 $menus[$r++] = $butmenu;
1466 } elseif ($reshook == 1) {
1467 $r = 0; //replace buttons
1468 if (is_array($hookmanager->resArray)) {
1469 foreach ($hookmanager->resArray as $resArray) {
1470 foreach ($resArray as $butmenu) {
1471 $menus[$r++] = $butmenu;
1479 $menus[$r++] = array('title' => '', 'style' => 'visibility: hidden;');
1482if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1483 $menus[$r++] = array('title' => '<span class="fa fa-sign-out-alt pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("Logout
").'</div>', 'action' => 'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php?token='.newToken().'\';');
1486if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1487 $menus[$r++] = array('title' => '<span class="fa fa-balance-scale pictofixedwidth
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action' => 'WeighingScale();');
1491 <!-- Show buttons -->
1495 foreach ($menus as $menu) {
1497 if (count($menus) > 12 and $i == 12) {
1498 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1499 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1500 } elseif ($i > 12) {
1501 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1503 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1507 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1508 print '<!-- Show the search input text -->'."\n
";
1509 print '<div class="margintoponly
">';
1510 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> ';
1511 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch(
false);
">'.img_picto('', 'searchclear').'</a>';
1522 <!-- Show categories -->
1524 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1525 print '<div class="div4
" style= "display: none;
">';
1527 print '<div class="div4
">';
1531 while ($count < $MAXCATEG) {
1533 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1534 echo 'onclick="MoreCategories(\
'less\')"';
1535 } elseif ($count == ($MAXCATEG - 1)) {
1536 echo
'onclick="MoreCategories(\'more\')"';
1538 echo
'onclick="LoadProducts('.$count.
')"';
1539 } ?>
id=
"catdiv<?php echo $count; ?>">
1541 if ($count == ($MAXCATEG - 2)) {
1543 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1544 } elseif ($count == ($MAXCATEG - 1)) {
1546 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1549 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1552 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1553 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1554 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1557 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1565 <!-- Show product -->
1566 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1567 print ' centpercent';
1571 while ($count < $MAXPRODUCT) {
1572 print
'<div class="wrapper2 arrow" id="prodiv'.$count.
'" '; ?>
1573 <?php
if ($count == ($MAXPRODUCT - 2)) {
1574 ?> onclick=
"MoreProducts('less')" <?php
1576 if ($count == ($MAXPRODUCT - 1)) {
1577 ?> onclick=
"MoreProducts('more')" <?php
1579 echo
'onclick="ClickProduct('.$count.
')"';
1582 if ($count == ($MAXPRODUCT - 2)) {
1584 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1585 } elseif ($count == ($MAXPRODUCT - 1)) {
1587 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1590 print
'<div class="" id="proprice'.$count.
'"></div>';
1593 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1595 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1598 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1599 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1600 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1603 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1609 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1610 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1611 <input
type=
"hidden" id=
"search_pagination" value=
"">
Class to manage categories.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
top_menu_user($hideloginname=0, $urllogout='')
Build the tooltip on user login.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.