Fix the property "list" was not used.

This commit is contained in:
Laurent Destailleur 2015-08-24 14:42:07 +02:00
parent e17abbb59a
commit 80fc4743c9
2 changed files with 95 additions and 45 deletions

View File

@ -158,6 +158,9 @@ $sts = array(-1,0,1,2,3);
$hookmanager->initHooks(array('prospectlist')); $hookmanager->initHooks(array('prospectlist'));
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('thirdparty');
// Do we click on purge search criteria ? // 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 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"; $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) 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 // 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 // Add fields from hooks
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint; $sql.=$hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st"; $sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st";
$sql.= ", ".MAIN_DB_PREFIX."societe as s"; $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)"; $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 (! 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 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("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($langs->trans("StatusProsp"),$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre(''); 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(); $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
@ -411,7 +427,21 @@ if ($resql)
print ' '; print ' ';
print '</td>'; print '</td>';
$parameters=array(); // Extrafields
if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list))
{
foreach($extrafields->attribute_list as $key => $val)
{
if ($val)
{
print '<td class="liste_titre">';
//print $extrafields->showInputField($key, $array_options[$key], '', '', 'search_', 4);
print '</td>';
}
}
}
// Hook fields
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSearch',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListSearch',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
@ -469,6 +499,21 @@ if ($resql)
} }
print '</td>'; print '</td>';
// Extrafields
if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list))
{
foreach($extrafields->attribute_list as $key => $val)
{
if ($val)
{
print '<td>';
$paramkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$paramkey);
print '</td>';
}
}
}
// Hook fields
$parameters=array('obj' => $obj); $parameters=array('obj' => $obj);
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;

View File

