[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4516] branches/1.3
- Subject: SF.net SVN: ledger-smb:[4516] branches/1.3
- From: ..hidden..
- Date: Wed, 21 Mar 2012 12:11:28 +0000
Revision: 4516
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4516&view=rev
Author: einhverfr
Date: 2012-03-21 12:11:27 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
Stored procedures for parts search. Using full text search for parts lookup on description field
Modified Paths:
--------------
branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm
branches/1.3/sql/modules/LOADORDER
branches/1.3/sql/modules/Util.sql
Added Paths:
-----------
branches/1.3/LedgerSMB/ScriptLib/Common_Search/
branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm
Added: branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm (rev 0)
+++ branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm 2012-03-21 12:11:27 UTC (rev 4516)
@@ -0,0 +1,106 @@
+=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::Part;
+use strict;
+use warnings;
+use LedgerSMB::DBObject::Part;
+
+=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 => 'id',
+ name => 'ID',
+ type => 'mirrored', }
+
+ {col_id => 'partnumber',
+ name => 'Partnumber',
+ type => 'mirrored', },
+
+ {col_id => 'description',
+ name => 'Description',
+ type => 'mirrored', },
+
+ {col_id => 'on_hand',
+ name => 'On Hand',
+ type => 'text', } ,
+ # Can add more later
+];
+
+sub columns {
+ return $COLUMNS;
+}
+
+=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 ($request) = @_;
+ my $self = {};
+ bless $self, __PACKAGE__;
+ $self->{_part} = LedgerSMB::DBObject::Part->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) = @_;
+ @results = $self->{_part}->search($args);
+ $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;
Modified: branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm 2012-03-21 09:54:28 UTC (rev 4515)
+++ branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm 2012-03-21 12:11:27 UTC (rev 4516)
@@ -103,6 +103,12 @@
Returns a list of columns as expected for Dynatable.
+=item results
+
+Returns a list of results, becomes the rows for the table.
+
+=back
+
=head1 COPYRIGHT
Copyright (C) 2012 LedgerSMB Core Team. This file may be re-used under the terms of the GNU General Public License version 2 or at your option any later version.
Modified: branches/1.3/sql/modules/LOADORDER
===================================================================
--- branches/1.3/sql/modules/LOADORDER 2012-03-21 09:54:28 UTC (rev 4515)
+++ branches/1.3/sql/modules/LOADORDER 2012-03-21 12:11:27 UTC (rev 4516)
@@ -25,4 +25,6 @@
Util.sql
Assets.sql
Files.sql
+Parts.sql
Fixes.sql
+
Modified: branches/1.3/sql/modules/Util.sql
===================================================================
--- branches/1.3/sql/modules/Util.sql 2012-03-21 09:54:28 UTC (rev 4515)
+++ branches/1.3/sql/modules/Util.sql 2012-03-21 12:11:27 UTC (rev 4516)
@@ -13,6 +13,13 @@
END;
$$ language plpgsql;
+
+CREATE OR REPLACE FUNCTION get_default_lang() RETURNS text AS
+$$ SELECT description FROM language
+ WHERE code = (SELECT substring(value, 1, 2) FROM defaults
+ WHERE setting_key = 'default_language');
+$$ LANGUAGE sql;
+
CREATE OR REPLACE FUNCTION je_get_default_lines() returns varchar as
$$
SELECT value FROM menu_attribute where node_id = 74 and attribute = 'rowcount';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.