Finished migration to the new architecture of extrafields

This commit is contained in:
Laurent Destailleur 2019-11-02 17:38:19 +01:00
parent 89f1904793
commit 6f82c212a0
9 changed files with 14 additions and 24 deletions

View File

@ -393,7 +393,7 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine=0;
foreach ($extrafields->attribute_computed as $key => $val)
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
}

View File

@ -407,7 +407,7 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine=0;
foreach ($extrafields->attribute_computed as $key => $val)
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
}

View File

@ -117,8 +117,6 @@ if (GETPOST("orphelins", "alpha"))
$sql = "SELECT p.rowid, p.ref, p.datep as dp, p.amount,";
$sql.= " p.statut, p.num_paiement,";
$sql.= " c.code as paiement_code";
// Add fields for extrafields
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
@ -139,8 +137,6 @@ else
$sql.= " c.code as paiement_code,";
$sql.= " ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal,";
$sql.= " s.rowid as socid, s.nom as name, s.email";
// Add fields for extrafields
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook

View File

@ -596,7 +596,7 @@ abstract class CommonDocGenerator
$line->fetch_optionals();
$resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs);
// Check if the current line belongs to a supplier order
if (get_class($line) == 'CommandeFournisseurLigne')
{
@ -606,7 +606,7 @@ abstract class CommonDocGenerator
$columns = "";
foreach ($extralabels as $key => $value)
$columns .= "$key, ";
if ($columns != "")
{
$columns = substr($columns, 0, strlen($columns) - 2);
@ -843,7 +843,7 @@ abstract class CommonDocGenerator
$id = $object->array_options['options_'.$key];
if ($id != "")
{
$param = $extrafields->attribute_param[$key];
$param = $extrafields->attributes[$object->table_element]['param'][$key];
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
$InfoFieldList = explode(":", $param_list[0]);
$classname=$InfoFieldList[0];

View File

@ -302,10 +302,10 @@ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
);
print '</td><td>' . "\n";
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]);
print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attributes[$key]['param']['options'], $array_query['options_' . $key]);
print '</td><td>' . "\n";
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]);
print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attributes[$key]['param']['options'], $array_query['options_' . $key]);
print '</td><td>' . "\n";
} else {
print '<table class="nobordernopadding"><tr>';
@ -499,10 +499,10 @@ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
);
print '</td><td>' . "\n";
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']);
print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attributes[$key]['param']['options'], $array_query['options_' . $key . '_cnct']);
print '</td><td>' . "\n";
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']);
print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attributes[$key]['param']['options'], $array_query['options_' . $key . '_cnct']);
print '</td><td>' . "\n";
} else {
print '<table class="nobordernopadding"><tr>';

View File

@ -216,7 +216,9 @@ $sql.= " p.ref as product_ref,";
$sql.= " p.label as product_label,";
$sql.= " p.tobatch";
// Add fields for extrafields
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
if (! empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook

View File

@ -473,7 +473,7 @@ foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/', '', $key);
$typ=$extrafields->attribute_type[$tmpkey];
$typ=$extrafields->attributes[$object->table_element]['type'][$tmpkey];
$mode=0;
if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric
if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int

View File

@ -71,7 +71,7 @@ foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/', '', $key);
$typ=$extrafields->attribute_type[$tmpkey];
$typ=$extrafields->attributes[$object->table_element]['type'][$tmpkey];
if ($val != '') {
$param.='&search_options_'.$tmpkey.'='.urlencode($val);
}

View File

@ -428,14 +428,6 @@ print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '',
print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine=0;
foreach ($extrafields->attribute_computed as $key => $val)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
}
// Detect if we need a fetch on each output line
$needToFetchEachLine=0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)