fix top subtotals on refund reports
[freeside.git] / httemplate / search / mailinglistmember.html
1 <& 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 <%init>
11
12 #XXX ACL:
13 #make sure the mailing list is attached to a customer service i can see/view
14
15 $cgi->param('listnum') =~ /^(\d+)$/ or die 'illegal listnum';
16 my $listnum = $1;
17
18 my $mailinglist = qsearchs('mailinglist', { 'listnum' => $listnum })
19   or die "unknown listnum $listnum";
20 my $title = $mailinglist->listname. ' mailing list';
21
22 my $svc_mailinglist = $mailinglist->svc_mailinglist;
23
24 my $query = {
25   'table' => 'mailinglistmember',
26   'hashref' => { 'listnum' => $listnum },
27 };
28
29 my $count_query = "SELECT COUNT(*) FROM mailinglistmember WHERE listnum = $listnum";
30
31 my $email_sub = sub {
32   my $member = shift;
33   my $r = $member->email; #just this one for now
34   my $a = qq[<A HREF="javascript:areyousure('$r', ]. $member->membernum. ')">';
35   $r .= " (${a}remove</A>)";
36   $r;
37 };
38
39 my $html_init = '';
40 if ( $svc_mailinglist ) {
41   my $svcnum = $svc_mailinglist->svcnum;
42   my $label = encode_entities($svc_mailinglist->label);
43   $html_init .= qq[<A HREF="${p}/view/svc_mailinglist.cgi?$svcnum">View customer mailing list: $label</A><BR><BR>];
44 }
45
46 $html_init .= <<"END";
47 <SCRIPT TYPE="text/javascript">
48   function areyousure(email,membernum) {
49     if ( confirm('Are you sure you want to remove ' + email + ' from this mailing list?') )
50       window.location.href="${p}misc/delete-mailinglistmember.html?" + membernum;
51     
52   }
53 </SCRIPT>
54 END
55
56 </%init>