source: trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Search/Adv.pm @ 2054

Last change on this file since 2054 was 1329, checked in by nanardon, 9 years ago

Merge branch 'jquery'

File size: 1.5 KB
Line 
1package LATMOS::Accounts::Web::Controller::Search::Adv;
2use Moose;
3use namespace::autoclean;
4
5BEGIN { extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9LATMOS::Accounts::Web::Controller::Search::Adv - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19
20=head2 index
21
22=cut
23
24sub index :Path :Args(0) {
25    my ( $self, $c ) = @_;
26
27    $c->stash->{db} = $c->model('Accounts')->db;
28
29    if ($c->req->param('otype')) {
30        $c->session->{searchOtype} = $c->req->param('otype');
31    } elsif ($c->req->param('attr')) {
32        push(@{$c->session->{searchValues}}, sprintf('%s~%s', $c->req->param('attr'), $c->req->param('attrval')));
33    } elsif ($c->req->param('delval')) {
34        my @delvals = $c->req->param('delval');
35        my @newvals = ();
36        foreach my $v (@{$c->session->{searchValues} || []}) {
37            grep { $_ eq $v } @delvals and next;
38            push(@newvals, $v);
39        }
40        $c->session->{searchValues} = \@newvals;
41    } elsif(grep { $_ && $_ eq 'new' } $c->req->query_keywords) {
42        $c->session->{searchOtype} = undef;
43        $c->session->{searchValues} = [];
44    }
45   
46    if ($c->session->{searchOtype}) {
47        $c->stash->{objs} = [ $c->stash->{db}->search_objects(
48            $c->session->{searchOtype},
49            @{ $c->session->{searchValues} || []},
50        ) ];
51    }
52
53}
54
55
56=head1 AUTHOR
57
58olivier
59
60=head1 LICENSE
61
62This library is free software. You can redistribute it and/or modify
63it under the same terms as Perl itself.
64
65=cut
66
67__PACKAGE__->meta->make_immutable;
68
691;
Note: See TracBrowser for help on using the repository browser.