index.php 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462
  1. <?php
  2. /* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
  3. * Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
  4. * Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/takepos/index.php
  21. * \ingroup takepos
  22. * \brief Main TakePOS screen
  23. */
  24. // if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
  25. // if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
  26. // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  27. // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
  28. if (!defined('NOREQUIREMENU')) {
  29. define('NOREQUIREMENU', '1');
  30. }
  31. if (!defined('NOREQUIREHTML')) {
  32. define('NOREQUIREHTML', '1');
  33. }
  34. if (!defined('NOREQUIREAJAX')) {
  35. define('NOREQUIREAJAX', '1');
  36. }
  37. // Load Dolibarr environment
  38. require '../main.inc.php'; // Load $user and permissions
  39. require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
  40. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  41. require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
  42. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  43. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  44. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  45. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  46. $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Bar or Restaurant or multiple sales
  47. $action = GETPOST('action', 'aZ09');
  48. $setterminal = GETPOST('setterminal', 'int');
  49. $setcurrency = GETPOST('setcurrency', 'aZ09');
  50. if (empty($_SESSION["takeposterminal"])) {
  51. if (getDolGlobalInt('TAKEPOS_NUM_TERMINALS') == 1) {
  52. $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal
  53. } elseif (!empty($_COOKIE["takeposterminal"])) {
  54. $_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session
  55. }
  56. }
  57. if ($setterminal > 0) {
  58. $_SESSION["takeposterminal"] = $setterminal;
  59. setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Permanent takeposterminal var in a cookie
  60. }
  61. if ($setcurrency != "") {
  62. $_SESSION["takeposcustomercurrency"] = $setcurrency;
  63. // We will recalculate amount for foreign currency at next call of invoice.php when $_SESSION["takeposcustomercurrency"] differs from invoice->multicurrency_code.
  64. }
  65. $_SESSION["urlfrom"] = '/takepos/index.php';
  66. $langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter", "banks"));
  67. $categorie = new Categorie($db);
  68. $maxcategbydefaultforthisdevice = 12;
  69. $maxproductbydefaultforthisdevice = 24;
  70. if ($conf->browser->layout == 'phone') {
  71. $maxcategbydefaultforthisdevice = 8;
  72. $maxproductbydefaultforthisdevice = 16;
  73. //REDIRECT TO BASIC LAYOUT IF TERMINAL SELECTED AND BASIC MOBILE LAYOUT ENABLED
  74. if ($_SESSION["takeposterminal"] != "" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) {
  75. $_SESSION["basiclayout"] = 1;
  76. header("Location: phone.php?mobilepage=invoice");
  77. exit;
  78. }
  79. }
  80. $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG);
  81. $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT);
  82. /*
  83. $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
  84. $soc = new Societe($db);
  85. if ($invoice->socid > 0) $soc->fetch($invoice->socid);
  86. else $soc->fetch($conf->global->$constforcompanyid);
  87. */
  88. // Security check
  89. $result = restrictedArea($user, 'takepos', 0, '');
  90. /*
  91. * View
  92. */
  93. $form = new Form($db);
  94. $disablejs = 0;
  95. $disablehead = 0;
  96. $arrayofjs = array('/takepos/js/jquery.colorbox-min.js'); // TODO It seems we don't need this
  97. $arrayofcss = array('/takepos/css/pos.css.php', '/takepos/css/colorbox.css');
  98. if (getDolGlobalInt('TAKEPOS_COLOR_THEME') == 1) {
  99. $arrayofcss[] = '/takepos/css/colorful.css';
  100. }
  101. // Title
  102. $title = 'TakePOS - Dolibarr '.DOL_VERSION;
  103. if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
  104. $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
  105. }
  106. $head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
  107. <meta name="apple-mobile-web-app-capable" content="yes">
  108. <meta name="mobile-web-app-capable" content="yes">
  109. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
  110. top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
  111. $categories = $categorie->get_full_arbo('product', ((getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) ? getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') : 0), 1);
  112. // Search root category to know its level
  113. //$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
  114. $levelofrootcategory = 0;
  115. if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) {
  116. foreach ($categories as $key => $categorycursor) {
  117. if ($categorycursor['id'] == getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID')) {
  118. $levelofrootcategory = $categorycursor['level'];
  119. break;
  120. }
  121. }
  122. }
  123. $levelofmaincategories = $levelofrootcategory + 1;
  124. $maincategories = array();
  125. $subcategories = array();
  126. foreach ($categories as $key => $categorycursor) {
  127. if ($categorycursor['level'] == $levelofmaincategories) {
  128. $maincategories[$key] = $categorycursor;
  129. } else {
  130. $subcategories[$key] = $categorycursor;
  131. }
  132. }
  133. $maincategories = dol_sort_array($maincategories, 'label');
  134. $subcategories = dol_sort_array($subcategories, 'label');
  135. ?>
  136. <body class="bodytakepos" style="overflow: hidden;">
  137. <script>
  138. var categories = <?php echo json_encode($maincategories); ?>;
  139. var subcategories = <?php echo json_encode($subcategories); ?>;
  140. var currentcat;
  141. var pageproducts=0;
  142. var pagecategories=0;
  143. var pageactions=0;
  144. var place="<?php echo $place; ?>";
  145. var editaction="qty";
  146. var editnumber="";
  147. var invoiceid=0;
  148. var search2_timer=null;
  149. /*
  150. var app = this;
  151. app.hasKeyboard = false;
  152. this.keyboardPress = function() {
  153. app.hasKeyboard = true;
  154. $(window).unbind("keyup", app.keyboardPress);
  155. localStorage.hasKeyboard = true;
  156. console.log("has keyboard!")
  157. }
  158. $(window).on("keyup", app.keyboardPress)
  159. if(localStorage.hasKeyboard) {
  160. app.hasKeyboard = true;
  161. $(window).unbind("keyup", app.keyboardPress);
  162. console.log("has keyboard from localStorage")
  163. }
  164. */
  165. function ClearSearch() {
  166. console.log("ClearSearch");
  167. $("#search").val('');
  168. $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
  169. $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
  170. $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
  171. <?php if ($conf->browser->layout == 'classic') { ?>
  172. setFocusOnSearchField();
  173. <?php } ?>
  174. }
  175. // 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
  176. function setFocusOnSearchField() {
  177. console.log("Call setFocusOnSearchField in page index.php");
  178. <?php if ($conf->browser->layout == 'classic') { ?>
  179. console.log("has keyboard from localStorage, so we can force focus on search field");
  180. $("#search").focus();
  181. <?php } ?>
  182. }
  183. function PrintCategories(first) {
  184. console.log("PrintCategories");
  185. for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
  186. if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined")
  187. {
  188. $("#catdivdesc"+i).hide();
  189. $("#catdesc"+i).text("");
  190. $("#catimg"+i).attr("src","genimg/empty.png");
  191. $("#catwatermark"+i).hide();
  192. $("#catdiv"+i).attr('class', 'wrapper divempty');
  193. continue;
  194. }
  195. $("#catdivdesc"+i).show();
  196. <?php
  197. if (getDolGlobalString('TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
  198. $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label'].bold() + ' - ' + categories[parseInt(i)+parseInt(first)]['description']);
  199. <?php } else { ?>
  200. $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']);
  201. <?php } ?>
  202. $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']);
  203. $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']);
  204. $("#catdiv"+i).attr('class', 'wrapper');
  205. $("#catwatermark"+i).show();
  206. }
  207. }
  208. function MoreCategories(moreorless) {
  209. console.log("MoreCategories moreorless="+moreorless+" pagecategories="+pagecategories);
  210. if (moreorless=="more") {
  211. $('#catimg15').animate({opacity: '0.5'}, 1);
  212. $('#catimg15').animate({opacity: '1'}, 100);
  213. pagecategories=pagecategories+1;
  214. }
  215. if (moreorless=="less") {
  216. $('#catimg14').animate({opacity: '0.5'}, 1);
  217. $('#catimg14').animate({opacity: '1'}, 100);
  218. if (pagecategories==0) return; //Return if no less pages
  219. pagecategories=pagecategories-1;
  220. }
  221. if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless=="more") == "undefined"){ // Return if no more pages
  222. pagecategories=pagecategories-1;
  223. return;
  224. }
  225. for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
  226. if (typeof (categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]) == "undefined") {
  227. $("#catdivdesc"+i).hide();
  228. $("#catdesc"+i).text("");
  229. $("#catimg"+i).attr("src","genimg/empty.png");
  230. $("#catwatermark"+i).hide();
  231. continue;
  232. }
  233. $("#catdivdesc"+i).show();
  234. <?php
  235. if (getDolGlobalString('TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
  236. $("#catdesc"+i).html(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['label'].bold() + ' - ' + categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['description']);
  237. <?php } else { ?>
  238. $("#catdesc"+i).text(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['label']);
  239. <?php } ?>
  240. $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
  241. $("#catdiv"+i).data("rowid",categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
  242. $("#catwatermark"+i).show();
  243. }
  244. ClearSearch();
  245. }
  246. // LoadProducts
  247. function LoadProducts(position, issubcat) {
  248. console.log("LoadProducts");
  249. var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
  250. if (position=="supplements") currentcat="supplements";
  251. else
  252. {
  253. $('#catimg'+position).animate({opacity: '0.5'}, 1);
  254. $('#catimg'+position).animate({opacity: '1'}, 100);
  255. if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid');
  256. else currentcat=$('#catdiv'+position).data('rowid');
  257. }
  258. if (currentcat == undefined) return;
  259. pageproducts=0;
  260. ishow=0; //product to show counter
  261. jQuery.each(subcategories, function(i, val) {
  262. if (currentcat==val.fk_parent) {
  263. $("#prodivdesc"+ishow).show();
  264. <?php if (getDolGlobalString('TAKEPOS_SHOW_CATEGORY_DESCRIPTION') == 1) { ?>
  265. $("#prodesc"+ishow).html(val.label.bold() + ' - ' + val.description);
  266. $("#probutton"+ishow).html(val.label);
  267. <?php } else { ?>
  268. $("#prodesc"+ishow).text(val.label);
  269. $("#probutton"+ishow).text(val.label);
  270. <?php } ?>
  271. $("#probutton"+ishow).show();
  272. $("#proprice"+ishow).attr("class", "hidden");
  273. $("#proprice"+ishow).html("");
  274. $("#proimg"+ishow).attr("src","genimg/index.php?query=cat&id="+val.rowid);
  275. $("#prodiv"+ishow).data("rowid",val.rowid);
  276. $("#prodiv"+ishow).data("iscat",1);
  277. $("#prowatermark"+ishow).show();
  278. ishow++;
  279. }
  280. });
  281. idata=0; //product data counter
  282. $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat, function(data) {
  283. console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs");
  284. console.log(data);
  285. while (ishow < maxproduct) {
  286. //console.log("ishow"+ishow+" idata="+idata);
  287. console.log(data[idata]);
  288. if (typeof (data[idata]) == "undefined") {
  289. <?php if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
  290. echo '$("#prodivdesc"+ishow).hide();';
  291. echo '$("#prodesc"+ishow).text("");';
  292. echo '$("#proimg"+ishow).attr("title","");';
  293. echo '$("#proimg"+ishow).attr("src","genimg/empty.png");';
  294. } else {
  295. echo '$("#probutton"+ishow).hide();';
  296. echo '$("#probutton"+ishow).text("");';
  297. }?>
  298. $("#proprice"+ishow).attr("class", "hidden");
  299. $("#proprice"+ishow).html("");
  300. $("#prodiv"+ishow).data("rowid","");
  301. $("#prodiv"+ishow).attr("class","wrapper2 divempty");
  302. $("#prowatermark"+ishow).hide();
  303. ishow++; //Next product to show after print data product
  304. }
  305. else if ((data[idata]['status']) == "1") { // Only show products with status=1 (for sell)
  306. <?php
  307. $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[idata]['ref']";
  308. $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']";
  309. ?>
  310. var titlestring = <?php echo $titlestring; ?>;
  311. <?php if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
  312. echo '$("#prodivdesc"+ishow).show();';
  313. if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
  314. echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
  315. } else {
  316. echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
  317. }
  318. echo '$("#proimg"+ishow).attr("title", titlestring);';
  319. echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
  320. } else {
  321. echo '$("#probutton"+ishow).show();';
  322. echo '$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);';
  323. }
  324. ?>
  325. if (data[parseInt(idata)]['price_formated']) {
  326. $("#proprice"+ishow).attr("class", "productprice");
  327. $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']);
  328. }
  329. console.log("#prodiv"+ishow+".data(rowid)="+data[idata]['id']);
  330. console.log($("#prodiv"+ishow));
  331. $("#prodiv"+ishow).data("rowid", data[idata]['id']);
  332. console.log($('#prodiv4').data('rowid'));
  333. $("#prodiv"+ishow).data("iscat", 0);
  334. $("#prodiv"+ishow).attr("class","wrapper2");
  335. $("#prowatermark"+ishow).hide();
  336. ishow++; //Next product to show after print data product
  337. <?php
  338. // Add js from hooks
  339. $parameters=array();
  340. $parameters['caller'] = 'loadProducts';
  341. $hookmanager->executeHooks('completeJSProductDisplay', $parameters);
  342. print $hookmanager->resPrint;
  343. ?>
  344. }
  345. //console.log("Hide the prowatermark for ishow="+ishow);
  346. idata++; //Next data everytime
  347. }
  348. });
  349. ClearSearch();
  350. }
  351. function MoreProducts(moreorless) {
  352. console.log("MoreProducts");
  353. if ($('#search_pagination').val() != '') {
  354. return Search2('<?php echo (isset($keyCodeForEnter) ? $keyCodeForEnter : ''); ?>', moreorless);
  355. }
  356. var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
  357. if (moreorless=="more"){
  358. $('#proimg31').animate({opacity: '0.5'}, 1);
  359. $('#proimg31').animate({opacity: '1'}, 100);
  360. pageproducts=pageproducts+1;
  361. }
  362. if (moreorless=="less"){
  363. $('#proimg30').animate({opacity: '0.5'}, 1);
  364. $('#proimg30').animate({opacity: '1'}, 100);
  365. if (pageproducts==0) return; //Return if no less pages
  366. pageproducts=pageproducts-1;
  367. }
  368. $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat, function(data) {
  369. console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
  370. if (typeof (data[(maxproduct * pageproducts)]) == "undefined" && moreorless=="more"){ // Return if no more pages
  371. pageproducts=pageproducts-1;
  372. return;
  373. }
  374. idata=<?php echo ($MAXPRODUCT - 2); ?> * pageproducts; //product data counter
  375. ishow=0; //product to show counter
  376. while (ishow < maxproduct) {
  377. if (typeof (data[idata]) == "undefined") {
  378. $("#prodivdesc"+ishow).hide();
  379. $("#prodesc"+ishow).text("");
  380. $("#probutton"+ishow).text("");
  381. $("#probutton"+ishow).hide();
  382. $("#proprice"+ishow).attr("class", "");
  383. $("#proprice"+ishow).html("");
  384. $("#proimg"+ishow).attr("src","genimg/empty.png");
  385. $("#prodiv"+ishow).data("rowid","");
  386. ishow++; //Next product to show after print data product
  387. }
  388. else if ((data[idata]['status']) == "1") {
  389. //Only show products with status=1 (for sell)
  390. $("#prodivdesc"+ishow).show();
  391. <?php
  392. if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?>
  393. $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']);
  394. <?php } else { ?>
  395. $("#prodesc"+ishow).html(data[parseInt(idata)]['label']);
  396. <?php } ?>
  397. $("#probutton"+ishow).html(data[parseInt(idata)]['label']);
  398. $("#probutton"+ishow).show();
  399. if (data[parseInt(idata)]['price_formated']) {
  400. $("#proprice"+ishow).attr("class", "productprice");
  401. $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']);
  402. }
  403. $("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']);
  404. $("#prodiv"+ishow).data("rowid",data[idata]['id']);
  405. $("#prodiv"+ishow).data("iscat",0);
  406. ishow++; //Next product to show after print data product
  407. }
  408. $("#prowatermark"+ishow).hide();
  409. idata++; //Next data everytime
  410. }
  411. });
  412. ClearSearch();
  413. }
  414. function ClickProduct(position, qty = 1) {
  415. console.log("ClickProduct at position"+position);
  416. $('#proimg'+position).animate({opacity: '0.5'}, 1);
  417. $('#proimg'+position).animate({opacity: '1'}, 100);
  418. if ($('#prodiv'+position).data('iscat')==1){
  419. console.log("Click on a category at position "+position);
  420. LoadProducts(position, true);
  421. }
  422. else{
  423. console.log($('#prodiv4').data('rowid'));
  424. idproduct=$('#prodiv'+position).data('rowid');
  425. console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty);
  426. if (idproduct=="") return;
  427. // Call page invoice.php to generate the section with product lines
  428. $("#poslines").load("invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline+"&qty="+qty, function() {
  429. <?php if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo "CustomerDisplay();";?>
  430. });
  431. }
  432. ClearSearch();
  433. }
  434. function ChangeThirdparty(idcustomer) {
  435. console.log("ChangeThirdparty");
  436. // Call page list.php to change customer
  437. $("#poslines").load("../societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() {
  438. });
  439. ClearSearch();
  440. }
  441. function deleteline() {
  442. console.log("Delete line");
  443. $("#poslines").load("invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline, function() {
  444. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  445. });
  446. ClearSearch();
  447. }
  448. function Customer() {
  449. console.log("Open box to select the thirdparty place="+place);
  450. $.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"); ?>"});
  451. }
  452. function History()
  453. {
  454. console.log("Open box to select the history");
  455. $.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("History"); ?>"});
  456. }
  457. function Reduction() {
  458. invoiceid = $("#invoiceid").val();
  459. console.log("Open popup to enter reduction on invoiceid="+invoiceid);
  460. $.colorbox({href:"reduction.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
  461. }
  462. function CloseBill() {
  463. invoiceid = $("#invoiceid").val();
  464. console.log("Open popup to enter payment on invoiceid="+invoiceid);
  465. $.colorbox({href:"pay.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
  466. }
  467. function Split() {
  468. invoiceid = $("#invoiceid").val();
  469. console.log("Open popup to split on invoiceid="+invoiceid);
  470. $.colorbox({href:"split.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
  471. }
  472. function Floors() {
  473. console.log("Open box to select floor place="+place);
  474. $.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors"); ?>"});
  475. }
  476. function FreeZone() {
  477. console.log("Open box to enter a free product");
  478. $.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"); ?>"});
  479. }
  480. function TakeposOrderNotes() {
  481. console.log("Open box to order notes");
  482. ModalBox('ModalNote');
  483. $("#textinput").focus();
  484. }
  485. function Refresh() {
  486. console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid);
  487. $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() {
  488. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  489. });
  490. }
  491. function New() {
  492. // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
  493. invoiceid = $("#invoiceid").val();
  494. console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid);
  495. $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid, function(data) {
  496. var r;
  497. if (parseInt(data['paye']) === 1) {
  498. r = true;
  499. } else {
  500. r = confirm('<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
  501. }
  502. if (r == true) {
  503. // Reload section with invoice lines
  504. $("#poslines").load("invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place, function () {
  505. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  506. });
  507. ClearSearch();
  508. }
  509. });
  510. }
  511. /**
  512. * Search products
  513. *
  514. * @param string keyCodeForEnter Key code for "enter" or '' if not
  515. * @param int moreorless ??
  516. * return void
  517. */
  518. function Search2(keyCodeForEnter, moreorless) {
  519. var eventKeyCode = window.event.keyCode;
  520. console.log("Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+", eventKeyCode="+eventKeyCode);
  521. var search_term = $('#search').val();
  522. var search_start = 0;
  523. var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
  524. if (moreorless != null) {
  525. search_term = $('#search_pagination').val();
  526. search_start = $('#search_start_'+moreorless).val();
  527. }
  528. console.log("search_term="+search_term);
  529. if (search_term == '') {
  530. $("[id^=prowatermark]").html("");
  531. $("[id^=prodesc]").text("");
  532. $("[id^=probutton]").text("");
  533. $("[id^=probutton]").hide();
  534. $("[id^=proprice]").attr("class", "hidden");
  535. $("[id^=proprice]").html("");
  536. $("[id^=proimg]").attr("src", "genimg/empty.png");
  537. $("[id^=prodiv]").data("rowid", "");
  538. return;
  539. }
  540. var search = false;
  541. if (keyCodeForEnter == '' || eventKeyCode == keyCodeForEnter) {
  542. search = true;
  543. }
  544. if (search === true) {
  545. // if a timer has been already started (search2_timer is a global js variable), we cancel it now
  546. // we click onto another key, we will restart another timer just after
  547. if (search2_timer) {
  548. clearTimeout(search2_timer);
  549. }
  550. // temporization time to give time to type
  551. search2_timer = setTimeout(function(){
  552. pageproducts = 0;
  553. jQuery(".wrapper2 .catwatermark").hide();
  554. var nbsearchresults = 0;
  555. $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {
  556. for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
  557. if (typeof (data[i]) == "undefined") {
  558. $("#prowatermark" + i).html("");
  559. $("#prodesc" + i).text("");
  560. $("#probutton" + i).text("");
  561. $("#probutton" + i).hide();
  562. $("#proprice" + i).attr("class", "hidden");
  563. $("#proprice" + i).html("");
  564. $("#proimg" + i).attr("src", "genimg/empty.png");
  565. $("#prodiv" + i).data("rowid", "");
  566. continue;
  567. }
  568. <?php
  569. $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[i]['ref']";
  570. $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']";
  571. ?>
  572. var titlestring = <?php echo $titlestring; ?>;
  573. <?php
  574. if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?>
  575. $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']);
  576. <?php } else { ?>
  577. $("#prodesc" + i).html(data[i]['label']);
  578. <?php } ?>
  579. $("#prodivdesc" + i).show();
  580. $("#probutton" + i).html(data[i]['label']);
  581. $("#probutton" + i).show();
  582. if (data[i]['price_formated']) {
  583. $("#proprice" + i).attr("class", "productprice");
  584. $("#proprice" + i).html(data[i]['price_ttc_formated']);
  585. }
  586. $("#proimg" + i).attr("title", titlestring);
  587. if( undefined !== data[i]['img']) {
  588. $("#proimg" + i).attr("src", data[i]['img']);
  589. }
  590. else {
  591. $("#proimg" + i).attr("src", "genimg/index.php?query=pro&id=" + data[i]['rowid']);
  592. }
  593. $("#prodiv" + i).data("rowid", data[i]['rowid']);
  594. $("#prodiv" + i).data("iscat", 0);
  595. <?php
  596. // Add js from hooks
  597. $parameters=array();
  598. $parameters['caller'] = 'search2';
  599. $hookmanager->executeHooks('completeJSProductDisplay', $parameters);
  600. print $hookmanager->resPrint;
  601. ?>
  602. nbsearchresults++;
  603. }
  604. }).always(function (data) {
  605. // If there is only 1 answer
  606. if ($('#search').val().length > 0 && data.length == 1) {
  607. console.log($('#search').val()+' - '+data[0]['barcode']);
  608. if ($('#search').val() == data[0]['barcode'] && 'thirdparty' == data[0]['object']) {
  609. console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']);
  610. ChangeThirdparty(data[0]['rowid']);
  611. }
  612. else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) {
  613. 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']);
  614. ClickProduct(0, data[0]['qty']);
  615. }
  616. }
  617. if (eventKeyCode == keyCodeForEnter){
  618. if (data.length == 0) {
  619. $('#search').val('<?php
  620. $langs->load('errors');
  621. echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
  622. ?> ('+search_term+')');
  623. $('#search').select();
  624. }
  625. else ClearSearch();
  626. }
  627. // memorize search_term and start for pagination
  628. $("#search_pagination").val($("#search").val());
  629. if (search_start == 0) {
  630. $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
  631. }
  632. else {
  633. $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
  634. var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
  635. $("#search_start_less").val(search_start_less);
  636. }
  637. if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
  638. $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
  639. }
  640. else {
  641. $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
  642. var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
  643. $("#search_start_more").val(search_start_more);
  644. }
  645. });
  646. }, 500); // 500ms delay
  647. }
  648. }
  649. /* Function called on an action into the PAD */
  650. function Edit(number) {
  651. console.log("We click on PAD on key="+number);
  652. if (typeof(selectedtext) == "undefined") {
  653. return; // We click on an action on the number pad but there is no line selected
  654. }
  655. var text=selectedtext+"<br> ";
  656. if (number=='c') {
  657. editnumber='';
  658. Refresh();
  659. $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
  660. $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
  661. $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
  662. return;
  663. } else if (number=='qty') {
  664. if (editaction=='qty' && editnumber != '') {
  665. $("#poslines").load("invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
  666. editnumber="";
  667. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  668. $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
  669. });
  670. setFocusOnSearchField();
  671. return;
  672. }
  673. else {
  674. editaction="qty";
  675. }
  676. } else if (number=='p') {
  677. if (editaction=='p' && editnumber!="") {
  678. $("#poslines").load("invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
  679. editnumber="";
  680. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  681. $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
  682. });
  683. ClearSearch();
  684. return;
  685. }
  686. else {
  687. editaction="p";
  688. }
  689. } else if (number=='r') {
  690. if (editaction=='r' && editnumber!="") {
  691. $("#poslines").load("invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
  692. editnumber="";
  693. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  694. $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
  695. });
  696. ClearSearch();
  697. return;
  698. }
  699. else {
  700. editaction="r";
  701. }
  702. }
  703. else {
  704. editnumber=editnumber+number;
  705. }
  706. if (editaction=='qty'){
  707. text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Qty").": "; ?>";
  708. $("#qty").html("OK").addClass("clicked");
  709. $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
  710. $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
  711. }
  712. if (editaction=='p'){
  713. text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Price").": "; ?>";
  714. $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
  715. $("#price").html("OK").addClass("clicked");
  716. $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
  717. }
  718. if (editaction=='r'){
  719. text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("ReductionShort").": "; ?>";
  720. $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
  721. $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
  722. $("#reduction").html("OK").addClass("clicked");
  723. }
  724. $('#'+selectedline).find("td:first").html(text+editnumber);
  725. }
  726. function TakeposPrintingOrder(){
  727. console.log("TakeposPrintingOrder");
  728. $("#poslines").load("invoice.php?action=order&token=<?php echo newToken();?>&place="+place, function() {
  729. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  730. });
  731. }
  732. function TakeposPrintingTemp(){
  733. console.log("TakeposPrintingTemp");
  734. $("#poslines").load("invoice.php?action=temp&token=<?php echo newToken();?>&place="+place, function() {
  735. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  736. });
  737. }
  738. function OpenDrawer(){
  739. console.log("OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
  740. $.ajax({
  741. type: "POST",
  742. data: { token: 'notrequired' },
  743. <?php
  744. if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
  745. echo "url: '".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost')."/printer/drawer.php',";
  746. } else {
  747. echo "url: 'http://".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost').":8111/print',";
  748. }
  749. ?>
  750. data: "opendrawer"
  751. });
  752. }
  753. function DolibarrOpenDrawer() {
  754. console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal"]); ?>");
  755. $.ajax({
  756. type: "GET",
  757. data: { token: '<?php echo currentToken(); ?>' },
  758. url: "<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode($_SESSION["takeposterminal"]); ?>",
  759. });
  760. }
  761. function MoreActions(totalactions){
  762. if (pageactions==0){
  763. pageactions=1;
  764. for (i = 0; i <= totalactions; i++){
  765. if (i<12) $("#action"+i).hide();
  766. else $("#action"+i).show();
  767. }
  768. }
  769. else if (pageactions==1){
  770. pageactions=0;
  771. for (i = 0; i <= totalactions; i++){
  772. if (i<12) $("#action"+i).show();
  773. else $("#action"+i).hide();
  774. }
  775. }
  776. }
  777. function ControlCashOpening()
  778. {
  779. $.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"); ?>"});
  780. }
  781. function CloseCashFence(rowid)
  782. {
  783. $.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"); ?>"});
  784. }
  785. function CashReport(rowid)
  786. {
  787. $.colorbox({href:"../compta/cashcontrol/report.php?id="+rowid+"&contextpage=takepos", width:"60%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("CashReport"); ?>"});
  788. }
  789. // TakePOS Popup
  790. function ModalBox(ModalID)
  791. {
  792. var modal = document.getElementById(ModalID);
  793. modal.style.display = "block";
  794. }
  795. function DirectPayment(){
  796. console.log("DirectPayment");
  797. $("#poslines").load("invoice.php?place="+place+"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ", function() {
  798. });
  799. }
  800. function FullScreen() {
  801. document.documentElement.requestFullscreen();
  802. }
  803. function WeighingScale(){
  804. console.log("Weighing Scale");
  805. $.ajax({
  806. type: "POST",
  807. data: { token: 'notrequired' },
  808. url: '<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>/scale/index.php',
  809. })
  810. .done(function( editnumber ) {
  811. $("#poslines").load("invoice.php?&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
  812. editnumber="";
  813. });
  814. });
  815. }
  816. $( document ).ready(function() {
  817. PrintCategories(0);
  818. LoadProducts(0);
  819. Refresh();
  820. <?php
  821. //IF NO TERMINAL SELECTED
  822. if ($_SESSION["takeposterminal"] == "") {
  823. print "ModalBox('ModalTerminal');";
  824. }
  825. if (getDolGlobalString('TAKEPOS_CONTROL_CASH_OPENING')) {
  826. $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
  827. $sql .= " entity = ".((int) $conf->entity)." AND ";
  828. $sql .= " posnumber = ".((int) $_SESSION["takeposterminal"])." AND ";
  829. $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
  830. $resql = $db->query($sql);
  831. if ($resql) {
  832. $obj = $db->fetch_object($resql);
  833. // If there is no cash control from today open it
  834. if ($obj->rowid == null) {
  835. print "ControlCashOpening();";
  836. }
  837. }
  838. }
  839. ?>
  840. /* For Header Scroll */
  841. var elem1 = $("#topnav-left")[0];
  842. var elem2 = $("#topnav-right")[0];
  843. var checkOverflow = function() {
  844. if (scrollBars().horizontal) $("#topnav").addClass("overflow");
  845. else $("#topnav").removeClass("overflow");
  846. }
  847. var scrollBars = function(){
  848. var container= $('#topnav')[0];
  849. return {
  850. vertical:container.scrollHeight > container.clientHeight,
  851. horizontal:container.scrollWidth > container.clientWidth
  852. };
  853. }
  854. $(window).resize(function(){
  855. checkOverflow();
  856. });
  857. let resizeObserver = new ResizeObserver(() => {
  858. checkOverflow();
  859. });
  860. resizeObserver.observe(elem1);
  861. resizeObserver.observe(elem2);
  862. checkOverflow();
  863. var pressTimer = [];
  864. var direction = 1;
  865. var step = 200;
  866. $(".indicator").mousedown(function(){
  867. direction = $(this).hasClass("left") ? -1 : 1;
  868. scrollTo();
  869. pressTimer.push(setInterval(scrollTo, 100));
  870. });
  871. $(".indicator").mouseup(function(){
  872. pressTimer.forEach(clearInterval);
  873. });
  874. $("body").mouseup(function(){
  875. pressTimer.forEach(clearInterval);
  876. console.log("body");
  877. });
  878. function scrollTo(){
  879. console.log("here");
  880. var pos = $("#topnav").scrollLeft();
  881. document.getElementById("topnav").scrollTo({ left: $("#topnav").scrollLeft() + direction * step, behavior: 'smooth' })
  882. }
  883. $("#topnav").scroll(function(){
  884. if (($("#topnav").offsetWidth + $("#topnav").scrollLeft >= $("#topnav").scrollWidth)) {
  885. console.log("end");
  886. }
  887. });
  888. /* End Header Scroll */
  889. });
  890. </script>
  891. <?php
  892. $keyCodeForEnter = getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) > 0 ? getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) : '';
  893. ?>
  894. <div class="container">
  895. <?php
  896. if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  897. ?>
  898. <div class="header">
  899. <div id="topnav" class="topnav">
  900. <div id="topnav-left" class="topnav-left">
  901. <div class="inline-block valignmiddle">
  902. <a class="topnav-terminalhour" onclick="ModalBox('ModalTerminal');">
  903. <span class="fa fa-cash-register"></span>
  904. <span class="hideonsmartphone">
  905. <?php echo getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$_SESSION["takeposterminal"], $langs->trans("TerminalName", $_SESSION["takeposterminal"])); ?>
  906. </span>
  907. <?php
  908. echo '<span class="hideonsmartphone"> - '.dol_print_date(dol_now(), "day").'</span>';
  909. ?>
  910. </a>
  911. <?php
  912. if (isModEnabled('multicurrency')) {
  913. print '<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\');" title=""><span class="fas fa-coins paddingrightonly"></span>';
  914. print '<span class="hideonsmartphone">'.$langs->trans("Currency").'</span>';
  915. print '</a>';
  916. }
  917. ?>
  918. </div>
  919. <!-- section for customer -->
  920. <div class="inline-block valignmiddle" id="customerandsales"></div>
  921. <!-- section for shopping carts -->
  922. <div class="inline-block valignmiddle" id="shoppingcart"></div>
  923. <!-- More info about customer -->
  924. <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="moreinfo"></div>
  925. <?php
  926. if (isModEnabled('stock')) {
  927. ?>
  928. <!-- More info about warehouse -->
  929. <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="infowarehouse"></div>
  930. <?php
  931. }
  932. ?>
  933. </div>
  934. <div id="topnav-right" class="topnav-right">
  935. <div class="login_block_other">
  936. <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>
  937. <a onclick="ClearSearch();"><span class="fa fa-backspace"></span></a>
  938. <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 -->
  939. <span class="fas fa-home"></span></a>
  940. <?php if (empty($conf->dol_use_jmobile)) { ?>
  941. <a class="hideonsmartphone" onclick="FullScreen();"><span class="fa fa-expand-arrows-alt"></span></a>
  942. <?php } ?>
  943. </div>
  944. <div class="login_block_user">
  945. <?php
  946. print top_menu_user(1);
  947. ?>
  948. </div>
  949. </div>
  950. <div class="arrows">
  951. <span class="indicator left"><i class="fa fa-arrow-left"></i></span>
  952. <span class="indicator right"><i class="fa fa-arrow-right"></i></span>
  953. </div>
  954. </div>
  955. </div>
  956. <?php
  957. }
  958. ?>
  959. <!-- Modal terminal box -->
  960. <div id="ModalTerminal" class="modal">
  961. <div class="modal-content">
  962. <div class="modal-header">
  963. <span class="close" href="#" onclick="document.getElementById('ModalTerminal').style.display = 'none';">&times;</span>
  964. <h3><?php print $langs->trans("TerminalSelect"); ?></h3>
  965. </div>
  966. <div class="modal-body">
  967. <button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print getDolGlobalString("TAKEPOS_TERMINAL_NAME_1", $langs->trans("TerminalName", 1)); ?></button>
  968. <?php
  969. $nbloop = getDolGlobalInt('TAKEPOS_NUM_TERMINALS');
  970. for ($i = 2; $i <= $nbloop; $i++) {
  971. print '<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$i, $langs->trans("TerminalName", $i)).'</button>';
  972. }
  973. ?>
  974. </div>
  975. </div>
  976. </div>
  977. <!-- Modal multicurrency box -->
  978. <?php if (isModEnabled('multicurrency')) { ?>
  979. <div id="ModalCurrency" class="modal">
  980. <div class="modal-content">
  981. <div class="modal-header">
  982. <span class="close" href="#" onclick="document.getElementById('ModalCurrency').style.display = 'none';">&times;</span>
  983. <h3><?php print $langs->trans("SetMultiCurrencyCode"); ?></h3>
  984. </div>
  985. <div class="modal-body">
  986. <?php
  987. $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
  988. $sql .= " WHERE entity IN ('".getEntity('multicurrency')."')";
  989. $resql = $db->query($sql);
  990. if ($resql) {
  991. while ($obj = $db->fetch_object($resql)) {
  992. print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>';
  993. }
  994. }
  995. ?>
  996. </div>
  997. </div>
  998. </div>
  999. <?php } ?>
  1000. <!-- Modal terminal Credit Note -->
  1001. <div id="ModalCreditNote" class="modal">
  1002. <div class="modal-content">
  1003. <div class="modal-header">
  1004. <span class="close" href="#" onclick="document.getElementById('ModalCreditNote').style.display = 'none';">&times;</span>
  1005. <h3><?php print $langs->trans("invoiceAvoirWithLines"); ?></h3>
  1006. </div>
  1007. <div class="modal-body">
  1008. <button type="button" class="block" onclick="CreditNote(); document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("Yes"); ?></button>
  1009. <button type="button" class="block" onclick="document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("No"); ?></button>
  1010. </div>
  1011. </div>
  1012. </div>
  1013. <!-- Modal Note -->
  1014. <div id="ModalNote" class="modal">
  1015. <div class="modal-content">
  1016. <div class="modal-header">
  1017. <span class="close" href="#" onclick="document.getElementById('ModalNote').style.display = 'none';">&times;</span>
  1018. <h3><?php print $langs->trans("Note"); ?></h3>
  1019. </div>
  1020. <div class="modal-body">
  1021. <input type="text" class="block" id="textinput">
  1022. <button type="button" class="block" onclick="SetNote(); document.getElementById('ModalNote').style.display = 'none';">OK</button>
  1023. </div>
  1024. </div>
  1025. </div>
  1026. <div class="row1<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1027. print 'withhead';
  1028. } ?>">
  1029. <div id="poslines" class="div1">
  1030. </div>
  1031. <div class="div2">
  1032. <button type="button" class="calcbutton" onclick="Edit(7);">7</button>
  1033. <button type="button" class="calcbutton" onclick="Edit(8);">8</button>
  1034. <button type="button" class="calcbutton" onclick="Edit(9);">9</button>
  1035. <button type="button" id="qty" class="calcbutton2" onclick="Edit('qty');"><?php echo $langs->trans("Qty"); ?></button>
  1036. <button type="button" class="calcbutton" onclick="Edit(4);">4</button>
  1037. <button type="button" class="calcbutton" onclick="Edit(5);">5</button>
  1038. <button type="button" class="calcbutton" onclick="Edit(6);">6</button>
  1039. <button type="button" id="price" class="calcbutton2" onclick="Edit('p');"><?php echo $langs->trans("Price"); ?></button>
  1040. <button type="button" class="calcbutton" onclick="Edit(1);">1</button>
  1041. <button type="button" class="calcbutton" onclick="Edit(2);">2</button>
  1042. <button type="button" class="calcbutton" onclick="Edit(3);">3</button>
  1043. <button type="button" id="reduction" class="calcbutton2" onclick="Edit('r');"><?php echo $langs->trans("ReductionShort"); ?></button>
  1044. <button type="button" class="calcbutton" onclick="Edit(0);">0</button>
  1045. <button type="button" class="calcbutton" onclick="Edit('.');">.</button>
  1046. <button type="button" class="calcbutton poscolorblue" onclick="Edit('c');">C</button>
  1047. <button type="button" class="calcbutton2 poscolordelete" id="delete" onclick="deleteline();"><span class="fa fa-trash"></span></button>
  1048. </div>
  1049. <?php
  1050. // TakePOS setup check
  1051. if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) {
  1052. $sql = "SELECT code, libelle FROM " . MAIN_DB_PREFIX . "c_paiement";
  1053. $sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")";
  1054. $sql .= " AND active = 1";
  1055. $sql .= " ORDER BY libelle";
  1056. $resql = $db->query($sql);
  1057. $paiementsModes = array();
  1058. if ($resql) {
  1059. while ( $obj = $db->fetch_object($resql) ) {
  1060. $paycode = $obj->code;
  1061. if ($paycode == 'LIQ') {
  1062. $paycode = 'CASH';
  1063. }
  1064. if ($paycode == 'CHQ') {
  1065. $paycode = 'CHEQUE';
  1066. }
  1067. $constantforkey = "CASHDESK_ID_BANKACCOUNT_" . $paycode . $_SESSION["takeposterminal"];
  1068. //var_dump($constantforkey.' '.$conf->global->$constantforkey);
  1069. if ( !empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) {
  1070. array_push($paiementsModes, $obj);
  1071. }
  1072. }
  1073. }
  1074. if (empty($paiementsModes) && isModEnabled("banque")) {
  1075. $langs->load('errors');
  1076. setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors');
  1077. setEventMessages($langs->trans("ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"]), null, 'errors');
  1078. }
  1079. }
  1080. if (count($maincategories) == 0) {
  1081. if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
  1082. $tmpcategory = new Categorie($db);
  1083. $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
  1084. setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory", $tmpcategory->label), null, 'errors');
  1085. } else {
  1086. setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors');
  1087. }
  1088. }
  1089. // User menu and external TakePOS modules
  1090. $menus = array();
  1091. $r = 0;
  1092. if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) {
  1093. $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("New").'</div>', 'action'=>'New();');
  1094. } else {
  1095. // BAR RESTAURANT specific menu
  1096. $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("Place").'</div>', 'action'=>'Floors();');
  1097. }
  1098. if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1099. $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Customer").'</div>', 'action'=>'Customer();');
  1100. }
  1101. $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly"></span><div class="trunc">'.$langs->trans("History").'</div>', 'action'=>'History();');
  1102. $menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly"></span><div class="trunc">'.$langs->trans("FreeZone").'</div>', 'action'=>'FreeZone();');
  1103. $menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly"></span><div class="trunc">'.$langs->trans("Reduction").'</div>', 'action'=>'Reduction();');
  1104. $menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("Payment").'</div>', 'action'=>'CloseBill();');
  1105. if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
  1106. $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();');
  1107. }
  1108. $menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly"></span><div class="trunc">'.$langs->trans("SplitSale").'</div>', 'action'=>'Split();');
  1109. // BAR RESTAURANT specific menu
  1110. if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
  1111. if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
  1112. $menus[$r++] = array('title'=>'<span class="fa fa-blender-phone paddingrightonly"></span><div class="trunc">'.$langs->trans("Order").'</span>', 'action'=>'TakeposPrintingOrder();');
  1113. }
  1114. //Button to print receipt before payment
  1115. if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
  1116. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
  1117. if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
  1118. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposConnector(placeid);');
  1119. } else {
  1120. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposPrinting(placeid);');
  1121. }
  1122. } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
  1123. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
  1124. } else {
  1125. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'Print(placeid);');
  1126. }
  1127. }
  1128. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
  1129. $menus[$r++] = array('title'=>'<span class="fa fa-sticky-note paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action'=>'TakeposOrderNotes();');
  1130. }
  1131. if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
  1132. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action'=>'LoadProducts(\'supplements\');');
  1133. }
  1134. }
  1135. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
  1136. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>', 'action'=>'OpenDrawer();');
  1137. }
  1138. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
  1139. $menus[$r++] = array(
  1140. 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>',
  1141. 'action' => 'DolibarrOpenDrawer();',
  1142. );
  1143. }
  1144. $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
  1145. $sql .= " entity = ".((int) $conf->entity)." AND ";
  1146. $sql .= " posnumber = ".((int) $_SESSION["takeposterminal"])." AND ";
  1147. $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
  1148. $resql = $db->query($sql);
  1149. if ($resql) {
  1150. $num = $db->num_rows($resql);
  1151. if ($num) {
  1152. $obj = $db->fetch_object($resql);
  1153. $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly"></span><div class="trunc">'.$langs->trans("CashReport").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
  1154. if ($obj->status == 0) {
  1155. $menus[$r++] = array('title'=>'<span class="fas fa-cash-register paddingrightonly"></span><div class="trunc">'.$langs->trans("CloseCashFence").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');');
  1156. }
  1157. }
  1158. }
  1159. $hookmanager->initHooks(array('takeposfrontend'));
  1160. $parameters = array('menus'=>$menus);
  1161. $reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
  1162. if ($reshook == 0) { //add buttons
  1163. if (is_array($hookmanager->resArray) ) {
  1164. foreach ($hookmanager->resArray as $resArray) {
  1165. foreach ($resArray as $butmenu) {
  1166. $menus[$r++] = $butmenu;
  1167. }
  1168. }
  1169. } elseif ($reshook == 1) {
  1170. $r = 0; //replace buttons
  1171. if (is_array($hookmanager->resArray) ) {
  1172. foreach ($hookmanager->resArray as $resArray) {
  1173. foreach ($resArray as $butmenu) {
  1174. $menus[$r++] = $butmenu;
  1175. }
  1176. }
  1177. }
  1178. }
  1179. }
  1180. if ($r % 3 == 2) {
  1181. $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
  1182. }
  1183. if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1184. $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().'\';');
  1185. }
  1186. if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
  1187. $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly"></span><div class="trunc">'.$langs->trans("WeighingScale").'</div>', 'action'=>'WeighingScale();');
  1188. }
  1189. ?>
  1190. <!-- Show buttons -->
  1191. <div class="div3">
  1192. <?php
  1193. $i = 0;
  1194. foreach ($menus as $menu) {
  1195. $i++;
  1196. if (count($menus) > 12 and $i == 12) {
  1197. echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="actionnext" class="actionbutton" onclick="MoreActions('.count($menus).');">'.$langs->trans("Next").'</button>';
  1198. echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
  1199. } elseif ($i > 12) {
  1200. echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
  1201. } else {
  1202. echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
  1203. }
  1204. }
  1205. if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1206. print '<!-- Show the search input text -->'."\n";
  1207. print '<div class="margintoponly">';
  1208. 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> ';
  1209. print '<a class="marginleftonly hideonsmartphone" onclick="ClearSearch();">'.img_picto('', 'searchclear').'</a>';
  1210. print '</div>';
  1211. }
  1212. ?>
  1213. </div>
  1214. </div>
  1215. <div class="row2<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1216. print 'withhead';
  1217. } ?>">
  1218. <!-- Show categories -->
  1219. <?php
  1220. if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
  1221. print '<div class="div4" style= "display: none;">';
  1222. } else {
  1223. print '<div class="div4">';
  1224. }
  1225. $count = 0;
  1226. while ($count < $MAXCATEG) {
  1227. ?>
  1228. <div class="wrapper" <?php if ($count == ($MAXCATEG - 2)) {
  1229. echo 'onclick="MoreCategories(\'less\');"';
  1230. } elseif ($count == ($MAXCATEG - 1)) {
  1231. echo 'onclick="MoreCategories(\'more\');"';
  1232. } else {
  1233. echo 'onclick="LoadProducts('.$count.');"';
  1234. } ?> id="catdiv<?php echo $count; ?>">
  1235. <?php
  1236. if ($count == ($MAXCATEG - 2)) {
  1237. //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="catimg'.$count.'" />';
  1238. echo '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
  1239. } elseif ($count == ($MAXCATEG - 1)) {
  1240. //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="catimg'.$count.'" />';
  1241. echo '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
  1242. } else {
  1243. if (!getDolGlobalString('TAKEPOS_HIDE_CATEGORY_IMAGES')) {
  1244. echo '<img class="imgwrapper" height="100%" id="catimg'.$count.'" />';
  1245. }
  1246. }
  1247. ?>
  1248. <?php if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?>
  1249. <div class="description" id="catdivdesc<?php echo $count; ?>">
  1250. <div class="description_content" id="catdesc<?php echo $count; ?>"></div>
  1251. </div>
  1252. <?php } ?>
  1253. <div class="catwatermark" id='catwatermark<?php echo $count; ?>'>...</div>
  1254. </div>
  1255. <?php
  1256. $count++;
  1257. }
  1258. ?>
  1259. </div>
  1260. <!-- Show product -->
  1261. <div class="div5"<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
  1262. print ' style="width:100%;"';
  1263. } ?>>
  1264. <?php
  1265. $count = 0;
  1266. while ($count < $MAXPRODUCT) {
  1267. print '<div class="wrapper2 arrow" id="prodiv'.$count.'" ';
  1268. ?>
  1269. <?php if ($count == ($MAXPRODUCT - 2)) {
  1270. ?> onclick="MoreProducts('less');" <?php
  1271. } if ($count == ($MAXPRODUCT - 1)) {
  1272. ?> onclick="MoreProducts('more');" <?php
  1273. } else {
  1274. echo 'onclick="ClickProduct('.$count.');"';
  1275. } ?>>
  1276. <?php
  1277. if ($count == ($MAXPRODUCT - 2)) {
  1278. //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';
  1279. print '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
  1280. } elseif ($count == ($MAXPRODUCT - 1)) {
  1281. //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="proimg'.$count.'" />';
  1282. print '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
  1283. } else {
  1284. if (getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
  1285. echo '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>';
  1286. } else {
  1287. print '<div class="" id="proprice'.$count.'"></div>';
  1288. print '<img class="imgwrapper" height="100%" title="" id="proimg'.$count.'">';
  1289. }
  1290. }
  1291. ?>
  1292. <?php if ($count != ($MAXPRODUCT - 2) && $count != ($MAXPRODUCT - 1) && !getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
  1293. <div class="description" id="prodivdesc<?php echo $count; ?>">
  1294. <div class="description_content" id="prodesc<?php echo $count; ?>"></div>
  1295. </div>
  1296. <?php } ?>
  1297. <div class="catwatermark" id='prowatermark<?php echo $count; ?>'>...</div>
  1298. </div>
  1299. <?php
  1300. $count++;
  1301. }
  1302. ?>
  1303. <input type="hidden" id="search_start_less" value="0">
  1304. <input type="hidden" id="search_start_more" value="0">
  1305. <input type="hidden" id="search_pagination" value="">
  1306. </div>
  1307. </div>
  1308. </div>
  1309. </body>
  1310. <?php
  1311. llxFooter();
  1312. $db->close();