Bugzilla – Attachment 11265 Details for
Bug 5357
Subscription search and displays
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8443: Suggestions publication year and copyright date
Bug-8443-Suggestions-publication-year-and-copyrigh.patch (text/plain), 10.93 KB, created by
Paul Poulain
on 2012-08-01 14:49:29 UTC
(
hide
)
Description:
Bug 8443: Suggestions publication year and copyright date
Filename:
MIME Type:
Creator:
Paul Poulain
Created:
2012-08-01 14:49:29 UTC
Size:
10.93 KB
patch
obsolete
>From d5fa1266945369122c53cbaa5a6bd78bd252ae45 Mon Sep 17 00:00:00 2001 >From: Fridolyn SOMERS <fridolyn.somers@biblibre.com> >Date: Tue, 24 Jul 2012 11:12:53 +0200 >Subject: [PATCH] Bug 8443: Suggestions publication year and copyright date > >Signed-off-by: Corinne HAYET <corinne.hayet@bulac.fr> > >http://bugs.koha-community.org/show_bug.cgi?id=5357 >Signed-off-by: Corinne HAYET <corinne.hayet@bulac.fr> >--- > C4/Suggestions.pm | 79 +++++++++++-------- > .../prog/en/modules/suggestion/suggestion.tt | 14 ++-- > suggestion/suggestion.pl | 16 ++++- > 3 files changed, 67 insertions(+), 42 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 0cb484a..0d07c1f 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -93,7 +93,7 @@ sub SearchSuggestion { > my $dbh = C4::Context->dbh; > my @sql_params; > my @query = ( >- q{ SELECT suggestions.*, >+ q/SELECT suggestions.*, > U1.branchcode AS branchcodesuggestedby, > B1.branchname AS branchnamesuggestedby, > U1.surname AS surnamesuggestedby, >@@ -115,49 +115,61 @@ sub SearchSuggestion { > LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber > LEFT JOIN branches AS B2 ON B2.branchcode=U2.branchcode > LEFT JOIN categories AS C2 ON C2.categorycode = U2.categorycode >- WHERE 1=1 >- } , map { >- if ( my $s = $suggestion->{$_} ) { >- push @sql_params,'%'.$s.'%'; >- " and suggestions.$_ like ? "; >- } else { () } >- } qw( title author isbn publishercode collectiontitle ) >+ WHERE 1=1/ > ); >+ >+ # filter on biblio informations >+ foreach my $field ( >+ grep { >+ my $fieldname = $_; >+ any { $fieldname eq $_ } qw/title author isbn publishercode copyrightdate collectiontitle/ >+ } keys %$suggestion >+ ) >+ { >+ if ( $suggestion->{$field} ) { >+ push @sql_params, $suggestion->{$field}; >+ push @query, " AND suggestions.$field = ?"; >+ } >+ } > >+ # filter on user branch > my $userenv = C4::Context->userenv; > if (C4::Context->preference('IndependantBranches')) { >- if ($userenv) { >- if (($userenv->{flags} % 2) != 1 && !$suggestion->{branchcode}){ >- push @sql_params,$$userenv{branch}; >- push @query,q{ and (suggestions.branchcode = ? or suggestions.branchcode ='')}; >- } >+ if ($userenv) { >+ if (($userenv->{flags} % 2) != 1 && !$suggestion->{branchcode}){ >+ push @sql_params, $userenv->{branch}; >+ push @query, q/ AND (suggestions.branchcode = ? or suggestions.branchcode = '')/; > } >+ } > } > >- foreach my $field (grep { my $fieldname=$_; >- any {$fieldname eq $_ } qw< >- STATUS branchcode itemtype suggestedby managedby acceptedby >- bookfundid biblionumber >- >} keys %$suggestion >- ) { >- if ($$suggestion{$field}){ >- push @sql_params,$suggestion->{$field}; >- push @query, " and suggestions.$field=?"; >- } >+ # filter on nillable fields >+ foreach my $field ( >+ grep { >+ my $fieldname = $_; >+ any { $fieldname eq $_ } qw/STATUS branchcode itemtype suggestedby managedby acceptedby bookfundid biblionumber/ >+ } keys %$suggestion >+ ) >+ { >+ if ( $suggestion->{$field} ) { >+ push @sql_params, $suggestion->{$field}; >+ push @query, " AND suggestions.$field = ?"; >+ } > else { >- push @query, " and (suggestions.$field='' OR suggestions.$field IS NULL)"; >+ push @query, " AND (suggestions.$field = '' OR suggestions.$field IS NULL)"; > } > } > >+ # filter on date fields > my $today = C4::Dates->today('iso'); >- >- foreach ( qw( suggesteddate manageddate accepteddate ) ) { >- my $from = $_ . "_from"; >- my $to = $_ . "_to"; >- if ($$suggestion{$from} || $$suggestion{$to}) { >- push @query, " AND suggestions.suggesteddate BETWEEN '" >- . (format_date_in_iso($$suggestion{$from}) || 0000-00-00) . "' AND '" . (format_date_in_iso($$suggestion{$to}) || $today) . "'"; >- } >+ foreach my $field ( qw/suggesteddate manageddate accepteddate/ ) { >+ my $from = $field."_from"; >+ my $to = $field."_to"; >+ if ($suggestion->{$from} || $suggestion->{$to}) { >+ push @query, " AND suggestions.$field BETWEEN ? AND ?"; >+ push @sql_params, format_date_in_iso($suggestion->{$from}) || '0000-00-00'; >+ push @sql_params, format_date_in_iso($suggestion->{$to}) || $today; >+ } > } > > $debug && warn "@query"; >@@ -165,7 +177,8 @@ sub SearchSuggestion { > $sth->execute(@sql_params); > my @results; > while ( my $data=$sth->fetchrow_hashref ){ >- $$data{$$data{STATUS}} = 1; >+ # add status as field >+ $data->{$data->{STATUS}} = 1; > push(@results,$data); > } > return (\@results); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >index edaea79..aa026dc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -493,7 +493,7 @@ $(document).ready(function() { calcNewsuggTotal(); }); > <li><label for="author"> Author:</label><input type="text" id="author" name="author" value="[% author %]" /></li> > <li><label for="isbn"> ISBN:</label><input type="text" id="isbn" name="isbn" value="[% isbn %]" /></li> > <li><label for="publishercode"> Publisher:</label><input type="text" id="publishercode" name="publishercode" value="[% publishercode %]" /></li> >- <li><label for="publicationyear"> Publication year:</label><input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear %]" /></li> >+ <li><label for="copyrightdate_filter"> Copyright date:</label><input type="text" id="copyrightdate_filter" name="copyrightdate" value="[% copyrightdate %]" /></li> > <li><label for="collectiontitle"> Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" value="[% collectiontitle %]" /></li><li><input type="submit" value="Go" /></li></ol> > </fieldset> > <fieldset class="brief"><h4 class="collapse"><a href="#">Suggestion information</a></h4> >@@ -514,10 +514,10 @@ $(document).ready(function() { calcNewsuggTotal(); }); > <li><label for="suggesteddate_from"> Suggested on:</label>[% suggesteddate %] > <table class="invis"> > <tr> >- <td><label for="suggesteddate_from">from:</label></td><td><input type="text" id="suggesteddate_from" name="suggesteddate_from" style="width:80px;" /></td> >+ <td><label for="suggesteddate_from">from:</label></td><td><input type="text" id="suggesteddate_from" name="suggesteddate_from" style="width:76px;" /></td> > </tr> > <tr> >- <td><label for="suggesteddate_to">to:</label></td><td><input type="text" id="suggesteddate_to" name="suggesteddate_to" style="width:80px;" /></td> >+ <td><label for="suggesteddate_to">to:</label></td><td><input type="text" id="suggesteddate_to" name="suggesteddate_to" style="width:76px;" /></td> > </tr> > </table> > </li> >@@ -527,10 +527,10 @@ $(document).ready(function() { calcNewsuggTotal(); }); > <li><label for="manageddate_from"> Management date:</label>[% manageddate %] > <table class="invis"> > <tr> >- <td><label for="manageddate_from">from:</label></td><td><input type="text" id="manageddate_from" name="manageddate_from" style="width:80px;" /></td> >+ <td><label for="manageddate_from">from:</label></td><td><input type="text" id="manageddate_from" name="manageddate_from" style="width:76px;" /></td> > </tr> > <tr> >- <td><label for="manageddate_to">to:</label></td><td><input type="text" id="manageddate_to" name="manageddate_to" style="width:80px;" /></td> >+ <td><label for="manageddate_to">to:</label></td><td><input type="text" id="manageddate_to" name="manageddate_to" style="width:76px;" /></td> > </tr> > </table> > </li> >@@ -540,10 +540,10 @@ $(document).ready(function() { calcNewsuggTotal(); }); > <li><label for="accepteddate_from"> Accepted on:</label>[% accepteddate %] > <table class="invis"> > <tr> >- <td><label for="accepteddate_from">from:</label></td><td><input type="text" id="accepteddate_from" name="accepteddate_from" style="width:80px;" /></td> >+ <td><label for="accepteddate_from">from:</label></td><td><input type="text" id="accepteddate_from" name="accepteddate_from" style="width:76px;" /></td> > </tr> > <tr> >- <td><label for="accepteddate_to">to:</label></td><td><input type="text" id="accepteddate_to" name="accepteddate_to" style="width:80px;" /></td> >+ <td><label for="accepteddate_to">to:</label></td><td><input type="text" id="accepteddate_to" name="accepteddate_to" style="width:76px;" /></td> > </tr> > </table> > </li> >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index 99f38eb..aadf58f 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -188,12 +188,24 @@ elsif ( $op eq 'show' ) { > if ($op=~/else/) { > $op='else'; > >- $displayby||="STATUS"; >+ $displayby||="STATUS"; # by default, organize by status > delete $$suggestion_ref{'branchcode'} if($displayby eq "branchcode"); > my $criteria_list=GetDistinctValues("suggestions.".$displayby); >+ my %criteria_dv; >+ foreach (@$criteria_list) { >+ my $criteria_key; >+ if ($_->{value}) { >+ $criteria_key = $_->{value}; >+ } else { >+ # agregate null and empty values under empty value >+ $criteria_key = ''; >+ } >+ my $criteria_cnt = $criteria_dv{$criteria_key} || 0; >+ $criteria_dv{$criteria_key} = $criteria_cnt + $_->{cnt}; >+ } > my @allsuggestions; > my $reasonsloop = GetAuthorisedValues("SUGGEST"); >- foreach my $criteriumvalue ( map { $$_{'value'} } @$criteria_list ) { >+ foreach my $criteriumvalue (keys %criteria_dv) { > # By default, display suggestions from current working branch > if(not defined $branchfilter) { > $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5357
:
10433
|
11263
|
11264
|
11265
|
11266
|
11287
|
11290
|
11736
|
11831
|
11832
|
11839