Le CA en mode crances ne fonctionnait pas.

This commit is contained in:
Laurent Destailleur 2004-05-05 21:17:07 +00:00
parent fda8ec8094
commit 0c5adb9f65

View File

@ -23,6 +23,26 @@
require("./pre.inc.php"); require("./pre.inc.php");
require("./lib.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 "<br>\n";
function propals ($db, $year, $month) { function propals ($db, $year, $month) {
global $bc; global $bc;
@ -170,14 +190,14 @@ function pt ($db, $sql, $year) {
$var=!$var; $var=!$var;
if ($obj->dm > $month ) { if ($obj->dm > $month ) {
for ($b = $month ; $b < $obj->dm ; $b++) { for ($b = $month ; $b < $obj->dm ; $b++) {
print "<TR $bc[$var]>"; print "<TR $bc[$var]>";
print "<TD>".strftime("%B",mktime(12,0,0,$b, 1, $year))."</TD>\n"; print "<TD>".strftime("%B",mktime(12,0,0,$b, 1, $year))."</TD>\n";
print "<TD align=\"right\">0</TD>\n"; print "<TD align=\"right\">0</TD>\n";
print "</TR>\n"; print "</TR>\n";
$var=!$var; $var=!$var;
$ca[$b] = 0; $ca[$b] = 0;
} }
} }
if ($obj->sum > 0) { if ($obj->sum > 0) {
@ -223,7 +243,7 @@ function pt ($db, $sql, $year) {
function ppt ($db, $year, $socidp) function ppt ($db, $year, $socidp)
{ {
global $bc; global $bc,$conf;
print "<table width=\"100%\">"; print "<table width=\"100%\">";
print "<tr class=\"liste_titre\"><td align=\"center\" width=\"30%\">"; print "<tr class=\"liste_titre\"><td align=\"center\" width=\"30%\">";
@ -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 = "SELECT sum(f.total) as sum, round(date_format(f.datef, '%m')) as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut = 1"; $sql .= " WHERE f.fk_statut = 1";
if ($conf->compta->mode != 'CREANCES-DETTES') { $sql .= " AND date_format(f.datef,'%Y') = ".($year-1);
$sql .= " AND f.paye = 1";
} if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql.=" AND date_format(f.datef,'%Y') = ".($year-1); $sql .= " AND f.paye = 1";
if ($socidp) }
if ($socidp)
{ {
$sql .= " AND f.fk_soc = $socidp"; $sql .= " AND f.fk_soc = $socidp";
} }
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
$prev = pt($db, $sql, $year - 1); $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 = "SELECT sum(f.total) as sum, round(date_format(f.datef, '%m')) as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut = 1"; $sql .= " WHERE f.fk_statut = 1";
$sql .= " AND date_format(f.datef,'%Y') = $year ";
if ($conf->compta->mode != 'CREANCES-DETTES') { if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql .= " AND f.paye = 1"; $sql .= " AND f.paye = 1";
} }
$sql.=" AND date_format(f.datef,'%Y') = $year ";
if ($socidp) if ($socidp)
{ {
$sql .= " AND f.fk_soc = $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()); $cyear = strftime ("%Y", time());
ppt($db, $cyear, $socidp); ppt($db, $cyear, $socidp);