4 use OpenILS::Application::Storage;
5 use OpenILS::Application::Storage::CDBI;
7 # I need to abstract the driver loading away...
8 use OpenILS::Application::Storage::Driver::Pg;
10 use CGI qw/:standard start_*/;
12 do '##CONFIG##/live-db-setup.pl';
14 OpenILS::Application::Storage::CDBI->connection($config{dsn},$config{usr},$config{pw});
15 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
19 #-------------------------------------------------------------------------------
21 #-------------------------------------------------------------------------------
24 Content-type: text/html
31 border: dashed lightgrey 1px;
32 background-color: #EEE;
33 border-collapse: collapse;
41 border: solid lightgrey 1px;
49 background-color: lightblue;
50 border: solid blue 1px;
55 <body style='padding: 25px;'>
57 <a href="$config{index}">Home</a>
59 <h1>Copy Status Setup</h1>
64 #-------------------------------------------------------------------------------
66 #-------------------------------------------------------------------------------
68 my %cs_cols = ( qw/id SysID name Name holdable Unholdable/ );
70 my @col_display_order = ( qw/id name holdable/ );
72 #-------------------------------------------------------------------------------
74 #-------------------------------------------------------------------------------
76 if (my $action = $cgi->param('action')) {
77 if ( $action eq 'Remove Selected' ) {
78 for my $id ( ($cgi->param('id')) ) {
79 next unless ($id > 99);
80 config::copy_status->retrieve($id)->delete;
82 } elsif ( $action eq 'Update Selected' ) {
83 for my $id ( ($cgi->param('id')) ) {
84 my $u = config::copy_status->retrieve($id);
85 $u->name( $cgi->param("name_$id") );
86 $u->holdable( $cgi->param("holdable_$id") );
89 } elsif ( $action eq 'Add New' ) {
90 config::copy_status->create( { name => $cgi->param("name") } );
95 #-------------------------------------------------------------------------------
97 #-------------------------------------------------------------------------------
99 #-----------------------------------------------------------------------
101 #-----------------------------------------------------------------------
102 print "<form method='POST'>".
103 "<table class='table_class'><tr class='header_class'>\n";
105 for my $col ( @col_display_order ) {
106 print th($cs_cols{$col});
109 print '<th>Action</th></tr>';
111 for my $row ( sort { $a->name cmp $b->name } (config::copy_status->retrieve_all) ) {
114 td("<input type='text' name='name_$row' value='". $row->name() ."'>"),
115 td("<input type='checkbox' name='holdable_$row' value='f'". do {'checked' unless $row->holdable()} .">"),
116 td("<input type='checkbox' value='$row' name='id'>"),
120 print "<tr class='new_row_class'>",
122 td("<input type='text' name='name'>"),
123 td("<input type='checkbox' name='holdable' value='f'>"),
128 print "<input type='submit' name='action' value='Remove Selected'/> | ";
129 print "<input type='submit' name='action' value='Update Selected'/> | ";
130 print "<input type='submit' name='action' value='Add New'/></form><hr/>";
133 print "</body></html>";