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