actions_lineupdown.inc.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
  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 <http://www.gnu.org/licenses/>.
  16. * or see http://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/core/actions_lineupdown.inc.php
  20. * \brief Code for actions on moving lines up or down onto object page
  21. */
  22. // $action must be defined
  23. // $permissiontoedit must be defined to permission to edit object
  24. // $object must be defined
  25. // $langs must be defined
  26. // $hidedetails, $hidedesc, $hideref must de defined
  27. if ($action == 'up' && $permissiontoedit)
  28. {
  29. $object->line_up(GETPOST('rowid'));
  30. // Define output language
  31. $outputlangs = $langs;
  32. $newlang = '';
  33. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
  34. if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
  35. if (! empty($newlang)) {
  36. $outputlangs = new Translate("", $conf);
  37. $outputlangs->setDefaultLang($newlang);
  38. }
  39. if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
  40. $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
  41. }
  42. header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid'));
  43. exit();
  44. }
  45. if ($action == 'down' && $permissiontoedit)
  46. {
  47. $object->line_down(GETPOST('rowid'));
  48. // Define output language
  49. $outputlangs = $langs;
  50. $newlang = '';
  51. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
  52. if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
  53. if (! empty($newlang)) {
  54. $outputlangs = new Translate("", $conf);
  55. $outputlangs->setDefaultLang($newlang);
  56. }
  57. if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
  58. $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
  59. }
  60. header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid'));
  61. exit();
  62. }