1 <& /elements/header-cust_main.html, view=>'payment_history', custnum=>$custnum &>
3 <h2>Invoice #<% $invnum %></h2>
5 % if ( !$cust_bill->closed ) { # otherwise allow no changes
6 % my $can_delete = $conf->exists('deleteinvoices')
7 % && $curuser->access_right('Delete invoices');
8 % my $can_void = $curuser->access_right('Void invoices');
10 <& /elements/popup_link.html,
11 'label' => emt('Void this invoice'),
12 'actionlabel' => emt('Void this invoice'),
13 'action' => $p.'misc/void-cust_bill.html?invnum='.$invnum,
16 % if ( $can_void and $can_delete ) {
19 % if ( $can_delete ) {
20 <A href="" onclick="areyousure(\
21 '<%$p%>misc/delete-cust_bill.html?<% $invnum %>',\
22 <% mt('Are you sure you want to delete this invoice?') |js_string %>)"\
23 TITLE = "<% mt('Delete this invoice from the database completely') |h %>">\
24 <% emt('Delete this invoice') |h %></A>
26 % if ( $can_void or $can_delete ) {
31 % if ( $cust_bill->owed > 0
32 % && $curuser->access_right(['Post payment', 'Post check payment', 'Post cash payment'])
33 % && ! $conf->exists('pkg-balances')
40 % if ( $curuser->access_right(['Post payment', 'Post check payment']) ) {
41 <% $s++ ? ' | ' : '' %>
42 <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>"><% mt('check') |h %></A>
45 % if ( $curuser->access_right(['Post payment', 'Post cash payment']) ) {
46 <% $s++ ? ' | ' : '' %>
47 <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>"><% mt('cash') |h %></A>
50 %# % if ( $payby{'WEST'} && $curuser->access_right(['Post payment']) ) {
51 %# <% $s++ ? ' | ' : '' %>
52 %# <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>"><% mt('Western Union') |h %></A>
55 %# % if ( $payby{'MCRD'} && $curuser->access_right(['Post payment']) ) {
56 %# <% $s++ ? ' | ' : '' %>
57 %# <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>"><% mt('manual credit card') |h %></A>
60 %# % if ( $payby{'MCHK'} && $curuser->access_right(['Post payment']) ) {
61 %# <% $s++ ? ' | ' : '' %>
62 %# <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCHK;invnum=<% $invnum %>"><% mt('manual electronic check') |h %></A>
65 <% mt('payment against this invoice') |h %><BR><BR>
69 % if ( $conf->exists('cust_bill-enable_promised_date') ) {
70 % my $onclick = include('/elements/popup_link_onclick.html',
71 % 'action' => $p.'misc/cust_bill-promised_date.html?'.$invnum,
72 % 'actionlabel' => emt('Set promised payment date'),
76 % $onclick = '<A HREF="#" onclick="'.$onclick.'">';
77 % if ( $cust_bill->promised_date ) {
78 % my $date_format = $conf->config('date_format') || '%b %o, %Y';
79 <% emt('Payment promised by [_1]',
80 time2str($date_format, $cust_bill->promised_date) ) %>
81 ( <% $onclick %><% mt('change') |h %></A> )
84 % elsif ( $cust_bill->owed > 0 ) {
85 <% $onclick %><% mt('Set promised payment date' ) |h %></A>
90 % if ( $curuser->access_right('Resend invoices') ) {
91 <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Print this invoice') |h %></A>
94 % if ( $conf->exists('support-key')
95 % && $curuser->access_right('Print and mail invoices')
98 | <& /elements/popup_link.html,
99 'action' => $p."misc/post_fsinc-invoice.cgi?$link",
100 'label' => 'Print and mail this invoice online',
101 'actionlabel' => 'Invoice printing and mailing',
105 % if ( $curuser->access_right('Resend invoices') ) {
107 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
108 | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A>
111 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
112 | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
117 % if ( $curuser->access_right('Resend invoices')
118 % || $curuser->access_right('Print and mail invoices') ) {
123 % if ( $conf->exists('invoice_latex') ) {
125 <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>"><% mt('View typeset invoice PDF') |h %></A>
130 % my @modes = grep {! $_->disabled}
131 % $cust_bill->cust_main->agent->invoice_modes;
132 % if ( @modes || $include_statement_template ) {
134 <% emt('View as:') %>
135 <FORM STYLE="display:inline" ACTION="<% $cgi->url %>" METHOD="GET">
136 <INPUT NAME="invnum" VALUE="<% $invnum %>" TYPE="hidden">
137 <& /elements/select-table.html,
138 table => 'invoice_mode',
140 curr_value => scalar($cgi->param('mode')),
142 name_col => 'modename',
143 onchange => 'change_invoice_mode',
144 empty_label => '(default)',
145 $include_statement_template ? (
146 'post_options' => [ 'statement', '(statement)' ]
149 <SCRIPT TYPE="text/javascript">
150 function change_invoice_mode(obj) {
157 % if ( $cust_bill->num_cust_event ) {
159 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>"><% mt('View invoice events') |h %></A>
162 % if ( $cust_bill->tax > 0 ) { # inefficient
164 <& /elements/popup_link.html,
165 'action' => 'cust_bill_tax_matrix.html?' . $cust_bill->invnum,
166 'label' => mt('View tax details'),
167 'actionlabel' => mt('Tax details'),
170 'title' => emt('Tax details'),
174 % if ( $cust_bill->taxengine_request ) { # inefficient
176 <& /elements/popup_link.html,
177 'action' => 'cust_bill-taxengine_request.html?invnum=' . $cust_bill->invnum,
178 'label' => mt('View raw tax engine request'),
179 'actionlabel' => mt('Tax engine request'),
182 'title' => emt('Tax engine request'),
189 % if ( $conf->exists('invoice_html') && ! $cgi->param('plaintext') ) {
190 <% join('', $cust_bill->print_html(\%opt) ) %>
192 <PRE><% join('', $cust_bill->print_text(\%opt) ) |h %></PRE>
195 <& /elements/footer-cust_main.html &>
198 my $curuser = $FS::CurrentUser::CurrentUser;
201 unless $curuser->access_right('View invoices');
203 my $conf = FS::Conf->new;
205 my( $invnum, $mode, $template, $notice_name, $no_coupon );
206 my($query) = $cgi->keywords;
207 if ( $query =~ /^((.+)-)?(\d+)$/ ) {
210 $notice_name = 'Invoice';
212 $invnum = $cgi->param('invnum');
213 $template = $cgi->param('template');
214 $notice_name = $cgi->param('notice_name');
215 $mode = $cgi->param('mode');
218 if ($mode eq 'statement') {
220 $template = 'statement';
221 $notice_name = 'Statement';
225 my $include_statement_template = $conf->config('payment_receipt_statement_mode') ? 0 : 1;
228 'unsquelch_cdr' => $conf->exists('voip-cdr_email'),
229 'template' => $template,
230 'notice_name' => $notice_name,
233 $opt{'barcode_img'} = 1 if $conf->exists('invoice-barcode');
235 my $cust_bill = qsearchs({
236 'select' => 'cust_bill.*',
237 'table' => 'cust_bill',
238 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
239 'hashref' => { 'invnum' => $invnum },
240 'extra_sql' => ' AND '. $curuser->agentnums_sql,
242 # if we're asked for a voided invnum, redirect appropriately
243 if (!$cust_bill and FS::cust_bill_void->row_exists("invnum = $invnum") ) {
245 my $url = $p.'view/cust_bill_void.html?'.$cgi->query_string;
246 $m->print( $cgi->redirect($url) );
249 die "Invoice #$invnum not found!" unless $cust_bill;
251 $cust_bill->set('mode' => $mode);
253 my $custnum = $cust_bill->custnum;
254 my $display_custnum = $cust_bill->cust_main->display_custnum;
256 my $link = "invnum=$invnum";
257 $link .= ';mode=' . $mode if $mode;
258 $link .= ';template='. uri_escape($template) if $template;
259 $link .= ';notice_name='. $notice_name if $notice_name;
260 $link .= ';no_coupon=1' if $no_coupon;