';
+ }
+ }
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index ee4add6d4c5..d9fa371e443 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -322,7 +322,7 @@ foreach ($search_array_options as $key => $val)
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
$mode=0;
- if (in_array($typ, array('int'))) $mode=1; // Search on a numeric
+ if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 0123d539f50..c925a587b33 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -4841,7 +4841,7 @@ class Form
/* var_dump($val);
var_dump(array_key_exists('enabled', $val));
var_dump(!$val['enabled']);*/
- if (array_key_exists('enabled', $val) && ! $val['enabled'])
+ if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled'])
{
unset($array[$key]); // We don't want this field
continue;
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index 8e4f1ac20aa..c78483bb93d 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -260,7 +260,7 @@ else
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
$mode=0;
- if (in_array($typ, array('int'))) $mode=1; // Search on a numeric
+ if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index 9ae3513fa8a..f520e7ba1a6 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -106,7 +106,7 @@ $hookmanager->initHooks(array($contextpage));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
-$extralabels = $extrafields->fetch_name_optionals_label('project');
+$extralabels = $extrafields->fetch_name_optionals_label('projet');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
// List of fields to search into when doing a "search in all"
@@ -218,16 +218,15 @@ $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."projet as p";
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as ef on (p.rowid = ef.fk_object)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
-
// We'll need this table joined to the select in order to filter by sale
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
if ($search_user > 0)
{
$sql.=", ".MAIN_DB_PREFIX."element_contact as ecp";
}
-
$sql.= " WHERE p.entity IN (".getEntity('project').')';
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
@@ -274,6 +273,19 @@ if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public);
if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale;
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
if ($search_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_user;
+// 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=0;
+ if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
+ if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
+ {
+ $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
+ }
+}
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
@@ -481,10 +493,25 @@ if ($resql)
{
foreach($extrafields->attribute_label as $key => $val)
{
- if (! empty($arrayfields["ef.".$key]['checked'])) print '
';
+ }
}
- }
- // Fields from hook
+ }
+ // Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php
index e140ee2f672..0f955484bfe 100644
--- a/htdocs/projet/tasks/list.php
+++ b/htdocs/projet/tasks/list.php
@@ -66,7 +66,7 @@ $hookmanager->initHooks(array($contextpage));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
-$extralabels = $extrafields->fetch_name_optionals_label('project');
+$extralabels = $extrafields->fetch_name_optionals_label('projet_task');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
// Security check
@@ -226,6 +226,7 @@ $sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid,";
$sql.= " ".MAIN_DB_PREFIX."projet_task as t";
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as ef on (t.rowid = ef.fk_object)";
if ($search_project_user > 0)
{
$sql.=", ".MAIN_DB_PREFIX."element_contact as ecp";
@@ -275,6 +276,19 @@ if ($search_projectstatus >= 0) $sql .= " AND p.fk_statut = ".$db->escape($searc
if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public);
if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user;
if ($search_task_user > 0) $sql.= " AND ect.fk_c_type_contact IN (".join(',',array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user;
+// 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=0;
+ if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
+ if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
+ {
+ $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
+ }
+}
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
@@ -478,14 +492,29 @@ if ($resql)
if (! empty($arrayfields['t.duration_effective']['checked'])) print '
';
if (! empty($arrayfields['t.progress_calculated']['checked'])) print '
';
if (! empty($arrayfields['t.progress']['checked'])) print '
';
- // Extra fields
- if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
- {
- foreach($extrafields->attribute_label as $key => $val)
+ // Extra fields
+ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
+ {
+ foreach($extrafields->attribute_label as $key => $val)
{
- if (! empty($arrayfields["ef.".$key]['checked'])) print '