diff --git a/lib/admin/Controller/subscriber.pm b/lib/admin/Controller/subscriber.pm index 1a8926a..7ae3efa 100644 --- a/lib/admin/Controller/subscriber.pm +++ b/lib/admin/Controller/subscriber.pm @@ -38,14 +38,67 @@ sub search : Local { $c->stash->{template} = 'tt/subscriber.tt'; my $limit = 10; + my %filter; + my %exact; + + if($c->request->params->{use_session}) { + %filter = %{ $c->session->{search_filter} }; + %exact = %{ $c->session->{exact_filter} }; + } else { + if(defined $c->request->params->{search_user} and length $c->request->params->{search_user}) { + $filter{username} = $c->request->params->{search_user}; + unless($c->request->params->{exact_user}) { + $filter{username} =~ s/^\%*/\%/; + $filter{username} =~ s/\%*$/\%/; + } else { + $exact{username} = 1; + } + } + if(defined $c->request->params->{search_e164} and length $c->request->params->{search_e164}) { + $filter{number} = $c->request->params->{search_e164}; + unless($c->request->params->{exact_e164}) { + $filter{number} =~ s/^\%*/\%/; + $filter{number} =~ s/\%*$/\%/; + } else { + $exact{number} = 1; + } + } + if(defined $c->request->params->{search_uuid} and length $c->request->params->{search_uuid}) { + $filter{uuid} = $c->request->params->{search_uuid}; + unless($c->request->params->{exact_uuid}) { + $filter{uuid} =~ s/^\%*/\%/; + $filter{uuid} =~ s/\%*$/\%/; + } else { + $exact{uuid} = 1; + } + } + } + + $c->session->{search_filter} = \%filter; + $c->session->{exact_filter} = \%exact; + + $c->stash->{exact_user} = $exact{username}; + $c->stash->{exact_e164} = $exact{number}; + $c->stash->{exact_uuid} = $exact{uuid}; + + $c->stash->{search_user} = $filter{username}; + $c->stash->{search_e164} = $filter{number}; + $c->stash->{search_uuid} = $filter{uuid}; + $c->stash->{search_user} =~ s/^\%*(.*?)\%*$/$1/ if defined $c->stash->{search_user}; + $c->stash->{search_e164} =~ s/^\%*(.*?)\%*$/$1/ if defined $c->stash->{search_e164}; + $c->stash->{search_uuid} =~ s/^\%*(.*?)\%*$/$1/ if defined $c->stash->{search_uuid}; + + unless(keys %filter) { + $c->session->{messages}{toperr} = 'Web.MissingSearchString'; + return; + } - my $searchstring = $c->request->params->{search_string}; my $offset = $c->request->params->{offset} || 0; $offset = 0 if $offset !~ /^\d+$/; my $subscriber_list; return unless $c->model('Provisioning')->call_prov( $c, 'billing', 'search_subscribers', - { filter => { username => '%'.$searchstring.'%', + { filter => { %filter, limit => $limit, offset => $limit * $offset, }, @@ -53,7 +106,6 @@ sub search : Local { \$subscriber_list ); - $c->stash->{search_string} = $searchstring; $c->stash->{searched} = 1; if(ref $$subscriber_list{subscribers} eq 'ARRAY' and @{$$subscriber_list{subscribers}}) { $c->stash->{subscriber_list} = $$subscriber_list{subscribers}; diff --git a/root/css/admin.css b/root/css/admin.css index d918754..fa99df0 100644 --- a/root/css/admin.css +++ b/root/css/admin.css @@ -258,3 +258,32 @@ h3 { #contentplace .pagination li.nextpage a:after { content: ""; } + +/* colorful table rows */ +#contentplace .tr_alt { + background-color: #ccffcc; +} + +#contentplace .orders, +#contentplace .contracts, +#contentplace .order_payments +{ + width: 100%; + border-spacing: 0px; +} + +#contentplace .table_name { + font-weight: bold; + white-space: nowrap; + text-align: center; +} + +/* align search labels and text fields */ +#contentplace .search_subscriber .search_label { + float: left; + min-width: 100px; + margin-top: 3px; +} +#contentplace .search_subscriber input { + margin: 3px 0; +} diff --git a/root/tt/subscriber.tt b/root/tt/subscriber.tt index ff3d1a7..4db9f37 100644 --- a/root/tt/subscriber.tt +++ b/root/tt/subscriber.tt @@ -1,7 +1,22 @@ -

Search Subscribers

+

Search subscribers

-
- + + + + + +
+ + + + +
+ + + + +
+
@@ -41,7 +56,7 @@
  • « prev
  • [% ELSE %]
  • - « prev + « prev
  • [% END %] [% FOREACH pagine = pagination %] @@ -53,8 +68,7 @@ ... [% ELSE %]
  • - [% pagine.offset + 1 %] + [% pagine.offset + 1 %]
  • [% END %] [% END %] @@ -64,7 +78,7 @@ [% ELSE %]
  • - next » + next »
  • [% END %]