5 use OpenILS::Application::Storage;
6 use OpenILS::Application::Storage::CDBI;
8 # I need to abstract the driver loading away...
9 use OpenILS::Application::Storage::Driver::Pg;
11 use CGI qw/:standard start_*/;
14 do '##CONFIG##/live-db-setup.pl';
16 OpenILS::Application::Storage::CDBI->connection($config{dsn},$config{usr},$config{pw});
17 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
21 #-------------------------------------------------------------------------------
23 #-------------------------------------------------------------------------------
26 Content-type: text/html
31 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
32 <meta http-equiv="Pragma" content="no-cache" />
33 <meta http-equiv="Expires" content="Thu, 01 Dec 2000 16:00:00 GMT" />
36 border: dashed lightgrey 1px;
37 background-color: #EEE;
38 border-collapse: collapse;
46 border: solid lightgrey 1px;
54 background-color: lightblue;
55 border: solid blue 1px;
60 <body style='padding: 25px;'>
62 <a href="$config{index}">Home</a>
64 <h1>Organizational Unit Type Setup</h1>
69 #-------------------------------------------------------------------------------
71 #-------------------------------------------------------------------------------
73 my %ou_cols = ( qw/id SysID name Name opac_label OpacLabel depth Depth parent ParentType can_have_vols CanHaveVolumes can_have_users CanHaveUsers/ );
75 my @col_display_order = ( qw/id name opac_label depth parent can_have_vols can_have_users/ );
77 #-------------------------------------------------------------------------------
79 #-------------------------------------------------------------------------------
81 if (my $action = $cgi->param('action')) {
82 if ( $action eq 'Remove Selected' ) {
83 for my $id ( ($cgi->param('id')) ) {
84 actor::org_unit_type->retrieve($id)->delete;
86 } elsif ( $action eq 'Update Selected' ) {
87 for my $id ( ($cgi->param('id')) ) {
88 my $u = actor::org_unit_type->retrieve($id);
89 for my $col (@col_display_order) {
90 next if ($cgi->param($col."_$id") =~ /Select One/o);
91 $u->$col( $cgi->param($col."_$id") );
95 } elsif ( $action eq 'Add New' ) {
96 actor::org_unit_type->create( { map {defined($cgi->param($_)) ? ($_ => $cgi->param($_)) : () } @col_display_order } );
101 #-------------------------------------------------------------------------------
103 #-------------------------------------------------------------------------------
105 #-----------------------------------------------------------------------
107 #-----------------------------------------------------------------------
108 print "<form method='POST'>".
109 "<table class='table_class'><tr class='header_class'>\n";
111 for my $col ( @col_display_order ) {
112 print th($ou_cols{$col});
115 print '<th>Action</th></tr>';
117 for my $row ( sort { $a->depth <=> $b->depth } (actor::org_unit_type->retrieve_all) ) {
120 td("<input type='text' name='name_$row' value='". $row->name() ."'>"),
121 td("<input type='text' name='opac_label_$row' value='". $row->opac_label() ."'>"),
122 td("<input type='text' size=3 name='depth_$row' value='". $row->depth() ."'>"),
123 td("<select name='parent_$row'><option>-- Select One --</option>".do{
125 for my $type ( sort {$a->depth <=> $b->depth} actor::org_unit_type->retrieve_all) {
126 $out .= "<option value='$type' ".do{
127 if ($row->parent == $type->id) {
130 }.">".$type->name.'</option>'
134 td("<input type='checkbox' name='can_have_vols_$row' value='t' ". do{if($row->can_have_vols){"checked"}} .">"),
135 td("<input type='checkbox' name='can_have_users_$row' value='t' ". do{if($row->can_have_users){"checked"}} .">"),
136 td("<input type='checkbox' value='$row' name='id'>"),
140 print "<tr class='new_row_class'>",
142 td("<input type='text' name='name'>"),
143 td("<input type='text' name='opac_label'>"),
144 td("<input type='text' size=3 name='depth'>"),
145 td("<select name='parent'><option>-- Select One --</option>".do{
147 for my $type ( sort {$a->depth <=> $b->depth} actor::org_unit_type->retrieve_all) {
148 $out .= "<option value='$type'>".$type->name.'</option>'
152 td("<input type='checkbox' name='can_have_vols' value='t'>"),
153 td("<input type='checkbox' name='can_have_users' value='t'>"),
157 print "<input type='submit' name='action' value='Remove Selected'/> | ";
158 print "<input type='submit' name='action' value='Update Selected'/> | ";
159 print "<input type='submit' name='action' value='Add New'/></form><hr/>";
162 print "</body></html>";