summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2008-09-23 23:23:03 +0000
committeraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2008-09-23 23:23:03 +0000
commit0a1573bd053a30b3ba2690fcf3545be02cb2eaa8 (patch)
treee449b9d1099e01686a6059720750ccd495ec45d8 /scripts
parent9937eb3c4ef04f15ceb7cd1106d6bffb10304355 (diff)
Lots of fixes for editing users. Minor changes to Person.sql, specifically person__save_contact.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2339 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r--scripts/admin.pl60
1 files changed, 40 insertions, 20 deletions
diff --git a/scripts/admin.pl b/scripts/admin.pl
index 9a09f40f..3a92425c 100644
--- a/scripts/admin.pl
+++ b/scripts/admin.pl
@@ -62,9 +62,9 @@ sub edit_user {
# uses the same page as create_user, only pre-populated.
my ($request) = @_;
my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'user_id');
- my $user = LedgerSMB::DBObject::User->new(base=>$request, copy=>'user_id');
-
- $user->get($request->{user_id});
+ my $user_obj = LedgerSMB::DBObject::User->new(base=>$request, copy=>'user_id');
+ $user_obj->{company} = $request->{company};
+ $user_obj->get($request->{user_id});
my @all_roles = $admin->get_roles();
@@ -75,16 +75,19 @@ sub edit_user {
format => 'HTML',
path=>'UI'
);
-
+ my $location = LedgerSMB::DBObject::Location->new(base=>$request);
my $template_data =
{
- user=>$user,
+ user=>$user_obj,
roles=>@all_roles,
countries=>$admin->get_countries(),
- user_roles=>$user->{roles},
+ user_roles=>$user_obj->{roles},
salutations=>$admin->get_salutations(),
- locations=>$location->get_all($u_id,"person"),
+ contact_classes=>$admin->get_contact_classes(),
+ locations=>$location->get_all($user_obj->{entity_id},"person"),
};
+ print STDERR Dumper($template_data->{contact_classes});
+ print STDERR Dumper($template_data->{user_roles});
if ($request->type() eq 'POST') {
$admin->save_user();
@@ -94,10 +97,8 @@ sub edit_user {
else {
# print STDERR Dumper($user);
# print STDERR Dumper(@all_roles);
- my $loc;
- my $location = LedgerSMB::DBObject::Location->new(base=>$request);
if ($request->{location_id}) {
- $loc = $location->get($request->{location_id});
+ $template_data->{location} = $location->get($request->{location_id});
}
$template->render($template_data);
}
@@ -248,7 +249,7 @@ sub main {
$template->render( { users=>$user->{users} } );
}
-sub edit_contact {
+sub save_contact {
my $request = shift @_;
@@ -258,13 +259,39 @@ sub edit_contact {
# We have a contact ID, ie, something we made up.
my $c_id = $request->{contact_id};
my $u_id = $request->{user_id};
- my $user = LedgerSMB::DBObject::User->new(base=>$request, copy=>'user_id');
- $user->get($u_id);
+ my $user_obj = LedgerSMB::DBObject::User->new(base=>$request, copy=>'list', merge=>['user_id','company']);
+ $user_obj->get($u_id);
# so we have a user object.
# ->{contacts} is an arrayref to the list of contacts this user has
# $request->{contact_id} is a reference to this structure.
+ $user_obj->save_contact($c_id);
+
+ my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'user_id');
+
+ $user_obj->get($request->{user_id});
+
+ my @all_roles = $admin->get_roles();
+
+ my $template = LedgerSMB::Template->new(
+ user => $user,
+ template => 'Admin/edit_user',
+ language => $user->{language},
+ format => 'HTML',
+ path=>'UI'
+ );
+ my $template_data =
+ {
+ user=>$user_obj,
+ roles=>@all_roles,
+ countries=>$admin->get_countries(),
+ user_roles=>$user_obj->{roles},
+ salutations=>$admin->get_salutations(),
+ contact_classes=>$admin->get_contact_classes(),
+ locations=>$location->get_all($user_obj->{entity_id},"person"),
+ };
+ $template->render($template_data);
}
}
@@ -293,13 +320,6 @@ sub delete_contact {
}
}
-sub new_contact {
-
- my $request = shift @_;
-
-
-}
-
sub save_location {
my $request = shift @_;