dolibarr 21.0.0-beta
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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
24//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
25//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
26if (!defined('NOREQUIRESOC')) {
27 define('NOREQUIRESOC', '1');
28}
29//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
30if (!defined('NOTOKENRENEWAL')) {
31 define('NOTOKENRENEWAL', '1');
32}
33if (!defined('NOREQUIREMENU')) {
34 define('NOREQUIREMENU', '1');
35}
36if (!defined('NOREQUIREHTML')) {
37 define('NOREQUIREHTML', '1');
38}
39if (!defined('NOREQUIREAJAX')) {
40 define('NOREQUIREAJAX', '1');
41}
42
43// Load Dolibarr environment
44require '../../main.inc.php'; // Load $user and permissions
45require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
46
55$idbom = GETPOST('idbom', 'alpha');
56//$action = GETPOST('action', 'aZ09');
57
58$object = new BOM($db);
59$result = $object->fetch($idbom);
60
61// Security check
62$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
63$result = restrictedArea($user, 'bom', $object, $object->table_element, '', '', 'rowid', $isdraft);
64
65
66/*
67 * View
68 */
69
70top_httphead('application/json');
71
72if ($result > 0) {
73 // We remove properties we don't need in answer
74 unset($object->fields);
75 unset($object->db);
76 echo json_encode($object);
77} else {
78 echo 'Failed to load category with id='.$idbom;
79}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class for BOM.
Definition bom.class.php:42
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.