From db319803ec6ce74eff5545b85dcb37ae583c3899 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 15 Sep 2017 12:17:18 +0200 Subject: [PATCH 1/3] add sreach on extrafeilds on contract service list --- htdocs/contrat/services.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index cd445e682eb..433f0bae4b2 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -237,6 +237,23 @@ if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $fi if (! empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql.= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1)."'"; if (! empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql.= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2)."'"; if (! empty($filter_opcloture) && $filter_opcloture != -1 && $filter_datecloture != '') $sql.= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture)."'"; +// Add where from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode_search_extrafields=0; + if (in_array($typ, array('int','double'))) $mode_search_extrafields=1; // Search on a numeric + + if ($val && ( ($crit != '' && in_array($typ, array('sellist'))) || ! empty($crit))) + { + $sql .= ' AND ef.'.$tmpkey.'='.$crit; + } else if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search_extrafields); + } +} + $sql .= $db->order($sortfield,$sortorder); $nbtotalofrecords = ''; @@ -464,7 +481,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); @@ -473,6 +490,11 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; print ''; } + else + { + // 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_'.$key], '', '', 'search_'); + } print ''; } } From 3c7c53f321396d37dd3b6233c3398d78d96b3dad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2017 15:55:43 +0200 Subject: [PATCH 2/3] Update services.php --- htdocs/contrat/services.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 433f0bae4b2..4a7658e5c9d 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -240,20 +240,17 @@ if (! empty($filter_opcloture) && $filter_opcloture != -1 && $filter_datecloture // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; - $mode_search_extrafields=0; - if (in_array($typ, array('int','double'))) $mode_search_extrafields=1; // Search on a numeric - - if ($val && ( ($crit != '' && in_array($typ, array('sellist'))) || ! empty($crit))) - { - $sql .= ' AND ef.'.$tmpkey.'='.$crit; - } else if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search_extrafields); - } + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode_search_extrafields=0; + if (in_array($typ, array('int','double','real'))) $mode_search_extrafields=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode_search_extrafields=2; // Search on a foreign key int + if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search_extrafields); + } } - $sql .= $db->order($sortfield,$sortorder); $nbtotalofrecords = ''; From 3dbf4cf1767c699e7959c020bcf82bbebf44f63c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2017 15:58:02 +0200 Subject: [PATCH 3/3] Update services.php --- htdocs/contrat/services.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 4a7658e5c9d..e5a5c21c00b 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -243,12 +243,12 @@ foreach ($search_array_options as $key => $val) $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; - $mode_search_extrafields=0; - if (in_array($typ, array('int','double','real'))) $mode_search_extrafields=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode_search_extrafields=2; // Search on a foreign key int + $mode_search=0; + if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search_extrafields); + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search); } } $sql .= $db->order($sortfield,$sortorder);