5 use OpenILS::Application::Storage;
6 use OpenILS::Application::Storage::CDBI;
8 # I need to abstract the driver loading away...
9 use OpenILS::Application::Storage::Driver::Pg;
11 use CGI qw/:standard start_*/;
14 do '##CONFIG##/live-db-setup.pl';
16 OpenILS::Application::Storage::CDBI->connection($config{dsn},$config{usr},$config{pw});
17 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
21 #-------------------------------------------------------------------------------
23 #-------------------------------------------------------------------------------
26 Content-type: text/html
31 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
32 <meta http-equiv="Pragma" content="no-cache" />
33 <meta http-equiv="Expires" content="Thu, 01 Dec 2000 16:00:00 GMT" />
36 border: dashed lightgrey 1px;
37 background-color: #EEE;
38 border-collapse: collapse;
43 border: solid lightgrey 1px;
51 background-color: lightblue;
52 border: solid blue 1px;
57 <body style='padding: 25px;'>
59 <a href="$config{index}">Home</a>
61 <h1>Configure Circulation Rules</h1>
66 #-------------------------------------------------------------------------------
68 #-------------------------------------------------------------------------------
72 extended => "Extended",
75 max_renewals => "Max Renewals",
78 my @dur_display_order = ( qw/name normal extended shrt max_renewals/ );
85 recurance_interval => "Interval",
88 my @fine_display_order = ( qw/name recurance_interval normal high low/ );
93 prox => "Holdable Radius",
96 my @age_display_order = ( qw/name age prox/ );
103 my @max_fine_display_order = ( qw/name amount/ );
106 #-------------------------------------------------------------------------------
108 #-------------------------------------------------------------------------------
110 if (my $action = $cgi->param('action')) {
111 my $form = $cgi->param('rules_form');
113 if ($form eq 'duration') {
114 if ($action eq 'Remove Selected') {
115 for my $id ( ($cgi->param('remove_me')) ) {
116 config::rules::circ_duration->retrieve($id)->delete;
118 } elsif ( $action eq 'Add New' ) {
119 config::rules::circ_duration->create(
120 { map { ($_ => $cgi->param($_)) } keys %dur_cols }
123 } elsif ($form eq 'recuring_fine') {
124 if ($action eq 'Remove Selected') {
125 for my $id ( ($cgi->param('remove_me')) ) {
126 config::rules::recuring_fine->retrieve($id)->delete;
128 } elsif ( $action eq 'Add New' ) {
129 config::rules::recuring_fine->create(
130 { map { ($_ => $cgi->param($_)) } keys %fine_cols }
133 } elsif ($form eq 'max_fine') {
134 if ($action eq 'Remove Selected') {
135 for my $id ( ($cgi->param('remove_me')) ) {
136 config::rules::max_fine->retrieve($id)->delete;
138 } elsif ( $action eq 'Add New' ) {
139 config::rules::max_fine->create(
140 { map { ($_ => $cgi->param($_)) } keys %max_fine_cols }
143 } elsif ($form eq 'age_hold') {
144 if ($action eq 'Remove Selected') {
145 for my $id ( ($cgi->param('remove_me')) ) {
146 config::rules::age_hold_protect->retrieve($id)->delete;
148 } elsif ( $action eq 'Add New' ) {
149 config::rules::age_hold_protect->create(
150 { map { ($_ => $cgi->param($_)) } keys %age_cols }
159 #-------------------------------------------------------------------------------
161 #-------------------------------------------------------------------------------
163 #-----------------------------------------------------------------------
165 #-----------------------------------------------------------------------
166 print "<form method='POST'>".
167 "<input type='hidden' name='rules_form' value='duration'>".
168 "<h2>Circulation Duration</h2>".
169 "<table class='table_class'><tr class='header_class'>\n";
171 for my $col ( @dur_display_order ) {
172 print th($dur_cols{$col});
177 for my $row ( config::rules::circ_duration->retrieve_all ) {
178 print "</tr><tr class='row_class'>";
179 for my $col ( @dur_display_order ) {
180 print td($row->$col);
182 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
184 print "</tr><tr class='new_row_class'>\n";
186 for my $col ( @dur_display_order ) {
187 print td("<input type='text' name='$col'>");
191 print "<td/></tr></table>".
192 "<input type='submit' name='action' value='Add New'/> | ".
193 "<input type='submit' name='action' value='Remove Selected'/>".
198 #-----------------------------------------------------------------------
200 #-----------------------------------------------------------------------
201 print "<form method='POST'>".
202 "<input type='hidden' name='rules_form' value='recuring_fine'>".
203 "<h2>Recuring Fine Levels</h2>".
204 "<table class='table_class'><tr class='header_class'>\n";
206 for my $col ( @fine_display_order ) {
207 print th($fine_cols{$col});
212 for my $row ( config::rules::recuring_fine->retrieve_all ) {
213 print "</tr><tr class='row_class'>\n";
214 for my $col ( @fine_display_order ) {
215 print td($row->$col);
217 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
220 print "</tr><tr class='new_row_class'>\n";
222 for my $col ( @fine_display_order ) {
223 print td("<input type='text' name='$col'>");
227 print "<td/></tr></table>".
228 "<input type='submit' name='action' value='Add New'/> | ".
229 "<input type='submit' name='action' value='Remove Selected'/>".
234 #-----------------------------------------------------------------------
236 #-----------------------------------------------------------------------
237 print "<form method='POST'>".
238 "<input type='hidden' name='rules_form' value='max_fine'>".
239 "<h2>Max Fine Levels</h2>".
240 "<table class='table_class'><tr class='header_class'>\n";
242 for my $col ( @max_fine_display_order ) {
243 print th($max_fine_cols{$col});
248 for my $row ( config::rules::max_fine->retrieve_all ) {
249 print "</tr><tr class='row_class'>\n";
250 for my $col ( @max_fine_display_order ) {
251 print td($row->$col);
253 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
256 print "</tr><tr class='new_row_class'>\n";
258 for my $col ( @max_fine_display_order ) {
259 print td("<input type='text' name='$col'>");
263 print "<td/></tr></table>".
264 "<input type='submit' name='action' value='Add New'/> | ".
265 "<input type='submit' name='action' value='Remove Selected'/>".
270 #-----------------------------------------------------------------------
271 # Age hold protect form
272 #-----------------------------------------------------------------------
273 print "<form method='POST'>".
274 "<input type='hidden' name='rules_form' value='age_hold'>".
275 "<h2>Item Age Hold Protection</h2>".
276 "<table class='table_class'><tr class='header_class'>\n";
278 for my $col ( @age_display_order ) {
279 print th($age_cols{$col});
284 for my $row ( config::rules::age_hold_protect->retrieve_all ) {
285 print "</tr><tr class='row_class'>\n";
286 for my $col ( @age_display_order ) {
287 print td($row->$col);
289 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
292 print "</tr><tr class='new_row_class'>\n";
294 for my $col ( @age_display_order ) {
295 print td("<input type='text' name='$col'>");
299 print "<td/></tr></table>".
300 "<input type='submit' name='action' value='Add New'/> | ".
301 "<input type='submit' name='action' value='Remove Selected'/>".
306 print "</body></html>";