display sent mail on customer notes page, and improve sent mail log UI, #29250
[freeside.git] / httemplate / view / cust_main.cgi
1 <& /elements/header.html, {
2              'title' => $title,
3              'head'  => $head,
4              'nobr'  => 1,
5           }
6 &>
7 <BR>
8 % my @part_tag = $cust_main->part_tag;
9 % if ( $conf->config('cust_tag-location') eq 'top' && @part_tag ) {
10 <TABLE STYLE="margin-bottom:8px" CELLSPACING=2>
11 %   foreach my $part_tag ( @part_tag ) {
12 <TR>
13   <TD>
14       <FONT SIZE="+1"
15             <% length($part_tag->tagcolor)
16                  ? 'STYLE="background-color:#'.$part_tag->tagcolor.'"'
17                  : ''
18       %>><% $part_tag->tagname.': '. $part_tag->tagdesc |h %></FONT>
19   </TD>
20 </TR>
21 %   }
22 </TABLE>
23 % }
24
25 <& /elements/menubar.html,
26              { 'newstyle' => 1,
27                'selected' => $viewname{$view},
28                'url_base' => $cgi->url. "?custnum=$custnum;show=",
29              },
30              %views,
31 &>
32 <DIV CLASS="fstabcontainer">
33
34 <& /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 %>"><% mt('Edit this customer') |h %></A> | 
47 % } 
48
49 % if ( $curuser->access_right('Suspend customer')
50 %        && scalar($cust_main->unsuspended_pkgs)
51 %      ) {
52   <& /elements/popup_link-cust_main.html,
53               { 'action'      => $p. 'misc/suspend_cust.html',
54                 'label'       => emt('Suspend this customer'),
55                 'actionlabel' => emt('Confirm Suspension'),
56                 'color'       => '#ff9900',
57                 'cust_main'   => $cust_main,
58                 'width'       => 616, #make room for reasons
59                 'height'      => 366,
60               }
61   &> | 
62 % }
63
64 % if ( $curuser->access_right('Unsuspend customer')
65 %        && scalar($cust_main->suspended_pkgs)
66 %      ) {
67   <& /elements/popup_link-cust_main.html,
68               { 'action'      => $p. 'misc/unsuspend_cust.html',
69                 'label'       => emt('Unsuspend this customer'),
70                 'actionlabel' => emt('Confirm Unsuspension'),
71                 #'color'       => '#ff9900',
72                 'cust_main'   => $cust_main,
73                 #'width'       => 616, #make room for reasons
74                 #'height'      => 366,
75               }
76   &> | 
77 % }
78
79 % if ( $curuser->access_right('Cancel customer')
80 %        && scalar($cust_main->ncancelled_pkgs)
81 %      ) {
82   <& /elements/popup_link-cust_main.html,
83               { 'action'      => $p. 'misc/cancel_cust.html',
84                 'label'       => emt('Cancel this customer'),
85                 'actionlabel' => emt('Confirm Cancellation'),
86                 'color'       => '#ff0000',
87                 'cust_main'   => $cust_main,
88                 'width'       => 616, #make room for reasons
89                 'height'      => 366,
90               }
91   &> | 
92 % }
93
94 % if (     $curuser->access_right('Merge customer')
95 %      and (    scalar($cust_main->ncancelled_pkgs)
96 %            # || we start supporting payment info merge again in some way
97 %          )
98 %    )
99 % {
100   <& /elements/popup_link-cust_main.html,
101               { 'action'      => $p. 'misc/merge_cust.html',
102                 'label'       => emt('Merge this customer'),
103                 'actionlabel' => emt('Merge customer'),
104                 'cust_main'   => $cust_main,
105                 'width'       => 569,
106                 'height'      => 210,
107               }
108   &> | 
109 % } 
110
111 % unless ( $conf->exists('disable_customer_referrals') ) { 
112   <A HREF="<% $p %>edit/cust_main.cgi?referral_custnum=<% $custnum %>"><% mt('Refer a new customer') |h %></A> | 
113   <A HREF="<% $p %>search/cust_main.cgi?referral_custnum=<% $custnum %>"><% mt('View this customer\'s referrals') |h %></A>
114 % } 
115
116 <BR><BR>
117
118 % my $br = 0;
119 % if (    $curuser->access_right('Billing event reports') 
120 %      || $curuser->access_right('View customer billing events')
121 %    ) {
122 % $br=1;
123   <A HREF="<% $p %>search/cust_event.html?custnum=<% $custnum %>"><% mt('View billing events for this customer') |h %></A>
124 % }
125
126 % my $email_link = ($cust_main->invoicing_list_emailonly) && 
127 %   include('/elements/email-link.html',
128 %            'table'               => 'cust_main', 
129 %            'search_hash'         => { 'custnum' => $custnum },
130 %            'agent_virt_agentnum' => $cust_main->agentnum,
131 %            'label'               => 'Email a notice to this customer',
132 % );
133 % if ( $email_link and $br ) {
134  | 
135 % }
136 <% $email_link || '' %>
137
138 % if ( $curuser->access_right('Order customer package') && $conf->exists('cust_main-enable_order_package') ) {
139   | <& /elements/order_pkg_link.html, 'cust_main'=>$cust_main &>
140 % }
141
142 % if ( $conf->config('cust_main-external_links') ) {
143     <% $br++ ? ' | ' : '' %>
144 %   my @links = split(/\n/, $conf->config('cust_main-external_links'));
145 %   foreach my $link (@links) {
146 %     $link =~ /^\s*(\S+)\s+(.*?)(\s*\(([^\)]*)\))?$/ or next;
147 %     my($url, $label, $alt) = ($1, $2, $4);
148       <A HREF="<% $url.$custnum %>" ALT="<% $alt |h %>"><% $label |h %></A>
149 %   }
150 % }
151
152 % if ( $br ) {
153   <BR><BR>
154 % }
155
156 %my $signupurl = $conf->config('signupurl');
157 %if ( $signupurl ) {
158   <% mt('This customer\'s signup URL:') |h %>
159   <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A>
160   <BR><BR>
161 % } 
162
163 <A NAME="cust_main"></A>
164 <TABLE BORDER=0>
165 <TR>
166   <TD VALIGN="top">
167     <& cust_main/contacts.html, $cust_main &>
168   </TD>
169   <TD VALIGN="top" STYLE="padding-left: 54px">
170     <& cust_main/misc.html, $cust_main &>
171 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
172       <BR><& cust_main/billing.html, $cust_main &>
173 % } 
174
175   </TD>
176 </TR>
177 <TR>
178   <TD COLSPAN = 2>
179     <& cust_main/contacts_new.html, $cust_main &>
180   </TD>
181 </TR>
182 </TABLE>
183
184 % }
185
186 % if ( $view eq 'notes' || $view eq 'jumbo' ) {
187
188 <& cust_main/notes.html, 'cust_main' => $cust_main &>
189
190 % }
191
192 % if ( $view eq 'jumbo' ) {
193     <BR>
194 % }
195
196 <BR>
197
198 % if ( $view eq 'tickets' || $view eq 'jumbo' ) {
199
200 % if ( $conf->config('ticket_system') ) { 
201   <& cust_main/tickets.html, $cust_main &>
202 % } 
203   <BR><BR>
204
205 % }
206
207 % if ( $view eq 'appointments' || $view eq 'jumbo' ) {
208
209 % if ( $conf->config('ticket_system')
210 %        && $curuser->access_right('View appointments') ) { 
211   <& cust_main/appointments.html, $cust_main &>
212 % } 
213   <BR><BR>
214
215 % }
216
217 % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { 
218
219   <A NAME="cust_pkg"><FONT SIZE="+2"><% mt('Packages') |h %></FONT></A><BR>
220 % }
221
222 % if ( $view eq 'packages' || $view eq 'jumbo' ) {
223
224 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
225 <& cust_main/packages.html, $cust_main &>
226 % #}
227
228 % }
229
230 % if ( $view eq 'jumbo' ) {
231     <BR><BR>
232     <A NAME="history"><FONT SIZE="+2"><% mt('Payment History') |h %></FONT></A>
233     <BR>
234 % }
235
236 % if ( $view eq 'payment_history' || $view eq 'jumbo' ) {
237
238 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
239   <& cust_main/payment_history.html, $cust_main &>
240 % } 
241
242 % }
243
244 % if ( $view eq 'change_history' ) { #  || $view eq 'jumbo'      
245 <& cust_main/change_history.html, $cust_main &>          
246 % }
247
248 % if ( $view eq 'custom' ) { 
249 %   if ( $conf->config('cust_main-custom_link') ) {
250 <& cust_main/custom.html, $cust_main &>
251 %   } elsif ( $conf->config('cust_main-custom_content') ) {
252       <& cust_main/custom_content.html, $cust_main &>
253 %   #} else {
254 %   #  warn "custom view without cust_main-custom_link or -custom_content?";
255 %   }
256 % }
257
258 </DIV>
259 <& /elements/footer.html &>
260 <%init>
261
262 my $curuser = $FS::CurrentUser::CurrentUser;
263
264 die "access denied"
265   unless $curuser->access_right('View customer');
266
267 my $conf = new FS::Conf;
268
269 my $custnum;
270 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
271   $custnum = $1;
272 } else {
273   die "No customer specified (bad URL)!" unless $cgi->keywords;
274   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
275   $query =~ /^(\d+)$/;
276   $custnum = $1;
277   $cgi->param('custnum', $1);
278 }
279
280 my $cust_main = qsearchs( {
281   'table'     => 'cust_main',
282   'hashref'   => { 'custnum' => $custnum },
283   'extra_sql' => ' AND '. $curuser->agentnums_sql,
284 });
285 die "Customer not found!" unless $cust_main;
286
287 my $title = $cust_main->name;
288 $title = '('. $cust_main->display_custnum. ") $title"
289   if $conf->exists('cust_main-title-display_custnum');
290 $title = mt("Customer:")." ".$title;
291
292 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
293 tie my %views, 'Tie::IxHash',
294        emt('Basics')           => 'basics',
295        emt('Notes')            => 'notes', #notes and files?
296 ;
297 if ( $conf->config('ticket_system') ) {
298   $views{emt('Tickets')}       =  'tickets';
299   $views{emt('Appointments')}  =  'appointments'
300     if $curuser->access_right('View appointments');
301 }
302 $views{emt('Packages')}        =  'packages';
303 $views{emt('Payment History')} =  'payment_history'
304                                unless $conf->config('payby-default' eq 'HIDE');
305 $views{emt('Change History')}  =  'change_history'
306   if $curuser->access_right('View customer history');
307 $views{$conf->config('cust_main-custom_title') || emt('Custom')} =  'custom'
308   if $conf->config('cust_main-custom_link')
309   || $conf->config('cust_main-custom_content');
310 $views{emt('Jumbo')}           =  'jumbo';
311
312 my %viewname = reverse %views;
313
314 my $view =  $cgi->param('show') || $curuser->default_customer_view;
315
316 my $ie_compat = $conf->config('ie-compatibility_mode');
317 my $head = '';
318 if ( $ie_compat ) {
319   $head = qq(<meta http-equiv="X-UA-Compatible" content="IE=$ie_compat" />);
320 }
321
322 </%init>