1 <& /elements/header.html, mt('Invoice View'), menubar(
2 emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
5 <SCRIPT TYPE="text/javascript">
6 function areyousure(href, message) {
7 if (confirm(message) == true)
8 window.location.href = href;
12 % if ( !$cust_bill->closed ) { # otherwise allow no changes
13 % my $can_delete = $conf->exists('deleteinvoices')
14 % && $curuser->access_right('Delete invoices');
15 % my $can_void = $curuser->access_right('Void invoices');
17 <& /elements/popup_link.html,
18 'label' => emt('Void this invoice'),
19 'actionlabel' => emt('Void this invoice'),
20 'action' => $p.'misc/void-cust_bill.html?invnum='.$invnum,
23 % if ( $can_void and $can_delete ) {
26 % if ( $can_delete ) {
27 <A href="" onclick="areyousure(\
28 '<%$p%>misc/delete-cust_bill.html?<% $invnum %>',\
29 <% mt('Are you sure you want to delete this invoice?') |js_string %>)"\
30 TITLE = "<% mt('Delete this invoice from the database completely') |h %>">\
31 <% emt('Delete this invoice') |h %></A>
33 % if ( $can_void or $can_delete ) {
38 % if ( $cust_bill->owed > 0
39 % && $curuser->access_right(['Post payment', 'Post check payment', 'Post cash payment'])
40 % && ! $conf->exists('pkg-balances')
47 % if ( $curuser->access_right(['Post payment', 'Post check payment']) ) {
48 <% $s++ ? ' | ' : '' %>
49 <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>"><% mt('check') |h %></A>
52 % if ( $curuser->access_right(['Post payment', 'Post cash payment']) ) {
53 <% $s++ ? ' | ' : '' %>
54 <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>"><% mt('cash') |h %></A>
57 %# % if ( $payby{'WEST'} && $curuser->access_right(['Post payment']) ) {
58 %# <% $s++ ? ' | ' : '' %>
59 %# <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>"><% mt('Western Union') |h %></A>
62 %# % if ( $payby{'MCRD'} && $curuser->access_right(['Post payment']) ) {
63 %# <% $s++ ? ' | ' : '' %>
64 %# <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>"><% mt('manual credit card') |h %></A>
67 %# % if ( $payby{'MCHK'} && $curuser->access_right(['Post payment']) ) {
68 %# <% $s++ ? ' | ' : '' %>
69 %# <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCHK;invnum=<% $invnum %>"><% mt('manual electronic check') |h %></A>
72 <% mt('payment against this invoice') |h %><BR><BR>
76 % if ( $conf->exists('cust_bill-enable_promised_date') ) {
77 % my $onclick = include('/elements/popup_link_onclick.html',
78 % 'action' => $p.'misc/cust_bill-promised_date.html?'.$invnum,
79 % 'actionlabel' => emt('Set promised payment date'),
83 % $onclick = '<A HREF="#" onclick="'.$onclick.'">';
84 % if ( $cust_bill->promised_date ) {
85 % my $date_format = $conf->config('date_format') || '%b %o, %Y';
86 <% mt('Payment promised by [_1]',
87 time2str($date_format, $cust_bill->promised_date) ) %>
88 ( <% $onclick %><% mt('change') |h %></A> )
91 % elsif ( $cust_bill->owed > 0 ) {
92 <% $onclick %><% mt('Set promised payment date' ) |h %></A>
97 % if ( $curuser->access_right('Resend invoices') ) {
99 <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
101 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
102 | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A>
105 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
106 | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
114 % if ( $conf->exists('invoice_latex') ) {
116 <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>"><% mt('View typeset invoice PDF') |h %></A>
121 % if ( $cust_bill->num_cust_event ) {
123 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>"><% mt('View invoice events') |h %></A>
127 % my @modes = grep {! $_->disabled}
128 % $cust_bill->cust_main->agent->invoice_modes;
129 % if ( @modes || $include_statement_template ) {
132 <FORM STYLE="display:inline" ACTION="<% $cgi->url %>" METHOD="GET">
133 <INPUT NAME="invnum" VALUE="<% $invnum %>" TYPE="hidden">
134 <& /elements/select-table.html,
135 table => 'invoice_mode',
137 curr_value => scalar($cgi->param('mode')),
139 name_col => 'modename',
140 onchange => 'change_invoice_mode',
141 empty_label => '(default)',
142 $include_statement_template ? (
143 'post_options' => [ 'statement', '(statement)' ]
146 <SCRIPT TYPE="text/javascript">
147 function change_invoice_mode(obj) {
155 % if ( $conf->exists('invoice_html') && ! $cgi->param('plaintext') ) {
156 <% join('', $cust_bill->print_html(\%opt) ) %>
158 <PRE><% join('', $cust_bill->print_text(\%opt) ) |h %></PRE>
161 <& /elements/footer.html &>
164 my $curuser = $FS::CurrentUser::CurrentUser;
167 unless $curuser->access_right('View invoices');
169 my $conf = FS::Conf->new;
171 my( $invnum, $mode, $template, $notice_name, $no_coupon );
172 my($query) = $cgi->keywords;
173 if ( $query =~ /^((.+)-)?(\d+)$/ ) {
176 $notice_name = 'Invoice';
178 $invnum = $cgi->param('invnum');
179 $template = $cgi->param('template');
180 $notice_name = $cgi->param('notice_name');
181 $mode = $cgi->param('mode');
184 if ($mode eq 'statement') {
186 $template = 'statement';
187 $notice_name = 'Statement';
191 my $include_statement_template = $conf->config('payment_receipt_statement_mode') ? 0 : 1;
194 'unsquelch_cdr' => $conf->exists('voip-cdr_email'),
195 'template' => $template,
196 'notice_name' => $notice_name,
199 $opt{'barcode_img'} = 1 if $conf->exists('invoice-barcode');
201 my $cust_bill = qsearchs({
202 'select' => 'cust_bill.*',
203 'table' => 'cust_bill',
204 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
205 'hashref' => { 'invnum' => $invnum },
206 'extra_sql' => ' AND '. $curuser->agentnums_sql,
208 # if we're asked for a voided invnum, redirect appropriately
209 if (!$cust_bill and FS::cust_bill_void->row_exists("invnum = $invnum") ) {
211 my $url = $p.'view/cust_bill_void.html?'.$cgi->query_string;
212 $m->print( $cgi->redirect($url) );
215 die "Invoice #$invnum not found!" unless $cust_bill;
217 $cust_bill->set('mode' => $mode);
219 my $custnum = $cust_bill->custnum;
220 my $display_custnum = $cust_bill->cust_main->display_custnum;
222 my $link = "invnum=$invnum";
223 $link .= ';mode=' . $mode if $mode;
224 $link .= ';template='. uri_escape($template) if $template;
225 $link .= ';notice_name='. $notice_name if $notice_name;
226 $link .= ';no_coupon=1' if $no_coupon;