This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
forked from kenirwin/Weeding-Helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.php
154 lines (135 loc) · 4.54 KB
/
graph.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
include("config.php");
if ($debug){
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', 1);
}
session_start();
?>
<html>
<head>
<title>Graph - Weeding Helper</title>
<style>
.intro { margin: 2em 1em; }
img { padding-top: 1px }
thead td { font-weight: bold }
td.title { width: 300px; }
td img { height: 1em; }
table.min td { padding: 0; margin: 0; border: none; spacing: 0; }
table.min img { height: .5em; }
td { font-size: 80%; }
</style>
<?php include("jquery.php"); ?>
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs();
$("#min-max").click(function() {
$("td.title").toggle();
$("td.circs").toggle();
$("thead").toggle();
$("table").toggleClass("min");
}); //end min-max click function
}); //end jquery load script
</script>
</head>
<body>
<?php
include ("mysql_connect.php");
if ($_REQUEST['table']) { $_SESSION['weed_table'] = $_REQUEST['table']; }
$table = $_SESSION['weed_table'];
$imgsrc = "images/greenblock.gif";
$redimg = "images/redblock.gif";
$q = "SELECT file_title from `controller` where table_name = ?";
$params = array($table);
$stmt = $db->prepare($q);
$stmt->execute($params);
if ($stmt->rowCount() == 1) { $verified_table_name = $table; }
$myrow = $stmt->fetch(PDO::FETCH_NUM);
$title = $myrow[0];
include("nav.php");
?>
<h1>Graph: <?php print($title);?></h1>
<div id="tabs">
<ul>
<li><a href="#tabs-age">Age of Collection</a></li>
<li><a href="#tabs-title-usage">Usage by Title</a></li>
<li><a href="#tabs-recency-of-circ">Recency of Circulation</a></li>
</ul>
<div id="tabs-age">
<?php
if (isset($verified_table_name)) {
$q = "SELECT `year`,count(*) as `items` FROM $verified_table_name GROUP BY `year` ORDER BY `year` DESC";
$stmt = $db->query($q);
$rows = "";
while ($myrow = $stmt->fetch(PDO::FETCH_ASSOC)) {
extract($myrow);
$size = $items * 1;
$rows .= '<tr><td>'.$year.'</td> <td>'.$items.'</td><td><img src="'.$imgsrc.'" width="'.$size.'" height="1em" /></td>'.PHP_EOL;
}
print '<table>'.PHP_EOL;
print $rows;
print '</table>'.PHP_EOL;
} //if $verified_table_name
?>
</div><!--tabs-age-->
<div id="tabs-title-usage">
<?php
if (isset($verified_table_name)) {
$q= "select * from $verified_table_name";
$stmt = $db->query($q);
$last_class = "";
}
?>
<div class="intro">
<p>This graphs the shelflist: arranged in call number order, the titles in this table are shown with the number of times circulated. Zero circs shown in red.</p>
<p><input type="checkbox" id="min-max" />Check this box to minimize the graph (hide all but graph; mouseover graph for title info)</p>
</div>
<?php
$thead = "<thead><tr><td>Title</td><td>Circs</td><td>Graph</td></tr></thead>\n";
while ($myrow = $stmt->fetch(PDO::FETCH_ASSOC)) {
extract ($myrow);
if (isset($call_item) && $call_item != "") { $call = $call_item; }
elseif (isset($call_bib) && $call_bib != "") { $call = $call_bib; }
else { $call = ""; }
if (preg_match("/^([a-zA-Z]+)/",$call,$m)) {
$class = $m[1];
if ($class != $last_class) {
// print "<h2>$class</h2>\n";
$lines .= "</table><h2>$class</h2><table>$thead\n";
}
$last_class = $class;
}
if ($circs == 0) { $size = 1; }
else { $size = $circs *10; }
if ($circs == 0) {
$lines .= "<tr><td class=\"title\">$title</td><td class=\"circs\">$circs</td><td><img src=\"$redimg\" width=5 title=\"$title ($call): $circs\"></td></tr>\n";
// print "<br><img src=\"$redimg\" height=4 width=5 title=\"$title ($call): $circs\">\n";
}
else {
$lines .= "<tr><td class=\"title\">$title</td><td class=\"circs\">$circs</td><td><img src=\"$imgsrc\" width=\"$size\" title=\"$title ($call): $circs\"></td></tr>\n";
// print "<br><img src=\"$imgsrc\" width=\"$size\" height=4 title=\"$title ($call): $circs\">\n";
}
} //end while
print "<table>$lines</table>\n";
?>
</div><!--title-usage-->
<div id="tabs-recency-of-circ">
<p>Year in which items last circulated, by number of items per year</p>
<?php
$q= "select count(*) as YearCount, year(`last_checkin`) as `LastCirc` from `$table` group by `LastCirc` order by `LastCirc` DESC";
$params = array($table);
$stmt = $db->prepare($q);
$stmt->execute($params);
while ($myrow = $stmt->fetch(PDO::FETCH_ASSOC)) {
extract($myrow);
$circ_rows .= "<tr><td>$LastCirc</td> <td>$YearCount</td> <td><img src=\"$imgsrc\" width=\"$YearCount\" title=\"Last Circ in $LastCirc: $YearCount\"></td></tr>\n";
}
print '<table id="recency-of-circ">'.PHP_EOL;
print $circ_rows;
print '</table>'.PHP_EOL;
?>
</div><!--recency-of-circ-->
</div><!--tabs-->
<?php include ("license.php"); ?>
</body>
</html>