summaryrefslogtreecommitdiff
path: root/httemplate/browse/payment_gateway.html
blob: a06e5cf7cc456dae9481c181079a30e02162db0b (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<% include( 'elements/browse.html',
                'title'              => 'Payment gateways',
                'menubar'            => [ 'Agents' => $p.'browse/agent.cgi', ],
                'html_init'          => $html_init,
                'name'               => 'payment gateways',
                'disableable'        => 1,
                'disabled_statuspos' => 1,
                'query'              => { 'table'   => 'payment_gateway',
                                          'hashref' => {},
                                        },
                'count_query'        => $count_query,
                'header'             => [ '#',
                                          'Type',
                                          'Gateway',
                                          'Username',
                                          'Password',
                                          'Action',
                                          'URL',
                                          'Options',
                                        ],
                'fields'             => [ 'gatewaynum',
                                          'namespace_description',
                                          $gateway_sub,
                                          'gateway_username',
                                          sub { ' - '; },
                                          'gateway_action',
                                          'gateway_callback_url',
                                          $options_sub,
                                        ],
          )
%>

</TABLE>

<% include('/elements/footer.html') %>
<%once>

my $html_init = qq!
  <A HREF="${p}edit/payment_gateway.html"><I>Add a new payment gateway</I></A>
  <BR><BR>

  <SCRIPT>
    function areyousure(href) {
     if (confirm("Are you sure you want to disable this payment gateway?") == true)
       window.location.href = href;
    }
  </SCRIPT>

!;

my $gateway_sub = sub {
  my($payment_gateway) = @_;

  my $gatewaynum = $payment_gateway->gatewaynum;

  my $html = $payment_gateway->gateway_module. ' '. qq!
     <FONT SIZE="-1">
        <A HREF="${p}edit/payment_gateway.html?$gatewaynum">(edit)</A>
    !;

  unless ( $payment_gateway->disabled ) {
    $html .= qq!
        <A HREF="javascript:areyousure('${p}misc/disable-payment_gateway.cgi?$gatewaynum')">(disable)</A>
    !;
  }

  $html .= '</FONT>';

  $html;

};

my $options_sub = sub {
  my($payment_gateway) = @_;

  #should return a structure instead of this manual formatting...

  my $html = '<TABLE CELLSPACING=0 CELLPADDING=0>';

  my %options = $payment_gateway->options;
  foreach my $option ( keys %options ) {
    $html .= '<TR><TH>'. $option. ':</TH>'.
             '<TD>'. $options{$option}. '</TD></TR>';
  }
  $html .= '</TABLE>';

  $html;
};

my $count_query = 'SELECT COUNT(*) FROM payment_gateway';

</%once>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

</%init>