diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 1e00e48f36e..45ca1c5212d 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -310,7 +310,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_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')'; if ($search_societe) $sql .= natural_search('s.nom', $search_societe); @@ -432,7 +432,7 @@ if ($resql) if ($search_year) $param.='&search_year='.urlencode($search_year); if ($search_ref) $param.='&search_ref='.urlencode($search_ref); if ($search_refcustomer) $param.='&search_refcustomer='.urlencode($search_refcustomer); - if ($search_refprojet) $param.='&search_refprojet='.urlencode($search_refprojet); + if ($search_refproject) $param.='&search_refproject='.urlencode($search_refproject); if ($search_societe) $param.='&search_societe='.urlencode($search_societe); if ($search_user > 0) $param.='&search_user='.urlencode($search_user); if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index f437920caf9..dcc282794b9 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -468,9 +468,10 @@ 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) + function select_element($table_element, $socid=0, $morecss='', $limitonstatus=-2,$projectkey="fk_projet") { global $conf, $langs; @@ -480,7 +481,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 210ff9e09a9..e117dc3eb39 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -523,9 +523,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='') + function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='', $projectkey='fk_projet') { $elements = array(); @@ -555,7 +556,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 ".$projectkey." IN (". $ids .")"; } if ($dates > 0) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 7a263ba3995..79b2be5b009 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -575,11 +575,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)) { @@ -710,6 +711,7 @@ foreach ($listofreferent as $key => $value) $urlnew=$value['urlnew']; $buttonnew=$value['buttonnew']; $testnew=$value['testnew']; + $project_field=$value['project_field']; if ($qualified) { @@ -732,7 +734,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'); @@ -800,7 +802,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;