vatrates.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
  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/core/ajax/vatrates.php
  19. * \brief File to load vat rates combobox
  20. */
  21. if (!defined('NOTOKENRENEWAL')) {
  22. define('NOTOKENRENEWAL', '1'); // Disables token renewal
  23. }
  24. if (!defined('NOREQUIREMENU')) {
  25. define('NOREQUIREMENU', '1');
  26. }
  27. if (!defined('NOREQUIREAJAX')) {
  28. define('NOREQUIREAJAX', '1');
  29. }
  30. require '../../main.inc.php';
  31. $id = GETPOST('id', 'int');
  32. $action = GETPOST('action', 'aZ09');
  33. $htmlname = GETPOST('htmlname', 'alpha');
  34. $selected = (GETPOST('selected') ?GETPOST('selected') : '-1');
  35. $productid = (GETPOST('productid', 'int') ?GETPOST('productid', 'int') : 0);
  36. /*
  37. * View
  38. */
  39. top_httphead();
  40. //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
  41. // Load original field value
  42. if (!empty($id) && !empty($action) && !empty($htmlname)) {
  43. $form = new Form($db);
  44. $soc = new Societe($db);
  45. $soc->fetch($id);
  46. if ($action == 'getSellerVATRates') {
  47. $seller = $mysoc;
  48. $buyer = $soc;
  49. } else {
  50. $buyer = $mysoc;
  51. $seller = $soc;
  52. }
  53. $return = array();
  54. $return['value'] = $form->load_tva('tva_tx', $selected, $seller, $buyer, $productid, 0, '', true);
  55. $return['num'] = $form->num;
  56. $return['error'] = $form->error;
  57. echo json_encode($return);
  58. }