From 27210969139c296dfcbd766ccfd3b76af0a6c1f5 Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 25 Apr 2005 20:49:22 +0000 Subject: [PATCH] adding circulation rule config stuff git-svn-id: svn://svn.open-ils.org/ILS/trunk@562 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/cgi-bin/circ-rules.cgi | 303 ++++++++++++++++++ .../OpenILS/Application/Storage/CDBI.pm | 2 + .../Application/Storage/CDBI/config.pm | 2 +- .../Application/Storage/Driver/Pg/dbi.pm | 24 ++ 4 files changed, 330 insertions(+), 1 deletion(-) create mode 100755 Open-ILS/src/cgi-bin/circ-rules.cgi diff --git a/Open-ILS/src/cgi-bin/circ-rules.cgi b/Open-ILS/src/cgi-bin/circ-rules.cgi new file mode 100755 index 0000000000..876724476d --- /dev/null +++ b/Open-ILS/src/cgi-bin/circ-rules.cgi @@ -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 < + + + + + +

Configure Circulation Rules

+
+ +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 "
". + "". + "

Circulation Duration

". + "\n"; + + for my $col ( @dur_display_order ) { + print th($dur_cols{$col}); + } + + print "\n"; + + for my $row ( config::rules::circ_duration->retrieve_all ) { + for my $col ( @dur_display_order ) { + print td($row->$col); + } + print "\n"; + } + + for my $col ( @dur_display_order ) { + print td(""); + } + + + print "
". + "
". + " | ". + "". + "

"; +} + +{ + #----------------------------------------------------------------------- + # Recuring Fine form + #----------------------------------------------------------------------- + print "
". + "". + "

Recuring Fine Levels

". + "\n"; + + for my $col ( @fine_display_order ) { + print th($fine_cols{$col}); + } + + print "\n"; + + for my $row ( config::rules::recuring_fine->retrieve_all ) { + for my $col ( @fine_display_order ) { + print td($row->$col); + } + print "\n"; + } + + for my $col ( @fine_display_order ) { + print td(""); + } + + + print "
". + "
". + " | ". + "". + "

"; +} + +{ + #----------------------------------------------------------------------- + # Max Fine form + #----------------------------------------------------------------------- + print "
". + "". + "

Max Fine Levels

". + "\n"; + + for my $col ( @max_fine_display_order ) { + print th($max_fine_cols{$col}); + } + + print "\n"; + + for my $row ( config::rules::max_fine->retrieve_all ) { + for my $col ( @max_fine_display_order ) { + print td($row->$col); + } + print "\n"; + } + + for my $col ( @max_fine_display_order ) { + print td(""); + } + + + print "
". + "
". + " | ". + "". + "

"; +} + +{ + #----------------------------------------------------------------------- + # Age hold protect form + #----------------------------------------------------------------------- + print "
". + "". + "

Item Age Hold Protection

". + "\n"; + + for my $col ( @age_display_order ) { + print th($age_cols{$col}); + } + + print "\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 "\n"; + } + + for my $col ( @age_display_order ) { + if ($col eq 'radius') { + print ""; + } else { + print td(""); + } + } + + + print "
". + "
". + " | ". + "". + "

"; +} + + +print ""; + + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm index 75a4f4e01b..53d91b712e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm @@ -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' ); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/config.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/config.pm index 62825007e3..1f9b63831e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/config.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/config.pm @@ -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; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm index 533d13ef0e..95c7f833d9 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm @@ -28,6 +28,30 @@ 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; -- 2.43.2