c748c3ac8e57a5c3cb5a661f48be558a1e4f84cd
[freeside.git] / httemplate / search / mailinglistmember.html
1 <% include('elements/search.html',
2              'title'         => $title,
3              'name_singular' => 'member',
4              'query'         => $query,
5              'count_query'   => $count_query,
6              'header'        => [ 'Email address' ],
7              'fields'        => [ $email_sub, ], #just this one for now
8              'html_init'     => $html_init,
9           )
10 %>
11 <%init>
12
13 #XXX ACL:
14 #make sure the mailing list is attached to a customer service i can see/view
15
16 $cgi->param('listnum') =~ /^(\d+)$/ or die 'illegal listnum';
17 my $listnum = $1;
18
19 my $mailinglist = qsearchs('mailinglist', { 'listnum' => $listnum })
20   or die "unknown listnum $listnum";
21 my $title = $mailinglist->listname. ' mailing list';
22
23 my $query = {
24   'table' => 'mailinglistmember',
25   'hashref' => { 'listnum' => $listnum },
26 };
27
28 my $count_query = "SELECT COUNT(*) FROM mailinglistmember WHERE listnum = $listnum";
29
30 my $email_sub = sub {
31   my $member = shift;
32   my $r = $member->email; #just this one for now
33   my $a = qq[<A HREF="javascript:areyousure('$r', ]. $member->membernum. ')">';
34   $r .= " (${a}remove</A>)";
35   $r;
36 };
37
38 my $html_init = <<"END";
39 <SCRIPT TYPE="text/javascript">
40   function areyousure(email,membernum) {
41     if ( confirm('Are you sure you want to remove ' + email + ' from this mailing list?') )
42       window.location.href="${p}misc/delete-mailinglistmember.html?" + membernum;
43     
44   }
45 </SCRIPT>
46 END
47
48 </%init>