actions_lineupdown.inc.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <https://www.gnu.org/licenses/>.
  16. * or see https://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. $object->line_up(GETPOST('rowid'));
  29. // Define output language
  30. $outputlangs = $langs;
  31. $newlang = '';
  32. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
  33. $newlang = GETPOST('lang_id', 'aZ09');
  34. }
  35. if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
  36. $newlang = $object->thirdparty->default_lang;
  37. }
  38. if (!empty($newlang)) {
  39. $outputlangs = new Translate("", $conf);
  40. $outputlangs->setDefaultLang($newlang);
  41. }
  42. if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
  43. $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
  44. }
  45. header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
  46. exit();
  47. }
  48. if ($action == 'down' && $permissiontoedit) {
  49. $object->line_down(GETPOST('rowid'));
  50. // Define output language
  51. $outputlangs = $langs;
  52. $newlang = '';
  53. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
  54. $newlang = GETPOST('lang_id', 'aZ09');
  55. }
  56. if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
  57. $newlang = $object->thirdparty->default_lang;
  58. }
  59. if (!empty($newlang)) {
  60. $outputlangs = new Translate("", $conf);
  61. $outputlangs->setDefaultLang($newlang);
  62. }
  63. if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
  64. $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
  65. }
  66. header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
  67. exit();
  68. }