From fb0f631188f652f32959bcf0b94e7769346c7446 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 25 Sep 2002 18:03:18 +0000 Subject: [PATCH] *** empty log message *** --- htdocs/compta/facture.php3 | 176 ++++++++++++++++++++++++------------- 1 file changed, 113 insertions(+), 63 deletions(-) diff --git a/htdocs/compta/facture.php3 b/htdocs/compta/facture.php3 index e15a5af8f44..beb37b399c1 100644 --- a/htdocs/compta/facture.php3 +++ b/htdocs/compta/facture.php3 @@ -20,6 +20,7 @@ * */ require("./pre.inc.php3"); +require("../facture.class.php3"); llxHeader(); @@ -56,41 +57,58 @@ if ($action == 'delete') { if ($action == 'add') { $datefacture = $db->idate(mktime(12, 0 , 0, $pmonth, $pday, $pyear)); - $sql = "INSERT INTO llx_facture (facnumber, fk_soc, datec, datef, note, amount, remise, tva, total, author) "; - $sql .= " VALUES ('$facnumber', $socid, now(), $datefacture,'$note', $amount, $remise, $tva, $total, '$author');"; - $result = $db->query($sql); + if (! $propalid) { - if ($result) { - $sql = "SELECT rowid, facnumber FROM llx_facture WHERE facnumber='$facnumber';"; - $result = $db->query($sql); - if ($result) { - $objfac = $db->fetch_object( 0); - $facid = $objfac->rowid; - $facnumber = $objfac->facnumber; - $action = ''; + $facture = new Facture($db, $socid); + $facture->number = $facnumber; + $facture->date = $datefacture; - $sql = "INSERT INTO llx_fa_pr (fk_facture,fk_propal) VALUES ($facid, $propalid);"; - $result = $db->query($sql); + $facture->note = $note; + $facture->amount = $amount; + $facture->remise = $remise; + $facture->create($user->id, $statut, $note); - /* - * - * Génération du PDF - * - */ - - // print "
Génération du PDF

"; - - // $command = "export DBI_DSN=\"".$GLOBALS["DBI"]."\" "; - // $command .= " ; ../../scripts/facture-tex.pl --facture=$facid --pdf --ps" ; - - // $output = system($command); - // print "

command : $command
"; - - } } else { - print "

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

Retour à la propal"; + + $sql = "INSERT INTO llx_facture (facnumber, fk_soc, datec, datef, note, amount, remise, tva, total, author) "; + $sql .= " VALUES ('$facnumber', $socid, now(), $datefacture,'$note', $amount, $remise, $tva, $total, '$author');"; + $result = $db->query($sql); + + if ($result) { + + $sql = "SELECT rowid, facnumber FROM llx_facture WHERE facnumber='$facnumber';"; + $result = $db->query($sql); + if ($result) { + $objfac = $db->fetch_object( 0); + $facid = $objfac->rowid; + $facnumber = $objfac->facnumber; + $action = ''; + + $sql = "INSERT INTO llx_fa_pr (fk_facture,fk_propal) VALUES ($facid, $propalid);"; + $result = $db->query($sql); + + + /* + * + * Génération du PDF + * + */ + + // print "


Génération du PDF

"; + + // $command = "export DBI_DSN=\"".$GLOBALS["DBI"]."\" "; + // $command .= " ; ../../scripts/facture-tex.pl --facture=$facid --pdf --ps" ; + + // $output = system($command); + // print "

command : $command
"; + + } + } else { + print "

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

Retour à la propal"; + print $db->error(); + } } $facid = $facid; $action = ''; @@ -107,11 +125,19 @@ if ($action == 'add') { if ($action == 'create') { print_titre("Emettre une facture"); + if ($propalid) { - $sql = "SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.tva, p.total, p.ref, ".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst"; - $sql .= " FROM societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; + $sql = "SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.tva, p.total, p.ref, ".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst"; + $sql .= " FROM societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; - $sql .= " AND p.rowid = $propalid"; + $sql .= " AND p.rowid = $propalid"; + } else { + + $sql = "SELECT s.nom, s.prefix_comm, s.idp "; + $sql .= "FROM societe as s "; + $sql .= "WHERE s.idp = $socidp"; + + } if ( $db->query($sql) ) { $num = $db->num_rows(); @@ -120,28 +146,45 @@ if ($action == 'create') { $numfa = "F-" . $obj->prefix_comm . "-" . strftime("%y%m%d", time()); - print "

"; - print "price - $obj->remise)."\">"; - print "total\">"; - print ''; - print ""; - print ""; - - - print ""; - print ""; - print ""; - print ""; - - print "remise\">"; - print "tva\">"; - print ""; - print ""; print "idp\">"; + print '
Société :$obj->nomCommentaires :
"; - print "
Propal :$obj->ref
Montant HT :".price($obj->price - $obj->remise)."
TVA 19.6% :".price($obj->tva)."
Total TTC :".price($obj->total)."
'; + + print ""; + + if ($propalid) { + $amount = ($obj->price - $obj->remise); + print ''; + print ''; + print ''; + print ''; + print ''; + + print ""; + print ''; + print ""; + print ""; + + } else { + + print ''; + + print ''; + + print ''; + print ''; + + + } + + print ""; + print ""; + $strmonth[1] = "Janvier"; $strmonth[2] = "Février"; $strmonth[3] = "Mars"; $strmonth[4] = "Avril"; $strmonth[5] = "Mai"; $strmonth[6] = "Juin"; $strmonth[7] = "Juillet"; $strmonth[8] = "Août"; $strmonth[9] = "Septembre"; $strmonth[10] = "Octobre"; @@ -178,11 +221,12 @@ if ($action == 'create') { print ""; print ""; + + print ''; + print ''; + print ""; print ""; print "
Société :$obj->nom
Propal :$obj->ref
Montant HT :'.price($amount).'
TVA 19.6% :".price($obj->tva)."
Total TTC :".price($obj->total)."
Montant HT :'; + + print '
Remise :'; + print '
Auteur :".$user->fullname."
Auteur :$author
Numéro :
Commentaires :
'; + print '
"; @@ -223,7 +267,7 @@ if ($action == 'create') { print "Sociétésocidp\">$obj->socnom"; print "Date".strftime("%A %d %B %Y",$obj->df)."\n"; - print "Auteur$obj->author"; + print "".translate("Author")."$obj->author"; print 'Montant'.price($obj->amount).'euros HT'; print 'TVA'.tva($obj->amount).'euros'; @@ -422,7 +466,7 @@ if ($action == 'create') { print "Numéro"; print_liste_field_titre("Société",$PHP_SELF,"s.nom"); print "DateMontant"; - print "Payé"; + print "\n"; if ($num > 0) { @@ -434,19 +478,25 @@ if ($action == 'create') { if ($objp->paye && !$sep) { print ""; print " "; - print "Sous Total : ".price($total)."euros HT"; + print "Sous Total : ".price($total).""; print ''; print "Numéro"; print_liste_field_titre("Société",$PHP_SELF,"s.nom"); print "DateMontant"; - print "Payé\n"; + $sep = 1 ; $j = 0; $subtotal = 0; } print ""; - print "facid\">$objp->facnumber\n"; + print "facid\">"; + if ($objp->paye) { + print $objp->facnumber; + } else { + print ''.$objp->facnumber.''; + } + print "\n"; print "idp\">$objp->nom\n"; if ($objp->df > 0 ) { @@ -467,7 +517,7 @@ if ($action == 'create') { $total = $total + $objp->amount; $subtotal = $subtotal + $objp->amount; - print "".$yn[$objp->paye]."\n"; + print "\n"; $i++; @@ -477,10 +527,10 @@ if ($action == 'create') { } if ($i == 0) { $i=1; } if ($j == 0) { $j=1; } print "$j factures "; - print "Sous Total : ".price($subtotal)."euros HT"; + print "Sous Total : ".price($subtotal).""; print "$i factures "; - print "Total : ".price($total)."euros HT"; + print "Total (euros HT): ".price($total).""; print ""; $db->free();