43 print
"Error, template page can't be called as URL";
48$langs->load(
"modulebuilder");
50$listofexamplesforlink =
'Societe:societe/class/societe.class.php<br>Contact:contact/class/contact.class.php<br>Product:product/class/product.class.php<br>Project:projet/class/project.class.php<br>...';
54<!-- BEGIN PHP TEMPLATE admin_extrafields_edit.tpl.php -->
56 jQuery(document).ready(
function() {
57 function init_typeoffields(
type)
59 console.log(
"select a new type (edit) = "+
type);
60 var size = jQuery(
"#size");
61 var computed_value = jQuery(
"#computed_value");
62 var langfile = jQuery(
"#langfile");
63 var default_value = jQuery(
"#default_value");
64 var unique = jQuery(
"#unique");
65 var required = jQuery(
"#required");
66 var alwayseditable = jQuery(
"#alwayseditable");
67 var list = jQuery(
"#list");
68 var totalizable = jQuery(
"#totalizable");
70 if ((
GETPOST(
'type',
'alpha') !=
"select") && (
GETPOST(
'type',
'alpha') !=
"sellist")) {
71 print
'jQuery("#value_choice").hide();';
74 if (in_array(
GETPOST(
'type',
'alpha'), [
"separate",
'point',
'linestrg',
'polygon'])) {
75 print
"jQuery('#size, #default_value, #langfile').val('').prop('disabled', true);";
76 print
'jQuery("#value_choice").hide();';
81 if (
type ==
'varchar' ||
type ==
'int' ||
type ==
'double' ||
type ==
'price') {
82 jQuery(
"tr.extra_computed_value").show();
84 computed_value.val(
''); jQuery(
"tr.extra_computed_value").hide();
86 if (computed_value.val())
88 console.log(
"We enter a computed formula");
89 jQuery(
"#default_value").val(
'');
91 jQuery(
"#default_value, #unique, #required, #alwayseditable, #list").attr(
'disabled',
true);
92 jQuery(
"tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").hide();
96 console.log(
"No computed formula");
97 jQuery(
"#default_value, #unique, #required, #alwayseditable, #list").attr(
'disabled',
false);
98 jQuery(
"tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").show();
101 if (
type ==
'date') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
102 else if (
type ==
'datetime') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
103 else if (
type ==
'double') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
104 else if (
type ==
'int') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
105 else if (
type ==
'text') { size.removeAttr(
'disabled'); unique.prop(
'disabled',
true).removeAttr(
'checked'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
106 else if (
type ==
'html') { size.removeAttr(
'disabled'); unique.prop(
'disabled',
true).removeAttr(
'checked'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
107 else if (
type ==
'varchar') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
108 else if (
type ==
'password') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); required.val(
'').prop(
'disabled',
true); default_value.val(
'').prop(
'disabled',
true); jQuery(
"#value_choice").show(); jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helppassword").show();}
109 else if (
type ==
'boolean') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
110 else if (
type ==
'price') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
111 else if (
type ==
'pricecy') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
112 else if (
type ==
'select') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").show(); jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helpselect").show();}
113 else if (
type ==
'sellist') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").show(); jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helpsellist").show();}
114 else if (
type ==
'radio') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").show(); jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helpselect").show();}
115 else if (
type ==
'checkbox') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").show(); jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helpselect").show();}
116 else if (
type ==
'chkbxlst') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").show(); jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helpchkbxlst").show();}
117 else if (
type ==
'link') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").show(); jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helplink").show();}
118 else if (
type ==
'stars') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
119 else if (
type ==
'separate') {
120 size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); required.val(
'').prop(
'disabled',
true); default_value.val(
'').prop(
'disabled',
true);
121 jQuery(
"#value_choice").show();
122 jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helpseparate").show();
125 size.val(
'').prop(
'disabled',
true);
126 unique.removeAttr(
'disabled');
129 if (
type ==
'separate' ||
type ==
'point' ||
type ==
'linestrg' ||
type ==
'polygon')
131 required.removeAttr(
'checked').prop(
'disabled',
true); alwayseditable.removeAttr(
'checked').prop(
'disabled',
true); list.removeAttr(
'checked').prop(
'disabled',
true);
132 jQuery(
'#size, #default_value, #langfile').val(
'').prop(
'disabled',
true);
133 jQuery(
'#list').val(3);
137 default_value.removeAttr(
'disabled');
138 required.removeAttr(
'disabled'); alwayseditable.removeAttr(
'disabled'); list.removeAttr(
'disabled');
141 init_typeoffields(jQuery(
"#type").val());
142 jQuery(
"#type").change(
function() {
143 init_typeoffields($(
this).val());
147 jQuery(
"#computed_value").keyup(
function() {
148 init_typeoffields(jQuery(
'#type').val());
153<!--
Form to edit an extra field -->
154<form action=
"<?php echo $_SERVER["PHP_SELF
"]; ?>?attrname=<?php echo $attrname; ?>" id=
"formeditextrafield" method=
"post">
155<input
type=
"hidden" name=
"token" value=
"<?php echo newToken(); ?>">
156<input
type=
"hidden" name=
"attrname" value=
"<?php echo $attrname; ?>">
157<input
type=
"hidden" name=
"action" value=
"update">
158<input
type=
"hidden" name=
"rowid" value=
"<?php echo(empty($rowid) ? '' : $rowid) ?>">
159<input
type=
"hidden" name=
"enabled" value=
"<?php echo dol_escape_htmltag((string) $extrafields->attributes[$elementtype]['enabled'][$attrname]); ?>">
163<
table summary=
"listofattributes" class=
"border centpercent">
166$label = $extrafields->attributes[$elementtype][
'label'][$attrname];
167$type = $extrafields->attributes[$elementtype][
'type'][$attrname];
168$size = $extrafields->attributes[$elementtype][
'size'][$attrname];
169$computed = $extrafields->attributes[$elementtype][
'computed'][$attrname];
170$default = $extrafields->attributes[$elementtype][
'default'][$attrname];
171$unique = $extrafields->attributes[$elementtype][
'unique'][$attrname];
172$required = $extrafields->attributes[$elementtype][
'required'][$attrname];
173$pos = $extrafields->attributes[$elementtype][
'pos'][$attrname];
174$alwayseditable = $extrafields->attributes[$elementtype][
'alwayseditable'][$attrname];
175$param = $extrafields->attributes[$elementtype][
'param'][$attrname];
176$perms = $extrafields->attributes[$elementtype][
'perms'][$attrname];
177$langfile = $extrafields->attributes[$elementtype][
'langfile'][$attrname];
178$list = $extrafields->attributes[$elementtype][
'list'][$attrname];
179$totalizable = $extrafields->attributes[$elementtype][
'totalizable'][$attrname];
180$help = $extrafields->attributes[$elementtype][
'help'][$attrname];
181$entitycurrentorall = $extrafields->attributes[$elementtype][
'entityid'][$attrname];
182$printable = $extrafields->attributes[$elementtype][
'printable'][$attrname];
183$enabled = $extrafields->attributes[$elementtype][
'enabled'][$attrname];
184$css = $extrafields->attributes[$elementtype][
'css'][$attrname];
185$cssview = $extrafields->attributes[$elementtype][
'cssview'][$attrname];
186$csslist = $extrafields->attributes[$elementtype][
'csslist'][$attrname];
189if (is_array($param)) {
190 if (($type ==
'select') || ($type ==
'checkbox') || ($type ==
'radio')) {
191 foreach ($param[
'options'] as $key => $value) {
193 $param_chain .= $key.
','.$value.
"\n";
196 } elseif (($type ==
'sellist') || ($type ==
'chkbxlst') || ($type ==
'link') || ($type ==
'password') || ($type ==
'separate')) {
197 $paramlist = array_keys($param[
'options']);
198 $param_chain = $paramlist[0];
203<tr><td
class=
"titlefieldcreate fieldrequired"><?php echo $langs->trans(
"LabelOrTranslationKey"); ?></td><td
class=
"valeur"><input
type=
"text" name=
"label" size=
"40" value=
"<?php echo $label; ?>"></td></tr>
206<tr><td
class=
"fieldrequired"><?php echo $form->textwithpicto($langs->trans(
"AttributeCode"), $langs->trans(
"AttributeCodeHelp")); ?></td><td
class=
"valeur"><?php echo $attrname; ?></td></tr>
209<tr><td
class=
"fieldrequired"><?php echo $langs->trans(
"Type"); ?></td><td
class=
"valeur">
212$typewecanchangeinto = array(
213 'varchar'=>array(
'varchar',
'phone',
'mail',
'url',
'ip',
'select',
'password',
'text',
'html'),
214 'double'=>array(
'double',
'price'),
215 'price'=>array(
'double',
'price'),
216 'text'=>array(
'text',
'html'),
217 'html'=>array(
'text',
'html'),
218 'password'=>array(
'password',
'varchar'),
219 'mail'=>array(
'varchar',
'phone',
'mail',
'url',
'ip',
'select'),
220 'url'=>array(
'varchar',
'phone',
'mail',
'url',
'ip',
'select'),
221 'phone'=>array(
'varchar',
'phone',
'mail',
'url',
'ip',
'select'),
222 'ip'=>array(
'varchar',
'phone',
'mail',
'url',
'ip',
'select'),
223 'select'=>array(
'varchar',
'phone',
'mail',
'url',
'ip',
'select'),
224 'date'=>array(
'date',
'datetime')
231if (in_array($type, array_keys($typewecanchangeinto))) {
233 if (empty($formadmin)) {
234 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
237 print $formadmin->selectTypeOfFields(
'type',
GETPOST(
'type',
'alpha') ?
GETPOST(
'type',
'alpha') : $type, $typewecanchangeinto);
240 print $type2label[$type];
241 print
'<input type="hidden" name="type" id="type" value="'.$type.
'">';
247<tr
class=
"extra_size"><td
class=
"fieldrequired"><?php echo $langs->trans(
"Size"); ?></td><td><input
id=
"size" type=
"text" name=
"size" class=
"width50" value=
"<?php echo $size; ?>"></td></tr>
249<!-- Value (
for some fields like password, select list, radio, ...) -->
250<tr
id=
"value_choice">
252 <?php echo $langs->trans(
"Value"); ?>
255 <
table class=
"nobordernopadding">
257 <textarea
name=
"param" id=
"param" cols=
"80" rows=
"<?php echo ROWS_4 ?>"><?php echo
dol_htmlcleanlastbr($param_chain); ?></textarea>
259 <span
id=
"helpselect" class=
"spanforparamtooltip"><?php print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpselect"), 1, 0,
'', 0, 2,
'helpvalue1')?></span>
260 <span
id=
"helpsellist" class=
"spanforparamtooltip"><?php print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpsellist"), 1, 0,
'', 0, 2,
'helpvalue2')?></span>
261 <span
id=
"helpchkbxlst" class=
"spanforparamtooltip"><?php print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpsellist"), 1, 0,
'', 0, 2,
'helpvalue3')?></span>
262 <span
id=
"helplink" class=
"spanforparamtooltip"><?php print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelplink").
'<br><br>'.$langs->trans(
"Examples").
':<br>'.$listofexamplesforlink, 1, 0,
'', 0, 2,
'helpvalue4')?></span>
263 <span
id=
"helppassword" class=
"spanforparamtooltip"><?php print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpPassword"), 1, 0,
'', 0, 2,
'helpvalue5')?></span>
264 <span
id=
"helpseparate" class=
"spanforparamtooltip"><?php print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpSeparator"), 1, 0,
'', 0, 2,
'helpvalue6')?></span>
271<tr><td
class=
"titlefield"><?php echo $langs->trans(
"Position"); ?></td><td
class=
"valeur"><input
type=
"text" name=
"pos" class=
"width50" value=
"<?php echo dol_escape_htmltag((string) $pos); ?>"></td></tr>
273<!-- Language file -->
274<tr><td
class=
"titlefield"><?php echo $langs->trans(
"LanguageFile"); ?></td><td
class=
"valeur"><input
type=
"text" name=
"langfile" class=
"minwidth200" value=
"<?php echo dol_escape_htmltag($langfile); ?>"></td></tr>
276<!-- Computed value -->
277<tr
class=
"extra_computed_value">
279 <td><?php echo $form->textwithpicto($langs->trans(
"ComputedFormula"), $langs->trans(
"ComputedFormulaDesc"), 1,
'help',
'', 0, 2,
'tooltipcompute'); ?></td>
281 <td><?php echo $form->textwithpicto($langs->trans(
"ComputedFormula"), $langs->trans(
"ComputedFormulaDesc")).$form->textwithpicto($langs->trans(
"Computedpersistent"), $langs->trans(
"ComputedpersistentDesc"), 1,
'warning'); ?></td>
283<td
class=
"valeur"><textarea
name=
"computed_value" id=
"computed_value" class=
"quatrevingtpercent" rows=
"<?php echo ROWS_4 ?>"><?php echo
dol_htmlcleanlastbr($computed); ?></textarea></td>
286<!-- Default Value (at sql setup level) -->
287<tr
class=
"extra_default_value"><td><?php echo $langs->trans(
"DefaultValue").
' ('.$langs->trans(
"Database").
')'; ?></td><td
class=
"valeur"><input
id=
"default_value" type=
"text" name=
"default_value" class=
"width50" value=
"<?php echo dol_escape_htmltag($default); ?>"></td></tr>
290<tr
class=
"extra_unique"><td><?php echo $langs->trans(
"Unique"); ?></td><td
class=
"valeur"><input
id=
"unique" type=
"checkbox" name=
"unique"<?php echo($unique ?
' checked' :
''); ?>></td></tr>
293<tr
class=
"extra_required"><td><?php echo $langs->trans(
"Mandatory"); ?></td><td
class=
"valeur"><input
id=
"required" type=
"checkbox" name=
"required"<?php echo($required ?
' checked' :
''); ?>></td></tr>
295<!-- Always editable -->
296<tr
class=
"extra_alwayseditable"><td><?php echo $form->textwithpicto($langs->trans(
"AlwaysEditable"), $langs->trans(
"EditableWhenDraftOnly")); ?></td><td
class=
"valeur"><input
id=
"alwayseditable" type=
"checkbox" name=
"alwayseditable"<?php echo($alwayseditable ?
' checked' :
''); ?>></td></tr>
299<tr><td
class=
"extra_list"><?php echo $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression")); ?>
300</td><td
class=
"valeur"><input
id=
"list" class=
"minwidth100" type=
"text" name=
"list" value=
"<?php echo($list != '' ? $list : '1'); ?>"></td></tr>
302<!-- Visibility
for PDF-->
303<tr><td
class=
"extra_pdf"><?php echo $form->textwithpicto($langs->trans(
"DisplayOnPdf"), $langs->trans(
"DisplayOnPdfDesc")); ?>
304</td><td
class=
"valeur"><input
id=
"printable" class=
"minwidth100" type=
"text" name=
"printable" value=
"<?php echo dol_escape_htmltag((string) $printable); ?>"></td></tr>
306<!-- Can be summed -->
307<tr
class=
"extra_totalizable"><td><?php echo $form->textwithpicto($langs->trans(
"Totalizable"), $langs->trans(
"TotalizableDesc")); ?></td><td
class=
"valeur"><input
id=
"totalizable" type=
"checkbox" name=
"totalizable"<?php echo($totalizable ?
' checked' :
''); ?>></td></tr>
310<tr
class=
"extra_css"><td><?php echo $form->textwithpicto($langs->trans(
"CssOnEdit"), $langs->trans(
"HelpCssOnEditDesc")); ?></td><td
class=
"valeur"><input
id=
"css" type=
"text" name=
"css" value=
"<?php echo $css ?>"></td></tr>
313<tr
class=
"extra_cssview"><td><?php echo $form->textwithpicto($langs->trans(
"CssOnView"), $langs->trans(
"HelpCssOnViewDesc")); ?></td><td
class=
"valeur"><input
id=
"cssview" type=
"text" name=
"cssview" value=
"<?php echo $cssview; ?>"></td></tr>
316<tr
class=
"extra_csslist"><td><?php echo $form->textwithpicto($langs->trans(
"CssOnList"), $langs->trans(
"HelpCssOnListDesc")); ?></td><td
class=
"valeur"><input
id=
"csslist" type=
"text" name=
"csslist" value=
"<?php echo $csslist; ?>"></td></tr>
319<tr
class=
"help"><td><?php echo $form->textwithpicto($langs->trans(
"HelpOnTooltip"), $langs->trans(
"HelpOnTooltipDesc")); ?></td><td
class=
"valeur"><input
id=
"help" class=
"quatrevingtpercent" type=
"text" name=
"help" value=
"<?php echo dol_escape_htmltag($help); ?>"></td></tr>
321<?php
if (isModEnabled(
'multicompany')) { ?>
322 <!-- Multicompany entity -->
323 <tr><td><?php echo $langs->trans(
"AllEntities"); ?></td><td
class=
"valeur"><input
id=
"entitycurrentorall" type=
"checkbox" name=
"entitycurrentorall"<?php echo(empty($entitycurrentorall) ?
' checked' :
''); ?>></td></tr>
326<!-- Show Enabled
property when value is not a common value -->
327<?php
if ($enabled !=
'1') { ?>
328 <tr
class=
"help"><td><?php echo $langs->trans(
"EnabledCondition"); ?></td><td
class=
"valeur">
337<div
class=
"center"><input
type=
"submit" name=
"button" class=
"button button-save" value=
"<?php echo $langs->trans("Save
"); ?>">
338<input
type=
"submit" name=
"button" class=
"button button-cancel" value=
"<?php echo $langs->trans("Cancel
"); ?>"></div>
342<!-- END PHP TEMPLATE admin_extrafields_edit.tpl.php -->
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getPictoForType($key, $morecss='')
Return the picto for a data type.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
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.
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...
treeview li table
No Email.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.