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

SF.net SVN: ledger-smb: [1799] trunk



Revision: 1799
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1799&view=rev
Author:   tetragon
Date:     2007-10-20 16:34:56 -0700 (Sat, 20 Oct 2007)

Log Message:
-----------
Hook email output of the aging reports statements back up
CSV output of the aging reports

Modified Paths:
--------------
    trunk/bin/rp.pl

Added Paths:
-----------
    trunk/UI/rp-aging.csv

Added: trunk/UI/rp-aging.csv
===================================================================
--- trunk/UI/rp-aging.csv	                        (rev 0)
+++ trunk/UI/rp-aging.csv	2007-10-20 23:34:56 UTC (rev 1799)
@@ -0,0 +1,22 @@
+<?lsmb FOREACH column IN columns;
+    IF heading.$column.text.defined;
+        heading.$column.text;
+    ELSE;
+        heading.$column;
+    END ?>,<?lsmb END; escape(text('Currency')) ?>
+<?lsmb FOREACH currency IN currencies;
+    FOREACH row IN currency.rows;
+        FOREACH column IN columns;
+            IF row.$column.text.defined;
+                row.$column.text;
+            ELSE;
+                row.$column;
+            END ?>,<?lsmb
+        END; currency.curr ?>
+<?lsmb END;
+    IF currency.totals;
+        FOREACH column IN columns;
+            currency.totals.$column ?>,<?lsmb
+        END ?>,<?lsmb currency.curr;
+    END;
+END ?>

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2007-10-19 23:28:25 UTC (rev 1798)
+++ trunk/bin/rp.pl	2007-10-20 23:34:56 UTC (rev 1799)
@@ -1470,6 +1470,8 @@
 
 }
 
+sub csv_generate_ar_aging { &generate_ar_aging }
+
 sub generate_ap_aging {
 
     # split vendor
@@ -1824,11 +1826,12 @@
         };
     }
     my $format;
-    if ($form->{action} eq 'continue') {
+    if ($form->{action} =~ /^(continue|generate_)/) {
 	$format = 'HTML';
     } else {
         $format = uc substr $form->{action}, 0, 3;
-    	push @column_index, 'class';
+        push @column_index, 'class';
+        @column_index = grep {!/^(language|statement)$/} @column_index;
         $column_header{class} = 'rowtype';
     }
     my $template = LedgerSMB::Template->new(
@@ -1882,7 +1885,7 @@
 
     if ( $form->{media} eq 'email' ) {
         $form->{print}{medium} = {name => 'sendmode', default_values => $form->{sendmode}};
-        push @media, {text => $locale->text('Attachement'), value => 'attachement'};
+        push @media, {text => $locale->text('Attachment'), value => 'attachment'};
         push @media, {text => $locale->text('In-line'), value => 'inline'};
 	if ($form->{SM}{attachment}) {
 	    $form->{print}{medium}{default_values} = $form->{SM}{attachment};
@@ -1972,20 +1975,42 @@
 
 sub send_email {
 
-    $form->{OUT}       = "${LedgerSMB::Sysconfig::sendmail}";
-    $form->{printmode} = '|-';
-
     $form->{subject} = $locale->text( 'Statement - [_1]', $form->{todate} )
       unless $form->{subject};
     $form->isblank( "email", $locale->text('E-mail address missing!') );
 
-    RP->aging( \%myconfig, \%$form );
+    RP->aging( \%myconfig, $form );
 
-    &print_form;
+    my $data = &print_form;
 
+    delete $form->{header};
+    my $template = LedgerSMB::Template->new( 
+        user => \%myconfig,
+        template => $form->{'formname'} || $form->{'type'},
+        format => uc $form->{format},
+        method => 'email',
+        output_options => {
+            to => $form->{email},
+            cc => $form->{cc},
+            bcc => $form->{bcc},
+            from => $form->{form},
+            subject => $form->{subject},
+            message => $form->{message},
+            notify => $form->{read_receipt},
+            attach => ($form->{sendmode} eq 'attachment')? 1: 0,
+            },
+        );
+    try {
+        $template->render({data => [$data]});
+    }
+    catch Error::Simple with {
+        my $E = shift;
+        $form->error( $E->stacktrace );
+    };
     $form->redirect(
         $locale->text( 'Statement sent to [_1]', $form->{ $form->{ct} } ) );
 
+    exit;
 }
 
 sub print {


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