remove obsolete usage of payby config, western union payments, etc., RT#23741
[freeside.git] / httemplate / view / cust_bill.cgi
1 <& /elements/header.html, mt('Invoice View'), menubar(
2   emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
3 ) &>
4
5 <SCRIPT TYPE="text/javascript">
6 function areyousure(href, message) {
7   if (confirm(message) == true)
8     window.location.href = href;
9 }
10 </SCRIPT>
11
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,
17     &>
18     <BR><BR>
19 % }
20
21 % if ( $cust_bill->owed > 0
22 %      && $curuser->access_right(['Post payment', 'Post check payment', 'Post cash payment'])
23 %      && ! $conf->exists('pkg-balances')
24 %    )
25 % {
26 %     my $s = 0;
27
28       <% mt('Post') |h %> 
29
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>
33 %     } 
34
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>
38 %     } 
39
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>
43 %#  %     } 
44 %#  
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>
48 %#  %     } 
49 %#  
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>
53 %#  %     } 
54
55       <% mt('payment against this invoice') |h %><BR><BR>
56
57 % } 
58
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'),
63 %      'width'       => 320,
64 %      'height'      => 240,
65 %   );
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       (&nbsp;<% $onclick %><% mt('change') |h %></A>&nbsp;)
72       <BR><BR>
73 %   }
74 %   elsif ( $cust_bill->owed > 0 ) {
75     <% $onclick %><% mt('Set promised payment date' ) |h %></A>
76     <BR><BR>
77 %   }
78 % }
79
80 % if ( $curuser->access_right('Resend invoices') ) {
81
82     <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
83
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>
86 %   } 
87
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>
90 %   } 
91
92     <BR><BR>
93
94 % } 
95
96 % if ( $conf->exists('invoice_latex') ) { 
97
98   <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>"><% mt('View typeset invoice PDF') |h %></A>
99   <BR><BR>
100 % } 
101
102 % my $br = 0;
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> 
105 % }
106
107 % my @modes = grep {! $_->disabled} 
108 %   $cust_bill->cust_main->agent->invoice_modes;
109 % if ( @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',
115   field       => 'mode',
116   curr_value  => scalar($cgi->param('mode')),
117   records     => \@modes,
118   name_col    => 'modename',
119   onchange    => 'change_invoice_mode',
120   empty_label => '(default)',
121 &> )
122 <SCRIPT TYPE="text/javascript">
123 function change_invoice_mode(obj) {
124   obj.form.submit();
125 }
126 </SCRIPT>
127 % $br++;
128 % }
129
130 <% $br ? '<BR><BR>' : '' %>
131
132 % if ( $conf->exists('invoice_html') && ! $cgi->param('plaintext') ) { 
133   <% join('', $cust_bill->print_html(\%opt) ) %>
134 % } else { 
135   <PRE><% join('', $cust_bill->print_text(\%opt) ) |h %></PRE>
136 % } 
137
138 <& /elements/footer.html &>
139 <%init>
140
141 my $curuser = $FS::CurrentUser::CurrentUser;
142
143 die "access denied"
144   unless $curuser->access_right('View invoices');
145
146 my $conf = FS::Conf->new;
147
148 my( $invnum, $mode, $template, $notice_name );
149 my($query) = $cgi->keywords;
150 if ( $query =~ /^((.+)-)?(\d+)$/ ) {
151   $template = $2;
152   $invnum = $3;
153   $notice_name = 'Invoice';
154 } else {
155   $invnum = $cgi->param('invnum');
156   $template = $cgi->param('template');
157   $notice_name = $cgi->param('notice_name');
158   $mode = $cgi->param('mode');
159 }
160
161 my %opt = (
162   'unsquelch_cdr' => $conf->exists('voip-cdr_email'),
163   'template'      => $template,
164   'notice_name'   => $notice_name,
165 );
166
167 $opt{'barcode_img'} = 1 if $conf->exists('invoice-barcode');
168
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,
175 });
176 # if we're asked for a voided invnum, redirect appropriately
177 if (!$cust_bill and FS::cust_bill_void->row_exists("invnum = $invnum") ) {
178   $m->clear_buffer;
179   my $url = $p.'view/cust_bill_void.html?'.$cgi->query_string;
180   $m->print( $cgi->redirect($url) );
181   $m->abort;
182 }
183 die "Invoice #$invnum not found!" unless $cust_bill;
184
185 $cust_bill->set('mode' => $mode);
186
187 my $custnum = $cust_bill->custnum;
188 my $display_custnum = $cust_bill->cust_main->display_custnum;
189
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;
194
195 </%init>