Newer
Older
Digital_Repository / Repositories / statistics / htdocs / inc.html.show_detail_eprint.es.php
<?php
	$current_year = date("Y");
	$last_year = date("Y")-1;

	if ($title == '')
		$title = 'Eprint #' . sprintf("%08d", $_REQUEST["id"]) . ' (title is not available)';
		
	// Create link to eprint.
	$title_link = '<a href="'. 
		$GLOBALS["config_vars"]["general"]["eprints_location"] . 
		'/archive/' . 
		sprintf("%08d", $_REQUEST["id"]) . 
		'/" target="_blank">' .
		$title .
		'</a>';
	
?>
<h3><?php print $title_link; ?></h3>      

<p>For this eprint:
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_eprint;id=<?php print $_REQUEST["id"]; ?>;range=4w">Past four weeks</a>]
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_eprint;id=<?php print $_REQUEST["id"]; ?>;year=<?php print $current_year; ?>">This year</a>]
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_eprint;id=<?php print $_REQUEST["id"]; ?>;year=<?php print $last_year; ?>">Last year</a>]
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_eprint;id=<?php print $_REQUEST["id"]; ?>;">All years</a>]</p>
</p>
<p>Most viewed eprints: 
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date;range=4w">Past four weeks</a>] 
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date;year=<?php print $current_year; ?>">This year</a>]
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date;year=<?php print $last_year; ?>">Last year</a>]
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date">All years</a>]
<br />Repository-wide statistics: 
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=cumulative_usage;range=all">by Year/month</a>] 
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=cumulative_usage_country">by Country</a>] 
</p>

<?php
	$max_width = '500'; // Max pixel width of barcharts
?>
	
<h4>Abstract views and document downloads for <?php print $show_date; ?></h4>
<?php
	$count0 = 0;
	$count1 = 0;
	if (isset($type_count["0"]["count"])) {
		if ($type_count["0"]["view_type"] != "download") {
			$count0 = $type_count["0"]["count"];
		} else {
			$count1 = $type_count["0"]["count"];
		}
	}
	if (isset($type_count["1"]["count"])) {
		if ($type_count["1"]["view_type"] != "download") {
			$count0 = $type_count["1"]["count"];
		} else {
			$count1 = $type_count["1"]["count"];
		}
	}
	$max_count = max($count0, $count1, 1);
	
	if ($count0 + $count1 > 0)
	{
		print "<table>\n";
		print '<tr><th align="left" width="150" bgcolor="#cccccc">&nbsp;</th>
		<th bgcolor="#66ddee">Abstracts</th>
		<th bgcolor="#4477dd"><font color="#ffffff">Downloads</font></th>
		<th bgcolor="#cccccc">&nbsp;</th></tr>';
	
		print '<tr><td align="left" bgcolor="#2ea495"><font face="Arial" size="-1" color="#ffffff"><b>Views</b></font></td><td align="right"><font face="Arial" size="-1">'.
			$count0.
			'</font></td><td align="right"><font face="Arial" size="-1">' .
			$count1 .
			'</font></td>';
	
		$cur_count = $count0;
		$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 = $count1;
		$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>';
		print "</table>\n";
	} else {
		print '<font color="#ff0000"><b>This document has not been viewed in this period.</b></font>';
	}
?>

