From a21658583a800d82c6e89c345829b88355944efc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Aug 2012 12:29:44 +0200 Subject: [PATCH] Bug 6813: Followup: indentation + simplify conditions --- C4/Biblio.pm | 38 +++----- C4/Suggestions.pm | 63 +++++------ acqui/duplicatesearch.pl | 88 ++++++++-------- .../prog/en/modules/acqui/duplicatesearch.tt | 112 ++++++++++---------- 4 files changed, 141 insertions(+), 160 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index b2ce44b..73b5211 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -3717,37 +3717,25 @@ sub FindBiblios { my %params = @_; my $title = $params{title}; my $author = $params{author}; - my $isbn = $params{isbn}; + my $isbn = $params{isbn}; my $query = "SELECT title, author, isbn, biblio.biblionumber FROM biblio LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber"; - $query .= " WHERE 1 "; + $query .= " WHERE 1 "; my @query_params = (); - - if ( defined $title ) { - if ( $title eq ""){ - } else { - $query .= " AND biblio.title LIKE ? "; - $title =~ s/\s+/%/g; - push @query_params, "%$title%"; - } + if ( defined $title and $title ne "" ) { + $query .= " AND biblio.title LIKE ? "; + $title =~ s/\s+/%/g; + push @query_params, "%$title%"; } - if ( defined $author ) { - if( $author eq ""){ - - } else { - $query .= " AND biblio.author LIKE ? "; - push @query_params, "%$author%"; - } + if ( defined $author and $author ne "" ) { + $query .= " AND biblio.author LIKE ? "; + push @query_params, "%$author%"; } - if ( defined $isbn) { - if ( $isbn eq ""){ - - } else { - $query .= " AND biblioitems.isbn LIKE ? "; - push @query_params, "%$isbn%"; - } + if ( defined $isbn and $isbn ne "" ) { + $query .= " AND biblioitems.isbn LIKE ? "; + push @query_params, "%$isbn%"; } my $sth = $dbh->prepare($query); @@ -3755,7 +3743,7 @@ sub FindBiblios { my @bib_loop; while (my $data=$sth->fetchrow_hashref){ push @bib_loop,$data; - } + } return \@bib_loop; } diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 802e4cf..6fe7547 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -461,44 +461,35 @@ sub FindSuggestions { my $title = $params{title}; my $author = $params{author}; my $isbn = $params{isbn}; - my $querysug="SELECT title, author, isbn, STATUS, suggestionid FROM suggestions"; - $querysug .=" WHERE 1"; + my $querysug = qq{ + SELECT title, author, isbn, STATUS, suggestionid + FROM suggestions + WHERE 1 + }; my @query_sug = (); - if ( defined $title ) { - if ( $title eq ""){ - - } else { - $querysug .= " AND suggestions.title LIKE ? "; - $title =~ s/\s+/%/g; - push @query_sug, "%$title%"; - } - } - - if ( defined $author ) { - if( $author eq ""){ - - } else { - $querysug .= " AND suggestions.author LIKE ? "; - push @query_sug, "%$author%"; - } - } - - if ( defined $isbn) { - if ( $isbn eq ""){ - - } else { - $querysug .= " AND suggestions.isbn LIKE ? "; - push @query_sug, "%$isbn%"; - } - } - my $sth = $dbh->prepare($querysug); - $sth->execute( @query_sug ); - my @sugg_loop; - while (my $data=$sth->fetchrow_hashref){ - push (@sugg_loop,$data); - } - + if ( defined $title and $title ne "" ) { + $querysug .= " AND suggestions.title LIKE ? "; + $title =~ s/\s+/%/g; + push @query_sug, "%$title%"; + } + + if ( defined $author and $author ne "" ) { + $querysug .= " AND suggestions.author LIKE ? "; + push @query_sug, "%$author%"; + } + + if ( defined $isbn and $isbn ne "" ) { + $querysug .= " AND suggestions.isbn LIKE ? "; + push @query_sug, "%$isbn%"; + } + my $sth = $dbh->prepare($querysug); + $sth->execute( @query_sug ); + my @sugg_loop; + while (my $data=$sth->fetchrow_hashref){ + push (@sugg_loop,$data); + } + return \@sugg_loop; } diff --git a/acqui/duplicatesearch.pl b/acqui/duplicatesearch.pl index 532bd91..32c5763 100755 --- a/acqui/duplicatesearch.pl +++ b/acqui/duplicatesearch.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl #script to duplicate search (Orders, suggestions, bibliographic records) #written by amit.gupta@osslabs.biz 08/06/2012 @@ -30,22 +30,21 @@ This script is used to search duplicate orders, suggestions and catalog records =cut -use strict; -use warnings; -use CGI; +use Modern::Perl; +use CGI; use C4::Auth; # get_template_and_user -use C4::Output; +use C4::Output; use C4::Acquisition; use C4::Suggestions; use C4::Biblio; use C4::Debug; use C4::Search; -my $input = new CGI; -my $title = $input->param( 'title'); -my $author = $input->param('author'); -my $isbn = $input->param('isbn'); -my $op = $input->param('op'); +my $input = new CGI; +my $title = $input->param('title'); +my $author = $input->param('author'); +my $isbn = $input->param('isbn'); +my $op = $input->param('op'); # getting the template my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -54,52 +53,55 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( query => $input, type => "intranet", authnotrequired => 0, - flagsrequired => { acquisition => 'group_manage', acquisition => 'order_manage', acquisition => 'order_receive' }, - debug => 1, + flagsrequired => { + acquisition => 'group_manage', + acquisition => 'order_manage', + acquisition => 'order_receive' + }, + debug => 1, } ); - -if ($op eq "result"){ - my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) = GetHistory( - title => $title, - author => $author, - isbn => $isbn, - name => undef, - from_placed_on => undef, - to_placed_on => undef, - basket => undef, - booksellerinvoicenumber => undef, - ); +if ( $op eq "result" ) { + my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) = + GetHistory( + title => $title, + author => $author, + isbn => $isbn, + name => undef, + from_placed_on => undef, + to_placed_on => undef, + basket => undef, + booksellerinvoicenumber => undef, + ); my $sugg_loop = FindSuggestions( - title => $title, - author => $author, - isbn => $isbn, - ); + title => $title, + author => $author, + isbn => $isbn, + ); my $bib_loop = FindBiblios( - title => $title, - author => $author, - isbn => $isbn - ); - + title => $title, + author => $author, + isbn => $isbn + ); $template->param( - result => 1, - orders_loop => $order_loop, - sugg_loop => $sugg_loop, - bib_loop => $bib_loop, - numresults_order => scalar(@$order_loop), - numresults_sugg => scalar(@$sugg_loop), - numresults_bib => scalar(@$bib_loop), + result => 1, + orders_loop => $order_loop, + sugg_loop => $sugg_loop, + bib_loop => $bib_loop, + numresults_order => scalar(@$order_loop), + numresults_sugg => scalar(@$sugg_loop), + numresults_bib => scalar(@$bib_loop), ); } $template->param( - title => $title, - author => $author, - isbn => $isbn, + title => $title, + author => $author, + isbn => $isbn, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicatesearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicatesearch.tt index 711d780..393d8f6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicatesearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicatesearch.tt @@ -14,7 +14,7 @@ @@ -23,14 +23,14 @@ $(function(){ [% INCLUDE 'acquisitions-search.inc' %] -
+

Duplicate Search

- [% IF ( result ) %] + [% IF ( result ) %]
- [% IF (numresults_order) %] - [% INCLUDE 'table-pager.inc' perpage='10' %] - - [% ELSE %] -
- [% END %] - - - - - - - - - [% FOREACH orders_loo IN orders_loop %] + [% IF (numresults_order) %] + [% INCLUDE 'table-pager.inc' perpage='10' %] +
Basket NameOrder NumberSummaryVendor
+ [% ELSE %] +
+ [% END %] + - - - - + + + + - [% END %] -
[% orders_loo.basketname %][% orders_loo.ordernumber %][% orders_loo.title |html %]
[% orders_loo.author %]
[% orders_loo.name %]Basket NameOrder NumberSummaryVendor
+ + [% FOREACH orders_loo IN orders_loop %] + + [% orders_loo.basketname %] + [% orders_loo.ordernumber %] + [% orders_loo.title |html %]
[% orders_loo.author %] + [% orders_loo.name %] + + [% END %] +

Suggestion Search Results

[% IF (numresults_sugg) %] - [% INCLUDE 'table-pager.inc' perpage='10' %] - + [% INCLUDE 'table-pager.inc' perpage='10' %] +
[% ELSE %] -
- [% END %] +
+ [% END %] - + - + [% FOREACH sugg_loo IN sugg_loop %] - - + + - + [% END %]
Title Author ISBN Status
[% sugg_loo.title %]
[% sugg_loo.title %] [% sugg_loo.author %] [% sugg_loo.isbn %] [% sugg_loo.STATUS %]

Catalog Search Results

[% IF (numresults_bib) %] - [% INCLUDE 'table-pager.inc' perpage='10' %] - + [% INCLUDE 'table-pager.inc' perpage='10' %] +
[% ELSE %] -
- [% END %] +
+ [% END %] - + - + [% FOREACH bib_loo IN bib_loop %] - - + + - + [% END %]
Title Author ISBN
[% bib_loo.title %]
[% bib_loo.title %] [% bib_loo.author %] [% bib_loo.isbn %]
@@ -122,20 +122,20 @@ $(function(){
- -
-

Filter Results:

-
    -
  1. -
  2. -
  3. -
  4. -
  5. -
  6. -
  7. -
  8. - -
+ +
+

Filter Results:

+
    +
  1. +
  2. +
  3. +
  4. +
  5. +
  6. +
  7. +
  8. + +
Clear All
-- 1.7.7.3