From ff9319aea6e1454651aa81f30a04e59c2df34678 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Mon, 14 Sep 2009 22:01:54 +0200 Subject: [PATCH] Adding More filters for member.pl page : Adding Search Function on Members which is a search on all the fields in Members Adding search.tmpl which adds a filter possiblity on Member page Adding the management and the use of Search function in C4::Members --- C4/Members.pm | 11 ++++- .../prog/en/modules/members/member.tmpl | 8 ++- .../prog/en/modules/members/search.tmpl | 30 ++++++++++++ members/member.pl | 49 +++++++++---------- 4 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tmpl diff --git a/C4/Members.pm b/C4/Members.pm index 00998b8af3..e813d9077e 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -28,7 +28,7 @@ use C4::Overdues; use C4::Reserves; use C4::Accounts; use C4::Biblio; -use C4::SQLHelper qw(InsertInTable UpdateInTable); +use C4::SQLHelper qw(InsertInTable UpdateInTable SearchInTable); our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug); @@ -39,6 +39,7 @@ BEGIN { @ISA = qw(Exporter); #Get data push @EXPORT, qw( + &Search &SearchMember &GetMemberDetails &GetMember @@ -253,6 +254,14 @@ AND attribute like ? return ( scalar(@$data), $data ); } +sub Search { + my ($filter,$orderby ) = @_; + + my $data=SearchInTable("borrowers",$filter,$orderby); + + return ( $data ); +} + =head2 GetMemberDetails ($borrower) = &GetMemberDetails($borrowernumber, $cardnumber); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl index 96b29ac229..de5f1605e2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl @@ -8,11 +8,14 @@ -
+
-
+
+ +
+
@@ -109,4 +112,5 @@ No results found
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tmpl new file mode 100644 index 0000000000..15bc172877 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tmpl @@ -0,0 +1,30 @@ +
+
search
+ Patron information + + " />
+ " />
+ " />
+ " />
+ " />
+ " />
+
+
+ Library Management + +
+ +
+ +
+
diff --git a/members/member.pl b/members/member.pl index fcc6ee1125..9192be8ae6 100755 --- a/members/member.pl +++ b/members/member.pl @@ -27,7 +27,8 @@ use C4::Auth; use C4::Output; use CGI; use C4::Members; - +use C4::Branch; +use C4::Category; my $input = new CGI; my $quicksearch = $input->param('quicksearch'); @@ -80,45 +81,40 @@ $member =~ s/\*/%/g; my ($count,$results); -if(length($member) == 1) -{ - ($count,$results)=SearchMember($member,$orderby,"simple"); +my $patron = $input->Vars; +foreach (keys %$patron){ + delete $$patron{$_} unless($$patron{$_}); } -else -{ - ($count,$results)=SearchMember($member,$orderby,"advanced"); +($results)=Search($patron,{surname=>1,firstname=>1}) if (keys %$patron); +$count =scalar(@$results); +use YAML; +warn Dump($results); +unless ($count){ + if(length($member) == 1) + { + ($count,$results)=SearchMember($member,$orderby,"simple"); + } + else + { + ($count,$results)=SearchMember($member,$orderby,"advanced"); + } } - my @resultsdata; my $to=($count>($startfrom*$resultsperpage)?$startfrom*$resultsperpage:$count); for (my $i=($startfrom-1)*$resultsperpage; $i < $to; $i++){ #find out stats my ($od,$issue,$fines)=GetMemberIssuesAndFines($results->[$i]{'borrowernumber'}); + $$results[$i]{'dateexpiry'}= C4::Dates->new($results->[$i]{'dateexpiry'},'iso')->output('syspref'); + my %row = ( count => $i+1, - borrowernumber => $results->[$i]{'borrowernumber'}, - cardnumber => $results->[$i]{'cardnumber'}, - surname => $results->[$i]{'surname'}, - firstname => $results->[$i]{'firstname'}, - categorycode => $results->[$i]{'categorycode'}, - category_type => $results->[$i]{'category_type'}, - category_description => $results->[$i]{'description'}, - address => $results->[$i]{'address'}, - address2 => $results->[$i]{'address2'}, - city => $results->[$i]{'city'}, - zipcode => $results->[$i]{'zipcode'}, - country => $results->[$i]{'country'}, - branchcode => $results->[$i]{'branchcode'}, + %{$results->[$i]}, overdues => $od, issues => $issue, odissue => "$od/$issue", fines => sprintf("%.2f",$fines), - borrowernotes => $results->[$i]{'borrowernotes'}, - sort1 => $results->[$i]{'sort1'}, - sort2 => $results->[$i]{'sort2'}, - dateexpiry => C4::Dates->new($results->[$i]{'dateexpiry'},'iso')->output('syspref'), ); push(@resultsdata, \%row); } @@ -134,6 +130,7 @@ my $base_url = ) ); +my @categories=C4::Category->all; $template->param( paginationbar => pagination_bar( $base_url, int( $count / $resultsperpage ) + 1, @@ -143,6 +140,8 @@ $template->param( from => ($startfrom-1)*$resultsperpage+1, to => $to, multipage => ($count != $to || $startfrom!=1), + branchloop=>GetBranchesLoop(), + categoryloop=>\@categories, ); $template->param( -- 2.39.5