invoice_sections_with_taxes per-agent, RT#79636
[freeside.git] / httemplate / view / cust_main.cgi
1 <& /elements/header-cust_main.html, view=>$view, cust_main=>$cust_main &>
2
3 % ###
4 % # Basics
5 % ###
6
7 % if ( $view eq 'basics' ) {
8
9 % my $br = 0;
10
11 % if ( $conf->config('cust_main-external_links') ) {
12     <% $br++ ? ' | ' : '' %>
13 %   my @links = split(/\n/, $conf->config('cust_main-external_links'));
14 %   foreach my $link (@links) {
15 %     $link =~ /^\s*(\S+)\s+(.*?)(\s*\(([^\)]*)\))?$/ or next;
16 %     my($url, $label, $alt) = ($1, $2, $4);
17       <A HREF="<% $url.$custnum %>" ALT="<% $alt |h %>"><% $label |h %></A>
18 %   }
19 % }
20
21 % if ( $br ) {
22   <BR><BR>
23 % }
24
25 %my $signupurl = $conf->config('signupurl');
26 %if ( $signupurl ) {
27   <% mt('This customer\'s signup URL:') |h %>
28   <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A>
29   <BR><BR>
30 % } 
31
32 <TABLE BORDER=0>
33 <TR>
34   <TD VALIGN="top">
35     <& cust_main/contacts.html, $cust_main &>
36     <BR>
37     <& cust_main/misc.html, $cust_main &>
38   </TD>
39   <TD VALIGN="top" STYLE="padding-left: 54px">
40     <& cust_main/billing.html, $cust_main &>
41     <BR>
42     <& cust_main/cust_payby.html, $cust_main &>
43   </TD>
44 </TR>
45 <TR>
46   <TD COLSPAN = 2>
47     <& cust_main/contacts_new.html, $cust_main &>
48   </TD>
49 </TR>
50 </TABLE>
51 <BR>
52
53 % }
54
55
56 % ###
57 % # Notes
58 % ###
59 % if ( $view eq 'notes' ) {
60   <& cust_main/notes.html, 'cust_main' => $cust_main &>
61   <BR>
62 % }
63
64
65 % ###
66 % # Tickets
67 % ###
68
69 % if ( $view eq 'tickets' ) {
70
71 % if ( $conf->config('ticket_system') ) { 
72   <& cust_main/tickets.html, $cust_main &>
73 % } 
74   <BR>
75
76 % }
77
78 % ###
79 % # Appointments
80 % ###
81
82 % if ( $view eq 'appointments' ) {
83
84 % if ( $conf->config('ticket_system')
85 %        && $curuser->access_right('View appointments') ) { 
86   <& cust_main/appointments.html, $cust_main &>
87 % } 
88   <BR>
89
90 % }
91
92
93 % ###
94 % # Quotations
95 % ###
96
97 % if ( $view eq 'quotations' ) {
98
99 %   if ( $curuser->access_right('Generate quotation') ) { 
100       <& cust_main/quotations.html, $cust_main &>
101 %   }
102
103 % }
104
105
106 % ###
107 % # Packages
108 % ###
109
110 % if ( $view eq 'packages' ) {
111
112 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
113 <& cust_main/packages.html, $cust_main &>
114 % #}
115 <BR>
116
117 % }
118
119
120 % ###
121 % # Payment History
122 % ###
123
124 % if ( $view eq 'payment_history' ) {
125
126 <& cust_main/payment_history.html, $cust_main &>
127 <BR>
128
129 % }
130
131
132 % ###
133 % # Change History
134 % ###
135
136 % if ( $view eq 'change_history' ) {
137 <& cust_main/change_history.html, $cust_main &>
138 <BR>
139 % }
140
141 % if ( $view eq 'custom' ) { 
142 %   if ( $conf->config('cust_main-custom_link') ) {
143 <& cust_main/custom.html, $cust_main &>
144 %   } elsif ( $conf->config('cust_main-custom_content') ) {
145       <& cust_main/custom_content.html, $cust_main &>
146 %   #} else {
147 %   #  warn "custom view without cust_main-custom_link or -custom_content?";
148 %   }
149 % }
150
151 <& /elements/footer-cust_main.html &>
152 <%init>
153
154 my $curuser = $FS::CurrentUser::CurrentUser;
155
156 die "access denied"
157   unless $curuser->access_right('View customer');
158
159 my $conf = new FS::Conf;
160
161 my $custnum;
162 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
163   $custnum = $1;
164 } else {
165   die "No customer specified (bad URL)!" unless $cgi->keywords;
166   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
167   $query =~ /^(\d+)$/;
168   $custnum = $1;
169   $cgi->delete('keywords');
170   $cgi->param('custnum', $1);
171 }
172
173 my $cust_main = qsearchs( {
174   'table'     => 'cust_main',
175   'hashref'   => { 'custnum' => $custnum },
176   'extra_sql' => ' AND '. $curuser->agentnums_sql,
177 });
178 die "Customer not found!" unless $cust_main;
179
180 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
181 tie my %views, 'Tie::IxHash',
182        emt('Basics')           => 'basics',
183        emt('Notes')            => 'notes', #notes and files?
184 ;
185 if ( $conf->config('ticket_system') ) {
186   $views{emt('Tickets')}       =  'tickets';
187   $views{emt('Appointments')}  =  'appointments'
188     if $curuser->access_right('View appointments');
189 }
190 $views{emt('Quotations')}      =  'quotations';
191 $views{emt('Packages')}        =  'packages';
192 $views{emt('Payment History')} =  'payment_history';
193 $views{emt('Change History')}  =  'change_history'
194   if $curuser->access_right('View customer history');
195 $views{$conf->config('cust_main-custom_title') || emt('Custom')} =  'custom'
196   if $conf->config('cust_main-custom_link')
197   || $conf->config('cust_main-custom_content');
198
199 my %viewname = reverse %views;
200
201 my $view =  $cgi->param('show') || $curuser->default_customer_view;
202
203 if ($view eq 'last') {
204   # something took us away from the page and is now bouncing back
205   $view = get_page_pref('last_view', $custnum);
206 } else {
207   # remember which view is open so we _can_ bounce back
208   set_page_pref('last_view', $custnum, $view);
209 }
210
211 $view = 'basics' if $view eq 'jumbo';
212
213 </%init>