objectonoff.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /**
  17. * \file htdocs/core/ajax/productonoff.php
  18. * \brief File to set tosell and tobuy for product
  19. */
  20. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
  21. if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
  22. if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
  23. if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
  24. if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  25. if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
  28. $action=GETPOST('action','alpha');
  29. $id=GETPOST('id', 'int');
  30. $value=GETPOST('value', 'int');
  31. $field=GETPOST('field', 'alpha');
  32. $element=GETPOST('element', 'alpha');
  33. $object = new GenericObject($db);
  34. /*
  35. * View
  36. */
  37. top_httphead();
  38. print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
  39. // Registering new values
  40. if (($action == 'set') && ! empty($id))
  41. $object->setValueFrom($field, $value, $element, $id);