b4a6170c59cebefa660acef58d9583925273d30a
[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                 'height'      => 366,
61               }
62             )
63   %> | 
64
65 % }
66
67 % if ( $conf->exists('deletecustomers')
68 %        && $curuser->access_right('Delete customer')
69 %      ) {
70   <A HREF="<% $p %>misc/delete-customer.cgi?<% $custnum%>">Delete this customer</A> | 
71 % } 
72
73 % unless ( $conf->exists('disable_customer_referrals') ) { 
74   <A HREF="<% $p %>edit/cust_main.cgi?referral_custnum=<% $custnum %>">Refer a new customer</A> | 
75   <A HREF="<% $p %>search/cust_main.cgi?referral_custnum=<% $custnum %>">View this customer's referrals</A>
76 % } 
77
78 <BR><BR>
79
80 % if (    $curuser->access_right('Billing event reports') 
81 %      || $curuser->access_right('View customer billing events')
82 %    ) {
83
84   <A HREF="<% $p %>search/cust_event.html?custnum=<% $custnum %>">View billing events for this customer</A>
85   <BR><BR>
86
87 % }
88
89 %my $signupurl = $conf->config('signupurl');
90 %if ( $signupurl ) {
91   This customer's signup URL: <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A><BR><BR>
92 % } 
93
94 %if ( $conf->exists('maestro-status_test') ) {
95   <A HREF="<% $p %>misc/maestro-customer_status-test.html?<% $custnum %>">Test maestro status</A><BR><BR>
96 % } 
97
98 <A NAME="cust_main"></A>
99 <TABLE BORDER=0>
100 <TR>
101   <TD VALIGN="top">
102     <% include('cust_main/contacts.html', $cust_main ) %>
103   </TD>
104   <TD VALIGN="top" STYLE="padding-left: 54px">
105     <% include('cust_main/misc.html', $cust_main ) %>
106 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
107
108       <BR>
109       <% include('cust_main/billing.html', $cust_main ) %>
110 % } 
111
112   </TD>
113 </TR>
114 </TABLE>
115
116 % }
117
118 % if ( $view eq 'notes' || $view eq 'jumbo' ) {
119
120 %if ( $cust_main->comments =~ /[^\s\n\r]/ ) {
121 <BR>
122 Comments
123 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
124 <TR>
125   <TD BGCOLOR="#ffffff">
126     <PRE><% encode_entities($cust_main->comments) %></PRE>
127   </TD>
128 </TR>
129 </TABLE></TABLE>
130 <BR><BR>
131 % }
132 <A NAME="notes">
133 % my $notecount = scalar($cust_main->notes());
134 % if ( ! $conf->exists('cust_main-disable_notes') || $notecount) {
135
136 %   unless ( $view eq 'notes' && $cust_main->comments !~ /[^\s\n\r]/ ) {
137       <BR>
138       <A NAME="cust_main_note"><FONT SIZE="+2">Notes</FONT></A><BR>
139 %   }
140
141 %   if ( $curuser->access_right('Add customer note') &&
142 %        ! $conf->exists('cust_main-disable_notes')
143 %      ) {
144
145   <% include( '/elements/popup_link-cust_main.html',
146                 'label'       => 'Add customer note',
147                 'action'      => $p. 'edit/cust_main_note.cgi',
148                 'actionlabel' => 'Enter customer note',
149                 'cust_main'   => $cust_main,
150                 'width'       => 616,
151                 'height'      => 538, #575
152             )
153   %>
154
155 %   }
156
157 <BR>
158
159 <% include('cust_main/notes.html', 'custnum' => $cust_main->custnum ) %>
160
161 % }
162 <BR>
163
164 % if(! $conf->config('disable_cust_attachment') 
165 %  and $curuser->access_right('Add attachment')) {
166 <% include( '/elements/popup_link-cust_main.html',
167               'label'       => 'Attach file',
168               'action'      => $p.'edit/cust_main_attach.cgi',
169               'actionlabel' => 'Upload file',
170               'cust_main'   => $cust_main,
171               'width'       => 480,
172               'height'      => 296,
173           )
174 %>
175 % }
176 % if( $curuser->access_right('View attachments') ) {
177 <% include('cust_main/attachments.html', 'custnum' => $cust_main->custnum ) %>
178 %   if ($cgi->param('show_deleted')) {
179 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
180            ($view ? ";show=$view" : '') . '#notes' 
181            %>"><I>(Show active attachments)</I></A>
182 %   }
183 % elsif($curuser->access_right('View deleted attachments')) {
184 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
185            ($view ? ";show=$view" : '') . ';show_deleted=1#notes'
186            %>"><I>(Show deleted attachments)</I></A>
187 %   }
188 % }
189 <BR>
190
191 % }
192
193 % if ( $view eq 'jumbo' ) {
194     <BR><BR>
195     <A NAME="tickets"><FONT SIZE="+2">Tickets</FONT></A><BR>
196 % }
197
198 % if ( $view eq 'tickets' || $view eq 'jumbo' ) {
199
200 % if ( $conf->config('ticket_system') ) { 
201   <% include('cust_main/tickets.html', $cust_main ) %>
202 % } 
203   <BR><BR>
204
205 % }
206
207 % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { 
208
209   <A NAME="cust_pkg"><FONT SIZE="+2">Packages</FONT></A><BR>
210 % }
211
212 % if ( $view eq 'packages' || $view eq 'jumbo' ) {
213
214 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
215 <% include('cust_main/packages.html', $cust_main ) %>
216 % #}
217
218 % }
219
220 % if ( $view eq 'jumbo' ) {
221     <BR><BR>
222     <A NAME="history"><FONT SIZE="+2">Payment History</FONT></A><BR>
223 % }
224
225 % if ( $view eq 'payment_history' || $view eq 'jumbo' ) {
226
227 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
228   <% include('cust_main/payment_history.html', $cust_main ) %>
229 % } 
230
231 % }
232
233 % if ( $view eq 'change_history' ) { #  || $view eq 'jumbo'      
234 <% include('cust_main/change_history.html', $cust_main ) %>      
235 % }
236
237 % if ( $view eq 'custom' ) { 
238 <% include('cust_main/custom.html', $cust_main ) %>
239 % }
240
241 </DIV>
242 <% include('/elements/footer.html') %>
243 <%init>
244
245 my $curuser = $FS::CurrentUser::CurrentUser;
246
247 die "access denied"
248   unless $curuser->access_right('View customer');
249
250 my $conf = new FS::Conf;
251
252 my $custnum;
253 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
254   $custnum = $1;
255 } else {
256   die "No customer specified (bad URL)!" unless $cgi->keywords;
257   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
258   $query =~ /^(\d+)$/;
259   $custnum = $1;
260 }
261
262 my $cust_main = qsearchs( {
263   'table'     => 'cust_main',
264   'hashref'   => { 'custnum' => $custnum },
265   'extra_sql' => ' AND '. $curuser->agentnums_sql,
266 });
267 die "Customer not found!" unless $cust_main;
268
269 my $title = $cust_main->name;
270 $title = '('. $cust_main->display_custnum. ") $title"
271   if $conf->exists('cust_main-title-display_custnum');
272 $title = "Customer: $title";
273
274 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
275 tie my %views, 'Tie::IxHash',
276        'Basics'           => 'basics',
277        'Notes'            => 'notes', #notes and files?
278 ;
279 $views{'Tickets'}         =  'tickets'
280                                if $conf->config('ticket_system');
281 $views{'Packages'}        =  'packages';
282 $views{'Payment History'} =  'payment_history'
283                                unless $conf->config('payby-default' eq 'HIDE');
284 $views{'Change History'}  =  'change_history'
285   if $curuser->access_right('View customer history');
286 $views{$conf->config('cust_main-custom_title') || 'Custom'} =  'custom'
287   if $conf->config('cust_main-custom_link');
288 $views{'Jumbo'}           =  'jumbo';
289
290 my %viewname = reverse %views;
291
292 my $view =  $cgi->param('show') || $curuser->default_customer_view;
293
294 </%init>