[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2686] trunk
- Subject: SF.net SVN: ledger-smb:[2686] trunk
- From: ..hidden..
- Date: Tue, 16 Jun 2009 05:36:38 +0000
Revision: 2686
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2686&view=rev
Author: einhverfr
Date: 2009-06-16 05:36:38 +0000 (Tue, 16 Jun 2009)
Log Message:
-----------
User search and edit now works
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Admin.pm
trunk/scripts/admin.pl
trunk/sql/modules/admin.sql
Added Paths:
-----------
trunk/UI/Admin/user_search.html
Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm 2009-06-15 21:02:15 UTC (rev 2685)
+++ trunk/LedgerSMB/DBObject/Admin.pm 2009-06-16 05:36:38 UTC (rev 2686)
@@ -92,6 +92,13 @@
}
+sub search_users {
+ my $self = shift @_;
+ my @users = $self->exec_method(funcname => 'admin__search_users');
+ $self->{user_results} = ..hidden..;
+ return @users;
+}
+
sub save_roles {
my $self = shift @_;
Added: trunk/UI/Admin/user_search.html
===================================================================
--- trunk/UI/Admin/user_search.html (rev 0)
+++ trunk/UI/Admin/user_search.html 2009-06-16 05:36:38 UTC (rev 2686)
@@ -0,0 +1,66 @@
+<?lsmb INCLUDE 'ui-header.html' stylesheet = stylesheet ?>
+<?lsmb PROCESS 'elements.html' ?>
+<div class="listtop">
+<?lsmb text('Search for Users') ?>
+</div>
+<div class="input_row">
+<form action="admin.pl" method="post" name="user_search">
+<div class="input_row">
+<?lsmb PROCESS input element_data = {
+ label = text('Username:')
+ type = "text"
+ name = "username"
+ value = username
+ class = "username"
+ size = "20"
+} ?>
+</div>
+<div class="input_row">
+<?lsmb PROCESS input element_data = {
+ label = text('First Name') #'
+ type = "text"
+ name = "first_name"
+ value = first_name
+ class = "name"
+ size = "20"
+} ?>
+</div>
+<div class="input_row">
+<?lsmb PROCESS input element_data = {
+ label = text('Last Name') #'
+ type = "text"
+ name = "last_name"
+ value = last_name
+ class = "name"
+ size = "20"
+} ?>
+</div>
+<div class="input_row">
+<?lsmb PROCESS input element_data = {
+ label = text('Tax ID') #'
+ type = "text"
+ name = "ssn"
+ value = ssn
+ class = "tax_id"
+ size = "20"
+} ?>
+</div>
+<div class="input_row">
+<?lsmb PROCESS input element_data = {
+ label = text('Date of Birth') #'
+ type = "text"
+ name = "dob"
+ value = dob
+ class = "date"
+ size = "12"
+} ?>
+</div>
+<?lsmb PROCESS button element_data = {
+ text = text('Search')
+ value = "get_user_results"
+ name = "action"
+ type = "submit"
+ class = "submit"
+} ?>
+</form>
+</body>
Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl 2009-06-15 21:02:15 UTC (rev 2685)
+++ trunk/scripts/admin.pl 2009-06-16 05:36:38 UTC (rev 2686)
@@ -378,4 +378,66 @@
#eval { do "scripts/custom/admin.pl"};
+sub search_users {
+ my ($request) = @_;
+ my $template = LedgerSMB::Template->new(
+ user => $request->{_user},
+ template => 'Admin/user_search',
+ locale => $request->{_locale},
+ format => 'HTML',
+ path=>'UI'
+ );
+ $template->render($request);
+}
+
+sub get_user_results {
+ my ($request) = @_;
+ my $admin = LedgerSMB::DBObject::Admin->new(base => $request);
+ my @users = $admin->search_users;
+ my $template = LedgerSMB::Template->new(
+ user => $request->{_user},
+ template => 'form-dynatable',
+ locale => $request->{_locale},
+ format => 'HTML',
+ path=>'UI'
+ );
+ my $columns;
+ @$columns = qw(id username first_name last_name ssn dob edit);
+ $column_headers = {
+ id => $request->{_locale}->text('ID'),
+ username => $request->{_locale}->text('Username'),
+ first_name => $request->{_locale}->text('First Name'),
+ last_name => $request->{_locale}->text('Last Name'),
+ ssn => $request->{_locale}->text('Tax ID'),
+ dob => $request->{_locale}->text('Date of Birth'),
+ };
+ my $rows = [];
+ my $rowcount = "0";
+ my $base_url = "admin.pl?action=edit_user";
+ for my $u (@users) {
+ $u->{i} = $rowcount % 2;
+ $u->{edit} = {
+ href =>"$base_url&user_id=$u->{id}",
+ text => '[' . $request->{_locale}->text('edit') . ']',
+ };
+ push @$rows, $u;
+ ++$rowcount;
+ }
+ $admin->{title} = $request->{_locale}->text('Search Results');
+ $template->render({
+ form => $admin,
+ columns => $columns,
+ heading => $column_headers,
+ rows => $rows,
+ buttons => [],
+ hiddens => [],
+ });
+}
+
+sub list_sessions {
+}
+
+sub delete_session {
+}
+
1;
Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql 2009-06-15 21:02:15 UTC (rev 2685)
+++ trunk/sql/modules/admin.sql 2009-06-16 05:36:38 UTC (rev 2686)
@@ -110,6 +110,7 @@
$$ language 'plpgsql' SECURITY DEFINER;
+
REVOKE EXECUTE ON FUNCTION admin__add_function_to_group(TEXT, TEXT) FROM PUBLIC;
CREATE OR REPLACE FUNCTION admin__remove_function_from_group(in_func TEXT, in_role TEXT) returns INT AS $$
@@ -609,3 +610,57 @@
END;
$$ language plpgsql;
+CREATE TYPE user_result AS (
+ id int,
+ username text,
+ first_name text,
+ last_name text,
+ ssn text,
+ dob text
+);
+
+
+CREATE OR REPLACE FUNCTION admin__search_users(in_username text, in_first_name text, in_last_name text, in_ssn text, in_dob text) RETURNS SETOF user_result AS
+$$
+DECLARE t_return_row user_result;
+BEGIN
+ FOR t_return_row IN
+ SELECT u.id, u.username, p.first_name, p.last_name, e.ssn, e.dob
+ FROM users u
+ JOIN person p ON (u.entity_id = p.entity_id)
+ JOIN entity_employee e ON (e.entity_id = p.entity_id)
+ WHERE u.username LIKE '%' || coalesce(in_username,'') || '%' AND
+ (p.first_name = in_first_name or in_first_name is null)
+ AND (p.last_name = in_last_name or in_last_name is null)
+ AND (in_ssn is NULL or in_ssn = e.ssn)
+ AND (e.dob = in_dob or in_dob is NULL)
+ LOOP
+ RETURN NEXT t_return_row;
+ END LOOP;
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE TYPE session_result AS (
+ id int,
+ username text,
+ last_used timestamp,
+ locks_active bigint
+);
+
+CREATE OR REPLACE FUNCTION admin__list_sessions() RETURNS SETOF session_result
+AS $$
+SELECT s.session_id, u.username, s.last_used, count(t.id)
+FROM "session" s
+JOIN users u ON (s.users_id = u.id)
+LEFT JOIN transactions t ON (t.locked_by = s.session_id)
+GROUP BY s.session_id, u.username, s.last_used
+ORDER BY u.username;
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION admin__drop_session(in_id) RETURNS bool AS
+$$
+BEGIN
+ DELETE FROM "session" WHERE session_id = in_id;
+ RETURN FOUND;
+END;
+$$ language plpgsql;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.