Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.html.show_detail_eprint.es.php
<?php
	require("inc.html.navbar_global.es.php");

	if ($title == '')
	{
		$title = getEPrintTitle($_REQUEST["id"]);
		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>      

<?php
	require("inc.html.navbar_eprint.es.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" style="background-color:#cccccc;">&nbsp;</th>
		<th style="background-color:#66ddee;">Abstracts</th>
		<th style="background-color:#4477dd;color:#ffffff;">Downloads</th>
		<th style="background-color:#cccccc;">&nbsp;</th></tr>';
	
		print '<tr><td align="left" style="background-color:#2ea495;color:#ffffff;font-size:small;"><b>Views</b></td><td align="right" style="font-size:small;">'.
			$count0.
			'</td><td align="right" style="font-size:small;">' .
			$count1 .
			'</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 '<b style="color:#ff0000;">This document has not been viewed in this period.</b>';
	}
?>

<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" style="background-color:#cccccc;" width="150">Country</th>
		<th style="background-color:#66ddee;">Abstracts</th>
		<th style="background-color:#4477dd;color:#ffffff;">Downloads</th>
		<th style="background-color:#cccccc;">&nbsp;</th></tr>';
	}
	else {
		print "<table>\n";
		print '<tr><td align="left" width="200"><b style="color:#ff0000;">No statistics are available.</b></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 style="font-size:small;">' .
			$GLOBALS["db_values"][$rs]["country_name"].
			'</td><td align="right" style="font-size:small;">'.
			$GLOBALS["db_values"][$rs]["country_abstracts"].
			'</td><td align="right" style="font-size:small;">'.
			$GLOBALS["db_values"][$rs]["country_downloads"].
			'</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 style="background-color:#cccccc;" width="150">Period</th><th style="background-color:#66ddee;">Abstracts</th><th style="background-color:#4477dd;color:#ffffff;">Downloads</th><th style="background-color:#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 style="font-size:small;"><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></td>';
			print '<td align="right" style="font-size:small;">'.
				$month_tally[$rs]["abstracts"].
				'</td>'; 
			print '<td align="right" style="font-size:small;">'.
				$month_tally[$rs]["downloads"].
				'</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 '<b style="color:#ff0000;">No statistics are available.</b>';
	}
?>