From 5e6e1da0f898ce2b6f3c0297370088b533fe2a63 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Fri, 10 Aug 2012 12:29:44 +0200
Subject: [PATCH] [SIGNED-OFF] Bug 6813: Followup: indentation + simplify conditions
Content-Type: text/plain; charset="utf-8"
Signed-off-by: Marc Veron <veron@veron.ch>
---
C4/Biblio.pm | 32 ++-----
C4/Suggestions.pm | 39 +++-----
acqui/duplicatesearch.pl | 80 ++++++++--------
.../prog/en/modules/acqui/duplicatesearch.tt | 98 ++++++++++----------
4 files changed, 115 insertions(+), 134 deletions(-)
diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 45e01a7..73b5211 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -3722,32 +3722,20 @@ sub FindBiblios {
$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);
diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm
index 8e83a0f..6fe7547 100644
--- a/C4/Suggestions.pm
+++ b/C4/Suggestions.pm
@@ -461,36 +461,27 @@ 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 $title and $title ne "" ) {
+ $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 $author and $author ne "" ) {
+ $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%";
- }
+ if ( defined $isbn and $isbn ne "" ) {
+ $querysug .= " AND suggestions.isbn LIKE ? ";
+ push @query_sug, "%$isbn%";
}
my $sth = $dbh->prepare($querysug);
$sth->execute( @query_sug );
diff --git a/acqui/duplicatesearch.pl b/acqui/duplicatesearch.pl
index 2495c06..32c5763 100755
--- a/acqui/duplicatesearch.pl
+++ b/acqui/duplicatesearch.pl
@@ -30,8 +30,7 @@ This script is used to search duplicate orders, suggestions and catalog records
=cut
-use strict;
-use warnings;
+use Modern::Perl;
use CGI;
use C4::Auth; # get_template_and_user
use C4::Output;
@@ -41,11 +40,11 @@ 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,
+ title => $title,
author => $author,
- isbn => $isbn,
+ 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 632e9c6..393d8f6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicatesearch.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicatesearch.tt
@@ -38,77 +38,77 @@ $(function(){
<li><a href="#pagercatalogtable">Catalog ([% numresults_bib %])</a></li>
</ul>
<div id="pagerordertable">
- [% IF (numresults_order) %]
- [% INCLUDE 'table-pager.inc' perpage='10' %]
- <table id="ordertable" class="sorted">
- [% ELSE %]
- <table>
- [% END %]
- <thead>
+ [% IF (numresults_order) %]
+ [% INCLUDE 'table-pager.inc' perpage='10' %]
+ <table id="ordertable" class="sorted">
+ [% ELSE %]
+ <table>
+ [% END %]
+ <thead>
<tr>
- <th>Basket Name</th>
- <th>Order Number</th>
- <th>Summary</th>
- <th>Vendor</th>
+ <th>Basket Name</th>
+ <th>Order Number</th>
+ <th>Summary</th>
+ <th>Vendor</th>
</tr>
- </thead>
- [% FOREACH orders_loo IN orders_loop %]
+ </thead>
+ [% FOREACH orders_loo IN orders_loop %]
<tr>
- <td><a href="basket.pl?basketno=[% orders_loo.basketno %]">[% orders_loo.basketname %]</a></td>
- <td><a href="neworderempty.pl?ordernumber=[% orders_loo.ordernumber %]">[% orders_loo.ordernumber %]</a></td>
- <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% orders_loo.biblionumber %]">[% orders_loo.title |html %]</a><br />[% orders_loo.author %]</td>
- <td><a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=[% orders_loo.id %]">[% orders_loo.name %]</a></td>
+ <td><a href="basket.pl?basketno=[% orders_loo.basketno %]">[% orders_loo.basketname %]</a></td>
+ <td><a href="neworderempty.pl?ordernumber=[% orders_loo.ordernumber %]">[% orders_loo.ordernumber %]</a></td>
+ <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% orders_loo.biblionumber %]">[% orders_loo.title |html %]</a><br />[% orders_loo.author %]</td>
+ <td><a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=[% orders_loo.id %]">[% orders_loo.name %]</a></td>
</tr>
- [% END %]
- </table>
+ [% END %]
+ </table>
</div>
<div id="pagersuggestiontable">
<h1>Suggestion Search Results</h1>
[% IF (numresults_sugg) %]
- [% INCLUDE 'table-pager.inc' perpage='10' %]
- <table id="suggestiontable" class="sorted">
+ [% INCLUDE 'table-pager.inc' perpage='10' %]
+ <table id="suggestiontable" class="sorted">
[% ELSE %]
- <table>
+ <table>
[% END %]
<thead>
- <tr>
+ <tr>
<th>Title</th>
<th>Author</th>
<th>ISBN</th>
<th>Status</th>
- </tr>
+ </tr>
</thead>
[% FOREACH sugg_loo IN sugg_loop %]
- <tr>
- <td><a href ="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% sugg_loo.suggestionid %]&op=edit"/>[% sugg_loo.title %]</td>
+ <tr>
+ <td><a href ="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% sugg_loo.suggestionid %]&op=edit"/>[% sugg_loo.title %]</a></td>
<td>[% sugg_loo.author %]</td>
<td>[% sugg_loo.isbn %]</td>
<td>[% sugg_loo.STATUS %]</td>
- </tr>
+ </tr>
[% END %]
</table>
</div>
<div id="pagercatalogtable">
<h1>Catalog Search Results</h1>
[% IF (numresults_bib) %]
- [% INCLUDE 'table-pager.inc' perpage='10' %]
- <table id="catalogtable" class="sorted">
+ [% INCLUDE 'table-pager.inc' perpage='10' %]
+ <table id="catalogtable" class="sorted">
[% ELSE %]
- <table>
+ <table>
[% END %]
<thead>
- <tr>
+ <tr>
<th>Title</th>
<th>Author</th>
<th>ISBN</th>
- </tr>
+ </tr>
</thead>
[% FOREACH bib_loo IN bib_loop %]
- <tr>
- <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% bib_loo.biblionumber %]">[% bib_loo.title %]</td>
+ <tr>
+ <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% bib_loo.biblionumber %]">[% bib_loo.title %]</a></td>
<td>[% bib_loo.author %]</td>
<td>[% bib_loo.isbn %]</td>
- </tr>
+ </tr>
[% END %]
</table>
</div>
@@ -122,20 +122,20 @@ $(function(){
</div>
<div class="yui-b">
<form name="form" action="/cgi-bin/koha/acqui/duplicatesearch.pl" method="post">
-<input type="hidden" name="op" value="result" />
-<fieldset class="brief">
-<h4>Filter Results:</h4>
- <ol>
- <li><label for="title">Title: </label> <input type="text" name="title" id="title" value="[% title %]" size="20" /></li>
- <li><label for="author">Author: </label> <input type="text" name="author" id="author" value="[% author %]" size="20" /></li>
- <li><label for="isbn">ISBN: </label> <input type="text" name="isbn" id="isbn" value="[% isbn %]" size="20" /></li>
- <li><label for="title"></label><input type="hidden" name="idx" id="title" value="ti" /></li>
- <li><input type="hidden" name="q" id="title1" value="[% title %]" /></li>
- <li><label for="author"></label><input type="hidden" name="idx" id="author" value="au" /></li>
- <li><input type="hidden" name="q" id="author1" value="[% author %]" /></li>
- <li><label for="isbn"></label><input type="hidden" name="idx" id="isbn" value="nb" /></li>
- <input type="hidden" name="q" id="isbn1" value="[% isbn %]" />
- </ol>
+ <input type="hidden" name="op" value="result" />
+ <fieldset class="brief">
+ <h4>Filter Results:</h4>
+ <ol>
+ <li><label for="title">Title: </label> <input type="text" name="title" id="title" value="[% title %]" size="20" /></li>
+ <li><label for="author">Author: </label> <input type="text" name="author" id="author" value="[% author %]" size="20" /></li>
+ <li><label for="isbn">ISBN: </label> <input type="text" name="isbn" id="isbn" value="[% isbn %]" size="20" /></li>
+ <li><label for="title"></label><input type="hidden" name="idx" id="title" value="ti" /></li>
+ <li><input type="hidden" name="q" id="title1" value="[% title %]" /></li>
+ <li><label for="author"></label><input type="hidden" name="idx" id="author" value="au" /></li>
+ <li><input type="hidden" name="q" id="author1" value="[% author %]" /></li>
+ <li><label for="isbn"></label><input type="hidden" name="idx" id="isbn" value="nb" /></li>
+ <input type="hidden" name="q" id="isbn1" value="[% isbn %]" />
+ </ol>
<input type="submit" value="Search" /> <a href="/cgi-bin/koha/acqui/duplicatesearch.pl">Clear All</a>
</fieldset>
</form>
--
1.7.2.5