index.php 58 KB

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