dolibarr  17.0.4
ajax_bom.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2019 Laurent Destailleur (eldy) <eldy@users.sourceforge.net>
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 
23 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
24 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
25 if (!defined('NOREQUIRESOC')) {
26  define('NOREQUIRESOC', '1');
27 }
28 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
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_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
45 
46 $idbom = GETPOST('idbom', 'alpha');
47 //$action = GETPOST('action', 'aZ09');
48 
49 
50 /*
51  * View
52  */
53 
54 top_httphead('application/json');
55 
56 $object = new BOM($db);
57 $result = $object->fetch($idbom);
58 if ($result > 0) {
59  // We remove properties we don't need in answer
60  unset($object->fields);
61  unset($object->db);
62  echo json_encode($object);
63 } else {
64  echo 'Failed to load category with id='.$idbom;
65 }
Class for BOM.
Definition: bom.class.php:37
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1440