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 && $curuser->access_right('Void invoices') ) {
13 <& /elements/popup_link.html,
14 'label' => emt('Void this invoice'),
15 'actionlabel' => emt('Void this invoice'),
16 'action' => $p.'misc/void-cust_bill.html?invnum='.$invnum,
21 % if ( $cust_bill->owed > 0
22 % && $curuser->access_right(['Post payment', 'Post check payment', 'Post cash payment'])
23 % && ! $conf->exists('pkg-balances')
30 % if ( $curuser->access_right(['Post payment', 'Post check payment']) ) {
31 <% $s++ ? ' | ' : '' %>
32 <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>"><% mt('check') |h %></A>
35 % if ( $curuser->access_right(['Post payment', 'Post cash payment']) ) {
36 <% $s++ ? ' | ' : '' %>
37 <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>"><% mt('cash') |h %></A>
40 %# % if ( $payby{'WEST'} && $curuser->access_right(['Post payment']) ) {
41 %# <% $s++ ? ' | ' : '' %>
42 %# <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>"><% mt('Western Union') |h %></A>
45 %# % if ( $payby{'MCRD'} && $curuser->access_right(['Post payment']) ) {
46 %# <% $s++ ? ' | ' : '' %>
47 %# <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>"><% mt('manual credit card') |h %></A>
50 %# % if ( $payby{'MCHK'} && $curuser->access_right(['Post payment']) ) {
51 %# <% $s++ ? ' | ' : '' %>
52 %# <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCHK;invnum=<% $invnum %>"><% mt('manual electronic check') |h %></A>
55 <% mt('payment against this invoice') |h %><BR><BR>
59 % if ( $conf->exists('cust_bill-enable_promised_date') ) {
60 % my $onclick = include('/elements/popup_link_onclick.html',
61 % 'action' => $p.'misc/cust_bill-promised_date.html?'.$invnum,
62 % 'actionlabel' => emt('Set promised payment date'),
66 % $onclick = '<A HREF="#" onclick="'.$onclick.'">';
67 % if ( $cust_bill->promised_date ) {
68 % my $date_format = $conf->config('date_format') || '%b %o, %Y';
69 <% mt('Payment promised by [_1]',
70 time2str($date_format, $cust_bill->promised_date) ) %>
71 ( <% $onclick %><% mt('change') |h %></A> )
74 % elsif ( $cust_bill->owed > 0 ) {
75 <% $onclick %><% mt('Set promised payment date' ) |h %></A>
80 % if ( $curuser->access_right('Resend invoices') ) {
82 <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
84 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
85 | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A>
88 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
89 | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
96 % if ( $conf->exists('invoice_latex') ) {
98 <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>"><% mt('View typeset invoice PDF') |h %></A>
103 % if ( $cust_bill->num_cust_event ) { $br++;
104 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>">( <% mt('View invoice events') |h %> )</A>
107 % my @modes = grep {! $_->disabled}
108 % $cust_bill->cust_main->agent->invoice_modes;
110 ( <% mt('View as:') %>
111 <FORM STYLE="display:inline" ACTION="<% $cgi->url %>" METHOD="GET">
112 <INPUT NAME="invnum" VALUE="<% $invnum %>" TYPE="hidden">
113 <& /elements/select-table.html,
114 table => 'invoice_mode',
116 curr_value => scalar($cgi->param('mode')),
118 name_col => 'modename',
119 onchange => 'change_invoice_mode',
120 empty_label => '(default)',
122 <SCRIPT TYPE="text/javascript">
123 function change_invoice_mode(obj) {
130 <% $br ? '<BR><BR>' : '' %>
132 % if ( $conf->exists('invoice_html') && ! $cgi->param('plaintext') ) {
133 <% join('', $cust_bill->print_html(\%opt) ) %>
135 <PRE><% join('', $cust_bill->print_text(\%opt) ) |h %></PRE>
138 <& /elements/footer.html &>
141 my $curuser = $FS::CurrentUser::CurrentUser;
144 unless $curuser->access_right('View invoices');
146 my $conf = FS::Conf->new;
148 my( $invnum, $mode, $template, $notice_name );
149 my($query) = $cgi->keywords;
150 if ( $query =~ /^((.+)-)?(\d+)$/ ) {
153 $notice_name = 'Invoice';
155 $invnum = $cgi->param('invnum');
156 $template = $cgi->param('template');
157 $notice_name = $cgi->param('notice_name');
158 $mode = $cgi->param('mode');
162 'unsquelch_cdr' => $conf->exists('voip-cdr_email'),
163 'template' => $template,
164 'notice_name' => $notice_name,
167 $opt{'barcode_img'} = 1 if $conf->exists('invoice-barcode');
169 my $cust_bill = qsearchs({
170 'select' => 'cust_bill.*',
171 'table' => 'cust_bill',
172 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
173 'hashref' => { 'invnum' => $invnum },
174 'extra_sql' => ' AND '. $curuser->agentnums_sql,
176 # if we're asked for a voided invnum, redirect appropriately
177 if (!$cust_bill and FS::cust_bill_void->row_exists("invnum = $invnum") ) {
179 my $url = $p.'view/cust_bill_void.html?'.$cgi->query_string;
180 $m->print( $cgi->redirect($url) );
183 die "Invoice #$invnum not found!" unless $cust_bill;
185 $cust_bill->set('mode' => $mode);
187 my $custnum = $cust_bill->custnum;
188 my $display_custnum = $cust_bill->cust_main->display_custnum;
190 my $link = "invnum=$invnum";
191 $link .= ';mode=' . $mode if $mode;
192 $link .= ';template='. uri_escape($template) if $template;
193 $link .= ';notice_name='. $notice_name if $notice_name;