Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.html.cumulative_usage.es.php
  1. <h3>Abstract views and full text downloads by year/month</h3>
  2.  
  3. <?php
  4. // NJS 2006-04-24
  5. // Add if to check whether there actually are any stats!
  6. if (! isset($GLOBALS["db_values"]["0"]["abstracts"])) {
  7. print "<table>\n";
  8. print '<tr><td align="left" width="200" style="color:#ff0000;"><b>No statistics available.</b></td></tr>';
  9. print "\n";
  10. } else {
  11. $max_count = $GLOBALS["db_values"][0]["abstracts"];
  12. for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
  13. {
  14. if($max_count < $GLOBALS["db_values"][$rs]["abstracts"])
  15. $max_count = $GLOBALS["db_values"][$rs]["abstracts"];
  16. // NJS 2006-06-14: Included downloads in the max_count
  17. // calculation for cases where there are more downloads
  18. // than abstracts.
  19. if($max_count < $GLOBALS["db_values"][$rs]["downloads"])
  20. $max_count = $GLOBALS["db_values"][$rs]["downloads"];
  21. }
  22. // NJS 2006-06-14: You never know, there may be no downloads or
  23. // abstracts yet...
  24. $max_count = max( $max_count, 1 );
  25. $max_width = '500'; // Max pixel width of barchart.
  26. print "<table cellspacing='0' cellpadding='4'>\n";
  27. print '<tr><td colspan="6"><span style="font-size:small;">Click on a month to see full text downloads for that month.<br />
  28. The numbers in (parentheses) are the number of distinct countries or search engines that downloads originated from.</span></td></tr>';
  29. print '<tr><th style="background-color:#cccccc;">Period</th>
  30. <th colspan="2" style="background-color:#66ddee;">Abstracts</th>
  31. <th colspan="2" style="background-color:#4477dd;color:#ffffff;">Full text</th>
  32. <th style="background-color:#cccccc;">&nbsp;</th></tr>';
  33. for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
  34. {
  35. $monthnum = (int) strpos('JanFebMarAprMayJunJulAugSepOctNovDec', $GLOBALS["db_values"][$rs]["month"])/3 + 1;
  36. // NJS 2005-12-15: subtly highlight every alternate row
  37. print '<tr';
  38. if ($rs % 2) print ' style="background-color:#EDF3FE;"';
  39. print '><td style="font-size:small;border-right:1px solid #dddddd;">';
  40. // NJS 2006-06-14: Only generate a link if there are actually
  41. // some downloads.
  42. if ( $GLOBALS["db_values"][$rs]["downloads"] > 0 )
  43. print '<a href="'.
  44. $_SERVER['PHP_SELF'].
  45. '?action=show_detail_date;year='.
  46. $GLOBALS["db_values"][$rs]["year"].
  47. ';month=' .
  48. $monthnum .
  49. '">';
  50. print $GLOBALS["db_values"][$rs]["year"].
  51. ' '.
  52. $GLOBALS["db_values"][$rs]["month"];
  53. if ( $GLOBALS["db_values"][$rs]["downloads"] > 0 )
  54. print '</a>';
  55. print '</td><td align="right" style="font-size:small;">'.
  56. $GLOBALS["db_values"][$rs]["abstracts"].
  57. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('.
  58. $GLOBALS["db_values"][$rs]["acountries"].
  59. ')</td><td align="right" style="font-size:small;">'.
  60. $GLOBALS["db_values"][$rs]["downloads"].
  61. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('.
  62. $GLOBALS["db_values"][$rs]["dcountries"].
  63. ')</td>';
  64. $cur_count = $GLOBALS["db_values"][$rs]["abstracts"];
  65. $col_width = (int) ($cur_count/$max_count * $max_width);
  66. $col_width = max($col_width, 1);
  67. $col_width .= "px";
  68. print '<td align="left"><img src="bars/hh.png" alt="abstracts" height="9" width="'.
  69. $col_width .
  70. '" /><br />';
  71. $cur_count = $GLOBALS["db_values"][$rs]["downloads"];
  72. $col_width = (int) ($cur_count/$max_count * $max_width);
  73. $col_width = max($col_width, 1);
  74. $col_width .= "px";
  75. print '<img src="bars/hp.png" alt="downloads" height="9" width="'.
  76. $col_width .
  77. '" /></td></tr>';
  78. }
  79. } // of else
  80. print "</table>\n";
  81. ?>
  82.