25if (!defined(
'NOTOKENRENEWAL')) {
26 define(
'NOTOKENRENEWAL',
'1');
28if (!defined(
'NOREQUIREMENU')) {
29 define(
'NOREQUIREMENU',
'1');
31if (!defined(
'NOREQUIREAJAX')) {
32 define(
'NOREQUIREAJAX',
'1');
34if (!defined(
'NOREQUIRESOC')) {
35 define(
'NOREQUIRESOC',
'1');
39require
'../../main.inc.php';
40require_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;
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";
108if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) {
109 $field = preg_replace(
'/^editval_/',
'', $field);
111 $type =
GETPOST(
'type',
'alpha', 2);
113 $value = ($type ==
'ckeditor' ?
GETPOST(
'value',
'', 2) :
GETPOST(
'value',
'alpha', 2));
116 $ext_element =
'notused';
120 $savemethodname =
'setValueFrom';
122 $newelement = $element;
130 if ($element !=
'order_supplier' && $element !=
'invoice_supplier' && preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
132 $subelement = $regs[2];
135 if ($element ==
'propal') {
136 $newelement =
'propale';
137 } elseif ($element ==
'fichinter') {
138 $newelement =
'ficheinter';
139 } elseif ($element ==
'product') {
140 $newelement =
'produit';
141 } elseif ($element ==
'member') {
142 $newelement =
'adherent';
143 } elseif ($element ==
'order_supplier') {
144 $newelement =
'fournisseur';
145 $subelement =
'commande';
146 } elseif ($element ==
'invoice_supplier') {
147 $newelement =
'fournisseur';
148 $subelement =
'facture';
150 $newelement = $element;
153 $_POST[
'action'] =
'update';
155 $feature = $newelement;
156 $feature2 = $subelement;
157 $object_id = $fk_element;
158 if ($feature ==
'expedition' || $feature ==
'shipping') {
159 $feature =
'commande';
162 if ($feature ==
'shipping') {
163 $feature =
'commande';
165 if ($feature ==
'payment') {
166 $feature =
'facture';
168 if ($feature ==
'payment_supplier') {
169 $feature =
'fournisseur';
170 $feature2 =
'facture';
174 $check_access =
restrictedArea($user, $feature, $object_id,
'', (
string) $feature2);
179 $newvalue = trim($value);
181 if ($type ==
'numeric') {
185 if (!is_numeric($newvalue)) {
187 $return[
'error'] = $langs->trans(
'ErrorBadValue');
189 } elseif ($type ==
'datepicker') {
192 $newvalue = ($timestamp / 1000);
198 $object->ext_fk_element = $newvalue;
199 $object->ext_element = $ext_element;
200 $object->fk_element = $fk_element;
203 $ret =
$object->setValueFrom($field, $newvalue,
$object->table_element, (
int) $fk_element, $format);
205 if ($type ==
'numeric') {
206 $value =
price($newvalue);
207 } elseif ($type ==
'textarea') {
211 $return[
'value'] = $value;
213 $return[
'error'] =
$object->error;
217 echo json_encode($return);
219 echo $langs->trans(
'NotEnoughPermissions');
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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.
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.