Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.html.cumulative_usage.es.php
  1. <h3>Abstract views and document 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 document downloads for that month.<br />
  28. The numbers in (parentheses) are the number of distinct countries that views/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;">Downloads</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: Added archive name to URL and only generate
  41. // a link if there are actually 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. ';archive=' .
  50. $GLOBALS["config_vars"]["archivename"] .
  51. '">';
  52. print $GLOBALS["db_values"][$rs]["year"].
  53. ' '.
  54. $GLOBALS["db_values"][$rs]["month"];
  55. if ( $GLOBALS["db_values"][$rs]["downloads"] > 0 )
  56. print '</a>';
  57. print '</td><td align="right" style="font-size:small;">'.
  58. $GLOBALS["db_values"][$rs]["abstracts"].
  59. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('.
  60. $GLOBALS["db_values"][$rs]["acountries"].
  61. ')</td><td align="right" style="font-size:small;">'.
  62. $GLOBALS["db_values"][$rs]["downloads"].
  63. '</td><td align="right" style="font-size:small;border-right:1px solid #dddddd;">('.
  64. $GLOBALS["db_values"][$rs]["dcountries"].
  65. ')</td>';
  66. $cur_count = $GLOBALS["db_values"][$rs]["abstracts"];
  67. $col_width = (int) ($cur_count/$max_count * $max_width);
  68. $col_width = max($col_width, 1);
  69. $col_width .= "px";
  70. print '<td align="left"><img src="bars/hh.png" alt="abstracts" height="9" width="'.
  71. $col_width .
  72. '" /><br />';
  73. $cur_count = $GLOBALS["db_values"][$rs]["downloads"];
  74. $col_width = (int) ($cur_count/$max_count * $max_width);
  75. $col_width = max($col_width, 1);
  76. $col_width .= "px";
  77. print '<img src="bars/hp.png" alt="downloads" height="9" width="'.
  78. $col_width .
  79. '" /></td></tr>';
  80. }
  81. } // of else
  82. print "</table>\n";
  83. ?>
  84.