Mise à NULL de projetid si il n'est pas setté
This commit is contained in:
parent
b22d707880
commit
b8d96efd74
@ -67,40 +67,47 @@ class Facture {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Function create($userid) {
|
Function create($userid)
|
||||||
/*
|
{
|
||||||
* Insertion dans la base
|
/*
|
||||||
*/
|
* Insertion dans la base
|
||||||
$socid = $this->socidp;
|
*/
|
||||||
$number = $this->number;
|
$socid = $this->socidp;
|
||||||
$amount = $this->amount;
|
$number = $this->number;
|
||||||
$remise = $this->remise;
|
$amount = $this->amount;
|
||||||
|
$remise = $this->remise;
|
||||||
|
|
||||||
|
if (! $remise)
|
||||||
|
{
|
||||||
|
$remise = 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->projetid)
|
||||||
|
{
|
||||||
|
$this->projetid = "NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalht = ($amount - $remise);
|
||||||
|
$tva = tva($totalht);
|
||||||
|
$total = $totalht + $tva;
|
||||||
|
|
||||||
|
$sql = "INSERT INTO $this->db_table (facnumber, fk_soc, datec, amount, remise, tva, total, datef, note, fk_user_author,fk_projet) ";
|
||||||
|
$sql .= " VALUES ('$number', $socid, now(), $totalht, $remise, $tva, $total, $this->date,'$note',$userid, $this->projetid);";
|
||||||
|
|
||||||
|
if ( $this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$this->id = $this->db->last_insert_id();
|
||||||
|
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error() . '<b><br>'.$sql;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (! $remise) {
|
|
||||||
$remise = 0 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$totalht = ($amount - $remise);
|
|
||||||
$tva = tva($totalht);
|
|
||||||
$total = $totalht + $tva;
|
|
||||||
|
|
||||||
$sql = "INSERT INTO $this->db_table (facnumber, fk_soc, datec, amount, remise, tva, total, datef, note, fk_user_author,fk_projet) ";
|
|
||||||
$sql .= " VALUES ('$number', $socid, now(), $totalht, $remise, $tva, $total, $this->date,'$note',$userid, $this->projetid);";
|
|
||||||
|
|
||||||
if ( $this->db->query($sql) )
|
|
||||||
{
|
|
||||||
$this->id = $this->db->last_insert_id();
|
|
||||||
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $this->db->error() . '<b><br>'.$sql;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user