row.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /* Copyright (C) 2010-2015 Regis Houssin <regis.houssin@capnetworks.com>
  3. * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  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 <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/core/ajax/row.php
  20. * \brief File to return Ajax response on Row move.
  21. * This ajax page is called when doing an up or down drag and drop.
  22. */
  23. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disable token renewal
  24. if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
  25. if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
  26. if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
  27. if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  28. if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
  29. if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks
  30. require '../../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
  32. /*
  33. * View
  34. */
  35. top_httphead();
  36. print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
  37. // Registering the location of boxes
  38. if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST['table_element_line']) && ! empty($_POST['table_element_line']))
  39. && (isset($_POST['fk_element']) && ! empty($_POST['fk_element'])) && (isset($_POST['element_id']) && ! empty($_POST['element_id'])) )
  40. {
  41. $roworder=GETPOST('roworder','alpha',2);
  42. $table_element_line=GETPOST('table_element_line','alpha',2);
  43. $fk_element=GETPOST('fk_element','alpha',2);
  44. $element_id=GETPOST('element_id','int',2);
  45. dol_syslog("AjaxRow roworder=".$roworder." table_element_line=".$table_element_line." fk_element=".$fk_element." element_id=".$element_id, LOG_DEBUG);
  46. $rowordertab = explode(',',$roworder);
  47. foreach($rowordertab as $value)
  48. {
  49. if (! empty($value)) $newrowordertab[] = $value;
  50. }
  51. $row=new GenericObject($db);
  52. $row->table_element_line = $table_element_line;
  53. $row->fk_element = $fk_element;
  54. $row->id = $element_id;
  55. $row->line_ajaxorder($newrowordertab);
  56. // Reorder line to have position of chilren lines sharing same counter than parent lines
  57. // This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database.
  58. if (in_array($fk_element,array('fk_facture','fk_propal','fk_commande')))
  59. {
  60. $result=$row->line_order(true);
  61. }
  62. }