Skip to content

Commit

Permalink
Can set language file to use for label key of extra field
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 27, 2017
1 parent 502ac19 commit 76b4a2c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 44 deletions.
12 changes: 6 additions & 6 deletions htdocs/core/actions_extrafields.inc.php
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*
*
* $elementype must be defined.
*/

Expand Down Expand Up @@ -158,12 +158,11 @@
$params['options'][$key] = $value;
}
}

$result=$extrafields->addExtraField(
GETPOST('attrname', 'alpha'),
GETPOST('label', 'alpha'),
$type,
GETPOST('pos', 'alpha'),
GETPOST('pos', 'int'),
$extrasize,
$elementtype,
(GETPOST('unique', 'alpha')?1:0),
Expand All @@ -175,8 +174,8 @@
(GETPOST('list', 'alpha')?1:0),
(GETPOST('ishidden', 'alpha')?1:0),
GETPOST('computed_value','alpha'),
(GETPOST('entitycurrentorall', 'alpha')?0:'')
(GETPOST('entitycurrentorall', 'alpha')?0:''),
GETPOST('langfile', 'alpha')
);
if ($result > 0)
{
Expand Down Expand Up @@ -338,7 +337,8 @@
(GETPOST('ishidden', 'alpha')?1:0),
GETPOST('default_value','alpha'),
GETPOST('computed_value','alpha'),
(GETPOST('entitycurrentorall', 'alpha')?0:'')
(GETPOST('entitycurrentorall', 'alpha')?0:''),
GETPOST('langfile')
);
if ($result > 0)
{
Expand Down
22 changes: 12 additions & 10 deletions htdocs/core/tpl/admin_extrafields_add.tpl.php
@@ -1,5 +1,5 @@
<?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) 2016 Charlie Benke <charlie@patas-monkey.com>
*
Expand Down Expand Up @@ -56,11 +56,11 @@ function init_typeoffields(type)

// Case of computed field
console.log(type);
if (type == '' || type == 'varchar' || type == 'int' || type == 'double' || type == 'price') {
jQuery("tr.extra_computed_value").show();
if (type == '' || type == 'varchar' || type == 'int' || type == 'double' || type == 'price') {
jQuery("tr.extra_computed_value").show();
} else {
computed_value.val(''); jQuery("tr.extra_computed_value").hide();
}
}
if (computed_value.val())
{
console.log("We enter a computed formula");
Expand All @@ -75,7 +75,7 @@ function init_typeoffields(type)
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();
}

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 == 'double') { size.val('24,8').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
Expand All @@ -90,8 +90,8 @@ function init_typeoffields(type)
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 == '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') {
size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true);
else if (type == 'separate') {
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();
}
else { // type = string
Expand All @@ -102,12 +102,12 @@ function init_typeoffields(type)
if (type == 'separate')
{
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
{
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'); ?>');
Expand Down Expand Up @@ -158,7 +158,9 @@ function init_typeoffields(type)
</td>
</tr>
<!-- 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 -->
<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) -->
Expand Down
55 changes: 27 additions & 28 deletions htdocs/core/tpl/admin_extrafields_edit.tpl.php
Expand Up @@ -54,11 +54,11 @@ function init_typeoffields(type)
?>

// Case of computed field
if (type == 'varchar' || type == 'int' || type == 'double' || type == 'price') {
jQuery("tr.extra_computed_value").show();
if (type == 'varchar' || type == 'int' || type == 'double' || type == 'price') {
jQuery("tr.extra_computed_value").show();
} else {
computed_value.val(''); jQuery("tr.extra_computed_value").hide();
}
}
if (computed_value.val())
{
console.log("We enter a computed formula");
Expand All @@ -73,7 +73,7 @@ function init_typeoffields(type)
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();
}

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 == 'double') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
Expand All @@ -91,19 +91,19 @@ function init_typeoffields(type)
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
size.val('').prop('disabled', true);
unique.removeAttr('disabled');
unique.removeAttr('disabled');
}

if (type == 'separate')
{
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);
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);
}
else
{
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());
jQuery("#type").change(function() {
Expand All @@ -113,7 +113,7 @@ function init_typeoffields(type)
// If we enter a formula, we disable other fields
jQuery("#computed_value").keyup(function() {
init_typeoffields(jQuery('#type').val());
});
});
});
</script>

Expand All @@ -129,23 +129,20 @@ function init_typeoffields(type)
<table summary="listofattributes" class="border centpercent">

<?php
$type=$extrafields->attribute_type[$attrname];
$size=$extrafields->attribute_size[$attrname];
$computed=$extrafields->attribute_computed[$attrname];
$default=$extrafields->attribute_default[$attrname];
$unique=$extrafields->attribute_unique[$attrname];
$required=$extrafields->attribute_required[$attrname];
$pos=$extrafields->attribute_pos[$attrname];
$alwayseditable=$extrafields->attribute_alwayseditable[$attrname];
$param=$extrafields->attribute_param[$attrname];
$perms=$extrafields->attribute_perms[$attrname];
$list=$extrafields->attribute_list[$attrname];
if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) {
$ishidden=$extrafields->attribute_hidden[$attrname];
}
if ($conf->multicompany->enabled) {
$entitycurrentorall=$extrafields->attribute_entityid[$attrname];
}
$type=$extrafields->attributes[$elementtype]['type'][$attrname];
$size=$extrafields->attributes[$elementtype]['size'][$attrname];
$computed=$extrafields->attributes[$elementtype]['computed'][$attrname];
$default=$extrafields->attributes[$elementtype]['default'][$attrname];
$unique=$extrafields->attributes[$elementtype]['unique'][$attrname];
$required=$extrafields->attributes[$elementtype]['required'][$attrname];
$pos=$extrafields->attributes[$elementtype]['pos'][$attrname];
$alwayseditable=$extrafields->attributes[$elementtype]['alwayseditable'][$attrname];
$param=$extrafields->attributes[$elementtype]['param'][$attrname];
$perms=$extrafields->attributes[$elementtype]['perms'][$attrname];
$langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname];
$list=$extrafields->attributes[$elementtype]['list'][$attrname];
$ishidden=$extrafields->attributes[$elementtype]['hidden'][$attrname];
$entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname];

if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param))
{
Expand Down Expand Up @@ -220,7 +217,9 @@ function init_typeoffields(type)
</td>
</tr>
<!-- 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 -->
<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 -->
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/admin.lang
Expand Up @@ -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...).
MinLength=Minimum length
LanguageFilesCachedIntoShmopSharedMemory=Files .lang loaded in shared memory
LanguageFile=Language file
ExamplesWithCurrentSetup=Examples with current running setup
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>.
Expand Down

0 comments on commit 76b4a2c

Please sign in to comment.