Merge pull request #11035 from atm-ph/new_search_input_on_type_list

NEW show html list instead input text for extrafields typed as list
This commit is contained in:
Laurent Destailleur 2019-11-13 19:26:19 +01:00 committed by GitHub
commit b9900c20cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,8 +3,8 @@
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf)) if (empty($conf) || ! is_object($conf))
{ {
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element; if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element;
@ -12,40 +12,44 @@ if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$o
// Loop to show all columns of extrafields for the search title line // Loop to show all columns of extrafields for the search title line
if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
{ {
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
{ {
if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.'; if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';
if (empty($search_options_pattern)) $search_options_pattern='search_options_'; if (empty($search_options_pattern)) $search_options_pattern='search_options_';
foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
{ {
if (! empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) { if (! empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) {
$align=$extrafields->getAlignFlag($key); $align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key]; $typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">'; print '<td class="liste_titre'.($align?' '.$align:'').'">';
$tmpkey=preg_replace('/'.$search_options_pattern.'/', '', $key); $tmpkey=preg_replace('/'.$search_options_pattern.'/', '', $key);
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]))
{ {
$searchclass=''; $searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; if (in_array($typeofextrafield, array('varchar'))) $searchclass='searchstring';
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="'.$search_options_pattern.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options[$search_options_pattern.$tmpkey]).'">'; print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="'.$search_options_pattern.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options[$search_options_pattern.$tmpkey]).'">';
} }
elseif (in_array($typeofextrafield, array('datetime','timestamp'))) elseif (in_array($typeofextrafield, array('datetime','timestamp')))
{ {
// TODO // 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')
// Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes $morecss='';
} if ($typeofextrafield == 'sellist') $morecss='maxwidth200';
else $keyprefix=$search_options_pattern;
{ if (substr($search_options_pattern, -8) === 'options_') $keyprefix = substr($search_options_pattern, 0, -8);
// 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') echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $keyprefix, $morecss);
$morecss=''; }
if (in_array($typeofextrafield, array('link', 'sellist'))) $morecss='maxwidth200'; else
echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $search_options_pattern, $morecss, 0, $extrafieldsobjectkey, 1); {
} // 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')
print '</td>'; $morecss='';
} if (in_array($typeofextrafield, array('link', 'sellist'))) $morecss='maxwidth200';
} echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $search_options_pattern, $morecss, 0, $extrafieldsobjectkey, 1);
} }
print '</td>';
}
}
}
} }