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') ) {
98 <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Print this invoice') |h %></A>
101 % if ( $curuser->access_right('Print and mail invoices') ) {
102 | <& /elements/popup_link.html,
103 'action' => $p."misc/post_fsinc-invoice.cgi?$link",
104 'label' => 'Print and mail this invoice online',
105 'actionlabel' => 'Invoice printing and mailing',
109 % if ( $curuser->access_right('Resend invoices') ) {
111 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
112 | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A>
115 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
116 | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
121 % if ( $curuser->access_right('Resend invoices')
122 % || $curuser->access_right('Print and mail invoices') ) {
127 % if ( $conf->exists('invoice_latex') ) {
129 <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>"><% mt('View typeset invoice PDF') |h %></A>
134 % if ( $cust_bill->num_cust_event ) {
136 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>"><% mt('View invoice events') |h %></A>
140 % my @modes = grep {! $_->disabled}
141 % $cust_bill->cust_main->agent->invoice_modes;
142 % if ( @modes || $include_statement_template ) {
145 <FORM STYLE="display:inline" ACTION="<% $cgi->url %>" METHOD="GET">
146 <INPUT NAME="invnum" VALUE="<% $invnum %>" TYPE="hidden">
147 <& /elements/select-table.html,
148 table => 'invoice_mode',
150 curr_value => scalar($cgi->param('mode')),
152 name_col => 'modename',
153 onchange => 'change_invoice_mode',
154 empty_label => '(default)',
155 $include_statement_template ? (
156 'post_options' => [ 'statement', '(statement)' ]
159 <SCRIPT TYPE="text/javascript">
160 function change_invoice_mode(obj) {
168 % if ( $conf->exists('invoice_html') && ! $cgi->param('plaintext') ) {
169 <% join('', $cust_bill->print_html(\%opt) ) %>
171 <PRE><% join('', $cust_bill->print_text(\%opt) ) |h %></PRE>
174 <& /elements/footer.html &>
177 my $curuser = $FS::CurrentUser::CurrentUser;
180 unless $curuser->access_right('View invoices');
182 my $conf = FS::Conf->new;
184 my( $invnum, $mode, $template, $notice_name, $no_coupon );
185 my($query) = $cgi->keywords;
186 if ( $query =~ /^((.+)-)?(\d+)$/ ) {
189 $notice_name = 'Invoice';
191 $invnum = $cgi->param('invnum');
192 $template = $cgi->param('template');
193 $notice_name = $cgi->param('notice_name');
194 $mode = $cgi->param('mode');
197 if ($mode eq 'statement') {
199 $template = 'statement';
200 $notice_name = 'Statement';
204 my $include_statement_template = $conf->config('payment_receipt_statement_mode') ? 0 : 1;
207 'unsquelch_cdr' => $conf->exists('voip-cdr_email'),
208 'template' => $template,
209 'notice_name' => $notice_name,
212 $opt{'barcode_img'} = 1 if $conf->exists('invoice-barcode');
214 my $cust_bill = qsearchs({
215 'select' => 'cust_bill.*',
216 'table' => 'cust_bill',
217 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
218 'hashref' => { 'invnum' => $invnum },
219 'extra_sql' => ' AND '. $curuser->agentnums_sql,
221 # if we're asked for a voided invnum, redirect appropriately
222 if (!$cust_bill and FS::cust_bill_void->row_exists("invnum = $invnum") ) {
224 my $url = $p.'view/cust_bill_void.html?'.$cgi->query_string;
225 $m->print( $cgi->redirect($url) );
228 die "Invoice #$invnum not found!" unless $cust_bill;
230 $cust_bill->set('mode' => $mode);
232 my $custnum = $cust_bill->custnum;
233 my $display_custnum = $cust_bill->cust_main->display_custnum;
235 my $link = "invnum=$invnum";
236 $link .= ';mode=' . $mode if $mode;
237 $link .= ';template='. uri_escape($template) if $template;
238 $link .= ';notice_name='. $notice_name if $notice_name;
239 $link .= ';no_coupon=1' if $no_coupon;