adding circulation rule config stuff
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 25 Apr 2005 20:49:22 +0000 (20:49 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 25 Apr 2005 20:49:22 +0000 (20:49 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@562 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/cgi-bin/circ-rules.cgi [new file with mode: 0755]
Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/config.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm

diff --git a/Open-ILS/src/cgi-bin/circ-rules.cgi b/Open-ILS/src/cgi-bin/circ-rules.cgi
new file mode 100755 (executable)
index 0000000..8767244
--- /dev/null
@@ -0,0 +1,303 @@
+#!/usr/bin/perl -w
+use strict;
+
+use OpenILS::Application::Storage;
+use OpenILS::Application::Storage::CDBI;
+
+# I need to abstract the driver loading away...
+use OpenILS::Application::Storage::Driver::Pg;
+
+use CGI qw/:standard start_*/;
+
+OpenILS::Application::Storage::CDBI->connection('dbi:Pg:host=10.0.0.2;dbname=open-ils-dev', 'postgres');
+OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
+
+my $cgi = new CGI;
+
+#-------------------------------------------------------------------------------
+# HTML part
+#-------------------------------------------------------------------------------
+
+print <<HEADER;
+Content-type: text/html
+
+<html>
+
+<head>
+       <style>
+               table.table_class {
+                       border: dashed lightgrey 1px;
+                       background-color: #EEE;
+                       border-collapse: collapse;
+               }
+
+               tr.row_class td {
+                       text-align: right;
+                       border: solid lightgrey 1px;
+               }
+               
+               tr.header_class th {
+                       background-color: lightblue;
+               }
+
+       </style>
+<body style='padding: 25px;'>
+
+<h1>Configure Circulation Rules</h1>
+<hr/>
+
+HEADER
+
+#-------------------------------------------------------------------------------
+# setup part
+#-------------------------------------------------------------------------------
+
+my %dur_cols = (
+       name            => "Name",
+       extended        => "Extended",
+       normal          => "Normal",
+       short           => "Short",
+       max_renewals    => "Max Renewals",
+);
+
+my @dur_display_order = ( qw/name normal extended short max_renewals/ );
+
+my %fine_cols = (
+       name                    => "Name",
+       high                    => "High",
+       normal                  => "Normal",
+       low                     => "Low",
+       recurance_interval      => "Interval",
+);
+
+my @fine_display_order = ( qw/name recurance_interval normal high low/ );
+
+my %age_cols = (
+       name    => "Name",
+       age     => "Item Age",
+       radius  => "Holdable Radius",
+);
+
+my @age_display_order = ( qw/name age radius/ );
+
+my %max_fine_cols = (
+       name    => "Name",
+       amount  => "Amount",
+);
+
+my @max_fine_display_order = ( qw/name amount/ );
+
+
+#-------------------------------------------------------------------------------
+# Logic part
+#-------------------------------------------------------------------------------
+
+if (my $action = $cgi->param('action')) {
+       my $form = $cgi->param('rules_form');
+
+       if ($form eq 'duration') {
+               if ($action eq 'Remove Selected') {
+                       for my $id ( ($cgi->param('remove_me')) ) {
+                               warn "========>>>  Deleteing $id\n";
+                               config::rules::circ_duration->retrieve($id)->delete;
+                       }
+               } elsif ( $action eq 'Add New' ) {
+                       config::rules::circ_duration->create(
+                               { map { ($_ => $cgi->param($_)) } keys %dur_cols }
+                       );
+               }
+       } elsif ($form eq 'recuring_fine') {
+               if ($action eq 'Remove Selected') {
+                       for my $id ( ($cgi->param('remove_me')) ) {
+                               warn "========>>>  Deleteing $id\n";
+                               config::rules::recuring_fine->retrieve($id)->delete;
+                       }
+               } elsif ( $action eq 'Add New' ) {
+                       config::rules::recuring_fine->create(
+                               { map { ($_ => $cgi->param($_)) } keys %fine_cols }
+                       );
+               }
+       } elsif ($form eq 'max_fine') {
+               if ($action eq 'Remove Selected') {
+                       for my $id ( ($cgi->param('remove_me')) ) {
+                               warn "========>>>  Deleteing $id\n";
+                               config::rules::max_fine->retrieve($id)->delete;
+                       }
+               } elsif ( $action eq 'Add New' ) {
+                       config::rules::max_fine->create(
+                               { map { ($_ => $cgi->param($_)) } keys %max_fine_cols }
+                       );
+               }
+       } elsif ($form eq 'age_hold') {
+               if ($action eq 'Remove Selected') {
+                       for my $id ( ($cgi->param('remove_me')) ) {
+                               warn "========>>>  Deleteing $id\n";
+                               config::rules::age_hold_protect->retrieve($id)->delete;
+                       }
+               } elsif ( $action eq 'Add New' ) {
+                       config::rules::age_hold_protect->create(
+                               { map { ($_ => $cgi->param($_)) } keys %age_cols }
+                       );
+               }
+       }
+
+
+}
+
+
+#-------------------------------------------------------------------------------
+# Form part
+#-------------------------------------------------------------------------------
+{
+       #-----------------------------------------------------------------------
+       # Duration form
+       #-----------------------------------------------------------------------
+       print   "<form method='POST'>".
+               "<input type='hidden' name='rules_form' value='duration'>".
+               "<h2>Circulation Duration</h2>".
+               "<table class='table_class'><tr class='header_class'>\n";
+       
+       for my $col ( @dur_display_order ) {
+               print th($dur_cols{$col});
+       }
+       
+       print "<td/></tr><tr class='row_class'>\n";
+       
+       for my $row ( config::rules::circ_duration->retrieve_all ) {
+               for my $col ( @dur_display_order ) {
+                       print td($row->$col);
+               }
+               print   "<td><input type='checkbox' value='$row' name='remove_me'</td>".
+                       "</tr><tr class='row_class'>\n";
+       }
+       
+       for my $col ( @dur_display_order ) {
+               print td("<input type='text' name='$col'>");
+       }
+       
+       
+       print   "<td/></tr></table>".
+               "<input type='submit' name='action' value='Add New'/> | ".
+               "<input type='submit' name='action' value='Remove Selected'/>".
+               "</form><hr/>";
+}
+
+{
+       #-----------------------------------------------------------------------
+       # Recuring Fine form
+       #-----------------------------------------------------------------------
+       print   "<form method='POST'>".
+               "<input type='hidden' name='rules_form' value='recuring_fine'>".
+               "<h2>Recuring Fine Levels</h2>".
+               "<table class='table_class'><tr class='header_class'>\n";
+       
+       for my $col ( @fine_display_order ) {
+               print th($fine_cols{$col});
+       }
+       
+       print "<td/></tr><tr class='row_class'>\n";
+       
+       for my $row ( config::rules::recuring_fine->retrieve_all ) {
+               for my $col ( @fine_display_order ) {
+                       print td($row->$col);
+               }
+               print   "<td><input type='checkbox' value='$row' name='remove_me'</td>".
+                       "</tr><tr class='row_class'>\n";
+       }
+       
+       for my $col ( @fine_display_order ) {
+               print td("<input type='text' name='$col'>");
+       }
+       
+       
+       print   "<td/></tr></table>".
+               "<input type='submit' name='action' value='Add New'/> | ".
+               "<input type='submit' name='action' value='Remove Selected'/>".
+               "</form><hr/>";
+}
+
+{
+       #-----------------------------------------------------------------------
+       # Max Fine form
+       #-----------------------------------------------------------------------
+       print   "<form method='POST'>".
+               "<input type='hidden' name='rules_form' value='max_fine'>".
+               "<h2>Max Fine Levels</h2>".
+               "<table class='table_class'><tr class='header_class'>\n";
+       
+       for my $col ( @max_fine_display_order ) {
+               print th($max_fine_cols{$col});
+       }
+       
+       print "<td/></tr><tr class='row_class'>\n";
+       
+       for my $row ( config::rules::max_fine->retrieve_all ) {
+               for my $col ( @max_fine_display_order ) {
+                       print td($row->$col);
+               }
+               print   "<td><input type='checkbox' value='$row' name='remove_me'</td>".
+                       "</tr><tr class='row_class'>\n";
+       }
+       
+       for my $col ( @max_fine_display_order ) {
+               print td("<input type='text' name='$col'>");
+       }
+       
+       
+       print   "<td/></tr></table>".
+               "<input type='submit' name='action' value='Add New'/> | ".
+               "<input type='submit' name='action' value='Remove Selected'/>".
+               "</form><hr/>";
+}
+
+{
+       #-----------------------------------------------------------------------
+       # Age hold protect form
+       #-----------------------------------------------------------------------
+       print   "<form method='POST'>".
+               "<input type='hidden' name='rules_form' value='age_hold'>".
+               "<h2>Item Age Hold Protection</h2>".
+               "<table class='table_class'><tr class='header_class'>\n";
+       
+       for my $col ( @age_display_order ) {
+               print th($age_cols{$col});
+       }
+       
+       print "<td/></tr><tr class='row_class'>\n";
+       
+       for my $row ( config::rules::age_hold_protect->retrieve_all ) {
+               for my $col ( @age_display_order ) {
+                       if ($col eq 'radius') {
+                               print td($row->$col->name);
+                       } else {
+                               print td($row->$col);
+                       }
+               }
+               print   "<td><input type='checkbox' value='$row' name='remove_me'</td>".
+                       "</tr><tr class='row_class'>\n";
+       }
+       
+       for my $col ( @age_display_order ) {
+               if ($col eq 'radius') {
+                       print "<td><select name='$col'>";
+                       for my $radius ( actor::org_unit_type->retrieve_all ) {
+                               print   "<option value='".$radius->id."'>".
+                                       $radius->name."</option>";
+                       }
+                       print "</select></td>";
+               } else {
+                       print td("<input type='text' name='$col'>");
+               }
+       }
+       
+       
+       print   "<td/></tr></table>".
+               "<input type='submit' name='action' value='Add New'/> | ".
+               "<input type='submit' name='action' value='Remove Selected'/>".
+               "</form><hr/>";
+}
+
+
+print "</body></html>";
+
+
index 75a4f4e..53d91b7 100644 (file)
@@ -287,6 +287,8 @@ sub modify_from_fieldmapper {
        
        actor::card->has_a( usr => 'actor::user' );
        
+       config::rules::age_hold_protect->has_a( radius => 'actor::org_unit_type' );
+       
        actor::org_unit->has_a( parent_ou => 'actor::org_unit' );
        actor::org_unit->has_a( ou_type => 'actor::org_unit_type' );
        #actor::org_unit->has_a( address => 'actor::org_address' );
index 6282500..1f9b638 100644 (file)
@@ -52,7 +52,7 @@ package config::rules::recuring_fine;
 use base qw/config/;
 __PACKAGE__->table('config_rule_recuring_fine');
 __PACKAGE__->columns(Primary => 'id');
-__PACKAGE__->columns(Essential => qw/name high normal low/);
+__PACKAGE__->columns(Essential => qw/name high normal low recurance_interval/);
 #-------------------------------------------------------------------------------
 
 package config::rules::age_hold_protect;
index 533d13e..95c7f83 100644 (file)
        
        config::standing->table( 'config.copy_status' );
        config::standing->sequence( 'config.copy_status_id_seq' );
+
+       #---------------------------------------------------------------------
+       package config::rules::circ_duration;
+       
+       config::rules::circ_duration->table( 'config.rule_circ_duration' );
+       config::rules::circ_duration->sequence( 'config.rule_circ_duration_id_seq' );
+       
+       #---------------------------------------------------------------------
+       package config::rules::age_hold_protect;
+       
+       config::rules::age_hold_protect->table( 'config.rule_age_hold_protect' );
+       config::rules::age_hold_protect->sequence( 'config.rule_age_hold_protect_id_seq' );
+       
+       #---------------------------------------------------------------------
+       package config::rules::max_fine;
+       
+       config::rules::max_fine->table( 'config.rule_max_fine' );
+       config::rules::max_fine->sequence( 'config.rule_max_fine_id_seq' );
+       
+       #---------------------------------------------------------------------
+       package config::rules::recuring_fine;
+       
+       config::rules::recuring_fine->table( 'config.rule_recuring_fine' );
+       config::rules::recuring_fine->sequence( 'config.rule_recuring_fine_id_seq' );
        
        #---------------------------------------------------------------------
        package config::net_access_level;