26if (!defined(
'NOTOKENRENEWAL')) {
27 define(
'NOTOKENRENEWAL',
'1');
29if (!defined(
'NOREQUIREMENU')) {
30 define(
'NOREQUIREMENU',
'1');
32if (!defined(
'NOREQUIREAJAX')) {
33 define(
'NOREQUIREAJAX',
'1');
35if (!defined(
'NOREQUIRESOC')) {
36 define(
'NOREQUIRESOC',
'1');
40require
'../../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
50$field =
GETPOST(
'field',
'alpha', 2);
51$element =
GETPOST(
'element',
'alpha', 2);
52$table_element =
GETPOST(
'table_element',
'alpha', 2);
53$fk_element =
GETPOST(
'fk_element',
'alpha', 2);
68print
'field='.$field.
' - element='.$element.
' - table_element='.$table_element.
' - id/fk_element='.$fk_element.
"\n";
72if (is_numeric($fk_element)) {
73 $id = (int) $fk_element;
75 $element_ref = $fk_element;
78$object = fetchObjectByElement($id, $element, $element_ref);
79if (!is_object($object)) {
85$usesublevelpermission = ($module != $element ? $element :
'');
86if ($usesublevelpermission && !$user->hasRight($module, $element)) {
87 $usesublevelpermission =
'';
89print
'object->id='.$object->id.
' - object->module='.
$object->module.
' - object->element='.
$object->element.
' - object->table_element='.
$object->table_element.
' - usesublevelpermission='.$usesublevelpermission.
"\n";
112if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) {
113 $field = preg_replace(
'/^editval_/',
'', $field);
115 $type =
GETPOST(
'type',
'alpha', 2);
117 $value = ($type ==
'ckeditor' ?
GETPOST(
'value',
'', 2) :
GETPOST(
'value',
'alpha', 2));
120 $ext_element =
'notused';
125 $newelement = $element;
133 if ($element !=
'order_supplier' && $element !=
'invoice_supplier' && preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
135 $subelement = $regs[2];
138 if ($element ==
'propal') {
139 $newelement =
'propale';
140 } elseif ($element ==
'fichinter') {
141 $newelement =
'ficheinter';
142 } elseif ($element ==
'product') {
143 $newelement =
'produit';
144 } elseif ($element ==
'member') {
145 $newelement =
'adherent';
146 } elseif ($element ==
'order_supplier') {
147 $newelement =
'fournisseur';
148 $subelement =
'commande';
149 } elseif ($element ==
'invoice_supplier') {
150 $newelement =
'fournisseur';
151 $subelement =
'facture';
153 $newelement = $element;
156 $_POST[
'action'] =
'update';
158 $feature = $newelement;
159 $feature2 = $subelement;
160 $object_id = $fk_element;
161 if ($feature ==
'expedition' || $feature ==
'shipping') {
162 $feature =
'commande';
165 if ($feature ==
'shipping') {
166 $feature =
'commande';
168 if ($feature ==
'payment') {
169 $feature =
'facture';
171 if ($feature ==
'payment_supplier') {
172 $feature =
'fournisseur';
173 $feature2 =
'facture';
177 $check_access =
restrictedArea($user, $feature, $object_id,
'', (
string) $feature2);
182 $newvalue = trim($value);
184 if ($type ==
'numeric') {
188 if (!is_numeric($newvalue)) {
190 $return[
'error'] = $langs->trans(
'ErrorBadValue');
192 } elseif ($type ==
'datepicker') {
195 $newvalue = ($timestamp / 1000);
198 if (!$error && is_object($object)) {
199 $ret =
$object->setValueFrom($field, $newvalue,
$object->table_element, (
int) $fk_element, $format);
201 if ($type ==
'numeric') {
202 $value =
price($newvalue);
203 } elseif ($type ==
'textarea') {
207 $return[
'value'] = $value;
209 $return[
'error'] =
$object->error;
213 echo json_encode($return);
215 echo $langs->trans(
'NotEnoughPermissions');
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a 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.