From 0c5adb9f65524b8a96ecb671a48fc127982cd84d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 May 2004 21:17:07 +0000 Subject: [PATCH] =?UTF-8?q?Le=20CA=20en=20mode=20cr=E9ances=20ne=20fonctio?= =?UTF-8?q?nnait=20pas.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/stats/exercices.php | 65 +++++++++++++++++-------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/htdocs/compta/stats/exercices.php b/htdocs/compta/stats/exercices.php index 781d5134712..8f0764fa02e 100644 --- a/htdocs/compta/stats/exercices.php +++ b/htdocs/compta/stats/exercices.php @@ -23,6 +23,26 @@ require("./pre.inc.php"); require("./lib.inc.php"); +/* + * + */ + +llxHeader(); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $socidp = $user->societe_id; +} + +$mode='recettes'; +if ($conf->compta->mode == 'CREANCES-DETTES') { $mode='creances'; } + + +print_titre("Comparatif CA année en cours avec année précédente (".MAIN_MONNAIE." HT, ".$mode.")"); +print "
\n"; function propals ($db, $year, $month) { global $bc; @@ -170,14 +190,14 @@ function pt ($db, $sql, $year) { $var=!$var; if ($obj->dm > $month ) { - for ($b = $month ; $b < $obj->dm ; $b++) { - print ""; - print "".strftime("%B",mktime(12,0,0,$b, 1, $year))."\n"; - print "0\n"; - print "\n"; - $var=!$var; - $ca[$b] = 0; - } + for ($b = $month ; $b < $obj->dm ; $b++) { + print ""; + print "".strftime("%B",mktime(12,0,0,$b, 1, $year))."\n"; + print "0\n"; + print "\n"; + $var=!$var; + $ca[$b] = 0; + } } if ($obj->sum > 0) { @@ -223,7 +243,7 @@ function pt ($db, $sql, $year) { function ppt ($db, $year, $socidp) { - global $bc; + global $bc,$conf; print ""; print "
"; @@ -236,15 +256,15 @@ function ppt ($db, $year, $socidp) $sql = "SELECT sum(f.total) as sum, round(date_format(f.datef, '%m')) as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_statut = 1"; - if ($conf->compta->mode != 'CREANCES-DETTES') { - $sql .= " AND f.paye = 1"; - } - $sql.=" AND date_format(f.datef,'%Y') = ".($year-1); - if ($socidp) + $sql .= " AND date_format(f.datef,'%Y') = ".($year-1); + + if ($conf->compta->mode != 'CREANCES-DETTES') { + $sql .= " AND f.paye = 1"; + } + if ($socidp) { $sql .= " AND f.fk_soc = $socidp"; } - $sql .= " GROUP BY dm"; $prev = pt($db, $sql, $year - 1); @@ -254,10 +274,10 @@ function ppt ($db, $year, $socidp) $sql = "SELECT sum(f.total) as sum, round(date_format(f.datef, '%m')) as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_statut = 1"; + $sql .= " AND date_format(f.datef,'%Y') = $year "; if ($conf->compta->mode != 'CREANCES-DETTES') { $sql .= " AND f.paye = 1"; } - $sql.=" AND date_format(f.datef,'%Y') = $year "; if ($socidp) { $sql .= " AND f.fk_soc = $socidp"; @@ -296,19 +316,6 @@ function ppt ($db, $year, $socidp) } -/* - * - */ - -llxHeader(); - -/* - * Sécurité accés client - */ -if ($user->societe_id > 0) -{ - $socidp = $user->societe_id; -} $cyear = strftime ("%Y", time()); ppt($db, $cyear, $socidp);