ws2.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /* Copyright (C) 2023 Mathieu Moulin <contact@iprospective.fr>
  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. // Load Dolibarr environment
  18. require_once 'env.inc.php';
  19. require_once 'main_load.inc.php';
  20. dol_include_once('custom/mmiprestasync/class/mmi_prestasync.class.php');
  21. header('content-type:application/json; charset=utf-8');
  22. if (empty($user) || empty($user->id)) {
  23. echo json_encode(['r'=>false, 'reason'=>'Not connected']);
  24. die();
  25. }
  26. $permission = $user->rights->mmiprestasync->resync_button->all;
  27. $type = GETPOST('type');
  28. $otype = GETPOST('otype');
  29. $oid = GETPOST('oid');
  30. if (empty($type) || empty($otype) || empty($oid)) {
  31. echo json_encode(['r'=>false, 'reason'=>'Missing parameter']);
  32. die();
  33. }
  34. $ret = mmi_prestasync::ws_trigger($type, $otype, 'osync', $oid);
  35. echo json_encode(['r'=>true, 'result'=>$ret]);
  36. die();