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;
40 background-color: lightblue;
44 <body style='padding: 25px;'>
46 <h1>Configure Circulation Rules</h1>
51 #-------------------------------------------------------------------------------
53 #-------------------------------------------------------------------------------
57 extended => "Extended",
60 max_renewals => "Max Renewals",
63 my @dur_display_order = ( qw/name normal extended shrt max_renewals/ );
70 recurance_interval => "Interval",
73 my @fine_display_order = ( qw/name recurance_interval normal high low/ );
78 radius => "Holdable Radius",
81 my @age_display_order = ( qw/name age radius/ );
88 my @max_fine_display_order = ( qw/name amount/ );
91 #-------------------------------------------------------------------------------
93 #-------------------------------------------------------------------------------
95 if (my $action = $cgi->param('action')) {
96 my $form = $cgi->param('rules_form');
98 if ($form eq 'duration') {
99 if ($action eq 'Remove Selected') {
100 for my $id ( ($cgi->param('remove_me')) ) {
101 config::rules::circ_duration->retrieve($id)->delete;
103 } elsif ( $action eq 'Add New' ) {
104 config::rules::circ_duration->create(
105 { map { ($_ => $cgi->param($_)) } keys %dur_cols }
108 } elsif ($form eq 'recuring_fine') {
109 if ($action eq 'Remove Selected') {
110 for my $id ( ($cgi->param('remove_me')) ) {
111 config::rules::recuring_fine->retrieve($id)->delete;
113 } elsif ( $action eq 'Add New' ) {
114 config::rules::recuring_fine->create(
115 { map { ($_ => $cgi->param($_)) } keys %fine_cols }
118 } elsif ($form eq 'max_fine') {
119 if ($action eq 'Remove Selected') {
120 for my $id ( ($cgi->param('remove_me')) ) {
121 config::rules::max_fine->retrieve($id)->delete;
123 } elsif ( $action eq 'Add New' ) {
124 config::rules::max_fine->create(
125 { map { ($_ => $cgi->param($_)) } keys %max_fine_cols }
128 } elsif ($form eq 'age_hold') {
129 if ($action eq 'Remove Selected') {
130 for my $id ( ($cgi->param('remove_me')) ) {
131 config::rules::age_hold_protect->retrieve($id)->delete;
133 } elsif ( $action eq 'Add New' ) {
134 config::rules::age_hold_protect->create(
135 { map { ($_ => $cgi->param($_)) } keys %age_cols }
144 #-------------------------------------------------------------------------------
146 #-------------------------------------------------------------------------------
148 #-----------------------------------------------------------------------
150 #-----------------------------------------------------------------------
151 print "<form method='POST'>".
152 "<input type='hidden' name='rules_form' value='duration'>".
153 "<h2>Circulation Duration</h2>".
154 "<table class='table_class'><tr class='header_class'>\n";
156 for my $col ( @dur_display_order ) {
157 print th($dur_cols{$col});
160 print "<td/></tr><tr class='row_class'>\n";
162 for my $row ( config::rules::circ_duration->retrieve_all ) {
163 for my $col ( @dur_display_order ) {
164 print td($row->$col);
166 print "<td><input type='checkbox' value='$row' name='remove_me'</td>".
167 "</tr><tr class='row_class'>\n";
170 for my $col ( @dur_display_order ) {
171 print td("<input type='text' name='$col'>");
175 print "<td/></tr></table>".
176 "<input type='submit' name='action' value='Add New'/> | ".
177 "<input type='submit' name='action' value='Remove Selected'/>".
182 #-----------------------------------------------------------------------
184 #-----------------------------------------------------------------------
185 print "<form method='POST'>".
186 "<input type='hidden' name='rules_form' value='recuring_fine'>".
187 "<h2>Recuring Fine Levels</h2>".
188 "<table class='table_class'><tr class='header_class'>\n";
190 for my $col ( @fine_display_order ) {
191 print th($fine_cols{$col});
194 print "<td/></tr><tr class='row_class'>\n";
196 for my $row ( config::rules::recuring_fine->retrieve_all ) {
197 for my $col ( @fine_display_order ) {
198 print td($row->$col);
200 print "<td><input type='checkbox' value='$row' name='remove_me'</td>".
201 "</tr><tr class='row_class'>\n";
204 for my $col ( @fine_display_order ) {
205 print td("<input type='text' name='$col'>");
209 print "<td/></tr></table>".
210 "<input type='submit' name='action' value='Add New'/> | ".
211 "<input type='submit' name='action' value='Remove Selected'/>".
216 #-----------------------------------------------------------------------
218 #-----------------------------------------------------------------------
219 print "<form method='POST'>".
220 "<input type='hidden' name='rules_form' value='max_fine'>".
221 "<h2>Max Fine Levels</h2>".
222 "<table class='table_class'><tr class='header_class'>\n";
224 for my $col ( @max_fine_display_order ) {
225 print th($max_fine_cols{$col});
228 print "<td/></tr><tr class='row_class'>\n";
230 for my $row ( config::rules::max_fine->retrieve_all ) {
231 for my $col ( @max_fine_display_order ) {
232 print td($row->$col);
234 print "<td><input type='checkbox' value='$row' name='remove_me'</td>".
235 "</tr><tr class='row_class'>\n";
238 for my $col ( @max_fine_display_order ) {
239 print td("<input type='text' name='$col'>");
243 print "<td/></tr></table>".
244 "<input type='submit' name='action' value='Add New'/> | ".
245 "<input type='submit' name='action' value='Remove Selected'/>".
250 #-----------------------------------------------------------------------
251 # Age hold protect form
252 #-----------------------------------------------------------------------
253 print "<form method='POST'>".
254 "<input type='hidden' name='rules_form' value='age_hold'>".
255 "<h2>Item Age Hold Protection</h2>".
256 "<table class='table_class'><tr class='header_class'>\n";
258 for my $col ( @age_display_order ) {
259 print th($age_cols{$col});
262 print "<td/></tr><tr class='row_class'>\n";
264 for my $row ( config::rules::age_hold_protect->retrieve_all ) {
265 for my $col ( @age_display_order ) {
266 if ($col eq 'radius') {
267 print td($row->$col->name);
269 print td($row->$col);
272 print "<td><input type='checkbox' value='$row' name='remove_me'</td>".
273 "</tr><tr class='row_class'>\n";
276 for my $col ( @age_display_order ) {
277 if ($col eq 'radius') {
278 print "<td><select name='$col'>";
279 for my $radius ( actor::org_unit_type->retrieve_all ) {
280 print "<option value='".$radius->id."'>".
281 $radius->name."</option>";
283 print "</select></td>";
285 print td("<input type='text' name='$col'>");
290 print "<td/></tr></table>".
291 "<input type='submit' name='action' value='Add New'/> | ".
292 "<input type='submit' name='action' value='Remove Selected'/>".
297 print "</body></html>";