summaryrefslogtreecommitdiff
path: root/httemplate/search/mailinglistmember.html
blob: a678d45edb540dd9524c970097da3ddee85670ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<& elements/search.html,
             'title'         => $title,
             'name_singular' => 'member',
             'query'         => $query,
             'count_query'   => $count_query,
             'header'        => [ 'Email address' ],
             'fields'        => [ $email_sub, ], #just this one for now
             'html_init'     => $html_init,
&>
<%init>

#XXX ACL:
#make sure the mailing list is attached to a customer service i can see/view

$cgi->param('listnum') =~ /^(\d+)$/ or die 'illegal listnum';
my $listnum = $1;

my $mailinglist = qsearchs('mailinglist', { 'listnum' => $listnum })
  or die "unknown listnum $listnum";
my $title = $mailinglist->listname. ' mailing list';

my $svc_mailinglist = $mailinglist->svc_mailinglist;

my $query = {
  'table' => 'mailinglistmember',
  'hashref' => { 'listnum' => $listnum },
};

my $count_query = "SELECT COUNT(*) FROM mailinglistmember WHERE listnum = $listnum";

my $email_sub = sub {
  my $member = shift;
  my $r = $member->email; #just this one for now
  my $a = qq[<A HREF="javascript:areyousure('$r', ]. $member->membernum. ')">';
  $r .= " (${a}remove</A>)";
  $r;
};

my $html_init = '';
if ( $svc_mailinglist ) {
  my $svcnum = $svc_mailinglist->svcnum;
  my $label = encode_entities($svc_mailinglist->label);
  $html_init .= qq[<A HREF="${p}/view/svc_mailinglist.cgi?$svcnum">View customer mailing list: $label</A><BR><BR>];
}

$html_init .= <<"END";
<SCRIPT TYPE="text/javascript">
  function areyousure(email,membernum) {
    if ( confirm('Are you sure you want to remove ' + email + ' from this mailing list?') )
      window.location.href="${p}misc/delete-mailinglistmember.html?" + membernum;
    
  }
</SCRIPT>
END

</%init>