diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index e6376bbe7eb..dc438d2b929 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1292,9 +1292,11 @@ class Project extends CommonObject switch ($Tablename) { case "facture": - case "facture_fourn": $sql = "SELECT rowid, facnumber as ref"; break; + case "facture_fourn": + $sql = "SELECT rowid, ref"; + break; case "facture_rec": $sql = "SELECT rowid, titre as ref"; break; @@ -1309,7 +1311,9 @@ class Project extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX.$Tablename; $sql.= " WHERE ".$projectkey." is null"; - $sql.= " AND fk_soc=".$this->societe->id; + if (!empty($this->societe->id)) { + $sql.= " AND fk_soc=".$this->societe->id; + } $sql.= " ORDER BY ref DESC"; dol_syslog("Project.Lib::select_element sql=".$sql);