24if (!defined(
'NOTOKENRENEWAL')) {
25 define(
'NOTOKENRENEWAL',
'1');
27if (!defined(
'NOREQUIREMENU')) {
28 define(
'NOREQUIREMENU',
'1');
30if (!defined(
'NOREQUIREAJAX')) {
31 define(
'NOREQUIREAJAX',
'1');
33if (!defined(
'NOREQUIRESOC')) {
34 define(
'NOREQUIRESOC',
'1');
38require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
41$field =
GETPOST(
'field',
'alpha', 2);
42$element =
GETPOST(
'element',
'alpha', 2);
43$table_element =
GETPOST(
'table_element',
'alpha', 2);
44$fk_element =
GETPOST(
'fk_element',
'alpha', 2);
64$usesublevelpermission = ($module != $element ? $element :
'');
65if ($usesublevelpermission && !$user->hasRight($module, $element)) {
66 $usesublevelpermission =
'';
92if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) {
93 $ext_element =
GETPOST(
'ext_element',
'alpha', 2);
94 $field = substr($field, 8);
95 $type =
GETPOST(
'type',
'alpha', 2);
96 $value = ($type ==
'ckeditor' ?
GETPOST(
'value',
'', 2) :
GETPOST(
'value',
'alpha', 2));
97 $loadmethod =
GETPOST(
'loadmethod',
'alpha', 2);
98 $savemethod =
GETPOST(
'savemethod',
'alpha', 2);
99 $savemethodname = (!empty($savemethod) ? $savemethod :
'setValueFrom');
100 $newelement = $element;
107 if ($element !=
'order_supplier' && $element !=
'invoice_supplier' && preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
109 $subelement = $regs[2];
112 if ($element ==
'propal') {
113 $newelement =
'propale';
114 } elseif ($element ==
'fichinter') {
115 $newelement =
'ficheinter';
116 } elseif ($element ==
'product') {
117 $newelement =
'produit';
118 } elseif ($element ==
'member') {
119 $newelement =
'adherent';
120 } elseif ($element ==
'order_supplier') {
121 $newelement =
'fournisseur';
122 $subelement =
'commande';
123 } elseif ($element ==
'invoice_supplier') {
124 $newelement =
'fournisseur';
125 $subelement =
'facture';
127 $newelement = $element;
130 $_POST[
'action'] =
'update';
132 $feature = $newelement;
133 $feature2 = $subelement;
134 $object_id = $fk_element;
135 if ($feature ==
'expedition' || $feature ==
'shipping') {
136 $feature =
'commande';
139 if ($feature ==
'shipping') {
140 $feature =
'commande';
142 if ($feature ==
'payment') {
143 $feature =
'facture';
145 if ($feature ==
'payment_supplier') {
146 $feature =
'fournisseur';
147 $feature2 =
'facture';
151 $check_access =
restrictedArea($user, $feature, $object_id,
'', $feature2);
162 $newvalue = trim($value);
164 if ($type ==
'numeric') {
168 if (!is_numeric($newvalue)) {
170 $return[
'error'] = $langs->trans(
'ErrorBadValue');
172 } elseif ($type ==
'datepicker') {
175 $newvalue = ($timestamp / 1000);
176 } elseif ($type ==
'select') {
177 $loadmethodname =
'load_cache_'.$loadmethod;
178 $loadcachename =
'cache_'.$loadmethod;
179 $loadviewname =
'view_'.$loadmethod;
181 $form =
new Form($db);
182 if (method_exists($form, $loadmethodname)) {
183 $ret = $form->$loadmethodname();
185 $loadcache = $form->$loadcachename;
186 $value = $loadcache[$newvalue];
188 if (!empty($form->$loadviewname)) {
189 $loadview = $form->$loadviewname;
190 $view = $loadview[$newvalue];
194 $return[
'error'] = $form->error;
197 $module = $subelement = $ext_element;
198 if (preg_match(
'/^([^_]+)_([^_]+)/i', $ext_element, $regs)) {
200 $subelement = $regs[2];
204 $classname =
'Actions'.ucfirst($subelement);
206 $ret =
$object->$loadmethodname();
208 $loadcache =
$object->$loadcachename;
209 $value = $loadcache[$newvalue];
211 if (!empty(
$object->$loadviewname)) {
212 $loadview =
$object->$loadviewname;
213 $view = $loadview[$newvalue];
217 $return[
'error'] =
$object->error;
223 if ((isset($object) && !is_object($object)) || empty($savemethod)) {
229 $object->ext_fk_element = $newvalue;
230 $object->ext_element = $ext_element;
231 $object->fk_element = $fk_element;
234 $ret =
$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format);
236 if ($type ==
'numeric') {
237 $value =
price($newvalue);
238 } elseif ($type ==
'textarea') {
242 $return[
'value'] = $value;
243 $return[
'view'] = (!empty($view) ? $view : $value);
245 $return[
'error'] =
$object->error;
249 echo json_encode($return);
251 echo $langs->trans(
'NotEnoughPermissions');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class of a generic business object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
fetchObjectByElement($element_id, $element_type, $element_ref='', $useCache=0, $maxCacheByType=10)
Fetch an object from its id and element_type Inclusion of classes is automatic.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.