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
/
print.php
185 lines (159 loc) · 6.31 KB
/
print.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
include ('config.php');
if ($debug){
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', 1);
}
session_start();
if ($_REQUEST['table']) { $_SESSION['weed_table'] = $_REQUEST['table']; }
$table = $_SESSION['weed_table'];
include('scripts.php');
include('mysql_connect.php');
$q = "SELECT file_title from `controller` where table_name = ?";
$params = array($table);
$stmt = $db->prepare($q);
$stmt->execute($params);
$myrow = $stmt->fetch(PDO::FETCH_ASSOC);
$title = $myrow[0];
?>
<html>
<head>
<title>Print View: <?php print($title);?></title>
<style>
table,td,th {
border-collapse: collapse; border: 1px solid black;
vertical-align: top;
}
td:nth-child(5),td:nth-child(6) { text-align: right }
</style>
<h1><?php print($title);?> (Print-friendly)</h1>
<?php
include("nav.php");
?>
<form action="">
<table>
<tr>
<td><label for="cmp_date">Show items with CATDATE</label></td>
<td><select name="before_after">
<option value="<="><= (on or before)</option>
<option value=">=">>= (on or after)</option>
</select></td>
<td><input type="text" name="cmp_date" id="cmp_date" placeholder="yyyy-mm-dd" value="<?php print($_REQUEST['cmp_date']);?>" /></td>
</tr>
<tr>
<td><label for="circ_count">Total Circs</label></td>
<td>
<select name="circ_count_operator">
<option value="<="><= (less than or equal to)</option>
<option value="=">= (equal to)</option>
<option value=">=">>= (greater than or equal to)</option>
</select>
</td>
<td>
<input type="text" name="circ_count" id="circ_count" placeholder="#" value="<?php print($_REQUEST['circ_count']);?>"/>
</td>
</tr>
<tr>
<td><label for="innreach_count">Total Innreach Copies</label></td>
<td><select name="innreach_count_operator">
<option value="<="><= (less than or equal to)</option>
<option value="=">= (equal to)</option>
<option value=">=">>= (greater than or equal to)</option>
</select>
</td>
<td><input type="text" name="innreach_count" id="innreach_count" placeholder="#" value="<?php print($_REQUEST['innreach_count']);?>"/></td>
</tr>
<tr>
<td><label for="innreach_circ_count">Total Innreach Circ Copies</label></td>
<td><select name="innreach_circ_count_operator">
<option value="<="><= (less than or equal to)</option>
<option value="=">= (equal to)</option>
<option value=">=">>= (greater than or equal to)</option>
</select></td>
<td><input type="text" name="innreach_circ_count" id="inreach_circ_count" placeholder="#" value="<?php print($_REQUEST['innreach_circ_count']);?>"/></td>
</tr>
<tr>
<td><label for="fate_operator">Fate</label></td>
<td><select name="fate_operator">
<option value="">--Select One--</option>
<option value="=" <?php if ($_REQUEST['fate_operator'] == "=") { print "SELECTED"; }?>>= (equals)</option>
<option value="!=" <?php if ($_REQUEST['fate_operator'] == "!=") { print "SELECTED"; }?>>!= (not equals)</option>
</select></td>
<td><select name="fate_value">
<option value="">None Selected</option>
<option value="weed" <?php if ($_REQUEST['fate_value'] == "weed") { print "SELECTED"; }?>>weed</option>
<option value="de-dup" <?php if ($_REQUEST['fate_value'] == "de-dup") { print "SELECTED"; }?>>de-dup</option>
<option value="replace" <?php if ($_REQUEST['fate_value'] == "replace") { print "SELECTED"; }?>>replace</option>
<option value="update" <?php if ($_REQUEST['fate_value'] == "update") { print "SELECTED"; }?>>update</option>
<option value="keep" <?php if ($_REQUEST['fate_value'] == "keep") { print "SELECTED"; }?>>keep</option>
<select>
</td>
</tr>
</table>
<input type="submit" value="Limit Records Displayed">
</form>
<?php
$print_params = array();
$valid_operators = array ("<=", "=", ">=");
if (is_numeric($_REQUEST['circ_count']) and (in_array($_REQUEST['circ_count_operator'], $valid_operators))) {
array_push($print_params, $_REQUEST['circ_count']);
$added_query = " AND `circs`" . $_REQUEST['circ_count_operator']. " ? ";
} //end if circ cmp
if (is_numeric($_REQUEST['innreach_count']) and (in_array($_REQUEST['innreach_count_operator'], $valid_operators))) {
array_push($print_params, $_REQUEST['innreach_count']);
$added_query .= " AND `innreach_total_copies`" . $_REQUEST['innreach_count_operator']. " ? ";
} //end if circ cmp
if (is_numeric($_REQUEST['innreach_circ_count']) and (in_array($_REQUEST['innreach_circ_count_operator'], $valid_operators))) {
array_push($print_params, $_REQUEST['innreach_circ_count']);
$added_query .= " AND `innreach_circ_copies`" . $_REQUEST['innreach_circ_count_operator']. " ? ";
} //end if circ cmp
if (preg_match("/\d\d\d\d-\d\d-\d\d/", $_REQUEST['cmp_date']) and (in_array($_REQUEST['before_after'], $valid_operators))) {
array_push($print_params,$_REQUEST['cmp_date']);
$added_query .= "AND `catdate`" . $_REQUEST['before_after'] . " ? ";
} //end if date cmp
$allowed_fate_ops = array("=", "!=");
if (isset($_REQUEST['fate_operator']) && in_array($_REQUEST['fate_operator'], $allowed_fate_ops)) {
array_push($print_params,$_REQUEST['fate_value']);
$added_query .= 'AND `fate` '. $_REQUEST['fate_operator'] . " ? ";
}
/* Find out if there are special settings for this table */
$q = "SELECT distinct `table_name` from `table_config` where `table_name`= ?";
$params = array($table);
$stmt = $db->prepare($q);
$stmt->execute($params);
if ($stmt->rowCount() > 0 ) {
$print_settings = $table;
}
else {
$print_settings = "default";
}
$q1 = "SELECT field from `table_config` where `printable` = 'Y' and `table_name` = ?";
$params = array($print_settings);
$stmt = $db->prepare($q1);
$stmt->execute($params);
$fields = array();
while ($myrow = $stmt->fetch(PDO::FETCH_ASSOC)) {
array_push ($fields, $myrow['field']);
}
$fields = "`". join ("`,`", $fields) . "`";
$verified_table = VerifyTableName($table);
$q = "SELECT $fields
FROM `$verified_table`
where 1 $added_query
ORDER BY call_order";
//ORDER BY subclass,subj_starts";
if ($_REQUEST['before_after'] || $_REQUEST['circ_count']) {
$clear_button = '<a href="print.php?"><button><img src="images/delete.png" style="height: .75em"> Remove Conditions</button></a>';
}
print "<div class=\"example\">$q<br>$clear_button</div>\n";
$stmt = $db->prepare($q);
$stmt->execute($print_params);
print ("<h3>".$stmt->rowCount()." items</h3>\n");
if (function_exists("MysqlResultsTable")) {
print(MysqlResultsTable($stmt));
}
else {
print "no function";
}
?>
<?php include ("license.php"); ?>