qr.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* Copyright (C) 2020 Andreu Bisquerra <jove@bisquerra.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. // This page return an image of a QR code
  18. if (!defined("NOLOGIN")) {
  19. define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
  20. }
  21. if (!defined('NOIPCHECK')) {
  22. define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  23. }
  24. if (!defined('NOREQUIRESOC')) {
  25. define('NOREQUIRESOC', '1');
  26. }
  27. if (!defined('NOTOKENRENEWAL')) {
  28. define('NOTOKENRENEWAL', '1');
  29. }
  30. if (!defined('NOREQUIREMENU')) {
  31. define('NOREQUIREMENU', '1');
  32. }
  33. if (!defined('NOREQUIREHTML')) {
  34. define('NOREQUIREHTML', '1');
  35. }
  36. if (!defined('NOREQUIREAJAX')) {
  37. define('NOREQUIREAJAX', '1');
  38. }
  39. // Load Dolibarr environment
  40. require '../../main.inc.php'; // Load $user and permissions
  41. require '../../core/modules/barcode/doc/tcpdfbarcode.modules.php';
  42. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  43. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  44. /*
  45. * View
  46. */
  47. // The buildBarCode does not include the http headers but this is a page that just return an image.
  48. if (GETPOSTISSET("key")) {
  49. $key = GETPOST('key');
  50. $module = new modTcpdfbarcode();
  51. $result = $module->buildBarCode($urlwithroot."/takepos/public/auto_order.php?key=".$key, 'QRCODE', 'Y');
  52. } else {
  53. $module = new modTcpdfbarcode();
  54. $result = $module->buildBarCode($urlwithroot."/takepos/public/menu.php", 'QRCODE', 'Y');
  55. }