dolibarr 24.0.0-beta
qr.php
1<?php
2/* Copyright (C) 2020 Andreu Bisquerra <jove@bisquerra.com>
3 * Copyright (C) 2024 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
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// This page return an image of a QR code of a public link
21// Note: Generating a QR code from a string, like done by this script, can be done with any online tool.
22
23if (!defined("NOLOGIN")) {
24 define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
25}
26if (!defined('NOIPCHECK')) {
27 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
28}
29if (!defined('NOREQUIRESOC')) {
30 define('NOREQUIRESOC', '1');
31}
32if (!defined('NOTOKENRENEWAL')) {
33 define('NOTOKENRENEWAL', '1');
34}
35if (!defined('NOREQUIREMENU')) {
36 define('NOREQUIREMENU', '1');
37}
38if (!defined('NOREQUIREHTML')) {
39 define('NOREQUIREHTML', '1');
40}
41if (!defined('NOREQUIREAJAX')) {
42 define('NOREQUIREAJAX', '1');
43}
44
45// Load Dolibarr environment
46require '../../main.inc.php'; // Load $user and permissions
47require '../../core/modules/barcode/doc/tcpdfbarcode.modules.php';
48
53$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
54$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
55
56if (!isModEnabled('takepos')) {
57 accessforbidden('Module not enabled');
58}
59
60
61/*
62 * View
63 */
64
65// The buildBarCode does not include the http headers but this is a page that just return an image.
66
67if (GETPOSTISSET("key")) {
68 $key = GETPOST('key');
69 $module = new modTcpdfbarcode();
70 $result = $module->buildBarCode($urlwithroot."/takepos/public/auto_order.php?key=".urlencode($key), 'QRCODE', 'Y');
71} else {
72 $module = new modTcpdfbarcode();
73 $result = $module->buildBarCode($urlwithroot."/takepos/public/menu.php", 'QRCODE', 'Y');
74}
global $dolibarr_main_url_root
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.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.