orderAttribute.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
  3. * Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
  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. if (!defined('NOTOKENRENEWAL')) {
  19. define('NOTOKENRENEWAL', '1'); // Disable token renewal
  20. }
  21. if (!defined('NOREQUIREMENU')) {
  22. define('NOREQUIREMENU', '1');
  23. }
  24. if (!defined('NOREQUIREHTML')) {
  25. define('NOREQUIREHTML', '1');
  26. }
  27. if (!defined('NOREQUIREAJAX')) {
  28. define('NOREQUIREAJAX', '1');
  29. }
  30. if (!defined('NOREQUIRESOC')) {
  31. define('NOREQUIRESOC', '1');
  32. }
  33. if (!defined('NOREQUIRETRAN')) {
  34. define('NOREQUIRETRAN', '1');
  35. }
  36. // Load Dolibarr environment
  37. require '../../main.inc.php';
  38. require DOL_DOCUMENT_ROOT . '/variants/class/ProductAttribute.class.php';
  39. // Security check
  40. if (!isModEnabled('variants')) {
  41. accessforbidden('Module not enabled');
  42. }
  43. if ($user->socid > 0) { // Protection if external user
  44. accessforbidden();
  45. }
  46. $result = restrictedArea($user, 'variants');
  47. /*
  48. * View
  49. */
  50. top_httphead();
  51. print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
  52. // Registering the location of boxes
  53. if (GETPOST('roworder', 'alpha', 3)) {
  54. $roworder = GETPOST('roworder', 'alpha', 3);
  55. dol_syslog("AjaxOrderAttribute roworder=" . $roworder, LOG_DEBUG);
  56. $rowordertab = explode(',', $roworder);
  57. $newrowordertab = array();
  58. foreach ($rowordertab as $value) {
  59. if (!empty($value)) {
  60. $newrowordertab[] = $value;
  61. }
  62. }
  63. $row = new ProductAttribute($db);
  64. $row->attributesAjaxOrder($newrowordertab); // This update field rank or position in table row->table_element_line
  65. } else {
  66. print 'Bad parameters for orderAttribute.php';
  67. }