also fix searching by charged/owed amount
[freeside.git] / httemplate / view / svc_mailinglist.cgi
1 <% include('elements/svc_Common.html',
2              'table' => 'svc_mailinglist',
3              %opt,
4           )
5 %>
6 <%init>
7
8 my %opt = ();
9
10 my $info = FS::svc_mailinglist->table_info;
11
12 $opt{'name'} = $info->{'name'};
13
14 my $fields = $info->{'fields'};
15 my %labels = map { $_ =>  ( ref($fields->{$_})
16                              ? $fields->{$_}{'label'}
17                              : $fields->{$_}
18                          );
19                  }
20              keys %$fields;
21
22 #$opt{'fields'} = [ keys %$fields ];
23 $opt{'fields'} = [
24   'username',
25   'domain',
26   'listname',
27   'reply_to',
28   'remove_from',
29   'reject_auto',
30   'remove_to_and_cc',
31 ];
32
33 $opt{'labels'} = \%labels;
34
35 $opt{'html_foot'} = sub {
36   my $svc_mailinglist = shift;
37   my $listnum = $svc_mailinglist->listnum;
38
39   my $sql = 'SELECT COUNT(*) FROM mailinglistmember WHERE listnum = ?';
40   my $sth = dbh->prepare($sql) or die dbh->errstr;
41   $sth->execute($listnum) or die $sth->errstr;
42   my $num = $sth->fetchrow_arrayref->[0];
43
44   my $add_url = $p."edit/mailinglistmember.html?listnum=$listnum";
45
46   my $add_link = include('/elements/init_overlib.html').
47                  include('/elements/popup_link.html',
48                            'action' => $add_url,
49                            'label'  => 'add',
50                            'actionlabel' => 'Add list member',
51                            'width'  => 392,
52                            'height' => 192,
53                         );
54
55   ntable('#cccccc').'<TR><TD>'.ntable('#cccccc',2). qq[
56     <TR>
57       <TD>List members</TD>
58       <TD BGCOLOR="#ffffff">
59         $num members
60         ( <A HREF="${p}search/mailinglistmember.html?listnum=$listnum">view</A>
61         | $add_link )
62       </TD>
63     </TR>
64     </TABLE></TD></TR></TABLE>
65
66     <BR><BR>
67   ]. include('svc_export_settings.html', $svc_mailinglist);
68
69 };
70
71 </%init>