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