[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [2178] trunk
- Subject: SF.net SVN: ledger-smb: [2178] trunk
- From: ..hidden..
- Date: Mon, 30 Jun 2008 14:25:00 -0700
Revision: 2178
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2178&view=rev
Author: einhverfr
Date: 2008-06-30 14:24:59 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
Adding batch_search_mini api
Addressing issue on create batch screen of searching through all batches
Adding error message in LedgerSMB::call_procedure if procname is undefined.
Modified Paths:
--------------
trunk/LedgerSMB/Batch.pm
trunk/LedgerSMB.pm
trunk/scripts/vouchers.pl
trunk/sql/modules/Voucher.sql
trunk/t/01-load.t
Modified: trunk/LedgerSMB/Batch.pm
===================================================================
--- trunk/LedgerSMB/Batch.pm 2008-06-30 20:56:17 UTC (rev 2177)
+++ trunk/LedgerSMB/Batch.pm 2008-06-30 21:24:59 UTC (rev 2178)
@@ -31,11 +31,26 @@
}
sub get_search_results {
- my ($self) = @_;
- @{$self->{search_results}} = $self->exec_method(funcname => 'batch_search');
+ my ($self, $args) = @_;
+ if ($args->{mini}){
+ $search_proc = "batch_search_mini";
+ } else {
+ $search_proc = "batch_search";
+ }
+ @{$self->{search_results}} = $self->exec_method(funcname => $search_proc);
return @{$self->{search_results}};
}
+sub get_class_id {
+ my ($self, $type) = @_;
+ @results = $self->call_procedure(
+ procname => 'batch_get_class_id',
+ args => [$type]
+ );
+ my $result = pop @results;
+ return $result->{batch_get_class_id};
+}
+
sub post {
my ($self) = @_;
($self->{post_return_ref}) = $self->exec_method(funcname => 'batch_post');
Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm 2008-06-30 20:56:17 UTC (rev 2177)
+++ trunk/LedgerSMB.pm 2008-06-30 21:24:59 UTC (rev 2178)
@@ -552,6 +552,10 @@
my $argstr = "";
my @results;
+ if (!defined $procname){
+ $self->error('Undefined function in call_procedure.');
+ }
+
$procname = $self->{dbh}->quote_identifier($procname);
for ( 1 .. scalar @call_args ) {
$argstr .= "?, ";
@@ -566,7 +570,7 @@
if (scalar @call_args){
$sth->execute(@call_args) || $self->error($self->{dbh}->errstr);
} else {
- $sth->execute() || $self->error($self->{dbh}->errstr);
+ $sth->execute() || $self->error($self->{dbh}->errstr . ':' . $query);
}
my @types = @{$sth->{TYPE}};
Modified: trunk/scripts/vouchers.pl
===================================================================
--- trunk/scripts/vouchers.pl 2008-06-30 20:56:17 UTC (rev 2177)
+++ trunk/scripts/vouchers.pl 2008-06-30 21:24:59 UTC (rev 2178)
@@ -22,7 +22,8 @@
];
my $batch = LedgerSMB::Batch->new({base => $request});
- $batch->get_search_results;
+ $batch->{class_id} = $batch->get_class_id($batch->{batch_type});
+ $batch->get_search_results();
my $template = LedgerSMB::Template->new(
user =>$request->{_user},
Modified: trunk/sql/modules/Voucher.sql
===================================================================
--- trunk/sql/modules/Voucher.sql 2008-06-30 20:56:17 UTC (rev 2177)
+++ trunk/sql/modules/Voucher.sql 2008-06-30 21:24:59 UTC (rev 2178)
@@ -213,8 +213,46 @@
END;
$$ LANGUAGE PLPGSQL;
+CREATE OR REPLACE FUNCTION batch_get_class_id (in_type text) returns int AS
+$$
+SELECT id FROM batch_class WHERE class = $1;
+$$ language sql;
+CREATE OR REPLACE FUNCTION
+batch_search_mini
+(in_class_id int, in_description text, in_created_by_eid int, in_approved bool)
+RETURNS SETOF batch_list_item AS
+$$
+DECLARE out_value batch_list_item;
+BEGIN
+ FOR out_value IN
+ SELECT b.id, c.class, b.control_code, b.description, u.username,
+ b.created_on, NULL
+ FROM batch b
+ JOIN batch_class c ON (b.batch_class_id = c.id)
+ LEFT JOIN users u ON (u.entity_id = b.created_by)
+ JOIN voucher v ON (v.batch_id = b.id)
+ WHERE (c.id = in_class_id OR in_class_id IS NULL) AND
+ (b.description LIKE
+ '%' || in_description || '%' OR
+ in_description IS NULL) AND
+ (in_created_by_eid = b.created_by OR
+ in_created_by_eid IS NULL) AND
+ ((in_approved = false OR in_approved IS NULL AND
+ approved_on IS NULL) OR
+ (in_approved = true AND approved_on IS NOT NULL)
+ )
+ GROUP BY b.id, c.class, b.description, u.username, b.created_on,
+ b.control_code
+ LOOP
+ RETURN NEXT out_value;
+ END LOOP;
+END;
+$$ LANGUAGE PLPGSQL;
+
+
+
CREATE OR REPLACE FUNCTION batch_post(in_batch_id INTEGER)
returns date AS
$$
Modified: trunk/t/01-load.t
===================================================================
--- trunk/t/01-load.t 2008-06-30 20:56:17 UTC (rev 2177)
+++ trunk/t/01-load.t 2008-06-30 21:24:59 UTC (rev 2178)
@@ -28,7 +28,7 @@
use_ok('LedgerSMB::PriceMatrix');
use_ok('LedgerSMB::RC');
use_ok('LedgerSMB::RP');
-use_ok('LedgerSMB::Session');
+use_ok('LedgerSMB::Auth');
use_ok('LedgerSMB::Sysconfig');
use_ok('LedgerSMB::Tax');
use_ok('LedgerSMB::Template');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.