Can set language file to use for label key of extra field

This commit is contained in:
Laurent Destailleur 2017-08-27 12:52:26 +02:00
parent 502ac19a0a
commit 76b4a2ce06
4 changed files with 46 additions and 44 deletions

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
* *
* $elementype must be defined. * $elementype must be defined.
*/ */
@ -158,12 +158,11 @@ if ($action == 'add')
$params['options'][$key] = $value; $params['options'][$key] = $value;
} }
} }
$result=$extrafields->addExtraField( $result=$extrafields->addExtraField(
GETPOST('attrname', 'alpha'), GETPOST('attrname', 'alpha'),
GETPOST('label', 'alpha'), GETPOST('label', 'alpha'),
$type, $type,
GETPOST('pos', 'alpha'), GETPOST('pos', 'int'),
$extrasize, $extrasize,
$elementtype, $elementtype,
(GETPOST('unique', 'alpha')?1:0), (GETPOST('unique', 'alpha')?1:0),
@ -175,8 +174,8 @@ if ($action == 'add')
(GETPOST('list', 'alpha')?1:0), (GETPOST('list', 'alpha')?1:0),
(GETPOST('ishidden', 'alpha')?1:0), (GETPOST('ishidden', 'alpha')?1:0),
GETPOST('computed_value','alpha'), GETPOST('computed_value','alpha'),
(GETPOST('entitycurrentorall', 'alpha')?0:'') (GETPOST('entitycurrentorall', 'alpha')?0:''),
GETPOST('langfile', 'alpha')
); );
if ($result > 0) if ($result > 0)
{ {
@ -338,7 +337,8 @@ if ($action == 'update')
(GETPOST('ishidden', 'alpha')?1:0), (GETPOST('ishidden', 'alpha')?1:0),
GETPOST('default_value','alpha'), GETPOST('default_value','alpha'),
GETPOST('computed_value','alpha'), GETPOST('computed_value','alpha'),
(GETPOST('entitycurrentorall', 'alpha')?0:'') (GETPOST('entitycurrentorall', 'alpha')?0:''),
GETPOST('langfile')
); );
if ($result > 0) if ($result > 0)
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2010-2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2010-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com> * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* *
@ -56,11 +56,11 @@
// Case of computed field // Case of computed field
console.log(type); console.log(type);
if (type == '' || type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { if (type == '' || type == 'varchar' || type == 'int' || type == 'double' || type == 'price') {
jQuery("tr.extra_computed_value").show(); jQuery("tr.extra_computed_value").show();
} else { } else {
computed_value.val(''); jQuery("tr.extra_computed_value").hide(); computed_value.val(''); jQuery("tr.extra_computed_value").hide();
} }
if (computed_value.val()) if (computed_value.val())
{ {
console.log("We enter a computed formula"); console.log("We enter a computed formula");
@ -75,7 +75,7 @@
jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false);
jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show();
} }
if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
else if (type == 'datetime') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'datetime') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
else if (type == 'double') { size.val('24,8').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'double') { size.val('24,8').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
@ -90,8 +90,8 @@
else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();}
else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();} else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();}
else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();} else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();}
else if (type == 'separate') { else if (type == 'separate') {
size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true);
jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide(); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();
} }
else { // type = string else { // type = string
@ -102,12 +102,12 @@
if (type == 'separate') if (type == 'separate')
{ {
required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true);
jQuery('#size, #default_value').val('').prop('disabled', true); jQuery('#size, #default_value').val('').prop('disabled', true);
} }
else else
{ {
default_value.removeAttr('disabled'); default_value.removeAttr('disabled');
required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled');
} }
} }
init_typeoffields('<?php echo GETPOST('type'); ?>'); init_typeoffields('<?php echo GETPOST('type'); ?>');
@ -158,7 +158,9 @@
</td> </td>
</tr> </tr>
<!-- Position --> <!-- Position -->
<tr><td class="titlefield"><?php echo $langs->trans("Position"); ?></td><td class="valeur"><input type="text" name="pos" size="5" value="<?php echo GETPOST('pos'); ?>"></td></tr> <tr><td class="titlefield"><?php echo $langs->trans("Position"); ?></td><td class="valeur"><input type="text" name="pos" size="5" value="<?php echo GETPOST('pos','int'); ?>"></td></tr>
<!-- Language file -->
<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(GETPOST('langfile','alpha')); ?>"></td></tr>
<!-- Computed Value --> <!-- Computed Value -->
<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" type="text" name="computed_value" class="quatrevingtpercent" value="<?php echo (GETPOST('"computed_value"')?GETPOST('"computed_value"'):''); ?>"></td></tr> <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" type="text" name="computed_value" class="quatrevingtpercent" value="<?php echo (GETPOST('"computed_value"')?GETPOST('"computed_value"'):''); ?>"></td></tr>
<!-- Default Value (at sql setup level) --> <!-- Default Value (at sql setup level) -->

View File

