From d7f58d0087b2b556466340c9c69852a9bf98cd51 Mon Sep 17 00:00:00 2001 From: Philippe Date: Tue, 24 Jul 2018 20:28:49 +0200 Subject: [PATCH 1/3] FIX search on ref project on propal list --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index f7fd5d9b2bb..a8e51d32173 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -283,7 +283,7 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country). if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer); -if ($search_refproject) $sql .= natural_search('pr.ref', $search_refprojet); +if ($search_refproject) $sql .= natural_search('pr.ref', $search_refproject); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_login) $sql .= natural_search("u.login", $search_login); From 1297470c999d510cdf7d96b46a4e0ce3092ab151 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 26 Jul 2018 15:05:32 +0200 Subject: [PATCH 2/3] FIX project overview (can use any fields as fk_projet) --- htdocs/core/class/html.formprojet.class.php | 4 ++-- htdocs/projet/class/project.class.php | 4 ++-- htdocs/projet/element.php | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index a6c94d79780..25e2cb13d81 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -458,7 +458,7 @@ class FormProjets * @param int $limitonstatus Add filters to limit length of list to opened status (for example to avoid ERR_RESPONSE_HEADERS_TOO_BIG on project/element.php page). TODO To implement * @return int|string The HTML select list of element or '' if nothing or -1 if KO */ - function select_element($table_element, $socid=0, $morecss='', $limitonstatus=-2) + function select_element($table_element, $socid=0, $morecss='', $limitonstatus=-2,$projectkey="fk_projet") { global $conf, $langs; @@ -468,7 +468,7 @@ class FormProjets if (! in_array($table_element, array('don','expensereport_det','expensereport','loan','stock_mouvement','chargesociales'))) $linkedtothirdparty=true; $sqlfilter=''; - $projectkey="fk_projet"; + //print $table_element; switch ($table_element) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index edfbef084df..1078733c19e 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -518,7 +518,7 @@ class Project extends CommonObject * @param int $datee End date * @return mixed Array list of object ids linked to project, < 0 or string if error */ - function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') + function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='', $project_field='fk_projet') { $elements = array(); @@ -548,7 +548,7 @@ class Project extends CommonObject } else { - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet IN (". $ids .")"; + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE ".$project_field." IN (". $ids .")"; } if ($dates > 0) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index dd19ceeb263..93b4cb1b810 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -562,11 +562,12 @@ foreach ($listofreferent as $key => $value) $datefieldname=$value['datefieldname']; $qualified=$value['test']; $margin = $value['margin']; + $project_field = $value['project_field']; if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'plus') { $element = new $classname($db); - $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); + $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field)?$project_field:'fk_projet'); if (count($elementarray)>0 && is_array($elementarray)) { @@ -697,6 +698,7 @@ foreach ($listofreferent as $key => $value) $urlnew=$value['urlnew']; $buttonnew=$value['buttonnew']; $testnew=$value['testnew']; + $project_field=$value['project_field']; if ($qualified) { @@ -719,7 +721,7 @@ foreach ($listofreferent as $key => $value) if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, array('payment_various'))) { - $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300'); + $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300',-2,!empty($project_field)?$project_field:'fk_projet'); if (! $selectList || ($selectList<0)) { setEventMessages($formproject->error,$formproject->errors,'errors'); @@ -787,7 +789,7 @@ foreach ($listofreferent as $key => $value) else print ''.$langs->trans("Status").''; print ''; - $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); + $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee,!empty($project_field)?$project_field:'fk_projet'); if (is_array($elementarray) && count($elementarray)>0) { $total_ht = 0; From 37a4a0c4888fd6cef0be2c88e4845faeb1c4193e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 31 Jul 2018 10:02:36 +0200 Subject: [PATCH 3/3] fix for travis --- htdocs/core/class/html.formprojet.class.php | 1 + htdocs/projet/class/project.class.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 25e2cb13d81..2e3bdafc319 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -456,6 +456,7 @@ class FormProjets * @param string $socid If of thirdparty to use as filter or 'id1,id2,...' * @param string $morecss More CSS * @param int $limitonstatus Add filters to limit length of list to opened status (for example to avoid ERR_RESPONSE_HEADERS_TOO_BIG on project/element.php page). TODO To implement + * @param string $projectkey Equivalent key to fk_projet for actual table_element * @return int|string The HTML select list of element or '' if nothing or -1 if KO */ function select_element($table_element, $socid=0, $morecss='', $limitonstatus=-2,$projectkey="fk_projet") diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 1078733c19e..c8c36a697fb 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -516,9 +516,10 @@ class Project extends CommonObject * @param string $datefieldname name of date field for filter * @param int $dates Start date * @param int $datee End date + * @param string $projectkey Equivalent key to fk_projet for actual type * @return mixed Array list of object ids linked to project, < 0 or string if error */ - function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='', $project_field='fk_projet') + function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='', $projectkey='fk_projet') { $elements = array(); @@ -548,7 +549,7 @@ class Project extends CommonObject } else { - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE ".$project_field." IN (". $ids .")"; + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE ".$projectkey." IN (". $ids .")"; } if ($dates > 0)