summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-15 23:10:31 +0000
committeraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-15 23:10:31 +0000
commitd340ccd5ecbb731c273a07876ad0dfc0a9b33379 (patch)
tree15acb5cc66a14c787ef49a6bab8910cdca0f82c9 /scripts
parentc366b783a65dfdd7dadb105962ae0807cddaa6b9 (diff)
Significant work on the Entity and Administrative code. It's buggy, so please test, etc. thoroughly.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1869 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r--scripts/admin.pl10
-rw-r--r--scripts/customer.pl68
-rw-r--r--scripts/login.pl45
3 files changed, 97 insertions, 26 deletions
diff --git a/scripts/admin.pl b/scripts/admin.pl
index 18fb0ca8..2b8ca816 100644
--- a/scripts/admin.pl
+++ b/scripts/admin.pl
@@ -5,6 +5,7 @@ require 'lsmb-request.pl';
use LedgerSMB::Template;
use LedgerSMB::DBObject::Admin;
+use LedgerSMB::DBObject::User;
sub new_user {
@@ -23,7 +24,7 @@ sub new_user {
my $template = LedgerSMB::Template->new( user => $user,
- template => 'Admin/edit_user', language => $user->{language},
+ template => 'Admin/edit_user', language => $user->{ language },
format => 'HTML', path=>'UI');
$template->render(
@@ -153,11 +154,14 @@ sub __default {
my ($class, $request) = @_;
- # TODO: check for login stuff.
my $template;
+ my $user = LedgerSMB::DBObject::User->new(base=>$request, copy=>'all');
+
+ $user->get_all_users();
+
$template = LedgerSMB::Template->new( user=>$user,
template=>'Admin/main', language=>$user->{language},
format=>'HTML', path=>'UI');
- $template->render();
+ $template->render($user);
}
1; \ No newline at end of file
diff --git a/scripts/customer.pl b/scripts/customer.pl
index 24fb04f6..7fc238da 100644
--- a/scripts/customer.pl
+++ b/scripts/customer.pl
@@ -44,11 +44,13 @@ of the customer informations.
sub get {
my ($request) = @_;
- my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
- my $result = $customer->get($customer->{id});
+ my $customer = LedgerSMB::DBObject::Company->new(base => $request, copy => 'all');
+
+ $customer->set( entity_class=> '2' );
+ my $result = $customer->get();
my $template = LedgerSMB::Template->new( user => $user,
- template => 'customer.html', language => $user->{language},
+ template => 'Customer/customer.html', language => $user->{language},
format => 'html');
$template->render($results);
@@ -68,10 +70,10 @@ This method creates a blank screen for entering a customer's information.
sub add {
my ($request) = @_;
- my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
-
+ my $customer = LedgerSMB::DBObject::Company->new(base => $request, copy => 'all');
+ $customer->set(entity_class=>2);
my $template = LedgerSMB::Template->new( user => $user,
- template => 'customer.html', language => $user->{language},
+ template => 'Customer/customer.html', language => $user->{language},
format => 'html');
$template->render($results);
}
@@ -94,13 +96,30 @@ as well as customer/Company name.
sub search {
my ($request) = @_;
- my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
- my $results = $customer->search($customer->{search_pattern});
- my $template = LedgerSMB::Template->new( user => $user,
- template => 'customer_search.html', language => $user->{language},
- format => 'html');
- $template->render($results);
+ if ($request->type() eq 'POST') {
+ # assume it's asking us to do the search, now
+
+ my $customer = LedgerSMB::DBObject::Company->new(base => $request, copy => 'all');
+ $customer->set(entity_class=>2);
+ my $results = $customer->search($customer->{search_pattern});
+
+ my $template = LedgerSMB::Template->new( user => $user,
+ template => 'Customer/customer.html', language => $user->{language},
+ format => 'html');
+ $template->render($results);
+
+ }
+ else {
+
+ # grab the happy search page out.
+
+ my $template = LedgerSMB::Template->new( user => $user,
+ template => 'Customer/customer_search.html', language => $user->{language},
+ format => 'html');
+
+ $template->render();
+ }
}
=pod
@@ -119,13 +138,26 @@ customer as needed, and will generate a new Company ID for the customer if neede
sub save {
my ($request) = @_;
- my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
- my $result = $customer->save_to_db();
- my $template = LedgerSMB::Template->new( user => $user,
- template => 'customer.html', language => $user->{language},
- format => 'html');
- $template->render($result);
+ if ($request->type() == 'POST') {
+
+ my $customer = LedgerSMB::DBObject::Customer->get(base=>$request, copy=>'all');
+
+ unless ($customer) {
+
+ $customer = LedgerSMB::DBObject::Customer->new(base=>$reqest, copy=>'all');
+ }
+
+ my $result = $customer->save();
+
+ my $template = LedgerSMB::Template->new( user => $user,
+ template => 'Customer/customer.html', language => $user->{language},
+ format => 'html');
+ $template->render($result);
+ }
+ else {
+
+ }
}
1;
diff --git a/scripts/login.pl b/scripts/login.pl
index 1ce79587..537d8b61 100644
--- a/scripts/login.pl
+++ b/scripts/login.pl
@@ -7,13 +7,18 @@ use LedgerSMB::User;
use LedgerSMB::Auth;
use strict;
+# this is kind of silly, as it doesn't check if someone IS trying to log in.
+# If one looks at the login template (get_password.html), it does not post
+# to any action, so this code will always get called, thereby preventing
+# anyone from actually logging in.
+
sub __default {
my ($request) = @_;
my $locale;
$locale = LedgerSMB::Locale->get_handle(${LedgerSMB::Sysconfig::language})
or $request->error( __FILE__ . ':' . __LINE__ .
- ": Locale not loaded: $!\n" );
- my $template = LedgerSMB::Template->new(
+ ": Locale not loaded: $!\n" );
+ my $template = LedgerSMB::Template->new(
user =>$request->{_user},
locale => $locale,
path => 'UI',
@@ -23,6 +28,8 @@ sub __default {
$template->render($request);
}
+# Directly printing like this is made of fail.
+
sub authenticate {
my ($request) = @_;
if (!$request->{dbh}){
@@ -33,10 +40,20 @@ sub authenticate {
}
my $path = $ENV{SCRIPT_NAME};
$path =~ s|[^/]*$||;
- if ($request->{dbh} || $request->{log_out}){
+
+ if ($request->{dbh} && $request->{next}) {
+
+ print "Content-Type: text/html\n";
+ print "Set-Cookie: LedgerSMB=Login; path=$path\n";
+ print "Status: 302 Found\n";
+ print "Location: ".$path.$request->{next}."\n";
+ print "\n";
+ exit;
+ }
+ elsif ($request->{dbh} || $request->{log_out}){
print "Content-Type: text/html\n";
print "Set-Cookie: LedgerSMB=Login; path=$path\n";
- print "Status: 200 Success\n\n";
+ print "Status: 200 Success\n\n";
if ($request->{log_out}){
exit;
}
@@ -44,7 +61,7 @@ sub authenticate {
else {
print "WWW-Authenticate: Basic realm=\"LedgerSMB\"\n";
print "Status: 401 Unauthorized\n\n";
- print "Please enter your credentials.\n";
+ print "Please enter your credentials.\n";
exit;
}
}
@@ -69,5 +86,23 @@ sub logout {
print "Content-type: text/html\n\n";
exit;
}
+
+sub continue {
+
+ my ($request) = @_;
+
+ if ($request->{next} && $request->{password}) {
+
+ $request->{user} = "admin";
+
+ if (&authenticate($request)) {
+# LedgerSMB::Handler::call_script();
+ }
+ }
+ else {
+ # well, wtf? This is kind of useless.
+ $request->error("Cannot continue to a Nonexistent page.");
+ }
+}
1;