Quick hack by adding hidden constant to solve a locking feature (how to

add project if likned to another third on project view)
This commit is contained in:
Laurent Destailleur 2016-12-22 16:52:03 +01:00
parent b2776a62d8
commit 081d3f0814
2 changed files with 13 additions and 4 deletions

View File

@ -446,7 +446,7 @@ class FormProjets
* Build a HTML select list of element of same thirdparty to suggest to link them to project
*
* @param string $table_element Table of the element to update
* @param int $socid If of thirdparty to use as filter
* @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
* @return int|string The HTML select list of element or '' if nothing or -1 if KO
@ -502,7 +502,11 @@ class FormProjets
$sql.= " FROM ".MAIN_DB_PREFIX.$table_element." as t";
if ($linkedtothirdparty) $sql.=", ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE ".$projectkey." is null";
if (! empty($socid) && $linkedtothirdparty) $sql.= " AND t.fk_soc=".$socid;
if (! empty($socid) && $linkedtothirdparty)
{
if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid;
else $sql.= " AND t.fk_soc IN (".$socid.")";
}
if (! in_array($table_element, array('expensereport_det'))) $sql.= ' AND t.entity IN ('.getEntity('project',1).')';
if ($linkedtothirdparty) $sql.=" AND s.rowid = t.fk_soc";
if ($sqlfilter) $sql.= " AND ".$sqlfilter;

View File

@ -640,9 +640,14 @@ foreach ($listofreferent as $key => $value)
$addform='';
$idtofilterthirdparty=0;
if (! in_array($tablename, array('facture_fourn', 'commande_fournisseur'))) $idtofilterthirdparty=$object->thirdparty->id;
$array_of_element_linkable_with_different_thirdparty = array('facture_fourn', 'commande_fournisseur');
if (! in_array($tablename, $array_of_element_linkable_with_different_thirdparty))
{
$idtofilterthirdparty=$object->thirdparty->id;
if (! empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty.=','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS;
}
if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty > 0)
if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty)
{
$selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300');
if (! $selectList || ($selectList<0))