dolibarr  16.0.5
extraparams.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
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  */
17 
23 if (!defined('NOTOKENRENEWAL')) {
24  define('NOTOKENRENEWAL', '1'); // Disables token renewal
25 }
26 if (!defined('NOREQUIREMENU')) {
27  define('NOREQUIREMENU', '1');
28 }
29 if (!defined('NOREQUIREHTML')) {
30  define('NOREQUIREHTML', '1');
31 }
32 if (!defined('NOREQUIREAJAX')) {
33  define('NOREQUIREAJAX', '1');
34 }
35 if (!defined('NOREQUIRESOC')) {
36  define('NOREQUIRESOC', '1');
37 }
38 
39 include '../../main.inc.php';
40 
41 $id = GETPOST('id', 'int');
42 $element = GETPOST('element', 'alpha');
43 $htmlelement = GETPOST('htmlelement', 'alpha');
44 $type = GETPOST('type', 'alpha');
45 
46 /*
47  * View
48  */
49 
50 top_httphead();
51 
52 print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
53 
54 if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type)) {
55  $value = GETPOST('value', 'alpha');
56  $params = array();
57 
58  dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG);
59 
60  $classpath = $subelement = $element;
61 
62  // For compatibility
63  if ($element == 'order' || $element == 'commande') {
64  $classpath = $subelement = 'commande';
65  } elseif ($element == 'propal') {
66  $classpath = 'comm/propal';
67  $subelement = 'propal';
68  } elseif ($element == 'facture') {
69  $classpath = 'compta/facture';
70  $subelement = 'facture';
71  } elseif ($element == 'contract') {
72  $classpath = $subelement = 'contrat';
73  } elseif ($element == 'shipping') {
74  $classpath = $subelement = 'expedition';
75  } elseif ($element == 'deplacement') {
76  $classpath = 'compta/deplacement';
77  $subelement = 'deplacement';
78  } elseif ($element == 'order_supplier') {
79  $classpath = 'fourn';
80  $subelement = 'fournisseur.commande';
81  } elseif ($element == 'invoice_supplier') {
82  $classpath = 'fourn';
83  $subelement = 'fournisseur.facture';
84  }
85 
86  dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php');
87 
88  if ($element == 'order_supplier') {
89  $classname = 'CommandeFournisseur';
90  } elseif ($element == 'invoice_supplier') {
91  $classname = 'FactureFournisseur';
92  } else {
93  $classname = ucfirst($subelement);
94  }
95 
96  $object = new $classname($db);
97  $object->fetch($id);
98 
99  $params[$htmlelement] = array($type => $value);
100  $object->extraparams = array_merge($object->extraparams, $params);
101 
102  $result = $object->setExtraParameters();
103 }
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1033
top_httphead
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1407
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603