import torrus 1.0.9
[freeside.git] / httemplate / browse / payment_gateway.html
1 <% include( 'elements/browse.html',
2                 'title'              => 'Payment gateways',
3                 'menubar'            => [ 'Agents' => $p.'browse/agent.cgi', ],
4                 'html_init'          => $html_init,
5                 'name'               => 'payment gateways',
6                 'disableable'        => 1,
7                 'disabled_statuspos' => 1,
8                 'query'              => { 'table'   => 'payment_gateway',
9                                           'hashref' => {},
10                                         },
11                 'count_query'        => $count_query,
12                 'header'             => [ '#',
13                                           'Type',
14                                           'Gateway',
15                                           'Username',
16                                           'Password',
17                                           'Action',
18                                           'URL',
19                                           'Options',
20                                         ],
21                 'fields'             => [ 'gatewaynum',
22                                           'namespace_description',
23                                           $gateway_sub,
24                                           'gateway_username',
25                                           sub { ' - '; },
26                                           'gateway_action',
27                                           'gateway_callback_url',
28                                           $options_sub,
29                                         ],
30           )
31 %>
32
33 </TABLE>
34
35 <% include('/elements/footer.html') %>
36 <%once>
37
38 my $html_init = qq!
39   <A HREF="${p}edit/payment_gateway.html"><I>Add a new payment gateway</I></A>
40   <BR><BR>
41
42   <SCRIPT>
43     function areyousure(href) {
44      if (confirm("Are you sure you want to disable this payment gateway?") == true)
45        window.location.href = href;
46     }
47   </SCRIPT>
48
49 !;
50
51 my $gateway_sub = sub {
52   my($payment_gateway) = @_;
53
54   my $gatewaynum = $payment_gateway->gatewaynum;
55
56   my $html = $payment_gateway->gateway_module. ' '. qq!
57      <FONT SIZE="-1">
58         <A HREF="${p}edit/payment_gateway.html?$gatewaynum">(edit)</A>
59     !;
60
61   unless ( $payment_gateway->disabled ) {
62     $html .= qq!
63         <A HREF="javascript:areyousure('${p}misc/disable-payment_gateway.cgi?$gatewaynum')">(disable)</A>
64     !;
65   }
66
67   $html .= '</FONT>';
68
69   $html;
70
71 };
72
73 my $options_sub = sub {
74   my($payment_gateway) = @_;
75
76   #should return a structure instead of this manual formatting...
77
78   my $html = '<TABLE CELLSPACING=0 CELLPADDING=0>';
79
80   my %options = $payment_gateway->options;
81   foreach my $option ( keys %options ) {
82     $html .= '<TR><TH>'. $option. ':</TH>'.
83              '<TD>'. $options{$option}. '</TD></TR>';
84   }
85   $html .= '</TABLE>';
86
87   $html;
88 };
89
90 my $count_query = 'SELECT COUNT(*) FROM payment_gateway';
91
92 </%once>
93 <%init>
94
95 die "access denied"
96   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
97
98 </%init>