Merge branch '3.2' of git+ssh://git@github.com/Dolibarr/dolibarr.git into 3.2

This commit is contained in:
Regis Houssin 2012-08-06 17:41:06 +02:00
commit 99e234d703
4 changed files with 21 additions and 14 deletions

View File

@ -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);

View File

@ -1726,6 +1726,7 @@ class Facture extends CommonObject
$this->ref = $num;
$this->facnumber=$num;
$this->statut=1;
$this->brouillon=0;
$this->date_validation=$now;
}

View File

@ -313,7 +313,7 @@ if ($resql)
$var=!$var;
print "<tr $bc[$var]>";
print "<tr ".$bc[$var].">";
$classname = "impayee";
print '<td nowrap="nowrap">';
@ -380,6 +380,7 @@ if ($resql)
print '<td align="right"><b>'.price($total_paid).'</b></td>';
print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
}

View File

@ -131,7 +131,14 @@ class CategorieTest extends PHPUnit_Framework_TestCase
// We create a category
$localobject=new Categorie($this->savdb);
$localobject->initAsSpecimen();
$resultFirstCreate=$localobject->create($user);
// Check it does not exist (return 0)
$resultCheck=$localobject->already_exists();
print __METHOD__." resultCheck=".$resultCheck."\n";
$this->assertEquals(0, $resultCheck);
// Create
$resultFirstCreate=$localobject->create($user);
print __METHOD__." resultFirstCreate=".$resultFirstCreate."\n";
$this->assertGreaterThan(0, $resultFirstCreate);
@ -139,8 +146,9 @@ class CategorieTest extends PHPUnit_Framework_TestCase
$localobject2=new Categorie($this->savdb);
$localobject2->initAsSpecimen();
// Check it does exist (return 1)
$resultCheck=$localobject2->already_exists();
print __METHOD__." resultCheck=".$resultCheck."\n";
print __METHOD__." resultCheck=".$resultCheck."\n";
$this->assertGreaterThan(0, $resultCheck);
$resultSecondCreate=$localobject2->create($user);