extraparams.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/extraparams.php
  19. * \brief File to make Ajax action on setting extra parameters of elements
  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('NOREQUIREHTML')) {
  28. define('NOREQUIREHTML', '1');
  29. }
  30. if (!defined('NOREQUIREAJAX')) {
  31. define('NOREQUIREAJAX', '1');
  32. }
  33. if (!defined('NOREQUIRESOC')) {
  34. define('NOREQUIRESOC', '1');
  35. }
  36. include '../../main.inc.php';
  37. $id = GETPOST('id', 'int');
  38. $element = GETPOST('element', 'alpha');
  39. $htmlelement = GETPOST('htmlelement', 'alpha');
  40. $type = GETPOST('type', 'alpha');
  41. /*
  42. * View
  43. */
  44. top_httphead();
  45. print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
  46. if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type)) {
  47. $value = GETPOST('value', 'alpha');
  48. $params = array();
  49. dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG);
  50. $classpath = $subelement = $element;
  51. // For compatibility
  52. if ($element == 'order' || $element == 'commande') {
  53. $classpath = $subelement = 'commande';
  54. } elseif ($element == 'propal') {
  55. $classpath = 'comm/propal';
  56. $subelement = 'propal';
  57. } elseif ($element == 'facture') {
  58. $classpath = 'compta/facture';
  59. $subelement = 'facture';
  60. } elseif ($element == 'contract') {
  61. $classpath = $subelement = 'contrat';
  62. } elseif ($element == 'shipping') {
  63. $classpath = $subelement = 'expedition';
  64. } elseif ($element == 'deplacement') {
  65. $classpath = 'compta/deplacement';
  66. $subelement = 'deplacement';
  67. } elseif ($element == 'order_supplier') {
  68. $classpath = 'fourn';
  69. $subelement = 'fournisseur.commande';
  70. } elseif ($element == 'invoice_supplier') {
  71. $classpath = 'fourn';
  72. $subelement = 'fournisseur.facture';
  73. }
  74. dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php');
  75. if ($element == 'order_supplier') {
  76. $classname = 'CommandeFournisseur';
  77. } elseif ($element == 'invoice_supplier') {
  78. $classname = 'FactureFournisseur';
  79. } else {
  80. $classname = ucfirst($subelement);
  81. }
  82. $object = new $classname($db);
  83. $object->fetch($id);
  84. $params[$htmlelement] = array($type => $value);
  85. $object->extraparams = array_merge($object->extraparams, $params);
  86. $result = $object->setExtraParameters();
  87. }