30 if (empty($conf) || !is_object($conf))
32 print "Error, template page can't be called as URL";
37 $langs->load(
"modulebuilder");
39 $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>...';
43 <!-- BEGIN PHP TEMPLATE admin_extrafields_edit.tpl.php -->
45 jQuery(document).ready(
function() {
46 function init_typeoffields(
type)
48 console.log(
"select a new type (edit) = "+
type);
49 var size = jQuery(
"#size");
50 var computed_value = jQuery(
"#computed_value");
51 var langfile = jQuery(
"#langfile");
52 var default_value = jQuery(
"#default_value");
53 var unique = jQuery(
"#unique");
54 var required = jQuery(
"#required");
55 var alwayseditable = jQuery(
"#alwayseditable");
56 var list = jQuery(
"#list");
57 var totalizable = jQuery(
"#totalizable");
59 if ((
GETPOST(
'type',
'alpha') !=
"select") && (
GETPOST(
'type',
'alpha') !=
"sellist"))
61 print 'jQuery("#value_choice").hide();';
64 if (
GETPOST(
'type',
'alpha') ==
"separate")
66 print "jQuery('#size, #default_value, #langfile').val('').prop('disabled', true);";
67 print 'jQuery("#value_choice").hide();';
72 if (
type ==
'varchar' ||
type ==
'int' ||
type ==
'double' ||
type ==
'price') {
73 jQuery(
"tr.extra_computed_value").show();
75 computed_value.val(
''); jQuery(
"tr.extra_computed_value").hide();
77 if (computed_value.val())
79 console.log(
"We enter a computed formula");
80 jQuery(
"#default_value").val(
'');
82 jQuery(
"#default_value, #unique, #required, #alwayseditable, #list").attr(
'disabled',
true);
83 jQuery(
"tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").hide();
87 console.log(
"No computed formula");
88 jQuery(
"#default_value, #unique, #required, #alwayseditable, #list").attr(
'disabled',
false);
89 jQuery(
"tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").show();
92 if (
type ==
'date') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
93 else if (
type ==
'datetime') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
94 else if (
type ==
'double') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
95 else if (
type ==
'int') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
96 else if (
type ==
'text') { size.removeAttr(
'disabled'); unique.prop(
'disabled',
true).removeAttr(
'checked'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
97 else if (
type ==
'html') { size.removeAttr(
'disabled'); unique.prop(
'disabled',
true).removeAttr(
'checked'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
98 else if (
type ==
'varchar') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
99 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();}
100 else if (
type ==
'boolean') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
101 else if (
type ==
'price') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
102 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();}
103 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();}
104 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();}
105 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();}
106 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();}
107 else if (
type ==
'link') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").show(); jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helplink").show();}
108 else if (
type ==
'separate') {
109 size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); required.val(
'').prop(
'disabled',
true); default_value.val(
'').prop(
'disabled',
true);
110 jQuery(
"#value_choice").show();
111 jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helpseparate").show();
114 size.val(
'').prop(
'disabled',
true);
115 unique.removeAttr(
'disabled');
118 if (
type ==
'separate')
120 required.removeAttr(
'checked').prop(
'disabled',
true); alwayseditable.removeAttr(
'checked').prop(
'disabled',
true); list.removeAttr(
'checked').prop(
'disabled',
true);
121 jQuery(
'#size, #default_value, #langfile').val(
'').prop(
'disabled',
true);
122 jQuery(
'#list').val(3);
126 default_value.removeAttr(
'disabled');
127 required.removeAttr(
'disabled'); alwayseditable.removeAttr(
'disabled'); list.removeAttr(
'disabled');
130 init_typeoffields(jQuery(
"#type").val());
131 jQuery(
"#type").change(
function() {
132 init_typeoffields($(
this).val());
136 jQuery(
"#computed_value").keyup(
function() {
137 init_typeoffields(jQuery(
'#type').val());
142 <!--
Form to edit an extra field -->
143 <form action=
"<?php echo $_SERVER["PHP_SELF
"]; ?>?attrname=<?php echo $attrname; ?>" id=
"formeditextrafield" method=
"post">
144 <input
type=
"hidden" name=
"token" value=
"<?php echo newToken(); ?>">
145 <input type=
"hidden" name=
"attrname" value=
"<?php echo $attrname; ?>">
146 <input type=
"hidden" name=
"action" value=
"update">
147 <input type=
"hidden" name=
"rowid" value=
"<?php echo $rowid ?>">
148 <input type=
"hidden" name=
"enabled" value=
"<?php echo $extrafields->attributes[$elementtype]['enabled'][$attrname]; ?>">
152 <table summary=
"listofattributes" class=
"border centpercent">
155 $label = $extrafields->attributes[$elementtype][
'label'][$attrname];
156 $type = $extrafields->attributes[$elementtype][
'type'][$attrname];
157 $size = $extrafields->attributes[$elementtype][
'size'][$attrname];
158 $computed = $extrafields->attributes[$elementtype][
'computed'][$attrname];
159 $default = $extrafields->attributes[$elementtype][
'default'][$attrname];
160 $unique = $extrafields->attributes[$elementtype][
'unique'][$attrname];
161 $required = $extrafields->attributes[$elementtype][
'required'][$attrname];
162 $pos = $extrafields->attributes[$elementtype][
'pos'][$attrname];
163 $alwayseditable = $extrafields->attributes[$elementtype][
'alwayseditable'][$attrname];
164 $param = $extrafields->attributes[$elementtype][
'param'][$attrname];
165 $perms = $extrafields->attributes[$elementtype][
'perms'][$attrname];
166 $langfile = $extrafields->attributes[$elementtype][
'langfile'][$attrname];
167 $list = $extrafields->attributes[$elementtype][
'list'][$attrname];
168 $totalizable = $extrafields->attributes[$elementtype][
'totalizable'][$attrname];
169 $help = $extrafields->attributes[$elementtype][
'help'][$attrname];
170 $entitycurrentorall = $extrafields->attributes[$elementtype][
'entityid'][$attrname];
171 $printable = $extrafields->attributes[$elementtype][
'printable'][$attrname];
172 $enabled = $extrafields->attributes[$elementtype][
'enabled'][$attrname];
174 if ((($type ==
'select') || ($type ==
'checkbox') || ($type ==
'radio')) && is_array($param))
177 foreach ($param[
'options'] as $key => $value)
181 $param_chain .= $key.
','.$value.
"\n";
184 } elseif (($type ==
'sellist') || ($type ==
'chkbxlst') || ($type ==
'link') || ($type ==
'password') || ($type ==
'separate'))
186 $paramlist = array_keys($param[
'options']);
187 $param_chain = $paramlist[0];
191 <tr><td
class=
"titlefield fieldrequired"><?php echo $langs->trans(
"LabelOrTranslationKey"); ?></td><td
class=
"valeur"><input type=
"text" name=
"label" size=
"40" value=
"<?php echo $label; ?>"></td></tr>
194 <tr><td
class=
"fieldrequired"><?php echo $langs->trans(
"AttributeCode"); ?></td><td
class=
"valeur"><?php echo $attrname; ?></td></tr>
197 <tr><td
class=
"fieldrequired"><?php echo $langs->trans(
"Type"); ?></td><td
class=
"valeur">
200 $typewecanchangeinto = array(
201 'varchar'=>array(
'varchar',
'phone',
'mail',
'url',
'select',
'password',
'text',
'html'),
202 'double'=>array(
'double',
'price'),
203 'price'=>array(
'double',
'price'),
204 'text'=>array(
'text',
'html'),
205 'html'=>array(
'text',
'html'),
206 'password'=>array(
'password',
'varchar'),
207 'mail'=>array(
'varchar',
'phone',
'mail',
'url',
'select'),
208 'url'=>array(
'varchar',
'phone',
'mail',
'url',
'select'),
209 'phone'=>array(
'varchar',
'phone',
'mail',
'url',
'select'),
210 'select'=>array(
'varchar',
'phone',
'mail',
'url',
'select'),
211 'date'=>array(
'date',
'datetime')
218 if (in_array($type, array_keys($typewecanchangeinto)))
221 print '<select id="type" class="flat type" name="type">';
222 foreach ($type2label as $key => $val)
225 if ($key == (
GETPOST(
'type',
'alpha') ?
GETPOST(
'type',
'alpha') : $type)) $selected =
' selected="selected"';
226 if (in_array($key, $typewecanchangeinto[$type]))
print '<option value="'.$key.
'"'.$selected.
'>'.$val.
'</option>';
227 else print '<option value="'.$key.
'" disabled="disabled"'.$selected.
'>'.$val.
'</option>';
232 print $type2label[$type];
233 print '<input type="hidden" name="type" id="type" value="'.$type.
'">';
239 <tr
class=
"extra_size"><td
class=
"fieldrequired"><?php echo $langs->trans(
"Size"); ?></td><td><input
id=
"size" type=
"text" name=
"size" size=
"5" value=
"<?php echo $size; ?>"></td></tr>
241 <!-- Value (
for some
fields like password, select list, radio, ...) -->
242 <tr
id=
"value_choice">
244 <?php echo $langs->trans(
"Value"); ?>
247 <table
class=
"nobordernopadding">
249 <textarea
name=
"param" id=
"param" cols=
"80" rows=
"<?php echo ROWS_4 ?>"><?php echo
dol_htmlcleanlastbr($param_chain); ?></textarea>
251 <span
id=
"helpselect" class=
"spanforparamtooltip"><?php
print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpselect"), 1, 0,
'', 0, 2,
'helpvalue1')?></span>
252 <span
id=
"helpsellist" class=
"spanforparamtooltip"><?php
print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpsellist"), 1, 0,
'', 0, 2,
'helpvalue2')?></span>
253 <span
id=
"helpchkbxlst" class=
"spanforparamtooltip"><?php
print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpchkbxlst"), 1, 0,
'', 0, 2,
'helpvalue3')?></span>
254 <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>
255 <span
id=
"helppassword" class=
"spanforparamtooltip"><?php
print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpPassword"), 1, 0,
'', 0, 2,
'helpvalue5')?></span>
256 <span
id=
"helpseparate" class=
"spanforparamtooltip"><?php
print $form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpSeparator"), 1, 0,
'', 0, 2,
'helpvalue6')?></span>
263 <tr><td
class=
"titlefield"><?php echo $langs->trans(
"Position"); ?></td><td
class=
"valeur"><input type=
"text" name=
"pos" size=
"5" value=
"<?php echo dol_escape_htmltag($pos); ?>"></td></tr>
265 <!-- Language file -->
266 <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>
268 <!-- Computed value -->
269 <?php
if (empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?>
270 <tr
class=
"extra_computed_value"><td><?php echo $form->textwithpicto($langs->trans(
"ComputedFormula"), $langs->trans(
"ComputedFormulaDesc"), 1,
'help',
'', 0, 2,
'tooltipcompute'); ?></td><td
class=
"valeur"><input
id=
"computed_value" class=
"quatrevingtpercent" type=
"text" name=
"computed_value" value=
"<?php echo dol_escape_htmltag($computed); ?>"></td></tr>
272 <tr
class=
"extra_computed_value"><td><?php echo $form->textwithpicto($langs->trans(
"ComputedFormula"), $langs->trans(
"ComputedFormulaDesc")).$form->textwithpicto($langs->trans(
"Computedpersistent"), $langs->trans(
"ComputedpersistentDesc"), 1,
'warning'); ?></td><td
class=
"valeur"><input
id=
"computed_value" class=
"quatrevingtpercent" type=
"text" name=
"computed_value" value=
"<?php echo dol_escape_htmltag($computed); ?>"></td></tr>
275 <!-- Default Value (at sql setup level) -->
276 <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" size=
"5" value=
"<?php echo dol_escape_htmltag($default); ?>"></td></tr>
279 <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>
282 <tr
class=
"extra_required"><td><?php echo $langs->trans(
"Required"); ?></td><td
class=
"valeur"><input
id=
"required" type=
"checkbox" name=
"required"<?php echo ($required ?
' checked' :
''); ?>></td></tr>
284 <!-- Always editable -->
285 <tr
class=
"extra_alwayseditable"><td><?php echo $langs->trans(
"AlwaysEditable"); ?></td><td
class=
"valeur"><input
id=
"alwayseditable" type=
"checkbox" name=
"alwayseditable"<?php echo ($alwayseditable ?
' checked' :
''); ?>></td></tr>
288 <tr><td
class=
"extra_list"><?php echo $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc")); ?>
289 </td><td
class=
"valeur"><input
id=
"list" class=
"minwidth100" type=
"text" name=
"list" value=
"<?php echo ($list != '' ? $list : '1'); ?>"></td></tr>
291 <!-- Visibility
for PDF-->
292 <tr><td
class=
"extra_pdf"><?php echo $form->textwithpicto($langs->trans(
"DisplayOnPdf"), $langs->trans(
"DisplayOnPdfDesc")); ?>
293 </td><td
class=
"valeur"><input
id=
"printable" class=
"minwidth100" type=
"text" name=
"printable" value=
"<?php echo dol_escape_htmltag($printable); ?>"></td></tr>
294 <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>
296 <!-- Help tooltip -->
297 <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>
299 <?php
if ($conf->multicompany->enabled) { ?>
300 <!-- Multicompany entity -->
301 <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>
304 <!-- Show Enabled
property when value is not a common value -->
305 <?php
if ($enabled !=
'1') { ?>
306 <tr
class=
"help"><td><?php echo $langs->trans(
"EnabledCondition"); ?></td><td
class=
"valeur">
315 <div
class=
"center"><input type=
"submit" name=
"button" class=
"button button-save" value=
"<?php echo $langs->trans("Save
"); ?>">
316 <input type=
"submit" name=
"button" class=
"button button-cancel" value=
"<?php echo $langs->trans("Cancel
"); ?>"></div>
320 <!-- END PHP TEMPLATE admin_extrafields_edit.tpl.php -->
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
foreach($object->fields as $key=> $val) if(is_array($extrafields->attributes[$object->table_element]['label'])&&count($extrafields->attributes[$object->table_element]['label']) > 0) $object fields
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...