index.php 57 KB

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