From 53547a802d5c76be967cc14301fc8a692f0fe066 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 2 Mar 2008 01:31:39 +0000 Subject: add payment gateway disabling (and move payment gateway browse over to new template) --- httemplate/browse/payment_gateway.html | 147 +++++++++++++++------------- httemplate/misc/disable-payment_gateway.cgi | 25 +++++ httemplate/search/elements/search.html | 4 +- 3 files changed, 109 insertions(+), 67 deletions(-) create mode 100644 httemplate/misc/disable-payment_gateway.cgi (limited to 'httemplate') 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, + ], + ) +%> -Add a new payment gateway

+ -<% $cgi->param('showdisabled') - ? do { $cgi->param('showdisabled', 0); - '( hide disabled gateways )'; } - : do { $cgi->param('showdisabled', 1); - '( show disabled gateways )'; } -%> +<% include('/elements/footer.html') %> +<%once> -<% table() %> - - param('showdisabled') ? 1 : 2 %>># - Gateway - Username - Password - Action - Options - -% foreach my $payment_gateway ( qsearch( 'payment_gateway', \%search ) ) { - - - - <% $payment_gateway->gatewaynum %> -% if ( !$cgi->param('showdisabled') ) { - - <% $payment_gateway->disabled ? 'DISABLED' : '' %> -% } - - <% $payment_gateway->gateway_module %> - - (edit) - <% !$payment_gateway->disabled - ? '(disable)' - : '' - %> - - - <% $payment_gateway->gateway_username %> - - - <% $payment_gateway->gateway_action %> - - -% my %options = $payment_gateway->options; -% foreach my $option ( keys %options ) { -% - - - - - -% } - -
<% $option %>:<% $options{$option} %>
- - -% } +my $html_init = qq! + Add a new payment gateway +

+ - +!; -<% include('/elements/footer.html') %> +my $gateway_sub = sub { + my($payment_gateway) = @_; + + my $gatewaynum = $payment_gateway->gatewaynum; + + my $html = $payment_gateway->gateway_module. ' '. qq! + + (edit) + !; + + unless ( $payment_gateway->disabled ) { + $html .= qq! + (disable) + !; + } + + $html .= ''; + $html; + +}; + +my $options_sub = sub { + my($payment_gateway) = @_; + + #should return a structure instead of this manual formatting... + + my $html = ''; + + my %options = $payment_gateway->options; + foreach my $option ( keys %options ) { + $html .= ''. + ''; + } + $html .= '
'. $option. ':'. $options{$option}. '
'; + + $html; +}; + +my $count_query = 'SELECT COUNT(*) FROM payment_gateway'; + + <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my %search; -if ( $cgi->param('showdisabled') ) { - %search = (); -} else { - %search = ( 'disabled' => '' ); -} - diff --git a/httemplate/misc/disable-payment_gateway.cgi b/httemplate/misc/disable-payment_gateway.cgi new file mode 100644 index 000000000..13e1f92bc --- /dev/null +++ b/httemplate/misc/disable-payment_gateway.cgi @@ -0,0 +1,25 @@ +%if ( $error ) { +% errorpage($error); +%} else { +%#<% $cgi->redirect(popurl(2). "browse/payment_gateway.html?showdiabled=$showdisabled") %> +<% $cgi->redirect(popurl(2). "browse/payment_gateway.html") %> +%} +<%init> + +die "access deined" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +#my $showdisabled = 0; +#$cgi->param('showdisabled') =~ /^(\d+)$/ and $showdisabled = $1; + +#$cgi->param('gatewaynum') =~ /^(\d+)$/ or die 'illegal gatewaynum'; +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/ or die 'illegal gatewaynum'; +my $gatewaynum = $1; + +my $payment_gateway = + qsearchs('payment_gateway', { 'gatewaynum' => $gatewaynum } ); + +my $error = $payment_gateway->disable; + + diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 14c6a0b6a..e1bc02450 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -319,7 +319,9 @@ Example: % unless ( $opt{'disable_nonefound'} ) { No matching <% $opt{'name'} %> found.
% } -% } else { +% } +% +% if ( $total || $opt{'disableable'} ) { #hmm... and there *are* ones to show?? -- cgit v1.2.1