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 % && scalar( grep $payby{$_}, qw(BILL CASH WEST MCRD MCHK) )
40 % && $curuser->access_right(['Post payment', 'Post check payment', 'Post cash payment'])
41 % && ! $conf->exists('pkg-balances')
48 % if ( $payby{'BILL'} && $curuser->access_right(['Post payment', 'Post check payment']) ) {
49 <% $s++ ? ' | ' : '' %>
50 <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>"><% mt('check') |h %></A>
53 % if ( $payby{'CASH'} && $curuser->access_right(['Post payment', 'Post cash payment']) ) {
54 <% $s++ ? ' | ' : '' %>
55 <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>"><% mt('cash') |h %></A>
58 % if ( $payby{'WEST'} && $curuser->access_right(['Post payment']) ) {
59 <% $s++ ? ' | ' : '' %>
60 <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>"><% mt('Western Union') |h %></A>
63 % if ( $payby{'MCRD'} && $curuser->access_right(['Post payment']) ) {
64 <% $s++ ? ' | ' : '' %>
65 <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>"><% mt('manual credit card') |h %></A>
68 % if ( $payby{'MCHK'} && $curuser->access_right(['Post payment']) ) {
69 <% $s++ ? ' | ' : '' %>
70 <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCHK;invnum=<% $invnum %>"><% mt('manual electronic check') |h %></A>
73 <% mt('payment against this invoice') |h %><BR><BR>
77 % if ( $conf->exists('cust_bill-enable_promised_date') ) {
78 % my $onclick = include('/elements/popup_link_onclick.html',
79 % 'action' => $p.'misc/cust_bill-promised_date.html?'.$invnum,
80 % 'actionlabel' => emt('Set promised payment date'),
84 % $onclick = '<A HREF="#" onclick="'.$onclick.'">';
85 % if ( $cust_bill->promised_date ) {
86 % my $date_format = $conf->config('date_format') || '%b %o, %Y';
87 <% mt('Payment promised by [_1]',
88 time2str($date_format, $cust_bill->promised_date) ) %>
89 ( <% $onclick %><% mt('change') |h %></A> )
92 % elsif ( $cust_bill->owed > 0 ) {
93 <% $onclick %><% mt('Set promised payment date' ) |h %></A>
98 % if ( $curuser->access_right('Resend invoices') ) {
100 <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
102 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
103 | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A>
106 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
107 | <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 ) { $br++;
122 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>">( <% mt('View invoice events') |h %> )</A>
125 % my @modes = grep {! $_->disabled}
126 % $cust_bill->cust_main->agent->invoice_modes;
128 ( <% mt('View as:') %>
129 <FORM STYLE="display:inline" ACTION="<% $cgi->url %>" METHOD="GET">
130 <INPUT NAME="invnum" VALUE="<% $invnum %>" TYPE="hidden">
131 <& /elements/select-table.html,
132 table => 'invoice_mode',
134 curr_value => scalar($cgi->param('mode')),
136 name_col => 'modename',
137 onchange => 'change_invoice_mode',
138 empty_label => '(default)',
140 <SCRIPT TYPE="text/javascript">
141 function change_invoice_mode(obj) {
148 <% $br ? '<BR><BR>' : '' %>
150 % if ( $conf->exists('invoice_html') && ! $cgi->param('plaintext') ) {
151 <% join('', $cust_bill->print_html(\%opt) ) %>
153 <PRE><% join('', $cust_bill->print_text(\%opt) ) |h %></PRE>
156 <& /elements/footer.html &>
159 my $curuser = $FS::CurrentUser::CurrentUser;
162 unless $curuser->access_right('View invoices');
164 my $conf = FS::Conf->new;
166 my( $invnum, $mode, $template, $notice_name );
167 my($query) = $cgi->keywords;
168 if ( $query =~ /^((.+)-)?(\d+)$/ ) {
171 $notice_name = 'Invoice';
173 $invnum = $cgi->param('invnum');
174 $template = $cgi->param('template');
175 $notice_name = $cgi->param('notice_name');
176 $mode = $cgi->param('mode');
180 'unsquelch_cdr' => $conf->exists('voip-cdr_email'),
181 'template' => $template,
182 'notice_name' => $notice_name,
185 $opt{'barcode_img'} = 1 if $conf->exists('invoice-barcode');
187 my @payby = grep /\w/, $conf->config('payby');
188 @payby = (qw( CARD DCRD CHEK DCHK BILL CASH ))
190 my %payby = map { $_=>1 } @payby;
192 my $cust_bill = qsearchs({
193 'select' => 'cust_bill.*',
194 'table' => 'cust_bill',
195 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
196 'hashref' => { 'invnum' => $invnum },
197 'extra_sql' => ' AND '. $curuser->agentnums_sql,
199 # if we're asked for a voided invnum, redirect appropriately
200 if (!$cust_bill and FS::cust_bill_void->row_exists("invnum = $invnum") ) {
202 my $url = $p.'view/cust_bill_void.html?'.$cgi->query_string;
203 $m->print( $cgi->redirect($url) );
206 die "Invoice #$invnum not found!" unless $cust_bill;
208 $cust_bill->set('mode' => $mode);
210 my $custnum = $cust_bill->custnum;
211 my $display_custnum = $cust_bill->cust_main->display_custnum;
213 my $link = "invnum=$invnum";
214 $link .= ';mode=' . $mode if $mode;
215 $link .= ';template='. uri_escape($template) if $template;
216 $link .= ';notice_name='. $notice_name if $notice_name;