@ -54,11 +54,11 @@
?> ?>
// Case of computed field // Case of computed field
if (type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { if (type == 'varchar' || type == 'int' || type == 'double' || type == 'price') {
jQuery("tr.extra_computed_value").show(); jQuery("tr.extra_computed_value").show();
} else { } else {
computed_value.val(''); jQuery("tr.extra_computed_value").hide(); computed_value.val(''); jQuery("tr.extra_computed_value").hide();
} }
if (computed_value.val()) if (computed_value.val())
{ {
console.log("We enter a computed formula"); console.log("We enter a computed formula");
@ -73,7 +73,7 @@
jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false);
jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show();
} }
if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
else if (type == 'datetime') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'datetime') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
else if (type == 'double') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'double') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
@ -91,19 +91,19 @@
else if (type == 'separate') { 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").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else if (type == 'separate') { 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").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();}
else { // type = string else { // type = string
size.val('').prop('disabled', true); size.val('').prop('disabled', true);
unique.removeAttr('disabled'); unique.removeAttr('disabled');
} }
if (type == 'separate') if (type == 'separate')
{ {
required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true);
jQuery('#size, #default_value').val('').prop('disabled', true); jQuery('#size, #default_value').val('').prop('disabled', true);
} }
else else
{ {
default_value.removeAttr('disabled'); default_value.removeAttr('disabled');
required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled');
} }
} }
init_typeoffields(jQuery("#type").val()); init_typeoffields(jQuery("#type").val());
jQuery("#type").change(function() { jQuery("#type").change(function() {
@ -113,7 +113,7 @@
// If we enter a formula, we disable other fields // If we enter a formula, we disable other fields
jQuery("#computed_value").keyup(function() { jQuery("#computed_value").keyup(function() {
init_typeoffields(jQuery('#type').val()); init_typeoffields(jQuery('#type').val());
}); });
}); });
</script> </script>
@ -129,23 +129,20 @@
<table summary="listofattributes" class="border centpercent"> <table summary="listofattributes" class="border centpercent">
<?php <?php
$type=$extrafields->attribute_type[$attrname]; $type=$extrafields->attributes[$elementtype]['type'][$attrname];
$size=$extrafields->attribute_size[$attrname]; $size=$extrafields->attributes[$elementtype]['size'][$attrname];
$computed=$extrafields->attribute_computed[$attrname]; $computed=$extrafields->attributes[$elementtype]['computed'][$attrname];
$default=$extrafields->attribute_default[$attrname]; $default=$extrafields->attributes[$elementtype]['default'][$attrname];
$unique=$extrafields->attribute_unique[$attrname]; $unique=$extrafields->attributes[$elementtype]['unique'][$attrname];
$required=$extrafields->attribute_required[$attrname]; $required=$extrafields->attributes[$elementtype]['required'][$attrname];
$pos=$extrafields->attribute_pos[$attrname]; $pos=$extrafields->attributes[$elementtype]['pos'][$attrname];
$alwayseditable=$extrafields->attribute_alwayseditable[$attrname]; $alwayseditable=$extrafields->attributes[$elementtype]['alwayseditable'][$attrname];
$param=$extrafields->attribute_param[$attrname]; $param=$extrafields->attributes[$elementtype]['param'][$attrname];
$perms=$extrafields->attribute_perms[$attrname]; $perms=$extrafields->attributes[$elementtype]['perms'][$attrname];
$list=$extrafields->attribute_list[$attrname]; $langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname];
if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) { $list=$extrafields->attributes[$elementtype]['list'][$attrname];
$ishidden=$extrafields->attribute_hidden[$attrname]; $ishidden=$extrafields->attributes[$elementtype]['hidden'][$attrname];
} $entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname];
if ($conf->multicompany->enabled) {
$entitycurrentorall=$extrafields->attribute_entityid[$attrname];
}
if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param))
{ {
@ -220,7 +217,9 @@ else
</td> </td>
</tr> </tr>
<!-- Position --> <!-- Position -->
<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($extrafields->attribute_pos[$attrname]); ?>"></td></tr> <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>
<!-- Language file -->
<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>
<!-- Computed value --> <!-- Computed value -->
<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> <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>
<!-- Default value --> <!-- Default value -->

View File

@ -345,6 +345,7 @@ AddCRIfTooLong=There is no automatic wrapping, so if line is out of page on docu
ConfirmPurge=Are you sure you want to execute this purge?<br>This will delete definitely all your data files with no way to restore them (ECM files, attached files...). ConfirmPurge=Are you sure you want to execute this purge?<br>This will delete definitely all your data files with no way to restore them (ECM files, attached files...).
MinLength=Minimum length MinLength=Minimum length
LanguageFilesCachedIntoShmopSharedMemory=Files .lang loaded in shared memory LanguageFilesCachedIntoShmopSharedMemory=Files .lang loaded in shared memory
LanguageFile=Language file
ExamplesWithCurrentSetup=Examples with current running setup ExamplesWithCurrentSetup=Examples with current running setup
ListOfDirectories=List of OpenDocument templates directories ListOfDirectories=List of OpenDocument templates directories
ListOfDirectoriesForModelGenODT=List of directories containing templates files with OpenDocument format.<br><br>Put here full path of directories.<br>Add a carriage return between eah directory.<br>To add a directory of the GED module, add here <b>DOL_DATA_ROOT/ecm/yourdirectoryname</b>.<br><br>Files in those directories must end with <b>.odt</b> or <b>.ods</b>. ListOfDirectoriesForModelGenODT=List of directories containing templates files with OpenDocument format.<br><br>Put here full path of directories.<br>Add a carriage return between eah directory.<br>To add a directory of the GED module, add here <b>DOL_DATA_ROOT/ecm/yourdirectoryname</b>.<br><br>Files in those directories must end with <b>.odt</b> or <b>.ods</b>.