40 print
"Error, template page can't be called as URL";
44if (!is_object($form)) {
45 $form =
new Form($db);
49<!-- BEGIN PHP TEMPLATE core/tpl/extrafields_view.tpl.php -->
51if (!isset($parameters) || !is_array($parameters)) {
52 $parameters = array();
55 $parameters[
'colspan'] =
' colspan="'.$cols.
'"';
57if (!empty($cols) && !isset($parameters[
'cols'])) {
58 $parameters[
'cols'] = $cols;
59} elseif (isset($parameters[
'cols'])) {
60 $cols = $parameters[
'cols'];
63 $parameters[
'socid'] =
$object->fk_soc;
65$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
66print $hookmanager->resPrint;
73if (empty($reshook) && !empty(
$object->table_element) && isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label'])) {
75 $extrafields_collapse_num =
'';
80 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $tmpkeyextra => $tmplabelextra) {
85 if ($enabled && isset($extrafields->attributes[
$object->table_element][
'enabled'][$tmpkeyextra])) {
86 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'enabled'][$tmpkeyextra], 1, 1,
'2');
88 if ($enabled && isset($extrafields->attributes[
$object->table_element][
'list'][$tmpkeyextra])) {
89 $enabled = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'list'][$tmpkeyextra], 1, 1,
'2');
93 if ($perms && isset($extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra])) {
94 $perms = (int)
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra], 1, 1,
'1');
98 if (empty($enabled)) {
101 if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) {
111 if (!empty($extrafields->attributes[
$object->table_element][
'langfile'][$tmpkeyextra])) {
112 $langs->load($extrafields->attributes[
$object->table_element][
'langfile'][$tmpkeyextra]);
114 if ($action ==
'edit_extras') {
115 $value = (GETPOSTISSET(
"options_".$tmpkeyextra) ?
GETPOST(
"options_".$tmpkeyextra) : (isset(
$object->array_options[
"options_".$tmpkeyextra]) ?
$object->array_options[
"options_".$tmpkeyextra] :
''));
117 $value = (isset(
$object->array_options[
"options_".$tmpkeyextra]) ?
$object->array_options[
"options_".$tmpkeyextra] :
'');
122 if ($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra] ==
'separate') {
123 $extrafields_collapse_num = $tmpkeyextra;
125 print $extrafields->showSeparator($tmpkeyextra,
$object);
129 $collapse_group = $extrafields_collapse_num.(!empty(
$object->id) ?
'_'.$object->id :
'');
131 print
'<tr class="trextrafields_collapse'.$collapse_group;
135 if ($extrafields_collapse_num && $i == count($extrafields->attributes[
$object->table_element][
'label'])) {
136 print
' trextrafields_collapse_last';
139 if (isset($extrafields->expand_display) && empty($extrafields->expand_display[$collapse_group])) {
140 print
' style="display: none;"';
145 print
'<table class="nobordernopadding centpercent">';
149 if ((!empty($action) && ($action ==
'create' || $action ==
'edit')) && !empty($extrafields->attributes[
$object->table_element][
'required'][$tmpkeyextra])) {
150 print
' fieldrequired';
153 if (!empty($extrafields->attributes[
$object->table_element][
'help'][$tmpkeyextra])) {
155 $tmptooltip = explode(
':', $extrafields->attributes[
$object->table_element][
'help'][$tmpkeyextra]);
156 print $form->textwithpicto($langs->trans($tmplabelextra), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.$tmpkeyextra.
'_'.$tmptooltip[1]));
158 print $langs->trans($tmplabelextra);
164 $permwriteobject =
false;
165 $keyforperm =
$object->element;
167 if (
$object->element ==
'fichinter') {
168 $keyforperm =
'ficheinter';
170 if (
$object->element ==
'product') {
171 $keyforperm =
'produit';
173 if (
$object->element ==
'project') {
174 $keyforperm =
'projet';
176 if (isset($user->rights->$keyforperm)) {
177 $permwriteobject = $user->hasRight($keyforperm,
'creer') || $user->hasRight($keyforperm,
'create') || $user->hasRight($keyforperm,
'write');
179 if (
$object->element ==
'order_supplier') {
181 $permwriteobject = $user->hasRight(
'fournisseur',
'commande',
'creer');
183 $permwriteobject = $user->hasRight(
'supplier_order',
'creer');
186 if (
$object->element ==
'invoice_supplier') {
188 $permwriteobject = $user->hasRight(
'fournisseur',
'facture',
'creer');
190 $permwriteobject = $user->hasRight(
'supplier_invoice',
'creer');
193 if (
$object->element ==
'shipping') {
194 $permwriteobject = $user->hasRight(
'expedition',
'creer');
196 if (
$object->element ==
'delivery') {
197 $permwriteobject = $user->hasRight(
'expedition',
'delivery',
'creer');
199 if (
$object->element ==
'productlot') {
200 $permwriteobject = $user->hasRight(
'stock',
'creer');
202 if (
$object->element ==
'facturerec') {
203 $permwriteobject = $user->hasRight(
'facture',
'creer');
205 if (
$object->element ==
'mo') {
206 $permwriteobject = $user->hasRight(
'mrp',
'write');
208 if (
$object->element ==
'contact') {
209 $permwriteobject = $user->hasRight(
'societe',
'contact',
'creer');
211 if (
$object->element ==
'salary') {
212 $permwriteobject = $user->hasRight(
'salaries',
'write');
214 if (
$object->element ==
'member') {
215 $permwriteobject = $user->hasRight(
'adherent',
'creer');
220 $permtoeditextrafield = $perms;
221 if (!isset($extrafields->attributes[
$object->table_element][
'perms'][$tmpkeyextra])) {
222 $permtoeditextrafield = $permwriteobject;
226 if (($isdraft || !empty($extrafields->attributes[
$object->table_element][
'alwayseditable'][$tmpkeyextra]))
227 && $permtoeditextrafield && $enabled != 5 && ($action !=
'edit_extras' ||
GETPOST(
'attribute') != $tmpkeyextra)
228 && empty($extrafields->attributes[
$object->table_element][
'computed'][$tmpkeyextra])) {
229 $fieldid = empty($forcefieldid) ?
'id' : $forcefieldid;
230 $valueid = empty($forceobjectid) ?
$object->id : $forceobjectid;
231 if (
$object->table_element ==
'societe') {
235 print
'<td class="right">';
236 if (isModEnabled(
"ai") && !empty($extrafields->attributes[
$object->table_element][
"aiprompt"][$tmpkeyextra])) {
237 $showlinktoai =
"extrafieldfiller_".$tmpkeyextra;
238 $showlinktoailabel = $langs->trans(
"FillExtrafieldWithAi");
239 $htmlname = !empty(
$object->id) ?
$object->element.
'_extras_'.$tmpkeyextra.
'_'.
$object->id :
"options_".$tmpkeyextra;
240 $onlyenhancements =
"textgenerationextrafield";
241 $morecss =
"editfielda";
242 $aiprompt = $extrafields->attributes[
$object->table_element][
"aiprompt"][$tmpkeyextra];
246 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
249 $(document).ready(function() {
250 $("#'.$htmlname.
'").on("change", function () {
251 value = $(this).html();
255 url: "'. DOL_URL_ROOT.
'/core/ajax/updateextrafield.php",
256 data: {"token": "'.
currentToken().
'", "objectType": "'.
$object->element.
'", "objectId": "'.
$object->id.
'", "field": "'.$tmpkeyextra.
'", "value": value},
257 success: function(response) {
258 console.log("Extrafield "+'.$tmpkeyextra.
'+" successfully updated");
265 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?'.$fieldid.
'='.$valueid.
'&action=edit_extras&token='.
newToken().
'&attribute='.$tmpkeyextra.
'&ignorecollapsesetup=1">'.
img_edit().
'</a>';
268 print
'</tr></table>';
271 $cssview = !empty($extrafields->attributes[
$object->table_element][
'cssview'][$tmpkeyextra]) ? ($extrafields->attributes[
$object->table_element][
'cssview'][$tmpkeyextra] .
' ') :
'';
274 print
'<td id="' . $html_id .
'" class="valuefield ' . $cssview .
$object->element .
'_extras_' . $tmpkeyextra .
' wordbreakimp"' . (!empty($cols) ?
' colspan="' . $cols .
'"' :
'') .
'>';
277 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra], array(
'date'))) {
278 $datenotinstring = empty(
$object->array_options[
'options_'.$tmpkeyextra]) ?
'' :
$object->array_options[
'options_'.$tmpkeyextra];
280 if (!empty(
$object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric(
$object->array_options[
'options_'.$tmpkeyextra])) {
281 $datenotinstring = $db->jdate($datenotinstring);
284 $value = GETPOSTISSET(
"options_".$tmpkeyextra) ?
dol_mktime(12, 0, 0,
GETPOSTINT(
"options_".$tmpkeyextra.
"month"),
GETPOSTINT(
"options_".$tmpkeyextra.
"day"),
GETPOSTINT(
"options_".$tmpkeyextra.
"year")) : $datenotinstring;
286 if (in_array($extrafields->attributes[
$object->table_element][
'type'][$tmpkeyextra], array(
'datetime'))) {
287 $datenotinstring = empty(
$object->array_options[
'options_'.$tmpkeyextra]) ?
'' :
$object->array_options[
'options_'.$tmpkeyextra];
289 if (!empty(
$object->array_options[
'options_'.$tmpkeyextra]) && !is_numeric(
$object->array_options[
'options_'.$tmpkeyextra])) {
290 $datenotinstring = $db->jdate($datenotinstring);
293 $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;
297 if ($action ==
'edit_extras' && $permtoeditextrafield &&
GETPOST(
'attribute',
'restricthtml') == $tmpkeyextra) {
300 if (
$object->table_element ==
'societe') {
303 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"] .
'?' . $fieldid .
'=' .
$object->id .
'" method="post" name="formextra">';
304 print
'<input type="hidden" name="action" value="update_extras">';
305 print
'<input type="hidden" name="attribute" value="'.$tmpkeyextra.
'">';
306 print
'<input type="hidden" name="token" value="'.newToken().
'">';
307 print
'<input type="hidden" name="'.$fieldid.
'" value="'.
$object->id.
'">';
308 print $extrafields->showInputField($tmpkeyextra, $value,
'',
'',
'',
'',
$object,
$object->table_element);
310 print
'<input type="submit" class="button" value="'.dolPrintHTMLForAttribute($langs->trans(
'Modify')).
'">';
315 if (empty($formai) || $formai instanceof
FormAI) {
316 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
317 $formai =
new FormAI($db);
319 print $formai->getAjaxAICallFunction();
324 print $extrafields->showOutputField($tmpkeyextra, $value,
'',
$object->table_element,
null,
$object);
336 if (!empty(
$conf->use_javascript_ajax)) {
340 jQuery(document).ready(function() {
341 setListDependencies();
347<!-- END PHP TEMPLATE core/tpl/extrafields_view.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...