<h4>Views by country (derived from IP address of query) for <?php print $show_date; ?></h4>
<?php
	if (isset($GLOBALS["db_values"]["0"]["country_downloads"])) {
		$max_count = $GLOBALS["db_values"]["0"]["country_downloads"];
		for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++) {
			if ($GLOBALS["db_values"][$rs]["country_abstracts"] > $max_count){
				$max_count = $GLOBALS["db_values"][$rs]["country_abstracts"];
			}
		}
		print "<table>\n";
		print '<tr><th colspan="2" align="left" bgcolor="#cccccc" width="150">Country</th>
		<th bgcolor="#66ddee">Abstracts</th>
		<th bgcolor="#4477dd"><font color="#ffffff">Downloads</font></th>
		<th bgcolor="#cccccc">&nbsp;</th></tr>';
	}
	else {
		print "<table>\n";
		print '<tr><td align="left" width="200"><font color="#ff0000"><b>No statistics are available.</b></font></td></tr>';
	}
	for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
	{
		if ($GLOBALS["db_values"][$rs]["country_name"]=='') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; }
		if ($GLOBALS["db_values"][$rs]["country_name"]=='N/A') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; }
		print '<tr><td>';
		
		// select a flag
		$ccode = strtolower($GLOBALS["db_values"][$rs]["country_code"]);
		$c_flag = 'flags18x14/' . $ccode . '.png';
		if (file_exists($c_flag)) {
			print '<img src="'. $c_flag . '" width="18" height="14" alt="'. $ccode . '">';
		} else {
			print '<img src="flags18x14/unknown.png" width="18" height="14" alt="' . $ccode . '">';
		};
		
		print '</td><td><font face="Arial" size="-1">' .
			$GLOBALS["db_values"][$rs]["country_name"].
			'</font></td><td align="right"><font face="Arial" size="-1">'.
			$GLOBALS["db_values"][$rs]["country_abstracts"].
			'</font></td><td align="right"><font face="Arial" size="-1">'.
			$GLOBALS["db_values"][$rs]["country_downloads"].
			'</font></td>';

		$cur_count = $GLOBALS["db_values"][$rs]["country_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="views" height="9" width="'. 
			$col_width . 
			'"><br />';

		$cur_count = $GLOBALS["db_values"][$rs]["country_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="views" height="9" width="'. 
			$col_width . 
			'"></td></tr>';
	}
	print "</table>\n";

?>

<h4>History of views for this ePrint</h4>
<?php
	if (count($month_tally) > 0)
	{
		$max_count = 1;
		for ($rs=0;$rs<count($month_tally);$rs++) {
			if($max_count < $month_tally[$rs]["abstracts"])
				$max_count = $month_tally[$rs]["abstracts"];
			if($max_count < $month_tally[$rs]["downloads"])
				$max_count = $month_tally[$rs]["downloads"];
		}
		
		print "<table>\n";
		print '<tr><th bgcolor="#cccccc" width="150">Period</th><th bgcolor="#66ddee">Abstracts</th><th bgcolor="#4477dd"><font color="#ffffff">Downloads</font></th><th bgcolor="#cccccc">&nbsp;</th></tr>';
		for ($rs=0;$rs<count($month_tally);$rs++)
		{

			$str_posn = strpos('JanFebMarAprMayJunJulAugSepOctNovDec',$month_tally[$rs]["month"]);
			if ($str_posn === false) $str_posn = 0;
			$month_number = (int) ($str_posn / 3) + 1;

			
			print '<tr><td><font face="Arial,Helvetica,sans-serif" size="-1"><a href="'.
				$_SERVER['PHP_SELF'].
				'?action=show_detail_eprint;id=' .
				$_REQUEST["id"] .
				';year=' .
				(int) $month_tally[$rs]["year"] .
				';month='.
				$month_number .
				'">'.
				(int) $month_tally[$rs]["year"] .
				' '.
				$month_tally[$rs]["month"] .
				'</a></font></td>';
			print '<td align="right"><font face="Arial,Helvetica,sans-serif" size="-1">'.
				$month_tally[$rs]["abstracts"].
				'</font></td>'; 
			print '<td align="right"><font face="Arial,Helvetica,sans-serif" size="-1">'.
				$month_tally[$rs]["downloads"].
				'</font></td>'; 
			// abstract views bar
			$cur_count = $month_tally[$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="views" height="9" width="'. 
				$col_width . 
				'"><br />';
			// download views bar
			$cur_count = $month_tally[$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="views" height="9" width="'. 
				$col_width . 
				'"></td></tr>';
		}
		print "</table>\n";
	} else {
		print '<font color="#ff0000"><b>No statistics are available.</b></font>';
	}
?>