From 80fc4743c9d82e4c6e0795b93cfecc81a84cb166 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Aug 2015 14:42:07 +0200 Subject: [PATCH] Fix the property "list" was not used. --- htdocs/comm/prospect/list.php | 51 +++++++++++++- htdocs/core/class/extrafields.class.php | 89 +++++++++++++------------ 2 files changed, 95 insertions(+), 45 deletions(-) diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 70847f479c3..6f35709ccfb 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -158,6 +158,9 @@ $sts = array(-1,0,1,2,3); $hookmanager->initHooks(array('prospectlist')); $extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('thirdparty'); + // Do we click on purge search criteria ? if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { @@ -216,13 +219,14 @@ $sql.= " st.libelle as stcomm_label,"; $sql.= " d.nom as departement"; if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) // Add fields for extrafields -foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; +if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list)) 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 $sql.=$hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; +if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)"; if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale @@ -346,7 +350,19 @@ if ($resql) print_liste_field_titre($langs->trans("ProspectLevelShort"),$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("StatusProsp"),$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); - + + // Extrafields + if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list)) + { + foreach($extrafields->attribute_list as $key => $val) + { + if ($val) + { + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,"",$sortfield,$sortorder); + } + } + } + // Hook fields $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -411,7 +427,21 @@ if ($resql) print ' '; print ''; - $parameters=array(); + // Extrafields + if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list)) + { + foreach($extrafields->attribute_list as $key => $val) + { + if ($val) + { + print ''; + //print $extrafields->showInputField($key, $array_options[$key], '', '', 'search_', 4); + print ''; + } + } + } + // Hook fields + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSearch',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -469,6 +499,21 @@ if ($resql) } print ''; + // Extrafields + if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list)) + { + foreach($extrafields->attribute_list as $key => $val) + { + if ($val) + { + print ''; + $paramkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$paramkey); + print ''; + } + } + } + // Hook fields $parameters=array('obj' => $obj); $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ebac8ccd797..5644b3c0137 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -567,7 +567,7 @@ class ExtraFields /** * Load array this->attribute_xxx like attribute_label, attribute_type, ... * - * @param string $elementtype Type of element ('adherent', 'commande', thirdparty', 'facture', 'propal', 'product', ...) + * @param string $elementtype Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) * @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED * @return array Array of attributes for all extra fields */ @@ -631,13 +631,15 @@ class ExtraFields /** * Return HTML string to put an input field into a page * - * @param string $key Key of attribute - * @param string $value Value to show (for date type it must be in timestamp format) - * @param string $moreparam To add more parametes on html input tag - * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * @return string + * @param string $key Key of attribute + * @param string $value Value to show (for date type it must be in timestamp format) + * @param string $moreparam To add more parametes on html input tag + * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) + * @param int $showsize Value for size attribute + * @return string */ - function showInputField($key,$value,$moreparam='',$keyprefix='') + function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$showsize=0) { global $conf,$langs; @@ -651,24 +653,27 @@ class ExtraFields $perms=$this->attribute_perms[$key]; $list=$this->attribute_list[$key]; - if ($type == 'date') + if (empty($showsize)) { - $showsize=10; + if ($type == 'date') + { + $showsize=10; + } + elseif ($type == 'datetime') + { + $showsize=19; + } + elseif (in_array($type,array('int','double'))) + { + $showsize=10; + } + else + { + $showsize=round($size); + if ($showsize > 48) $showsize=48; + } } - elseif ($type == 'datetime') - { - $showsize=19; - } - elseif (in_array($type,array('int','double'))) - { - $showsize=10; - } - else - { - $showsize=round($size); - if ($showsize > 48) $showsize=48; - } - + if (in_array($type,array('date','datetime'))) { $tmp=explode(',',$size); @@ -684,22 +689,22 @@ class ExtraFields if (! is_object($form)) $form=new Form($this->db); // TODO Must also support $moreparam - $out = $form->select_date($value, 'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1); + $out = $form->select_date($value, $keysuffix.'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1); } elseif (in_array($type,array('int'))) { $tmp=explode(',',$size); $newsize=$tmp[0]; - $out=''; + $out=''; } elseif ($type == 'varchar') { - $out=''; + $out=''; } elseif ($type == 'text') { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('options_'.$key.$keyprefix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,5,100); + $doleditor=new DolEditor($keysuffix.'options_'.$key.$keyprefix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,5,100); $out=$doleditor->Create(1); } elseif ($type == 'boolean') @@ -710,26 +715,26 @@ class ExtraFields } else { $checked=' value="1" '; } - $out=''; + $out=''; } elseif ($type == 'mail') { - $out=''; + $out=''; } elseif ($type == 'phone') { - $out=''; + $out=''; } elseif ($type == 'price') { - $out=' '.$langs->getCurrencySymbol($conf->currency); + $out=' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { if (!empty($value)) { $value=price($value); } - $out=' '; + $out=' '; } elseif ($type == 'select') { @@ -737,10 +742,10 @@ class ExtraFields if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && ! $forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox('options_'.$key.$keyprefix, array(), $conf->global->COMPANY_USE_SEARCH_TO_SELECT); + $out.= ajax_combobox($keysuffix.'options_'.$key.$keyprefix, array(), $conf->global->COMPANY_USE_SEARCH_TO_SELECT); } - $out.=''; $out.=''; foreach ($param['options'] as $key=>$val ) { @@ -758,10 +763,10 @@ class ExtraFields if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && ! $forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox('options_'.$key.$keyprefix, array(), $conf->global->COMPANY_USE_SEARCH_TO_SELECT); + $out.= ajax_combobox($keysuffix.'options_'.$key.$keyprefix, array(), $conf->global->COMPANY_USE_SEARCH_TO_SELECT); } - $out.=''; if (is_array($param['options'])) { $param_list=array_keys($param['options']); @@ -907,7 +912,7 @@ class ExtraFields foreach ($param['options'] as $keyopt=>$val ) { - $out.='$val ) { - $out.=''; @@ -1018,7 +1023,7 @@ class ExtraFields $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; } } - $out .= 'rowid . '"'; $out .= 'checked'; @@ -1037,7 +1042,7 @@ class ExtraFields $labeltoshow = '(not defined)'; if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - $out .= 'rowid . '"'; $out .= 'checked'; @@ -1050,7 +1055,7 @@ class ExtraFields $parent = $parentName . ':' . $obj->{$parentField}; } - $out .= 'rowid . '"'; $out .= ((is_array($value_arr) && in_array($obj->rowid, $value_arr)) ? ' checked ' : ''); @@ -1080,7 +1085,7 @@ class ExtraFields dol_include_once($InfoFieldList[1]); $object = new $InfoFieldList[0]($this->db); $object->fetch($value); - $out=''; + $out=''; } /* Add comments