IKM : work on new extrafield separator type

This commit is contained in:
jfefe 2013-03-15 23:39:18 +01:00
parent b1d50e3f7f
commit b36b776f10
2 changed files with 32 additions and 9 deletions

View File

@ -64,7 +64,7 @@ class ExtraFields
'phone'=>'ExtrafieldPhone',
'mail'=>'ExtrafieldMail',
'select' => 'ExtrafieldSelect',
'separator' => 'ExtrafieldSeparator'
'separate' => 'ExtrafieldSeparator'
);
/**
@ -103,14 +103,13 @@ class ExtraFields
if (empty($attrname)) return -1;
if (empty($label)) return -1;
// Create field into database except for separator type
if ($elementtype != 'separator')
// Create field into database except for separator type which is not stored in database
if ($type != 'separate')
{
$result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param);
}
$err1=$this->errno;
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $elementtype == 'separator')
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate')
{
// Add declaration of field into table
$result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param);
@ -550,8 +549,13 @@ class ExtraFields
{
while ($tab = $this->db->fetch_object($resql))
{
// we can add this attribute to adherent object
$array_name_label[$tab->name]=$tab->label;
if ($tab->type != 'separate')
{
$array_name_label[$tab->name]=$tab->label;
}
$this->attribute_type[$tab->name]=$tab->type;
$this->attribute_label[$tab->name]=$tab->label;
$this->attribute_size[$tab->name]=$tab->size;
@ -734,5 +738,16 @@ class ExtraFields
return $out;
}
/**
* Return HTML string to print separator extrafield
*
* @param string $key Key of attribute
* @return string
*/
function showSeparator($key)
{
$out = '<tr class="liste_titre"><td colspan="4"><strong>'.$this->attribute_label[$key].'</strong></td></tr>';
return $out;
}
}
?>

View File

@ -25,11 +25,18 @@
var size = jQuery("#size");
var unique = jQuery("#unique");
var required = jQuery("#required");
var default_value = jQuery("#default_value");
<?php
if(!GETPOST('type') == "select")
if(GETPOST('type') != "select")
{
print 'jQuery("#value_choice").hide();';
}
if (GETPOST('type') == "separate")
{
print "jQuery('#size, #unique, #required, #default_value').val('').attr('disabled','disabled');";
print 'jQuery("#value_choice").hide();';
}
?>
if (type == 'date') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); }
@ -41,6 +48,7 @@
else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();}
else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();}
else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();}
else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();}
else size.val('').attr('disabled','disabled');
}
init_typeoffields('');
@ -64,7 +72,7 @@
<!-- Label -->
<tr><td class="fieldrequired"><?php echo $langs->trans("Label"); ?></td><td class="valeur"><input type="text" name="label" size="40" value="<?php echo GETPOST('label'); ?>"></td></tr>
<!-- Code -->
<tr><td class="fieldrequired"><?php echo $langs->trans("AttributeCode"); ?> (<?php echo $langs->trans("AlphaNumOnlyCharsAndNoSpace"); ?>)</td><td class="valeur"><input type="text" name="attrname" size="10" value="<?php echo GETPOST('attrname'); ?>"></td></tr>
<tr><td class="fieldrequired"><?php echo $langs->trans("AttributeCode"); ?> (<?php echo $langs->trans("AlphaNumOnlyCharsAndNoSpace"); ?>)</td><td class="valeur"><input type="text" name="attrname" id="attrname" size="10" value="<?php echo GETPOST('attrname'); ?>"></td></tr>
<!-- Value (for select list / radio) -->
<tr id="value_choice">
<td>
@ -75,7 +83,7 @@
</td>
</tr>
<!-- Default Value -->
<tr><td><?php echo $langs->trans("DefaultValue"); ?></td><td class="valeur"><input id="default_value" type="text" name=""default_value"" size="5" value="<?php echo (GETPOST('"default_value"')?GETPOST('"default_value"'):''); ?>"></td></tr>
<tr><td><?php echo $langs->trans("DefaultValue"); ?></td><td class="valeur"><input id="default_value" type="text" name="default_value" size="5" value="<?php echo (GETPOST('"default_value"')?GETPOST('"default_value"'):''); ?>"></td></tr>
<!-- Size -->
<tr><td class="fieldrequired"><?php echo $langs->trans("Size"); ?></td><td class="valeur"><input id="size" type="text" name="size" size="5" value="<?php echo (GETPOST('size')?GETPOST('size'):''); ?>"></td></tr>
<!-- Unique -->