Enhance extrafields feature. Input and output fields can be personalised according to their format/size.
This commit is contained in:
parent
b457221277
commit
bf38ea15ba
@ -769,9 +769,12 @@ if ($action == 'create')
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Attribut optionnels
|
||||
foreach($extrafields->attribute_label as $key=>$value)
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
print "<tr><td>".$value.'</td><td><input type="text" name="options_'.$key.'" size="40" value="'.(isset($_POST["options_".$key])?$_POST["options_".$key]:'').'"></td></tr>'."\n";
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:'');
|
||||
print "<tr><td>".$label.'</td><td>';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
/*
|
||||
@ -980,9 +983,12 @@ if ($action == 'edit')
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Other attributes
|
||||
foreach($extrafields->attribute_label as $key=>$value)
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
print "<tr><td>".$value."</td><td><input type=\"text\" name=\"options_".$key."\" size=\"40\" value=\"".$adh->array_options["options_$key"]."\"></td></tr>\n";
|
||||
$value=(isset($_POST["options_$key"])?$_POST["options_$key"]:$adh->array_options["options_$key"]);
|
||||
print "<tr><td>".$label."</td><td>";
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Third party Dolibarr
|
||||
@ -1285,9 +1291,12 @@ if ($rowid && $action != 'edit')
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$adh->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
foreach($extrafields->attribute_label as $key=>$value)
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
print "<tr><td>".$value."</td><td>".$adh->array_options["options_$key"]." </td></tr>\n";
|
||||
$value=$adh->array_options["options_$key"];
|
||||
print "<tr><td>".$label."</td><td>";
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Third party Dolibarr
|
||||
|
||||
@ -397,5 +397,66 @@ class ExtraFields
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return HTML string to put an input field into a page
|
||||
* @param key Key of attribute
|
||||
* @param value Value to show
|
||||
* @param moreparam To add more parametes on html input tag
|
||||
*/
|
||||
function showInputField($key,$value,$moreparam='')
|
||||
{
|
||||
$label=$this->attribute_label[$key];
|
||||
$type=$this->attribute_type[$key];
|
||||
$size=$this->attribute_size[$key];
|
||||
$elementtype=$this->attribute_elementtype[$key];
|
||||
if ($type == 'date')
|
||||
{
|
||||
$showsize=10;
|
||||
}
|
||||
elseif ($type == 'int')
|
||||
{
|
||||
$showsize=10;
|
||||
}
|
||||
else
|
||||
{
|
||||
$showsize=round($size);
|
||||
if ($showsize > 48) $showsize=48;
|
||||
}
|
||||
//print $type.'-'.$size;
|
||||
$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$size.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
|
||||
if ($type == 'date') $out.=' (YYYY-MM-DD)';
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML string to put an output field into a page
|
||||
* @param key Key of attribute
|
||||
* @param value Value to show
|
||||
*/
|
||||
function showOutputField($key,$value,$moreparam='')
|
||||
{
|
||||
$label=$this->attribute_label[$key];
|
||||
$type=$this->attribute_type[$key];
|
||||
$size=$this->attribute_size[$key];
|
||||
$elementtype=$this->attribute_elementtype[$key];
|
||||
if ($type == 'date')
|
||||
{
|
||||
$showsize=10;
|
||||
}
|
||||
elseif ($type == 'int')
|
||||
{
|
||||
$showsize=10;
|
||||
}
|
||||
else
|
||||
{
|
||||
$showsize=round($size);
|
||||
if ($showsize > 48) $showsize=48;
|
||||
}
|
||||
//print $type.'-'.$size;
|
||||
$out=$value;
|
||||
return $out;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -982,10 +982,13 @@ else
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Attribut optionnels
|
||||
foreach($extrafields->attribute_label as $key=>$value)
|
||||
// Other attributes
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
print "<tr><td>".$value.'</td><td colspan="3"><input type="text" name="options_'.$key.'" size="40" value="'.(isset($_POST["options_".$key])?$_POST["options_".$key]:'').'"></td></tr>'."\n";
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:'');
|
||||
print "<tr><td>".$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
// Ajout du logo
|
||||
@ -1130,7 +1133,7 @@ else
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Name
|
||||
print '<tr><td><span class="fieldrequired">'.$langs->trans('ThirdPartyName').'</span></td><td colspan="3"><input type="text" size="40" maxlength="60" name="nom" value="'.$soc->nom.'"></td></tr>';
|
||||
print '<tr><td><span class="fieldrequired">'.$langs->trans('ThirdPartyName').'</span></td><td colspan="3"><input type="text" size="40" maxlength="60" name="nom" value="'.$soc->name.'"></td></tr>';
|
||||
|
||||
// Prefix
|
||||
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
@ -1407,9 +1410,12 @@ else
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
foreach($extrafields->attribute_label as $key=>$value)
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
print "<tr><td>".$value."</td><td colspan=\"3\"><input type=\"text\" name=\"options_".$key."\" size=\"40\" value=\"".$soc->array_options["options_$key"]."\"></td></tr>\n";
|
||||
$value=(isset($_POST["options_$key"])?$_POST["options_$key"]:$soc->array_options["options_$key"]);
|
||||
print "<tr><td>".$label."</td><td colspan=\"3\">";
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Logo
|
||||
@ -1740,9 +1746,12 @@ else
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
foreach($extrafields->attribute_label as $key=>$value)
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
print "<tr><td>".$value."</td><td>".$soc->array_options["options_$key"]." </td></tr>\n";
|
||||
$value=$soc->array_options["options_$key"];
|
||||
print "<tr><td>".$label."</td><td>";
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Ban
|
||||
|
||||
Loading…
Reference in New Issue
Block a user