dolibarr  19.0.0-dev
actions_lineupdown.inc.php
Go to the documentation of this file.
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 
25 // $action must be defined
26 // $permissiontoedit must be defined to permission to edit object
27 // $object must be defined
28 // $langs must be defined
29 // $hidedetails, $hidedesc, $hideref must de defined
30 
31 if ($action == 'up' && $permissiontoedit) {
32  $object->line_up(GETPOST('rowid'));
33 
34  // Define output language
35  $outputlangs = $langs;
36  $newlang = '';
37  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
38  $newlang = GETPOST('lang_id', 'aZ09');
39  }
40  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
41  $newlang = $object->thirdparty->default_lang;
42  }
43  if (!empty($newlang)) {
44  $outputlangs = new Translate("", $conf);
45  $outputlangs->setDefaultLang($newlang);
46  }
47 
48  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
49  $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
50  }
51 
52  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
53  exit();
54 }
55 
56 if ($action == 'down' && $permissiontoedit) {
57  $object->line_down(GETPOST('rowid'));
58 
59  // Define output language
60  $outputlangs = $langs;
61  $newlang = '';
62  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
63  $newlang = GETPOST('lang_id', 'aZ09');
64  }
65  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
66  $newlang = $object->thirdparty->default_lang;
67  }
68  if (!empty($newlang)) {
69  $outputlangs = new Translate("", $conf);
70  $outputlangs->setDefaultLang($newlang);
71  }
72  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
73  $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
74  }
75 
76  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
77  exit();
78 }
Class to manage translations.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.