dolibarr 18.0.6
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
25if (!defined('NOREQUIRESOC')) {
26 define('NOREQUIRESOC', '1');
27}
28//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
29if (!defined('NOTOKENRENEWAL')) {
30 define('NOTOKENRENEWAL', '1');
31}
32if (!defined('NOREQUIREMENU')) {
33 define('NOREQUIREMENU', '1');
34}
35if (!defined('NOREQUIREHTML')) {
36 define('NOREQUIREHTML', '1');
37}
38if (!defined('NOREQUIREAJAX')) {
39 define('NOREQUIREAJAX', '1');
40}
41
42// Load Dolibarr environment
43require '../../main.inc.php'; // Load $user and permissions
44require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
45
46$idbom = GETPOST('idbom', 'alpha');
47//$action = GETPOST('action', 'aZ09');
48
49$object = new BOM($db);
50$result = $object->fetch($idbom);
51
52// Security check
53$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
54$result = restrictedArea($user, 'bom', $object, $object->table_element, '', '', 'rowid', $isdraft);
55
56
57/*
58 * View
59 */
60
61top_httphead('application/json');
62
63if ($result > 0) {
64 // We remove properties we don't need in answer
65 unset($object->fields);
66 unset($object->db);
67 echo json_encode($object);
68} else {
69 echo 'Failed to load category with id='.$idbom;
70}
Class for BOM.
Definition bom.class.php:39
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(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.