From 989d949833d85f82c9a091dbf115706f097f8f1a Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 25 Sep 2002 18:36:27 +0000 Subject: [PATCH] *** empty log message *** --- htdocs/facture.class.php3 | 128 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 htdocs/facture.class.php3 diff --git a/htdocs/facture.class.php3 b/htdocs/facture.class.php3 new file mode 100644 index 00000000000..1c03771efad --- /dev/null +++ b/htdocs/facture.class.php3 @@ -0,0 +1,128 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ + +class Facture { + var $id; + var $db; + var $socidp; + var $number; + var $author; + var $date; + var $ref; + var $amount; + var $remise; + var $tva; + var $total; + var $note; + var $db_table; + + /* + * Initialisation + * + */ + + Function Facture($DB, $soc_idp="") { + $this->db = $DB ; + $this->socidp = $soc_idp; + $this->products = array(); + $this->db_table = "llx_facture"; + $this->amount = 0; + $this->remise = 0; + $this->tva = 0; + $this->total = 0; + } + /* + * + * + * + */ + + Function create() { + /* + * Insertion dans la base + */ + $socid = $this->socidp; + $number = $this->number; + $amount = $this->amount; + $remise = $this->remise; + + if (! $remise) { $remise = 0 ; } + + $totalht = ($amount - $remise); + $tva = tva($totalht); + $total = $totalht + $tva; + + + $sql = "INSERT INTO $this->db_table (facnumber, fk_soc, datec, datef, note, amount, remise, tva, total) "; + $sql .= " VALUES ('$number', $socid, now(), $this->date,'$note', $amount, $remise, $tva, $total);"; + + if ( $this->db->query($sql) ) { + + } else { + print $this->db->error() . '
'.$sql; + } + return $this->id; + } + + /* + * + * + * + */ + Function fetch($rowid) { + + $sql = "SELECT ref,price,remise,".$this->db->pdate(datep)."as dp FROM llx_facture WHERE rowid=$rowid;"; + + if ($this->db->query($sql) ) { + if ($this->db->num_rows()) { + $obj = $this->db->fetch_object(0); + + $this->id = $rowid; + $this->datep = $obj->dp; + $this->ref = $obj->ref; + $this->price = $obj->price; + $this->remise = $obj->remise; + + $this->db->free(); + } + } else { + print $this->db->error(); + } + } + /* + * + * + * + */ + Function valid($userid) { + $sql = "UPDATE llx_facture SET fk_statut = 1, date_valid=now(), fk_user_valid=$userid"; + $sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;"; + + if ($this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + +} +?>