ajax_bom.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. /**
  18. * \file htdocs/mrp/ajax/ajax_bom.php
  19. * \brief Ajax search component for Mrp. It get BOM content.
  20. */
  21. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
  22. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
  23. if (!defined('NOREQUIRESOC')) {
  24. define('NOREQUIRESOC', '1');
  25. }
  26. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
  27. if (!defined('NOTOKENRENEWAL')) {
  28. define('NOTOKENRENEWAL', '1');
  29. }
  30. if (!defined('NOREQUIREMENU')) {
  31. define('NOREQUIREMENU', '1');
  32. }
  33. if (!defined('NOREQUIREHTML')) {
  34. define('NOREQUIREHTML', '1');
  35. }
  36. if (!defined('NOREQUIREAJAX')) {
  37. define('NOREQUIREAJAX', '1');
  38. }
  39. // Load Dolibarr environment
  40. require '../../main.inc.php'; // Load $user and permissions
  41. require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
  42. $idbom = GETPOST('idbom', 'alpha');
  43. //$action = GETPOST('action', 'aZ09');
  44. /*
  45. * View
  46. */
  47. top_httphead('application/json');
  48. $object = new BOM($db);
  49. $result = $object->fetch($idbom);
  50. if ($result > 0) {
  51. // We remove properties we don't need in answer
  52. unset($object->fields);
  53. unset($object->db);
  54. echo json_encode($object);
  55. } else {
  56. echo 'Failed to load category with id='.$idbom;
  57. }