#!/usr/bin/perl 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

Organizational Unit Type Setup


HEADER #------------------------------------------------------------------------------- # setup part #------------------------------------------------------------------------------- my %ou_cols = ( qw/id SysID name Name opac_label OpacLabel depth Depth parent ParentType can_have_vols CanHaveVolumes can_have_users CanHaveUsers/ ); my @col_display_order = ( qw/id name opac_label depth parent can_have_vols can_have_users/ ); #------------------------------------------------------------------------------- # Logic part #------------------------------------------------------------------------------- if (my $action = $cgi->param('action')) { if ( $action eq 'Remove Selected' ) { for my $id ( ($cgi->param('id')) ) { actor::org_unit_type->retrieve($id)->delete; } } elsif ( $action eq 'Update Selected' ) { for my $id ( ($cgi->param('id')) ) { my $u = actor::org_unit_type->retrieve($id); for my $col (@col_display_order) { next if ($cgi->param($col."_$id") =~ /Select One/o); $u->$col( $cgi->param($col."_$id") ); } $u->update; } } elsif ( $action eq 'Add New' ) { actor::org_unit_type->create( { map {defined($cgi->param($_)) ? ($_ => $cgi->param($_)) : () } @col_display_order } ); } } #------------------------------------------------------------------------------- # Form part #------------------------------------------------------------------------------- { #----------------------------------------------------------------------- # User form #----------------------------------------------------------------------- print "
". "\n"; for my $col ( @col_display_order ) { print th($ou_cols{$col}); } print ''; for my $row ( sort { $a->depth <=> $b->depth } (actor::org_unit_type->retrieve_all) ) { print Tr( td( $row->id() ), td(""), td(""), td(""), td(""), td("can_have_vols){"checked"}} .">"), td("can_have_users){"checked"}} .">"), td(""), ); } print "", td(), td(""), td(""), td(""), td(""), td(""), td(""), td(), ""; print "
Action
"; print " | "; print " | "; print "

"; } print "";