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