Merge branch 'extrafields' into fgd

Conflicts:
	htdocs/core/class/commondocgenerator.class.php
This commit is contained in:
jfefe 2013-02-18 00:59:32 +01:00
commit 4ff08b026f
3 changed files with 55 additions and 12 deletions

View File

@ -171,11 +171,13 @@ abstract class CommonDocGenerator
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label('company',true);
//Get extrafield values
$object->fetch_optionals($object->id,$extralabels);
foreach($extrafields->attribute_label as $key=>$label)
{
if($extrafields->attribute_type[$key] == 'price')
{
$object->array_options['options_'.$key] = price($object->array_options['options_'.$key]).' '.$outputlangs->getCurrencySymbol($conf->currency);
}
$array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key]));
}
}

View File

@ -44,6 +44,10 @@ class ExtraFields
var $attribute_unique;
// Array to store if attribute is required or not
var $attribute_required;
// Array to store parameters of attribute (used in select type)
var $attribute_param;
// Int to store position of attribute
var $attribute_pos;
var $error;
var $errno;

View File

@ -998,14 +998,25 @@ else
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
$e=0;
foreach($extrafields->attribute_label as $key=>$label)
{
$colspan='3';
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:''));
print '<tr><td';
if (($e % 2) == 0)
{
print '<tr>';
$colspan='0';
}
print '<td';
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
print '>'.$label.'</td><td colspan="3">';
print '>'.$label.'</td>';
print '<td colspan="'.$colspan.'">';
print $extrafields->showInputField($key,$value);
print '</td></tr>'."\n";
print '</td>';
if (($e % 2) == 1) print '</tr>'."\n";
$e++;
}
}
@ -1426,23 +1437,38 @@ else
print '</td>';
print '</tr>';
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
$old_pos=0;
$e=0;
foreach($extrafields->attribute_label as $key=>$label)
{
$colspan = '3';
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
print '<tr><td';
if (($e % 2) == 0)
{
print '<tr>'."\n";
$colspan = '0';
}
print '<td';
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
print '>'.$label.'</td><td colspan="3">';
print '>'.$label.'</td>'."\n";
print '<td colspan="'.$colspan.'">';
print $extrafields->showInputField($key,$value);
print "</td></tr>\n";
print "</td>"."\n";
if (($e % 2) == 1 )
{
print "</tr>\n";
}
$old_pos = $extrafields->attribute_pos[$key];
$e++;
}
}
// Logo
print '<tr>';
print '<td>'.$langs->trans("Logo").'</td>';
@ -1756,12 +1782,23 @@ else
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
$e=0;
foreach($extrafields->attribute_label as $key=>$label)
{
$colspan='3';
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:''));
print '<tr><td>'.$label.'</td><td colspan="3">';
if (($e % 2) == 0)
{
print '<tr>';
$colspan='0';
}
print '<td>'.$label.'</td>';
print '<td colspan="'.$colspan.'">';
print $extrafields->showOutputField($key,$value);
print "</td></tr>\n";
print "</td>";
if (($e % 2) == 1) print '</tr>';
$e++;
}
}