30 if (!defined(
'NOCSRFCHECK')) {
31 define(
'NOCSRFCHECK',
'1');
33 if (!defined(
'NOTOKENRENEWAL')) {
34 define(
'NOTOKENRENEWAL',
'1');
36 if (!defined(
'NOREQUIREMENU')) {
37 define(
'NOREQUIREMENU',
'1');
39 if (!defined(
'NOREQUIREHTML')) {
40 define(
'NOREQUIREHTML',
'1');
42 if (!defined(
'NOREQUIREAJAX')) {
43 define(
'NOREQUIREAJAX',
'1');
46 require
'../main.inc.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
55 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') : 0);
56 $action =
GETPOST(
'action',
'aZ09');
57 $setterminal =
GETPOST(
'setterminal',
'int');
58 $setcurrency =
GETPOST(
'setcurrency',
'aZ09');
60 if (empty($_SESSION[
"takeposterminal"])) {
62 $_SESSION[
"takeposterminal"] = 1;
63 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
64 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
68 if ($setterminal > 0) {
69 $_SESSION[
"takeposterminal"] = $setterminal;
70 setcookie(
"takeposterminal", $setterminal, (time() + (86400 * 354)),
'/',
null, (empty($dolibarr_main_force_https) ?
false :
true),
true);
73 if ($setcurrency !=
"") {
74 $_SESSION[
"takeposcustomercurrency"] = $setcurrency;
78 $_SESSION[
"urlfrom"] =
'/takepos/index.php';
80 $langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter",
"banks"));
84 $maxcategbydefaultforthisdevice = 12;
85 $maxproductbydefaultforthisdevice = 24;
86 if ($conf->browser->layout ==
'phone') {
87 $maxcategbydefaultforthisdevice = 8;
88 $maxproductbydefaultforthisdevice = 16;
90 if ($_SESSION[
"takeposterminal"] !=
"" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) {
91 $_SESSION[
"basiclayout"] = 1;
92 header(
"Location: phone.php?mobilepage=invoice");
96 $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
97 $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
119 $arrayofjs = array();
120 $arrayofcss = array();
123 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
124 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
125 $title =
'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
127 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
128 <meta name="apple-mobile-web-app-capable" content="yes">
129 <meta name="mobile-web-app-capable" content="yes">
130 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
131 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
134 <link rel=
"stylesheet" href=
"css/pos.css.php">
135 <link rel=
"stylesheet" href=
"css/colorbox.css" type=
"text/css" media=
"screen" />
138 print
'<link rel="stylesheet" href="css/colorful.css">';
141 <script
type=
"text/javascript" src=
"js/jquery.colorbox-min.js"></script> <!-- TODO It seems we don
't need this -->
142 <script type="text/javascript">
144 $categories = $categorie->get_full_arbo('product
', ((getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID
') > 0) ? getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID
') : 0), 1);
147 // Search root category to know its level
148 //$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
149 $levelofrootcategory = 0;
150 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID
') > 0) {
151 foreach ($categories as $key => $categorycursor) {
152 if ($categorycursor['id'] == getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID
')) {
153 $levelofrootcategory = $categorycursor['level
'];
159 $levelofmaincategories = $levelofrootcategory + 1;
161 $maincategories = array();
162 $subcategories = array();
163 foreach ($categories as $key => $categorycursor) {
164 if ($categorycursor['level
'] == $levelofmaincategories) {
165 $maincategories[$key] = $categorycursor;
167 $subcategories[$key] = $categorycursor;
171 $maincategories = dol_sort_array($maincategories, 'label
');
172 $subcategories = dol_sort_array($subcategories, 'label
');
175 var categories = <?php echo json_encode($maincategories); ?>;
176 var subcategories = <?php echo json_encode($subcategories); ?>;
180 var pagecategories=0;
182 var place="<?php echo $place; ?>";
183 var editaction="qty";
186 var search2_timer=null;
190 app.hasKeyboard = false;
191 this.keyboardPress = function() {
192 app.hasKeyboard = true;
193 $(window).unbind("keyup", app.keyboardPress);
194 localStorage.hasKeyboard = true;
195 console.log("has keyboard!")
197 $(window).on("keyup", app.keyboardPress)
198 if(localStorage.hasKeyboard) {
199 app.hasKeyboard = true;
200 $(window).unbind("keyup", app.keyboardPress);
201 console.log("has keyboard from localStorage")
205 function ClearSearch() {
206 console.log("ClearSearch");
207 $("#search").val('');
208 $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked
');
209 $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked
');
210 $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked
');
211 <?php if ($conf->browser->layout == 'classic
') { ?>
212 setFocusOnSearchField();
216 // Set the focus on search field but only on desktop. On tablet or smartphone, we don't to avoid to have the keyboard open automatically
217 function setFocusOnSearchField() {
218 console.log(
"Call setFocusOnSearchField in page index.php");
219 <?php
if ($conf->browser->layout ==
'classic') { ?>
220 console.log(
"has keyboard from localStorage, so we can force focus on search field");
221 $(
"#search").focus();
225 function PrintCategories(first) {
226 console.log(
"PrintCategories");
227 for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
228 if (typeof (categories[parseInt(i)+parseInt(first)]) ==
"undefined")
230 $(
"#catdivdesc"+i).hide();
231 $(
"#catdesc"+i).text(
"");
232 $(
"#catimg"+i).attr(
"src",
"genimg/empty.png");
233 $(
"#catwatermark"+i).hide();
234 $(
"#catdiv"+i).attr(
'class',
'wrapper divempty');
237 $(
"#catdivdesc"+i).show();
240 $(
"#catdesc"+i).html(categories[parseInt(i)+parseInt(first)][
'label'].bold() +
' - ' + categories[parseInt(i)+parseInt(first)][
'description']);
242 $(
"#catdesc"+i).text(categories[parseInt(i)+parseInt(first)][
'label']);
244 $(
"#catimg"+i).attr(
"src",
"genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)][
'rowid']);
245 $(
"#catdiv"+i).data(
"rowid",categories[parseInt(i)+parseInt(first)][
'rowid']);
246 $(
"#catdiv"+i).attr(
'class',
'wrapper');
247 $(
"#catwatermark"+i).show();
251 function 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;
268 for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
269 if (typeof (categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]) ==
"undefined") {
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();
292 function 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();
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();
330 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&category='+currentcat,
function(data) {
331 console.log(
"Call ajax.php (in LoadProducts) to get Products of category "+currentcat+
" then loop on result to fill image thumbs");
333 while (ishow < maxproduct) {
335 console.log(data[idata]);
336 if (typeof (data[idata]) ==
"undefined") {
338 echo
'$("#prodivdesc"+ishow).hide();';
339 echo
'$("#prodesc"+ishow).text("");';
340 echo
'$("#proimg"+ishow).attr("title","");';
341 echo
'$("#proimg"+ishow).attr("src","genimg/empty.png");';
343 echo
'$("#probutton"+ishow).hide();';
344 echo
'$("#probutton"+ishow).text("");';
346 $(
"#proprice"+ishow).attr(
"class",
"hidden");
347 $(
"#proprice"+ishow).html(
"");
348 $(
"#prodiv"+ishow).data(
"rowid",
"");
349 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2 divempty");
350 $(
"#prowatermark"+ishow).hide();
353 else if ((data[idata][
'status']) ==
"1") {
355 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[idata]['ref']";
356 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[idata]['barcode']";
358 var titlestring = <?php echo $titlestring; ?>;
360 echo
'$("#prodivdesc"+ishow).show();';
362 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
364 echo
'$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
366 echo
'$("#proimg"+ishow).attr("title", titlestring);';
367 echo
'$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
369 echo
'$("#probutton"+ishow).show();';
370 echo
'$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
373 if (data[parseInt(idata)][
'price_formated']) {
374 $(
"#proprice"+ishow).attr(
"class",
"productprice");
375 $(
"#proprice"+ishow).html(data[parseInt(idata)][
'price_formated']);
377 $(
"#prodiv"+ishow).data(
"rowid", data[idata][
'id']);
378 $(
"#prodiv"+ishow).data(
"iscat", 0);
379 $(
"#prodiv"+ishow).attr(
"class",
"wrapper2");
380 $(
"#prowatermark"+ishow).hide();
385 $parameters[
'caller'] =
'loadProducts';
386 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
387 print $hookmanager->resPrint;
398 function MoreProducts(moreorless) {
399 console.log(
"MoreProducts");
401 if ($(
'#search_pagination').val() !=
'')
return Search2(
'<?php echo $keyCodeForEnter; ?>', moreorless);
403 var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
405 if (moreorless==
"more"){
406 $(
'#proimg31').animate({opacity:
'0.5'}, 1);
407 $(
'#proimg31').animate({opacity:
'1'}, 100);
408 pageproducts=pageproducts+1;
410 if (moreorless==
"less"){
411 $(
'#proimg30').animate({opacity:
'0.5'}, 1);
412 $(
'#proimg30').animate({opacity:
'1'}, 100);
413 if (pageproducts==0)
return;
414 pageproducts=pageproducts-1;
416 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&category='+currentcat,
function(data) {
417 console.log(
"Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
419 if (typeof (data[(maxproduct * pageproducts)]) ==
"undefined" && moreorless==
"more"){
420 pageproducts=pageproducts-1;
423 idata=<?php echo ($MAXPRODUCT - 2); ?> * pageproducts;
426 while (ishow < maxproduct) {
427 if (typeof (data[idata]) ==
"undefined") {
428 $(
"#prodivdesc"+ishow).hide();
429 $(
"#prodesc"+ishow).text(
"");
430 $(
"#probutton"+ishow).text(
"");
431 $(
"#probutton"+ishow).hide();
432 $(
"#proprice"+ishow).attr(
"class",
"");
433 $(
"#proprice"+ishow).html(
"");
434 $(
"#proimg"+ishow).attr(
"src",
"genimg/empty.png");
435 $(
"#prodiv"+ishow).data(
"rowid",
"");
438 else if ((data[idata][
'status']) ==
"1") {
440 $(
"#prodivdesc"+ishow).show();
443 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'ref'].bold() +
' - ' + data[parseInt(idata)][
'label']);
445 $(
"#prodesc"+ishow).html(data[parseInt(idata)][
'label']);
447 $(
"#probutton"+ishow).html(data[parseInt(idata)][
'label']);
448 $(
"#probutton"+ishow).show();
449 if (data[parseInt(idata)][
'price_formated']) {
450 $(
"#proprice"+ishow).attr(
"class",
"productprice");
451 $(
"#proprice"+ishow).html(data[parseInt(idata)][
'price_formated']);
453 $(
"#proimg"+ishow).attr(
"src",
"genimg/index.php?query=pro&id="+data[idata][
'id']);
454 $(
"#prodiv"+ishow).data(
"rowid",data[idata][
'id']);
455 $(
"#prodiv"+ishow).data(
"iscat",0);
458 $(
"#prowatermark"+ishow).hide();
466 function ClickProduct(position, qty = 1) {
467 console.log(
"ClickProduct");
468 $(
'#proimg'+position).animate({opacity:
'0.5'}, 1);
469 $(
'#proimg'+position).animate({opacity:
'1'}, 100);
470 if ($(
'#prodiv'+position).data(
'iscat')==1){
471 console.log(
"Click on a category at position "+position);
472 LoadProducts(position,
true);
475 idproduct=$(
'#prodiv'+position).data(
'rowid');
476 console.log(
"Click on product at position "+position+
" for idproduct "+idproduct+
", qty="+qty);
477 if (idproduct==
"")
return;
479 $(
"#poslines").load(
"invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+
"&idproduct="+idproduct+
"&selectedline="+selectedline+
"&qty="+qty,
function() {
480 <?php
if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo
"CustomerDisplay();";?>
487 function ChangeThirdparty(idcustomer) {
488 console.log(
"ChangeThirdparty");
490 $(
"#poslines").load(
"../societe/list.php?action=change&type=t&contextpage=poslist&idcustomer="+idcustomer+
"&place="+place+
"",
function() {
496 function deleteline() {
497 console.log(
"Delete line");
498 $(
"#poslines").load(
"invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
504 function Customer() {
505 console.log(
"Open box to select the thirdparty place="+place);
506 $.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
"); ?>"});
511 console.log(
"Open box to select the history");
512 $.colorbox({href:
"../compta/facture/list.php?contextpage=poslist", width:
"90%", height:
"80%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("History
"); ?>"});
515 function Reduction() {
516 invoiceid = $(
"#invoiceid").val();
517 console.log(
"Open popup to enter reduction on invoiceid="+invoiceid);
518 $.colorbox({href:
"reduction.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
521 function CloseBill() {
522 invoiceid = $(
"#invoiceid").val();
523 console.log(
"Open popup to enter payment on invoiceid="+invoiceid);
524 $.colorbox({href:
"pay.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
528 invoiceid = $(
"#invoiceid").val();
529 console.log(
"Open popup to split on invoiceid="+invoiceid);
530 $.colorbox({href:
"split.php?place="+place+
"&invoiceid="+invoiceid, width:
"80%", height:
"90%", transition:
"none", iframe:
"true", title:
""});
534 console.log(
"Open box to select floor place="+place);
535 $.colorbox({href:
"floors.php?place="+place, width:
"90%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("Floors
"); ?>"});
538 function FreeZone() {
539 console.log(
"Open box to enter a free product");
540 $.colorbox({href:
"freezone.php?action=freezone&place="+place, width:
"80%", height:
"200px", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("FreeZone
"); ?>"});
543 function TakeposOrderNotes() {
544 console.log(
"Open box to order notes");
545 ModalBox(
'ModalNote');
546 $(
"#textinput").focus();
550 console.log(
"Refresh by reloading place="+place+
" invoiceid="+invoiceid);
551 $(
"#poslines").load(
"invoice.php?place="+place+
"&invoiceid="+invoiceid,
function() {
558 invoiceid = $(
"#invoiceid").val();
560 console.log(
"New with place = <?php echo $place; ?>, js place="+place+
", invoiceid="+invoiceid);
562 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&id='+invoiceid,
function(data) {
565 if (parseInt(data[
'paye']) === 1) {
568 r = confirm(
'<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
573 $(
"#poslines").load(
"invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place,
function () {
588 function Search2(keyCodeForEnter, moreorless) {
589 var eventKeyCode = window.event.keyCode;
591 console.log(
"Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+
", eventKeyCode="+eventKeyCode);
593 var search_term = $(
'#search').val();
594 var search_start = 0;
595 var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
596 if (moreorless !=
null) {
597 search_term = $(
'#search_pagination').val();
598 search_start = $(
'#search_start_'+moreorless).val();
601 console.log(
"search_term="+search_term);
603 if (search_term ==
'') {
604 $(
"[id^=prowatermark]").html(
"");
605 $(
"[id^=prodesc]").text(
"");
606 $(
"[id^=probutton]").text(
"");
607 $(
"[id^=probutton]").hide();
608 $(
"[id^=proprice]").attr(
"class",
"hidden");
609 $(
"[id^=proprice]").html(
"");
610 $(
"[id^=proimg]").attr(
"src",
"genimg/empty.png");
611 $(
"[id^=prodiv]").data(
"rowid",
"");
616 if (keyCodeForEnter ==
'' || eventKeyCode == keyCodeForEnter) {
620 if (search ===
true) {
624 clearTimeout(search2_timer);
628 search2_timer = setTimeout(
function(){
630 jQuery(
".wrapper2 .catwatermark").hide();
631 var nbsearchresults = 0;
632 $.getJSON(
'<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&term=' + search_term +
'&search_start=' + search_start +
'&search_limit=' + search_limit,
function (data) {
633 for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
634 if (typeof (data[i]) ==
"undefined") {
635 $(
"#prowatermark" + i).html(
"");
636 $(
"#prodesc" + i).text(
"");
637 $(
"#probutton" + i).text(
"");
638 $(
"#probutton" + i).hide();
639 $(
"#proprice" + i).attr(
"class",
"hidden");
640 $(
"#proprice" + i).html(
"");
641 $(
"#proimg" + i).attr(
"src",
"genimg/empty.png");
642 $(
"#prodiv" + i).data(
"rowid",
"");
646 $titlestring =
"'".dol_escape_js($langs->transnoentities(
'Ref').
': ').
"' + data[i]['ref']";
647 $titlestring .=
" + ' - ".dol_escape_js($langs->trans(
"Barcode").
': ').
"' + data[i]['barcode']";
649 var titlestring = <?php echo $titlestring; ?>;
652 $(
"#prodesc" + i).html(data[i][
'ref'].bold() +
' - ' + data[i][
'label']);
654 $(
"#prodesc" + i).html(data[i][
'label']);
656 $(
"#prodivdesc" + i).show();
657 $(
"#probutton" + i).html(data[i][
'label']);
658 $(
"#probutton" + i).show();
659 if (data[i][
'price_formated']) {
660 $(
"#proprice" + i).attr(
"class",
"productprice");
661 $(
"#proprice" + i).html(data[i][
'price_formated']);
663 $(
"#proimg" + i).attr(
"title", titlestring);
664 if( undefined !== data[i][
'img']) {
665 $(
"#proimg" + i).attr(
"src", data[i][
'img']);
668 $(
"#proimg" + i).attr(
"src",
"genimg/index.php?query=pro&id=" + data[i][
'rowid']);
670 $(
"#prodiv" + i).data(
"rowid", data[i][
'rowid']);
671 $(
"#prodiv" + i).data(
"iscat", 0);
676 $parameters[
'caller'] =
'search2';
677 $hookmanager->executeHooks(
'completeJSProductDisplay', $parameters);
678 print $hookmanager->resPrint;
683 }).always(
function (data) {
685 if ($(
'#search').val().length > 0 && data.length == 1) {
686 console.log($(
'#search').val()+
' - '+data[0][
'barcode']);
687 if ($(
'#search').val() == data[0][
'barcode'] &&
'thirdparty' == data[0][
'object']) {
688 console.log(
"There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0][
'rowid']);
689 ChangeThirdparty(data[0][
'rowid']);
691 else if ($(
'#search').val() == data[0][
'barcode'] &&
'product' == data[0][
'object']) {
692 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']);
693 ClickProduct(0, data[0][
'qty']);
696 if (eventKeyCode == keyCodeForEnter){
697 if (data.length == 0) {
698 $(
'#search').val(
'<?php
699 $langs->load('errors
');
700 echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
701 ?> ('+search_term+
')');
702 $(
'#search').select();
707 $(
"#search_pagination").val($(
"#search").val());
708 if (search_start == 0) {
709 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
712 $(
"#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
713 var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
714 $(
"#search_start_less").val(search_start_less);
716 if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
717 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
720 $(
"#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
721 var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
722 $(
"#search_start_more").val(search_start_more);
731 function Edit(number) {
732 console.log(
"We click on PAD on key="+number);
734 if (typeof(selectedtext) ==
"undefined") {
738 var text=selectedtext+
"<br> ";
744 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
745 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
746 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
748 }
else if (number==
'qty') {
749 if (editaction==
'qty' && editnumber !=
'') {
750 $(
"#poslines").load(
"invoice.php?action=updateqty&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
753 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
756 setFocusOnSearchField();
762 }
else if (number==
'p') {
763 if (editaction==
'p' && editnumber!=
"") {
764 $(
"#poslines").load(
"invoice.php?action=updateprice&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
767 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
776 }
else if (number==
'r') {
777 if (editaction==
'r' && editnumber!=
"") {
778 $(
"#poslines").load(
"invoice.php?action=updatereduction&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
781 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
792 editnumber=editnumber+number;
794 if (editaction==
'qty'){
795 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Qty
").":
"; ?>";
796 $(
"#qty").html(
"OK").addClass(
"clicked");
797 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
798 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
800 if (editaction==
'p'){
801 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("Price
").":
"; ?>";
802 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
803 $(
"#price").html(
"OK").addClass(
"clicked");
804 $(
"#reduction").html(
"<?php echo $langs->trans("ReductionShort
"); ?>").removeClass(
'clicked');
806 if (editaction==
'r'){
807 text=text+
"<?php echo $langs->trans("Modify
")." ->
".$langs->trans("ReductionShort
").":
"; ?>";
808 $(
"#qty").html(
"<?php echo $langs->trans("Qty
"); ?>").removeClass(
'clicked');
809 $(
"#price").html(
"<?php echo $langs->trans("Price
"); ?>").removeClass(
'clicked');
810 $(
"#reduction").html(
"OK").addClass(
"clicked");
812 $(
'#'+selectedline).find(
"td:first").html(text+editnumber);
816 function TakeposPrintingOrder(){
817 console.log(
"TakeposPrintingOrder");
818 $(
"#poslines").load(
"invoice.php?action=order&place="+place,
function() {
823 function TakeposPrintingTemp(){
824 console.log(
"TakeposPrintingTemp");
825 $(
"#poslines").load(
"invoice.php?action=temp&place="+place,
function() {
830 function OpenDrawer(){
831 console.log(
"OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
834 data: { token:
'notrequired' },
836 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
837 echo
"url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
"/printer/drawer.php',";
839 echo
"url: 'http://".getDolGlobalString(
'TAKEPOS_PRINT_SERVER',
'localhost').
":8111/print',";
846 function DolibarrOpenDrawer() {
847 console.log(
"DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&term=<?php print urlencode($_SESSION["takeposterminal
"]); ?>");
850 data: { token:
'<?php echo currentToken(); ?>' },
851 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&term='.urlencode($_SESSION["takeposterminal
"]); ?>",
855 function MoreActions(totalactions){
858 for (i = 0; i <= totalactions; i++){
859 if (i<12) $(
"#action"+i).hide();
860 else $(
"#action"+i).show();
863 else if (pageactions==1){
865 for (i = 0; i <= totalactions; i++){
866 if (i<12) $(
"#action"+i).show();
867 else $(
"#action"+i).hide();
872 function ControlCashOpening()
874 $.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
"); ?>"});
877 function CloseCashFence(
rowid)
879 $.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
"); ?>"});
882 function CashReport(
rowid)
884 $.colorbox({href:
"../compta/cashcontrol/report.php?id="+
rowid+
"&contextpage=takepos", width:
"60%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("CashReport
"); ?>"});
888 function ModalBox(ModalID)
890 var modal = document.getElementById(ModalID);
891 modal.style.display =
"block";
894 function DirectPayment(){
895 console.log(
"DirectPayment");
896 $(
"#poslines").load(
"invoice.php?place="+place+
"&action=valid&pay=LIQ",
function() {
900 function FullScreen() {
901 document.documentElement.requestFullscreen();
904 function WeighingScale(){
905 console.log(
"Weighing Scale");
908 data: { token:
'notrequired' },
909 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/scale/index.php',
911 .done(
function( editnumber ) {
912 $(
"#poslines").load(
"invoice.php?action=updateqty&place="+place+
"&idline="+selectedline+
"&number="+editnumber,
function() {
918 $( document ).ready(
function() {
924 if ($_SESSION[
"takeposterminal"] ==
"") {
925 print
"ModalBox('ModalTerminal');";
929 $sql =
"SELECT rowid, status FROM ".MAIN_DB_PREFIX.
"pos_cash_fence WHERE";
930 $sql .=
" entity = ".((int) $conf->entity).
" AND ";
931 $sql .=
" posnumber = ".((int) $_SESSION[
"takeposterminal"]).
" AND ";
933 $resql = $db->query($sql);
935 $obj = $db->fetch_object(
$resql);
937 if ($obj->rowid ==
null) {
938 print
"ControlCashOpening();";
946 <body
class=
"bodytakepos" style=
"overflow: hidden;">
948 $keyCodeForEnter =
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) > 0 ?
getDolGlobalInt(
'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION[
'takeposterminal']) :
'';
950 <div
class=
"container">
953 if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
957 <div
class=
"topnav-left">
958 <div
class=
"inline-block valignmiddle">
959 <a
class=
"topnav-terminalhour" onclick=
"ModalBox('ModalTerminal');">
960 <span
class=
"fa fa-cash-register"></span>
961 <span
class=
"hideonsmartphone">
962 <?php echo $langs->trans(
"Terminal"); ?>
965 if ($_SESSION[
"takeposterminal"] ==
"") {
968 echo $_SESSION[
"takeposterminal"];
970 echo
'<span class="hideonsmartphone"> - '.dol_print_date(
dol_now(),
"day").
'</span>';
975 print
'<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\');" title=""><span class="fas fa-coins paddingrightonly"></span>';
976 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency").
'</span>';
981 <!-- section
for customer -->
982 <div
class=
"inline-block valignmiddle" id=
"customerandsales"></div>
983 <!-- section
for shopping carts -->
984 <div
class=
"inline-block valignmiddle" id=
"shoppingcart"></div>
985 <!-- More info about customer -->
986 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"moreinfo"></div>
990 <!-- More info about warehouse -->
991 <div
class=
"inline-block valignmiddle tdoverflowmax150onsmartphone" id=
"infowarehouse"></div>
996 <div
class=
"topnav-right">
997 <div
class=
"login_block_other">
998 <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>
999 <a onclick=
"ClearSearch();"><span
class=
"fa fa-backspace"></span></a>
1000 <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 -->
1001 <span
class=
"fas fa-home"></span></a>
1002 <?php
if (empty($conf->dol_use_jmobile)) { ?>
1003 <a
class=
"hideonsmartphone" onclick=
"FullScreen();"><span
class=
"fa fa-expand-arrows-alt"></span></a>
1006 <div
class=
"login_block_user">
1018 <!-- Modal terminal box -->
1019 <div
id=
"ModalTerminal" class=
"modal">
1020 <div
class=
"modal-content">
1021 <div
class=
"modal-header">
1022 <span
class=
"close" href=
"#" onclick=
"document.getElementById('ModalTerminal').style.display = 'none';">×</span>
1023 <h3><?php print $langs->trans(
"TerminalSelect"); ?></h3>
1025 <div
class=
"modal-body">
1026 <button
type=
"button" class=
"block" onclick=
"location.href='index.php?setterminal=1'"><?php print $langs->trans(
"Terminal"); ?> 1</button>
1029 for ($i = 2; $i <= $nbloop; $i++) {
1030 print
'<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.
'\'">'.$langs->trans("Terminal
").' '.$i.'</button>';
1037 <!-- Modal multicurrency box -->
1038 <?php if (isModEnabled('multicurrency')) { ?>
1039 <div id="ModalCurrency
" class="modal
">
1040 <div class="modal-content
">
1041 <div class="modal-header
">
1042 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCurrency').style.display =
'none';
">×</span>
1043 <h3><?php print $langs->trans("SetMultiCurrencyCode
"); ?></h3>
1045 <div class="modal-body
">
1047 $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
1048 $sql .= " WHERE entity IN (
'".getEntity('multicurrency
')."')
";
1049 $resql = $db->query($sql);
1051 while ($obj = $db->fetch_object($resql)) {
1052 print '<button type="button
" class="block
" onclick="location.href=\
'index.php?setcurrency='.$obj->code.
'\'">'.$obj->code.'</button>';
1061 <!-- Modal terminal Credit Note -->
1062 <div id="ModalCreditNote
" class="modal
">
1063 <div class="modal-content
">
1064 <div class="modal-header
">
1065 <span class="close
" href="#
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
">×</span>
1066 <h3><?php print $langs->trans("invoiceAvoirWithLines
"); ?></h3>
1068 <div class="modal-body
">
1069 <button type="button
" class="block
" onclick="CreditNote(); document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("Yes
"); ?></button>
1070 <button type="button
" class="block
" onclick="document.getElementById(
'ModalCreditNote').style.display =
'none';
"><?php print $langs->trans("No
"); ?></button>
1076 <div id="ModalNote
" class="modal
">
1077 <div class="modal-content
">
1078 <div class="modal-header
">
1079 <span class="close
" href="#
" onclick="document.getElementById(
'ModalNote').style.display =
'none';
">×</span>
1080 <h3><?php print $langs->trans("Note
"); ?></h3>
1082 <div class="modal-body
">
1083 <input type="text
" class="block
" id="textinput
">
1084 <button type="button
" class="block
" onclick="SetNote(); document.getElementById(
'ModalNote').style.display =
'none';
">OK</button>
1089 <div class="row1<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1093 <div id="poslines
" class="div1
">
1097 <button type="button
" class="calcbutton
" onclick="Edit(7);
">7</button>
1098 <button type="button
" class="calcbutton
" onclick="Edit(8);
">8</button>
1099 <button type="button
" class="calcbutton
" onclick="Edit(9);
">9</button>
1100 <button type="button
" id="qty
" class="calcbutton2
" onclick="Edit(
'qty');
"><?php echo $langs->trans("Qty
"); ?></button>
1101 <button type="button
" class="calcbutton
" onclick="Edit(4);
">4</button>
1102 <button type="button
" class="calcbutton
" onclick="Edit(5);
">5</button>
1103 <button type="button
" class="calcbutton
" onclick="Edit(6);
">6</button>
1104 <button type="button
" id="price" class="calcbutton2
" onclick="Edit(
'p');
"><?php echo $langs->trans("Price
"); ?></button>
1105 <button type="button
" class="calcbutton
" onclick="Edit(1);
">1</button>
1106 <button type="button
" class="calcbutton
" onclick="Edit(2);
">2</button>
1107 <button type="button
" class="calcbutton
" onclick="Edit(3);
">3</button>
1108 <button type="button
" id="reduction
" class="calcbutton2
" onclick="Edit(
'r');
"><?php echo $langs->trans("ReductionShort
"); ?></button>
1109 <button type="button
" class="calcbutton
" onclick="Edit(0);
">0</button>
1110 <button type="button
" class="calcbutton
" onclick="Edit(
'.');
">.</button>
1111 <button type="button
" class="calcbutton poscolorblue
" onclick="Edit(
'c');
">C</button>
1112 <button type="button
" class="calcbutton2 poscolordelete
" id="delete" onclick="deleteline();
"><span class="fa fa-trash
"></span></button>
1117 // TakePOS setup check
1118 if (isset($_SESSION["takeposterminal
"]) && $_SESSION["takeposterminal
"]) {
1119 $sql = "SELECT
code, libelle FROM
" . MAIN_DB_PREFIX . "c_paiement
";
1120 $sql .= " WHERE entity IN (
" . getEntity('c_paiement') . ")
";
1121 $sql .= " AND active = 1
";
1122 $sql .= " ORDER BY libelle
";
1124 $resql = $db->query($sql);
1125 $paiementsModes = array();
1127 while ( $obj = $db->fetch_object($resql) ) {
1128 $paycode = $obj->code;
1129 if ($paycode == 'LIQ') {
1132 if ($paycode == 'CHQ') {
1133 $paycode = 'CHEQUE';
1136 $constantforkey = "CASHDESK_ID_BANKACCOUNT_
" . $paycode . $_SESSION["takeposterminal
"];
1137 //var_dump($constantforkey.' '.$conf->global->$constantforkey);
1138 if ( ! empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) {
1139 array_push($paiementsModes, $obj);
1144 if (empty($paiementsModes) && isModEnabled('banque')) {
1145 $langs->load('errors');
1146 setEventMessages($langs->trans("ErrorModuleSetupNotComplete
", $langs->transnoentitiesnoconv("TakePOS
")), null, 'errors');
1147 setEventMessages($langs->trans("ProblemIsInSetupOfTerminal
", $_SESSION["takeposterminal
"]), null, 'errors');
1151 if (count($maincategories) == 0) {
1152 if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
1153 $tmpcategory = new Categorie($db);
1154 $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
1155 setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory
", $tmpcategory->label), null, 'errors');
1157 setEventMessages($langs->trans("TakeposNeedsCategories
"), null, 'errors');
1160 // User menu and external TakePOS modules
1164 if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) {
1165 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("New
").'</div>', 'action'=>'New();');
1167 // BAR RESTAURANT specific menu
1168 $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Place
").'</div>', 'action'=>'Floors();');
1171 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1172 $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Customer
").'</div>', 'action'=>'Customer();');
1174 $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly
"></span><div class="trunc
">'.$langs->trans("History
").'</div>', 'action'=>'History();');
1175 $menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly
"></span><div class="trunc
">'.$langs->trans("FreeZone
").'</div>', 'action'=>'FreeZone();');
1176 $menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Reduction
").'</div>', 'action'=>'Reduction();');
1177 $menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Payment
").'</div>', 'action'=>'CloseBill();');
1179 if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
1180 $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();');
1183 $menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly
"></span><div class="trunc
">'.$langs->trans("SplitSale
").'</div>', 'action'=>'Split();');
1185 // BAR RESTAURANT specific menu
1186 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1187 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
1188 $menus[$r++] = array('title'=>'<span class="fa fa-blender-phone paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Order
").'</span>', 'action'=>'TakeposPrintingOrder();');
1190 //Button to print receipt before payment
1191 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1192 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1193 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1194 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposConnector(placeid);');
1196 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'TakeposPrinting(placeid);');
1198 } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1199 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
1201 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("Receipt
").'</div>', 'action'=>'Print(placeid);');
1204 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
1205 $menus[$r++] = array('title'=>'<span class="fa fa-sticky-note paddingrightonly
"></span><div class="trunc
">'.$langs->trans("OrderNotes
").'</div>', 'action'=>'TakeposOrderNotes();');
1207 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
1208 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("ProductSupplements
").'</div>', 'action'=>'LoadProducts(\'supplements\');');
1212 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1213 $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>', 'action'=>'OpenDrawer();');
1215 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") {
1216 $menus[$r++] = array(
1217 'title' => '<span class="fa fa-receipt paddingrightonly
"></span><div class="trunc
">'.$langs->trans("DOL_OPEN_DRAWER
").'</div>',
1218 'action' => 'DolibarrOpenDrawer();',
1222 $sql = "SELECT
rowid, status, entity FROM
".MAIN_DB_PREFIX."pos_cash_fence WHERE
";
1223 $sql .= " entity =
".((int) $conf->entity)." AND
";
1224 $sql .= " posnumber =
".((int) $_SESSION["takeposterminal
"])." AND
";
1225 $sql .= " date_creation >
'".$db->idate(dol_get_first_hour(dol_now()))."'";
1227 $resql = $db->query($sql);
1229 $num = $db->num_rows($resql);
1231 $obj = $db->fetch_object($resql);
1232 $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CashReport
").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
1233 if ($obj->status == 0) {
1234 $menus[$r++] = array('title'=>'<span class="fas fa-cash-
register paddingrightonly
"></span><div class="trunc
">'.$langs->trans("CloseCashFence
").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');');
1239 $hookmanager->initHooks(array('takeposfrontend'));
1240 $parameters = array('menus'=>$menus);
1241 $reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1242 if ($reshook == 0) { //add buttons
1243 if (is_array($hookmanager->resArray) ) {
1244 foreach ($hookmanager->resArray as $resArray) {
1245 foreach ($resArray as $butmenu) {
1246 $menus[$r++] = $butmenu;
1249 } elseif ($reshook == 1) {
1250 $r = 0; //replace buttons
1251 if (is_array($hookmanager->resArray) ) {
1252 foreach ($hookmanager->resArray as $resArray) {
1253 foreach ($resArray as $butmenu) {
1254 $menus[$r++] = $butmenu;
1262 $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
1265 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1266 $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().'\';');
1269 if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
1270 $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly
"></span><div class="trunc
">'.$langs->trans("WeighingScale
").'</div>', 'action'=>'WeighingScale();');
1274 <!-- Show buttons -->
1278 foreach ($menus as $menu) {
1280 if (count($menus) > 12 and $i == 12) {
1281 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button
" id="actionnext
" class="actionbutton
" onclick="MoreActions(
'.count($menus).');
">'.$langs->trans("Next
").'</button>';
1282 echo '<button style="display: none;
" type="button
" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1283 } elseif ($i > 12) {
1284 echo '<button style="display: none;
" type="button
" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1286 echo '<button style="'.(empty($menu['style
']) ? '' : $menu['style
']).'" type="button
" id="action
'.$i.'" class="actionbutton
" onclick="'.(empty($menu['action
']) ? '' : $menu['action
']).'">'.$menu['title'].'</button>';
1290 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1291 print '<!-- Show the search input text -->'."\n
";
1292 print '<div class="margintoponly
">';
1293 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> ';
1294 print '<a class="marginleftonly hideonsmartphone
" onclick="ClearSearch();
">'.img_picto('', 'searchclear').'</a>';
1301 <div class="row2<?php
if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1305 <!-- Show categories -->
1307 if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
1308 print '<div class="div4
" style= "display: none;
">';
1310 print '<div class="div4
">';
1314 while ($count < $MAXCATEG) {
1316 <div class="wrapper
" <?php if ($count == ($MAXCATEG - 2)) {
1317 echo 'onclick="MoreCategories(\
'less\');"';
1318 } elseif ($count == ($MAXCATEG - 1)) {
1319 echo
'onclick="MoreCategories(\'more\');"';
1321 echo
'onclick="LoadProducts('.$count.
');"';
1322 } ?>
id=
"catdiv<?php echo $count; ?>">
1324 if ($count == ($MAXCATEG - 2)) {
1326 echo
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1327 } elseif ($count == ($MAXCATEG - 1)) {
1329 echo
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1332 echo
'<img class="imgwrapper" height="100%" id="catimg'.$count.
'" />';
1336 <?php
if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?>
1337 <div
class=
"description" id=
"catdivdesc<?php echo $count; ?>">
1338 <div
class=
"description_content" id=
"catdesc<?php echo $count; ?>"></div>
1341 <div
class=
"catwatermark" id=
'catwatermark<?php echo $count; ?>'>...</div>
1349 <!-- Show product -->
1350 <div
class=
"div5"<?php
if (
getDolGlobalInt(
'TAKEPOS_HIDE_CATEGORIES') == 1) {
1351 print
' style="width:100%;"';
1355 while ($count < $MAXPRODUCT) {
1356 print
'<div class="wrapper2" id="prodiv'.$count.
'" ';
1358 <?php
if ($count == ($MAXPRODUCT - 2)) {
1359 ?> onclick=
"MoreProducts('less');" <?php
1360 }
if ($count == ($MAXPRODUCT - 1)) {
1361 ?> onclick=
"MoreProducts('more');" <?php
1363 echo
'onclick="ClickProduct('.$count.
');"';
1366 if ($count == ($MAXPRODUCT - 2)) {
1368 print
'<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1369 } elseif ($count == ($MAXPRODUCT - 1)) {
1371 print
'<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
1374 echo
'<button type="button" id="probutton'.$count.
'" class="productbutton" style="display: none;"></button>';
1376 print
'<div class="" id="proprice'.$count.
'"></div>';
1377 print
'<img class="imgwrapper" height="100%" title="" id="proimg'.$count.
'">';
1381 <?php
if ($count != ($MAXPRODUCT - 2) && $count != ($MAXPRODUCT - 1) && !
getDolGlobalString(
'TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
1382 <div
class=
"description" id=
"prodivdesc<?php echo $count; ?>">
1383 <div
class=
"description_content" id=
"prodesc<?php echo $count; ?>"></div>
1386 <div
class=
"catwatermark" id=
'prowatermark<?php echo $count; ?>'>...</div>
1392 <input
type=
"hidden" id=
"search_start_less" value=
"0">
1393 <input
type=
"hidden" id=
"search_start_more" value=
"0">
1394 <input
type=
"hidden" id=
"search_pagination" value=
"">