Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / view / cust_main.cgi
1 <& /elements/header.html, {
2              'title' => $title,
3              'title_noescape' => $title_noescape,
4              'head'  => $head,
5              'nobr'  => 1,
6           }
7 &>
8 <BR>
9 % my @part_tag = $cust_main->part_tag;
10 % if ( $conf->config('cust_tag-location') eq 'top' && @part_tag ) {
11 <TABLE STYLE="margin-bottom:8px" CELLSPACING=2>
12 %   foreach my $part_tag ( @part_tag ) {
13 <TR>
14   <TD>
15       <FONT SIZE="+1"
16             <% length($part_tag->tagcolor)
17                  ? 'STYLE="background-color:#'.$part_tag->tagcolor.'"'
18                  : ''
19       %>><% $part_tag->tagname.': '. $part_tag->tagdesc |h %></FONT>
20   </TD>
21 </TR>
22 %   }
23 </TABLE>
24 % }
25
26 <& cust_main/menu.html, cust_main => $cust_main, show => $view &>
27 <DIV CLASS="fstabcontainer">
28
29 <& /elements/init_overlib.html &>
30
31 <SCRIPT TYPE="text/javascript">
32 function areyousure(href, message) {
33   if (confirm(message) == true)
34     window.location.href = href;
35 }
36 </SCRIPT>
37
38 <br><br>
39
40 % ###
41 % # Basics
42 % ###
43
44 % if ( $view eq 'basics' || $view eq 'jumbo' ) {
45
46 % my $br = 0;
47 % if ( $curuser->access_right('Order customer package') && $conf->exists('cust_main-enable_order_package') ) {
48   | <& /elements/order_pkg_link.html, 'cust_main'=>$cust_main &>
49 % }
50
51 % if ( $conf->config('cust_main-external_links') ) {
52     <% $br++ ? ' | ' : '' %>
53 %   my @links = split(/\n/, $conf->config('cust_main-external_links'));
54 %   foreach my $link (@links) {
55 %     $link =~ /^\s*(\S+)\s+(.*?)(\s*\(([^\)]*)\))?$/ or next;
56 %     my($url, $label, $alt) = ($1, $2, $4);
57       <A HREF="<% $url.$custnum %>" ALT="<% $alt |h %>"><% $label |h %></A>
58 %   }
59 % }
60
61 % if ( $br ) {
62   <BR><BR>
63 % }
64
65 %my $signupurl = $conf->config('signupurl');
66 %if ( $signupurl ) {
67   <% mt('This customer\'s signup URL:') |h %>
68   <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A>
69   <BR><BR>
70 % } 
71
72 <A NAME="cust_main"></A>
73 <TABLE BORDER=0>
74 <TR>
75   <TD VALIGN="top">
76     <& cust_main/contacts.html, $cust_main &>
77     <BR>
78     <& cust_main/misc.html, $cust_main &>
79   </TD>
80   <TD VALIGN="top" STYLE="padding-left: 54px">
81     <& cust_main/billing.html, $cust_main &>
82     <BR>
83     <& cust_main/cust_payby.html, $cust_main &>
84   </TD>
85 </TR>
86 <TR>
87   <TD COLSPAN = 2>
88     <& cust_main/contacts_new.html, $cust_main &>
89   </TD>
90 </TR>
91 </TABLE>
92
93 % }
94
95
96 % ###
97 % # Notes
98 % ###
99
100 % if ( $view eq 'notes' || $view eq 'jumbo' ) {
101
102 <& cust_main/notes.html, 'cust_main' => $cust_main &>
103
104 % }
105
106 % if ( $view eq 'jumbo' ) {
107     <BR>
108 % }
109
110 <BR>
111
112
113 % ###
114 % # Tickets
115 % ###
116
117 % if ( $view eq 'tickets' || $view eq 'jumbo' ) {
118
119 % if ( $conf->config('ticket_system') ) { 
120   <& cust_main/tickets.html, $cust_main &>
121 % } 
122   <BR><BR>
123
124 % }
125
126 % ###
127 % # Appointments
128 % ###
129
130 % if ( $view eq 'appointments' || $view eq 'jumbo' ) {
131
132 % if ( $conf->config('ticket_system')
133 %        && $curuser->access_right('View appointments') ) { 
134   <& cust_main/appointments.html, $cust_main &>
135 % } 
136   <BR><BR>
137
138 % }
139
140
141 % ###
142 % # Quotations
143 % ###
144
145 % if ( $view eq 'jumbo' && $curuser->access_right('Generate quotation') ) { 
146   <A NAME="quotations"><FONT SIZE="+2"><% mt('Quotations') |h %></FONT></A><BR>
147 % }
148
149 % if ( $view eq 'quotations' || $view eq 'jumbo' ) {
150
151 %   if ( $curuser->access_right('Generate quotation') ) { 
152       <& cust_main/quotations.html, $cust_main &>
153 %   }
154
155 % }
156
157
158 % ###
159 % # Packages
160 % ###
161
162 % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { 
163
164   <A NAME="cust_pkg"><FONT SIZE="+2"><% mt('Packages') |h %></FONT></A><BR>
165 % }
166
167 % if ( $view eq 'packages' || $view eq 'jumbo' ) {
168
169 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
170 <& cust_main/packages.html, $cust_main &>
171 % #}
172
173 % }
174
175
176 % ###
177 % # Payment History
178 % ###
179
180 % if ( $view eq 'jumbo' ) {
181     <BR><BR>
182     <A NAME="history"><FONT SIZE="+2"><% mt('Payment History') |h %></FONT></A>
183     <BR>
184 % }
185
186 % if ( $view eq 'payment_history' || $view eq 'jumbo' ) {
187
188 <& cust_main/payment_history.html, $cust_main &>
189
190 % }
191
192
193 % ###
194 % # Change History
195 % ###
196
197 % if ( $view eq 'change_history' ) { #  || $view eq 'jumbo'      
198 <& cust_main/change_history.html, $cust_main &>          
199 % }
200
201 % if ( $view eq 'custom' ) { 
202 %   if ( $conf->config('cust_main-custom_link') ) {
203 <& cust_main/custom.html, $cust_main &>
204 %   } elsif ( $conf->config('cust_main-custom_content') ) {
205       <& cust_main/custom_content.html, $cust_main &>
206 %   #} else {
207 %   #  warn "custom view without cust_main-custom_link or -custom_content?";
208 %   }
209 % }
210
211 </DIV>
212 <& /elements/footer.html &>
213 <%init>
214
215 my $curuser = $FS::CurrentUser::CurrentUser;
216
217 die "access denied"
218   unless $curuser->access_right('View customer');
219
220 my $conf = new FS::Conf;
221
222 my $custnum;
223 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
224   $custnum = $1;
225 } else {
226   die "No customer specified (bad URL)!" unless $cgi->keywords;
227   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
228   $query =~ /^(\d+)$/;
229   $custnum = $1;
230   $cgi->delete('keywords');
231   $cgi->param('custnum', $1);
232 }
233
234 my $cust_main = qsearchs( {
235   'table'     => 'cust_main',
236   'hashref'   => { 'custnum' => $custnum },
237   'extra_sql' => ' AND '. $curuser->agentnums_sql,
238 });
239 die "Customer not found!" unless $cust_main;
240
241 my $title = encode_entities($cust_main->name);
242 $title = '#'. $cust_main->display_custnum. " $title";
243 #  if $conf->exists('cust_main-title-display_custnum');
244 $title = mt("Customer")." ".$title;
245
246 my @agentnums = $curuser->agentnums;
247 if (scalar(@agentnums) > 1 ) {
248   $title = encode_entities($cust_main->agent->agent). " $title";
249 }
250
251 my $status = $cust_main->status_label;
252 $status .= ' (Cancelled)' if $cust_main->is_status_delay_cancel;
253 my $title_noescape = $title. ' (<B><FONT COLOR="#'. $cust_main->statuscolor. '">'. $status.  '</FONT></B>)';
254 $title .= " ($status)";
255
256 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
257 tie my %views, 'Tie::IxHash',
258        emt('Basics')           => 'basics',
259        emt('Notes')            => 'notes', #notes and files?
260 ;
261 if ( $conf->config('ticket_system') ) {
262   $views{emt('Tickets')}       =  'tickets';
263   $views{emt('Appointments')}  =  'appointments'
264     if $curuser->access_right('View appointments');
265 }
266 $views{emt('Quotations')}      =  'quotations';
267 $views{emt('Packages')}        =  'packages';
268 $views{emt('Payment History')} =  'payment_history';
269 $views{emt('Change History')}  =  'change_history'
270   if $curuser->access_right('View customer history');
271 $views{$conf->config('cust_main-custom_title') || emt('Custom')} =  'custom'
272   if $conf->config('cust_main-custom_link')
273   || $conf->config('cust_main-custom_content');
274 $views{emt('Jumbo')}           =  'jumbo';
275
276 my %viewname = reverse %views;
277
278 my $view =  $cgi->param('show') || $curuser->default_customer_view;
279
280 my $ie_compat = $conf->config('ie-compatibility_mode');
281 my $head = '';
282 if ( $ie_compat ) {
283   $head = qq(<meta http-equiv="X-UA-Compatible" content="IE=$ie_compat" />);
284 }
285
286 </%init>