@ -567,7 +567,7 @@ class ExtraFields
/** /**
* Load array this->attribute_xxx like attribute_label, attribute_type, ... * 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 * @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED
* @return array Array of attributes for all extra fields * @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 * Return HTML string to put an input field into a page
* *
* @param string $key Key of attribute * @param string $key Key of attribute
* @param string $value Value to show (for date type it must be in timestamp format) * @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 $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 $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @return string * @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; global $conf,$langs;
@ -651,24 +653,27 @@ class ExtraFields
$perms=$this->attribute_perms[$key]; $perms=$this->attribute_perms[$key];
$list=$this->attribute_list[$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'))) if (in_array($type,array('date','datetime')))
{ {
$tmp=explode(',',$size); $tmp=explode(',',$size);
@ -684,22 +689,22 @@ class ExtraFields
if (! is_object($form)) $form=new Form($this->db); if (! is_object($form)) $form=new Form($this->db);
// TODO Must also support $moreparam // 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'))) elseif (in_array($type,array('int')))
{ {
$tmp=explode(',',$size); $tmp=explode(',',$size);
$newsize=$tmp[0]; $newsize=$tmp[0];
$out='<input type="text" class="flat" name="options_'.$key.$keyprefix.'" size="'.$showsize.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>'; $out='<input type="text" class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" size="'.$showsize.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
} }
elseif ($type == 'varchar') elseif ($type == 'varchar')
{ {
$out='<input type="text" class="flat" name="options_'.$key.$keyprefix.'" size="'.$showsize.'" maxlength="'.$size.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>'; $out='<input type="text" class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" size="'.$showsize.'" maxlength="'.$size.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
} }
elseif ($type == 'text') elseif ($type == 'text')
{ {
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; 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); $out=$doleditor->Create(1);
} }
elseif ($type == 'boolean') elseif ($type == 'boolean')
@ -710,26 +715,26 @@ class ExtraFields
} else { } else {
$checked=' value="1" '; $checked=' value="1" ';
} }
$out='<input type="checkbox" class="flat" name="options_'.$key.$keyprefix.'" '.$checked.' '.($moreparam?$moreparam:'').'>'; $out='<input type="checkbox" class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
} }
elseif ($type == 'mail') elseif ($type == 'mail')
{ {
$out='<input type="text" class="flat" name="options_'.$key.$keyprefix.'" size="32" value="'.$value.'" '.($moreparam?$moreparam:'').'>'; $out='<input type="text" class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" size="32" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
} }
elseif ($type == 'phone') elseif ($type == 'phone')
{ {
$out='<input type="text" class="flat" name="options_'.$key.$keyprefix.'" size="20" value="'.$value.'" '.($moreparam?$moreparam:'').'>'; $out='<input type="text" class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" size="20" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
} }
elseif ($type == 'price') elseif ($type == 'price')
{ {
$out='<input type="text" class="flat" name="options_'.$key.$keyprefix.'" size="6" value="'.price($value).'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency); $out='<input type="text" class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" size="6" value="'.price($value).'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
} }
elseif ($type == 'double') elseif ($type == 'double')
{ {
if (!empty($value)) { if (!empty($value)) {
$value=price($value); $value=price($value);
} }
$out='<input type="text" class="flat" name="options_'.$key.$keyprefix.'" size="6" value="'.$value.'" '.($moreparam?$moreparam:'').'> '; $out='<input type="text" class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" size="6" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
} }
elseif ($type == 'select') elseif ($type == 'select')
{ {
@ -737,10 +742,10 @@ class ExtraFields
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && ! $forcecombo) 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'; 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.='<select class="flat" name="options_'.$key.$keyprefix.'" id="options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:'').'>'; $out.='<select class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" id="options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:'').'>';
$out.='<option value="0">&nbsp;</option>'; $out.='<option value="0">&nbsp;</option>';
foreach ($param['options'] as $key=>$val ) 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) if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && ! $forcecombo)
{ {
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; 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.='<select class="flat" name="options_'.$key.$keyprefix.'" id="options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:'').'>'; $out.='<select class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" id="options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:'').'>';
if (is_array($param['options'])) if (is_array($param['options']))
{ {
$param_list=array_keys($param['options']); $param_list=array_keys($param['options']);
@ -907,7 +912,7 @@ class ExtraFields
foreach ($param['options'] as $keyopt=>$val ) foreach ($param['options'] as $keyopt=>$val )
{ {
$out.='<input class="flat" type="checkbox" name="options_'.$key.$keyprefix.'[]" '.($moreparam?$moreparam:''); $out.='<input class="flat" type="checkbox" name="'.$keysuffix.'options_'.$key.$keyprefix.'[]" '.($moreparam?$moreparam:'');
$out.=' value="'.$keyopt.'"'; $out.=' value="'.$keyopt.'"';
if ((is_array($value_arr)) && in_array($keyopt,$value_arr)) { if ((is_array($value_arr)) && in_array($keyopt,$value_arr)) {
@ -924,7 +929,7 @@ class ExtraFields
$out=''; $out='';
foreach ($param['options'] as $keyopt=>$val ) foreach ($param['options'] as $keyopt=>$val )
{ {
$out.='<input class="flat" type="radio" name="options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:''); $out.='<input class="flat" type="radio" name="'.$keysuffix.'options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:'');
$out.=' value="'.$keyopt.'"'; $out.=' value="'.$keyopt.'"';
$out.= ($value==$keyopt?'checked':''); $out.= ($value==$keyopt?'checked':'');
$out.='/>'.$val.'<br>'; $out.='/>'.$val.'<br>';
@ -1018,7 +1023,7 @@ class ExtraFields
$labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' ';
} }
} }
$out .= '<input class="flat" type="checkbox" name="options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : ''); $out .= '<input class="flat" type="checkbox" name="'.$keysuffix.'options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
$out .= ' value="' . $obj->rowid . '"'; $out .= ' value="' . $obj->rowid . '"';
$out .= 'checked'; $out .= 'checked';
@ -1037,7 +1042,7 @@ class ExtraFields
$labeltoshow = '(not defined)'; $labeltoshow = '(not defined)';
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
$out .= '<input class="flat" type="checkbox" name="options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : ''); $out .= '<input class="flat" type="checkbox" name="'.$keysuffix.'options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
$out .= ' value="' . $obj->rowid . '"'; $out .= ' value="' . $obj->rowid . '"';
$out .= 'checked'; $out .= 'checked';
@ -1050,7 +1055,7 @@ class ExtraFields
$parent = $parentName . ':' . $obj->{$parentField}; $parent = $parentName . ':' . $obj->{$parentField};
} }
$out .= '<input class="flat" type="checkbox" name="options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : ''); $out .= '<input class="flat" type="checkbox" name="'.$keysuffix.'options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
$out .= ' value="' . $obj->rowid . '"'; $out .= ' value="' . $obj->rowid . '"';
$out .= ((is_array($value_arr) && in_array($obj->rowid, $value_arr)) ? ' checked ' : ''); $out .= ((is_array($value_arr) && in_array($obj->rowid, $value_arr)) ? ' checked ' : '');
@ -1080,7 +1085,7 @@ class ExtraFields
dol_include_once($InfoFieldList[1]); dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db); $object = new $InfoFieldList[0]($this->db);
$object->fetch($value); $object->fetch($value);
$out='<input type="text" class="flat" name="options_'.$key.$keyprefix.'" size="20" value="'.$object->ref.'" >'; $out='<input type="text" class="flat" name="'.$keysuffix.'options_'.$key.$keyprefix.'" size="20" value="'.$object->ref.'" >';
} }
/* Add comments /* Add comments