diff options
author | aurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-10 23:02:09 +0000 |
---|---|---|
committer | aurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-10 23:02:09 +0000 |
commit | 74afbb457aac6a1f6e2d4a2357768f710977a640 (patch) | |
tree | cc06c426397d05c5f1dc12eb40b0883f7d3b0854 /scripts | |
parent | 928290e80924da702b9041a30dd776ad34d24ba9 (diff) |
Creation of next-gen admin.pl, admin.pm, and admin.sql systems.
Admin.pm defines the new controller
admin.pl is the direct view-backing software.
POD is not completed, will be provided shortly.
Full UI templates provided for the Reconciliation, Vendor, Customer, and Employee as well.
UI/ is being delineated by subdirectories for Admin, Vendor, Customer and Employee, to date.
Minor whitespace cleanup.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1557 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/admin.pl | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/scripts/admin.pl b/scripts/admin.pl new file mode 100644 index 00000000..64fefcb9 --- /dev/null +++ b/scripts/admin.pl @@ -0,0 +1,155 @@ +package LedgerSMB::Scripts::Admin; + +use LedgerSMB::Template; +use LedgerSMB::DBObject::Admin; + +sub new_user { + + # uses the same page as create_user, only pre-populated. + my ($class, $request) = @_; + my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all'); + + if ($request->type() == 'POST') { + + # do the save stuff + + my $entity = $admin->save_user(); + + + my $template = LedgerSMB::Template->new( user => $user, + template => 'admin/edit_user.html', language => $user->{language}, + format => 'html'); + + $template->render($entity); + } else { + + my $template = LedgerSMB::Template->new( user => $user, + template => 'admin/edit_user.html', language => $user->{language}, + format => 'html'); + + $template->render(); + } +} + +sub edit_user { + + # uses the same page as create_user, only pre-populated. + my ($class, $request) = @_; + my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'user_id'); + + my $edited_user = $admin->get_entire_user(); + my $all_roles = $admin->role_list(); + + my $template = LedgerSMB::Template->new( user => $user, + template => 'admin/edit_user.html', language => $user->{language}, + format => 'html'); + + $template->render($edited_user, $all_roles); +} + +sub edit_group { + + my ($class, $request) = @_; + my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all'); + + my $all_roles = $admin->role_list(); + my $group = $admin->get_group(); + + my $template = LedgerSMB::Template->new( user => $user, + template => 'admin/edit_group.html', language => $user->{language}, + format => 'html'); + + $template->render($all_roles); +} + +sub create_group { + + my ($class, $request) = @_; + my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all'); + + my $all_roles = $admin->role_list(); + + my $template = LedgerSMB::Template->new( user => $user, + template => 'admin/edit_group.html', language => $user->{language}, + format => 'html'); + + $template->render($all_roles); +} + +sub delete_group { + + my ($class, $request) = @_; + + my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all'); + + # requires the field modifying_user to be set. + + my $status = $admin->delete_group($request->{modifying_user}); + + # status can either be 1, or an error. + # if there's an error, $status->throw() is called by admin.pm. Or possibly + # in the template itself. + + my $template = LedgerSMB::Template->new ( user=>$user, + template=>'admin/delete_group.html', language=>$user->{language}, + format=>'html'); + + $template->render($status); +} + +sub delete_user { + + my ($class, $request) = @_; + + my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all'); + + # requires the field modifying_user to be set. + + my $status = $admin->delete_user($request->{modifying_user}); + + # status can either be 1, or an error. + # if there's an error, $status->throw() is called by admin.pm. Or possibly + # in the template itself. + + my $template = LedgerSMB::Template->new ( user=>$user, + template=>'admin/delete_user.html', language=>$user->{language}, + format=>'html'); + + $template->render($status); +} + +sub new_user { + + my ($class, $request) = @_; + + my $template = LedgerSMB::Template->new( user=>$user, + template=>'admin/new_user.html', language=>$user->{language}, + format=>'html'); + + $template->render(); +} + +sub new_group { + + my ($class, $request) = @_; + + my $template = LedgerSMB::Template->new( user=>$user, + template=>'admin/new_group.html', language=>$user->{language}, + format=>'html'); + + $template->render(); +} + +sub __default { + + my ($class, $request) = @_; + + # check for login + my $template; + $template = LedgerSMB::Template->new( user=>$user, + template=>'admin/main.html', language=>$user->{language}, + format=>'html'); + $template->render(); +} + +1;
\ No newline at end of file |