functions.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. <?php
  2. /*
  3. * Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. function FilterValue($Data) { // Filtrado basico
  19. $Data = trim($Data);
  20. $Data = stripslashes($Data);
  21. $Data = htmlspecialchars($Data);
  22. return $Data;
  23. }
  24. function ValidateRegex($Regex, $Data) {
  25. if (preg_match($Regex, $Data)) {
  26. return true;
  27. } else {
  28. return false;
  29. }
  30. }
  31. function GeneratePossibleValues($Data, $Content, $FieldName) {
  32. $PossibleValues = [];
  33. foreach ($Data as $Key => $Value) {
  34. if ($Value[$FieldName] === $Content) {
  35. array_push($PossibleValues, $Value);
  36. }
  37. }
  38. return $PossibleValues;
  39. }
  40. function CheckIdListsMatching($List1, $List2) {
  41. $FoundMatching = false;
  42. $Position1 = 0;
  43. while ($Position1 < count($List1) && !$FoundMatching) {
  44. $Position2 = 0;
  45. while ($Position2 < count($List2) && !$FoundMatching) {
  46. if (isset($List1[$Position1]['id'])) {
  47. if (isset($List2[$Position2]['id'])) {
  48. if ($List1[$Position1]['id'] === $List2[$Position2]['id']) {
  49. $FoundMatching = true;
  50. }
  51. } else {
  52. if ($List1[$Position1]['id'] === $List2[$Position2]) {
  53. $FoundMatching = true;
  54. }
  55. }
  56. } else {
  57. if (isset($List2[$Position2]['id'])) {
  58. if ($List1[$Position1] === $List2[$Position2]['id']) {
  59. $FoundMatching = true;
  60. }
  61. } else {
  62. if ($List1[$Position1] === $List2[$Position2]) {
  63. $FoundMatching = true;
  64. }
  65. }
  66. }
  67. $Position2++;
  68. }
  69. $Position1++;
  70. }
  71. return $FoundMatching;
  72. }
  73. function CheckListValue($Data, $Content, $FieldName) {
  74. $Exists = false;
  75. $Position = 0;
  76. while ($Position < count($Data) && !$Exists) {
  77. if ($Data[$Position][$FieldName] === $Content) {
  78. $Exists = true;
  79. }
  80. $Position++;
  81. }
  82. return $Exists;
  83. }
  84. function GenerateFieldValues($Data, $FieldName) {
  85. $FieldValues = [];
  86. foreach ($Data as $Key => $Value) {
  87. array_push($FieldValues, $Value[$FieldName]);
  88. }
  89. return $FieldValues;
  90. }
  91. function DumpCanaryData($File, $DependentValues, $FieldName, $NoId = false, $NewId = '') {
  92. $Data = json_decode(file_get_contents($File), true);
  93. $CanaryData = [];
  94. $FieldValues = GenerateFieldValues($DependentValues, $FieldName);
  95. foreach ($Data as $Key => $Value) {
  96. if (in_array($Value[$FieldName], $FieldValues, true)) {
  97. if ($NoId === true && $NewId !== '') {
  98. $Value[$NewId] = "$Key";
  99. array_push($CanaryData, $Value);
  100. } else {
  101. array_push($CanaryData, $Value);
  102. }
  103. }
  104. }
  105. return $CanaryData;
  106. }
  107. function GetProduct($Products, $Id) {
  108. $Product = [];
  109. $Position = 0;
  110. while ($Position < count($Products) && empty($Product)) {
  111. if ($Products[$Position]['id'] === $Id) {
  112. $Product = $Products[$Position];
  113. }
  114. $Position++;
  115. }
  116. return $Product;
  117. }
  118. function DefineCookie($Name, $Value) {
  119. setcookie($Name, $Value, time() + 365 * 24 * 60 * 60, '.');
  120. }
  121. function AddProductCookie($Products, $Id, &$List, $CookieName, $Delete = false) {
  122. if (CheckListValue($Products, $Id, 'id')) {
  123. if (!in_array($Id, $List)) {
  124. array_push($List, $Id);
  125. } else if (in_array($Id, $List) && $Delete) {
  126. $Key = array_search($Id, $List);
  127. unset($List[$Key]);
  128. }
  129. sort($List);
  130. DefineCookie($CookieName, serialize($List));
  131. }
  132. }
  133. function AddProductCart($Products, $Id, &$Cart, $Delete = false) {
  134. if (CheckListValue($Products, $Id, 'id')) {
  135. if (in_array($Id, array_keys($Cart))) {
  136. if ($Delete) {
  137. unset($Cart[$Id]);
  138. } else {
  139. $Cart[$Id] += 1;
  140. }
  141. } else {
  142. $Cart[$Id] = 1;
  143. }
  144. }
  145. ksort($Cart);
  146. $_SESSION['cart'] = serialize($Cart);
  147. }
  148. function CountCart($Cart) {
  149. $QuantityCart = 0;
  150. foreach ($Cart as $Id => $QuantityPerId) {
  151. $QuantityCart += $QuantityPerId;
  152. }
  153. return $QuantityCart;
  154. }
  155. function CalculateCosts($Products, $Cart) {
  156. $Costs = [0, 0, 0];
  157. foreach ($Cart as $ProductId => $ProductQuantity) {
  158. if (CheckListValue($Products, $ProductId, 'id')) {
  159. $Costs[0] += round(floatval(GetProduct($Products, $ProductId)['price']) * $ProductQuantity, 2);
  160. }
  161. }
  162. if ($Costs[0] >= 500) {
  163. $Costs[1] = 0;
  164. } else {
  165. $Costs[1] = round($Costs[0] * (10 / 100), 2);
  166. }
  167. $Costs[2] = round($Costs[0] + $Costs[1], 2);
  168. return $Costs;
  169. }
  170. function CheckRepliesEmpty($Replies) {
  171. $IsSomethingEmpty = false;
  172. foreach ($Replies as $Key => $Value) {
  173. if (!in_array($Key, ['information', 'complement'])) {
  174. if ($Value === '') {
  175. $IsSomethingEmpty = true;
  176. }
  177. }
  178. }
  179. return $IsSomethingEmpty;
  180. }
  181. function ShowTopButtons($Show, $UserButton, $Cart, $CartShowed) {
  182. $HTML = '';
  183. if ($Show) {
  184. $HTML .= '<div class="col-lg-3 col-md-8 col-sm-10 col-12 mx-auto p-4">' . PHP_EOL;
  185. $HTML .= '<div class="container">' . PHP_EOL;
  186. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  187. $HTML .= '<div class="col-12 px-0 text-center">' . PHP_EOL;
  188. $HTML .= '<a class="h-100 btn btn-block btn-' . $UserButton[0] . ' t-large" href="' . $UserButton[1] . '"><i class="fas ' . $UserButton[2] . '"></i> ' . $UserButton[3] . '</a>' . PHP_EOL;
  189. $HTML .= '</div>' . PHP_EOL;
  190. $HTML .= '</div>' . PHP_EOL;
  191. $HTML .= '<div class="row">' . PHP_EOL;
  192. $HTML .= '<div class="col-12 px-0 text-center">' . PHP_EOL;
  193. if ($CartShowed) {
  194. $HTML .= '<a class="h-100 btn btn-block btn-secondary t-large" href=".">Return</a>' . PHP_EOL;
  195. } else {
  196. $HTML .= '<a class="h-100 btn btn-block btn-info t-large" href=".?cart=all"><i class="fas fa-shopping-cart"></i> Cart (<span id="quantitycart">' . CountCart($Cart) . '</span>)</a>' . PHP_EOL;
  197. }
  198. $HTML .= '</div>' . PHP_EOL;
  199. $HTML .= '</div>' . PHP_EOL;
  200. $HTML .= '</div>' . PHP_EOL;
  201. $HTML .= '</div>' . PHP_EOL;
  202. } else {
  203. $HTML .= '<div class="col"></div>' . PHP_EOL;
  204. }
  205. return $HTML;
  206. }
  207. function ShowPolicy() {
  208. $HTML = '';
  209. $HTML .= '<form method="POST" action="." class="col-lg-4 col-md-6 col-sm-10 col-12 mx-auto">' . PHP_EOL;
  210. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  211. $HTML .= '<div class="row my-3">' . PHP_EOL;
  212. $HTML .= '<div class="col-12 px-0 text-center">' . PHP_EOL;
  213. $HTML .= '<span class="t-large">Cookies agreement</span>' . PHP_EOL;
  214. $HTML .= '</div>' . PHP_EOL;
  215. $HTML .= '</div>' . PHP_EOL;
  216. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  217. $HTML .= '<div class="col-12">' . PHP_EOL;
  218. $HTML .= '<div class="container-fluid border border-secondary rounded">' . PHP_EOL;
  219. $HTML .= '<div class="row my-3">' . PHP_EOL;
  220. $HTML .= '<p class="col-12 mb-0">' . PHP_EOL;
  221. $HTML .= 'This website uses cookies to guarantee you basic functionality '
  222. . 'such as favourites, etc.' . PHP_EOL;
  223. $HTML .= '</p>' . PHP_EOL;
  224. $HTML .= '</div>' . PHP_EOL;
  225. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  226. $HTML .= '<p class="col-12 mb-0">' . PHP_EOL;
  227. $HTML .= 'You must accept them in order to continue browsing this website.'
  228. . PHP_EOL;
  229. $HTML .= '</p>' . PHP_EOL;
  230. $HTML .= '</div>' . PHP_EOL;
  231. $HTML .= '</div>' . PHP_EOL;
  232. $HTML .= '</div>' . PHP_EOL;
  233. $HTML .= '</div>' . PHP_EOL;
  234. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  235. $HTML .= '<div class="col-md-6 col-12">' . PHP_EOL;
  236. $HTML .= '<button type="submit" class="btn btn-success btn-lg btn-block" name="operation" value="accept">Accept</button>' . PHP_EOL;
  237. $HTML .= '</div>' . PHP_EOL;
  238. $HTML .= '<div class="col-md-6 col-12">' . PHP_EOL;
  239. $HTML .= '<button type="submit" class="btn btn-danger btn-lg btn-block" name="operation" value="cancel">Cancel</button>' . PHP_EOL;
  240. $HTML .= '</div>' . PHP_EOL;
  241. $HTML .= '</div>' . PHP_EOL;
  242. $HTML .= '</div>' . PHP_EOL;
  243. $HTML .= '</form>' . PHP_EOL;
  244. return $HTML;
  245. }
  246. function ShowWarning() {
  247. $HTML = '';
  248. $HTML .= '<div class="col-lg-4 col-md-6 col-sm-10 col-12 mx-auto">' . PHP_EOL;
  249. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  250. $HTML .= '<div class="row my-3">' . PHP_EOL;
  251. $HTML .= '<div class="col-12 text-center">' . PHP_EOL;
  252. $HTML .= '<span class="t-large">Cookies warning</span>' . PHP_EOL;
  253. $HTML .= '</div>' . PHP_EOL;
  254. $HTML .= '</div>' . PHP_EOL;
  255. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  256. $HTML .= '<div class="col-12">' . PHP_EOL;
  257. $HTML .= '<div class="container-fluid border border-secondary rounded">' . PHP_EOL;
  258. $HTML .= '<div class="row my-3">' . PHP_EOL;
  259. $HTML .= '<p class="col-12 mb-0">' . PHP_EOL;
  260. $HTML .= 'You cannot continue to browse in the website without accepting '
  261. . 'the "Cookies agreement".' . PHP_EOL;
  262. $HTML .= '</p>' . PHP_EOL;
  263. $HTML .= '</div>' . PHP_EOL;
  264. $HTML .= '</div>' . PHP_EOL;
  265. $HTML .= '</div>' . PHP_EOL;
  266. $HTML .= '</div>' . PHP_EOL;
  267. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  268. $HTML .= '<div class="col-12">' . PHP_EOL;
  269. $HTML .= '<a class="btn btn-secondary btn-lg btn-block" href=".">Return</a>' . PHP_EOL;
  270. $HTML .= '</div>' . PHP_EOL;
  271. $HTML .= '</div>' . PHP_EOL;
  272. $HTML .= '</div>' . PHP_EOL;
  273. $HTML .= '</div>' . PHP_EOL;
  274. return $HTML;
  275. }
  276. function ShowLogin($Location, $LoginErrors) {
  277. $HTML = '';
  278. $HTML .= '<form method="POST" action="' . $Location . '" class="col-lg-4 col-md-6 col-sm-10 col-12 mx-auto">' . PHP_EOL;
  279. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  280. $HTML .= '<div class="row my-3">' . PHP_EOL;
  281. $HTML .= '<div class="col-12 text-center">' . PHP_EOL;
  282. $HTML .= '<span class="t-large">Login</span>' . PHP_EOL;
  283. $HTML .= '</div>' . PHP_EOL;
  284. $HTML .= '</div>' . PHP_EOL;
  285. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  286. $HTML .= '<div class="col-12">' . PHP_EOL;
  287. $HTML .= '<div class="container-fluid border border-secondary rounded">' . PHP_EOL;
  288. $HTML .= '<div class="row my-3">' . PHP_EOL;
  289. $HTML .= '<div class="form-group col-12 mb-0">' . PHP_EOL;
  290. $HTML .= '<label for="username">Username</label>' . PHP_EOL;
  291. $HTML .= '<input type="text" class="form-control" name="username" id="username" required="" />' . PHP_EOL;
  292. $HTML .= '</div>' . PHP_EOL;
  293. $HTML .= '</div>' . PHP_EOL;
  294. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  295. $HTML .= '<div class="form-group col-12 mb-0">' . PHP_EOL;
  296. $HTML .= '<label for="password">Password</label>' . PHP_EOL;
  297. $HTML .= '<input type="password" class="form-control" name="password" id="password" required="" />' . PHP_EOL;
  298. $HTML .= '</div>' . PHP_EOL;
  299. $HTML .= '</div>' . PHP_EOL;
  300. $HTML .= '</div>' . PHP_EOL;
  301. $HTML .= '</div>' . PHP_EOL;
  302. $HTML .= '</div>' . PHP_EOL;
  303. if (count($LoginErrors) > 0) {
  304. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  305. $HTML .= '<div class="col-12">' . PHP_EOL;
  306. $HTML .= '<ul class="mb-0 p-3 pl-4 rounded bg-danger text-white">' . PHP_EOL;
  307. foreach ($LoginErrors as $Value) {
  308. $HTML .= '<li>' . $Value . '</li>' . PHP_EOL;
  309. }
  310. $HTML .= '</ul>' . PHP_EOL;
  311. $HTML .= '</div>' . PHP_EOL;
  312. $HTML .= '</div>' . PHP_EOL;
  313. }
  314. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  315. $HTML .= '<div class="col-12">' . PHP_EOL;
  316. $HTML .= '<button type="submit" class="btn btn-success btn-lg btn-block" name="validatelogin">Continue</button>' . PHP_EOL;
  317. $HTML .= '</div>' . PHP_EOL;
  318. $HTML .= '</div>' . PHP_EOL;
  319. $HTML .= '</div>' . PHP_EOL;
  320. $HTML .= '</form>' . PHP_EOL;
  321. return $HTML;
  322. }
  323. function PrintProductCard($Product, $Favourite, $InView, $InCart = false, $Quantity = -1) {
  324. $HTML = '';
  325. $HTML .= '<div class="col mb-3 mx-auto">' . PHP_EOL;
  326. $HTML .= '<div class="card">' . PHP_EOL;
  327. $HTML .= '<img src="' . $Product['image'] . '" class="card-img-top" alt="' . $Product['name'] . '"/>' . PHP_EOL;
  328. $HTML .= '<div class="card-body">' . PHP_EOL;
  329. $HTML .= '<div class="card-title">' . PHP_EOL;
  330. $HTML .= '<div class="container-fluid">' . PHP_EOL;
  331. if (!$InCart) {
  332. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  333. if ($Favourite) {
  334. $HTML .= '<div class="col-12 px-0 text-center">' . PHP_EOL;
  335. $HTML .= '<i class="fas fa-heart favourite" data-id="' . $Product['id'] . '"></i>' . PHP_EOL;
  336. $HTML .= '</div>' . PHP_EOL;
  337. } else {
  338. $HTML .= '<div class="col-12 px-0 text-center">' . PHP_EOL;
  339. $HTML .= '<i class="far fa-heart favourite" data-id="' . $Product['id'] . '"></i>' . PHP_EOL;
  340. $HTML .= '</div>' . PHP_EOL;
  341. }
  342. $HTML .= '</div>' . PHP_EOL;
  343. }
  344. $HTML .= '<div class="row">' . PHP_EOL;
  345. $HTML .= '<span class="col-7 d-block pl-0 font-weight-bold text-center">'
  346. . $Product['name'] . '</span>' . PHP_EOL;
  347. $HTML .= '<span class="col-5 d-block pr-0 font-weight-bold text-center">US $'
  348. . $Product['price'] . '</span>' . PHP_EOL;
  349. $HTML .= '</div>' . PHP_EOL;
  350. $HTML .= '</div>' . PHP_EOL;
  351. $HTML .= '</div>' . PHP_EOL;
  352. $HTML .= '<div class="container-fluid card-text">' . PHP_EOL;
  353. if ($InCart) {
  354. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  355. $HTML .= '<div class="form-group col-12 px-0 text-center">' . PHP_EOL;
  356. $HTML .= '<label for="quantityproduct-' . $Product['id'] . '">Quantity</label>' . PHP_EOL;
  357. $HTML .= '<input type="number" class="form-control quantityproduct" id="quantityproduct-'
  358. . $Product['id'] . '" min="1" value="' . $Quantity . '" '
  359. . 'data-id="' . $Product['id'] . '" data-price="' . $Product['price'] . '" />' . PHP_EOL;
  360. $HTML .= '</div>' . PHP_EOL;
  361. $HTML .= '</div>' . PHP_EOL;
  362. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  363. $HTML .= '<div class="col-12 px-0">' . PHP_EOL;
  364. $HTML .= '<a class="btn btn-block btn-lg btn-danger removecart" href=".?nocart=' . $Product['id'] . '" >'
  365. . '<i class="fas fa-cart-plus"></i> Remove of cart</a>' . PHP_EOL;
  366. $HTML .= '</div>' . PHP_EOL;
  367. $HTML .= '</div>' . PHP_EOL;
  368. } else {
  369. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  370. $HTML .= '<p class="col-12 px-0">' . $Product['description'] . '</p>' . PHP_EOL;
  371. $HTML .= '</div>' . PHP_EOL;
  372. }
  373. $HTML .= '</div>' . PHP_EOL;
  374. if ($InView) {
  375. $HTML .= '<button type="button" class="btn btn-block btn-lg btn-info addcart" '
  376. . 'data-id="' . $Product['id'] . '"><i class="fas fa-cart-plus"></i> Add to cart</button>' . PHP_EOL;
  377. } else {
  378. $HTML .= '<a class="btn btn-block btn-lg btn-primary" href=".?view='
  379. . $Product['id'] . '">Show details</a>' . PHP_EOL;
  380. }
  381. $HTML .= '</div>' . PHP_EOL;
  382. $HTML .= '</div>' . PHP_EOL;
  383. $HTML .= '</div>' . PHP_EOL;
  384. return $HTML;
  385. }
  386. function ShowProduct($Products, $Id, $Favourites) {
  387. $HTML = '';
  388. if (CheckListValue($Products, $Id, 'id')) {
  389. $HTML .= '<div class="col-xl-5 col-lg-7 col-md-10 col-12 mx-auto">' . PHP_EOL;
  390. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  391. $HTML .= '<div class="row my-3">' . PHP_EOL;
  392. $HTML .= '<div class="col"></div>' . PHP_EOL;
  393. $HTML .= '<h2 class="col-xl-6 col-lg-4 col-12 mb-lg-0 mb-2 text-center">Product</h2>' . PHP_EOL;
  394. $HTML .= '<div class="col text-center">' . PHP_EOL;
  395. $HTML .= '<a class="h-100 btn btn-block btn-secondary t-large" href=".">Return</a>' . PHP_EOL;
  396. $HTML .= '</div>' . PHP_EOL;
  397. $HTML .= '</div>' . PHP_EOL;
  398. $HTML .= '<div class="row">' . PHP_EOL;
  399. if (in_array($Id, $Favourites)) {
  400. $HTML .= PrintProductCard(GetProduct($Products, $Id), true, true);
  401. } else {
  402. $HTML .= PrintProductCard(GetProduct($Products, $Id), false, true);
  403. }
  404. $HTML .= '</div>' . PHP_EOL;
  405. $HTML .= '</div>' . PHP_EOL;
  406. $HTML .= '</div>' . PHP_EOL;
  407. $HTML .= '</div>' . PHP_EOL;
  408. } else {
  409. $HTML .= ShowProductWarning();
  410. }
  411. return $HTML;
  412. }
  413. function ShowProductWarning() {
  414. $HTML = '';
  415. $HTML .= '<div class="col-lg-4 col-md-6 col-sm-10 col-12 mx-auto">' . PHP_EOL;
  416. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  417. $HTML .= '<div class="row my-3">' . PHP_EOL;
  418. $HTML .= '<div class="col-12 text-center">' . PHP_EOL;
  419. $HTML .= '<span class="t-large">Inexistent product</span>' . PHP_EOL;
  420. $HTML .= '</div>' . PHP_EOL;
  421. $HTML .= '</div>' . PHP_EOL;
  422. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  423. $HTML .= '<div class="col-12">' . PHP_EOL;
  424. $HTML .= '<div class="container-fluid border border-secondary rounded">' . PHP_EOL;
  425. $HTML .= '<div class="row my-3">' . PHP_EOL;
  426. $HTML .= '<p class="col-12 mb-0">' . PHP_EOL;
  427. $HTML .= 'The selected product doesn\'t exist. Please, return back and choose a '
  428. . 'correct product.' . PHP_EOL;
  429. $HTML .= '</p>' . PHP_EOL;
  430. $HTML .= '</div>' . PHP_EOL;
  431. $HTML .= '</div>' . PHP_EOL;
  432. $HTML .= '</div>' . PHP_EOL;
  433. $HTML .= '</div>' . PHP_EOL;
  434. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  435. $HTML .= '<div class="col-12">' . PHP_EOL;
  436. $HTML .= '<a class="btn btn-secondary btn-lg btn-block" href=".">Return</a>' . PHP_EOL;
  437. $HTML .= '</div>' . PHP_EOL;
  438. $HTML .= '</div>' . PHP_EOL;
  439. $HTML .= '</div>' . PHP_EOL;
  440. $HTML .= '</div>' . PHP_EOL;
  441. return $HTML;
  442. }
  443. function FilterFavourites($Products, $Favourites) {
  444. $FavouriteProducts = [];
  445. foreach ($Products as $Position => $Product) {
  446. if (in_array($Product['id'], $Favourites)) {
  447. array_push($FavouriteProducts, $Product);
  448. }
  449. }
  450. return $FavouriteProducts;
  451. }
  452. function ShowCart($Products, $Cart, $Costs) {
  453. $HTML = '';
  454. $HTML .= '<div class="col-lg-10 col-12 mx-auto">' . PHP_EOL;
  455. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  456. $HTML .= '<div class="row my-3">' . PHP_EOL;
  457. $HTML .= '<h2 class="col-12 mb-0 text-center">Cart</h2>' . PHP_EOL;
  458. $HTML .= '</div>' . PHP_EOL;
  459. if (count($Cart) !== 0) {
  460. $HTML .= '<div class="row row-cols-lg-2 row-cols-1">' . PHP_EOL;
  461. foreach ($Cart as $ProductCartId => $ProductCartQuantity) {
  462. if (CheckListValue($Products, $ProductCartId, 'id')) {
  463. $HTML .= PrintProductCard(GetProduct($Products, $ProductCartId), false, false, true, $ProductCartQuantity);
  464. }
  465. }
  466. $HTML .= '</div>' . PHP_EOL;
  467. } else {
  468. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  469. $HTML .= '<span class="col-12 d-block my-auto text-center t-large">No products in the cart</span>' . PHP_EOL;
  470. $HTML .= '</div>' . PHP_EOL;
  471. }
  472. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  473. $HTML .= '<div class="col-xl-4 col-md-6 col-sm-10 col-12 mx-auto">' . PHP_EOL;
  474. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  475. $HTML .= '<div class="row my-3">' . PHP_EOL;
  476. $HTML .= '<span class="col-md-6 col-12 mb-lg-0 mb-2 text-center font-weight-bold">Subtotal</span>' . PHP_EOL;
  477. $HTML .= '<span class="col-md-6 col-12 text-center">US $<span id="subtotal">'
  478. . $Costs[0] . '</span></span>' . PHP_EOL;
  479. $HTML .= '</div>' . PHP_EOL;
  480. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  481. $HTML .= '<span class="col-md-6 col-12 mb-lg-0 mb-2 text-center font-weight-bold">Shipping</span>' . PHP_EOL;
  482. $HTML .= '<span class="col-md-6 col-12 text-center">US $<span id="shipping">'
  483. . $Costs[1] . '</span></span>' . PHP_EOL;
  484. $HTML .= '</div>' . PHP_EOL;
  485. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  486. $HTML .= '<span class="col-md-6 col-12 mb-lg-0 mb-2 text-center font-weight-bold">Total</span>' . PHP_EOL;
  487. $HTML .= '<span class="col-md-6 col-12 text-center">US $<span id="total">'
  488. . $Costs[2] . '</span></span>' . PHP_EOL;
  489. $HTML .= '</div>' . PHP_EOL;
  490. $HTML .= '</div>' . PHP_EOL;
  491. $HTML .= '</div>' . PHP_EOL;
  492. $HTML .= '</div>' . PHP_EOL;
  493. if ($Costs[2] > 0) {
  494. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  495. $HTML .= '<div class="col-md-6 col-12 text-center mx-auto">' . PHP_EOL;
  496. $HTML .= '<a class="btn btn-lg btn-block btn-primary" href=".?checkout">Checkout</a>' . PHP_EOL;
  497. $HTML .= '</div>' . PHP_EOL;
  498. $HTML .= '</div>' . PHP_EOL;
  499. }
  500. $HTML .= '</div>' . PHP_EOL;
  501. $HTML .= '</div>' . PHP_EOL;
  502. $HTML .= '</div>' . PHP_EOL;
  503. return $HTML;
  504. }
  505. function CreateSelect($Data, $Name, $FieldValue, $FieldName, $Selected, $Disabled = false) {
  506. $HTML = '';
  507. if (!$Disabled) {
  508. $HTML .= '<select name="' . $Name . '" class="form-control"
  509. id="' . $Name . '" required="">' . PHP_EOL;
  510. } else {
  511. $HTML .= '<select name="' . $Name . '" class="form-control"
  512. id="' . $Name . '" disabled="" required="">' . PHP_EOL;
  513. }
  514. $HTML .= '<option value="">-- Select --</option>' . PHP_EOL;
  515. foreach ($Data as $Key => $Value) {
  516. if ($Value[$FieldValue] === $Selected) {
  517. $HTML .= '<option value="' . $Value[$FieldValue] . '" selected="">'
  518. . $Value[$FieldName] . '</option>' . PHP_EOL;
  519. } else {
  520. $HTML .= '<option value="' . $Value[$FieldValue] . '">'
  521. . $Value[$FieldName] . '</option>' . PHP_EOL;
  522. }
  523. }
  524. $HTML .= '</select>' . PHP_EOL;
  525. return $HTML;
  526. }
  527. function ShowCheckout($Replies, $Selects, $CheckoutErrors, $Costs) {
  528. $HTML = '';
  529. $HTML .= '<form method="POST" action=".?checkout" class="col-lg-8 col-12 mb-lg-0 mb-2 mx-auto">' . PHP_EOL;
  530. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  531. $HTML .= '<div class="row my-3">' . PHP_EOL;
  532. $HTML .= '<div class="col"></div>' . PHP_EOL;
  533. $HTML .= '<h2 class="col-xl-6 col-md-4 col-12 mb-md-0 mb-2 text-center">Checkout</h2>' . PHP_EOL;
  534. $HTML .= '<div class="col text-center">' . PHP_EOL;
  535. $HTML .= '<a class="h-100 btn btn-block btn-secondary t-large" href=".?cart=all">Return</a>' . PHP_EOL;
  536. $HTML .= '</div>' . PHP_EOL;
  537. $HTML .= '</div>' . PHP_EOL;
  538. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  539. $HTML .= '<div class="col-12">' . PHP_EOL;
  540. $HTML .= '<div class="container-fluid">' . PHP_EOL;
  541. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  542. $HTML .= '<span class="col-12 bg-info rounded p-1 text-white text-center font-weight-bold t-large">Personal Information</span>' . PHP_EOL;
  543. $HTML .= '</div>' . PHP_EOL;
  544. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  545. $HTML .= '<div class="form-group col-lg-6 col-12 mb-lg-0 mb-2">' . PHP_EOL;
  546. $HTML .= '<label class="font-weight-bold" for="firstname">First name (*)</label>' . PHP_EOL;
  547. $HTML .= '<input type="text" class="form-control" id="firstname" name="firstname" pattern="[a-zA-ZñÑáéíóúÁÉÍÓÚü\s]{2,50}" value="' . $Replies['firstname'] . '" required="" title="Between 2 and 50 word characters"/>' . PHP_EOL;
  548. $HTML .= '</div>' . PHP_EOL;
  549. $HTML .= '<div class="form-group col-lg-6 col-12 mb-lg-0 mb-2">' . PHP_EOL;
  550. $HTML .= '<label class="font-weight-bold" for="lastname">Last name (*)</label>' . PHP_EOL;
  551. $HTML .= '<input type="text" class="form-control" id="lastname" name="lastname" pattern="[a-zA-ZñÑáéíóúÁÉÍÓÚü\s]{2,60}" value="' . $Replies['lastname'] . '" required="" title="Between 2 and 60 word characters"/>' . PHP_EOL;
  552. $HTML .= '</div>' . PHP_EOL;
  553. $HTML .= '</div>' . PHP_EOL;
  554. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  555. $HTML .= '<div class="form-group col-lg-6 col-12 mx-auto">' . PHP_EOL;
  556. $HTML .= '<label class="font-weight-bold" for="telephone">Telephone (*)</label>' . PHP_EOL;
  557. $HTML .= '<input type="tel" class="form-control" id="telephone" name="telephone" value="' . $Replies['telephone'] . '" pattern="[0-9]{9}" required="" title="Number of 9 digits"/>' . PHP_EOL;
  558. $HTML .= '</div>' . PHP_EOL;
  559. $HTML .= '</div>' . PHP_EOL;
  560. $HTML .= '<div class="row">' . PHP_EOL;
  561. $HTML .= '<div class="form-group col-12">' . PHP_EOL;
  562. $HTML .= '<label class="font-weight-bold" for="information">Additional information</label>' . PHP_EOL;
  563. $HTML .= '<textarea class="form-control" name="information" id="information" rows="3" maxlength="2000">' . $Replies['information'] . '</textarea>' . PHP_EOL;
  564. $HTML .= '</div>' . PHP_EOL;
  565. $HTML .= '</div>' . PHP_EOL;
  566. $HTML .= '</div>' . PHP_EOL;
  567. $HTML .= '</div>' . PHP_EOL;
  568. $HTML .= '</div>' . PHP_EOL;
  569. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  570. $HTML .= '<div class="col-12">' . PHP_EOL;
  571. $HTML .= '<div class="container-fluid">' . PHP_EOL;
  572. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  573. $HTML .= '<span class="col-12 bg-info rounded p-1 text-white text-center font-weight-bold t-large">Shipment</span>' . PHP_EOL;
  574. $HTML .= '</div>' . PHP_EOL;
  575. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  576. $HTML .= '<div class="form-group col-lg-6 col-12">' . PHP_EOL;
  577. $HTML .= '<label class="font-weight-bold" for="country">Country (*)</label>' . PHP_EOL;
  578. $HTML .= $Selects[0];
  579. $HTML .= '</div>' . PHP_EOL;
  580. $HTML .= '<div class="form-group col-lg-6 col-12">' . PHP_EOL;
  581. $HTML .= '<label class="font-weight-bold" for="province">Province (*)</label>' . PHP_EOL;
  582. $HTML .= $Selects[1];
  583. $HTML .= '</div>' . PHP_EOL;
  584. $HTML .= '</div>' . PHP_EOL;
  585. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  586. $HTML .= '<div class="form-group col-lg-6 col-12">' . PHP_EOL;
  587. $HTML .= '<label class="font-weight-bold" for="municipality">Municipality (*)</label>' . PHP_EOL;
  588. $HTML .= $Selects[2];
  589. $HTML .= '</div>' . PHP_EOL;
  590. $HTML .= '<div class="form-group col-lg-6 col-12">' . PHP_EOL;
  591. $HTML .= '<label class="font-weight-bold" for="zipcode">ZIP code (*)</label>' . PHP_EOL;
  592. $HTML .= $Selects[3];
  593. $HTML .= '</div>' . PHP_EOL;
  594. $HTML .= '</div>' . PHP_EOL;
  595. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  596. $HTML .= '<div class="form-group col-lg-6 col-12">' . PHP_EOL;
  597. $HTML .= '<label class="font-weight-bold" for="roadtype">Road type (*)</label>' . PHP_EOL;
  598. $HTML .= $Selects[4];
  599. $HTML .= '</div>' . PHP_EOL;
  600. $HTML .= '<div class="form-group col-lg-6 col-12">' . PHP_EOL;
  601. $HTML .= '<label class="font-weight-bold" for="roadname">Road name (*)</label>' . PHP_EOL;
  602. $HTML .= '<input type="text" class="form-control" id="roadname" name="roadname" pattern="[a-zA-ZñÑáéíóúÁÉÍÓÚü\s]{2,80}" value="' . $Replies['roadname'] . '" required="" title="Between 2 and 80 word characters"/>' . PHP_EOL;
  603. $HTML .= '</div>' . PHP_EOL;
  604. $HTML .= '</div>' . PHP_EOL;
  605. $HTML .= '<div class="row">' . PHP_EOL;
  606. $HTML .= '<div class="form-group col-md-6 col-12">' . PHP_EOL;
  607. $HTML .= '<label class="font-weight-bold" for="number">Number (*)</label>' . PHP_EOL;
  608. $HTML .= '<input type="number" name="number" class="form-control" id="numero" min="0" max="999" value="' . $Replies['number'] . '" required="" />' . PHP_EOL;
  609. $HTML .= '</div>' . PHP_EOL;
  610. $HTML .= '<div class="form-group col-md-6 col-12">' . PHP_EOL;
  611. $HTML .= '<label class="font-weight-bold" for="complement">Complement</label>' . PHP_EOL;
  612. $HTML .= '<input type="text" name="complement" class="form-control" id="complement" pattern="[a-zA-ZñÑáéíóúÁÉÍÓÚü\d\s]{2,50}" value="' . $Replies['complement'] . '" title="Between 2 and 50 alphanumeric characters"/>' . PHP_EOL;
  613. $HTML .= '</div>' . PHP_EOL;
  614. $HTML .= '</div>' . PHP_EOL;
  615. $HTML .= '</div>' . PHP_EOL;
  616. $HTML .= '</div>' . PHP_EOL;
  617. $HTML .= '</div>' . PHP_EOL;
  618. if (count($CheckoutErrors) > 0) {
  619. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  620. $HTML .= '<div class="col-12">' . PHP_EOL;
  621. $HTML .= '<ul class="mb-0 p-3 pl-4 rounded bg-danger text-white">' . PHP_EOL;
  622. foreach ($CheckoutErrors as $Value) {
  623. $HTML .= '<li>' . $Value . '</li>' . PHP_EOL;
  624. }
  625. $HTML .= '</ul>' . PHP_EOL;
  626. $HTML .= '</div>' . PHP_EOL;
  627. $HTML .= '</div>' . PHP_EOL;
  628. }
  629. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  630. $HTML .= '<div class="col-xl-4 col-md-6 col-sm-10 col-12 mx-auto">' . PHP_EOL;
  631. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  632. $HTML .= '<div class="row my-3">' . PHP_EOL;
  633. $HTML .= '<span class="col-md-6 col-12 mb-lg-0 mb-2 text-center font-weight-bold">Subtotal</span>' . PHP_EOL;
  634. $HTML .= '<span class="col-md-6 col-12 text-center">US $<span id="subtotal">'
  635. . $Costs[0] . '</span></span>' . PHP_EOL;
  636. $HTML .= '</div>' . PHP_EOL;
  637. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  638. $HTML .= '<span class="col-md-6 col-12 mb-lg-0 mb-2 text-center font-weight-bold">Shipping</span>' . PHP_EOL;
  639. $HTML .= '<span class="col-md-6 col-12 text-center">US $<span id="shipping">'
  640. . $Costs[1] . '</span></span>' . PHP_EOL;
  641. $HTML .= '</div>' . PHP_EOL;
  642. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  643. $HTML .= '<span class="col-md-6 col-12 mb-lg-0 mb-2 text-center font-weight-bold">Total</span>' . PHP_EOL;
  644. $HTML .= '<span class="col-md-6 col-12 text-center">US $<span id="total">'
  645. . $Costs[2] . '</span></span>' . PHP_EOL;
  646. $HTML .= '</div>' . PHP_EOL;
  647. $HTML .= '</div>' . PHP_EOL;
  648. $HTML .= '</div>' . PHP_EOL;
  649. $HTML .= '</div>' . PHP_EOL;
  650. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  651. $HTML .= '<div class="col-md-6 col-12 text-center mx-auto">' . PHP_EOL;
  652. $HTML .= '<button type="submit" class="btn btn-lg btn-block btn-primary" name="validatecheckout">Process shipment</button>' . PHP_EOL;
  653. $HTML .= '</div>' . PHP_EOL;
  654. $HTML .= '</div>' . PHP_EOL;
  655. $HTML .= '</div>' . PHP_EOL;
  656. $HTML .= '</form>' . PHP_EOL;
  657. return $HTML;
  658. }
  659. function ShowEnd() {
  660. $HTML = '';
  661. $HTML .= '<div class="col-lg-4 col-md-6 col-sm-10 col-12 mx-auto">' . PHP_EOL;
  662. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  663. $HTML .= '<div class="row my-3">' . PHP_EOL;
  664. $HTML .= '<div class="col-12 text-center">' . PHP_EOL;
  665. $HTML .= '<span class="t-large">Checkout</span>' . PHP_EOL;
  666. $HTML .= '</div>' . PHP_EOL;
  667. $HTML .= '</div>' . PHP_EOL;
  668. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  669. $HTML .= '<div class="col-12">' . PHP_EOL;
  670. $HTML .= '<div class="container-fluid border border-secondary rounded">' . PHP_EOL;
  671. $HTML .= '<div class="row my-3">' . PHP_EOL;
  672. $HTML .= '<p class="col-12 mb-0">' . PHP_EOL;
  673. $HTML .= 'The order has been processed correctly.' . PHP_EOL;
  674. $HTML .= '</p>' . PHP_EOL;
  675. $HTML .= '</div>' . PHP_EOL;
  676. $HTML .= '<div class="row my-3">' . PHP_EOL;
  677. $HTML .= '<p class="col-12 mb-0">' . PHP_EOL;
  678. $HTML .= 'You can return to the main webpage.' . PHP_EOL;
  679. $HTML .= '</p>' . PHP_EOL;
  680. $HTML .= '</div>' . PHP_EOL;
  681. $HTML .= '</div>' . PHP_EOL;
  682. $HTML .= '</div>' . PHP_EOL;
  683. $HTML .= '</div>' . PHP_EOL;
  684. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  685. $HTML .= '<div class="col-12">' . PHP_EOL;
  686. $HTML .= '<a class="btn btn-secondary btn-lg btn-block" href=".">Return</a>' . PHP_EOL;
  687. $HTML .= '</div>' . PHP_EOL;
  688. $HTML .= '</div>' . PHP_EOL;
  689. $HTML .= '</div>' . PHP_EOL;
  690. $HTML .= '</div>' . PHP_EOL;
  691. return $HTML;
  692. }
  693. function ShowCatalogue($Products, $Viewed, $Favourites, $FilterFavourites) {
  694. $HTML = '';
  695. $HTML .= '<div class="col-lg-8 col-12 mb-lg-0 mb-2">' . PHP_EOL;
  696. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  697. $HTML .= '<div class="row my-3">' . PHP_EOL;
  698. $HTML .= '<div class="col text-center"></div>' . PHP_EOL;
  699. if ($FilterFavourites) {
  700. $HTML .= '<h2 class="col-xl-6 col-md-4 col-12 mb-md-0 mb-2 text-center">Favourites</h2>' . PHP_EOL;
  701. $HTML .= '<div class="col text-center">' . PHP_EOL;
  702. $HTML .= '<a class="h-100 btn btn-block btn-secondary t-large" href=".">Return</a>' . PHP_EOL;
  703. $HTML .= '</div>' . PHP_EOL;
  704. } else {
  705. $HTML .= '<h2 class="col-xl-6 col-md-4 col-12 mb-md-0 mb-2 text-center">Products</h2>' . PHP_EOL;
  706. $HTML .= '<div class="col text-center">' . PHP_EOL;
  707. $HTML .= '<a class="h-100 btn btn-block btn-danger t-large" href=".?favourite=all"><i class="far fa-heart"></i> Favourites</a>' . PHP_EOL;
  708. $HTML .= '</div>' . PHP_EOL;
  709. }
  710. $HTML .= '</div>' . PHP_EOL;
  711. if (count($Products) !== 0) {
  712. $HTML .= '<div class="row row-cols-lg-2 row-cols-1">' . PHP_EOL;
  713. foreach ($Products as $Index => $Product) {
  714. if (in_array($Product['id'], $Favourites)) {
  715. $HTML .= PrintProductCard($Product, true, false);
  716. } else {
  717. $HTML .= PrintProductCard($Product, false, false);
  718. }
  719. }
  720. $HTML .= '</div>' . PHP_EOL;
  721. } else {
  722. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  723. $HTML .= '<span class="col-12 d-block my-auto text-center t-large">No products in the catalogue</span>' . PHP_EOL;
  724. $HTML .= '</div>' . PHP_EOL;
  725. }
  726. $HTML .= '</div>' . PHP_EOL;
  727. $HTML .= '</div>' . PHP_EOL;
  728. $HTML .= '<div class="col-lg-4 col-12">' . PHP_EOL;
  729. $HTML .= '<div class="container-fluid border border-primary rounded">' . PHP_EOL;
  730. $HTML .= '<div class="row my-3">' . PHP_EOL;
  731. $HTML .= '<div class="col-12 text-center">' . PHP_EOL;
  732. $HTML .= '<h2 class="mb-0">Viewed</h2>' . PHP_EOL;
  733. $HTML .= '</div>' . PHP_EOL;
  734. $HTML .= '</div>' . PHP_EOL;
  735. if (CheckIdListsMatching($Products, $Viewed) !== false) {
  736. $HTML .= '<div class="row row-cols-1">' . PHP_EOL;
  737. foreach ($Products as $Index => $Product) {
  738. if (in_array($Product['id'], $Viewed)) {
  739. if (in_array($Product['id'], $Favourites)) {
  740. $HTML .= PrintProductCard($Product, true, false);
  741. } else {
  742. $HTML .= PrintProductCard($Product, false, false);
  743. }
  744. }
  745. }
  746. $HTML .= '</div>' . PHP_EOL;
  747. } else {
  748. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  749. $HTML .= '<span class="col-12 d-block my-auto text-center t-large">No products viewed</span>' . PHP_EOL;
  750. $HTML .= '</div>' . PHP_EOL;
  751. }
  752. $HTML .= '</div>' . PHP_EOL;
  753. $HTML .= '</div>' . PHP_EOL;
  754. return $HTML;
  755. }