DNS, RT#8933
[freeside.git] / httemplate / view / cust_main.cgi
1 <% include('/elements/header.html', {
2              'title' => $title,
3              'nobr'  => 1,
4           })
5 %>
6 <BR>
7 % my @part_tag = $cust_main->part_tag;
8 % if ( $conf->config('cust_tag-location') eq 'top' && @part_tag ) {
9 <TABLE STYLE="margin-bottom:8px" CELLSPACING=2>
10 %   foreach my $part_tag ( @part_tag ) {
11 <TR>
12   <TD>
13       <FONT SIZE="+1"
14             <% length($part_tag->tagcolor)
15                  ? 'STYLE="background-color:#'.$part_tag->tagcolor.'"'
16                  : ''
17       %>><% $part_tag->tagname.': '. $part_tag->tagdesc |h %></FONT>
18   </TD>
19 </TR>
20 %   }
21 </TABLE>
22 % }
23
24 <% include('/elements/menubar.html',
25              { 'newstyle' => 1,
26                'selected' => $viewname{$view},
27                'url_base' => $cgi->url. "?custnum=$custnum;show=",
28              },
29              %views,
30           )
31 %>
32 <DIV CLASS="fstabcontainer">
33
34 <% include('/elements/init_overlib.html') %>
35
36 <SCRIPT TYPE="text/javascript">
37 function areyousure(href, message) {
38   if (confirm(message) == true)
39     window.location.href = href;
40 }
41 </SCRIPT>
42
43 % if ( $view eq 'basics' || $view eq 'jumbo' ) {
44
45 % if ( $curuser->access_right('Edit customer') ) { 
46   <A HREF="<% $p %>edit/cust_main.cgi?<% $custnum %>">Edit this customer</A> | 
47 % } 
48
49 % if ( $curuser->access_right('Cancel customer')
50 %        && $cust_main->ncancelled_pkgs
51 %      ) {
52
53   <% include( '/elements/popup_link-cust_main.html',
54               { 'action'      => $p. 'misc/cancel_cust.html',
55                 'label'       => 'Cancel&nbsp;this&nbsp;customer',
56                 'actionlabel' => 'Confirm Cancellation',
57                 'color'       => '#ff0000',
58                 'cust_main'   => $cust_main,
59                 'width'       => 616, #make room for reasons
60               }
61             )
62   %> | 
63
64 % }
65
66 % if ( $conf->exists('deletecustomers')
67 %        && $curuser->access_right('Delete customer')
68 %      ) {
69   <A HREF="<% $p %>misc/delete-customer.cgi?<% $custnum%>">Delete this customer</A> | 
70 % } 
71
72 % unless ( $conf->exists('disable_customer_referrals') ) { 
73   <A HREF="<% $p %>edit/cust_main.cgi?referral_custnum=<% $custnum %>">Refer a new customer</A> | 
74   <A HREF="<% $p %>search/cust_main.cgi?referral_custnum=<% $custnum %>">View this customer's referrals</A>
75 % } 
76
77 <BR><BR>
78
79 % if (    $curuser->access_right('Billing event reports') 
80 %      || $curuser->access_right('View customer billing events')
81 %    ) {
82
83   <A HREF="<% $p %>search/cust_event.html?custnum=<% $custnum %>">View billing events for this customer</A>
84   <BR><BR>
85
86 % }
87
88 %my $signupurl = $conf->config('signupurl');
89 %if ( $signupurl ) {
90   This customer's signup URL: <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A><BR><BR>
91 % } 
92
93 %if ( $conf->exists('maestro-status_test') ) {
94   <A HREF="<% $p %>misc/maestro-customer_status-test.html?<% $custnum %>">Test maestro status</A><BR><BR>
95 % } 
96
97 <A NAME="cust_main"></A>
98 <TABLE BORDER=0>
99 <TR>
100   <TD VALIGN="top">
101     <% include('cust_main/contacts.html', $cust_main ) %>
102   </TD>
103   <TD VALIGN="top" STYLE="padding-left: 54px">
104     <% include('cust_main/misc.html', $cust_main ) %>
105 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
106
107       <BR>
108       <% include('cust_main/billing.html', $cust_main ) %>
109 % } 
110
111   </TD>
112 </TR>
113 </TABLE>
114
115 % }
116
117 % if ( $view eq 'notes' || $view eq 'jumbo' ) {
118
119 %if ( $cust_main->comments =~ /[^\s\n\r]/ ) {
120 <BR>
121 Comments
122 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
123 <TR>
124   <TD BGCOLOR="#ffffff">
125     <PRE><% encode_entities($cust_main->comments) %></PRE>
126   </TD>
127 </TR>
128 </TABLE></TABLE>
129 <BR><BR>
130 % }
131 <A NAME="notes">
132 % my $notecount = scalar($cust_main->notes());
133 % if ( ! $conf->exists('cust_main-disable_notes') || $notecount) {
134
135 %   unless ( $view eq 'notes' && $cust_main->comments !~ /[^\s\n\r]/ ) {
136       <BR>
137       <A NAME="cust_main_note"><FONT SIZE="+2">Notes</FONT></A><BR>
138 %   }
139
140 %   if ( $curuser->access_right('Add customer note') &&
141 %        ! $conf->exists('cust_main-disable_notes')
142 %      ) {
143
144   <% include( '/elements/popup_link-cust_main.html',
145                 'label'       => 'Add customer note',
146                 'action'      => $p. 'edit/cust_main_note.cgi',
147                 'actionlabel' => 'Enter customer note',
148                 'cust_main'   => $cust_main,
149                 'width'       => 616,
150                 'height'      => 538, #575
151             )
152   %>
153
154 %   }
155
156 <BR>
157
158 <% include('cust_main/notes.html', 'custnum' => $cust_main->custnum ) %>
159
160 % }
161 <BR>
162
163 % if(! $conf->config('disable_cust_attachment') 
164 %  and $curuser->access_right('Add attachment')) {
165 <% include( '/elements/popup_link-cust_main.html',
166               'label'       => 'Attach file',
167               'action'      => $p.'edit/cust_main_attach.cgi',
168               'actionlabel' => 'Upload file',
169               'cust_main'   => $cust_main,
170               'width'       => 480,
171               'height'      => 296,
172           )
173 %>
174 % }
175 % if( $curuser->access_right('View attachments') ) {
176 <% include('cust_main/attachments.html', 'custnum' => $cust_main->custnum ) %>
177 %   if ($cgi->param('show_deleted')) {
178 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
179            ($view ? ";show=$view" : '') . '#notes' 
180            %>"><I>(Show active attachments)</I></A>
181 %   }
182 % elsif($curuser->access_right('View deleted attachments')) {
183 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
184            ($view ? ";show=$view" : '') . ';show_deleted=1#notes'
185            %>"><I>(Show deleted attachments)</I></A>
186 %   }
187 % }
188 <BR>
189
190 % }
191
192 % if ( $view eq 'jumbo' ) {
193     <BR><BR>
194     <A NAME="tickets"><FONT SIZE="+2">Tickets</FONT></A><BR>
195 % }
196
197 % if ( $view eq 'tickets' || $view eq 'jumbo' ) {
198
199 % if ( $conf->config('ticket_system') ) { 
200   <% include('cust_main/tickets.html', $cust_main ) %>
201 % } 
202   <BR><BR>
203
204 % }
205
206 % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { 
207
208   <A NAME="cust_pkg"><FONT SIZE="+2">Packages</FONT></A><BR>
209 % }
210
211 % if ( $view eq 'packages' || $view eq 'jumbo' ) {
212
213 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
214 <% include('cust_main/packages.html', $cust_main ) %>
215 % #}
216
217 % }
218
219 % if ( $view eq 'jumbo' ) {
220     <BR><BR>
221     <A NAME="history"><FONT SIZE="+2">Payment History</FONT></A><BR>
222 % }
223
224 % if ( $view eq 'payment_history' || $view eq 'jumbo' ) {
225
226 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
227   <% include('cust_main/payment_history.html', $cust_main ) %>
228 % } 
229
230 % }
231
232 % if ( $view eq 'change_history' ) { #  || $view eq 'jumbo'      
233 <% include('cust_main/change_history.html', $cust_main ) %>      
234 % }
235
236 % if ( $view eq 'custom' ) { 
237 <% include('cust_main/custom.html', $cust_main ) %>
238 % }
239
240 </DIV>
241 <% include('/elements/footer.html') %>
242 <%init>
243
244 my $curuser = $FS::CurrentUser::CurrentUser;
245
246 die "access denied"
247   unless $curuser->access_right('View customer');
248
249 my $conf = new FS::Conf;
250
251 my $custnum;
252 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
253   $custnum = $1;
254 } else {
255   die "No customer specified (bad URL)!" unless $cgi->keywords;
256   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
257   $query =~ /^(\d+)$/;
258   $custnum = $1;
259 }
260
261 my $cust_main = qsearchs( {
262   'table'     => 'cust_main',
263   'hashref'   => { 'custnum' => $custnum },
264   'extra_sql' => ' AND '. $curuser->agentnums_sql,
265 });
266 die "Customer not found!" unless $cust_main;
267
268 my $title = $cust_main->name;
269 $title = '('. $cust_main->display_custnum. ") $title"
270   if $conf->exists('cust_main-title-display_custnum');
271 $title = "Customer: $title";
272
273 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
274 tie my %views, 'Tie::IxHash',
275        'Basics'           => 'basics',
276        'Notes'            => 'notes', #notes and files?
277 ;
278 $views{'Tickets'}         =  'tickets'
279                                if $conf->config('ticket_system');
280 $views{'Packages'}        =  'packages';
281 $views{'Payment History'} =  'payment_history'
282                                unless $conf->config('payby-default' eq 'HIDE');
283 $views{'Change History'}  =  'change_history'
284   if $curuser->access_right('View customer history');
285 $views{$conf->config('cust_main-custom_title') || 'Custom'} =  'custom'
286   if $conf->config('cust_main-custom_link');
287 $views{'Jumbo'}           =  'jumbo';
288
289 my %viewname = reverse %views;
290
291 my $view =  $cgi->param('show') || $curuser->default_customer_view;
292
293 </%init>