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_*/;
12 OpenILS::Application::Storage::CDBI->connection('dbi:Pg:host=10.0.0.2;dbname=open-ils-dev', 'postgres');
13 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
17 #-------------------------------------------------------------------------------
19 #-------------------------------------------------------------------------------
22 Content-type: text/html
29 border: dashed lightgrey 1px;
30 background-color: #EEE;
31 border-collapse: collapse;
36 border: solid lightgrey 1px;
44 background-color: lightblue;
45 border: solid blue 1px;
50 <body style='padding: 25px;'>
52 <h1>Configure Circulation Rules</h1>
57 #-------------------------------------------------------------------------------
59 #-------------------------------------------------------------------------------
63 extended => "Extended",
66 max_renewals => "Max Renewals",
69 my @dur_display_order = ( qw/name normal extended shrt max_renewals/ );
76 recurance_interval => "Interval",
79 my @fine_display_order = ( qw/name recurance_interval normal high low/ );
84 radius => "Holdable Radius",
87 my @age_display_order = ( qw/name age radius/ );
94 my @max_fine_display_order = ( qw/name amount/ );
97 #-------------------------------------------------------------------------------
99 #-------------------------------------------------------------------------------
101 if (my $action = $cgi->param('action')) {
102 my $form = $cgi->param('rules_form');
104 if ($form eq 'duration') {
105 if ($action eq 'Remove Selected') {
106 for my $id ( ($cgi->param('remove_me')) ) {
107 config::rules::circ_duration->retrieve($id)->delete;
109 } elsif ( $action eq 'Add New' ) {
110 config::rules::circ_duration->create(
111 { map { ($_ => $cgi->param($_)) } keys %dur_cols }
114 } elsif ($form eq 'recuring_fine') {
115 if ($action eq 'Remove Selected') {
116 for my $id ( ($cgi->param('remove_me')) ) {
117 config::rules::recuring_fine->retrieve($id)->delete;
119 } elsif ( $action eq 'Add New' ) {
120 config::rules::recuring_fine->create(
121 { map { ($_ => $cgi->param($_)) } keys %fine_cols }
124 } elsif ($form eq 'max_fine') {
125 if ($action eq 'Remove Selected') {
126 for my $id ( ($cgi->param('remove_me')) ) {
127 config::rules::max_fine->retrieve($id)->delete;
129 } elsif ( $action eq 'Add New' ) {
130 config::rules::max_fine->create(
131 { map { ($_ => $cgi->param($_)) } keys %max_fine_cols }
134 } elsif ($form eq 'age_hold') {
135 if ($action eq 'Remove Selected') {
136 for my $id ( ($cgi->param('remove_me')) ) {
137 config::rules::age_hold_protect->retrieve($id)->delete;
139 } elsif ( $action eq 'Add New' ) {
140 config::rules::age_hold_protect->create(
141 { map { ($_ => $cgi->param($_)) } keys %age_cols }
150 #-------------------------------------------------------------------------------
152 #-------------------------------------------------------------------------------
154 #-----------------------------------------------------------------------
156 #-----------------------------------------------------------------------
157 print "<form method='POST'>".
158 "<input type='hidden' name='rules_form' value='duration'>".
159 "<h2>Circulation Duration</h2>".
160 "<table class='table_class'><tr class='header_class'>\n";
162 for my $col ( @dur_display_order ) {
163 print th($dur_cols{$col});
168 for my $row ( config::rules::circ_duration->retrieve_all ) {
169 print "</tr><tr class='row_class'>";
170 for my $col ( @dur_display_order ) {
171 print td($row->$col);
173 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
175 print "</tr><tr class='new_row_class'>\n";
177 for my $col ( @dur_display_order ) {
178 print td("<input type='text' name='$col'>");
182 print "<td/></tr></table>".
183 "<input type='submit' name='action' value='Add New'/> | ".
184 "<input type='submit' name='action' value='Remove Selected'/>".
189 #-----------------------------------------------------------------------
191 #-----------------------------------------------------------------------
192 print "<form method='POST'>".
193 "<input type='hidden' name='rules_form' value='recuring_fine'>".
194 "<h2>Recuring Fine Levels</h2>".
195 "<table class='table_class'><tr class='header_class'>\n";
197 for my $col ( @fine_display_order ) {
198 print th($fine_cols{$col});
203 for my $row ( config::rules::recuring_fine->retrieve_all ) {
204 print "</tr><tr class='row_class'>\n";
205 for my $col ( @fine_display_order ) {
206 print td($row->$col);
208 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
211 print "</tr><tr class='new_row_class'>\n";
213 for my $col ( @fine_display_order ) {
214 print td("<input type='text' name='$col'>");
218 print "<td/></tr></table>".
219 "<input type='submit' name='action' value='Add New'/> | ".
220 "<input type='submit' name='action' value='Remove Selected'/>".
225 #-----------------------------------------------------------------------
227 #-----------------------------------------------------------------------
228 print "<form method='POST'>".
229 "<input type='hidden' name='rules_form' value='max_fine'>".
230 "<h2>Max Fine Levels</h2>".
231 "<table class='table_class'><tr class='header_class'>\n";
233 for my $col ( @max_fine_display_order ) {
234 print th($max_fine_cols{$col});
239 for my $row ( config::rules::max_fine->retrieve_all ) {
240 print "</tr><tr class='row_class'>\n";
241 for my $col ( @max_fine_display_order ) {
242 print td($row->$col);
244 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
247 print "</tr><tr class='new_row_class'>\n";
249 for my $col ( @max_fine_display_order ) {
250 print td("<input type='text' name='$col'>");
254 print "<td/></tr></table>".
255 "<input type='submit' name='action' value='Add New'/> | ".
256 "<input type='submit' name='action' value='Remove Selected'/>".
261 #-----------------------------------------------------------------------
262 # Age hold protect form
263 #-----------------------------------------------------------------------
264 print "<form method='POST'>".
265 "<input type='hidden' name='rules_form' value='age_hold'>".
266 "<h2>Item Age Hold Protection</h2>".
267 "<table class='table_class'><tr class='header_class'>\n";
269 for my $col ( @age_display_order ) {
270 print th($age_cols{$col});
275 for my $row ( config::rules::age_hold_protect->retrieve_all ) {
276 print "</tr><tr class='row_class'>\n";
277 for my $col ( @age_display_order ) {
278 if ($col eq 'radius') {
279 print td($row->$col->name);
281 print td($row->$col);
284 print "<td><input type='checkbox' value='$row' name='remove_me'</td>";
287 print "</tr><tr class='new_row_class'>\n";
289 for my $col ( @age_display_order ) {
290 if ($col eq 'radius') {
291 print "<td><select name='$col'>";
292 for my $radius ( actor::org_unit_type->retrieve_all ) {
293 print "<option value='".$radius->id."'>".
294 $radius->name."</option>";
296 print "</select></td>";
298 print td("<input type='text' name='$col'>");
303 print "<td/></tr></table>".
304 "<input type='submit' name='action' value='Add New'/> | ".
305 "<input type='submit' name='action' value='Remove Selected'/>".
310 print "</body></html>";