index.php 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490
  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 - '.$conf->global->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("ReductionShort"); ?>").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 History()
  463. {
  464. console.log("Open box to select the history");
  465. $.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("History"); ?>"});
  466. }
  467. function Reduction() {
  468. invoiceid = $("#invoiceid").val();
  469. console.log("Open popup to enter reduction on invoiceid="+invoiceid);
  470. $.colorbox({href:"reduction.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
  471. }
  472. function CloseBill() {
  473. invoiceid = $("#invoiceid").val();
  474. console.log("Open popup to enter payment on invoiceid="+invoiceid);
  475. $.colorbox({href:"pay.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
  476. }
  477. function Split() {
  478. invoiceid = $("#invoiceid").val();
  479. console.log("Open popup to split on invoiceid="+invoiceid);
  480. $.colorbox({href:"split.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
  481. }
  482. function Floors() {
  483. console.log("Open box to select floor place="+place);
  484. $.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors"); ?>"});
  485. }
  486. function FreeZone() {
  487. console.log("Open box to enter a free product");
  488. $.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"); ?>"});
  489. }
  490. function TakeposOrderNotes() {
  491. console.log("Open box to order notes");
  492. ModalBox('ModalNote');
  493. $("#textinput").focus();
  494. }
  495. function Refresh() {
  496. console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid);
  497. $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() {
  498. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  499. });
  500. }
  501. function New() {
  502. // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
  503. invoiceid = $("#invoiceid").val(); // This is a hidden field added by invoice.php
  504. console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid);
  505. $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid, function(data) {
  506. var r;
  507. if (parseInt(data['paye']) === 1) {
  508. r = true;
  509. } else {
  510. r = confirm('<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>');
  511. }
  512. if (r == true) {
  513. // Reload section with invoice lines
  514. $("#poslines").load("invoice.php?action=delete&token=<?php echo newToken(); ?>&place=" + place, function () {
  515. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  516. });
  517. ClearSearch();
  518. }
  519. });
  520. }
  521. /**
  522. * Search products
  523. *
  524. * @param keyCodeForEnter Key code for "enter" or '' if not
  525. * @param moreorless "more" or "less"
  526. * return void
  527. */
  528. function Search2(keyCodeForEnter, moreorless) {
  529. var eventKeyCode = window.event.keyCode;
  530. console.log("Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter+", eventKeyCode="+eventKeyCode);
  531. var search_term = $('#search').val();
  532. var search_start = 0;
  533. var search_limit = <?php echo $MAXPRODUCT - 2; ?>;
  534. if (moreorless != null) {
  535. search_term = $('#search_pagination').val();
  536. search_start = $('#search_start_'+moreorless).val();
  537. }
  538. console.log("search_term="+search_term);
  539. if (search_term == '') {
  540. $("[id^=prowatermark]").html("");
  541. $("[id^=prodesc]").text("");
  542. $("[id^=probutton]").text("");
  543. $("[id^=probutton]").hide();
  544. $("[id^=proprice]").attr("class", "hidden");
  545. $("[id^=proprice]").html("");
  546. $("[id^=proimg]").attr("src", "genimg/empty.png");
  547. $("[id^=prodiv]").data("rowid", "");
  548. return;
  549. }
  550. var search = false;
  551. if (keyCodeForEnter == '' || eventKeyCode == keyCodeForEnter) {
  552. search = true;
  553. }
  554. if (search === true) {
  555. // if a timer has been already started (search2_timer is a global js variable), we cancel it now
  556. // we click onto another key, we will restart another timer just after
  557. if (search2_timer) {
  558. clearTimeout(search2_timer);
  559. }
  560. // temporization time to give time to type
  561. search2_timer = setTimeout(function(){
  562. pageproducts = 0;
  563. jQuery(".wrapper2 .catwatermark").hide();
  564. var nbsearchresults = 0;
  565. $.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) {
  566. for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
  567. if (typeof (data[i]) == "undefined") {
  568. $("#prowatermark" + i).html("");
  569. $("#prodesc" + i).text("");
  570. $("#probutton" + i).text("");
  571. $("#probutton" + i).hide();
  572. $("#proprice" + i).attr("class", "hidden");
  573. $("#proprice" + i).html("");
  574. $("#proimg" + i).attr("src", "genimg/empty.png");
  575. $("#prodiv" + i).data("rowid", "");
  576. continue;
  577. }
  578. <?php
  579. $titlestring = "'".dol_escape_js($langs->transnoentities('Ref').': ')."' + data[i]['ref']";
  580. $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']";
  581. ?>
  582. var titlestring = <?php echo $titlestring; ?>;
  583. <?php if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?>
  584. $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']);
  585. <?php } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { ?>
  586. $("#prodesc" + i).html(data[i]['ref'].bold());
  587. <?php } else { ?>
  588. $("#prodesc" + i).html(data[i]['label']);
  589. <?php } ?>
  590. $("#prodivdesc" + i).show();
  591. $("#probutton" + i).html(data[i]['label']);
  592. $("#probutton" + i).show();
  593. if (data[i]['price_formated']) {
  594. $("#proprice" + i).attr("class", "productprice");
  595. $("#proprice" + i).html(data[i]['price_ttc_formated']);
  596. }
  597. $("#proimg" + i).attr("title", titlestring);
  598. if( undefined !== data[i]['img']) {
  599. $("#proimg" + i).attr("src", data[i]['img']);
  600. }
  601. else {
  602. $("#proimg" + i).attr("src", "genimg/index.php?query=pro&id=" + data[i]['rowid']);
  603. }
  604. $("#prodiv" + i).data("rowid", data[i]['rowid']);
  605. $("#prodiv" + i).data("iscat", 0);
  606. <?php
  607. // Add js from hooks
  608. $parameters=array();
  609. $parameters['caller'] = 'search2';
  610. $hookmanager->executeHooks('completeJSProductDisplay', $parameters);
  611. print $hookmanager->resPrint;
  612. ?>
  613. nbsearchresults++;
  614. }
  615. }).always(function (data) {
  616. // If there is only 1 answer
  617. if ($('#search').val().length > 0 && data.length == 1) {
  618. console.log($('#search').val()+' - '+data[0]['barcode']);
  619. if ($('#search').val() == data[0]['barcode'] && 'thirdparty' == data[0]['object']) {
  620. console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']);
  621. ChangeThirdparty(data[0]['rowid']);
  622. }
  623. else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) {
  624. 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']);
  625. ClickProduct(0, data[0]['qty']);
  626. }
  627. }
  628. if (eventKeyCode == keyCodeForEnter){
  629. if (data.length == 0) {
  630. $('#search').val('<?php
  631. $langs->load('errors');
  632. echo dol_escape_js($langs->transnoentitiesnoconv("ErrorRecordNotFoundShort"));
  633. ?> ('+search_term+')');
  634. $('#search').select();
  635. }
  636. else ClearSearch();
  637. }
  638. // memorize search_term and start for pagination
  639. $("#search_pagination").val($("#search").val());
  640. if (search_start == 0) {
  641. $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").hide();
  642. }
  643. else {
  644. $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
  645. var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
  646. $("#search_start_less").val(search_start_less);
  647. }
  648. if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
  649. $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").hide();
  650. }
  651. else {
  652. $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
  653. var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
  654. $("#search_start_more").val(search_start_more);
  655. }
  656. });
  657. }, 500); // 500ms delay
  658. }
  659. }
  660. /* Function called on an action into the PAD */
  661. function Edit(number) {
  662. console.log("We click on PAD on key="+number);
  663. if (typeof(selectedtext) == "undefined") {
  664. return; // We click on an action on the number pad but there is no line selected
  665. }
  666. var text=selectedtext+"<br> ";
  667. if (number=='c') {
  668. editnumber='';
  669. Refresh();
  670. $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
  671. $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
  672. $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
  673. return;
  674. } else if (number=='qty') {
  675. if (editaction=='qty' && editnumber != '') {
  676. $("#poslines").load("invoice.php?action=updateqty&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
  677. editnumber="";
  678. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  679. $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
  680. });
  681. setFocusOnSearchField();
  682. return;
  683. }
  684. else {
  685. editaction="qty";
  686. }
  687. } else if (number=='p') {
  688. if (editaction=='p' && editnumber!="") {
  689. $("#poslines").load("invoice.php?action=updateprice&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
  690. editnumber="";
  691. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  692. $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
  693. });
  694. ClearSearch();
  695. return;
  696. }
  697. else {
  698. editaction="p";
  699. }
  700. } else if (number=='r') {
  701. if (editaction=='r' && editnumber!="") {
  702. $("#poslines").load("invoice.php?action=updatereduction&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
  703. editnumber="";
  704. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  705. $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
  706. });
  707. ClearSearch();
  708. return;
  709. }
  710. else {
  711. editaction="r";
  712. }
  713. }
  714. else {
  715. editnumber=editnumber+number;
  716. }
  717. if (editaction=='qty'){
  718. text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Qty").": "; ?>";
  719. $("#qty").html("OK").addClass("clicked");
  720. $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
  721. $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
  722. }
  723. if (editaction=='p'){
  724. text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Price").": "; ?>";
  725. $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
  726. $("#price").html("OK").addClass("clicked");
  727. $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>").removeClass('clicked');
  728. }
  729. if (editaction=='r'){
  730. text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("ReductionShort").": "; ?>";
  731. $("#qty").html("<?php echo $langs->trans("Qty"); ?>").removeClass('clicked');
  732. $("#price").html("<?php echo $langs->trans("Price"); ?>").removeClass('clicked');
  733. $("#reduction").html("OK").addClass("clicked");
  734. }
  735. $('#'+selectedline).find("td:first").html(text+editnumber);
  736. }
  737. function TakeposPrintingOrder(){
  738. console.log("TakeposPrintingOrder");
  739. $("#poslines").load("invoice.php?action=order&token=<?php echo newToken();?>&place="+place, function() {
  740. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  741. });
  742. }
  743. function TakeposPrintingTemp(){
  744. console.log("TakeposPrintingTemp");
  745. $("#poslines").load("invoice.php?action=temp&token=<?php echo newToken();?>&place="+place, function() {
  746. //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
  747. });
  748. }
  749. function OpenDrawer(){
  750. console.log("OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print");
  751. $.ajax({
  752. type: "POST",
  753. data: { token: 'notrequired' },
  754. <?php
  755. if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
  756. echo "url: '".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost')."/printer/drawer.php',";
  757. } else {
  758. echo "url: 'http://".getDolGlobalString('TAKEPOS_PRINT_SERVER', 'localhost').":8111/print',";
  759. }
  760. ?>
  761. data: "opendrawer"
  762. });
  763. }
  764. function DolibarrOpenDrawer() {
  765. console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal"]); ?>");
  766. $.ajax({
  767. type: "GET",
  768. data: { token: '<?php echo currentToken(); ?>' },
  769. url: "<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&token='.newToken().'&term='.urlencode($_SESSION["takeposterminal"]); ?>",
  770. });
  771. }
  772. function MoreActions(totalactions){
  773. if (pageactions==0){
  774. pageactions=1;
  775. for (i = 0; i <= totalactions; i++){
  776. if (i<12) $("#action"+i).hide();
  777. else $("#action"+i).show();
  778. }
  779. }
  780. else if (pageactions==1){
  781. pageactions=0;
  782. for (i = 0; i <= totalactions; i++){
  783. if (i<12) $("#action"+i).show();
  784. else $("#action"+i).hide();
  785. }
  786. }
  787. return true;
  788. }
  789. function ControlCashOpening()
  790. {
  791. $.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"); ?>"});
  792. }
  793. function CloseCashFence(rowid)
  794. {
  795. $.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"); ?>"});
  796. }
  797. function CashReport(rowid)
  798. {
  799. $.colorbox({href:"../compta/cashcontrol/report.php?id="+rowid+"&contextpage=takepos", width:"60%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("CashReport"); ?>"});
  800. }
  801. // TakePOS Popup
  802. function ModalBox(ModalID)
  803. {
  804. var modal = document.getElementById(ModalID);
  805. modal.style.display = "block";
  806. }
  807. function DirectPayment(){
  808. console.log("DirectPayment");
  809. $("#poslines").load("invoice.php?place="+place+"&action=valid&token=<?php echo newToken(); ?>&pay=LIQ", function() {
  810. });
  811. }
  812. function FullScreen() {
  813. document.documentElement.requestFullscreen();
  814. }
  815. function WeighingScale(){
  816. console.log("Weighing Scale");
  817. $.ajax({
  818. type: "POST",
  819. data: { token: 'notrequired' },
  820. url: '<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>/scale/index.php',
  821. })
  822. .done(function( editnumber ) {
  823. $("#poslines").load("invoice.php?&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
  824. editnumber="";
  825. });
  826. });
  827. }
  828. $( document ).ready(function() {
  829. PrintCategories(0);
  830. LoadProducts(0);
  831. Refresh();
  832. <?php
  833. //IF NO TERMINAL SELECTED
  834. if ($_SESSION["takeposterminal"] == "") {
  835. print "ModalBox('ModalTerminal');";
  836. }
  837. if (getDolGlobalString('TAKEPOS_CONTROL_CASH_OPENING')) {
  838. $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
  839. $sql .= " entity = ".((int) $conf->entity)." AND ";
  840. $sql .= " posnumber = ".((int) $_SESSION["takeposterminal"])." AND ";
  841. $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
  842. $resql = $db->query($sql);
  843. if ($resql) {
  844. $obj = $db->fetch_object($resql);
  845. // If there is no cash control from today open it
  846. if (!isset($obj->rowid) || is_null($obj->rowid)) {
  847. print "ControlCashOpening();";
  848. }
  849. }
  850. }
  851. ?>
  852. /* For Header Scroll */
  853. var elem1 = $("#topnav-left")[0];
  854. var elem2 = $("#topnav-right")[0];
  855. var checkOverflow = function() {
  856. if (scrollBars().horizontal) $("#topnav").addClass("overflow");
  857. else $("#topnav").removeClass("overflow");
  858. }
  859. var scrollBars = function(){
  860. var container= $('#topnav')[0];
  861. return {
  862. vertical:container.scrollHeight > container.clientHeight,
  863. horizontal:container.scrollWidth > container.clientWidth
  864. }
  865. }
  866. $(window).resize(function(){
  867. checkOverflow();
  868. });
  869. let resizeObserver = new ResizeObserver(() => {
  870. checkOverflow();
  871. });
  872. resizeObserver.observe(elem1);
  873. resizeObserver.observe(elem2);
  874. checkOverflow();
  875. var pressTimer = [];
  876. var direction = 1;
  877. var step = 200;
  878. $(".indicator").mousedown(function(){
  879. direction = $(this).hasClass("left") ? -1 : 1;
  880. scrollTo();
  881. pressTimer.push(setInterval(scrollTo, 100));
  882. });
  883. $(".indicator").mouseup(function(){
  884. pressTimer.forEach(clearInterval);
  885. });
  886. $("body").mouseup(function(){
  887. pressTimer.forEach(clearInterval);
  888. console.log("body");
  889. });
  890. function scrollTo(){
  891. console.log("here");
  892. var pos = $("#topnav").scrollLeft();
  893. document.getElementById("topnav").scrollTo({ left: $("#topnav").scrollLeft() + direction * step, behavior: 'smooth' })
  894. }
  895. $("#topnav").scroll(function(){
  896. if (($("#topnav").offsetWidth + $("#topnav").scrollLeft >= $("#topnav").scrollWidth)) {
  897. console.log("end");
  898. }
  899. });
  900. /* End Header Scroll */
  901. });
  902. </script>
  903. <?php
  904. $keyCodeForEnter = getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) > 0 ? getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) : '';
  905. ?>
  906. <div class="container">
  907. <?php
  908. if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  909. ?>
  910. <div class="header">
  911. <div id="topnav" class="topnav">
  912. <div id="topnav-left" class="topnav-left">
  913. <div class="inline-block valignmiddle">
  914. <a class="topnav-terminalhour" onclick="ModalBox('ModalTerminal')">
  915. <span class="fa fa-cash-register"></span>
  916. <span class="hideonsmartphone">
  917. <?php echo getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$_SESSION["takeposterminal"], $langs->trans("TerminalName", $_SESSION["takeposterminal"])); ?>
  918. </span>
  919. <?php
  920. echo '<span class="hideonsmartphone"> - '.dol_print_date(dol_now(), "day").'</span>';
  921. ?>
  922. </a>
  923. <?php
  924. if (isModEnabled('multicurrency')) {
  925. print '<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\')" title=""><span class="fas fa-coins paddingrightonly"></span>';
  926. print '<span class="hideonsmartphone">'.$langs->trans("Currency").'</span>';
  927. print '</a>';
  928. }
  929. ?>
  930. </div>
  931. <!-- section for customer -->
  932. <div class="inline-block valignmiddle" id="customerandsales"></div>
  933. <!-- section for shopping carts -->
  934. <div class="inline-block valignmiddle" id="shoppingcart"></div>
  935. <!-- More info about customer -->
  936. <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="moreinfo"></div>
  937. <?php
  938. if (isModEnabled('stock')) {
  939. ?>
  940. <!-- More info about warehouse -->
  941. <div class="inline-block valignmiddle tdoverflowmax150onsmartphone" id="infowarehouse"></div>
  942. <?php
  943. }
  944. ?>
  945. </div>
  946. <div id="topnav-right" class="topnav-right">
  947. <?php
  948. $reshook = $hookmanager->executeHooks('takepos_login_block_other');
  949. if ($reshook == 0) { //Search method ?>
  950. <div class="login_block_other">
  951. <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>
  952. <a onclick="ClearSearch();"><span class="fa fa-backspace"></span></a>
  953. <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 -->
  954. <span class="fas fa-home"></span></a>
  955. <?php if (empty($conf->dol_use_jmobile)) {?>
  956. <a class="hideonsmartphone" onclick="FullScreen();" title="<?php echo dol_escape_htmltag($langs->trans("ClickFullScreenEscapeToLeave")); ?>"><span class="fa fa-expand-arrows-alt"></span></a>
  957. <?php }?>
  958. </div>
  959. <?php
  960. }?>
  961. <div class="login_block_user">
  962. <?php
  963. print top_menu_user(1);
  964. ?>
  965. </div>
  966. </div>
  967. <div class="arrows">
  968. <span class="indicator left"><i class="fa fa-arrow-left"></i></span>
  969. <span class="indicator right"><i class="fa fa-arrow-right"></i></span>
  970. </div>
  971. </div>
  972. </div>
  973. <?php
  974. }
  975. ?>
  976. <!-- Modal terminal box -->
  977. <div id="ModalTerminal" class="modal">
  978. <div class="modal-content">
  979. <div class="modal-header">
  980. <?php
  981. if (empty($conf->global->TAKEPOS_FORCE_TERMINAL_SELECT)) {
  982. ?>
  983. <span class="close" href="#" onclick="document.getElementById('ModalTerminal').style.display = 'none';">&times;</span>
  984. <?php } ?>
  985. <h3><?php print $langs->trans("TerminalSelect"); ?></h3>
  986. </div>
  987. <div class="modal-body">
  988. <button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print getDolGlobalString("TAKEPOS_TERMINAL_NAME_1", $langs->trans("TerminalName", 1)); ?></button>
  989. <?php
  990. $nbloop = getDolGlobalInt('TAKEPOS_NUM_TERMINALS');
  991. for ($i = 2; $i <= $nbloop; $i++) {
  992. print '<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.'\'">'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$i, $langs->trans("TerminalName", $i)).'</button>';
  993. }
  994. ?>
  995. </div>
  996. </div>
  997. </div>
  998. <!-- Modal multicurrency box -->
  999. <?php if (isModEnabled('multicurrency')) { ?>
  1000. <div id="ModalCurrency" class="modal">
  1001. <div class="modal-content">
  1002. <div class="modal-header">
  1003. <span class="close" href="#" onclick="document.getElementById('ModalCurrency').style.display = 'none';">&times;</span>
  1004. <h3><?php print $langs->trans("SetMultiCurrencyCode"); ?></h3>
  1005. </div>
  1006. <div class="modal-body">
  1007. <?php
  1008. $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
  1009. $sql .= " WHERE entity IN ('".getEntity('multicurrency')."')";
  1010. $resql = $db->query($sql);
  1011. if ($resql) {
  1012. while ($obj = $db->fetch_object($resql)) {
  1013. print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>';
  1014. }
  1015. }
  1016. ?>
  1017. </div>
  1018. </div>
  1019. </div>
  1020. <?php } ?>
  1021. <!-- Modal terminal Credit Note -->
  1022. <div id="ModalCreditNote" class="modal">
  1023. <div class="modal-content">
  1024. <div class="modal-header">
  1025. <span class="close" href="#" onclick="document.getElementById('ModalCreditNote').style.display = 'none';">&times;</span>
  1026. <h3><?php print $langs->trans("invoiceAvoirWithLines"); ?></h3>
  1027. </div>
  1028. <div class="modal-body">
  1029. <button type="button" class="block" onclick="CreditNote(); document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("Yes"); ?></button>
  1030. <button type="button" class="block" onclick="document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("No"); ?></button>
  1031. </div>
  1032. </div>
  1033. </div>
  1034. <!-- Modal Note -->
  1035. <div id="ModalNote" class="modal">
  1036. <div class="modal-content">
  1037. <div class="modal-header">
  1038. <span class="close" href="#" onclick="document.getElementById('ModalNote').style.display = 'none';">&times;</span>
  1039. <h3><?php print $langs->trans("Note"); ?></h3>
  1040. </div>
  1041. <div class="modal-body">
  1042. <input type="text" class="block" id="textinput">
  1043. <button type="button" class="block" onclick="SetNote(); document.getElementById('ModalNote').style.display = 'none';">OK</button>
  1044. </div>
  1045. </div>
  1046. </div>
  1047. <div class="row1<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1048. print 'withhead';
  1049. } ?>">
  1050. <div id="poslines" class="div1">
  1051. </div>
  1052. <div class="div2">
  1053. <button type="button" class="calcbutton" onclick="Edit(7);">7</button>
  1054. <button type="button" class="calcbutton" onclick="Edit(8);">8</button>
  1055. <button type="button" class="calcbutton" onclick="Edit(9);">9</button>
  1056. <button type="button" id="qty" class="calcbutton2" onclick="Edit('qty')"><?php echo $langs->trans("Qty"); ?></button>
  1057. <button type="button" class="calcbutton" onclick="Edit(4);">4</button>
  1058. <button type="button" class="calcbutton" onclick="Edit(5);">5</button>
  1059. <button type="button" class="calcbutton" onclick="Edit(6);">6</button>
  1060. <button type="button" id="price" class="calcbutton2" onclick="Edit('p')"><?php echo $langs->trans("Price"); ?></button>
  1061. <button type="button" class="calcbutton" onclick="Edit(1);">1</button>
  1062. <button type="button" class="calcbutton" onclick="Edit(2);">2</button>
  1063. <button type="button" class="calcbutton" onclick="Edit(3);">3</button>
  1064. <button type="button" id="reduction" class="calcbutton2" onclick="Edit('r')"><?php echo $langs->trans("ReductionShort"); ?></button>
  1065. <button type="button" class="calcbutton" onclick="Edit(0);">0</button>
  1066. <button type="button" class="calcbutton" onclick="Edit('.')">.</button>
  1067. <button type="button" class="calcbutton poscolorblue" onclick="Edit('c')">C</button>
  1068. <button type="button" class="calcbutton2 poscolordelete" id="delete" onclick="deleteline()"><span class="fa fa-trash"></span></button>
  1069. </div>
  1070. <?php
  1071. // TakePOS setup check
  1072. if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) {
  1073. $sql = "SELECT code, libelle FROM " . MAIN_DB_PREFIX . "c_paiement";
  1074. $sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")";
  1075. $sql .= " AND active = 1";
  1076. $sql .= " ORDER BY libelle";
  1077. $resql = $db->query($sql);
  1078. $paiementsModes = array();
  1079. if ($resql) {
  1080. while ( $obj = $db->fetch_object($resql) ) {
  1081. $paycode = $obj->code;
  1082. if ($paycode == 'LIQ') {
  1083. $paycode = 'CASH';
  1084. }
  1085. if ($paycode == 'CHQ') {
  1086. $paycode = 'CHEQUE';
  1087. }
  1088. $constantforkey = "CASHDESK_ID_BANKACCOUNT_" . $paycode . $_SESSION["takeposterminal"];
  1089. //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey));
  1090. if ( !empty($conf->global->$constantforkey) && getDolGlobalInt($constantforkey) > 0) {
  1091. array_push($paiementsModes, $obj);
  1092. }
  1093. }
  1094. }
  1095. if (empty($paiementsModes) && isModEnabled("banque")) {
  1096. $langs->load('errors');
  1097. setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors');
  1098. setEventMessages($langs->trans("ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"]), null, 'errors');
  1099. }
  1100. }
  1101. if (count($maincategories) == 0) {
  1102. if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
  1103. $tmpcategory = new Categorie($db);
  1104. $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
  1105. setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory", $tmpcategory->label), null, 'errors');
  1106. } else {
  1107. setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors');
  1108. }
  1109. }
  1110. // User menu and external TakePOS modules
  1111. $menus = array();
  1112. $r = 0;
  1113. if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) {
  1114. $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("New").'</div>', 'action'=>'New();');
  1115. } else {
  1116. // BAR RESTAURANT specific menu
  1117. $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("Place").'</div>', 'action'=>'Floors();');
  1118. }
  1119. if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1120. $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Customer").'</div>', 'action'=>'Customer();');
  1121. }
  1122. if ( ! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
  1123. $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly"></span><div class="trunc">'.$langs->trans("History").'</div>', 'action'=>'History();');
  1124. }
  1125. $menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly"></span><div class="trunc">'.$langs->trans("FreeZone").'</div>', 'action'=>'FreeZone();');
  1126. $menus[$r++] = array('title'=>'<span class="fa fa-percent paddingrightonly"></span><div class="trunc">'.$langs->trans("Reduction").'</div>', 'action'=>'Reduction();');
  1127. $menus[$r++] = array('title'=>'<span class="far fa-money-bill-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("Payment").'</div>', 'action'=>'CloseBill();');
  1128. if (getDolGlobalString('TAKEPOS_DIRECT_PAYMENT')) {
  1129. $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();');
  1130. }
  1131. $menus[$r++] = array('title'=>'<span class="fas fa-cut paddingrightonly"></span><div class="trunc">'.$langs->trans("SplitSale").'</div>', 'action'=>'Split();');
  1132. // BAR RESTAURANT specific menu
  1133. if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
  1134. if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
  1135. $menus[$r++] = array('title'=>'<span class="fa fa-blender-phone paddingrightonly"></span><div class="trunc">'.$langs->trans("Order").'</span>', 'action'=>'TakeposPrintingOrder();');
  1136. }
  1137. //Button to print receipt before payment
  1138. if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
  1139. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
  1140. if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
  1141. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposConnector(placeid);');
  1142. } else {
  1143. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposPrinting(placeid);');
  1144. }
  1145. } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
  1146. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
  1147. } else {
  1148. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'Print(placeid);');
  1149. }
  1150. }
  1151. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && getDolGlobalString('TAKEPOS_ORDER_NOTES') == 1) {
  1152. $menus[$r++] = array('title'=>'<span class="fa fa-sticky-note paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action'=>'TakeposOrderNotes();');
  1153. }
  1154. if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
  1155. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action'=>'LoadProducts(\'supplements\');');
  1156. }
  1157. }
  1158. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
  1159. $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>', 'action'=>'OpenDrawer();');
  1160. }
  1161. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
  1162. $menus[$r++] = array(
  1163. 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>',
  1164. 'action' => 'DolibarrOpenDrawer();',
  1165. );
  1166. }
  1167. $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
  1168. $sql .= " entity = ".((int) $conf->entity)." AND ";
  1169. $sql .= " posnumber = ".((int) $_SESSION["takeposterminal"])." AND ";
  1170. $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
  1171. $resql = $db->query($sql);
  1172. if ($resql) {
  1173. $num = $db->num_rows($resql);
  1174. if ($num) {
  1175. $obj = $db->fetch_object($resql);
  1176. $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly"></span><div class="trunc">'.$langs->trans("CashReport").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
  1177. if ($obj->status == 0) {
  1178. $menus[$r++] = array('title'=>'<span class="fas fa-cash-register paddingrightonly"></span><div class="trunc">'.$langs->trans("CloseCashFence").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');');
  1179. }
  1180. }
  1181. }
  1182. $parameters = array('menus'=>$menus);
  1183. $reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
  1184. if ($reshook == 0) { //add buttons
  1185. if (is_array($hookmanager->resArray) ) {
  1186. foreach ($hookmanager->resArray as $resArray) {
  1187. foreach ($resArray as $butmenu) {
  1188. $menus[$r++] = $butmenu;
  1189. }
  1190. }
  1191. } elseif ($reshook == 1) {
  1192. $r = 0; //replace 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. }
  1200. }
  1201. }
  1202. if ($r % 3 == 2) {
  1203. $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
  1204. }
  1205. if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1206. $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().'\';');
  1207. }
  1208. if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
  1209. $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly"></span><div class="trunc">'.$langs->trans("WeighingScale").'</div>', 'action'=>'WeighingScale();');
  1210. }
  1211. ?>
  1212. <!-- Show buttons -->
  1213. <div class="div3">
  1214. <?php
  1215. $i = 0;
  1216. foreach ($menus as $menu) {
  1217. $i++;
  1218. if (count($menus) > 12 and $i == 12) {
  1219. echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="actionnext" class="actionbutton" onclick="MoreActions('.count($menus).')">'.$langs->trans("Next").'</button>';
  1220. echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
  1221. } elseif ($i > 12) {
  1222. echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
  1223. } else {
  1224. echo '<button style="'.(empty($menu['style']) ? '' : $menu['style']).'" type="button" id="action'.$i.'" class="actionbutton" onclick="'.(empty($menu['action']) ? '' : $menu['action']).'">'.$menu['title'].'</button>';
  1225. }
  1226. }
  1227. if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1228. print '<!-- Show the search input text -->'."\n";
  1229. print '<div class="margintoponly">';
  1230. 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> ';
  1231. print '<a class="marginleftonly hideonsmartphone" onclick="ClearSearch();">'.img_picto('', 'searchclear').'</a>';
  1232. print '</div>';
  1233. }
  1234. ?>
  1235. </div>
  1236. </div>
  1237. <div class="row2<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
  1238. print 'withhead';
  1239. } ?>">
  1240. <!-- Show categories -->
  1241. <?php
  1242. if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
  1243. print '<div class="div4" style= "display: none;">';
  1244. } else {
  1245. print '<div class="div4">';
  1246. }
  1247. $count = 0;
  1248. while ($count < $MAXCATEG) {
  1249. ?>
  1250. <div class="wrapper" <?php if ($count == ($MAXCATEG - 2)) {
  1251. echo 'onclick="MoreCategories(\'less\')"';
  1252. } elseif ($count == ($MAXCATEG - 1)) {
  1253. echo 'onclick="MoreCategories(\'more\')"';
  1254. } else {
  1255. echo 'onclick="LoadProducts('.$count.')"';
  1256. } ?> id="catdiv<?php echo $count; ?>">
  1257. <?php
  1258. if ($count == ($MAXCATEG - 2)) {
  1259. //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="catimg'.$count.'" />';
  1260. echo '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
  1261. } elseif ($count == ($MAXCATEG - 1)) {
  1262. //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="catimg'.$count.'" />';
  1263. echo '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
  1264. } else {
  1265. if (!getDolGlobalString('TAKEPOS_HIDE_CATEGORY_IMAGES')) {
  1266. echo '<img class="imgwrapper" id="catimg'.$count.'" />';
  1267. }
  1268. }
  1269. ?>
  1270. <?php if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?>
  1271. <div class="description" id="catdivdesc<?php echo $count; ?>">
  1272. <div class="description_content" id="catdesc<?php echo $count; ?>"></div>
  1273. </div>
  1274. <?php } ?>
  1275. <div class="catwatermark" id='catwatermark<?php echo $count; ?>'>...</div>
  1276. </div>
  1277. <?php
  1278. $count++;
  1279. }
  1280. ?>
  1281. </div>
  1282. <!-- Show product -->
  1283. <div class="div5"<?php if (getDolGlobalInt('TAKEPOS_HIDE_CATEGORIES') == 1) {
  1284. print ' style="width:100%;"';
  1285. } ?>>
  1286. <?php
  1287. $count = 0;
  1288. while ($count < $MAXPRODUCT) {
  1289. print '<div class="wrapper2 arrow" id="prodiv'.$count.'" ';
  1290. ?>
  1291. <?php if ($count == ($MAXPRODUCT - 2)) {
  1292. ?> onclick="MoreProducts('less')" <?php
  1293. } if ($count == ($MAXPRODUCT - 1)) {
  1294. ?> onclick="MoreProducts('more')" <?php
  1295. } else {
  1296. echo 'onclick="ClickProduct('.$count.')"';
  1297. } ?>>
  1298. <?php
  1299. if ($count == ($MAXPRODUCT - 2)) {
  1300. //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';
  1301. print '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
  1302. } elseif ($count == ($MAXPRODUCT - 1)) {
  1303. //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="proimg'.$count.'" />';
  1304. print '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>';
  1305. } else {
  1306. if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_PRICES')) {
  1307. print '<div class="" id="proprice'.$count.'"></div>';
  1308. }
  1309. if (getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
  1310. print '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>';
  1311. } else {
  1312. print '<img class="imgwrapper" title="" id="proimg'.$count.'">';
  1313. }
  1314. }
  1315. ?>
  1316. <?php if ($count != ($MAXPRODUCT - 2) && $count != ($MAXPRODUCT - 1) && !getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) { ?>
  1317. <div class="description" id="prodivdesc<?php echo $count; ?>">
  1318. <div class="description_content" id="prodesc<?php echo $count; ?>"></div>
  1319. </div>
  1320. <?php } ?>
  1321. <div class="catwatermark" id='prowatermark<?php echo $count; ?>'>...</div>
  1322. </div>
  1323. <?php
  1324. $count++;
  1325. }
  1326. ?>
  1327. <input type="hidden" id="search_start_less" value="0">
  1328. <input type="hidden" id="search_start_more" value="0">
  1329. <input type="hidden" id="search_pagination" value="">
  1330. </div>
  1331. </div>
  1332. </div>
  1333. </body>
  1334. <?php
  1335. llxFooter();
  1336. $db->close();