statement link display by default, better label, statements say "statement" and have...
authorIvan Kohler <ivan@freeside.biz>
Thu, 16 May 2013 20:31:08 +0000 (13:31 -0700)
committerIvan Kohler <ivan@freeside.biz>
Thu, 16 May 2013 20:31:08 +0000 (13:31 -0700)
FS/FS/Conf.pm
FS/FS/Template_Mixin.pm
httemplate/view/cust_main/payment_history.html
httemplate/view/cust_main_statement-pdf.cgi

index 0784cd0..3dffa45 100644 (file)
@@ -5236,13 +5236,6 @@ and customer address. Include units.',
     'select_enum' => [ 'Classic', 'Recurring' ],
   },
 
     'select_enum' => [ 'Classic', 'Recurring' ],
   },
 
-  {
-    'key'         => 'cust_main-print_statement_link',
-    'section'     => 'UI',
-    'description' => 'Show a link to download a current statement for the customer.',
-    'type'        => 'checkbox',
-  },
-
   { 
     'key'         => 'username-pound',
     'section'     => 'username',
   { 
     'key'         => 'username-pound',
     'section'     => 'username',
index b3d3cf2..be9d68a 100644 (file)
@@ -106,7 +106,7 @@ sub print_latex {
   $params{'time'} = $today if $today;
   $params{'template'} = $template if $template;
   $params{$_} = $opt{$_} 
   $params{'time'} = $today if $today;
   $params{'template'} = $template if $template;
   $params{$_} = $opt{$_} 
-    foreach grep $opt{$_}, qw( unsquelch_cdr notice_name );
+    foreach grep $opt{$_}, qw( unsquelch_cdr notice_name no_date no_number );
 
   $template ||= $self->_agent_template
     if $self->can('_agent_template');
 
   $template ||= $self->_agent_template
     if $self->can('_agent_template');
@@ -445,9 +445,14 @@ sub print_generic {
     'agent'           => &$escape_function($cust_main->agent->agent),
 
     #invoice/quotation info
     'agent'           => &$escape_function($cust_main->agent->agent),
 
     #invoice/quotation info
-    'invnum'          => $self->invnum,
+    'no_number'       => $params{'no_number'},
+    'invnum'          => ( $params{'no_number'} ? '' : $self->invnum ),
     'quotationnum'    => $self->quotationnum,
     'quotationnum'    => $self->quotationnum,
-    'date'            => time2str($date_format, $self->_date),
+    'no_date'         => $params{'no_date'},
+    'date'            => ( $params{'no_date'}
+                             ? ''
+                             : time2str($date_format, $self->_date)
+                         ),
     'today'           => time2str($date_format_long, $today),
     'terms'           => $self->terms,
     'template'        => $template, #params{'template'},
     'today'           => time2str($date_format_long, $today),
     'terms'           => $self->terms,
     'template'        => $template, #params{'template'},
index 915be49..c7bf374 100644 (file)
 
 %# invoice reports, combined statement
 % if ( $curuser->access_right('List invoices') ) { 
 
 %# invoice reports, combined statement
 % if ( $curuser->access_right('List invoices') ) { 
-%   if ( $conf->exists('cust_main-print_statement_link')
-%        and $num_cust_bill > 0 ) {
+%   if ( $num_cust_bill > 0 ) {
   <A HREF="<% $p %>view/cust_main_statement-pdf.cgi?<% $custnum %>"><%
   <A HREF="<% $p %>view/cust_main_statement-pdf.cgi?<% $custnum %>"><%
-  mt('Print a current statement') |h %></A>
+  mt('Download typeset statement PDF') |h %></A>
   <BR>
 %   }
   <A HREF="<% $p %>search/report_cust_bill.html?custnum=<% $custnum %>"><% mt('Invoice reports') |h %></A>
   <BR>
 %   }
   <A HREF="<% $p %>search/report_cust_bill.html?custnum=<% $custnum %>"><% mt('Invoice reports') |h %></A>
index 7c2c207..79110ee 100755 (executable)
@@ -1,29 +1,34 @@
+<% $pdf %>\
 <%doc>
 Like view/cust_statement-pdf.cgi, but for viewing/printing the implicit 
 statement containing all of a customer's invoices.  Slightly redundant.
 I don't see the need to create an equivalent to view/cust_statement.html 
 for this case, but one can be added if necessary.
 </%doc>
 <%doc>
 Like view/cust_statement-pdf.cgi, but for viewing/printing the implicit 
 statement containing all of a customer's invoices.  Slightly redundant.
 I don't see the need to create an equivalent to view/cust_statement.html 
 for this case, but one can be added if necessary.
 </%doc>
-<% $pdf %>
 <%init>
 
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
 
 <%init>
 
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
 
-#untaint statement
 my($query) = $cgi->keywords;
 my($query) = $cgi->keywords;
-$query =~ /^((.+)-)?(\d+)$/;
-my $templatename = $2 || 'statement'; #XXX configure... via event??  eh..
-my $custnum = $3;
+$query =~ /^(\d+)$/;
+my $custnum = $1;
 
 
+#mostly for the agent-virt, i guess.  could probably bolt it onto the cust_bill
+# search
 my $cust_main = qsearchs({
   'select'    => 'cust_main.*',
   'table'     => 'cust_main',
   'hashref'   => { 'custnum' => $custnum },
   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
 my $cust_main = qsearchs({
   'select'    => 'cust_main.*',
   'table'     => 'cust_main',
   'hashref'   => { 'custnum' => $custnum },
   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
-});
-die "Customer #$custnum not found!" unless $cust_main;
-my $cust_bill = ($cust_main->cust_bill)[-1]
+})
+  or die "Customer #$custnum not found!";
+
+my $cust_bill = qsearchs({
+  'table'    => 'cust_bill',
+  'hashref'  => { 'custnum' => $custnum },
+  'order_by' => 'ORDER BY _date desc LIMIT 1',
+})
   or die "Customer #$custnum has no invoices!";
 
 my $cust_statement = FS::cust_statement->new({
   or die "Customer #$custnum has no invoices!";
 
 my $cust_statement = FS::cust_statement->new({
@@ -33,11 +38,14 @@ my $cust_statement = FS::cust_statement->new({
   '_date'         => time,
 });
 
   '_date'         => time,
 });
 
+my $pdf = $cust_statement->print_pdf({
+  'notice_name' => 'Statement',
+  'no_date'     => 1,
+  'no_number'   => 1,
+});
 
 
-my $pdf = $cust_statement->print_pdf( '', $templatename );
-
-http_header('Content-Type' => 'application/pdf' );
+http_header('Content-Type'   => 'application/pdf' );
 http_header('Content-Length' => length($pdf) );
 http_header('Content-Length' => length($pdf) );
-http_header('Cache-control' => 'max-age=60' );
+http_header('Cache-control'  => 'max-age=60' );
 
 </%init>
 
 </%init>