diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 3fa17ba4312..ce8ce6e7387 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -953,6 +953,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') if ($search_name != '') $param.='&search_name='.urlencode($search_name); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields + $extrafieldsobjectkey=$contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.skype, t.statut, t.photo,"; @@ -963,6 +964,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); // Add where from extra fields + $extrafieldsobjectkey=$contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; if ($sortfield == "t.name") $sql.=" ORDER BY t.lastname $sortorder, t.firstname $sortorder"; else $sql.= " ORDER BY $sortfield $sortorder"; @@ -991,6 +993,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') } } // Extra fields + $extrafieldsobjectkey=$contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook @@ -1017,6 +1020,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; } // Extra fields + $extrafieldsobjectkey=$contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters=array('arrayfields'=>$arrayfields); @@ -1110,7 +1114,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') } // Extra fields - $extrafieldsobjectkey='socpeople'; + $extrafieldsobjectkey=$contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Actions diff --git a/htdocs/core/tpl/extrafields_list_search_input.tpl.php b/htdocs/core/tpl/extrafields_list_search_input.tpl.php index 2bef2ea42ab..6243b172479 100644 --- a/htdocs/core/tpl/extrafields_list_search_input.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_input.tpl.php @@ -10,36 +10,39 @@ if (empty($conf) || ! is_object($conf)) if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element; // Loop to show all columns of extrafields for the search title line -if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) +if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... { - foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) + if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) { - if (! empty($arrayfields["ef.".$key]['checked'])) { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key]; - print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; + foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + elseif (! in_array($typeofextrafield, array('datetime','timestamp'))) + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + $morecss=''; + if ($typeofextrafield == 'sellist') $morecss='maxwidth200'; + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_', $morecss); + } + elseif (in_array($typeofextrafield, array('datetime','timestamp'))) + { + // TODO + // Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes + } + print ''; } - elseif (! in_array($typeofextrafield, array('datetime','timestamp'))) - { - // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') - $morecss=''; - if ($typeofextrafield == 'sellist') $morecss='maxwidth200'; - echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_', $morecss); - } - elseif (in_array($typeofextrafield, array('datetime','timestamp'))) - { - // TODO - // Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes - } - print ''; } } } \ No newline at end of file diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index 8e126820bf9..8020739d5cb 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -7,18 +7,23 @@ if (empty($conf) || ! is_object($conf)) exit; } +if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element; + // Loop to show all columns of extrafields for the title line -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) +if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) { - if (! empty($arrayfields["ef.".$key]['checked'])) + foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) { - $align=$extrafields->getAlignFlag($key); - $sortonfield = "ef.".$key; - if (! empty($extrafields->attributes[$object->table_element]['computed'][$key])) $sortonfield=''; - if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') print ''; - else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $sortonfield = "ef.".$key; + if (! empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield=''; + if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') print ''; + else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; + } } } } \ No newline at end of file