1 <& /elements/header.html, mt('Invoice View'), menubar(
2 emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
5 % if ( $conf->exists('deleteinvoices')
6 % && $curuser->access_right('Delete invoices' )
10 <SCRIPT TYPE="text/javascript">
11 function areyousure(href, message) {
12 if (confirm(message) == true)
13 window.location.href = href;
17 <A HREF = "javascript:areyousure(
18 '<%$p%>misc/delete-cust_bill.html?<% $invnum %>',
19 '<% mt('Are you sure you want to delete this invoice?') |h %>'
21 TITLE = "<% mt('Delete this invoice from the database completely') |h %>"
22 ><% mt('Delete this invoice') |h %></A>
27 % if ( $cust_bill->owed > 0
28 % && scalar( grep $payby{$_}, qw(BILL CASH WEST MCRD MCHK) )
29 % && $curuser->access_right(['Post payment', 'Post check payment', 'Post cash payment'])
30 % && ! $conf->exists('pkg-balances')
37 % if ( $payby{'BILL'} && $curuser->access_right(['Post payment', 'Post check payment']) ) {
38 <% $s++ ? ' | ' : '' %>
39 <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>"><% mt('check') |h %></A>
42 % if ( $payby{'CASH'} && $curuser->access_right(['Post payment', 'Post cash payment']) ) {
43 <% $s++ ? ' | ' : '' %>
44 <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>"><% mt('cash') |h %></A>
47 % if ( $payby{'WEST'} && $curuser->access_right(['Post payment']) ) {
48 <% $s++ ? ' | ' : '' %>
49 <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>"><% mt('Western Union') |h %></A>
52 % if ( $payby{'MCRD'} && $curuser->access_right(['Post payment']) ) {
53 <% $s++ ? ' | ' : '' %>
54 <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>"><% mt('manual credit card') |h %></A>
57 % if ( $payby{'MCHK'} && $curuser->access_right(['Post payment']) ) {
58 <% $s++ ? ' | ' : '' %>
59 <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCHK;invnum=<% $invnum %>"><% mt('manual electronic check') |h %></A>
62 <% mt('payment against this invoice') |h %><BR><BR>
66 % if ( $conf->exists('cust_bill-enable_promised_date') ) {
67 % my $onclick = include('/elements/popup_link_onclick.html',
68 % 'action' => $p.'misc/cust_bill-promised_date.html?'.$invnum,
69 % 'actionlabel' => emt('Set promised payment date'),
73 % $onclick = '<A HREF="#" onclick="'.$onclick.'">';
74 % if ( $cust_bill->promised_date ) {
75 % my $date_format = $conf->config('date_format') || '%b %o, %Y';
76 <% mt('Payment promised by [_1]',
77 time2str($date_format, $cust_bill->promised_date) ) %>
78 ( <% $onclick %><% mt('change') |h %></A> )
81 % elsif ( $cust_bill->owed > 0 ) {
82 <% $onclick %><% mt('Set promised payment date' ) |h %></A>
87 % if ( $curuser->access_right('Resend invoices') ) {
89 <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
91 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
92 | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A>
95 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
96 | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
103 % if ( $conf->exists('invoice_latex') ) {
105 <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>"><% mt('View typeset invoice PDF') |h %></A>
110 % if ( $cust_bill->num_cust_event ) { $br++;
111 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>">( <% mt('View invoice events') |h %> )</A>
114 % my @modes = grep {! $_->disabled}
115 % $cust_bill->cust_main->agent->invoice_modes;
117 ( <% mt('View as:') %>
118 <FORM STYLE="display:inline" ACTION="<% $cgi->url %>" METHOD="GET">
119 <INPUT NAME="invnum" VALUE="<% $invnum %>" TYPE="hidden">
120 <& /elements/select-table.html,
121 table => 'invoice_mode',
123 curr_value => scalar($cgi->param('mode')),
125 name_col => 'modename',
126 onchange => 'change_invoice_mode',
127 empty_label => '(default)',
129 <SCRIPT TYPE="text/javascript">
130 function change_invoice_mode(obj) {
137 <% $br ? '<BR><BR>' : '' %>
139 % if ( $conf->exists('invoice_html') && ! $cgi->param('plaintext') ) {
140 <% join('', $cust_bill->print_html(\%opt) ) %>
142 <PRE><% join('', $cust_bill->print_text(\%opt) ) |h %></PRE>
145 <& /elements/footer.html &>
148 my $curuser = $FS::CurrentUser::CurrentUser;
151 unless $curuser->access_right('View invoices');
153 my $conf = FS::Conf->new;
155 my( $invnum, $mode, $template, $notice_name );
156 my($query) = $cgi->keywords;
157 if ( $query =~ /^((.+)-)?(\d+)$/ ) {
160 $notice_name = 'Invoice';
162 $invnum = $cgi->param('invnum');
163 $template = $cgi->param('template');
164 $notice_name = $cgi->param('notice_name');
165 $mode = $cgi->param('mode');
169 'unsquelch_cdr' => $conf->exists('voip-cdr_email'),
170 'template' => $template,
171 'notice_name' => $notice_name,
174 $opt{'barcode_img'} = 1 if $conf->exists('invoice-barcode');
176 my @payby = grep /\w/, $conf->config('payby');
177 @payby = (qw( CARD DCRD CHEK DCHK BILL CASH ))
179 my %payby = map { $_=>1 } @payby;
181 my $cust_bill = qsearchs({
182 'select' => 'cust_bill.*',
183 'table' => 'cust_bill',
184 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
185 'hashref' => { 'invnum' => $invnum },
186 'extra_sql' => ' AND '. $curuser->agentnums_sql,
188 die "Invoice #$invnum not found!" unless $cust_bill;
190 $cust_bill->set('mode' => $mode);
192 my $custnum = $cust_bill->custnum;
193 my $display_custnum = $cust_bill->cust_main->display_custnum;
195 my $link = "invnum=$invnum";
196 $link .= ';mode=' . $mode if $mode;
197 $link .= ';template='. uri_escape($template) if $template;
198 $link .= ';notice_name='. $notice_name if $notice_name;