summaryrefslogtreecommitdiff
path: root/httemplate/browse
diff options
context:
space:
mode:
authorivan <ivan>2008-03-02 01:31:39 +0000
committerivan <ivan>2008-03-02 01:31:39 +0000
commit53547a802d5c76be967cc14301fc8a692f0fe066 (patch)
tree54f1d62bf4b0e1cde08249798339358437fa9693 /httemplate/browse
parentc21f9fadde9100aedb8c4cfc35629bc3294ba91e (diff)
add payment gateway disabling (and move payment gateway browse over to new template)
Diffstat (limited to 'httemplate/browse')
-rw-r--r--httemplate/browse/payment_gateway.html147
1 files changed, 81 insertions, 66 deletions
diff --git a/httemplate/browse/payment_gateway.html b/httemplate/browse/payment_gateway.html
index 671f7118c..848c58a82 100644
--- a/httemplate/browse/payment_gateway.html
+++ b/httemplate/browse/payment_gateway.html
@@ -1,79 +1,94 @@
-<% include("/elements/header.html",'Payment gateways', menubar(
- 'Agents' => $p. 'browse/agent.cgi',
-)) %>
+<% 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' => [ '#',
+ 'Gateway',
+ 'Username',
+ 'Password',
+ 'Action',
+ 'Options',
+ ],
+ 'fields' => [ 'gatewaynum',
+ $gateway_sub,
+ 'gateway_username',
+ sub { ' - '; },
+ 'gateway_action',
+ $options_sub,
+ ],
+ )
+%>
-<A HREF="<% $p %>edit/payment_gateway.html"><I>Add a new payment gateway</I></A><BR><BR>
+</TABLE>
-<% $cgi->param('showdisabled')
- ? do { $cgi->param('showdisabled', 0);
- '( <a href="'. $cgi->self_url. '">hide disabled gateways</a> )'; }
- : do { $cgi->param('showdisabled', 1);
- '( <a href="'. $cgi->self_url. '">show disabled gateways</a> )'; }
-%>
+<% include('/elements/footer.html') %>
+<%once>
-<% table() %>
-<TR>
- <TH COLSPAN=<% $cgi->param('showdisabled') ? 1 : 2 %>>#</TH>
- <TH>Gateway</TH>
- <TH>Username</TH>
- <TH>Password</TH>
- <TH>Action</TH>
- <TH>Options</TH>
-</TR>
-% foreach my $payment_gateway ( qsearch( 'payment_gateway', \%search ) ) {
-
-
- <TR>
- <TD><% $payment_gateway->gatewaynum %></TD>
-% if ( !$cgi->param('showdisabled') ) {
-
- <TD><% $payment_gateway->disabled ? 'DISABLED' : '' %></TD>
-% }
-
- <TD><% $payment_gateway->gateway_module %>
- <FONT SIZE="-1">
- <A HREF="<%$p%>edit/payment_gateway.html?<% $payment_gateway->gatewaynum %>">(edit)</A>
- <% !$payment_gateway->disabled
- ? '<A HREF="'. $p. 'misc/disable-payment_gateway.cgi?'. $payment_gateway->gatewaynum.'">(disable)</A>'
- : ''
- %>
- </FONT>
- </TD>
- <TD><% $payment_gateway->gateway_username %></TD>
- <TD> - </TD>
- <TD><% $payment_gateway->gateway_action %></TD>
- <TD>
- <TABLE CELLSPACING=0 CELLPADDING=0>
-% my %options = $payment_gateway->options;
-% foreach my $option ( keys %options ) {
-%
-
- <TR>
- <TH><% $option %>:</TH>
- <TD><% $options{$option} %></TD>
- </TR>
-% }
-
- </TABLE>
- </TD>
- </TR>
-% }
+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>
-</TABLE>
+!;
-<% include('/elements/footer.html') %>
+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');
-my %search;
-if ( $cgi->param('showdisabled') ) {
- %search = ();
-} else {
- %search = ( 'disabled' => '' );
-}
-
</%init>