4 use OpenILS::Application::Storage;
5 use OpenILS::Application::Storage::CDBI;
7 # I need to abstract the driver loading away...
8 use OpenILS::Application::Storage::Driver::Pg;
10 use CGI qw/:standard start_*/;
15 OpenILS::Application::Storage::CDBI->connection($config{dsn},$config{usr});
16 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
20 #-------------------------------------------------------------------------------
22 #-------------------------------------------------------------------------------
25 Content-type: text/html
32 border: dashed lightgrey 1px;
33 background-color: #EEE;
34 border-collapse: collapse;
39 border: solid lightgrey 1px;
47 background-color: lightblue;
48 border: solid blue 1px;
53 <body style='padding: 25px;'>
55 <a href="$config{index}">Home</a>
57 <h1>Configure Circulation Rules</h1>
62 #-------------------------------------------------------------------------------
64 #-------------------------------------------------------------------------------
68 extended => "Extended",
71 max_renewals => "Max Renewals",
74 my @dur_display_order = ( qw/name normal extended shrt max_renewals/ );
81 recurance_interval => "Interval",
84 my @fine_display_order = ( qw/name recurance_interval normal high low/ );
89 radius => "Holdable Radius",
92 my @age_display_order = ( qw/name age radius/ );
99 my @max_fine_display_order = ( qw/name amount/ );
102 #-------------------------------------------------------------------------------
104 #-------------------------------------------------------------------------------
106 if (my $action = $cgi->param('action')) {
107 my $form = $cgi->param('rules_form');
109 if ($form eq 'duration') {
110 if ($action eq 'Remove Selected') {
111 for my $id ( ($cgi->param('remove_me')) ) {
112 config::rules::circ_duration->retrieve($id)->delete;
114 } elsif ( $action eq 'Add New' ) {
115 config::rules::circ_duration->create(
116 { map { ($_ => $cgi->param($_)) } keys %dur_cols }
119 } elsif ($form eq 'recuring_fine') {
120 if ($action eq 'Remove Selected') {
121 for my $id ( ($cgi->param('remove_me')) ) {
122 config::rules::recuring_fine->retrieve($id)->delete;
124 } elsif ( $action eq 'Add New' ) {
125 config::rules::recuring_fine->create(
126 { map { ($_ => $cgi->param($_)) } keys %fine_cols }
129 } elsif ($form eq 'max_fine') {
130 if ($action eq 'Remove Selected') {
131 for my $id ( ($cgi->param('remove_me')) ) {
132 config::rules::max_fine->retrieve($id)->delete;
134 } elsif ( $action eq 'Add New' ) {
135 config::rules::max_fine->create(
136 { map { ($_ => $cgi->param($_)) } keys %max_fine_cols }
139 } elsif ($form eq 'age_hold') {
140 if ($action eq 'Remove Selected') {
141 for my $id ( ($cgi->param('remove_me')) ) {
142 config::rules::age_hold_protect->retrieve($id)->delete;
144 } elsif ( $action eq 'Add New' ) {
145 config::rules::age_hold_protect->create(
146 { map { ($_ => $cgi->param($_)) } keys %age_cols }
155 #-------------------------------------------------------------------------------
157 #-------------------------------------------------------------------------------
159 #-----------------------------------------------------------------------
161 #-----------------------------------------------------------------------
162 print "<form method='POST'>".
163 "<input type='hidden' name='rules_form' value='duration'>".
164 "<h2>Circulation Duration</h2>".
165 "<table class='table_class'><tr class='header_class'>\n";
167 for my $col ( @dur_display_order ) {
168 print th($dur_cols{$col});
173 for my $row ( config::rules::circ_duration->retrieve_all ) {
174 print "</tr><tr class='row_class'>";
175 for my $col ( @dur_display_order ) {
176 print td($row->$col);
178 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
180 print "</tr><tr class='new_row_class'>\n";
182 for my $col ( @dur_display_order ) {
183 print td("<input type='text' name='$col'>");
187 print "<td/></tr></table>".
188 "<input type='submit' name='action' value='Add New'/> | ".
189 "<input type='submit' name='action' value='Remove Selected'/>".
194 #-----------------------------------------------------------------------
196 #-----------------------------------------------------------------------
197 print "<form method='POST'>".
198 "<input type='hidden' name='rules_form' value='recuring_fine'>".
199 "<h2>Recuring Fine Levels</h2>".
200 "<table class='table_class'><tr class='header_class'>\n";
202 for my $col ( @fine_display_order ) {
203 print th($fine_cols{$col});
208 for my $row ( config::rules::recuring_fine->retrieve_all ) {
209 print "</tr><tr class='row_class'>\n";
210 for my $col ( @fine_display_order ) {
211 print td($row->$col);
213 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
216 print "</tr><tr class='new_row_class'>\n";
218 for my $col ( @fine_display_order ) {
219 print td("<input type='text' name='$col'>");
223 print "<td/></tr></table>".
224 "<input type='submit' name='action' value='Add New'/> | ".
225 "<input type='submit' name='action' value='Remove Selected'/>".
230 #-----------------------------------------------------------------------
232 #-----------------------------------------------------------------------
233 print "<form method='POST'>".
234 "<input type='hidden' name='rules_form' value='max_fine'>".
235 "<h2>Max Fine Levels</h2>".
236 "<table class='table_class'><tr class='header_class'>\n";
238 for my $col ( @max_fine_display_order ) {
239 print th($max_fine_cols{$col});
244 for my $row ( config::rules::max_fine->retrieve_all ) {
245 print "</tr><tr class='row_class'>\n";
246 for my $col ( @max_fine_display_order ) {
247 print td($row->$col);
249 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
252 print "</tr><tr class='new_row_class'>\n";
254 for my $col ( @max_fine_display_order ) {
255 print td("<input type='text' name='$col'>");
259 print "<td/></tr></table>".
260 "<input type='submit' name='action' value='Add New'/> | ".
261 "<input type='submit' name='action' value='Remove Selected'/>".
266 #-----------------------------------------------------------------------
267 # Age hold protect form
268 #-----------------------------------------------------------------------
269 print "<form method='POST'>".
270 "<input type='hidden' name='rules_form' value='age_hold'>".
271 "<h2>Item Age Hold Protection</h2>".
272 "<table class='table_class'><tr class='header_class'>\n";
274 for my $col ( @age_display_order ) {
275 print th($age_cols{$col});
280 for my $row ( config::rules::age_hold_protect->retrieve_all ) {
281 print "</tr><tr class='row_class'>\n";
282 for my $col ( @age_display_order ) {
283 if ($col eq 'radius') {
284 print td($row->$col->name);
286 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 if ($col eq 'radius') {
296 print "<td><select name='$col'>";
297 for my $radius ( actor::org_unit_type->retrieve_all ) {
298 print "<option value='".$radius->id."'>".
299 $radius->name."</option>";
301 print "</select></td>";
303 print td("<input type='text' name='$col'>");
308 print "<td/></tr></table>".
309 "<input type='submit' name='action' value='Add New'/> | ".
310 "<input type='submit' name='action' value='Remove Selected'/>".
315 print "</body></html>";