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