dolibarr 24.0.0-beta
ajax.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2004 Andreu Bisquerra <jove@bisquerra.com>
3 * Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
26if (!defined('NOTOKENRENEWAL')) {
27 define('NOTOKENRENEWAL', '1');
28}
29if (!defined('NOREQUIREMENU')) {
30 define('NOREQUIREMENU', '1');
31}
32if (!defined('NOREQUIREHTML')) {
33 define('NOREQUIREHTML', '1');
34}
35if (!defined('NOREQUIREAJAX')) {
36 define('NOREQUIREAJAX', '1');
37}
38if (!defined('NOBROWSERNOTIF')) {
39 define('NOBROWSERNOTIF', '1');
40}
41
42// Load Dolibarr environment
43require '../../main.inc.php'; // Load $user and permissions
51require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
52require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
53require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
54require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
55
56$category = GETPOST('category', 'alphanohtml'); // Can be id of category or 'supplements'
57$action = GETPOST('action', 'aZ09');
58$term = GETPOST('term', 'alpha');
59$search_term = GETPOST('search_term', 'alpha');
60$id = GETPOSTINT('id');
61$search_start = GETPOSTINT('search_start');
62$search_limit = GETPOSTINT('search_limit');
63
64if (!$user->hasRight('takepos', 'run')) {
66}
67
68// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
69$hookmanager->initHooks(array('takeposproductsearch')); // new context for product search hooks
70
71$pricelevel = 1; // default price level if PRODUIT_MULTIPRICES. TODO Get price level from thirdparty.
72
73
74
75/*
76 * View
77 */
78
79$thirdparty = new Societe($db);
80
81if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) {
82 $tosell = GETPOSTISSET('tosell') ? GETPOSTINT('tosell') : '';
83 $limit = GETPOSTISSET('limit') ? GETPOSTINT('limit') : 0;
84 $offset = GETPOSTISSET('offset') ? GETPOSTINT('offset') : 0;
85
86 top_httphead('application/json');
87
88 // Search
89 if (GETPOSTINT('thirdpartyid') > 0) {
90 $result = $thirdparty->fetch(GETPOSTINT('thirdpartyid'));
91 if ($result > 0) {
92 $pricelevel = $thirdparty->price_level;
93 }
94 }
95
96 $object = new Categorie($db);
97 if ($category == "supplements") {
98 $category = getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY');
99 if (empty($category)) {
100 echo 'Error, the category to use for supplements is not defined. Go into setup of module TakePOS.';
101 exit;
102 }
103 }
104
105 $result = $object->fetch($category);
106 if ($result > 0) {
107 $filter = '';
108 if ($tosell != '') {
109 $filter = '(o.tosell:=:'.((int) $tosell).')';
110 }
111 $prods = $object->getObjectsInCateg("product", 0, $limit, $offset, getDolGlobalString('TAKEPOS_SORTPRODUCTFIELD'), 'ASC', $filter);
112 // Removed properties we don't need
113 $res = array();
114 if (is_array($prods) && count($prods) > 0) {
115 $productChildrenNb = 0;
116 foreach ($prods as $prod) {
117 '@phan-var-force Product $prod';
118 if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
119 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
120 $productChildrenNb = $prod->hasFatherOrChild(1);
121 }
122 // always show virtual products (don't manage stock)
123 if ($productChildrenNb == 0) {
124 // remove products without stock
125 $prod->load_stock('nobatch,novirtual');
126 if ($prod->stock_warehouse[getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])]->real <= 0) {
127 continue;
128 }
129 }
130 }
131 unset($prod->fields);
132 unset($prod->db);
133
134 $prod->price_formated = price(price2num(empty($prod->multiprices[$pricelevel]) ? $prod->price : $prod->multiprices[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
135 $prod->price_ttc_formated = price(price2num(empty($prod->multiprices_ttc[$pricelevel]) ? $prod->price_ttc : $prod->multiprices_ttc[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
136
137 $res[] = $prod;
138 }
139 }
140 echo json_encode($res);
141 } else {
142 echo 'Failed to load category with id='.dol_escape_htmltag($category);
143 }
144} elseif ($action == 'search' && $search_term != '' && $user->hasRight('takepos', 'run')) {
145 top_httphead('application/json');
146
147 // Search barcode into third parties. If found, it means we want to change third parties.
148 $result = $thirdparty->fetch(0, '', '', $search_term);
149
150 if ($result && $thirdparty->id > 0) {
151 $rows = array();
152 $rows[] = array(
153 'rowid' => $thirdparty->id,
154 'name' => $thirdparty->name,
155 'barcode' => $thirdparty->barcode,
156 'object' => 'thirdparty'
157 );
158 echo json_encode($rows);
159 exit;
160 }
161
162 // Search
163 if (GETPOSTINT('thirdpartyid') > 0) {
164 $result = $thirdparty->fetch(GETPOSTINT('thirdpartyid'));
165 if ($result > 0) {
166 $pricelevel = $thirdparty->price_level;
167 }
168 }
169
170 // Define $filteroncategids, the filter on category ID if there is a Root category defined.
171 $filteroncategids = '';
172 if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) { // A root category is defined, we must filter on products inside this category tree
173 $object = new Categorie($db);
174 //$result = $object->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
175 $arrayofcateg = $object->get_full_arbo('product', getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID'), 1);
176 if (is_array($arrayofcateg) && count($arrayofcateg) > 0) {
177 foreach ($arrayofcateg as $val) {
178 $filteroncategids .= ($filteroncategids ? ', ' : '').$val['id'];
179 }
180 }
181 }
182
183 $barcode_rules = getDolGlobalString('TAKEPOS_BARCODE_RULE_TO_INSERT_PRODUCT');
184 if (isModEnabled('barcode') && !empty($barcode_rules)) {
185 $barcode_rules_list = array();
186
187 // get barcode rules
188 $barcode_char_nb = 0;
189 $barcode_rules_arr = explode('+', $barcode_rules);
190 foreach ($barcode_rules_arr as $barcode_rules_values) {
191 $barcode_rules_values_arr = explode(':', $barcode_rules_values);
192 if (count($barcode_rules_values_arr) == 2) {
193 $char_nb = intval($barcode_rules_values_arr[1]);
194 $barcode_rules_list[] = array('code' => $barcode_rules_values_arr[0], 'char_nb' => $char_nb);
195 $barcode_char_nb += $char_nb;
196 }
197 }
198
199 $barcode_value_list = array();
200 $barcode_offset = 0;
201 $barcode_length = dol_strlen($search_term);
202 if ($barcode_length == $barcode_char_nb) {
203 $rows = array();
204
205 // split term with barcode rules
206 foreach ($barcode_rules_list as $barcode_rule_arr) {
207 $code = $barcode_rule_arr['code'];
208 $char_nb = $barcode_rule_arr['char_nb'];
209 $barcode_value_list[$code] = substr($search_term, $barcode_offset, $char_nb);
210 $barcode_offset += $char_nb;
211 }
212
213 if (isset($barcode_value_list['ref'])) {
214 // search product from reference
215 $sql = "SELECT rowid, ref, label, tosell, tobuy, barcode, price, price_ttc";
216 $sql .= " FROM " . $db->prefix() . "product as p";
217 $sql .= " WHERE entity IN (" . getEntity('product') . ")";
218 $sql .= " AND ref = '" . $db->escape($barcode_value_list['ref']) . "'";
219 if ($filteroncategids) {
220 $sql .= " AND EXISTS (SELECT cp.fk_product FROM " . $db->prefix() . "categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN (".$db->sanitize($filteroncategids)."))";
221 }
222 $sql .= " AND tosell = 1";
223 $sql .= " AND (barcode IS NULL OR barcode <> '" . $db->escape($search_term) . "')";
224
225 $resql = $db->query($sql);
226 if ($resql && $db->num_rows($resql) == 1) {
227 if ($obj = $db->fetch_object($resql)) {
228 $qty = 1;
229 if (isset($barcode_value_list['qu'])) {
230 $qty_str = $barcode_value_list['qu'];
231 if (isset($barcode_value_list['qd'])) {
232 $qty_str .= '.' . $barcode_value_list['qd'];
233 }
234 $qty = (float) $qty_str;
235 }
236
237 $objProd = new Product($db);
238 $objProd->fetch($obj->rowid);
239
240 $ig = '../public/theme/common/nophoto.png';
241 if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
242 $image = $objProd->show_photos('product', $conf->product->multidir_output[$objProd->entity], 'small', 1);
243
244 $match = array();
245 preg_match('@src="([^"]+)"@', $image, $match);
246 $file = array_pop($match);
247
248 if ($file != '') {
249 if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
250 $ig = $file.'&cache=1';
251 } else {
252 $ig = $file.'&cache=1&publictakepos=1&modulepart=product';
253 }
254 }
255 }
256
257 $rows[] = array(
258 'rowid' => $obj->rowid,
259 'ref' => $obj->ref,
260 'label' => $obj->label,
261 'tosell' => $obj->tosell,
262 'tobuy' => $obj->tobuy,
263 'barcode' => $search_term, // there is only one product matches the barcode rule and so the term is considered as the barcode of this product
264 'price' => empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel],
265 'price_ttc' => empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel],
266 'object' => 'product',
267 'img' => $ig,
268 'qty' => $qty,
269 );
270 }
271 $db->free($resql);
272 }
273 }
274
275 if (count($rows) == 1) {
276 echo json_encode($rows);
277 exit();
278 }
279 }
280 }
281
282 $sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price, p.price_ttc' ;
283 if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
284 if (getDolGlobalInt('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])) {
285 $sql .= ', ps.reel';
286 } else {
287 $sql .= ', SUM(ps.reel) as reel';
288 }
289 }
290 /* this will be possible when field archive will be supported into llx_product_price
291 if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
292 $sql .= ', pp.price_level, pp.price as multiprice_ht, pp.price_ttc as multiprice_ttc';
293 }*/
294 // Add fields from hooks
295 $parameters = array();
296 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters);
297 if ($reshook >= 0) {
298 $sql .= $hookmanager->resPrint;
299 }
300
301 $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
302 /* this will be possible when field archive will be supported into llx_product_price
303 if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
304 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_price as pp ON pp.fk_product = p.rowid AND pp.entity = ".((int) $conf->entity)." AND pp.price_level = ".((int) $pricelevel);
305 $sql .= " AND archive = 0";
306 }*/
307 if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
308 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps';
309 $sql .= ' ON (p.rowid = ps.fk_product';
310 if (getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])) {
311 $sql .= " AND ps.fk_entrepot = ".((int) getDolGlobalInt("CASHDESK_ID_WAREHOUSE".$_SESSION['takeposterminal']));
312 }
313 $sql .= ')';
314 }
315
316 // Add tables from hooks
317 $parameters = array();
318 $reshook = $hookmanager->executeHooks('printFieldListTables', $parameters);
319 if ($reshook >= 0) {
320 $sql .= $hookmanager->resPrint;
321 }
322
323 $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
324 if ($filteroncategids) {
325 $sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$db->sanitize($filteroncategids).'))';
326 }
327 $sql .= ' AND p.tosell = 1';
328 if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1 && getDolGlobalInt('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])) {
329 $sql .= ' AND ps.reel > 0';
330 }
331 $sql .= natural_search(array('ref', 'label', 'barcode'), $search_term);
332 // Add where from hooks
333 $parameters = array();
334 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters);
335 if ($reshook >= 0) {
336 $sql .= $hookmanager->resPrint;
337 }
338
339 if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1 && !getDolGlobalInt('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])) {
340 $sql .= ' GROUP BY p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price, p.price_ttc';
341 // Add fields from hooks
342 $parameters = array();
343 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters);
344 if ($reshook >= 0) {
345 $sql .= $hookmanager->resPrint;
346 }
347 $sql .= ' HAVING SUM(ps.reel) > 0';
348 }
349
350 // load only one page of products
351 $sql .= $db->plimit($search_limit, $search_start);
352
353 $resql = $db->query($sql);
354 if ($resql) {
355 $rows = array();
356
357 while ($obj = $db->fetch_object($resql)) {
358 $objProd = new Product($db);
359 $objProd->fetch($obj->rowid);
360 $image = $objProd->show_photos('product', $conf->product->multidir_output[$objProd->entity], 'small', 1);
361
362 $match = array();
363 preg_match('@src="([^"]+)"@', $image, $match);
364 $file = array_pop($match);
365
366 if ($file == "") {
367 $ig = '../public/theme/common/nophoto.png';
368 } else {
369 if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
370 $ig = $file.'&cache=1';
371 } else {
372 $ig = $file.'&cache=1&publictakepos=1&modulepart=product';
373 }
374 }
375
376 $row = array(
377 'rowid' => $obj->rowid,
378 'ref' => $obj->ref,
379 'label' => $obj->label,
380 'tosell' => $obj->tosell,
381 'tobuy' => $obj->tobuy,
382 'barcode' => $obj->barcode,
383 'price' => empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel],
384 'price_ttc' => empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel],
385 'object' => 'product',
386 'img' => $ig,
387 'qty' => 1,
388 'price_formated' => price(price2num(empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency),
389 'price_ttc_formated' => price(price2num(empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency)
390 );
391 // Add entries to row from hooks
392 $parameters = array();
393 $parameters['row'] = $row;
394 $parameters['obj'] = $obj;
395 $reshook = $hookmanager->executeHooks('completeAjaxReturnArray', $parameters);
396 if ($reshook > 0) {
397 // replace
398 if (count($hookmanager->resArray)) {
399 $row = $hookmanager->resArray;
400 } else {
401 $row = array();
402 }
403 $rows[] = $row;
404 } else {
405 // add
406 if (count($hookmanager->resArray)) {
407 $rows[] = $hookmanager->resArray;
408 }
409 $rows[] = $row;
410 }
411 }
412
413 echo json_encode($rows);
414 } else {
415 echo 'Failed to search product : '.$db->lasterror();
416 }
417} elseif ($action == "opendrawer" && $term != '' && $user->hasRight('takepos', 'run')) {
418 top_httphead('application/html');
419
420 require_once DOL_DOCUMENT_ROOT.'/takepos/class/dolreceiptprinter.class.php';
421 $printer = new dolReceiptPrinter($db);
422
423 // check printer for terminal
424 if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) {
425 // TODO Set the profile into $this->profile (used by initPrinter). Profile not used yet.
426
427 // Init printer
428 $printer->initPrinter(getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term));
429 // open cashdrawer
430 if ($printer->getPrintConnector()) {
431 $printer->pulse();
432 $printer->close();
433 } else {
434 print 'Failed to init printer with ID='.getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term);
435 }
436 }
437} elseif ($action == "printinvoiceticket" && $term != '' && $id > 0 && $user->hasRight('takepos', 'run') && $user->hasRight('facture', 'lire')) {
438 top_httphead('application/html');
439
440 require_once DOL_DOCUMENT_ROOT.'/takepos/class/dolreceiptprinter.class.php';
441 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
442 $printer = new dolReceiptPrinter($db);
443
444 // check printer for terminal
445 if ((getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector")) {
446 $object = new Facture($db);
447 $object->fetch($id);
448
449 $resultinccounter = 0;
450 $templateidtouse = 0;
451
452 $url = DOL_URL_ROOT."/blockedlog/ajax/block-add.php?id=".((int) $object->id).'&element='.urlencode($object->element)."&action=DOC_PREVIEW&token=".newToken();
453
454 $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
455
456 if ((string) $result['http_code'] == '200') {
457 $resultinccounter++;
458 $object->pos_print_counter++; // increase counter to match the change in database
459
460 $templateidtouse = getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term); // Note that this may not be ignored by the sendToPrinter()
461 }
462
463 if ($resultinccounter) {
464 // Send to printer
465 $printer->sendToPrinter($object, $templateidtouse, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term));
466 } else {
467 print 'Failed to update print counter for object ID='.$object->id;
468 }
469 }
470} elseif ($action == 'getInvoice' && $user->hasRight('takepos', 'run')) {
471 top_httphead('application/json');
472
473 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
474
475 $object = new Facture($db);
476 if ($id > 0) {
477 $object->fetch($id);
478 }
479
480 echo json_encode($object);
481} elseif ($action == 'thecheck' && $user->hasRight('takepos', 'run')) {
482 top_httphead('application/html');
483
484 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
485 require_once DOL_DOCUMENT_ROOT.'/takepos/class/dolreceiptprinter.class.php';
486
487 $object = new Facture($db);
488 $printer = new dolReceiptPrinter($db);
489
490 $printer->sendToPrinter($object, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term), getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term));
491}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage categories.
Class to manage invoices.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Receipt Printers.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1, $timeoutconnect=0, $timeoutresponse=0, $otherCurlOptions=array(), $morelogsuffix='')
Function to get a content from an URL (use proxy if proxy defined).
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.