summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-06-23 21:57:46 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-06-23 21:57:46 +0000
commit17c0ab0a7ee10abc0b0397f21d0277096bdc15f7 (patch)
treee8ef09774fa813c45280c021f57b5c8fbc5a6c64 /scripts
parent675bce61fec48b070d653424867e897cf57b72df (diff)
Correcting missing files and commits
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2170 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r--scripts/drafts.pl130
-rw-r--r--scripts/vouchers.pl4
2 files changed, 130 insertions, 4 deletions
diff --git a/scripts/drafts.pl b/scripts/drafts.pl
new file mode 100644
index 00000000..741b5fed
--- /dev/null
+++ b/scripts/drafts.pl
@@ -0,0 +1,130 @@
+
+package LedgerSMB::Scripts::vouchers;
+our $VERSION = '0.1';
+
+use LedgerSMB::DBObject::Draft;
+use LedgerSMB::Template;
+use strict;
+
+sub search {
+ my ($request) = @_;
+ my $template = LedgerSMB::Template->new(
+ user =>$request->{_user},
+ locale => $request->{_locale},
+ path => 'UI',
+ template => 'batch/search_transactions',
+ format => 'HTML'
+ );
+ $template->render($request);
+}
+
+sub list_drafts {
+ my ($request) = @_;
+ my $draft= LedgerSMB::Draft->new(base => $request);
+ my @search_results = $draft->search;
+ $draft->{script} = "drafts.pl";
+
+ my @columns =
+ qw(select id transdate reference description, amount);
+
+ my $base_href = "drafts.pl";
+ my $search_href = "$base_href?action=list_transactions";
+ my $draft_href= "$base_href?action=get_transaction";
+
+ for my $key (
+ qw(class_id approved created_by description amount_gt amount_lt)
+ ){
+ $search_href .= "&$key=$draft->{key}";
+ }
+
+ my %column_heading = (
+ 'select' => $draft->{_locale}->text('Select'),
+ transaction_total => {
+ text => $draft->{_locale}->text('AR/AP/GL Total'),
+ href => "$search_href&order_by=transaction_total"
+ },
+ payment_total => {
+ text => $draft->{_locale}->text('Paid/Received Total'),
+ href => "$search_href&order_by=payment_total"
+ },
+ description => {
+ text => $draft->{_locale}->text('Description'),
+ href => "$search_href&order_by=description"
+ },
+ control_code => {
+ text => $draft->{_locale}->text('Batch Number'),
+ href => "$search_href&order_by=control_code"
+ },
+ id => {
+ text => $draft->{_locale}->text('ID'),
+ href => "$search_href&order_by=control_code"
+ },
+ );
+ my $count = 0;
+ my @rows;
+ for my $result (@search_results){
+ ++$count;
+ $draft->{"row_$count"} = $result->{id};
+ push @rows, {
+ 'select' => {
+ input => {
+ type => 'checkbox',
+ value => 1,
+ name => "draft_$result->{id}"
+ }
+ },
+ transaction_total => $draft->format_amount(
+ amount => $result->{transaction_total}
+ ),
+ payment_total => $draft->format_amount (
+ amount => $result->{payment_total}
+ ),
+ description => $result->{description},
+ control_code => {
+ text => $result->{control_code},
+ href => "$draft_href&draft_id=$result->{id}",
+
+ },
+ id => $result->{id},
+ };
+ }
+ $draft->{rowcount} = $count;
+ my $template = LedgerSMB::Template->new(
+ user => $request->{_user},
+ locale => $request->{_locale},
+ path => 'UI',
+ template => 'form-dynatable',
+ format => ($draft->{format}) ? $draft->{format} : 'HTML',
+ );
+
+ my $hiddens = $draft->take_top_level();
+ $draft->{rowcount} = "$count";
+ delete $draft->{search_results};
+
+ $template->render({
+ form => $draft,
+ columns => \@columns,
+ heading => \%column_heading,
+ rows => \@rows,
+ hiddens => $hiddens,
+ buttons => [{
+ name => 'action',
+ type => 'submit',
+ text => $request->{_locale}->text('Post'),
+ value => 'draft_approve',
+ class => 'submit',
+ },{
+ name => 'action',
+ type => 'submit',
+ text => $request->{_locale}->text('Delete'),
+ value => 'draft_delete',
+ class => 'submit',
+ }]
+ });
+}
+
+
+
+sub delete_drafts {
+ my ($request) = @_;
+}
diff --git a/scripts/vouchers.pl b/scripts/vouchers.pl
index e6eb7f39..321c0303 100644
--- a/scripts/vouchers.pl
+++ b/scripts/vouchers.pl
@@ -38,10 +38,6 @@ sub create_vouchers {
add_vouchers($batch);
}
-sub search_transactions {
-}
-
-
sub add_vouchers {
# This function is not safe for caching as long as the scripts are in bin.
# This is because these scripts import all functions into the *current*