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_*/;
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
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>Permission List Setup</h1>
65 #-------------------------------------------------------------------------------
67 #-------------------------------------------------------------------------------
69 my %profile_cols = ( qw/id SysID code Name/ );
71 my @col_display_order = ( qw/id cod3/ );
73 #-------------------------------------------------------------------------------
75 #-------------------------------------------------------------------------------
77 if (my $action = $cgi->param('action')) {
78 if ( $action eq 'Remove Selected' ) {
79 for my $id ( ($cgi->param('id')) ) {
80 permission::perm_list->retrieve($id)->delete;
82 } elsif ( $action eq 'Update Selected' ) {
83 for my $id ( ($cgi->param('id')) ) {
84 my $u = permission::perm_list->retrieve($id);
85 $u->code( $cgi->param("code_$id") );
88 } elsif ( $action eq 'Add New' ) {
89 permission::perm_list->create( { code => $cgi->param("code") } );
94 #-------------------------------------------------------------------------------
96 #-------------------------------------------------------------------------------
98 #-----------------------------------------------------------------------
100 #-----------------------------------------------------------------------
101 print "<form method='POST'>".
102 "<table class='table_class'><tr class='header_class'>\n";
104 for my $col ( @col_display_order ) {
105 print th($profile_cols{$col});
108 print '<th>Action</th></tr>';
110 for my $row ( sort { $a->code cmp $b->code } (permission::perm_list->retrieve_all) ) {
113 td("<input type='text' name='code_$row' value='". $row->code() ."'>"),
114 td("<input type='checkbox' value='$row' name='id'>"),
118 print "<tr class='new_row_class'>",
120 td("<input type='text' name='code'>"),
124 print "<input type='submit' name='action' value='Remove Selected'/> | ";
125 print "<input type='submit' name='action' value='Update Selected'/> | ";
126 print "<input type='submit' name='action' value='Add New'/></form><hr/>";
129 print "</body></html>";