30 if (empty($conf) || !is_object($conf)) {
31 print
"Error, template page can't be called as URL";
36 $langs->load(
"modulebuilder");
38 $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>...';
42 <!-- BEGIN PHP TEMPLATE admin_extrafields_edit.tpl.php -->
44 jQuery(document).ready(
function() {
45 function init_typeoffields(
type)
47 console.log(
"select a new type (edit) = "+
type);
48 var size = jQuery(
"#size");
49 var computed_value = jQuery(
"#computed_value");
50 var langfile = jQuery(
"#langfile");
51 var default_value = jQuery(
"#default_value");
52 var unique = jQuery(
"#unique");
53 var required = jQuery(
"#required");
54 var alwayseditable = jQuery(
"#alwayseditable");
55 var list = jQuery(
"#list");
56 var totalizable = jQuery(
"#totalizable");
58 if ((
GETPOST(
'type',
'alpha') !=
"select") && (
GETPOST(
'type',
'alpha') !=
"sellist")) {
59 print
'jQuery("#value_choice").hide();';
62 if (
GETPOST(
'type',
'alpha') ==
"separate") {
63 print
"jQuery('#size, #default_value, #langfile').val('').prop('disabled', true);";
64 print
'jQuery("#value_choice").hide();';
69 if (
type ==
'varchar' ||
type ==
'int' ||
type ==
'double' ||
type ==
'price') {
70 jQuery(
"tr.extra_computed_value").show();
72 computed_value.val(
''); jQuery(
"tr.extra_computed_value").hide();
74 if (computed_value.val())
76 console.log(
"We enter a computed formula");
77 jQuery(
"#default_value").val(
'');
79 jQuery(
"#default_value, #unique, #required, #alwayseditable, #list").attr(
'disabled',
true);
80 jQuery(
"tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").hide();
84 console.log(
"No computed formula");
85 jQuery(
"#default_value, #unique, #required, #alwayseditable, #list").attr(
'disabled',
false);
86 jQuery(
"tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").show();
89 if (
type ==
'date') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
90 else if (
type ==
'datetime') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
91 else if (
type ==
'double') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
92 else if (
type ==
'int') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
93 else if (
type ==
'text') { size.removeAttr(
'disabled'); unique.prop(
'disabled',
true).removeAttr(
'checked'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
94 else if (
type ==
'html') { size.removeAttr(
'disabled'); unique.prop(
'disabled',
true).removeAttr(
'checked'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
95 else if (
type ==
'varchar') { size.removeAttr(
'disabled'); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").hide();jQuery(
"#helpchkbxlst").hide(); }
96 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();}
97 else if (
type ==
'boolean') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
98 else if (
type ==
'price') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); jQuery(
"#value_choice").hide(); jQuery(
"#helpchkbxlst").hide();}
99 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();}
100 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();}
101 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();}
102 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();}
103 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();}
104 else if (
type ==
'link') { size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'disabled'); jQuery(
"#value_choice").show(); jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helplink").show();}
105 else if (
type ==
'separate') {
106 size.val(
'').prop(
'disabled',
true); unique.removeAttr(
'checked').prop(
'disabled',
true); required.val(
'').prop(
'disabled',
true); default_value.val(
'').prop(
'disabled',
true);
107 jQuery(
"#value_choice").show();
108 jQuery(
".spanforparamtooltip").hide(); jQuery(
"#helpseparate").show();
111 size.val(
'').prop(
'disabled',
true);
112 unique.removeAttr(
'disabled');
115 if (
type ==
'separate')
117 required.removeAttr(
'checked').prop(
'disabled',
true); alwayseditable.removeAttr(
'checked').prop(
'disabled',
true); list.removeAttr(
'checked').prop(
'disabled',
true);
118 jQuery(
'#size, #default_value, #langfile').val(
'').prop(
'disabled',
true);
119 jQuery(
'#list').val(3);
123 default_value.removeAttr(
'disabled');
124 required.removeAttr(
'disabled'); alwayseditable.removeAttr(
'disabled'); list.removeAttr(
'disabled');
127 init_typeoffields(jQuery(
"#type").val());
128 jQuery(
"#type").change(
function() {
129 init_typeoffields($(
this).val());
133 jQuery(
"#computed_value").keyup(
function() {
134 init_typeoffields(jQuery(
'#type').val());
139 <!--
Form to edit an extra field -->
140 <form action=
"<?php echo $_SERVER["PHP_SELF
"]; ?>?attrname=<?php echo $attrname; ?>" id=
"formeditextrafield" method=
"post">
141 <input
type=
"hidden" name=
"token" value=
"<?php echo newToken(); ?>">
142 <input
type=
"hidden" name=
"attrname" value=
"<?php echo $attrname; ?>">
143 <input
type=
"hidden" name=
"action" value=
"update">
144 <input
type=
"hidden" name=
"rowid" value=
"<?php echo (empty($rowid) ? '' : $rowid) ?>">
145 <input
type=
"hidden" name=
"enabled" value=
"<?php echo $extrafields->attributes[$elementtype]['enabled'][$attrname]; ?>">
149 <table summary=
"listofattributes" class=
"border centpercent">
152 $label = $extrafields->attributes[$elementtype][
'label'][$attrname];
153 $type = $extrafields->attributes[$elementtype][
'type'][$attrname];
154 $size = $extrafields->attributes[$elementtype][
'size'][$attrname];
155 $computed = $extrafields->attributes[$elementtype][
'computed'][$attrname];
156 $default = $extrafields->attributes[$elementtype][
'default'][$attrname];
157 $unique = $extrafields->attributes[$elementtype][
'unique'][$attrname];
158 $required = $extrafields->attributes[$elementtype][
'required'][$attrname];
159 $pos = $extrafields->attributes[$elementtype][
'pos'][$attrname];
160 $alwayseditable = $extrafields->attributes[$elementtype][
'alwayseditable'][$attrname];
161 $param = $extrafields->attributes[$elementtype][
'param'][$attrname];
162 $perms = $extrafields->attributes[$elementtype][
'perms'][$attrname];
163 $langfile = $extrafields->attributes[$elementtype][
'langfile'][$attrname];
164 $list = $extrafields->attributes[$elementtype][
'list'][$attrname];
165 $totalizable = $extrafields->attributes[$elementtype][
'totalizable'][$attrname];
166 $help = $extrafields->attributes[$elementtype][
'help'][$attrname];
167 $entitycurrentorall = $extrafields->attributes[$elementtype][
'entityid'][$attrname];
168 $printable = $extrafields->attributes[$elementtype][
'printable'][$attrname];
169 $enabled = $extrafields->attributes[$elementtype][
'enabled'][$attrname];
171 if ((($type ==
'select') || ($type ==
'checkbox') || ($type ==
'radio')) && is_array($param)) {
173 foreach ($param[
'options'] as $key => $value) {
175 $param_chain .= $key.
','.$value.
"\n";
178 } elseif (($type ==
'sellist') || ($type ==
'chkbxlst') || ($type ==
'link') || ($type ==
'password') || ($type ==
'separate')) {
179 $paramlist = array_keys($param[
'options']);
180 $param_chain = $paramlist[0];
184 <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>
187 <tr><td
class=
"fieldrequired"><?php echo $langs->trans(
"AttributeCode"); ?></td><td
class=
"valeur"><?php echo $attrname; ?></td></tr>
190 <tr><td
class=
"fieldrequired"><?php echo $langs->trans(
"Type"); ?></td><td
class=
"valeur">
193 $typewecanchangeinto = array(
194 'varchar'=>array(
'varchar',
'phone',
'mail',
'url',
'select',
'password',
'text',
'html'),
195 'double'=>array(
'double',
'price'),
196 'price'=>array(
'double',
'price'),
197 'text'=>array(
'text',
'html'),
198 'html'=>array(
'text',
'html'),
199 'password'=>array(
'password',
'varchar'),
200 'mail'=>array(
'varchar',
'phone',
'mail',
'url',
'select'),
201 'url'=>array(
'varchar',
'phone',
'mail',
'url',
'select'),
202 'phone'=>array(
'varchar',
'phone',
'mail',
'url',
'select'),
203 'select'=>array(
'varchar',
'phone',
'mail',
'url',
'select'),
204 'date'=>array(
'date',
'datetime')
211 if (in_array($type, array_keys($typewecanchangeinto))) {
213 print
'<select id="type" class="flat type" name="type">';
214 foreach ($type2label as $key => $val) {
216 if ($key == (
GETPOST(
'type',
'alpha') ?
GETPOST(
'type',
'alpha') : $type)) {
217 $selected =
' selected="selected"';
219 if (in_array($key, $typewecanchangeinto[$type])) {
220 print
'<option value="'.$key.
'"'.$selected.
'>'.$val.
'</option>';
222 print
'<option value="'.$key.
'" disabled="disabled"'.$selected.
'>'.$val.
'</option>';
228 print $type2label[$type];
229 print
'<input type="hidden" name="type" id="type" value="'.$type.
'">';
235 <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>
237 <!-- Value (
for some fields like password, select list, radio, ...) -->
238 <tr
id=
"value_choice">
240 <?php echo $langs->trans(
"Value"); ?>
243 <table
class=
"nobordernopadding">
245 <textarea
name=
"param" id=
"param" cols=
"80" rows=
"<?php echo ROWS_4 ?>"><?php echo
dol_htmlcleanlastbr($param_chain); ?></textarea>
247 <span
id=
"helpselect" class=
"spanforparamtooltip"><?php print
$form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpselect"), 1, 0,
'', 0, 2,
'helpvalue1')?></span>
248 <span
id=
"helpsellist" class=
"spanforparamtooltip"><?php print
$form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpsellist"), 1, 0,
'', 0, 2,
'helpvalue2')?></span>
249 <span
id=
"helpchkbxlst" class=
"spanforparamtooltip"><?php print
$form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpchkbxlst"), 1, 0,
'', 0, 2,
'helpvalue3')?></span>
250 <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>
251 <span
id=
"helppassword" class=
"spanforparamtooltip"><?php print
$form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpPassword"), 1, 0,
'', 0, 2,
'helpvalue5')?></span>
252 <span
id=
"helpseparate" class=
"spanforparamtooltip"><?php print
$form->textwithpicto(
'', $langs->trans(
"ExtrafieldParamHelpSeparator"), 1, 0,
'', 0, 2,
'helpvalue6')?></span>
259 <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>
261 <!-- Language file -->
262 <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>
264 <!-- Computed value -->
265 <tr
class=
"extra_computed_value">
266 <?php
if (empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?>
267 <td><?php echo
$form->textwithpicto($langs->trans(
"ComputedFormula"), $langs->trans(
"ComputedFormulaDesc"), 1,
'help',
'', 0, 2,
'tooltipcompute'); ?></td>
269 <td><?php echo
$form->textwithpicto($langs->trans(
"ComputedFormula"), $langs->trans(
"ComputedFormulaDesc")).$form->textwithpicto($langs->trans(
"Computedpersistent"), $langs->trans(
"ComputedpersistentDesc"), 1,
'warning'); ?></td>
271 <td
class=
"valeur"><textarea
name=
"computed_value" id=
"computed_value" class=
"quatrevingtpercent" rows=
"<?php echo ROWS_4 ?>"><?php echo
dol_htmlcleanlastbr($computed); ?></textarea></td>
274 <!-- Default Value (at sql setup level) -->
275 <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>
278 <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>
281 <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>
283 <!-- Always editable -->
284 <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>
287 <tr><td
class=
"extra_list"><?php echo
$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc")); ?>
288 </td><td
class=
"valeur"><input
id=
"list" class=
"minwidth100" type=
"text" name=
"list" value=
"<?php echo ($list != '' ? $list : '1'); ?>"></td></tr>
290 <!-- Visibility
for PDF-->
291 <tr><td
class=
"extra_pdf"><?php echo
$form->textwithpicto($langs->trans(
"DisplayOnPdf"), $langs->trans(
"DisplayOnPdfDesc")); ?>
292 </td><td
class=
"valeur"><input
id=
"printable" class=
"minwidth100" type=
"text" name=
"printable" value=
"<?php echo dol_escape_htmltag($printable); ?>"></td></tr>
293 <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>
295 <!-- Help tooltip -->
296 <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>
298 <?php
if (!empty($conf->multicompany->enabled)) { ?>
299 <!-- Multicompany entity -->
300 <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>
303 <!-- Show Enabled
property when value is not a common value -->
304 <?php
if ($enabled !=
'1') { ?>
305 <tr
class=
"help"><td><?php echo $langs->trans(
"EnabledCondition"); ?></td><td
class=
"valeur">
314 <div
class=
"center"><input
type=
"submit" name=
"button" class=
"button button-save" value=
"<?php echo $langs->trans("Save
"); ?>">
315 <input
type=
"submit" name=
"button" class=
"button button-cancel" value=
"<?php echo $langs->trans("Cancel
"); ?>"></div>
319 <!-- END PHP TEMPLATE admin_extrafields_edit.tpl.php -->