3 * Copyright (C) 2009-2012 Alain Peyrat, Alcatel-Lucent
4 * Copyright 2012, Franck Villaume - TrivialDev
5 * http://fusionforge.org
7 * This file is part of FusionForge. FusionForge is free software;
8 * you can redistribute it and/or modify it under the terms of the
9 * GNU General Public License as published by the Free Software
10 * Foundation; either version 2 of the Licence, or (at your option)
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * Standard Alcatel-Lucent disclaimer for contributing to open source
26 * "The program ("Contribution") has not been tested and/or
27 * validated for release as or in products, combinations with products or
28 * other commercial use. Any use of the Contribution is entirely made at
29 * the user's own responsibility and the user can not rely on any features,
30 * functionalities or performances Alcatel-Lucent has attributed to the
33 * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
34 * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
35 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
36 * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
37 * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
38 * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
39 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40 * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
41 * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
45 /* please do not add require here : use www/docman/index.php to add require */
46 /* global variables used */
47 global $HTML; // html object
48 global $d_arr; // document array
49 global $group_id; // id of group
50 global $g; // the group object
52 if ( !forge_check_perm('docman', $group_id, 'admin')) {
53 $return_msg= _('Document Manager Access Denied');
54 session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
57 $start = getIntFromRequest('start');
58 $end = getIntFromRequest('end');
60 $report = new Report();
61 if ($report->isError()) {
62 exit_error($report->getErrorMessage(), 'docman');
65 if (!$start || !$end) $z =& $report->getMonthStartArr();
72 $end = $z[ count($z)-1 ];
74 if ($end < $start) list($start, $end) = array($end, $start);
76 html_use_jqueryjqplotpluginCanvas();
77 echo $HTML->getJavascripts();
78 echo $HTML->getStylesheets();
81 $report = new ReportPerGroupDocmanDownloads($group_id, $start, $end);
82 if ($report->isError()) {
83 echo '<p class="error_msg">'.$report->getErrorMessage().'</p>';
87 <form action="<?php echo util_make_url('/docman/') ?>"
90 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
91 <input type="hidden" name="view" value="reporting" />
92 <strong><?php echo _('Start Date')._(':'); ?></strong>
93 <?php echo report_months_box($report, 'start', $start); ?>
94 <strong><?php echo _('End Date')._(':'); ?></strong>
95 <?php echo report_months_box($report, 'end', $end); ?>
96 <input type="submit" name="submit" value="<?php echo _('Refresh'); ?>" />
101 $data = $report->getData();
103 if (count($data) == 0) {
104 echo '<p class="information">';
105 echo _('There have been no viewed documents for this project yet.');
108 echo '<script type="text/javascript">//<![CDATA['."\n";
109 echo 'var ticks = new Array();';
110 echo 'var values = new Array();';
111 $arr =& $report->getMonthStartArr();
113 $valuesArr = array();
114 for ($i=0; $i < count($arr); $i++) {
115 if ($arr[$i] >= $start && $arr[$i] <= $end) {
116 $arr2[$i] = date(_('Y-m'), $arr[$i]);
120 foreach ($arr2 as $key) {
121 echo 'ticks.push("'.$key.'");';
123 for ($i=0; $i < count($data); $i++) {
124 $this_date = date(_('Y-m'), mktime(0, 0, 0, substr($data[$i][2], 4, 2), 0, substr($data[$i][2], 0, 4)));
125 $index_key = array_search($this_date, $arr2);
126 $valuesArr[$index_key+1]++;
128 foreach ($valuesArr as $key) {
129 echo 'values.push('.$key.');';
132 echo 'jQuery(document).ready(function(){
133 plot1 = jQuery.jqplot (\'chart1\', [values], {
136 label: "'._('Month').'",
137 renderer: jQuery.jqplot.CategoryAxisRenderer,
142 label: "'._('Downloads').'",
148 echo 'jQuery(window).resize(function() {
149 plot1.replot( { resetAxes: true } );
151 echo '//]]></script>';
152 echo '<div id="chart1"></div>';
153 $tabletop = array(_('Folder'), _('Document'), _('User'), _('Date'));
154 $classth = array('', '', '', '');
155 echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
156 for ($i=0; $i<count($data); $i++) {
157 $date = preg_replace('/^(....)(..)(..)$/', '\1-\2-\3', $data[$i][2]);
158 $ndg = new DocumentGroup($g, $data[$i][4]);
159 $path = $ndg->getPath(true);
160 echo '<tr '. $HTML->boxGetAltRowStyle($i) .'>'.
161 '<td>'.$path.'</td>'.
162 '<td>'. $data[$i][0] .'</td>'.
163 '<td><a class="tabtitle" title="'._('View user profile').'" href="/users/'.urlencode($data[$i][3]).'/">'. $data[$i][1] .'</a></td>'.
164 '<td class="align-center">'. $date .'</td></tr>';
166 echo $HTML->listTableBottom();