From 9c4fa650d7f143a62c13b287acbe09cf48f00504 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 21 Jul 2003 13:05:24 +0000 Subject: [PATCH] =?UTF-8?q?Gestion=20des=20conditions=20de=20r=E9glement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/facture.php3 | 129 +++++++++++++++++++++---------------- htdocs/facture.class.php3 | 32 +++++++-- 2 files changed, 101 insertions(+), 60 deletions(-) diff --git a/htdocs/compta/facture.php3 b/htdocs/compta/facture.php3 index 84ce6a89d87..65dd541041b 100644 --- a/htdocs/compta/facture.php3 +++ b/htdocs/compta/facture.php3 @@ -133,30 +133,26 @@ if ($action == 'delete') if ($action == 'add') { - $datefacture = $db->idate(mktime(12, 0 , 0, $remonth, $reday, $reyear)); + $datefacture = mktime(12, 0 , 0, $remonth, $reday, $reyear); + + $facture = new Facture($db, $socid); + + $facture->number = $HTTP_POST_VARS["facnumber"]; + $facture->date = $datefacture; + $facture->note = $HTTP_POST_VARS["note"]; + $facture->projetid = $HTTP_POST_VARS["projetid"]; + $facture->cond_reglement = $HTTP_POST_VARS["condid"]; if (! $propalid) { - $facture = new Facture($db, $socid); - $facture->number = $facnumber; - $facture->date = $datefacture; - $facture->projetid = $HTTP_POST_VARS["projetid"]; - $facture->note = $note; - $facture->amount = $amount; - $facture->remise = $remise; + $facture->amount = $HTTP_POST_VARS["amount"]; + $facture->remise = $HTTP_POST_VARS["remise"]; $facid = $facture->create($user->id, $statut, $note); - } else { - $facture = new Facture($db, $socid); - - $facture->number = $facnumber; - $facture->date = $datefacture; - $facture->note = $note; - $facture->projetid = $HTTP_POST_VARS["projetid"]; - $facture->amount = $amount; + $facture->amount = $HTTP_POST_VARS["amount"]; $facture->remise = $remise; $facture->propalid = $propalid; @@ -291,7 +287,7 @@ if ($action == 'create') print ''; print "idp\">"; - print ''; + print '
'; print ""; print ""; @@ -299,7 +295,7 @@ if ($action == 'create') print ""; print ""; - print ''; print ""; print ""; + print ""; + print "
Client :$obj->nomCommentaire
Auteur :".$user->fullname."'; + print ''; print '
Date :"; @@ -309,6 +305,26 @@ if ($action == 'create') print "
Numéro :
Conditions de réglement :"; + $sql = "SELECT rowid, libelle FROM llx_cond_reglement ORDER BY sortorder"; + $result = $db->query($sql); + $conds=array(); + if ($result) + { + $num = $db->num_rows(); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($i); + $conds[$objp->rowid]=$objp->libelle; + $i++; + } + $db->free(); + } + + $html->select_array("condid",$conds); + print "
Projet :"; $proj = new Project($db); $html->select_array("projetid",$proj->liste_array($socidp)); @@ -390,36 +406,27 @@ else $author->id = $obj->fk_user_author; $author->fetch(); - print_titre("Facture : ".$obj->facnumber); + print_titre("Facture : ".$fac->ref); - print ""; - print "
"; /* * Facture */ print ""; print ""; print ""; + print "socidp\">$obj->socnom"; + print ""; + print ""; - print "\n"; + print "\n"; + print ""; print ""; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print "
Client"; - print "socidp\">$obj->socnom
Conditions de réglement : " . $fac->cond_reglement ."
Date".strftime("%A %d %B %Y",$obj->df)."
".strftime("%A %d %B %Y",$obj->df)."Date limite de réglement : " . strftime("%d %B %Y",$fac->date_lim_reglement) ."
Auteur$author->fullname
Montant'.price($fac->total_ht).'euros HT
TVA'.price($fac->total_tva).'euros
Total'.price($fac->total_ttc).'euros TTC
"; - - print "
"; + + print ''; $_MONNAIE="euros"; - + /* * Paiements */ @@ -431,7 +438,7 @@ else { $num = $db->num_rows(); $i = 0; $total = 0; - print "

Paiements"; + print "Paiements"; echo ''; print ""; print ""; @@ -478,11 +485,20 @@ else } print ""; - if ($obj->note) + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($fac->note) { - print ""; + print '"; } - print "
Date
Montant'.price($fac->total_ht).'euros HT
TVA'.price($fac->total_tva).'euros
Total'.price($fac->total_ttc).'euros TTC
Note : ".nl2br($obj->note)."
Note : '.nl2br($obj->note)."
"; + + print "


"; /* * Lignes de factures * @@ -698,7 +714,7 @@ else if ($num) { $i = 0; $total = 0; - print ''; + print '
'; print ""; print ""; print ""; @@ -709,9 +725,9 @@ else { $objp = $db->fetch_object( $i); $var=!$var; - print ""; - print "\n"; - print ''; + print ""; + print "\n"; + print ''; print ""; $i++; } @@ -844,7 +860,7 @@ else $sortfield="f.datef"; } - $sql = "SELECT s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid"; + $sql = "SELECT s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid, f.fk_statut"; $sql .= " FROM llx_societe as s,llx_facture as f WHERE f.fk_soc = s.idp"; if ($socidp) @@ -887,10 +903,10 @@ else $var=True; while ($i < min($num,$limit)) { - $objp = $db->fetch_object( $i); + $objp = $db->fetch_object($i); $var=!$var; - - print ""; + + print ""; print "'; + if ($objp->fk_statut == 0) + { + print ''; + } + else + { + print ''; + } } else { @@ -933,20 +956,16 @@ else print "\n"; $i++; - $j++; - } } - if ($i == 0) { $i=1; } if ($j == 0) { $j=1; } - print "
DateAction
".strftime("%d %B %Y",$objp->da)."'.stripslashes($objp->note).'
".strftime("%d %B %Y",$objp->da)."'.stripslashes($objp->note).'
facid\">"; if ($objp->paye) { @@ -924,7 +940,14 @@ else if (! $objp->paye) { - print 'impayéebrouillonimpayée
"; + print "
"; $db->free(); } else { print $db->error(); - } - + } } } diff --git a/htdocs/facture.class.php3 b/htdocs/facture.class.php3 index 2d522b7880a..ac1633c8621 100644 --- a/htdocs/facture.class.php3 +++ b/htdocs/facture.class.php3 @@ -71,6 +71,21 @@ class Facture Function create($userid) { + /* + * + */ + $sql = "SELECT fdm,nbjour FROM llx_cond_reglement WHERE rowid = $this->cond_reglement"; + if ($this->db->query($sql) ) + { + if ($this->db->num_rows()) + { + $obj = $this->db->fetch_object(0); + $cdr_nbjour = $obj->nbjour; + $cdr_fdm = $obj->fdm; + } + $this->db->free(); + } + $datelim = $this->date + ( $cdr_nbjour * 3600 * 24 ); /* * Insertion dans la base */ @@ -93,9 +108,8 @@ class Facture $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);"; - + $sql = "INSERT INTO $this->db_table (facnumber, fk_soc, datec, amount, remise, tva, total, datef, note, fk_user_author,fk_projet, fk_cond_reglement, date_lim_reglement) "; + $sql .= " VALUES ('$number', $socid, now(), $totalht, $remise, $tva, $total,".$this->db->idate($this->date).",'$this->note',$userid, $this->projetid, $this->cond_reglement,".$this->db->idate($datelim).")"; if ( $this->db->query($sql) ) { $this->id = $this->db->last_insert_id(); @@ -123,8 +137,9 @@ class Facture Function fetch($rowid) { - $sql = "SELECT fk_soc,facnumber,amount,tva,total,remise,".$this->db->pdate(datef)."as df,fk_projet"; - $sql .= " FROM llx_facture WHERE rowid=$rowid;"; + $sql = "SELECT f.fk_soc,f.facnumber,f.amount,f.tva,f.total,f.remise,".$this->db->pdate("f.datef")."as df,f.fk_projet,".$this->db->pdate("f.date_lim_reglement")." as dlr, c.libelle, f.note"; + $sql .= " FROM llx_facture as f, llx_cond_reglement as c"; + $sql .= " WHERE f.rowid=$rowid AND c.rowid = f.fk_cond_reglement"; if ($this->db->query($sql) ) { @@ -141,7 +156,10 @@ class Facture $this->total_ttc = $obj->total; $this->remise = $obj->remise; $this->socidp = $obj->fk_soc; + $this->date_lim_reglement = $obj->dlr; + $this->cond_reglement = $obj->libelle; $this->projetid = $obj->fk_projet; + $this->note = stripslashes($obj->note); $this->lignes = array(); $this->db->free(); @@ -177,6 +195,10 @@ class Facture print $this->db->error(); } } + else + { + print "Error"; + } } else {