37'@phan-var-force array<string,mixed> $parameters';
41 print
"Error, template page can't be called as URL";
45if (!is_object($form)) {
54<!-- BEGIN PHP TEMPLATE core/tpl/extrafields_view.tpl.php to show formObjectOptions + extrafields -->
56if (!isset($parameters) || !is_array($parameters)) {
57 $parameters = array();
60 $parameters[
'colspan'] =
' colspan="'.$cols.
'"';
62if (!empty($cols) && !isset($parameters[
'cols'])) {
63 $parameters[
'cols'] = $cols;
64} elseif (isset($parameters[
'cols'])) {
65 $cols = $parameters[
'cols'];
68 $parameters[
'socid'] =
$object->fk_soc;
70$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
71print $hookmanager->resPrint;
78if (empty($reshook) && !empty(
$object->table_element) && isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label'])) {
80 $extrafields_collapse_num =
'';
85 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $tmpkeyextra => $tmplabelextra) {
90 if ($enabled && isset($extrafields->attributes[
$object->table_element][
'enabled'][$tmpkeyextra])) {
91 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'enabled'][$tmpkeyextra], 1, 1,
'2');
93 if ($enabled && isset($extrafields->attributes[
$object->table_element][
'list'][$tmpkeyextra])) {
94 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'list'][$tmpkeyextra], 1, 1,
'2');
98 if ($perms && isset($extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra])) {
99 $perms = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra], 1, 1,
'1');
103 if (empty($enabled)) {
106 if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) {
116 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$tmpkeyextra])) {
117 $langs->load($extrafields->attributes[
$object->table_element][
'langfile'][$tmpkeyextra]);
119 if ($action ==
'edit_extras') {
120 $value = (GETPOSTISSET(
"options_".$tmpkeyextra) ?
GETPOST(
"options_".$tmpkeyextra) : (isset(
$object->array_options[
"options_".$tmpkeyextra]) ?
$object->array_options[
"options_".$tmpkeyextra] :
''));
122 $value = (isset(
$object->array_options[
"options_".$tmpkeyextra]) ?
$object->array_options[
"options_".$tmpkeyextra] :
'');
127 if ($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra] ==
'separate') {
128 $extrafields_collapse_num = $tmpkeyextra;
130 print $extrafields->showSeparator($tmpkeyextra,
$object);
134 $collapse_group = $extrafields_collapse_num.(!empty(
$object->id) ?
'_'.$object->id :
'');
136 print
'<tr class="trextrafields_collapse'.$collapse_group;
140 if ($extrafields_collapse_num && $i == count($extrafields->attributes[
$object->table_element][
'label'])) {
141 print
' trextrafields_collapse_last';
144 if (isset($extrafields->expand_display) && empty($extrafields->expand_display[$collapse_group])) {
145 print
' style="display: none;"';
150 print
'<table class="nobordernopadding centpercent">';
154 if ((!empty($action) && ($action ==
'create' || $action ==
'edit')) && !empty($extrafields->attributes[
$object->table_element][
'required'][$tmpkeyextra])) {
155 print
' fieldrequired';
158 if (!empty($extrafields->attributes[
$object->table_element][
'help'][$tmpkeyextra])) {
160 $tmptooltip = explode(
':', $extrafields->attributes[
$object->table_element][
'help'][$tmpkeyextra]);
161 print $form->textwithpicto($langs->trans($tmplabelextra), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.$tmpkeyextra.
'_'.$tmptooltip[1]));
163 print $langs->trans($tmplabelextra);
169 $permwriteobject =
false;
170 $keyforperm =
$object->element;
172 if (
$object->element ==
'fichinter') {
173 $keyforperm =
'ficheinter';
175 if (
$object->element ==
'product') {
176 $keyforperm =
'produit';
178 if (
$object->element ==
'project') {
179 $keyforperm =
'projet';
181 if (isset($user->rights->$keyforperm)) {
182 $permwriteobject = $user->hasRight($keyforperm,
'creer') || $user->hasRight($keyforperm,
'create') || $user->hasRight($keyforperm,
'write');
184 if (
$object->element ==
'order_supplier') {
186 $permwriteobject = $user->hasRight(
'fournisseur',
'commande',
'creer');
188 $permwriteobject = $user->hasRight(
'supplier_order',
'creer');
191 if (
$object->element ==
'invoice_supplier') {
193 $permwriteobject = $user->hasRight(
'fournisseur',
'facture',
'creer');
195 $permwriteobject = $user->hasRight(
'supplier_invoice',
'creer');
198 if (
$object->element ==
'shipping') {
199 $permwriteobject = $user->hasRight(
'expedition',
'creer');
201 if (
$object->element ==
'delivery') {
202 $permwriteobject = $user->hasRight(
'expedition',
'delivery',
'creer');
204 if (
$object->element ==
'productlot') {
205 $permwriteobject = $user->hasRight(
'stock',
'creer');
207 if (
$object->element ==
'facturerec') {
208 $permwriteobject = $user->hasRight(
'facture',
'creer');
210 if (
$object->element ==
'mo') {
211 $permwriteobject = $user->hasRight(
'mrp',
'write');
213 if (
$object->element ==
'contact') {
214 $permwriteobject = $user->hasRight(
'societe',
'contact',
'creer');
216 if (
$object->element ==
'salary') {
217 $permwriteobject = $user->hasRight(
'salaries',
'write');
219 if (
$object->element ==
'member') {
220 $permwriteobject = $user->hasRight(
'adherent',
'creer');
225 $permtoeditextrafield = $perms;
226 if (!isset($extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra])) {
227 $permtoeditextrafield = $permwriteobject;
231 if (($isdraft || !empty($extrafields->attributes[
$object->table_element][
'alwayseditable'][$tmpkeyextra]))
232 && $permtoeditextrafield && $enabled != 5 && ($action !=
'edit_extras' ||
GETPOST(
'attribute') != $tmpkeyextra)
233 && empty($extrafields->attributes[
$object->table_element][
'computed'][$tmpkeyextra])) {
234 $fieldid = empty($forcefieldid) ?
'id' : $forcefieldid;
235 $valueid = empty($forceobjectid) ?
$object->id : $forceobjectid;
236 if (
$object->table_element ==
'societe') {
240 print
'<td class="right">';
241 if (
isModEnabled(
"ai") && !empty($extrafields->attributes[
$object->table_element][
"aiprompt"][$tmpkeyextra])) {
242 $showlinktoai =
"extrafieldfiller_".$tmpkeyextra;
243 $showlinktoailabel = $langs->trans(
"FillExtrafieldWithAi");
244 $htmlname = !empty(
$object->id) ?
$object->element.
'_extras_'.$tmpkeyextra.
'_'.
$object->id :
"options_".$tmpkeyextra;
245 $onlyenhancements =
"textgenerationextrafield";
246 $morecss =
"editfielda";
247 $aiprompt = $extrafields->attributes[
$object->table_element][
"aiprompt"][$tmpkeyextra];
251 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
254 $(document).ready(function() {
255 $("#'.$htmlname.
'").on("change", function () {
256 value = $(this).html();
260 url: "'. DOL_URL_ROOT.
'/core/ajax/updateextrafield.php",
261 data: {"token": "'.currentToken().
'", "objectType": "'.
$object->element.
'", "objectId": "'.
$object->id.
'", "field": "'.$tmpkeyextra.
'", "value": value},
262 success: function(response) {
263 console.log("Extrafield "+'.$tmpkeyextra.
'+" successfully updated");
270 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?'.$fieldid.
'='.$valueid.
'&action=edit_extras&token='.newToken().
'&attribute='.$tmpkeyextra.
'&ignorecollapsesetup=1">'.
img_edit().
'</a>';
273 print
'</tr></table>';
276 $cssview = !empty($extrafields->attributes[
$object->table_element][
'cssview'][$tmpkeyextra]) ? ($extrafields->attributes[
$object->table_element][
'cssview'][$tmpkeyextra] .
' ') :
'';
279 print
'<td id="' . $html_id .
'" class="valuefield ' . $cssview .
$object->element .
'_extras_' . $tmpkeyextra .
' wordbreakimp"' . (!empty($cols) ?
' colspan="' . $cols .
'"' :
'') .
'>';
282 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra], array(
'date'))) {
283 $datenotinstring = empty(
$object->array_options[
'options_'.$tmpkeyextra]) ?
'' :
$object->array_options[
'options_'.$tmpkeyextra];
285 if (!empty(
$object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric(
$object->array_options[
'options_'.$tmpkeyextra])) {
286 $datenotinstring =
$db->jdate($datenotinstring);
289 $value = GETPOSTISSET(
"options_".$tmpkeyextra) ?
dol_mktime(12, 0, 0,
GETPOSTINT(
"options_".$tmpkeyextra.
"month"),
GETPOSTINT(
"options_".$tmpkeyextra.
"day"),
GETPOSTINT(
"options_".$tmpkeyextra.
"year")) : $datenotinstring;
291 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra], array(
'datetime'))) {
292 $datenotinstring = empty(
$object->array_options[
'options_'.$tmpkeyextra]) ?
'' :
$object->array_options[
'options_'.$tmpkeyextra];
294 if (!empty(
$object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric(
$object->array_options[
'options_'.$tmpkeyextra])) {
295 $datenotinstring =
$db->jdate($datenotinstring);
298 $value = GETPOSTISSET(
"options_".$tmpkeyextra) ?
dol_mktime(
GETPOSTINT(
"options_".$tmpkeyextra.
"hour"),
GETPOSTINT(
"options_".$tmpkeyextra.
"min"),
GETPOSTINT(
"options_".$tmpkeyextra.
"sec"),
GETPOSTINT(
"options_".$tmpkeyextra.
"month"),
GETPOSTINT(
"options_".$tmpkeyextra.
"day"),
GETPOSTINT(
"options_".$tmpkeyextra.
"year"),
'tzuserrel') : $datenotinstring;
302 if ($action ==
'edit_extras' && $permtoeditextrafield &&
GETPOST(
'attribute',
'restricthtml') == $tmpkeyextra) {
305 if (
$object->table_element ==
'societe') {
308 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"] .
'?' . $fieldid .
'=' .
$object->id .
'" method="post" name="formextra">';
309 print
'<input type="hidden" name="action" value="update_extras">';
310 print
'<input type="hidden" name="attribute" value="'.$tmpkeyextra.
'">';
311 print
'<input type="hidden" name="token" value="'.newToken().
'">';
312 print
'<input type="hidden" name="'.$fieldid.
'" value="'.
$object->id.
'">';
313 print
'<input type="hidden" name="page_y" value="">';
314 print $extrafields->showInputField($tmpkeyextra, $value,
'',
'',
'',
'',
$object,
$object->table_element);
316 print
'<input type="submit" class="button reposition" value="'.dolPrintHTMLForAttribute($langs->trans(
'Modify')).
'">';
321 if (empty($formai) || $formai instanceof
FormAI) {
322 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
325 print $formai->getAjaxAICallFunction();
330 print $extrafields->showOutputField($tmpkeyextra, $value,
'',
$object->table_element,
null,
$object);
342 if (!empty(
$conf->use_javascript_ajax)) {
346 jQuery(document).ready(function() {
347 setListDependencies();
353<!-- 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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
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.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...