Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.html.cumulative_usage.es.php
<h3>Abstract views and document downloads by year/month</h3>      

<?php
	// NJS 2006-04-24
	// Add if to check whether there actually are any stats!
	if (! isset($GLOBALS["db_values"]["0"]["abstracts"])) {
		print "<table>\n";
		print '<tr><td align="left" width="200" style="color:#ff0000;"><b>No statistics available.</b></td></tr>';
		print "\n";
	} else {
		$max_count = $GLOBALS["db_values"][0]["abstracts"];
		for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
		{
			if($max_count < $GLOBALS["db_values"][$rs]["abstracts"])
				$max_count = $GLOBALS["db_values"][$rs]["abstracts"];
		}
		$max_width = '500'; // Max pixel width of barchart.
		
		print "<table cellspacing='0' cellpadding='4'>\n";
		print '<tr><td colspan="6"><span style="font-size:small;">Click on a month to see document downloads for that month.<br />
			The numbers in (parentheses) are the number of distinct countries that views/downloads originated from.</span></td></tr>';
		print '<tr><th style="background-color:#cccccc;">Period</th>
			<th colspan="2" style="background-color:#66ddee;">Abstracts</th>
			<th colspan="2" style="background-color:#4477dd;color:#ffffff;">Downloads</th>
			<th style="background-color:#cccccc;">&nbsp;</th></tr>';
		for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
		{
			$monthnum = (int) strpos('JanFebMarAprMayJunJulAugSepOctNovDec', $GLOBALS["db_values"][$rs]["month"])/3 + 1;
			// NJS 2005-12-15: subtly highlight every alternate row
			print '<tr';
			if ($rs % 2) print ' style="background-color:#EDF3FE;"';
			print '><td style="font-size:small;border-right:1px solid #dddddd;"><a href="'.
				$_SERVER['PHP_SELF'].
				'?action=show_detail_date;year='.
				$GLOBALS["db_values"][$rs]["year"].
				';month=' .
				$monthnum .
				'">' .
				$GLOBALS["db_values"][$rs]["year"].
				' '.
				$GLOBALS["db_values"][$rs]["month"].
				'</a></td><td align="right" style="font-size:small;">'.
				$GLOBALS["db_values"][$rs]["abstracts"].
				'</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('.
				$GLOBALS["db_values"][$rs]["acountries"].
				')</td><td align="right" style="font-size:small;">'.
				$GLOBALS["db_values"][$rs]["downloads"].
				'</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('.
				$GLOBALS["db_values"][$rs]["dcountries"].
				')</td>';
			$cur_count = $GLOBALS["db_values"][$rs]["abstracts"];
			$col_width = (int) ($cur_count/$max_count * $max_width);
			$col_width = max($col_width, 1);
			$col_width .= "px";
			print '<td align="left"><img src="bars/hh.png" alt="abstracts" height="9" width="'. 
				$col_width . 
				'"><br />';
			$cur_count = $GLOBALS["db_values"][$rs]["downloads"];
			$col_width = (int) ($cur_count/$max_count * $max_width);
			$col_width = max($col_width, 1);
			$col_width .= "px";
			print '<img src="bars/hp.png" alt="downloads" height="9" width="'. 
				$col_width . 
				'"></td></tr>';
		}
	} // of else
	print "</table>\n";
?>