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 OpenILS::Application::Storage::CDBI->connection('dbi:Pg:host=10.0.0.2;dbname=demo-dev', 'postgres');
13 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
17 #-------------------------------------------------------------------------------
19 #-------------------------------------------------------------------------------
22 Content-type: text/html
29 border: dashed lightgrey 1px;
30 background-color: #EEE;
31 border-collapse: collapse;
39 border: solid lightgrey 1px;
47 background-color: lightblue;
48 border: solid blue 1px;
53 <body style='padding: 25px;'>
55 <h1>Copy Status Setup</h1>
60 #-------------------------------------------------------------------------------
62 #-------------------------------------------------------------------------------
64 my %cs_cols = ( qw/id SysID name Name/ );
66 my @col_display_order = ( qw/id name/ );
68 #-------------------------------------------------------------------------------
70 #-------------------------------------------------------------------------------
72 if (my $action = $cgi->param('action')) {
73 if ( $action eq 'Remove Selected' ) {
74 for my $id ( ($cgi->param('id')) ) {
75 next unless ($id > 99);
76 config::copy_status->retrieve($id)->delete;
78 } elsif ( $action eq 'Update Selected' ) {
79 for my $id ( ($cgi->param('id')) ) {
80 my $u = config::copy_status->retrieve($id);
81 $u->name( $cgi->param("name_$id") );
84 } elsif ( $action eq 'Add New' ) {
85 config::copy_status->create( { name => $cgi->param("name") } );
90 #-------------------------------------------------------------------------------
92 #-------------------------------------------------------------------------------
94 #-----------------------------------------------------------------------
96 #-----------------------------------------------------------------------
97 print "<form method='POST'>".
98 "<table class='table_class'><tr class='header_class'>\n";
100 for my $col ( @col_display_order ) {
101 print th($cs_cols{$col});
104 print '<th>Action</th></tr>';
106 for my $row ( sort { $a->name cmp $b->name } (config::copy_status->retrieve_all) ) {
109 td("<input type='text' name='name_$row' value='". $row->name() ."'>"),
110 td("<input type='checkbox' value='$row' name='id'>"),
114 print "<tr class='new_row_class'>",
116 td("<input type='text' name='name'>"),
121 print "<input type='submit' name='action' value='Remove Selected'/> | ";
122 print "<input type='submit' name='action' value='Update Selected'/> | ";
123 print "<input type='submit' name='action' value='Add New'/></form><hr/>";
126 print "</body></html>";