[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4554] branches/1.3/LedgerSMB/ScriptLib/ Common_Search/Customer.pm



Revision: 4554
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4554&view=rev
Author:   ehuelsmann
Date:     2012-03-24 13:55:08 +0000 (Sat, 24 Mar 2012)
Log Message:
-----------
Add customer searches to the Common Search functionality.

Added Paths:
-----------
    branches/1.3/LedgerSMB/ScriptLib/Common_Search/Customer.pm

Added: branches/1.3/LedgerSMB/ScriptLib/Common_Search/Customer.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Common_Search/Customer.pm	                        (rev 0)
+++ branches/1.3/LedgerSMB/ScriptLib/Common_Search/Customer.pm	2012-03-24 13:55:08 UTC (rev 4554)
@@ -0,0 +1,122 @@
+=head1 NAME
+
+LedgerSMB::ScriptLib::Common_Search::Part - Part Search Routines
+
+=head1 SYNPOSIS
+
+This provides functionality to search for a part, for new 1.3-framework code.
+
+=cut
+
+package LedgerSMB::ScriptLib::Common_Search::Customer;
+use base qw(LedgerSMB::ScriptLib::Common_Search);
+use strict;
+use warnings;
+use LedgerSMB::DBObject::Customer;
+
+=head1 PROPERTIES/ACCESSORS
+
+=over
+
+=item columns (Global, static, read-only)
+
+Returns a list of columns for the embedded table engine as an arrayref.
+
+=cut
+
+my $COLUMNS = [
+      {col_id => 'entity_control_code',
+         name => 'Control code',
+         type => 'mirrored', },
+
+      {col_id => 'meta_number',
+         name => 'Account number',
+         type => 'mirrored', },
+
+      {col_id => 'legal_name',
+         name => 'Company name',
+         type => 'mirrored', },
+
+      {col_id => 'credit_description',
+         name => 'Description',
+         type => 'mirrored', },
+
+      # Can add more later
+];
+
+sub columns {
+   return $COLUMNS;
+}
+
+
+=item row_id
+
+Returns the name of the column which contains the row unique id.  
+
+=cut
+
+sub row_id {
+    return 'entity_id';
+}
+
+=item results
+
+Returns a list of results as an array of hashrefs.
+
+=cut
+
+sub results {
+    my ($self) = @_;
+    return $self->{_results};
+}
+
+=back
+
+=head1 METHODS
+
+=over 
+
+=item new ($request)
+
+Instantiates a new search object.
+
+=cut
+
+sub new {
+    my ($pkg, $request) = @_;
+    my $self = {};
+    bless $self, __PACKAGE__;
+    $self->{_customer} =
+	LedgerSMB::DBObject::Customer->new({base => $request});
+    $self->{_results} = [];
+    return $self;
+};
+
+
+=item search({partnumber => $string, description => $string})
+
+Performs a search and caches it.  One object should be used per search unless
+results are no longer needed.
+
+=cut
+
+sub search {
+    my ($self, $args) = @_;
+    $args->{account_class} = 2; # search requires account_class (1=customer)
+    $self->{_customer}->merge($args);
+    my @results = $self->{_customer}->search;
+    $self->{_results} = ..hidden..;
+    return @{$self->{_results}};
+}
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2012 The LedgerSMB Core Team.  This file may be used in 
+accordance with the GNU General Public License version 2 or at your option any
+later version.  Please see attached LICENSE file for details.
+
+=cut
+
+return 1;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.