38'@phan-var-force array<string,mixed> $parameters';
42 print
"Error, template page can't be called as URL";
46if (!is_object($form)) {
47 $form =
new Form($db);
55<!-- BEGIN PHP TEMPLATE core/tpl/extrafields_view.tpl.php to show formObjectOptions + extrafields -->
57if (!isset($parameters) || !is_array($parameters)) {
58 $parameters = array();
61 $parameters[
'colspan'] =
' colspan="'.$cols.
'"';
63if (!empty($cols) && !isset($parameters[
'cols'])) {
64 $parameters[
'cols'] = $cols;
65} elseif (isset($parameters[
'cols'])) {
66 $cols = $parameters[
'cols'];
69 $parameters[
'socid'] =
$object->fk_soc;
71$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
72print $hookmanager->resPrint;
74 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
79if (empty($reshook) && !empty(
$object->table_element) && isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label'])) {
81 $extrafields_collapse_num =
'';
86 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $tmpkeyextra => $tmplabelextra) {
91 if ($enabled && isset($extrafields->attributes[
$object->table_element][
'enabled'][$tmpkeyextra])) {
92 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'enabled'][$tmpkeyextra], 1, 1,
'2');
94 if ($enabled && isset($extrafields->attributes[
$object->table_element][
'list'][$tmpkeyextra])) {
95 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'list'][$tmpkeyextra], 1, 1,
'2');
99 if ($perms && isset($extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra])) {
100 $perms = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra], 1, 1,
'1');
104 if (empty($enabled)) {
107 if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) {
117 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$tmpkeyextra])) {
118 $langs->load($extrafields->attributes[
$object->table_element][
'langfile'][$tmpkeyextra]);
120 if ($action ==
'edit_extras') {
121 $value = (
GETPOSTISSET(
"options_".$tmpkeyextra) ?
GETPOST(
"options_".$tmpkeyextra) : (isset(
$object->array_options[
"options_".$tmpkeyextra]) ?
$object->array_options[
"options_".$tmpkeyextra] :
''));
123 $value = (isset(
$object->array_options[
"options_".$tmpkeyextra]) ?
$object->array_options[
"options_".$tmpkeyextra] :
'');
128 if ($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra] ==
'separate') {
129 $extrafields_collapse_num = $tmpkeyextra;
131 print $extrafields->showSeparator($tmpkeyextra,
$object);
135 $collapse_group = $extrafields_collapse_num.(!empty(
$object->id) ?
'_'.$object->id :
'');
137 print
'<tr class="trextrafields_collapse'.$collapse_group;
141 if ($extrafields_collapse_num && $i == count($extrafields->attributes[
$object->table_element][
'label'])) {
142 print
' trextrafields_collapse_last';
145 if (isset($extrafields->expand_display) && empty($extrafields->expand_display[$collapse_group])) {
146 print
' style="display: none;"';
151 print
'<table class="nobordernopadding centpercent">';
155 if ((!empty($action) && ($action ==
'create' || $action ==
'edit')) && !empty($extrafields->attributes[
$object->table_element][
'required'][$tmpkeyextra])) {
156 print
' fieldrequired';
159 if (!empty($extrafields->attributes[
$object->table_element][
'help'][$tmpkeyextra])) {
161 $tmptooltip = explode(
':', $extrafields->attributes[
$object->table_element][
'help'][$tmpkeyextra]);
162 print $form->textwithpicto($langs->trans($tmplabelextra), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.$tmpkeyextra.
'_'.$tmptooltip[1]));
164 print $langs->trans($tmplabelextra);
170 $permwriteobject =
false;
171 $keyforperm =
$object->element;
173 if (
$object->element ==
'fichinter') {
174 $keyforperm =
'ficheinter';
176 if (
$object->element ==
'product') {
177 $keyforperm =
'produit';
179 if (
$object->element ==
'project') {
180 $keyforperm =
'projet';
182 if (isset($user->rights->$keyforperm)) {
183 $permwriteobject = $user->hasRight($keyforperm,
'creer') || $user->hasRight($keyforperm,
'create') || $user->hasRight($keyforperm,
'write');
185 if (
$object->element ==
'order_supplier') {
187 $permwriteobject = $user->hasRight(
'fournisseur',
'commande',
'creer');
189 $permwriteobject = $user->hasRight(
'supplier_order',
'creer');
192 if (
$object->element ==
'invoice_supplier') {
194 $permwriteobject = $user->hasRight(
'fournisseur',
'facture',
'creer');
196 $permwriteobject = $user->hasRight(
'supplier_invoice',
'creer');
199 if (
$object->element ==
'shipping') {
200 $permwriteobject = $user->hasRight(
'expedition',
'creer');
202 if (
$object->element ==
'delivery') {
203 $permwriteobject = $user->hasRight(
'expedition',
'delivery',
'creer');
205 if (
$object->element ==
'productlot') {
206 $permwriteobject = $user->hasRight(
'stock',
'creer');
208 if (
$object->element ==
'facturerec') {
209 $permwriteobject = $user->hasRight(
'facture',
'creer');
211 if (
$object->element ==
'mo') {
212 $permwriteobject = $user->hasRight(
'mrp',
'write');
214 if (
$object->element ==
'contact') {
215 $permwriteobject = $user->hasRight(
'societe',
'contact',
'creer');
217 if (
$object->element ==
'salary') {
218 $permwriteobject = $user->hasRight(
'salaries',
'write');
220 if (
$object->element ==
'member') {
221 $permwriteobject = $user->hasRight(
'adherent',
'creer');
226 $permtoeditextrafield = $perms;
227 if (!isset($extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra])) {
228 $permtoeditextrafield = $permwriteobject;
232 if (($isdraft || !empty($extrafields->attributes[
$object->table_element][
'alwayseditable'][$tmpkeyextra]))
233 && $permtoeditextrafield && $enabled != 5 && ($action !=
'edit_extras' ||
GETPOST(
'attribute') != $tmpkeyextra)
234 && empty($extrafields->attributes[
$object->table_element][
'computed'][$tmpkeyextra])) {
235 $fieldid = empty($forcefieldid) ?
'id' : $forcefieldid;
236 $valueid = empty($forceobjectid) ?
$object->id : $forceobjectid;
237 if (
$object->table_element ==
'societe') {
241 print
'<td class="right">';
242 if (
isModEnabled(
"ai") && !empty($extrafields->attributes[
$object->table_element][
"aiprompt"][$tmpkeyextra])) {
243 $showlinktoai =
"extrafieldfiller_".$tmpkeyextra;
244 $showlinktoailabel = $langs->trans(
"FillExtrafieldWithAi");
245 $htmlname = !empty(
$object->id) ?
$object->element.
'_extras_'.$tmpkeyextra.
'_'.
$object->id :
"options_".$tmpkeyextra;
246 $onlyenhancements =
"textgenerationextrafield";
247 $morecss =
"editfielda";
248 $aiprompt = $extrafields->attributes[
$object->table_element][
"aiprompt"][$tmpkeyextra];
252 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
255 $(document).ready(function() {
256 $("#'.$htmlname.
'").on("change", function () {
257 value = $(this).html();
261 url: "'. DOL_URL_ROOT.
'/core/ajax/updateextrafield.php",
262 data: {"token": "'.
currentToken().
'", "objectType": "'.
$object->element.
'", "objectId": "'.
$object->id.
'", "field": "'.$tmpkeyextra.
'", "value": value},
263 success: function(response) {
264 console.log("Extrafield "+'.$tmpkeyextra.
'+" successfully updated");
271 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?'.$fieldid.
'='.$valueid.
'&action=edit_extras&token='.
newToken().
'&attribute='.$tmpkeyextra.
'&ignorecollapsesetup=1'.(empty($moreparam) ?
'' : $moreparam).
'">'.img_edit().
'</a>';
274 print
'</tr></table>';
277 $cssview = !empty($extrafields->attributes[
$object->table_element][
'cssview'][$tmpkeyextra]) ? ($extrafields->attributes[
$object->table_element][
'cssview'][$tmpkeyextra] .
' ') :
'';
280 print
'<td id="' . $html_id .
'" class="valuefield ' . $cssview .
$object->element .
'_extras_' . $tmpkeyextra .
' wordbreakimp"' . (!empty($cols) ?
' colspan="' . $cols .
'"' :
'') .
'>';
283 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra], array(
'date'))) {
284 $datenotinstring = empty(
$object->array_options[
'options_'.$tmpkeyextra]) ?
'' :
$object->array_options[
'options_'.$tmpkeyextra];
286 if (!empty(
$object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric(
$object->array_options[
'options_'.$tmpkeyextra])) {
287 $datenotinstring = $db->jdate($datenotinstring);
292 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra], array(
'datetime'))) {
293 $datenotinstring = empty(
$object->array_options[
'options_'.$tmpkeyextra]) ?
'' :
$object->array_options[
'options_'.$tmpkeyextra];
295 if (!empty(
$object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric(
$object->array_options[
'options_'.$tmpkeyextra])) {
296 $datenotinstring = $db->jdate($datenotinstring);
303 if ($action ==
'edit_extras' && $permtoeditextrafield &&
GETPOST(
'attribute',
'restricthtml') == $tmpkeyextra) {
305 $fieldid = empty($forcefieldid) ?
'id' : $forcefieldid;
306 $valueid = empty($forceobjectid) ?
$object->id : $forceobjectid;
307 if (
$object->table_element ==
'societe') {
310 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"] .
'?' . $fieldid .
'=' . $valueid . (empty($moreparam) ?
'' : $moreparam) .
'" method="post" name="formextra">';
311 print
'<input type="hidden" name="action" value="update_extras">';
312 print
'<input type="hidden" name="attribute" value="'.$tmpkeyextra.
'">';
313 print
'<input type="hidden" name="token" value="'.newToken().
'">';
314 print
'<input type="hidden" name="'.$fieldid.
'" value="'.$valueid.
'">';
315 print
'<input type="hidden" name="page_y" value="">';
318 print $extrafields->showInputField($tmpkeyextra, $value,
'',
'',
'',
'',
$object,
$object->table_element, 0, 1);
320 print
'<input type="submit" class="button reposition" value="'.dolPrintHTMLForAttribute($langs->trans(
'Modify')).
'">';
325 if (empty($formai) || $formai instanceof
FormAI) {
326 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
327 $formai =
new FormAI($db);
329 print $formai->getAjaxAICallFunction();
334 print $extrafields->showOutputField($tmpkeyextra, $value,
'',
$object->table_element,
null,
$object);
336 print
'<input type="hidden" value="' . dolPrintHTMLForAttribute($value) .
'" name="options_' .
dol_escape_htmltag($tmpkeyextra) .
'" id="options_' .
dol_escape_htmltag($tmpkeyextra) .
'"/>';
346 if (!empty(
$conf->use_javascript_ajax)) {
350 jQuery(document).ready(function() {
351 setListDependencies();
357<!-- END PHP TEMPLATE core/tpl/extrafields_view.tpl.php -->
if(! $sortfield) if(! $sortorder) $object
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)