This commit was generated by cvs2svn to compensate for changes in r6252,
[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                                           'Gateway',
14                                           'Username',
15                                           'Password',
16                                           'Action',
17                                           'Options',
18                                         ],
19                 'fields'             => [ 'gatewaynum',
20                                           $gateway_sub,
21                                           'gateway_username',
22                                           sub { ' - '; },
23                                           'gateway_action',
24                                           $options_sub,
25                                         ],
26           )
27 %>
28
29 </TABLE>
30
31 <% include('/elements/footer.html') %>
32 <%once>
33
34 my $html_init = qq!
35   <A HREF="${p}edit/payment_gateway.html"><I>Add a new payment gateway</I></A>
36   <BR><BR>
37
38   <SCRIPT>
39     function areyousure(href) {
40      if (confirm("Are you sure you want to disable this payment gateway?") == true)
41        window.location.href = href;
42     }
43   </SCRIPT>
44
45 !;
46
47 my $gateway_sub = sub {
48   my($payment_gateway) = @_;
49
50   my $gatewaynum = $payment_gateway->gatewaynum;
51
52   my $html = $payment_gateway->gateway_module. ' '. qq!
53      <FONT SIZE="-1">
54         <A HREF="${p}edit/payment_gateway.html?$gatewaynum">(edit)</A>
55     !;
56
57   unless ( $payment_gateway->disabled ) {
58     $html .= qq!
59         <A HREF="javascript:areyousure('${p}misc/disable-payment_gateway.cgi?$gatewaynum')">(disable)</A>
60     !;
61   }
62
63   $html .= '</FONT>';
64
65   $html;
66
67 };
68
69 my $options_sub = sub {
70   my($payment_gateway) = @_;
71
72   #should return a structure instead of this manual formatting...
73
74   my $html = '<TABLE CELLSPACING=0 CELLPADDING=0>';
75
76   my %options = $payment_gateway->options;
77   foreach my $option ( keys %options ) {
78     $html .= '<TR><TH>'. $option. ':</TH>'.
79              '<TD>'. $options{$option}. '</TD></TR>';
80   }
81   $html .= '</TABLE>';
82
83   $html;
84 };
85
86 my $count_query = 'SELECT COUNT(*) FROM payment_gateway';
87
88 </%once>
89 <%init>
90
91 die "access denied"
92   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
93
94 </%init>