diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 99686eed40d..5485cb31db6 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -889,17 +889,14 @@ class Categorie } else // mother_id undefined (so it's root) { - /* We have to select any rowid from llx_categorie which which category's type and label - * are equals to those of the calling category, AND which doesn't exist in categorie association - * as children (rowid != fk_categorie_fille) - */ - $sql = "SELECT c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c "; - $sql.= " JOIN ".MAIN_DB_PREFIX."categorie_association as ca"; - $sql.= " ON c.rowid!=ca.fk_categorie_fille"; - $sql.= " WHERE c.type=".$this->type; - $sql.= " AND c.label='".$this->db->escape($this->label)."'"; - $sql.= " AND c.entity IN (".getEntity('category',1).")"; + /* We have to select any rowid from llx_categorie that is not at root level + */ + $sql = "SELECT c.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c "; + $sql.= " WHERE c.type=".$this->type; + $sql.= " AND c.label='".$this->db->escape($this->label)."'"; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; + $sql.= " AND c.rowid NOT IN (SELECT ca.fk_categorie_fille FROM ".MAIN_DB_PREFIX."categorie_association as ca)"; } dol_syslog(get_class($this)."::already_exists sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4d7ef16713d..af79c0967f9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1726,6 +1726,7 @@ class Facture extends CommonObject $this->ref = $num; $this->facnumber=$num; $this->statut=1; + $this->brouillon=0; $this->date_validation=$now; } diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index 24bf6de375e..01bcf3599d2 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -313,7 +313,7 @@ if ($resql) $var=!$var; - print "