From 9042c10398153acb284abc0106c3b48099205087 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Oct 2009 18:08:35 +0000 Subject: [PATCH] Qual: Better compatibility with other databases --- htdocs/comm/action/rapport/index.php | 15 ++++++++------- htdocs/fourn/stats.php | 16 +++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index c689d0f3501..7594c53ea74 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -68,16 +68,17 @@ if ($_GET["action"] == 'builddoc') llxHeader(); -$sql = "SELECT count(*) as cc, date_format(a.datep, '%m/%Y') as df"; -$sql.= ", date_format(a.datep, '%m') as month"; -$sql.= ", date_format(a.datep, '%Y') as year"; -$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; -$sql.= ", ".MAIN_DB_PREFIX."user as u"; +$sql = "SELECT count(*) as cc,"; +$sql.= " date_format(a.datep, '%m/%Y') as df,"; +$sql.= " date_format(a.datep, '%m') as month,"; +$sql.= " date_format(a.datep, '%Y') as year"; +$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a,"; +$sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE a.fk_user_author = u.rowid"; $sql.= " AND u.entity = ".$conf->entity; $sql.= " AND percent = 100"; -$sql.= " GROUP BY date_format(a.datep, '%m/%Y') "; -$sql.= " ORDER BY a.datep DESC"; +$sql.= " GROUP BY year, month, df"; +$sql.= " ORDER BY year DESC, month DESC, df DESC"; $sql.= $db->plimit($limit+1,$offset); //print $sql; diff --git a/htdocs/fourn/stats.php b/htdocs/fourn/stats.php index 2d1a87673c7..34a1a4330bd 100644 --- a/htdocs/fourn/stats.php +++ b/htdocs/fourn/stats.php @@ -56,8 +56,7 @@ $fourns=array(); /* - * Affichage liste - * + * View */ llxHeader(); @@ -85,8 +84,7 @@ if ($search_ville) { $sql .= " AND s.ville LIKE '%".$search_ville."%'"; } -$sql .= " AND ca.year > (date_format(".$db->idate(mktime()).",'%Y') - 5)"; - +// TODO Add date ranges $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); dol_syslog("fourn/stats.php sql=".$sql); @@ -95,10 +93,10 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - + while ($i < min($num,$conf->liste_limit)) { - $obj = $db->fetch_object($resql); + $obj = $db->fetch_object($resql); $var=!$var; $i++; @@ -109,7 +107,7 @@ if ($resql) } } -else +else { dol_print_error($db); } @@ -150,13 +148,13 @@ $var=True; foreach($fourns as $fid => $fnom) { $var=!$var; - + print ""; print ''.img_object($langs->trans("ShowSupplier"),"company").''; print " ".$fnom."\n"; print "".$obj->ville."\n"; print ''.$code_fourns[$fid].' '; - + foreach($years as $year) { print ''.price($ca[$fid][$year]).' ';