3 * FusionForge reporting system
5 * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
6 * Copyright 2009, Roland Mas
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * Standard Alcatel-Lucent disclaimer for contributing to open source
27 * "The class ("Contribution") has not been tested and/or
28 * validated for release as or in products, combinations with products or
29 * other commercial use. Any use of the Contribution is entirely made at
30 * the user's own responsibility and the user can not rely on any features,
31 * functionalities or performances Alcatel-Lucent has attributed to the
34 * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
35 * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
36 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
37 * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
38 * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
39 * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
40 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
41 * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
42 * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
46 require_once $gfcommon.'reporting/Report.class.php';
48 class ReportDownloads extends Report {
50 function ReportDownloads($group_id,$package_id,$start=0,$end=0) {
54 $start=mktime(0,0,0,date('m'),1,date('Y'));;
62 // Convert start & end date to month .
63 $start_m = date('Ym', $start);
64 $end_m = date('Ym', $end);
67 $this->setError('No Group_id');
72 $res = db_query_params ('SELECT package_id FROM frs_package WHERE frs_package.group_id = $1',
74 $package_id = db_result($res, 0, 'package_id');
77 $this->setError(_('There are no packages defined.'));
81 $res = db_query_params ('SELECT frs_package.name, frs_release.name,
82 frs_file.filename, users.realname,
83 frs_dlstats_file.month || lpad(frs_dlstats_file.day::text,2,0::text),
85 FROM frs_dlstats_file, frs_file, frs_release,
87 WHERE frs_dlstats_file.user_id = users.user_id
88 AND frs_dlstats_file.file_id = frs_file.file_id
89 AND frs_file.release_id = frs_release.release_id
90 AND frs_release.package_id = frs_package.package_id
91 AND frs_package.group_id = $1
92 AND frs_release.package_id = $2
93 AND frs_dlstats_file.month >= $3
94 AND frs_dlstats_file.month <= $4
95 ORDER BY frs_dlstats_file.month DESC,
96 frs_dlstats_file.day DESC',
102 $this->start_date=$start;
103 $this->end_date=$end;
105 if (!$res || db_error()) {
106 $this->setError('ReportUserAct:: '.db_error());
110 $rows=db_numrows($res);
114 while ($row = db_fetch_array ($res)) {