RT# 73421 Fixed E-Mail pipeline to obey contact opt-in flags
[freeside.git] / httemplate / view / cust_main / contacts_new.html
1 % if ( $display and @cust_contacts ) {
2 <BR>
3 <FONT CLASS="fsinnerbox-title">Contacts</FONT>
4
5 <& /elements/table-grid.html &>
6 <THEAD>
7 % my $th = '<TH CLASS="grid" ALIGN="left">';
8 <TR>
9   <%$th%>Type</TH>
10   <%$th%>Contact</TH>
11   <%$th%>Email</TH>
12   <%$th%>Send invoices</TH>
13   <%$th%>Send messages</TH>
14   <%$th%>Self-service</TH>
15 % foreach my $phone_type (@phone_type) {
16     <%$th%><% $phone_type->typename |h %></TH>
17 % }
18   <%$th%>Comment</TH>
19 </TR>
20 </THEAD>
21
22 %   my $bgcolor1 = '#ffffff';
23 %   my $bgcolor2 = '#eeeeee';
24 %   my $bgcolor = $bgcolor2;
25 %   foreach my $cust_contact ( @cust_contacts ) {
26 %     my $contact = $cust_contact->contact;
27 %     my $td = qq(<TD CLASS="grid" BGCOLOR="$bgcolor">);
28
29       <TR>
30         <%$td%><% $cust_contact->contact_classname |h %></TD>
31         <%$td%><% $contact->line |h %></TD>
32
33 %       my @contact_email = $contact->contact_email;
34         <%$td%><% join(', ', map $_->emailaddress, @contact_email) %></TD>
35         <%$td%><% $cust_contact->invoice_dest eq 'Y' ? 'Yes' : 'No' %></TD>
36         <%$td%><% $cust_contact->message_dest eq 'Y' ? 'Yes' : 'No' %></TD>
37         <%$td%>
38 %         if ( $cust_contact->selfservice_access ) {
39             Enabled
40 %#            <FONT SIZE="-1"><A HREF="XXX">disable</A>
41 %#                            <A HREF="XXX">re-email</A></FONT>
42 %         } else {
43             Disabled
44 %#            <FONT SIZE="-1"><A HREF="XXX">enable</A></FONT>
45 %        }
46        </TD>
47
48 %       foreach my $phone_type (@phone_type) {
49 %         my $contact_phone =
50 %           qsearchs('contact_phone', {
51 %                      'contactnum'   => $contact->contactnum,
52 %                      'phonetypenum' => $phone_type->phonetypenum,
53 %                   });
54           <%$td%><% $contact_phone ? $contact_phone->phonenum_pretty : '' |h %></TD>
55 %       }
56
57         <%$td%><% $cust_contact->comment |h %></TD>
58
59       </TR>
60
61 %     if ( $bgcolor eq $bgcolor1 ) {
62 %        $bgcolor = $bgcolor2;
63 %      } else {
64 %        $bgcolor = $bgcolor1;
65 %      }
66 %   }
67 </TABLE>
68 %}
69 <%once>
70
71 my @phone_type = qsearch({table=>'phone_type', order_by=>'weight'});
72
73 </%once>
74 <%init>
75
76 my( $cust_main ) = @_;
77 #my $conf = new FS::Conf;
78
79 my @cust_contacts = $cust_main->cust_contact;
80
81 # residential customers have a default "invisible" contact, but if they
82 # somehow get more than one contact, show them
83 my $display = scalar(@cust_contacts) > 1;
84
85 </%init>