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;
87 if ($_SESSION[
"takeposterminal"] !=
"" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) {
88 $_SESSION[
"basiclayout"] = 1;
89 header(
"Location: phone.php?mobilepage=invoice");
93$MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
94$MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
96$term = empty($_SESSION[
'takeposterminal']) ? 1 : $_SESSION[
'takeposterminal'];
114$form =
new Form($db);
118$arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
119$arrayofcss = array(
'/takepos/css/pos.css.php',
'/takepos/css/colorbox.css');
122 $arrayofcss[] =
'/takepos/css/colorful.css';
127$title =
'TakePOS - Dolibarr '.DOL_VERSION;
128if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
129 $title =
'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
131$head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
132<meta name="apple-mobile-web-app-capable" content="yes">
133<meta name="mobile-web-app-capable" content="yes">
134<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
135top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
138$categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
143$levelofrootcategory = 0;
145 foreach ($categories as $key => $categorycursor) {
146 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
147 $levelofrootcategory = $categorycursor[
'level'];
153$levelofmaincategories = $levelofrootcategory + 1;
155$maincategories = array();
156$subcategories = array();
157foreach ($categories as $key => $categorycursor) {
158 if ($categorycursor[
'level'] == $levelofmaincategories) {
159 $maincategories[$key] = $categorycursor;
161 $subcategories[$key] = $categorycursor;
169<body
class=
"bodytakepos" style=
"overflow: hidden;">
172var categories = <?php echo json_encode($maincategories); ?>;
173var subcategories = <?php echo json_encode($subcategories); ?>;
179var place=
"<?php echo $place; ?>";
183var search2_timer=
null;
202function ClearSearch() {
203 console.log(
"ClearSearch");
204 $(
"#search").val(
'');
205 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
206 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
207 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
208 <?php
if ($conf->browser->layout ==
'classic') { ?>
209 setFocusOnSearchField();
214function setFocusOnSearchField() {
215 console.log(
"Call setFocusOnSearchField in page index.php");
216 <?php
if ($conf->browser->layout ==
'classic') { ?>
217 console.log(
"has keyboard from localStorage, so we can force focus on search field");
218 $(
"#search").focus();
222function PrintCategories(first) {
223 console.log(
"PrintCategories");
224 for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
225 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
227 $(
"#catdivdesc"+i).hide();
228 $(
"#catdesc"+i).text(
"");
229 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
230 $(
"#catwatermark"+i).hide();
231 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
234 $(
"#catdivdesc"+i).show();
237 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
239 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
241 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
242 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
243 $(
"#catdiv"+i).attr(
'class',
'wrapper');
244 $(
"#catwatermark"+i).show();
248function MoreCategories(moreorless) {
249 console.log(
"MoreCategories moreorless="+moreorless+
" pagecategories="+pagecategories);
250 if (moreorless ==
"more") {
251 $(
'#catimg15').animate({opacity:
'0.5'}, 1);
252 $(
'#catimg15').animate({opacity:
'1'}, 100);
253 pagecategories=pagecategories+1;
255 if (moreorless ==
"less") {
256 $(
'#catimg14').animate({opacity:
'0.5'}, 1);
257 $(
'#catimg14').animate({opacity:
'1'}, 100);
258 if (pagecategories==0)
return;
259 pagecategories=pagecategories-1;
261 if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless ==
"more") ==
"undefined") {
262 pagecategories=pagecategories-1;
266 for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
267 if (typeof (categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
269 console.log(
"complete with empty record");
270 $(
"#catdivdesc"+i).hide();
271 $(
"#catdesc"+i).text(
"");
272 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
273 $(
"#catwatermark"+i).hide();
276 $(
"#catdivdesc"+i).show();
279 $(
"#catdesc"+i).html(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'label'].bold() +
' - ' + categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'description']);
281 $(
"#catdesc"+i).text(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'label']);
283 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
284 $(
"#catdiv"+i).data(
"rowid",categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)][
'rowid']);
285 $(
"#catwatermark"+i).show();
292function LoadProducts(
position, issubcat) {
293 console.log(
"LoadProducts");
294 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
296 if (
position==
"supplements") currentcat=
"supplements";
299 $(
'#catimg'+
position).animate({opacity:
'0.5'}, 1);
300 $(
'#catimg'+
position).animate({opacity:
'1'}, 100);
301 if (issubcat==
true) currentcat=$(
'#prodiv'+
position).data(
'rowid');
302 else currentcat=$(
'#catdiv'+
position).data(
'rowid');
304 if (currentcat == undefined)
return;
308 jQuery.each(subcategories,
function(i, val) {
309 if (currentcat==val.fk_parent) {
310 $(
"#prodivdesc"+ishow).show();
311 <?php if (getDolGlobalString(
'TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
312 $(
"#prodesc"+ishow).html(val.label.bold() +
' - ' + val.description);
313 $(
"#probutton"+ishow).html(val.label);
315 $(
"#prodesc"+ishow).text(val.label);
316 $(
"#probutton"+ishow).text(val.label);
318 $(
"#probutton"+ishow).show();
319 $(
"#proprice"+ishow).attr(
"class",
"hidden");
320 $(
"#proprice"+ishow).html(
"");
321 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=cat&id="+val.rowid);
322 $(
"#prodiv"+ishow).data(
"rowid",val.rowid);
323 $(
"#prodiv"+ishow).data(
"iscat",1);
324 $(
"#prowatermark"+ishow).show();
331 if (maxproduct >= 1) {
332 limit = maxproduct-1;
336 let socid = jQuery(
'#thirdpartyid').val();
337 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
338 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
342 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + socid +
'&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset=0',
function(data) {
343 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
345 while (ishow < maxproduct) {
347 console.log(data[idata]);
348 if (typeof (data[idata]) ==
"undefined") {
350 echo
'$("#prodivdesc"+ishow).hide();';
351 echo
'$("#prodesc"+ishow).text("");';
352 echo
'$("#proimg"+ishow).attr("title","");';
353 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
355 echo
'$("#probutton"+ishow).hide();';
356 echo
'$("#probutton"+ishow).text("");';
358 $(
"#proprice"+ishow).attr(
"class",
"hidden");
359 $(
"#proprice"+ishow).html(
"");
360 $(
"#prodiv"+ishow).data(
"rowid",
"");
361 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
364 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
365 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
367 var titlestring = <?php echo $titlestring; ?>;
369 echo
'$("#prodivdesc"+ishow).show();';
371 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
373 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
375 echo
'$("#proimg"+ishow).attr("title", titlestring);';
376 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
378 echo
'$("#probutton"+ishow).show();';
379 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
382 if (data[parseInt(idata)][
'price_formated']) {
383 $(
"#proprice" + ishow).attr(
"class",
"productprice");
387 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
391 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
396 console.log(
"#prodiv"+ishow+
".data(rowid)="+data[idata][
'id']);
397 console.log($(
"#prodiv"+ishow));
399 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
400 console.log($(
'#prodiv4').data(
'rowid'));
401 $(
"#prodiv"+ishow).data(
"iscat", 0);
402 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
407 $parameters[
'caller'] =
'loadProducts';
408 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
409 print $hookmanager->resPrint;
412 $(
"#prowatermark"+ishow).hide();
421function MoreProducts(moreorless) {
422 console.log(
"MoreProducts");
424 if ($(
'#search_pagination').val() !=
'') {
425 return Search2(
'<?php echo (isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
428 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
430 if (moreorless==
"more"){
431 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
432 $(
'#proimg31').animate({opacity:
'1'}, 100);
433 pageproducts=pageproducts+1;
435 if (moreorless==
"less"){
436 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
437 $(
'#proimg30').animate({opacity:
'1'}, 100);
438 if (pageproducts==0)
return;
439 pageproducts=pageproducts-1;
445 if (maxproduct >= 1) {
446 limit = maxproduct-1;
448 var offset = <?php echo ($MAXPRODUCT - 2); ?> * pageproducts;
451 let socid = jQuery(
'#thirdpartyid').val();
452 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
453 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
457 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + socid +
'&category='+currentcat+
'&tosell=1&limit='+limit+
'&offset='+offset,
function(data) {
458 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
460 if (typeof (data[0]) ==
"undefined" && moreorless==
"more"){
461 pageproducts=pageproducts-1;
465 while (ishow < maxproduct) {
466 if (typeof (data[idata]) ==
"undefined") {
467 $(
"#prodivdesc"+ishow).hide();
468 $(
"#prodesc"+ishow).text(
"");
469 $(
"#probutton"+ishow).text(
"");
470 $(
"#probutton"+ishow).hide();
471 $(
"#proprice"+ishow).attr(
"class",
"");
472 $(
"#proprice"+ishow).html(
"");
473 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
474 $(
"#prodiv"+ishow).data(
"rowid",
"");
476 $(
"#prodivdesc"+ishow).show();
479 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
481 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
483 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
484 $(
"#probutton"+ishow).show();
485 if (data[parseInt(idata)][
'price_formated']) {
486 $(
"#proprice" + ishow).attr(
"class",
"productprice");
490 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_formated']);
494 $(
"#proprice" + ishow).html(data[parseInt(idata)][
'price_ttc_formated']);
499 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
500 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
501 $(
"#prodiv"+ishow).data(
"iscat",0);
503 $(
"#prowatermark"+ishow).hide();
512function ClickProduct(
position, qty = 1) {
513 console.log(
"ClickProduct at position"+
position);
514 $(
'#proimg'+
position).animate({opacity:
'0.5'}, 1);
515 $(
'#proimg'+
position).animate({opacity:
'1'}, 100);
516 if ($(
'#prodiv'+
position).data(
'iscat')==1){
517 console.log(
"Click on a category at position "+
position);
521 console.log($(
'#prodiv4').data(
'rowid'));
522 invoiceid = $(
"#invoiceid").val();
523 idproduct=$(
'#prodiv'+
position).data(
'rowid');
524 console.log(
"Click on product at position "+
position+
" for idproduct "+idproduct+
", qty="+qty);
525 if (idproduct==
"")
return;
527 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+
"&idproduct="+idproduct+
"&selectedline="+selectedline+
"&qty="+qty+
"&invoiceid="+invoiceid,
function() {
528 <?php
if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo
"CustomerDisplay();";?>
535function ChangeThirdparty(idcustomer) {
536 console.log(
"ChangeThirdparty");
538 $(
"#poslines").load(
"../societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+
"&place="+place+
"",
function() {
544function deleteline() {
545 console.log(
"Delete line");
546 invoiceid = $(
"#invoiceid").val();
547 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&invoiceid="+invoiceid,
function() {
554 console.log(
"Open box to select the thirdparty place="+place);
555 $.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
"); ?>"});
560 console.log(
"Open box to select the history");
561 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
564function Reduction() {
565 invoiceid = $(
"#invoiceid").val();
566 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
567 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
570function CloseBill() {
571 invoiceid = $(
"#invoiceid").val();
572 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
573 $.colorbox({href:
"pay.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
577 invoiceid = $(
"#invoiceid").val();
578 console.log(
"Open popup to split on invoiceid="+invoiceid);
579 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
583 console.log(
"Open box to select floor place="+place);
584 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
588 console.log(
"Open box to enter a free product");
589 $.colorbox({href:
"freezone.php?action=freezone&token=<?php echo newToken(); ?>&place="+place, width:
"80%", height:
"200px", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("FreeZone
"); ?>"});
592function TakeposOrderNotes() {
593 console.log(
"Open box to order notes");
594 ModalBox(
'ModalNote');
595 $(
"#textinput").focus();
599 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
600 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
607 invoiceid = $(
"#invoiceid").val();
609 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
611 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid,
function(data) {
614 if (parseInt(data[
'paye']) === 1) {
617 r = confirm(
'<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
622 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
637function Search2(keyCodeForEnter, moreorless) {
638 var eventKeyCode = window.event.keyCode;
640 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
642 var search_term = $(
'#search').val();
643 var search_start = 0;
644 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
645 if (moreorless !=
null) {
646 search_term = $(
'#search_pagination').val();
647 search_start = $(
'#search_start_'+moreorless).val();
650 console.log(
"search_term="+search_term);
652 if (search_term ==
'') {
653 $(
"[id^=prowatermark]").html(
"");
654 $(
"[id^=prodesc]").text(
"");
655 $(
"[id^=probutton]").text(
"");
656 $(
"[id^=probutton]").hide();
657 $(
"[id^=proprice]").attr(
"class",
"hidden");
658 $(
"[id^=proprice]").html(
"");
659 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
660 $(
"[id^=prodiv]").data(
"rowid",
"");
665 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
669 if (search ===
true) {
673 clearTimeout(search2_timer);
677 search2_timer = setTimeout(
function(){
679 jQuery(
".wrapper2 .catwatermark").hide();
680 var nbsearchresults = 0;
683 let socid = jQuery(
'#thirdpartyid').val();
684 if ((socid === undefined || socid ===
"") && parseInt(
"<?php echo dol_escape_js($socid) ?>") > 0) {
685 socid = parseInt(
"<?php echo dol_escape_js($socid); ?>");
688 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term +
'&thirdpartyid=' + socid +
'&search_start=' + search_start +
'&search_limit=' + search_limit,
function (data) {
689 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
690 if (typeof (data[i]) ==
"undefined") {
691 $(
"#prowatermark" + i).html(
"");
692 $(
"#prodesc" + i).text(
"");
693 $(
"#probutton" + i).text(
"");
694 $(
"#probutton" + i).hide();
695 $(
"#proprice" + i).attr(
"class",
"hidden");
696 $(
"#proprice" + i).html(
"");
697 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
698 $(
"#prodiv" + i).data(
"rowid",
"");
702 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
703 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
705 var titlestring = <?php echo $titlestring; ?>;
708 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
710 $(
"#prodesc" + i).html(data[i][
'label']);
712 $(
"#prodivdesc" + i).show();
713 $(
"#probutton" + i).html(data[i][
'label']);
714 $(
"#probutton" + i).show();
715 if (data[i][
'price_formated']) {
716 $(
"#proprice" + i).attr(
"class",
"productprice");
720 $(
"#proprice" + i).html(data[i][
'price_formated']);
724 $(
"#proprice" + i).html(data[i][
'price_ttc_formated']);
729 $(
"#proimg" + i).attr(
"title", titlestring);
730 if( undefined !== data[i][
'img']) {
731 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
734 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
736 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
737 $(
"#prodiv" + i).data(
"iscat", 0);
742 $parameters[
'caller'] =
'search2';
743 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
744 print $hookmanager->resPrint;
749 }).always(
function (data) {
751 if ($(
'#search').val().length > 0 && data.length == 1) {
752 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
753 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
754 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
755 ChangeThirdparty(data[0][
'rowid']);
757 else if (
'product' == data[0][
'object'] && $(
'#search').val() == data[0][
'barcode']) {
758 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']);
759 ClickProduct(0, data[0][
'qty']);
762 if (eventKeyCode == keyCodeForEnter){
763 if (data.length == 0) {
764 $(
'#search').val(
'<?php
765 $langs->load('errors
');
766 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
767 ?> ('+search_term+
')');
768 $(
'#search').select();
773 $(
"#search_pagination").val($(
"#search").val());
774 if (search_start == 0) {
775 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
778 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
779 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
780 $(
"#search_start_less").val(search_start_less);
782 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
783 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
786 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
787 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
788 $(
"#search_start_more").val(search_start_more);
797function Edit(number) {
798 console.log(
"We click on PAD on key="+number);
800 if (typeof(selectedtext) ==
"undefined") {
804 var text=selectedtext+
"<br> ";
810 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
811 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
812 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
814 }
else if (number==
'qty') {
815 if (editaction==
'qty' && editnumber !=
'') {
816 $(
"#poslines").load(
"invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
819 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
822 setFocusOnSearchField();
828 }
else if (number==
'p') {
829 if (editaction==
'p' && editnumber!=
"") {
830 $(
"#poslines").load(
"invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
833 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
842 }
else if (number==
'r') {
843 if (editaction==
'r' && editnumber!=
"") {
844 $(
"#poslines").load(
"invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
847 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
858 editnumber=editnumber+number;
860 if (editaction==
'qty'){
861 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
862 $(
"#qty").html(
"OK").addClass(
"clicked");
863 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
864 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
866 if (editaction==
'p'){
867 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
868 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
869 $(
"#price").html(
"OK").addClass(
"clicked");
870 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
872 if (editaction==
'r'){
873 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("ReductionShort
").":
"; ?>";
874 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
875 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
876 $(
"#reduction").html(
"OK").addClass(
"clicked");
878 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
882function TakeposPrintingOrder(){
883 console.log(
"TakeposPrintingOrder");
884 $(
"#poslines").load(
"invoice.php?action=order&token=<?php echo newToken();?>&place="+place,
function() {
889function TakeposPrintingTemp(){
890 console.log(
"TakeposPrintingTemp");
891 $(
"#poslines").load(
"invoice.php?action=temp&token=<?php echo newToken();?>&place="+place,
function() {
896function OpenDrawer(){
897 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
900 data: { token:
'notrequired' },
902 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
903 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
905 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
912function DolibarrOpenDrawer() {
913 console.log(
"DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal
"]); ?>");
916 data: { token:
'<?php echo currentToken(); ?>' },
917 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode($_SESSION["takeposterminal
"]); ?>",
921function MoreActions(totalactions){
924 for (i = 0; i <= totalactions; i++){
925 if (i<12) $(
"#action"+i).hide();
926 else $(
"#action"+i).show();
929 else if (pageactions==1){
931 for (i = 0; i <= totalactions; i++){
932 if (i<12) $(
"#action"+i).show();
933 else $(
"#action"+i).hide();
940function ControlCashOpening()
942 $.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
"); ?>"});
945function CloseCashFence(
rowid)
947 $.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
"); ?>"});
950function CashReport(
rowid)
952 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+
rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
956function ModalBox(ModalID)
958 var modal = document.getElementById(ModalID);
959 modal.style.display =
"block";
962function DirectPayment(){
963 console.log(
"DirectPayment");
964 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ",
function() {
968function FullScreen() {
969 document.documentElement.requestFullscreen();
972function WeighingScale(){
973 console.log(
"Weighing Scale");
976 data: { token:
'notrequired' },
977 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
979 .done(
function( editnumber ) {
980 $(
"#poslines").load(
"invoice.php?&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
986$( document ).ready(
function() {
992 if ($_SESSION[
"takeposterminal"] ==
"") {
993 print
"ModalBox('ModalTerminal');";
997 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
998 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
999 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
1001 $resql = $db->query($sql);
1003 $obj = $db->fetch_object($resql);
1005 if (!isset($obj->rowid) || is_null($obj->rowid)) {
1006 print
"ControlCashOpening();";
1013 var elem1 = $(
"#topnav-left")[0];
1014 var elem2 = $(
"#topnav-right")[0];
1015 var checkOverflow =
function() {
1016 if (scrollBars().horizontal) $(
"#topnav").addClass(
"overflow");
1017 else $(
"#topnav").removeClass(
"overflow");
1020 var scrollBars =
function(){
1021 var container= $(
'#topnav')[0];
1023 vertical:container.scrollHeight > container.clientHeight,
1024 horizontal:container.scrollWidth > container.clientWidth
1028 $(window).resize(
function(){
1032 let resizeObserver =
new ResizeObserver(() => {
1035 resizeObserver.observe(elem1);
1036 resizeObserver.observe(elem2);
1039 var pressTimer = [];
1043 $(
".indicator").mousedown(
function(){
1044 direction = $(
this).hasClass(
"left") ? -1 : 1;
1046 pressTimer.push(setInterval(scrollTo, 100));
1049 $(
".indicator").mouseup(
function(){
1050 pressTimer.forEach(clearInterval);
1053 $(
"body").mouseup(
function(){
1054 pressTimer.forEach(clearInterval);
1055 console.log(
"body");
1058 function scrollTo(){
1059 console.log(
"here");
1060 var pos = $(
"#topnav").scrollLeft();
1061 document.getElementById(
"topnav").scrollTo({ left: $(
"#topnav").scrollLeft() + direction * step, behavior:
'smooth' })
1064 $(
"#topnav").scroll(
function(){
1065 if (($(
"#topnav").offsetWidth + $(
"#topnav").scrollLeft >= $(
"#topnav").scrollWidth)) {
1074$keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
1076<div
class=
"container">
1079if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1081 <div
class=
"header">
1082 <div
id=
"topnav" class=
"topnav">
1083 <div
id=
"topnav-left" class=
"topnav-left">
1084 <div
class=
"inline-block valignmiddle">
1085 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal')">
1086 <span
class=
"fa fa-cash-register"></span>
1087 <span
class=
"hideonsmartphone">
1088 <?php echo
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_".$_SESSION[
"takeposterminal"], $langs->trans(
"TerminalName", $_SESSION[
"takeposterminal"])); ?>
1091 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>';
1095 if (isModEnabled(
'multicurrency')) {
1096 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
1097 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
1102 <!-- section
for customer -->
1103 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
1104 <!-- section
for shopping carts -->
1105 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
1106 <!-- More info about customer -->
1107 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
1109 if (isModEnabled(
'stock')) {
1111 <!-- More info about warehouse -->
1112 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
1117 <div
id=
"topnav-right" class=
"topnav-right">
1119 $reshook = $hookmanager->executeHooks(
'takepos_login_block_other');
1120 if ($reshook == 0) {
1121 <div
class=
"login_block_other">
1122 <input
type=
"text" id=
"search" name=
"search" class=
"input-search-takepos" onkeyup=
"Search2('<?php echo dol_escape_js($keyCodeForEnter); ?>', null);" placeholder=
"<?php echo dol_escape_htmltag($langs->trans("Search
")); ?>" autofocus>
1123 <a onclick=
"ClearSearch();"><span
class=
"fa fa-backspace"></span></a>
1124 <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 -->
1125 <span
class=
"fas fa-home"></span></a>
1126 <?php
if (empty($conf->dol_use_jmobile)) {?>
1127 <a
class=
"hideonsmartphone" onclick=
"FullScreen();" title=
"<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave
")); ?>"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1132 <div
class=
"login_block_user">
1134 print
top_menu_user(1, DOL_URL_ROOT.
'/user/logout.php?token='.newtoken().
'&urlfrom='.urlencode(
'/takepos/?setterminal='.((
int) $term)));
1138 <div
class=
"arrows">
1139 <span
class=
"indicator left"><i
class=
"fa fa-arrow-left"></i></span>
1140 <span
class=
"indicator right"><i
class=
"fa fa-arrow-right"></i></span>
1148<!-- Modal terminal box -->
1149<div
id=
"ModalTerminal" class=
"modal">
1150 <div
class=
"modal-content">
1151 <div
class=
"modal-header">
1153 if (empty($conf->global->TAKEPOS_FORCE_TERMINAL_SELECT)) {
1155 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1157 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1159 <div
class=
"modal-body">
1160 <
button type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print
getDolGlobalString(
"TAKEPOS_TERMINAL_NAME_1", $langs->trans(
"TerminalName", 1)); ?></
button>
1163 for ($i = 2; $i <= $nbloop; $i++) {
1164 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_
".$i, $langs->trans("TerminalName
", $i)).'</button>';
1171<!-- Modal multicurrency box -->
1172<?php if (isModEnabled('multicurrency')) { ?>
1173<div id="ModalCurrency
" class="modal
">
1174 <div class="modal-content
">
1175 <div class="modal-header
">
1176 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1177 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1179 <div class="modal-body
">
1181 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1182 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1183 $resql = $db->query($sql);
1185 while ($obj = $db->fetch_object($resql)) {
1186 print '<button type="button" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1195<!-- Modal terminal Credit Note -->
1196<div id="ModalCreditNote
" class="modal
">
1197 <div class="modal-content
">
1198 <div class="modal-header
">
1199 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1200 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1202 <div class="modal-body
">
1203 <button type="button" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1204 <button type="button" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1210<div id="ModalNote
" class="modal
">
1211 <div class="modal-content
">
1212 <div class="modal-header
">
1213 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1214 <h3><?php print $langs->trans("Note
"); ?></h3>
1216 <div class="modal-body
">
1217 <input type="text
" class="block
" id="textinput
">
1218 <button type="button" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1223 <div class="row1<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1227 <div id="poslines
" class="div1
">
1231 <button type="button" class="calcbutton
" onclick="Edit(7);
">7</button>
1232 <button type="button" class="calcbutton
" onclick="Edit(8);
">8</button>
1233 <button type="button" class="calcbutton
" onclick="Edit(9);
">9</button>
1234 <button type="button" id="qty
" class="calcbutton2
" onclick="Edit(
'qty')
"><?php echo $langs->trans("Qty
"); ?></button>
1235 <button type="button" class="calcbutton
" onclick="Edit(4);
">4</button>
1236 <button type="button" class="calcbutton
" onclick="Edit(5);
">5</button>
1237 <button type="button" class="calcbutton
" onclick="Edit(6);
">6</button>
1238 <button type="button" id="price" class="calcbutton2
" onclick="Edit(
'p')
"><?php echo $langs->trans("Price
"); ?></button>
1239 <button type="button" class="calcbutton
" onclick="Edit(1);
">1</button>
1240 <button type="button" class="calcbutton
" onclick="Edit(2);
">2</button>
1241 <button type="button" class="calcbutton
" onclick="Edit(3);
">3</button>
1242 <button type="button" id="reduction
" class="calcbutton2
" onclick="Edit(
'r')
"><?php echo $langs->trans("ReductionShort
"); ?></button>
1243 <button type="button" class="calcbutton
" onclick="Edit(0);
">0</button>
1244 <button type="button" class="calcbutton
" onclick="Edit(
'.')
">.</button>
1245 <button type="button" class="calcbutton poscolorblue
" onclick="Edit(
'c')
">C</button>
1246 <button type="button" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline()
"><span class="fa fa-trash
"></span></button>
1251// TakePOS setup check
1252if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1253 $sql = "SELECT code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1254 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1255 $sql .= " AND active = 1
";
1256 $sql .= " ORDER BY libelle
";
1258 $resql = $db->query($sql);
1259 $paiementsModes = array();
1261 while ( $obj = $db->fetch_object($resql) ) {
1262 $paycode = $obj->code;
1263 if ($paycode == 'LIQ') {
1266 if ($paycode == 'CHQ') {
1267 $paycode = 'CHEQUE';
1270 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1271 //var_dump($constantforkey.' '.$conf->global->$constantforkey);
1272 if ( !empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) {
1273 array_push($paiementsModes, $obj);
1278 if (empty($paiementsModes) && isModEnabled("banque
")) {
1279 $langs->load('errors');
1280 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1281 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1285if (count($maincategories) == 0) {
1286 if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
1287 $tmpcategory = new Categorie($db);
1288 $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
1289 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1291 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1294// User menu and external TakePOS modules
1298if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) {
1299 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action'=>'New();');
1301 // BAR RESTAURANT specific menu
1302 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action'=>'Floors();');
1305if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1306 $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action'=>'Customer();');
1308if ( ! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1309 $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action'=>'History();');
1311$menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action'=>'FreeZone();');
1312$menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Reduction
").'</div>', 'action'=>'Reduction();');
1313$menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action'=>'CloseBill();');
1315if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1316 $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();');
1319$menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action'=>'Split();');
1321// BAR RESTAURANT specific menu
1322if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1323 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1324 $menus[$r++] = array('title'=>'<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action'=>'TakeposPrintingOrder();');
1326 //Button to print receipt before payment
1327 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1328 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1329 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1330 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposConnector(placeid);');
1332 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposPrinting(placeid);');
1334 } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1335 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
1337 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'Print(placeid);');
1340 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1341 $menus[$r++] = array('title'=>'<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action'=>'TakeposOrderNotes();');
1343 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1344 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action'=>'LoadProducts(\'supplements\');');
1348if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1349 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action'=>'OpenDrawer();');
1351if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1352 $menus[$r++] = array(
1353 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1354 'action' => 'DolibarrOpenDrawer();',
1358$sql = "SELECT
rowid, status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1359$sql .= " entity =
".((int) $conf->entity)." AND
";
1360$sql .= " posnumber =
".((int) $_SESSION["takeposterminal
"])." AND
";
1361$sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1363$resql = $db->query($sql);
1365 $num = $db->num_rows($resql);
1367 $obj = $db->fetch_object($resql);
1368 $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
1369 if ($obj->status == 0) {
1370 $menus[$r++] = array('title'=>'<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');');
1375$parameters = array('menus'=>$menus);
1376$reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1377if ($reshook == 0) { //add buttons
1378 if (is_array($hookmanager->resArray) ) {
1379 foreach ($hookmanager->resArray as $resArray) {
1380 foreach ($resArray as $butmenu) {
1381 $menus[$r++] = $butmenu;
1385} elseif ($reshook == 1) {
1386 $r = 0; //replace buttons
1387 if (is_array($hookmanager->resArray) ) {
1388 foreach ($hookmanager->resArray as $resArray) {
1389 foreach ($resArray as $butmenu) {
1390 $menus[$r++] = $butmenu;
1397 $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
1400if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1401 $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().'\';');
1404if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
1405 $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action'=>'WeighingScale();');
1409 <!-- Show buttons -->
1413 foreach ($menus as $menu) {
1415 if (count($menus) > 12 and $i == 12) {
1416 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).')
">'.$langs->trans("Next
").'</button>';
1417 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1418 } elseif ($i > 12) {
1419 echo '<button style="display: none;
" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1421 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1425 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1426 print '<!-- Show the search input text -->'."\n
";
1427 print '<div class="margintoponly
">';
1428 print '<input type="text
" id="search
" class="input-search-takepos
" 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> ';
1429 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch();
">'.img_picto('', 'searchclear').'</a>';
1436 <div class="row2<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1440 <!-- Show categories -->
1442 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1443 print '<div class="div4
" style= "display: none;
">';
1445 print '<div class="div4
">';
1449 while ($count < $MAXCATEG) {
1451 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1452 echo 'onclick="MoreCategories(\
'less\')"';
1453 } elseif ($count == ($MAXCATEG - 1)) {
1454 echo
'onclick="MoreCategories(\'more\')"';
1456 echo
'onclick="LoadProducts('.$count.
')"';
1457 } ?>
id=
"catdiv<?php echo $count; ?>">
1459 if ($count == ($MAXCATEG - 2)) {
1461 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1462 } elseif ($count == ($MAXCATEG - 1)) {
1464 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1467 echo
'<img class="imgwrapper" id="catimg'.$count.
'" />';
1471 <?php
if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?>
1472 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1473 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1476 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1484 <!-- Show product -->
1485 <div
class=
"div5"<?php
if (
getDolGlobalInt(
'TAKEPOS_HIDE_CATEGORIES') == 1) {
1486 print
' style="width:100%;"';
1490 while ($count < $MAXPRODUCT) {
1491 print
'<div class="wrapper2 arrow" id="prodiv'.$count.
'" ';
1493 <?php
if ($count == ($MAXPRODUCT - 2)) {
1494 ?> onclick=
"MoreProducts('less')" <?php
1495 }
if ($count == ($MAXPRODUCT - 1)) {
1496 ?> onclick=
"MoreProducts('more')" <?php
1498 echo
'onclick="ClickProduct('.$count.
')"';
1501 if ($count == ($MAXPRODUCT - 2)) {
1503 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1504 } elseif ($count == ($MAXPRODUCT - 1)) {
1506 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1509 echo
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1511 print
'<div class="" id="proprice'.$count.
'"></div>';
1512 print
'<img class="imgwrapper" title="" id="proimg'.$count.
'">';
1516 <?php
if ($count != ($MAXPRODUCT - 2) && $count != ($MAXPRODUCT - 1) && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1517 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1518 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1521 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1527 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1528 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1529 <input
type=
"hidden" id=
"search_pagination" value=
"">
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 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_menu_user($hideloginname=0, $urllogout='')
Build the tooltip on user login.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
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.