|
Lines 28-34
use warnings;
Link Here
|
| 28 |
use CGI; |
28 |
use CGI; |
| 29 |
use C4::Auth; # get_template_and_user |
29 |
use C4::Auth; # get_template_and_user |
| 30 |
use C4::Output; |
30 |
use C4::Output; |
| 31 |
use C4::Members; # BornameSearch |
31 |
use C4::Members qw/ FindByPartialName /; |
| 32 |
use C4::Branch; |
32 |
use C4::Branch; |
| 33 |
use C4::Category; |
33 |
use C4::Category; |
| 34 |
use File::Basename; |
34 |
use File::Basename; |
|
Lines 38-56
my $theme = $cgi->param('theme') || "default";
Link Here
|
| 38 |
my $resultsperpage = $cgi->param('resultsperpage')||C4::Context->preference("PatronsPerPage")||20; |
38 |
my $resultsperpage = $cgi->param('resultsperpage')||C4::Context->preference("PatronsPerPage")||20; |
| 39 |
my $startfrom = $cgi->param('startfrom')||1; |
39 |
my $startfrom = $cgi->param('startfrom')||1; |
| 40 |
|
40 |
|
| 41 |
my $patron = $cgi->Vars; |
41 |
my $member=$cgi->param('member'); |
| 42 |
foreach (keys %$patron){ |
42 |
my $branchcode = $cgi->param('branchcode'); |
| 43 |
delete $$patron{$_} unless($$patron{$_}); |
43 |
my $categorycode = $cgi->param('categorycode'); |
| 44 |
} |
|
|
| 45 |
|
44 |
|
| 46 |
my @categories=C4::Category->all; |
45 |
my @categories=C4::Category->all; |
| 47 |
my $branches=(defined $$patron{branchcode}?GetBranchesLoop($$patron{branchcode}):GetBranchesLoop()); |
46 |
my @branches=@{ GetBranchesLoop( |
| 48 |
my $subscriptionid = $cgi->param('subscriptionid'); |
47 |
$branchcode || undef |
| 49 |
my $searchstring = $cgi->param('member'); |
48 |
) }; |
| 50 |
|
49 |
|
| 51 |
my %categories_dislay; |
50 |
my %categories_display; |
| 52 |
my ($template, $loggedinuser, $cookie); |
51 |
my ($template, $loggedinuser, $cookie) |
| 53 |
($template, $loggedinuser, $cookie) |
|
|
| 54 |
= get_template_and_user({template_name => "serials/member-search.tmpl", |
52 |
= get_template_and_user({template_name => "serials/member-search.tmpl", |
| 55 |
query => $cgi, |
53 |
query => $cgi, |
| 56 |
type => "intranet", |
54 |
type => "intranet", |
|
Lines 63-146
foreach my $category (@categories){
Link Here
|
| 63 |
category_description=>$$category{description}, |
61 |
category_description=>$$category{description}, |
| 64 |
category_type=>$$category{category_type} |
62 |
category_type=>$$category{category_type} |
| 65 |
}; |
63 |
}; |
| 66 |
$categories_dislay{$$category{categorycode}} = $hash; |
64 |
$categories_display{$$category{categorycode}} = $hash; |
| 67 |
} |
65 |
} |
| 68 |
$template->param( |
|
|
| 69 |
"AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1", |
| 70 |
); |
| 71 |
if (C4::Context->preference("AddPatronLists")=~/code/){ |
66 |
if (C4::Context->preference("AddPatronLists")=~/code/){ |
| 72 |
$categories[0]->{'first'}=1; |
67 |
$categories[0]->{'first'}=1; |
| 73 |
} |
68 |
} |
| 74 |
|
69 |
|
| 75 |
my $member=$cgi->param('member'); |
|
|
| 76 |
my $orderby=$cgi->param('orderby'); |
| 77 |
$orderby = "surname,firstname" unless $orderby; |
| 78 |
if (defined $member) { |
| 79 |
$member =~ s/,//g; #remove any commas from search string |
| 80 |
$member =~ s/\*/%/g; |
| 81 |
} |
| 82 |
|
70 |
|
| 83 |
my ($count,$results); |
71 |
my ($count,@results) = (0); |
|
|
72 |
|
| 73 |
my $shouldsearch = $branchcode || $categorycode || $member; |
| 84 |
|
74 |
|
| 85 |
if (C4::Context->preference("IndependantBranches")){ |
75 |
if (C4::Context->preference("IndependantBranches")){ |
| 86 |
if (C4::Context->userenv && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){ |
76 |
if (C4::Context->userenv && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){ |
| 87 |
$$patron{branchcode}=C4::Context->userenv->{'branch'} unless (C4::Context->userenv->{'branch'} eq "insecure"); |
77 |
$branchcode = C4::Context->userenv->{'branch'} unless (C4::Context->userenv->{'branch'} eq "insecure"); |
| 88 |
} |
78 |
} |
| 89 |
} |
79 |
} |
| 90 |
$$patron{firstname}.="\%" if ($$patron{firstname}); |
|
|
| 91 |
$$patron{surname}.="\%" if ($$patron{surname}); |
| 92 |
|
80 |
|
| 93 |
my @searchpatron; |
81 |
|
| 94 |
push @searchpatron, $member if ($member); |
|
|
| 95 |
push @searchpatron, $patron if ( keys %$patron ); |
| 96 |
my $from = ( $startfrom - 1 ) * $resultsperpage; |
82 |
my $from = ( $startfrom - 1 ) * $resultsperpage; |
| 97 |
my $to = $from + $resultsperpage; |
83 |
my $to = $from + $resultsperpage; |
| 98 |
if (@searchpatron) { |
84 |
if ($shouldsearch) { |
| 99 |
($results) = Search( |
85 |
@results = FindByPartialName( |
| 100 |
\@searchpatron, |
86 |
$member, |
| 101 |
[ { surname => 0 }, { firstname => 0 } ], |
87 |
categorycode => $categorycode, |
| 102 |
undef, |
88 |
branchcode => $branchcode, |
| 103 |
undef, |
|
|
| 104 |
[ "firstname", "surname", "email", "othernames", "cardnumber" ], |
| 105 |
"start_with" |
| 106 |
); |
89 |
); |
| 107 |
} |
90 |
} |
| 108 |
if ($results) { |
91 |
if (@results) { |
| 109 |
$count = scalar(@$results); |
92 |
$count = @results; |
| 110 |
} |
93 |
} |
| 111 |
my @resultsdata; |
94 |
my @resultsdata; |
| 112 |
$to=($count>$to?$to:$count); |
95 |
$to=($count>$to?$to:$count); |
| 113 |
my $index=$from; |
96 |
my $index=$from; |
| 114 |
foreach my $borrower(@$results[$from..$to-1]){ |
97 |
foreach my $borrower (@results[$from..$to-1]){ |
| 115 |
# find out stats |
98 |
# find out stats |
| 116 |
$borrower->{'dateexpiry'}= C4::Dates->new($borrower->{'dateexpiry'},'iso')->output('syspref'); |
99 |
if ($categories_display{$borrower->{'categorycode'}}){ |
| 117 |
if ($categories_dislay{$borrower->{'categorycode'}}){ |
|
|
| 118 |
my %row = ( |
100 |
my %row = ( |
| 119 |
count => $index++, |
101 |
count => $index++, |
| 120 |
%$borrower, |
102 |
%$borrower, |
| 121 |
%{$categories_dislay{$$borrower{categorycode}}}, |
103 |
%{$categories_display{$$borrower{categorycode}}}, |
| 122 |
); |
104 |
); |
| 123 |
push(@resultsdata, \%row); |
105 |
push(@resultsdata, \%row); |
| 124 |
} |
106 |
} else { |
| 125 |
else { |
107 |
warn $borrower->{'cardnumber'} ." has a bad category code of " . $borrower->{'categorycode'} ."\n"; |
| 126 |
warn $borrower->{'cardnumber'} ." has a bad category code of " . $borrower->{'categorycode'} ."\n"; |
|
|
| 127 |
} |
108 |
} |
| 128 |
} |
109 |
} |
| 129 |
if ($$patron{branchcode}){ |
110 |
if ($branchcode){ |
| 130 |
foreach my $branch (grep{$_->{value} eq $$patron{branchcode}}@$branches){ |
111 |
foreach my $branch (grep {$_->{value} eq $branchcode} @branches){ |
| 131 |
$$branch{selected}=1; |
112 |
$$branch{selected}=1; |
| 132 |
} |
113 |
} |
| 133 |
} |
114 |
} |
| 134 |
if ($$patron{categorycode}){ |
115 |
if ($categorycode){ |
| 135 |
foreach my $category (grep{$_->{categorycode} eq $$patron{categorycode}}@categories){ |
116 |
foreach my $category (grep {$_->{categorycode} eq $categorycode} @categories){ |
| 136 |
$$category{selected}=1; |
117 |
$$category{selected}=1; |
| 137 |
} |
118 |
} |
| 138 |
} |
119 |
} |
| 139 |
my %parameters= |
120 |
my %parameters=( |
| 140 |
( %{$patron}, |
121 |
member => $member, |
| 141 |
'orderby' => $orderby, |
122 |
categorycode => $categorycode, |
| 142 |
'resultsperpage' => $resultsperpage, |
123 |
branchcode => $branchcode, |
| 143 |
'type'=> 'intranet'); |
124 |
resultsperpage => $resultsperpage, |
|
|
125 |
type => 'intranet' |
| 126 |
); |
| 144 |
my $base_url = |
127 |
my $base_url = |
| 145 |
'member-search.pl?&' |
128 |
'member-search.pl?&' |
| 146 |
. join( |
129 |
. join( |
|
Lines 158-175
$template->param(
Link Here
|
| 158 |
to => $to, |
141 |
to => $to, |
| 159 |
multipage => ($count != $to+1 || $startfrom!=1), |
142 |
multipage => ($count != $to+1 || $startfrom!=1), |
| 160 |
); |
143 |
); |
|
|
144 |
|
| 161 |
$template->param( |
145 |
$template->param( |
| 162 |
branchloop=>$branches, |
146 |
branchloop=>\@branches, |
| 163 |
categoryloop=>\@categories, |
147 |
categoryloop=>\@categories, |
| 164 |
); |
148 |
); |
| 165 |
|
149 |
|
| 166 |
|
|
|
| 167 |
$template->param( |
150 |
$template->param( |
| 168 |
searching => "1", |
151 |
searching => $shouldsearch, |
| 169 |
actionname => basename($0), |
152 |
actionname => basename($0), |
| 170 |
%$patron, |
153 |
%parameters, |
| 171 |
numresults => $count, |
154 |
numresults => $count, |
| 172 |
resultsloop => \@resultsdata, |
155 |
resultsloop => \@resultsdata, |
| 173 |
); |
156 |
); |
| 174 |
|
157 |
|
| 175 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
158 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
| 176 |
- |
|
|