From 5f028dc5a4f3f35a4ae2a8698ffe5ddbca1d4e43 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sun, 12 Oct 2003 14:41:22 +0000 Subject: [PATCH] =?UTF-8?q?Gestion=20des=20factures=20r=E9currentes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/facture.php | 132 +++++++++++++++++++++++++------------- 1 file changed, 89 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8df85ca1c9e..8d6c01d026d 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -55,54 +55,66 @@ if ($HTTP_POST_VARS["action"] == 'add') $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"]; - $facture->amount = $HTTP_POST_VARS["amount"]; - $facture->remise = $HTTP_POST_VARS["remise"]; - $facture->remise_percent = $HTTP_POST_VARS["remise_percent"]; - - if (!$HTTP_POST_VARS["propalid"]) - { - $facture->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"],$HTTP_POST_VARS["remise_percent1"]); - $facture->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"],$HTTP_POST_VARS["remise_percent2"]); - $facture->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"],$HTTP_POST_VARS["remise_percent3"]); - $facture->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"],$HTTP_POST_VARS["remise_percent4"]); - + + if ($HTTP_POST_VARS["fac_rec"] > 0) + { + /* + * Facture récurrente + */ + $facture->fac_rec = $HTTP_POST_VARS["fac_rec"]; $facid = $facture->create($user); } else { - $facture->propalid = $HTTP_POST_VARS["propalid"]; - - $facid = $facture->create($user); - - if ($facid) + $facture->projetid = $HTTP_POST_VARS["projetid"]; + $facture->cond_reglement = $HTTP_POST_VARS["condid"]; + $facture->amount = $HTTP_POST_VARS["amount"]; + $facture->remise = $HTTP_POST_VARS["remise"]; + $facture->remise_percent = $HTTP_POST_VARS["remise_percent"]; + + if (!$HTTP_POST_VARS["propalid"]) + { + $facture->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"],$HTTP_POST_VARS["remise_percent1"]); + $facture->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"],$HTTP_POST_VARS["remise_percent2"]); + $facture->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"],$HTTP_POST_VARS["remise_percent3"]); + $facture->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"],$HTTP_POST_VARS["remise_percent4"]); + + $facid = $facture->create($user); + } + else { - $prop = New Propal($db); - if ( $prop->fetch($HTTP_POST_VARS["propalid"]) ) + $facture->propalid = $HTTP_POST_VARS["propalid"]; + + $facid = $facture->create($user); + + if ($facid) { - for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++) + $prop = New Propal($db); + if ( $prop->fetch($HTTP_POST_VARS["propalid"]) ) { - $result = $facture->addline($facid, - addslashes($prop->lignes[$i]->libelle), - $prop->lignes[$i]->subprice, - $prop->lignes[$i]->qty, - $prop->lignes[$i]->tva_tx, - $prop->lignes[$i]->product_id, - $prop->lignes[$i]->remise_percent); + for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++) + { + $result = $facture->addline($facid, + addslashes($prop->lignes[$i]->libelle), + $prop->lignes[$i]->subprice, + $prop->lignes[$i]->qty, + $prop->lignes[$i]->tva_tx, + $prop->lignes[$i]->product_id, + $prop->lignes[$i]->remise_percent); + } + } + else + { + print "Erreur"; } } else { - print "Erreur"; + print "

Erreur : la facture n'a pas été créée, vérifier le numéro !"; + print "

Retour à la propal"; + print $db->error(); } } - else - { - print "

Erreur : la facture n'a pas été créée, vérifier le numéro !"; - print "

Retour à la propal"; - print $db->error(); - } } $action = ''; @@ -338,10 +350,10 @@ if ($action == 'create') print '' ."\n"; print ''; - print ''; + print '
'; - print ""; - print ""; + print ''; + print ''; print ""; @@ -427,19 +439,53 @@ if ($action == 'create') print $db->error(); } - print '
Client :$obj->nomCommentaire
Client :'.$obj->nom.'Commentaire
Auteur :".$user->fullname."
'; + print '
'; print ''; for ($i = 1 ; $i < 5 ; $i++) { print ''; print ''; print ''; - } - + } + print '
ProduitQuan.Remise
%
'; print ''; } - + /* + * Factures récurrentes + * + */ + if ($propalid == 0) + { + $sql = "SELECT r.rowid, r.titre, r.amount FROM llx_facture_rec as r"; + $sql .= " WHERE r.fk_soc = $socidp"; + if ( $db->query($sql) ) + { + $num = $db->num_rows(); + $i = 0; + + if ($num > 0) + { + print 'Factures récurrentes : '; + } + $db->free(); + } + else + { + print "$sql"; + } + } + /* + * + */ print ''; print "\n"; print "\n"; @@ -678,7 +724,7 @@ else $objp = $db->fetch_object( $i); $var=!$var; print ""; - if ($objp->fk_product) + if ($objp->fk_product > 0) { print ''.stripslashes(nl2br($objp->description)).''; }