IKM : work on new extrafield separator type
This commit is contained in:
parent
b1d50e3f7f
commit
b36b776f10
@ -64,7 +64,7 @@ class ExtraFields
|
|||||||
'phone'=>'ExtrafieldPhone',
|
'phone'=>'ExtrafieldPhone',
|
||||||
'mail'=>'ExtrafieldMail',
|
'mail'=>'ExtrafieldMail',
|
||||||
'select' => 'ExtrafieldSelect',
|
'select' => 'ExtrafieldSelect',
|
||||||
'separator' => 'ExtrafieldSeparator'
|
'separate' => 'ExtrafieldSeparator'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,14 +103,13 @@ class ExtraFields
|
|||||||
if (empty($attrname)) return -1;
|
if (empty($attrname)) return -1;
|
||||||
if (empty($label)) return -1;
|
if (empty($label)) return -1;
|
||||||
|
|
||||||
|
// Create field into database except for separator type which is not stored in database
|
||||||
// Create field into database except for separator type
|
if ($type != 'separate')
|
||||||
if ($elementtype != 'separator')
|
|
||||||
{
|
{
|
||||||
$result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param);
|
$result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param);
|
||||||
}
|
}
|
||||||
$err1=$this->errno;
|
$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
|
// Add declaration of field into table
|
||||||
$result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param);
|
$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))
|
while ($tab = $this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
|
|
||||||
// we can add this attribute to adherent object
|
// 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_type[$tab->name]=$tab->type;
|
||||||
$this->attribute_label[$tab->name]=$tab->label;
|
$this->attribute_label[$tab->name]=$tab->label;
|
||||||
$this->attribute_size[$tab->name]=$tab->size;
|
$this->attribute_size[$tab->name]=$tab->size;
|
||||||
@ -734,5 +738,16 @@ class ExtraFields
|
|||||||
return $out;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -25,11 +25,18 @@
|
|||||||
var size = jQuery("#size");
|
var size = jQuery("#size");
|
||||||
var unique = jQuery("#unique");
|
var unique = jQuery("#unique");
|
||||||
var required = jQuery("#required");
|
var required = jQuery("#required");
|
||||||
|
var default_value = jQuery("#default_value");
|
||||||
<?php
|
<?php
|
||||||
if(!GETPOST('type') == "select")
|
if(GETPOST('type') != "select")
|
||||||
{
|
{
|
||||||
print 'jQuery("#value_choice").hide();';
|
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(); }
|
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 == '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 == '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 == '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');
|
else size.val('').attr('disabled','disabled');
|
||||||
}
|
}
|
||||||
init_typeoffields('');
|
init_typeoffields('');
|
||||||
@ -64,7 +72,7 @@
|
|||||||
<!-- Label -->
|
<!-- 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>
|
<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 -->
|
<!-- 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) -->
|
<!-- Value (for select list / radio) -->
|
||||||
<tr id="value_choice">
|
<tr id="value_choice">
|
||||||
<td>
|
<td>
|
||||||
@ -75,7 +83,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Default Value -->
|
<!-- 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 -->
|
<!-- 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>
|
<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 -->
|
<!-- Unique -->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user