From fc263806f5e475559a0c4cfdb70a5f1cefe0ffa3 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 27 May 2020 13:39:47 -0700 Subject: deposit slips --- httemplate/search/elements/grouped-search.html | 2 +- httemplate/search/elements/grouped-search/deposit_slip | 8 ++++++++ httemplate/search/elements/grouped-search/html | 6 +++++- httemplate/search/elements/search-deposit_slip.html | 17 +++++++++++++++++ httemplate/search/elements/search.html | 9 +++++++-- 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 httemplate/search/elements/grouped-search/deposit_slip create mode 100644 httemplate/search/elements/search-deposit_slip.html (limited to 'httemplate/search') diff --git a/httemplate/search/elements/grouped-search.html b/httemplate/search/elements/grouped-search.html index 56fc88d38..80a931983 100644 --- a/httemplate/search/elements/grouped-search.html +++ b/httemplate/search/elements/grouped-search.html @@ -42,7 +42,7 @@ <%init> my $type = 'html'; -if ($cgi->param('type') =~ /^(html|html-print|xls)$/) { +if ($cgi->param('type') =~ /^(html|html-print|xls|deposit_slip)$/) { $type = $1; } diff --git a/httemplate/search/elements/grouped-search/deposit_slip b/httemplate/search/elements/grouped-search/deposit_slip new file mode 100644 index 000000000..6e69662c4 --- /dev/null +++ b/httemplate/search/elements/grouped-search/deposit_slip @@ -0,0 +1,8 @@ +<& /search/elements/search-deposit_slip.html, rows=>\@rows, &>\ +<%init> +my %opt = @_; +my $group_info = $m->comp('core', %opt); +#just the first group +my $query = $group_info->{queries}[0]; +my @rows = $query->qsearch; + diff --git a/httemplate/search/elements/grouped-search/html b/httemplate/search/elements/grouped-search/html index ae8086512..24cf50e96 100644 --- a/httemplate/search/elements/grouped-search/html +++ b/httemplate/search/elements/grouped-search/html @@ -114,9 +114,13 @@ my $money = $conf->config('money_char') || '$'; %# download links

<% emt('Download results:') %> % $cgi->param('type', 'xls'); -<% emt('Spreadsheet') %> |  +<% emt('Spreadsheet') %> | % $cgi->param('type', 'html-print'); <% emt('webpage') %> +% if ( ref($query) && $query->{table} eq 'cust_pay' ) { +% $cgi->param('type', 'deposit_slip'); + | <% emt('deposit slip') %> +% } % $cgi->delete('type');

% } diff --git a/httemplate/search/elements/search-deposit_slip.html b/httemplate/search/elements/search-deposit_slip.html new file mode 100644 index 000000000..c7a6cbb18 --- /dev/null +++ b/httemplate/search/elements/search-deposit_slip.html @@ -0,0 +1,17 @@ +<% $deposit_pdf %>\ +<%init> + +my %args = @_; +my $rows = $args{'rows'}; + +my $deposit_pdf = deposit_slip_pdf( + conf => FS::Conf->new, + cust_pay => $rows, +); + +http_header('Content-Type' => 'application/pdf'); +http_header('Content-Disposition' => "filename=deposit.pdf" ); +http_header('Content-Length' => length($deposit_pdf) ); +http_header('Cache-control' => 'max-age=60' ); + + diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 730a51aa3..60548e28e 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -198,6 +198,10 @@ Example: % <% include('search-xml.html', rows=>$rows, opt=>\%opt ) %> % +% } elsif ( $type eq 'deposit_slip' ) { +% +<% include('search-deposit_slip.html', rows=>$rows, opt=>\%opt ) %> +% % } else { % <% include('search-html.html', @@ -224,8 +228,9 @@ my $curuser = $FS::CurrentUser::CurrentUser; $m->comp('/elements/handle_uri_query'); -my $type = $cgi->param('_type') =~ /^(csv|\w*\.xls|xml|select|html(-print)?)$/ - ? $1 : 'html' ; +my $type = $cgi->param('_type') + =~ /^(csv|\w*\.xls|xml|select|html(-print)?|deposit_slip)$/ + ? $1 : 'html' ; if ( !$curuser->access_right('Download report data') ) { $opt{'disable_download'} = 1; -- cgit v1.2.1