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_*/;
13 do '##CONFIG##/live-db-setup.pl';
15 OpenILS::Application::Storage::CDBI->connection($config{dsn},$config{usr},$config{pw});
16 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
20 #-------------------------------------------------------------------------------
22 #-------------------------------------------------------------------------------
25 Content-type: text/html
30 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
31 <meta http-equiv="Pragma" content="no-cache" />
32 <meta http-equiv="Expires" content="Thu, 01 Dec 2000 16:00:00 GMT" />
35 border: dashed lightgrey 1px;
36 background-color: #EEE;
37 border-collapse: collapse;
45 border: solid lightgrey 1px;
53 background-color: lightblue;
54 border: solid blue 1px;
59 <body style='padding: 25px;'>
61 <a href="$config{index}">Home</a>
63 <h1>Copy Status Setup</h1>
68 #-------------------------------------------------------------------------------
70 #-------------------------------------------------------------------------------
72 my %cs_cols = ( qw/id SysID name Name holdable Unholdable/ );
74 my @col_display_order = ( qw/id name holdable/ );
76 #-------------------------------------------------------------------------------
78 #-------------------------------------------------------------------------------
80 if (my $action = $cgi->param('action')) {
81 if ( $action eq 'Remove Selected' ) {
82 for my $id ( ($cgi->param('id')) ) {
83 next unless ($id > 99);
84 config::copy_status->retrieve($id)->delete;
86 } elsif ( $action eq 'Update Selected' ) {
87 for my $id ( ($cgi->param('id')) ) {
88 my $u = config::copy_status->retrieve($id);
89 $u->name( $cgi->param("name_$id") );
90 $u->holdable( $cgi->param("holdable_$id") );
93 } elsif ( $action eq 'Add New' ) {
94 config::copy_status->create( { name => $cgi->param("name") } );
99 #-------------------------------------------------------------------------------
101 #-------------------------------------------------------------------------------
103 #-----------------------------------------------------------------------
105 #-----------------------------------------------------------------------
106 print "<form method='POST'>".
107 "<table class='table_class'><tr class='header_class'>\n";
109 for my $col ( @col_display_order ) {
110 print th($cs_cols{$col});
113 print '<th>Action</th></tr>';
115 for my $row ( sort { $a->name cmp $b->name } (config::copy_status->retrieve_all) ) {
118 td("<input type='text' name='name_$row' value='". $row->name() ."'>"),
119 td("<input type='checkbox' name='holdable_$row' value='f'". do {'checked' unless $row->holdable()} .">"),
120 td("<input type='checkbox' value='$row' name='id'>"),
124 print "<tr class='new_row_class'>",
126 td("<input type='text' name='name'>"),
127 td("<input type='checkbox' name='holdable' value='f'>"),
132 print "<input type='submit' name='action' value='Remove Selected'/> | ";
133 print "<input type='submit' name='action' value='Update Selected'/> | ";
134 print "<input type='submit' name='action' value='Add New'/></form><hr/>";
137 print "</body></html>";