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 short 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 warn "========>>> Deleteing $id\n";
102 config::rules::circ_duration->retrieve($id)->delete;
104 } elsif ( $action eq 'Add New' ) {
105 config::rules::circ_duration->create(
106 { map { ($_ => $cgi->param($_)) } keys %dur_cols }
109 } elsif ($form eq 'recuring_fine') {
110 if ($action eq 'Remove Selected') {
111 for my $id ( ($cgi->param('remove_me')) ) {
112 warn "========>>> Deleteing $id\n";
113 config::rules::recuring_fine->retrieve($id)->delete;
115 } elsif ( $action eq 'Add New' ) {
116 config::rules::recuring_fine->create(
117 { map { ($_ => $cgi->param($_)) } keys %fine_cols }
120 } elsif ($form eq 'max_fine') {
121 if ($action eq 'Remove Selected') {
122 for my $id ( ($cgi->param('remove_me')) ) {
123 warn "========>>> Deleteing $id\n";
124 config::rules::max_fine->retrieve($id)->delete;
126 } elsif ( $action eq 'Add New' ) {
127 config::rules::max_fine->create(
128 { map { ($_ => $cgi->param($_)) } keys %max_fine_cols }
131 } elsif ($form eq 'age_hold') {
132 if ($action eq 'Remove Selected') {
133 for my $id ( ($cgi->param('remove_me')) ) {
134 warn "========>>> Deleteing $id\n";
135 config::rules::age_hold_protect->retrieve($id)->delete;
137 } elsif ( $action eq 'Add New' ) {
138 config::rules::age_hold_protect->create(
139 { map { ($_ => $cgi->param($_)) } keys %age_cols }
148 #-------------------------------------------------------------------------------
150 #-------------------------------------------------------------------------------
152 #-----------------------------------------------------------------------
154 #-----------------------------------------------------------------------
155 print "<form method='POST'>".
156 "<input type='hidden' name='rules_form' value='duration'>".
157 "<h2>Circulation Duration</h2>".
158 "<table class='table_class'><tr class='header_class'>\n";
160 for my $col ( @dur_display_order ) {
161 print th($dur_cols{$col});
164 print "<td/></tr><tr class='row_class'>\n";
166 for my $row ( config::rules::circ_duration->retrieve_all ) {
167 for my $col ( @dur_display_order ) {
168 print td($row->$col);
170 print "<td><input type='checkbox' value='$row' name='remove_me'</td>".
171 "</tr><tr class='row_class'>\n";
174 for my $col ( @dur_display_order ) {
175 print td("<input type='text' name='$col'>");
179 print "<td/></tr></table>".
180 "<input type='submit' name='action' value='Add New'/> | ".
181 "<input type='submit' name='action' value='Remove Selected'/>".
186 #-----------------------------------------------------------------------
188 #-----------------------------------------------------------------------
189 print "<form method='POST'>".
190 "<input type='hidden' name='rules_form' value='recuring_fine'>".
191 "<h2>Recuring Fine Levels</h2>".
192 "<table class='table_class'><tr class='header_class'>\n";
194 for my $col ( @fine_display_order ) {
195 print th($fine_cols{$col});
198 print "<td/></tr><tr class='row_class'>\n";
200 for my $row ( config::rules::recuring_fine->retrieve_all ) {
201 for my $col ( @fine_display_order ) {
202 print td($row->$col);
204 print "<td><input type='checkbox' value='$row' name='remove_me'</td>".
205 "</tr><tr class='row_class'>\n";
208 for my $col ( @fine_display_order ) {
209 print td("<input type='text' name='$col'>");
213 print "<td/></tr></table>".
214 "<input type='submit' name='action' value='Add New'/> | ".
215 "<input type='submit' name='action' value='Remove Selected'/>".
220 #-----------------------------------------------------------------------
222 #-----------------------------------------------------------------------
223 print "<form method='POST'>".
224 "<input type='hidden' name='rules_form' value='max_fine'>".
225 "<h2>Max Fine Levels</h2>".
226 "<table class='table_class'><tr class='header_class'>\n";
228 for my $col ( @max_fine_display_order ) {
229 print th($max_fine_cols{$col});
232 print "<td/></tr><tr class='row_class'>\n";
234 for my $row ( config::rules::max_fine->retrieve_all ) {
235 for my $col ( @max_fine_display_order ) {
236 print td($row->$col);
238 print "<td><input type='checkbox' value='$row' name='remove_me'</td>".
239 "</tr><tr class='row_class'>\n";
242 for my $col ( @max_fine_display_order ) {
243 print td("<input type='text' name='$col'>");
247 print "<td/></tr></table>".
248 "<input type='submit' name='action' value='Add New'/> | ".
249 "<input type='submit' name='action' value='Remove Selected'/>".
254 #-----------------------------------------------------------------------
255 # Age hold protect form
256 #-----------------------------------------------------------------------
257 print "<form method='POST'>".
258 "<input type='hidden' name='rules_form' value='age_hold'>".
259 "<h2>Item Age Hold Protection</h2>".
260 "<table class='table_class'><tr class='header_class'>\n";
262 for my $col ( @age_display_order ) {
263 print th($age_cols{$col});
266 print "<td/></tr><tr class='row_class'>\n";
268 for my $row ( config::rules::age_hold_protect->retrieve_all ) {
269 for my $col ( @age_display_order ) {
270 if ($col eq 'radius') {
271 print td($row->$col->name);
273 print td($row->$col);
276 print "<td><input type='checkbox' value='$row' name='remove_me'</td>".
277 "</tr><tr class='row_class'>\n";
280 for my $col ( @age_display_order ) {
281 if ($col eq 'radius') {
282 print "<td><select name='$col'>";
283 for my $radius ( actor::org_unit_type->retrieve_all ) {
284 print "<option value='".$radius->id."'>".
285 $radius->name."</option>";
287 print "</select></td>";
289 print td("<input type='text' name='$col'>");
294 print "<td/></tr></table>".
295 "<input type='submit' name='action' value='Add New'/> | ".
296 "<input type='submit' name='action' value='Remove Selected'/>".
301 print "</body></html>";