summaryrefslogtreecommitdiff
path: root/scripts/customer.pl
diff options
context:
space:
mode:
authoraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-08-06 20:28:31 +0000
committeraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-08-06 20:28:31 +0000
commitf1756b69854a21b50da387f32f394d4b6fb80be7 (patch)
treea41cf10135ad979ec6fce5d6c924feba94f53fed /scripts/customer.pl
parenta68e3e4e78cd1bb7efe35a39d0fdd376f60e2fae (diff)
Addition of Vendor and Customer-specific save, get, and search functions in Pgsql stored procedures.
Cleanup and modification of Employee.sql, to fit the new Entity framework, as well as the modifications to support trigram searching. Addition of customer.pl and vendor.pl scripts, to support new perl framework code, as well as .pm modules for the same. Some cleanup of Pg-database.sql. addition of note_class = 1 check on entity_note, removal of check id = 1. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1454 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts/customer.pl')
-rw-r--r--scripts/customer.pl106
1 files changed, 106 insertions, 0 deletions
diff --git a/scripts/customer.pl b/scripts/customer.pl
new file mode 100644
index 00000000..8b476995
--- /dev/null
+++ b/scripts/customer.pl
@@ -0,0 +1,106 @@
+
+=pod
+
+=head1 NAME
+
+LedgerSMB::Scripts::customer - LedgerSMB class defining the Controller
+functions, template instantiation and rendering for customer editing and display.
+
+=head1 SYOPSIS
+
+This module is the UI controller for the customer DB access; it provides the
+View interface, as well as defines the Save customer.
+Save customer will update or create as needed.
+
+
+=head1 METHODS
+
+=cut
+
+package LedgerSMB::Scripts::Customer;
+
+use LedgerSMB::Template;
+use LedgerSMB::DBObject::Customer;
+
+=pod
+
+=over
+
+=item get($self, $request, $user)
+
+Requires form var: id
+
+Extracts a single customer from the database, using its company ID as the primary
+point of uniqueness. Shows (appropriate to user privileges) and allows editing
+of the customer informations.
+
+=back
+
+=cut
+
+sub get {
+
+ my ($class, $request) = @_;
+ my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
+ my $result = $customer->get($customer->{id});
+
+ my $template = LedgerSMB::Template->new( user => $user,
+ template => 'customer.html', language => $user->{language},
+ format => 'html');
+ $template->render($results);
+
+}
+
+=pod
+
+=over
+
+=item search($self, $request, $user)
+
+Requires form var: search_pattern
+
+Directly calls the database function search, and returns a set of all customers
+found that match the search parameters. Search parameters search over address
+as well as customer/Company name.
+
+=back
+
+=cut
+
+sub search {
+ my ($class, $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);
+}
+
+=pod
+
+=over
+
+=item save($self, $request, $user)
+
+Saves a customer to the database. The function will update or insert a new
+customer as needed, and will generate a new Company ID for the customer if needed.
+
+=back
+
+=cut
+
+sub save {
+
+ my ($class, $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);
+}
+
+1; \ No newline at end of file