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
29 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
32 border: dashed lightgrey 1px;
33 background-color: #EEE;
34 border-collapse: collapse;
42 border: solid lightgrey 1px;
50 background-color: lightblue;
51 border: solid blue 1px;
56 <body style='padding: 25px;'>
58 <a href="$config{index}">Home</a>
60 <h1>Copy Status Setup</h1>
65 #-------------------------------------------------------------------------------
67 #-------------------------------------------------------------------------------
69 my %cs_cols = ( qw/id SysID name Name holdable Unholdable/ );
71 my @col_display_order = ( qw/id name holdable/ );
73 #-------------------------------------------------------------------------------
75 #-------------------------------------------------------------------------------
77 if (my $action = $cgi->param('action')) {
78 if ( $action eq 'Remove Selected' ) {
79 for my $id ( ($cgi->param('id')) ) {
80 next unless ($id > 99);
81 config::copy_status->retrieve($id)->delete;
83 } elsif ( $action eq 'Update Selected' ) {
84 for my $id ( ($cgi->param('id')) ) {
85 my $u = config::copy_status->retrieve($id);
86 $u->name( $cgi->param("name_$id") );
87 $u->holdable( $cgi->param("holdable_$id") );
90 } elsif ( $action eq 'Add New' ) {
91 config::copy_status->create( { name => $cgi->param("name") } );
96 #-------------------------------------------------------------------------------
98 #-------------------------------------------------------------------------------
100 #-----------------------------------------------------------------------
102 #-----------------------------------------------------------------------
103 print "<form method='POST'>".
104 "<table class='table_class'><tr class='header_class'>\n";
106 for my $col ( @col_display_order ) {
107 print th($cs_cols{$col});
110 print '<th>Action</th></tr>';
112 for my $row ( sort { $a->name cmp $b->name } (config::copy_status->retrieve_all) ) {
115 td("<input type='text' name='name_$row' value='". $row->name() ."'>"),
116 td("<input type='checkbox' name='holdable_$row' value='f'". do {'checked' unless $row->holdable()} .">"),
117 td("<input type='checkbox' value='$row' name='id'>"),
121 print "<tr class='new_row_class'>",
123 td("<input type='text' name='name'>"),
124 td("<input type='checkbox' name='holdable' value='f'>"),
129 print "<input type='submit' name='action' value='Remove Selected'/> | ";
130 print "<input type='submit' name='action' value='Update Selected'/> | ";
131 print "<input type='submit' name='action' value='Add New'/></form><hr/>";
134 print "</body></html>";