* Copyright (C) 2004 Laurent Destailleur * * 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$ * */ require("./pre.inc.php"); function pt ($db, $sql) { $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; $total = 0 ; $month = 1 ; while ($i < $num) { $obj = $db->fetch_object($result); $ca[$obj->dm] = $obj->sum; $i++; } $db->free(); return $ca; } } function pm ($db) { $sql = "SELECT amount, date_format('%Y%m',month) as dm FROM ".MAIN_DB_PREFIX."pointmort"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; $total = 0 ; $month = 1 ; while ($i < $num) { $obj = $db->fetch_object($result); $ca[$obj->dm] = $obj->amount; print $obj->dm ."=". $obj->amount ."
"; $i++; } $db->free(); return $ca; } } function ppt ($db) { $sql = "SELECT sum(f.amount), date_format(f.datef,'%Y%m') as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; $sql .= " GROUP BY dm"; $ca = pt($db, $sql); $ptmt = pm($db); print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "\n"; $bc[0]="bgcolor=\"#90c090\""; $bc[1]="bgcolor=\"#b0e0b0\""; $var = 1 ; $pmt = 0 ; $subpmt = 0 ; $totalca = 0 ; $totalpm = 0; $xdate = mktime(0, 0, 0, 7 , 1, 2000); $oldyear = 0; $i = 1; while ($xdate < time()) { if ($oldyear <> date("Y",$xdate)) { $oldyear = date("Y",$xdate); $subpmt = 0 ; print ''; print ''; } $var=!$var; print ""; print "\n"; $b = strftime("%Y", $xdate) . strftime("%m", $xdate); $totalca = $ca[$b] + $totalca; $totalpm = $ptmt[$b] + $totalpm; $pm = $ca[$b] - $ptmt[$b]; $pmt = $pmt + $pm; $subpmt = $subpmt + $pm; if ($ca[$b]) { print "\n"; } else { print "\n"; } print "\n"; if ($pm > 0) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; $pmbymonth = round($pmt/$i); print "\n"; $pmbymdelta = ($pmbymonth - $pmbymontha); if ( $pmbymdelta > 0 ) { print "\n"; } else { print "\n"; } $pmbymontha = $pmbymonth; print "\n"; $xdate = mktime(0, 0, 0, date("m", $xdate + (33 * 24 * 3600)), 1 , date("Y", $xdate + (33 * 24 * 3600))) ; $i++; } print ""; print ""; print ""; print "
 ".$langs->trans("Month")."CAPoint mortDeltaSommeSomme par anSomme / nb moisEcart
 '.$oldyear.' 
$i".strftime("%Y %B", $xdate)."".$ca[$b]."0".$ptmt[$b]."+$pm$pm$pmt$subpmt$pmbymonth +$pmbymdelta$pmbymdelta
Totaux:$totalca$totalpm$pmt 
"; } /* * */ llxHeader(); print "Point mort"; ppt($db, 0); print "


"; print ""; print "
Paramétrer le point mort
"; $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>