fix FK upgrade for pkg_referral: remove records referencing non-existant customer...
[freeside.git] / httemplate / browse / acct_snarf.html
1 <% include('elements/browse.html',
2              'title'         => "Remote POP accounts for $svc_label: $svc_value",
3              'name_singular' => 'Remote POP account',
4              'html_init'     => $html_init,
5              'query'         => { 'table'   => 'acct_snarf',
6                                   'hashref' => { 'svcnum' => $svcnum },
7                                   #'order_by' => 'ORDER BY priority DESC',
8                                 },
9              'count_query'   => $count_query,
10              'header'        => [ 'Name',
11                                   'Mail server',
12                                   'Username',
13                                   #'Password',
14                                   'Poll every',
15                                   #'Options',
16                                   'Leave',
17                                   'APOP',
18                                   'TLS',
19                                   'Mailbox',
20                                   '', #delete
21                                 ],
22              'fields'        => [ 'snarfname',
23                                   'machine',
24                                   'username',
25                                   sub { FS::acct_snarf->check_freq_labels->{shift->check_freq} },
26                                   'leave',
27                                   'apop',
28                                   'tls',
29                                   'mailbox',
30                                 ],
31              #'align'
32              'links'         => [ $edit_sub, $edit_sub, $edit_sub, '',
33                                   '', '', '', '', $del_sub ],
34           )
35 %>
36 <%init>
37
38 $cgi->param('svcnum') =~ /^(\d+)$/ or die 'no svcnum';
39 my $svcnum = $1;
40
41 #agent virt so you can't do cross-agent snarfing
42 my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $svcnum })
43   or die 'unknown svcnum';
44 my $part_svc = $cust_svc->part_svc;
45
46 my $count_query = "SELECT COUNT(*) FROM acct_snarf WHERE svcnum = $svcnum";
47
48 my($svc_label, $svc_value, $svcdb) = $cust_svc->label;
49
50 my $view = FS::UI::Web::svc_url( 'm'        => $m,
51                                  'action'   => 'view',
52                                  'part_svc' => $part_svc, 
53                                  'svc'      => $cust_svc,
54                                );
55
56 my $html_init =
57   qq(<A HREF="$view">View this $svc_label</A><BR><BR>).
58   qq!<A HREF="${p}edit/acct_snarf.html?svcnum=$svcnum">Add new remote POP account</A><BR>!.
59   '<BR>'.
60   qq!
61   <SCRIPT>
62     function areyousure_delete(href) {
63      areyousure(href,"Are you sure you want to delete this remote POP account?");
64     }
65     function areyousure(href,message) {
66      if (confirm(message) == true)
67        window.location.href = href;
68     }
69   </SCRIPT>
70 !;
71
72 my $edit_sub = [ $p.'edit/acct_snarf.html?', 'snarfnum' ];
73 my $del_sub = sub {
74   my $snarfnum = shift->snarfnum;
75   [ "javascript:areyousure_delete('${p}misc/delete-acct_snarf.html?$snarfnum')", '' ];
76 };
77
78 </%init>