From 1038e92354824b5995a89d8dd72f456677a35309 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Feb 2016 18:42:57 +0100 Subject: [PATCH] FIX sql request and total for time spen for current month --- htdocs/projet/activity/index.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 480294607f6..e9db844a1f7 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -46,6 +46,10 @@ $langs->load("projects"); */ $now = dol_now(); +$tmp=dol_getdate($now); +$day=$tmp['mday']; +$month=$tmp['mon']; +$year=$tmp['year']; $projectstatic=new Project($db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project @@ -221,7 +225,7 @@ if ($db->type != 'pgsql') $sql.= " AND p.entity = ".$conf->entity; $sql.= " AND tt.fk_task = t.rowid"; $sql.= " AND tt.fk_user = ".$user->id; - $sql.= " AND task_date >= '".dol_get_first_day($year, $month).'" AND ..."; + $sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ..."; $sql.= " AND p.rowid in (".$projectsListId.")"; $sql.= " GROUP BY p.rowid, p.ref, p.title"; @@ -278,13 +282,15 @@ $sql.= " WHERE t.fk_projet = p.rowid"; $sql.= " AND p.entity = ".$conf->entity; $sql.= " AND tt.fk_task = t.rowid"; $sql.= " AND tt.fk_user = ".$user->id; -$sql.= " AND task_date BETWEEN '".dol_get_first_day($year, $month).'" AND "'.dol_get_last_day($year, $month)."'"; +$sql.= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; $sql.= " AND p.rowid in (".$projectsListId.")"; $sql.= " GROUP BY p.rowid, p.ref, p.title"; $resql = $db->query($sql); if ( $resql ) { + $total = 0; + $var=false; while ($row = $db->fetch_object($resql)) @@ -299,6 +305,7 @@ if ( $resql ) print ''.convertSecondToTime($row->nb, 'allhourmin').''; print "\n"; $var=!$var; + $total += $row->nb; } $db->free($resql); }