* * $Id$ * $Source$ * * 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. * */ require("./pre.inc.php3"); require("../lib/functions.inc.php3"); llxHeader(); $db = new Db(); if ($sortorder == "") { $sortfield="lower(s.nom)"; $sortorder="ASC"; } $bc[0]="bgcolor=\"#90c090\""; $bc[1]="bgcolor=\"#b0e0b0\""; $yn["1"] = "oui"; $yn["0"] = "non"; if ($action == 'valid') { $sql = "UPDATE llx_facture set fk_statut = 1 WHERE rowid = $facid ;"; $result = $db->query( $sql); } if ($action == 'payed') { $sql = "UPDATE llx_facture set paye = 1 WHERE rowid = $facid ;"; $result = $db->query( $sql); } if ($action == 'delete') { $sql = "DELETE FROM llx_facture WHERE rowid = $facid ; DELETE FROM llx_fa_pr WHERE fk_facture = $facid"; $result = $db->query( $sql); $facid = 0 ; } if ($facid > 0) { $sql = "SELECT s.nom as socnom, s.idp as socidp, f.facnumber, f.amount, int(f.datef) as df, f.paye, f.fk_statut as statut, f.author "; $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.rowid = $facid"; $result = $db->query( $sql); if ($result) { $num = $db->num_rows(); if ($num) { $obj = $db->fetch_object( $i); } $db->free(); } $factex = "\documentclass[a4paper,11pt]{article} \usepackage[francais]{babel} \usepackage[dvips]{graphics} \usepackage{fancyhdr} % % \\newcommand{\aquatre}{ \setlength{\oddsidemargin}{0.5cm} \setlength{\evensidemargin}{0.5cm} \setlength{\\textwidth}{16cm} %\setlength{\\topmargin}{0.5cm} %\setlength{\\textheight}{24cm} %\setlength{\headheight}{0cm} %\setlength{\headsep}{0cm} \setlength{\parindent}{0.5cm} \setlength{\parskip}{0.2cm} } % % Debut du document % \aquatre \\title{Conseil d'administration du 30 juin 2001} \fancyhead{} \fancyhead[RO,LE]{Conseil d'administration du 30 juin 2001} \fancyfoot[C]{Page \\thepage} \pagestyle{fancy} \begin{document} toto \end{document}"; $filename = "/tmp/fac.tex"; $fp = fopen($filename, "w"); fwrite($fp, $factex); fclose($fp); print "latex $filename

"; $outp = `cd /tmp ; pdflatex $filename`; print "

$outp

"; } else { /* * Liste * */ function liste($db, $paye) { global $bc, $year, $month; $sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, int(f.datef) as df, f.paye, f.rowid as facid "; $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.paye = $paye"; if ($socidp) { $sql .= " AND s.idp = $socidp"; } if ($month > 0) { $sql .= " AND date_part('month', date(f.datef)) = $month"; } if ($year > 0) { $sql .= " AND date_part('year', date(f.datef)) = $year"; } $sql .= " ORDER BY f.datef DESC "; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); if ($num > 0) { $i = 0; print "

"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; if ($objp->df > 0 ) { print "\n"; } else { print "\n"; } print "\n"; $yn[1] = "oui"; $yn[0] = "non"; $total = $total + $objp->amount; print "\n"; print "\n"; print "\n"; $i++; } print ""; print ""; print ""; print "
[Tous]SocieteNumDateMontantPayéMoyenne
[idp\">Filtre]idp\">$objp->nomfacid\">$objp->facnumber"; $y = strftime("%Y",$objp->df); $m = strftime("%m",$objp->df); print strftime("%d",$objp->df)."\n"; print " "; print strftime("%B",$objp->df)."\n"; print " "; print strftime("%Y",$objp->df)."!!!$objp->amount".$yn[$objp->paye]."".round($total / ($i + 1))."
$i facturesTotal : ".round($total * 6.55957)." FFTotal : $totaleuros HTMoyenne : ".round($total/ $i)."
"; $db->free(); } } } print "

"; liste($db, 0); print "

"; liste($db, 1); } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>