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