#!/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_*/; our %config; do '##CONFIG##/live-db-setup.pl'; OpenILS::Application::Storage::CDBI->connection($config{dsn},$config{usr},$config{pw}); OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1; my $cgi = new CGI; #------------------------------------------------------------------------------- # HTML part #------------------------------------------------------------------------------- print < Home

Configure Circulation Rules


HEADER #------------------------------------------------------------------------------- # setup part #------------------------------------------------------------------------------- my %dur_cols = ( name => "Name", extended => "Extended", normal => "Normal", shrt => "Short", max_renewals => "Max Renewals", ); my @dur_display_order = ( qw/name normal extended shrt 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", prox => "Holdable Radius", ); my @age_display_order = ( qw/name age prox/ ); 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')) ) { 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')) ) { 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')) ) { 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')) ) { 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 ""; for my $col ( @dur_display_order ) { print td($row->$col); } print "\n"; for my $col ( @dur_display_order ) { print td(""); } print "
\n"; for my $row ( config::rules::circ_duration->retrieve_all ) { print "
"; } print "
". " | ". "". "

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

Recuring Fine Levels

". "\n"; for my $col ( @fine_display_order ) { print th($fine_cols{$col}); } print "\n"; for my $col ( @fine_display_order ) { print td($row->$col); } print "\n"; for my $col ( @fine_display_order ) { print td(""); } print "
\n"; for my $row ( config::rules::recuring_fine->retrieve_all ) { print "
"; } 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 $col ( @max_fine_display_order ) { print td($row->$col); } print "\n"; for my $col ( @max_fine_display_order ) { print td(""); } print "
\n"; for my $row ( config::rules::max_fine->retrieve_all ) { print "
"; } 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 $col ( @age_display_order ) { print td($row->$col); } print "\n"; for my $col ( @age_display_order ) { print td(""); } print "
\n"; for my $row ( config::rules::age_hold_protect->retrieve_all ) { print "
"; } print "
". " | ". "". "

"; } print "";