dolibarr  17.0.4
qr.php
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 
18 // This page return an image of a QR code
19 
20 if (!defined("NOLOGIN")) {
21  define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
22 }
23 if (!defined('NOIPCHECK')) {
24  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
25 }
26 if (!defined('NOREQUIRESOC')) {
27  define('NOREQUIRESOC', '1');
28 }
29 if (!defined('NOTOKENRENEWAL')) {
30  define('NOTOKENRENEWAL', '1');
31 }
32 if (!defined('NOREQUIREMENU')) {
33  define('NOREQUIREMENU', '1');
34 }
35 if (!defined('NOREQUIREHTML')) {
36  define('NOREQUIREHTML', '1');
37 }
38 if (!defined('NOREQUIREAJAX')) {
39  define('NOREQUIREAJAX', '1');
40 }
41 
42 // Load Dolibarr environment
43 require '../../main.inc.php'; // Load $user and permissions
44 require '../../core/modules/barcode/doc/tcpdfbarcode.modules.php';
45 
46 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
47 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
48 
49 
50 /*
51  * View
52  */
53 
54 // The buildBarCode does not include the http headers but this is a page that just return an image.
55 
56 if (GETPOSTISSET("key")) {
57  $key = GETPOST('key');
58  $module = new modTcpdfbarcode();
59  $result = $module->buildBarCode($urlwithroot."/takepos/public/auto_order.php?key=".$key, 'QRCODE', 'Y');
60 } else {
61  $module = new modTcpdfbarcode();
62  $result = $module->buildBarCode($urlwithroot."/takepos/public/menu.php", 'QRCODE', 'Y');
63 }
Class to generate barcode images using tcpdf barcode generator.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.