Récupération du nom et de l'id de la societe auquel la facture est rattachée
This commit is contained in:
parent
dcc19539a6
commit
a42c21c3db
@ -141,7 +141,9 @@ class FactureFourn
|
|||||||
$sql = "SELECT fk_soc,libelle,facnumber,amount,remise,".$this->db->pdate(datef)."as df";
|
$sql = "SELECT fk_soc,libelle,facnumber,amount,remise,".$this->db->pdate(datef)."as df";
|
||||||
$sql .= ", total_ht, total_tva, total_ttc, fk_user_author";
|
$sql .= ", total_ht, total_tva, total_ttc, fk_user_author";
|
||||||
$sql .= ", fk_statut, paye";
|
$sql .= ", fk_statut, paye";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f WHERE f.rowid=$rowid;";
|
$sql .= ", s.nom as socnom, s.idp as socidp";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."societe as s";
|
||||||
|
$sql .= " WHERE f.rowid=$rowid AND f.fk_soc = s.idp ;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
@ -166,6 +168,9 @@ class FactureFourn
|
|||||||
$this->statut = $obj->fk_statut;
|
$this->statut = $obj->fk_statut;
|
||||||
$this->paye = $obj->paye;
|
$this->paye = $obj->paye;
|
||||||
|
|
||||||
|
$this->socidp = $obj->socidp;
|
||||||
|
$this->socnom = $obj->socnom;
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -266,115 +271,116 @@ class FactureFourn
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Ajout ligne facture fourn
|
* Ajoute une ligne dans la facture
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
Function addline($desc, $pu, $tauxtva, $qty)
|
Function addline($desc, $pu, $tauxtva, $qty)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_fourn_det (fk_facture_fourn)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_fourn_det (fk_facture_fourn)";
|
||||||
$sql .= " VALUES ($this->id);";
|
$sql .= " VALUES ($this->id);";
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$idligne = $this->db->last_insert_id();
|
$idligne = $this->db->last_insert_id();
|
||||||
|
|
||||||
$this->updateline($idligne, $desc, $pu, $tauxtva, $qty);
|
$this->updateline($idligne, $desc, $pu, $tauxtva, $qty);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $this->db->error();
|
print $this->db->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise a jour prix facture
|
// Mise a jour prix facture
|
||||||
$this->updateprice($this->id);
|
$this->updateprice($this->id);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Mise a jour ligne facture fourn
|
* Mise a jour ligne facture fourn
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Function updateline($id, $label, $puht, $tauxtva, $qty=1)
|
Function updateline($id, $label, $puht, $tauxtva, $qty=1)
|
||||||
{
|
{
|
||||||
$puht = ereg_replace(",",".",$puht);
|
$puht = ereg_replace(",",".",$puht);
|
||||||
|
|
||||||
$totalht = $puht * $qty;
|
$totalht = $puht * $qty;
|
||||||
$tva = tva($totalht, $tauxtva);
|
$tva = ($totalht * $tauxtva / 100);
|
||||||
$totalttc = $totalht + $tva;
|
$totalttc = $totalht + $tva;
|
||||||
|
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det ";
|
||||||
$sql .= "SET description ='".$label."'";
|
$sql .= "SET description ='".$label."'";
|
||||||
$sql .= ", pu_ht = " . $puht;
|
$sql .= ", pu_ht = " . $puht;
|
||||||
$sql .= ", qty =".$qty;
|
$sql .= ", qty =".$qty;
|
||||||
$sql .= ", total_ht=".$totalht;
|
$sql .= ", total_ht=".$totalht;
|
||||||
$sql .= ", tva=".$tva;
|
$sql .= ", tva=".$tva;
|
||||||
$sql .= ", tva_taux=".$tauxtva;
|
$sql .= ", tva_taux=".$tauxtva;
|
||||||
$sql .= ", total_ttc=".$totalttc;
|
$sql .= ", total_ttc=".$totalttc;
|
||||||
|
|
||||||
$sql .= " WHERE rowid = $id";
|
$sql .= " WHERE rowid = $id";
|
||||||
|
|
||||||
if (! $this->db->query($sql) )
|
if (! $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
print $this->db->error() . '<b><br>'.$sql;
|
print $this->db->error() . '<b><br>'.$sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise a jour prix facture
|
// Mise a jour prix facture
|
||||||
$this->updateprice($this->id);
|
$this->updateprice($this->id);
|
||||||
}
|
}
|
||||||
/*
|
/**
|
||||||
* Supprime ligne facture fourn
|
* Supprime une ligne de la facture
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Function deleteline($rowid)
|
Function deleteline($rowid)
|
||||||
{
|
{
|
||||||
// Supprime ligne
|
// Supprime ligne
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_det ";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_det ";
|
||||||
$sql .= " WHERE rowid = $rowid";
|
$sql .= " WHERE rowid = $rowid";
|
||||||
|
|
||||||
if (! $this->db->query($sql) )
|
if (! $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
print "Erreur : ".$this->db->error() . '<b><br>'.$sql;
|
print "Erreur : ".$this->db->error() . '<b><br>'.$sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise a jour prix facture
|
// Mise a jour prix facture
|
||||||
$this->updateprice($this->id);
|
$this->updateprice($this->id);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*
|
/**
|
||||||
*
|
*Mets à jour le prix total de la facture
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Function updateprice($facid)
|
Function updateprice($facid)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "SELECT sum(total_ht), sum(tva), sum(total_ttc) FROM ".MAIN_DB_PREFIX."facture_fourn_det";
|
$sql = "SELECT sum(total_ht), sum(tva), sum(total_ttc) FROM ".MAIN_DB_PREFIX."facture_fourn_det";
|
||||||
$sql .= " WHERE fk_facture_fourn = $facid;";
|
$sql .= " WHERE fk_facture_fourn = $facid;";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
if ($this->db->num_rows() )
|
||||||
|
{
|
||||||
|
$row = $this->db->fetch_row();
|
||||||
|
$total_ht = $row[0];
|
||||||
|
$total_tva = $row[1];
|
||||||
|
$total_ttc = $row[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn SET total_ht = $total_ht, total_tva = $total_tva, total_ttc = $total_ttc";
|
||||||
|
$sql .= " WHERE rowid = $facid ;";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
if ($this->db->num_rows() )
|
|
||||||
{
|
|
||||||
$row = $this->db->fetch_row();
|
|
||||||
$total_ht = $row[0];
|
|
||||||
$total_tva = $row[1];
|
|
||||||
$total_ttc = $row[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn SET total_ht = $total_ht, total_tva = $total_tva, total_ttc = $total_ttc";
|
|
||||||
$sql .= " WHERE rowid = $facid ;";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $this->db->error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Génération du PDF
|
* Génération du PDF
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user