41 print
"Error, template page can't be called as URL";
45if (!is_object($form)) {
46 $form =
new Form($db);
50<!-- BEGIN PHP TEMPLATE core/tpl/extrafields_view.tpl.php -->
52if (!isset($parameters) || !is_array($parameters)) {
53 $parameters = array();
56 $parameters[
'colspan'] =
' colspan="'.$cols.
'"';
58if (!empty($cols) && !isset($parameters[
'cols'])) {
59 $parameters[
'cols'] = $cols;
60} elseif (isset($parameters[
'cols'])) {
61 $cols = $parameters[
'cols'];
64 $parameters[
'socid'] =
$object->fk_soc;
66$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
67print $hookmanager->resPrint;
74if (empty($reshook) && !empty(
$object->table_element) && isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label'])) {
76 $extrafields_collapse_num =
'';
81 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $tmpkeyextra => $tmplabelextra) {
86 if ($enabled && isset($extrafields->attributes[
$object->table_element][
'enabled'][$tmpkeyextra])) {
87 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'enabled'][$tmpkeyextra], 1, 1,
'2');
89 if ($enabled && isset($extrafields->attributes[
$object->table_element][
'list'][$tmpkeyextra])) {
90 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'list'][$tmpkeyextra], 1, 1,
'2');
94 if ($perms && isset($extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra])) {
95 $perms = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra], 1, 1,
'1');
99 if (empty($enabled)) {
102 if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) {
112 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$tmpkeyextra])) {
113 $langs->load($extrafields->attributes[
$object->table_element][
'langfile'][$tmpkeyextra]);
115 if ($action ==
'edit_extras') {
116 $value = (GETPOSTISSET(
"options_".$tmpkeyextra) ?
GETPOST(
"options_".$tmpkeyextra) : (isset(
$object->array_options[
"options_".$tmpkeyextra]) ?
$object->array_options[
"options_".$tmpkeyextra] :
''));
118 $value = (isset(
$object->array_options[
"options_".$tmpkeyextra]) ?
$object->array_options[
"options_".$tmpkeyextra] :
'');
123 if ($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra] ==
'separate') {
124 $extrafields_collapse_num = $tmpkeyextra;
126 print $extrafields->showSeparator($tmpkeyextra,
$object);
130 $collapse_group = $extrafields_collapse_num.(!empty(
$object->id) ?
'_'.$object->id :
'');
132 print
'<tr class="trextrafields_collapse'.$collapse_group;
136 if ($extrafields_collapse_num && $i == count($extrafields->attributes[
$object->table_element][
'label'])) {
137 print
' trextrafields_collapse_last';
140 if (isset($extrafields->expand_display) && empty($extrafields->expand_display[$collapse_group])) {
141 print
' style="display: none;"';
146 print
'<table class="nobordernopadding centpercent">';
150 if ((!empty($action) && ($action ==
'create' || $action ==
'edit')) && !empty($extrafields->attributes[
$object->table_element][
'required'][$tmpkeyextra])) {
151 print
' fieldrequired';
154 if (!empty($extrafields->attributes[
$object->table_element][
'help'][$tmpkeyextra])) {
156 $tmptooltip = explode(
':', $extrafields->attributes[
$object->table_element][
'help'][$tmpkeyextra]);
157 print $form->textwithpicto($langs->trans($tmplabelextra), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.$tmpkeyextra.
'_'.$tmptooltip[1]));
159 print $langs->trans($tmplabelextra);
165 $permwriteobject =
false;
166 $keyforperm =
$object->element;
168 if (
$object->element ==
'fichinter') {
169 $keyforperm =
'ficheinter';
171 if (
$object->element ==
'product') {
172 $keyforperm =
'produit';
174 if (
$object->element ==
'project') {
175 $keyforperm =
'projet';
177 if (isset($user->rights->$keyforperm)) {
178 $permwriteobject = $user->hasRight($keyforperm,
'creer') || $user->hasRight($keyforperm,
'create') || $user->hasRight($keyforperm,
'write');
180 if (
$object->element ==
'order_supplier') {
182 $permwriteobject = $user->hasRight(
'fournisseur',
'commande',
'creer');
184 $permwriteobject = $user->hasRight(
'supplier_order',
'creer');
187 if (
$object->element ==
'invoice_supplier') {
189 $permwriteobject = $user->hasRight(
'fournisseur',
'facture',
'creer');
191 $permwriteobject = $user->hasRight(
'supplier_invoice',
'creer');
194 if (
$object->element ==
'shipping') {
195 $permwriteobject = $user->hasRight(
'expedition',
'creer');
197 if (
$object->element ==
'delivery') {
198 $permwriteobject = $user->hasRight(
'expedition',
'delivery',
'creer');
200 if (
$object->element ==
'productlot') {
201 $permwriteobject = $user->hasRight(
'stock',
'creer');
203 if (
$object->element ==
'facturerec') {
204 $permwriteobject = $user->hasRight(
'facture',
'creer');
206 if (
$object->element ==
'mo') {
207 $permwriteobject = $user->hasRight(
'mrp',
'write');
209 if (
$object->element ==
'contact') {
210 $permwriteobject = $user->hasRight(
'societe',
'contact',
'creer');
212 if (
$object->element ==
'salary') {
213 $permwriteobject = $user->hasRight(
'salaries',
'write');
215 if (
$object->element ==
'member') {
216 $permwriteobject = $user->hasRight(
'adherent',
'creer');
221 $permtoeditextrafield = $perms;
222 if (!isset($extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra])) {
223 $permtoeditextrafield = $permwriteobject;
227 if (($isdraft || !empty($extrafields->attributes[
$object->table_element][
'alwayseditable'][$tmpkeyextra]))
228 && $permtoeditextrafield && $enabled != 5 && ($action !=
'edit_extras' ||
GETPOST(
'attribute') != $tmpkeyextra)
229 && empty($extrafields->attributes[
$object->table_element][
'computed'][$tmpkeyextra])) {
230 $fieldid = empty($forcefieldid) ?
'id' : $forcefieldid;
231 $valueid = empty($forceobjectid) ?
$object->id : $forceobjectid;
232 if (
$object->table_element ==
'societe') {
236 print
'<td class="right">';
237 if (
isModEnabled(
"ai") && !empty($extrafields->attributes[
$object->table_element][
"aiprompt"][$tmpkeyextra])) {
238 $showlinktoai =
"extrafieldfiller_".$tmpkeyextra;
239 $showlinktoailabel = $langs->trans(
"FillExtrafieldWithAi");
240 $htmlname = !empty(
$object->id) ?
$object->element.
'_extras_'.$tmpkeyextra.
'_'.
$object->id :
"options_".$tmpkeyextra;
241 $onlyenhancements =
"textgenerationextrafield";
242 $morecss =
"editfielda";
243 $aiprompt = $extrafields->attributes[
$object->table_element][
"aiprompt"][$tmpkeyextra];
247 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
250 $(document).ready(function() {
251 $("#'.$htmlname.
'").on("change", function () {
252 value = $(this).html();
256 url: "'. DOL_URL_ROOT.
'/core/ajax/updateextrafield.php",
257 data: {"token": "'.
currentToken().
'", "objectType": "'.
$object->element.
'", "objectId": "'.
$object->id.
'", "field": "'.$tmpkeyextra.
'", "value": value},
258 success: function(response) {
259 console.log("Extrafield "+'.$tmpkeyextra.
'+" successfully updated");
266 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>';
269 print
'</tr></table>';
272 $cssview = !empty($extrafields->attributes[
$object->table_element][
'cssview'][$tmpkeyextra]) ? ($extrafields->attributes[
$object->table_element][
'cssview'][$tmpkeyextra] .
' ') :
'';
275 print
'<td id="' . $html_id .
'" class="valuefield ' . $cssview .
$object->element .
'_extras_' . $tmpkeyextra .
' wordbreakimp"' . (!empty($cols) ?
' colspan="' . $cols .
'"' :
'') .
'>';
278 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra], array(
'date'))) {
279 $datenotinstring = empty(
$object->array_options[
'options_'.$tmpkeyextra]) ?
'' :
$object->array_options[
'options_'.$tmpkeyextra];
281 if (!empty(
$object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric(
$object->array_options[
'options_'.$tmpkeyextra])) {
282 $datenotinstring = $db->jdate($datenotinstring);
285 $value = ($action ==
'edit_extras' && GETPOSTISSET(
"options_".$tmpkeyextra)) ?
dol_mktime(12, 0, 0,
GETPOSTINT(
"options_".$tmpkeyextra.
"month"),
GETPOSTINT(
"options_".$tmpkeyextra.
"day"),
GETPOSTINT(
"options_".$tmpkeyextra.
"year")) : $datenotinstring;
287 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra], array(
'datetime'))) {
288 $datenotinstring = empty(
$object->array_options[
'options_'.$tmpkeyextra]) ?
'' :
$object->array_options[
'options_'.$tmpkeyextra];
290 if (!empty(
$object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric(
$object->array_options[
'options_'.$tmpkeyextra])) {
291 $datenotinstring = $db->jdate($datenotinstring);
294 $value = ($action ==
'edit_extras' && 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;
298 if ($action ==
'edit_extras' && $permtoeditextrafield &&
GETPOST(
'attribute',
'restricthtml') == $tmpkeyextra) {
300 $fieldid = empty($forcefieldid) ?
'id' : $forcefieldid;
301 $valueid = empty($forceobjectid) ?
$object->id : $forceobjectid;
302 if (
$object->table_element ==
'societe') {
305 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"] .
'?' . $fieldid .
'=' . $valueid . (empty($moreparam) ?
'' : $moreparam) .
'" method="post" name="formextra">';
306 print
'<input type="hidden" name="action" value="update_extras">';
307 print
'<input type="hidden" name="attribute" value="'.$tmpkeyextra.
'">';
308 print
'<input type="hidden" name="token" value="'.newToken().
'">';
309 print
'<input type="hidden" name="'.$fieldid.
'" value="'.$valueid.
'">';
310 print
'<input type="hidden" name="page_y" value="">';
311 print $extrafields->showInputField($tmpkeyextra, $value,
'',
'',
'',
'',
$object,
$object->table_element);
313 print
'<input type="submit" class="button reposition" value="'.dolPrintHTMLForAttribute($langs->trans(
'Modify')).
'">';
318 if (empty($formai) || $formai instanceof
FormAI) {
319 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
320 $formai =
new FormAI($db);
322 print $formai->getAjaxAICallFunction();
327 print $extrafields->showOutputField($tmpkeyextra, $value,
'',
$object->table_element,
null,
$object);
339 if (!empty($conf->use_javascript_ajax)) {
343 jQuery(document).ready(function() {
344 setListDependencies();
350<!-- 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.
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'.
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...