dolibarr 22.0.5
ajax_bom.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2019 Laurent Destailleur (eldy) <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2025 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
25//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
26//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
27if (!defined('NOREQUIRESOC')) {
28 define('NOREQUIRESOC', '1');
29}
30//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
31if (!defined('NOTOKENRENEWAL')) {
32 define('NOTOKENRENEWAL', '1');
33}
34if (!defined('NOREQUIREMENU')) {
35 define('NOREQUIREMENU', '1');
36}
37if (!defined('NOREQUIREHTML')) {
38 define('NOREQUIREHTML', '1');
39}
40if (!defined('NOREQUIREAJAX')) {
41 define('NOREQUIREAJAX', '1');
42}
43
44// Load Dolibarr environment
45require '../../main.inc.php'; // Load $user and permissions
46require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
47
56$idbom = GETPOSTINT('idbom');
57//$action = GETPOST('action', 'aZ09');
58
59$object = new BOM($db);
60$result = $object->fetch($idbom);
61
62// Security check
63$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
64$result = restrictedArea($user, 'bom', $object, $object->table_element, '', '', 'rowid', $isdraft);
65
66
67/*
68 * View
69 */
70
71top_httphead('application/json');
72
73if ($result > 0) {
74 // We remove properties we don't need in answer
75 unset($object->fields);
76 unset($object->db);
77 echo json_encode($object);
78} else {
79 echo 'Failed to load category with id='.$idbom;
80}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
Class for BOM.
Definition bom.class.php:42
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.