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>User Profile Setup</h1>
60 #-------------------------------------------------------------------------------
62 #-------------------------------------------------------------------------------
64 my %profile_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 actor::profile->retrieve($id)->delete;
77 } elsif ( $action eq 'Update Selected' ) {
78 for my $id ( ($cgi->param('id')) ) {
79 my $u = actor::profile->retrieve($id);
80 $u->name( $cgi->param("name_$id") );
83 } elsif ( $action eq 'Add New' ) {
84 actor::profile->create( { name => $cgi->param("name") } );
89 #-------------------------------------------------------------------------------
91 #-------------------------------------------------------------------------------
93 #-----------------------------------------------------------------------
95 #-----------------------------------------------------------------------
96 print "<form method='POST'>".
97 "<table class='table_class'><tr class='header_class'>\n";
99 for my $col ( @col_display_order ) {
100 print th($profile_cols{$col});
103 print '<th>Action</th></tr>';
105 for my $row ( sort { $a->name cmp $b->name } (actor::profile->retrieve_all) ) {
108 td("<input type='text' name='name_$row' value='". $row->name() ."'>"),
109 td("<input type='checkbox' value='$row' name='id'>"),
113 print "<tr class='new_row_class'>",
115 td("<input type='text' name='name'>"),
119 print "<input type='submit' name='action' value='Remove Selected'/> | ";
120 print "<input type='submit' name='action' value='Update Selected'/> | ";
121 print "<input type='submit' name='action' value='Add New'/></form><hr/>";
124 print "</body></html>";