#!/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_*/; 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 <

Organizational Unit Type Setup


HEADER #------------------------------------------------------------------------------- # setup part #------------------------------------------------------------------------------- my %ou_cols = ( qw/id SysID name Name depth Depth parent ParentType can_have_vols CanHaveVolumes can_have_users CanHaveUsers/ ); my @col_display_order = ( qw/id name 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) { $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("can_have_vols){"checked"}} .">"), td("can_have_users){"checked"}} .">"), td(""), ); } print Tr( td(), td(""), td(""), td(""), td(""), td(""), td(), ); print "
Action
"; print " | "; print " | "; print "

"; } print "";