31if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
42require
'../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
53$action =
GETPOST(
'action',
'aZ09');
54$setterminal =
GETPOST(
'setterminal',
'int');
55$setcurrency =
GETPOST(
'setcurrency',
'aZ09');
57$hookmanager->initHooks(array(
'takeposfrontend'));
58if (empty($_SESSION[
"takeposterminal"])) {
60 $_SESSION[
"takeposterminal"] = 1;
61 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
62 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
66if ($setterminal > 0) {
67 $_SESSION[
"takeposterminal"] = $setterminal;
68 setcookie(
"takeposterminal", $setterminal, (time() + (86400 * 354)),
'/',
null, (empty($dolibarr_main_force_https) ?
false : true), true);
71if ($setcurrency !=
"") {
72 $_SESSION[
"takeposcustomercurrency"] = $setcurrency;
77$langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter",
"banks"));
81$maxcategbydefaultforthisdevice = 12;
82$maxproductbydefaultforthisdevice = 24;
83if ($conf->browser->layout ==
'phone') {
84 $maxcategbydefaultforthisdevice = 8;
85 $maxproductbydefaultforthisdevice = 16;
88 $_SESSION[
"basiclayout"] = 1;
89 header(
"Location: phone.php?mobilepage=invoice");
93 unset($_SESSION[
"basiclayout"]);
95$MAXCATEG = (!
getDolGlobalString(
'TAKEPOS_NB_MAXCATEG') ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
96$MAXPRODUCT = (!
getDolGlobalString(
'TAKEPOS_NB_MAXPRODUCT') ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
98$term = empty($_SESSION[
'takeposterminal']) ? 1: $_SESSION[
'takeposterminal'];
116$form =
new Form($db);
120$arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
121$arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
124 $arrayofcss[] =
'/takepos/css/colorful.css';
129$title =
'TakePOS - Dolibarr '.DOL_VERSION;
133$head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
134<meta name="apple-mobile-web-app-capable" content="yes">
135<meta name="mobile-web-app-capable" content="yes">
136<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
137top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
140$categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
145$levelofrootcategory = 0;
147 foreach ($categories as $key => $categorycursor) {
148 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
149 $levelofrootcategory = $categorycursor[
'level'];
155$levelofmaincategories = $levelofrootcategory + 1;
157$maincategories = array();
158$subcategories = array();
159foreach ($categories as $key => $categorycursor) {
160 if ($categorycursor[
'level'] == $levelofmaincategories) {
161 $maincategories[$key] = $categorycursor;
163 $subcategories[$key] = $categorycursor;
171<body
class=
"bodytakepos" style=
"overflow: hidden;">
174var categories = <?php echo json_encode($maincategories); ?>;
175var subcategories = <?php echo json_encode($subcategories); ?>;
181var place=
"<?php echo $place; ?>";
185var search2_timer=
null;
204function ClearSearch() {
205 console.log(
"ClearSearch");
206 $(
"#search").val(
'');
207 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
208 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
209 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
210 <?php
if ($conf->browser->layout ==
'classic') { ?>
211 setFocusOnSearchField();
216function setFocusOnSearchField() {
217 console.log(
"Call setFocusOnSearchField in page index.php");
218 <?php
if ($conf->browser->layout ==
'classic') { ?>
219 console.log(
"has keyboard from localStorage, so we can force focus on search field");
220 $(
"#search").focus();
224function PrintCategories(first) {
225 console.log(
"PrintCategories");
226 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
227 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
229 $(
"#catdivdesc"+i).hide();
230 $(
"#catdesc"+i).text(
"");
231 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
232 $(
"#catwatermark"+i).hide();
233 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
236 $(
"#catdivdesc"+i).show();
239 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
241 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
243 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
244 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
245 $(
"#catdiv"+i).attr(
"data-rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
246 $(
"#catdiv"+i).attr(
'class',
'wrapper');
247 $(
"#catwatermark"+i).show();
251function MoreCategories(moreorless) {
252 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
253 if (moreorless ==
"more") {
254 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
255 $(
'#catimg15').animate({opacity:
'1'}, 100);
256 pagecategories=pagecategories+1;
258 if (moreorless ==
"less") {
259 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
260 $(
'#catimg14').animate({opacity:
'1'}, 100);
261 if (pagecategories==0)
return;
262 pagecategories=pagecategories-1;
264 if (typeof (categories[<?php echo($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
265 pagecategories=pagecategories-1;
269 for (i = 0; i < <?php echo($MAXCATEG - 2); ?>; i++) {
270 if (typeof (categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
272 console.log(
"complete with empty record");
273 $(
"#catdivdesc"+i).hide();
274 $(
"#catdesc"+i).text(
"");
275 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
276 $(
"#catwatermark"+i).hide();
279 $(
"#catdivdesc"+i).show();
282 $(
"#catdesc"+i).html(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'description']);
284 $(
"#catdesc"+i).text(categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'label']);
286 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
287 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
288 $(
"#catdiv"+i).attr(
"data-rowid",categories[i+(<?php echo($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
289 $(
"#catwatermark"+i).show();
296function LoadProducts(
position, issubcat) {
297 console.log(
"LoadProducts position="+
position+
" issubcat="+issubcat);
298 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
301 currentcat=
"supplements";
303 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
304 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
305 if (issubcat ==
true) {
306 currentcat=$(
'#prodiv'+
position).data(
'rowid');
309 currentcat=$(
'#catdiv'+
position).data(
'rowid');
310 console.log(
"currentcat="+currentcat);
313 if (currentcat == undefined) {
319 jQuery.each(subcategories,
function(i, val) {
320 if (currentcat==val.fk_parent) {
321 $(
"#prodivdesc"+ishow).show();
322 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
323 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
324 $(
"#probutton"+ishow).html(val.label);
326 $(
"#prodesc"+ishow).text(val.label);
327 $(
"#probutton"+ishow).text(val.label);
329 $(
"#probutton"+ishow).show();
330 $(
"#proprice"+ishow).attr(
"class",
"hidden");
331 $(
"#proprice"+ishow).html(
"");
332 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
333 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
334 $(
"#prodiv"+ishow).attr(
"data-rowid",val.rowid);
335 $(
"#prodiv"+ishow).data(
"iscat",1);
336 $(
"#prodiv"+ishow).attr(
"data-iscat",1);
337 $(
"#prowatermark"+ishow).show();
344 if (maxproduct >= 1) {
345 limit = maxproduct-1;
348 $.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) {
349 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
352 while (ishow < maxproduct) {
353 console.log(
"ishow"+ishow+
" idata="+idata);
356 if (typeof (data[idata]) ==
"undefined") {
358 echo
'$("#prodivdesc"+ishow).hide();';
359 echo
'$("#prodesc"+ishow).text("");';
360 echo
'$("#proimg"+ishow).attr("title","");';
361 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
363 echo
'$("#probutton"+ishow).hide();';
364 echo
'$("#probutton"+ishow).text("");';
366 $(
"#proprice"+ishow).attr(
"class",
"hidden");
367 $(
"#proprice"+ishow).html(
"");
369 $(
"#prodiv"+ishow).data(
"rowid",
"");
370 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
372 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
375 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
376 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
378 var titlestring = <?php echo $titlestring; ?>;
380 echo
'$("#prodivdesc"+ishow).show();';
382 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
384 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
386 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
388 echo
'$("#proimg"+ishow).attr("title", titlestring);';
389 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
391 echo
'$("#probutton"+ishow).show();';
392 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
395 if (data[parseInt(idata)][
'price_formated']) {
396 $(
"#proprice" + ishow).attr(
"class",
"productprice");
400 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
404 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
409 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
411 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
412 $(
"#prodiv"+ishow).attr(
"data-rowid", data[idata][
'id']);
413 console.log($(
'#prodiv4').data(
'rowid'));
415 $(
"#prodiv"+ishow).data(
"iscat", 0);
416 $(
"#prodiv"+ishow).attr(
"data-iscat", 0);
418 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
423 $parameters[
'caller'] =
'loadProducts';
424 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
425 print $hookmanager->resPrint;
428 $(
"#prowatermark"+ishow).hide();
437function MoreProducts(moreorless) {
438 console.log(
"MoreProducts");
440 if ($(
'#search_pagination').val() !=
'') {
441 return Search2(
'<?php echo(isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
444 var maxproduct = <?php echo($MAXPRODUCT - 2); ?>;
446 if (moreorless==
"more"){
447 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
448 $(
'#proimg31').animate({opacity:
'1'}, 100);
449 pageproducts=pageproducts+1;
451 if (moreorless==
"less"){
452 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
453 $(
'#proimg30').animate({opacity:
'1'}, 100);
454 if (pageproducts==0)
return;
455 pageproducts=pageproducts-1;
461 if (maxproduct >= 1) {
462 limit = maxproduct-1;
464 var offset = <?php echo($MAXPRODUCT - 2); ?> * pageproducts;
466 $.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) {
467 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
469 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
470 pageproducts=pageproducts-1;
474 while (ishow < maxproduct) {
475 if (typeof (data[idata]) ==
"undefined") {
476 $(
"#prodivdesc"+ishow).hide();
477 $(
"#prodesc"+ishow).text(
"");
478 $(
"#probutton"+ishow).text(
"");
479 $(
"#probutton"+ishow).hide();
480 $(
"#proprice"+ishow).attr(
"class",
"");
481 $(
"#proprice"+ishow).html(
"");
482 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
483 $(
"#prodiv"+ishow).data(
"rowid",
"");
484 $(
"#prodiv"+ishow).attr(
"data-rowid",
"");
486 $(
"#prodivdesc"+ishow).show();
488 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
489 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
490 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold());
492 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
494 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
495 $(
"#probutton"+ishow).show();
496 if (data[parseInt(idata)][
'price_formated']) {
497 $(
"#proprice" + ishow).attr(
"class",
"productprice");
501 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
505 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
510 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
511 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
512 $(
"#prodiv"+ishow).attr(
"data-rowid",data[idata][
'id']);
513 $(
"#prodiv"+ishow).data(
"iscat",0);
515 $(
"#prowatermark"+ishow).hide();
524function ClickProduct(
position, qty = 1) {
525 console.log(
"ClickProduct at position"+
position);
526 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
527 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
528 if ($(
'#prodiv'+
position).data(
'iscat')==1){
529 console.log(
"Click on a category at position "+
position);
533 console.log($(
'#prodiv4').data(
'rowid'));
534 invoiceid = $(
"#invoiceid").val();
535 idproduct=$(
'#prodiv'+
position).data(
'rowid');
536 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty+
" invoicdeid="+invoiceid);
537 if (idproduct==
"")
return;
539 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+
"&idproduct="+idproduct+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
541 echo
"CustomerDisplay();";
549function ChangeThirdparty(idcustomer) {
550 console.log(
"ChangeThirdparty");
552 $(
"#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() {
558function deleteline() {
559 invoiceid = $(
"#invoiceid").val();
560 console.log(
"Delete line invoiceid="+invoiceid);
561 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
568 console.log(
"Open box to select the thirdparty place="+place);
569 $.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
"); ?>"});
573 console.log(
"Open box to select the contact place="+place);
574 $.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"); ?>"});
579 console.log(
"Open box to select the history");
580 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
583function Reduction() {
584 invoiceid = $(
"#invoiceid").val();
585 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
586 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
589function CloseBill() {
590 invoiceid = $(
"#invoiceid").val();
591 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
592 $.colorbox({href:
"pay.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
596 invoiceid = $(
"#invoiceid").val();
597 console.log(
"Open popup to split on invoiceid="+invoiceid);
598 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
602 console.log(
"Open box to select floor place="+place);
603 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
607 invoiceid = $(
"#invoiceid").val();
608 console.log(
"Open box to enter a free product on invoiceid="+invoiceid);
609 $.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
"); ?>"});
612function TakeposOrderNotes() {
613 console.log(
"Open box to order notes");
614 ModalBox(
'ModalNote');
615 $(
"#textinput").focus();
619 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
620 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
627 invoiceid = $(
"#invoiceid").val();
629 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
631 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
634 if (parseInt(data[
'paye']) === 1) {
637 r = confirm(
'<?php echo($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
642 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
657function Search2(keyCodeForEnter, moreorless) {
658 var eventKeyCode = window.event.keyCode;
660 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
662 var search_term = $(
'#search').val();
663 var search_start = 0;
664 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
665 if (moreorless !=
null) {
666 search_term = $(
'#search_pagination').val();
667 search_start = $(
'#search_start_'+moreorless).val();
670 console.log(
"search_term="+search_term);
672 if (search_term ==
'') {
673 $(
"[id^=prowatermark]").html(
"");
674 $(
"[id^=prodesc]").text(
"");
675 $(
"[id^=probutton]").text(
"");
676 $(
"[id^=probutton]").hide();
677 $(
"[id^=proprice]").attr(
"class",
"hidden");
678 $(
"[id^=proprice]").html(
"");
679 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
680 $(
"[id^=prodiv]").data(
"rowid",
"");
681 $(
"[id^=prodiv]").attr(
"data-rowid",
"");
686 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
690 if (search ===
true) {
694 clearTimeout(search2_timer);
698 search2_timer = setTimeout(
function(){
700 jQuery(
".wrapper2 .catwatermark").hide();
701 var nbsearchresults = 0;
702 $.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) {
703 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
704 if (typeof (data[i]) ==
"undefined") {
705 $(
"#prowatermark" + i).html(
"");
706 $(
"#prodesc" + i).text(
"");
707 $(
"#probutton" + i).text(
"");
708 $(
"#probutton" + i).hide();
709 $(
"#proprice" + i).attr(
"class",
"hidden");
710 $(
"#proprice" + i).html(
"");
711 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
712 $(
"#prodiv" + i).data(
"rowid",
"");
713 $(
"#prodiv" + i).attr(
"data-rowid",
"");
717 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
718 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
720 var titlestring = <?php echo $titlestring; ?>;
722 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
723 <?php } elseif (
getDolGlobalInt(
'TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
724 $(
"#prodesc" + i).html(data[i][
'ref'].bold());
726 $(
"#prodesc" + i).html(data[i][
'label']);
728 $(
"#prodivdesc" + i).show();
729 $(
"#probutton" + i).html(data[i][
'label']);
730 $(
"#probutton" + i).show();
731 if (data[i][
'price_formated']) {
732 $(
"#proprice" + i).attr(
"class",
"productprice");
736 $(
"#proprice" + i).html(data[i][
'price_formated']);
740 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
745 $(
"#proimg" + i).attr(
"title", titlestring);
746 if( undefined !== data[i][
'img']) {
747 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
750 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
752 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
753 $(
"#prodiv" + i).attr(
"data-rowid", data[i][
'rowid']);
754 $(
"#prodiv" + i).data(
"iscat", 0);
755 $(
"#prodiv" + i).attr(
"data-iscat", 0);
760 $parameters[
'caller'] =
'search2';
761 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
762 print $hookmanager->resPrint;
767 }).always(
function (data) {
769 if ($(
'#search').val().length > 0 && data.length == 1) {
770 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
771 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
772 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
773 ChangeThirdparty(data[0][
'rowid']);
775 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
776 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']);
777 ClickProduct(0, data[0][
'qty']);
780 if (eventKeyCode == keyCodeForEnter){
781 if (data.length == 0) {
782 $(
'#search').val(
'<?php
783 $langs->load('errors
');
784 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
785 ?> ('+search_term+
')');
786 $(
'#search').select();
791 $(
"#search_pagination").val($(
"#search").val());
792 if (search_start == 0) {
793 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
796 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
797 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
798 $(
"#search_start_less").val(search_start_less);
800 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
801 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
804 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
805 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
806 $(
"#search_start_more").val(search_start_more);
815function Edit(number) {
816 console.log(
"We click on PAD on key="+number);
818 if (typeof(selectedtext) ==
"undefined") {
822 var text=selectedtext+
"<br> ";
828 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
829 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
830 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
832 }
else if (number==
'qty') {
833 if (editaction==
'qty' && editnumber !=
'') {
834 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
837 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
840 setFocusOnSearchField();
846 }
else if (number==
'p') {
847 if (editaction==
'p' && editnumber!=
"") {
848 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
851 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
860 }
else if (number==
'r') {
861 if (editaction==
'r' && editnumber!=
"") {
862 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
865 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
876 editnumber=editnumber+number;
878 if (editaction==
'qty'){
879 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
880 $(
"#qty").html(
"OK").addClass(
"clicked");
881 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
882 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
884 if (editaction==
'p'){
885 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
886 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
887 $(
"#price").html(
"OK").addClass(
"clicked");
888 $(
"#reduction").html(
"<?php echo $langs->trans("LineDiscountShort
"); ?>").removeClass(
'clicked');
890 if (editaction==
'r'){
891 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("LineDiscountShort
").":
"; ?>";
892 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
893 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
894 $(
"#reduction").html(
"OK").addClass(
"clicked");
896 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
900function TakeposPrintingOrder(){
901 console.log(
"TakeposPrintingOrder");
902 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
907function TakeposPrintingTemp(){
908 console.log(
"TakeposPrintingTemp");
909 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
914function OpenDrawer(){
915 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
918 data: { token:
'notrequired' },
920 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
921 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
923 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
930function DolibarrOpenDrawer() {
931 console.log(
"DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal
"]); ?>");
934 data: { token:
'<?php echo currentToken(); ?>' },
935 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode($_SESSION["takeposterminal
"]); ?>",
939function MoreActions(totalactions){
942 for (i = 0; i <= totalactions; i++){
943 if (i<12) $(
"#action"+i).hide();
944 else $(
"#action"+i).show();
947 else if (pageactions==1){
949 for (i = 0; i <= totalactions; i++){
950 if (i<12) $(
"#action"+i).show();
951 else $(
"#action"+i).hide();
958function ControlCashOpening()
960 $.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
"); ?>"});
963function CloseCashFence(
rowid)
965 $.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
"); ?>"});
968function CashReport(
rowid)
970 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+
rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
974function ModalBox(ModalID)
976 var modal = document.getElementById(ModalID);
977 modal.style.display =
"block";
980function DirectPayment(){
981 console.log(
"DirectPayment");
982 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
986function FullScreen() {
987 document.documentElement.requestFullscreen();
990function WeighingScale(){
991 console.log(
"Weighing Scale");
994 data: { token:
'notrequired' },
995 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
997 .done(
function( editnumber ) {
998 $(
"#poslines").load(
"invoice.php?token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
1004$( document ).ready(
function() {
1010 if ($_SESSION[
"takeposterminal"] ==
"") {
1011 print
"ModalBox('ModalTerminal');";
1015 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
1016 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
1017 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1019 $resql = $db->query($sql);
1021 $obj = $db->fetch_object($resql);
1023 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1024 print
"ControlCashOpening();";
1031 var elem1 = $(
"#topnav-left")[0];
1032 var elem2 = $(
"#topnav-right")[0];
1033 var checkOverflow =
function() {
1034 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1035 else $(
"#topnav").removeClass(
"overflow");
1038 var scrollBars =
function(){
1039 var container= $(
'#topnav')[0];
1041 vertical:container.scrollHeight > container.clientHeight,
1042 horizontal:container.scrollWidth > container.clientWidth
1046 $(window).resize(
function(){
1050 let resizeObserver =
new ResizeObserver(() => {
1053 resizeObserver.observe(elem1);
1054 resizeObserver.observe(elem2);
1057 var pressTimer = [];
1061 $(
".indicator").mousedown(
function(){
1062 direction = $(
this).hasClass(
"left") ? -1 : 1;
1064 pressTimer.push(setInterval(scrollTo, 100));
1067 $(
".indicator").mouseup(
function(){
1068 pressTimer.forEach(clearInterval);
1071 $(
"body").mouseup(
function(){
1072 pressTimer.forEach(clearInterval);
1073 console.log(
"body");
1076 function scrollTo(){
1077 console.log(
"here");
1078 var pos = $(
"#topnav").scrollLeft();
1079 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1082 $(
"#topnav").scroll(
function(){
1083 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1092$keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1094<div
class=
"container">
1099 <div
class=
"header">
1100 <div
id=
"topnav" class=
"topnav">
1101 <div
id=
"topnav-left" class=
"topnav-left">
1102 <div
class=
"inline-block valignmiddle">
1103 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1104 <span
class=
"fa fa-cash-register"></span>
1105 <span
class=
"hideonsmartphone">
1106 <?php echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"])); ?>
1109 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>'; ?>
1112 if (isModEnabled(
'multicurrency')) {
1113 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1114 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1118 <!-- section
for customer -->
1119 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1120 <!-- section
for shopping carts -->
1121 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1122 <!-- More info about customer -->
1123 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1125 if (isModEnabled(
'stock')) {
1127 <!-- More info about warehouse -->
1128 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1132 <div
id=
"topnav-right" class=
"topnav-right">
1134 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1135 if ($reshook == 0) {
1137 <div
class=
"login_block_other">
1138 <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>
1139 <a onclick=
"ClearSearch();" class=
"nohover"><span
class=
"fa fa-backspace"></span></a>
1140 <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 -->
1141 <span
class=
"fas fa-home"></span></a>
1142 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1143 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1149 <div
class=
"login_block_user">
1151 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.newtoken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1155 <div
class=
"arrows">
1156 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1157 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1165<!-- Modal terminal box -->
1166<div
id=
"ModalTerminal" class=
"modal">
1167 <div
class=
"modal-content">
1168 <div
class=
"modal-header">
1172 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1175 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1177 <div
class=
"modal-body">
1178 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1181 for ($i = 2; $i <= $nbloop; $i++) {
1182 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1189<!-- Modal multicurrency box -->
1190<?php if (isModEnabled('multicurrency')) { ?>
1191<div id="ModalCurrency
" class="modal
">
1192 <div class="modal-content
">
1193 <div class="modal-header
">
1194 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1195 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1197 <div class="modal-body
">
1199 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1200 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1201 $resql = $db->query($sql);
1203 while ($obj = $db->fetch_object($resql)) {
1204 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1213<!-- Modal terminal Credit Note -->
1214<div id="ModalCreditNote
" class="modal
">
1215 <div class="modal-content
">
1216 <div class="modal-header
">
1217 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1218 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1220 <div class="modal-body
">
1221 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1222 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1228<div id="ModalNote
" class="modal
">
1229 <div class="modal-content
">
1230 <div class="modal-header
">
1231 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1232 <h3><?php print $langs->trans("Note
"); ?></h3>
1234 <div class="modal-body
">
1235 <input type="text
" class="block
" id="textinput
">
1236 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1245 <div id="poslines
" class="div1
">
1249 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1250 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1251 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1252 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1253 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1254 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1255 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1256 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1257 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1258 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1259 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1260 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("LineDiscountShort
"); ?></button>
1261 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1262 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1263 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1264 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1269// TakePOS setup check
1270if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1271 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1272 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1273 $sql .= " AND active = 1
";
1274 $sql .= " ORDER BY libelle
";
1276 $resql = $db->query($sql);
1277 $paiementsModes = array();
1279 while ($obj = $db->fetch_object($resql)) {
1280 $paycode = $obj->code;
1281 if ($paycode == 'LIQ') {
1284 if ($paycode == 'CHQ') {
1285 $paycode = 'CHEQUE';
1288 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1289 //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
1290 if (getDolGlobalInt($constantforkey) > 0) {
1291 array_push($paiementsModes, $obj);
1296 if (empty($paiementsModes) && isModEnabled("banque
")) {
1297 $langs->load('errors');
1298 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1299 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1303if (count($maincategories) == 0) {
1304 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
1305 $tmpcategory = new Categorie($db);
1306 $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
1307 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1309 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1312// User menu and external TakePOS modules
1316if (!getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1317 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action'=>'New();');
1319 // BAR RESTAURANT specific menu
1320 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action'=>'Floors();');
1323if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1324 if (getDolGlobalString('TAKEPOS_CHOOSE_CONTACT')) {
1325 $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Contact").'</div>', 'action'=>'Contact();');
1327 $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action'=>'Customer();');
1330if (! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1331 $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action'=>'History();');
1333$menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action'=>'FreeZone();');
1334$menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("InvoiceDiscountShort
").'</div>', 'action'=>'Reduction();');
1335$menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action'=>'CloseBill();');
1337if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1338 $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();');
1341$menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action'=>'Split();');
1343// BAR RESTAURANT specific menu
1344if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1345 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1346 $menus[$r++] = array('title'=>'<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action'=>'TakeposPrintingOrder();');
1348 //Button to print receipt before payment
1349 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1350 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1351 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1352 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposConnector(placeid);');
1354 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposPrinting(placeid);');
1356 } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1357 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
1359 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'Print(placeid);');
1362 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1363 $menus[$r++] = array('title'=>'<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action'=>'TakeposOrderNotes();');
1365 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1366 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action'=>'LoadProducts(\'supplements\');');
1370if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1371 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action'=>'OpenDrawer();');
1373if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1374 $menus[$r++] = array(
1375 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1376 'action' => 'DolibarrOpenDrawer();',
1380$sql = "SELECT
rowid,
status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1381$sql .= " entity =
".((int) $conf->entity)." AND
";
1382$sql .= " posnumber =
".((int) $_SESSION["takeposterminal
"])." AND
";
1383$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1385$resql = $db->query($sql);
1387 $num = $db->num_rows($resql);
1389 $obj = $db->fetch_object($resql);
1390 $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
1391 if ($obj->status == 0) {
1392 $menus[$r++] = array('title'=>'<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');');
1397$parameters = array('menus'=>$menus);
1398$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1399if ($reshook == 0) { //add buttons
1400 if (is_array($hookmanager->resArray)) {
1401 foreach ($hookmanager->resArray as $resArray) {
1402 foreach ($resArray as $butmenu) {
1403 $menus[$r++] = $butmenu;
1406 } elseif ($reshook == 1) {
1407 $r = 0; //replace buttons
1408 if (is_array($hookmanager->resArray)) {
1409 foreach ($hookmanager->resArray as $resArray) {
1410 foreach ($resArray as $butmenu) {
1411 $menus[$r++] = $butmenu;
1419 $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
1422if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) {
1423 $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().'\';');
1426if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) {
1427 $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action'=>'WeighingScale();');
1431 <!-- Show buttons -->
1435 foreach ($menus as $menu) {
1437 if (count($menus) > 12 and $i == 12) {
1438 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1439 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1440 } elseif ($i > 12) {
1441 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1443 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1447 if (getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR') && !getDolGlobalString('TAKEPOS_HIDE_SEARCH')) {
1448 print '<!-- Show the search input text -->'."\n
";
1449 print '<div class="margintoponly
">';
1450 print '<input type="text
" id="search
" class="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> ';
1451 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch();
">'.img_picto('', 'searchclear').'</a>';
1462 <!-- Show categories -->
1464 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1465 print '<div class="div4
" style= "display: none;
">';
1467 print '<div class="div4
">';
1471 while ($count < $MAXCATEG) {
1473 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1474 echo 'onclick="MoreCategories(\
'less\')"';
1475 } elseif ($count == ($MAXCATEG - 1)) {
1476 echo
'onclick="MoreCategories(\'more\')"';
1478 echo
'onclick="LoadProducts('.$count.
')"';
1479 } ?>
id=
"catdiv<?php echo $count; ?>">
1481 if ($count == ($MAXCATEG - 2)) {
1483 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1484 } elseif ($count == ($MAXCATEG - 1)) {
1486 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1489 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1492 <?php
if ($count != $MAXCATEG - 2 && $count != $MAXCATEG - 1) { ?>
1493 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1494 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1497 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1505 <!-- Show product -->
1506 <div
class=
"div5<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1507 print ' centpercent';
1511 while ($count < $MAXPRODUCT) {
1512 print
'<div class="wrapper2 arrow" id="prodiv'.$count.
'" '; ?>
1513 <?php
if ($count == ($MAXPRODUCT - 2)) {
1514 ?> onclick=
"MoreProducts('less')" <?php
1516 if ($count == ($MAXPRODUCT - 1)) {
1517 ?> onclick=
"MoreProducts('more')" <?php
1519 echo
'onclick="ClickProduct('.$count.
')"';
1522 if ($count == ($MAXPRODUCT - 2)) {
1524 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1525 } elseif ($count == ($MAXPRODUCT - 1)) {
1527 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1530 print
'<div class="" id="proprice'.$count.
'"></div>';
1533 print
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1535 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1538 <?php
if ($count != $MAXPRODUCT - 2 && $count != $MAXPRODUCT - 1 && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1539 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1540 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1543 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1549 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1550 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1551 <input
type=
"hidden" id=
"search_pagination" value=
"">
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
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)
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 second index function, which produces ascending (default) or descending output...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e rowid
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
top_menu_user($hideloginname=0, $urllogout='')
Build the tooltip on user login.
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
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.
Search2(keyCodeForEnter, moreorless)
Search products.