api_rollerstorage.class.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  3. * Copyright (C) 2024 László Szollősi
  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. use Luracast\Restler\RestException;
  19. dol_include_once('/rollerstorage/class/rollerhistory.class.php');
  20. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/groupusers.class.php';
  21. /**
  22. * \file rollerstorage/class/api_rollerstorage.class.php
  23. * \ingroup rollerstorage
  24. * \brief File for API management of rollerhistory.
  25. */
  26. /**
  27. * API class for rollerstorage rollerhistory
  28. *
  29. * @access protected
  30. * @class DolibarrApiAccess {@requires user,external}
  31. */
  32. class RollerstorageApi extends DolibarrApi
  33. {
  34. /**
  35. * @var RollerHistory $rollerhistory {@type RollerHistory}
  36. */
  37. public $rollerhistory;
  38. /**
  39. * Constructor
  40. *
  41. * @url GET /
  42. *
  43. */
  44. public function __construct()
  45. {
  46. global $db;
  47. $this->db = $db;
  48. $this->rollerhistory = new RollerHistory($this->db);
  49. }
  50. /**
  51. * Check user and eventdetail type permissions
  52. *
  53. * Return a result.
  54. *
  55. * @return array|mixed Data without useless information
  56. *
  57. * @url POST checkPermission
  58. */
  59. public function checkPermission()
  60. {
  61. global $user, $db;
  62. $permissionArray = [];
  63. dol_include_once('/eventwizard/class/eventdetails.class.php');
  64. $sqlBasicService = "SELECT pe.basic_service FROM llx_product as p
  65. INNER JOIN llx_product_extrafields as pe ON pe.fk_object = p.rowid
  66. GROUP BY pe.basic_service";
  67. $resultBasicServices = $db->query($sqlBasicService);
  68. if ($db->num_rows($resultBasicServices) > 0) {
  69. while ($row = $db->fetch_object($resultBasicServices)) {
  70. $basicServices[] = $row->basic_service;
  71. }
  72. }
  73. $sqlBasicServicesTable = "SELECT basic_service_id, ref FROM llx_bbus_basicServices WHERE server_host = 'excelia' ORDER BY basic_service_id ASC";
  74. $resultBasicServicesObj = $db->query($sqlBasicServicesTable);
  75. if ($db->num_rows($resultBasicServicesObj) > 0) {
  76. while ($bsrow = $db->fetch_object($resultBasicServicesObj)) {
  77. foreach ($basicServices as $item) {
  78. if ($bsrow->basic_service_id == $item) {
  79. $permissionArray[$item] = $bsrow->ref;
  80. }
  81. }
  82. }
  83. }
  84. return $permissionArray;
  85. }
  86. }