@@ -, +, @@ --- C4/Biblio.pm | 55 ++++++++ C4/Suggestions.pm | 54 +++++++ acqui/duplicatesearch.pl | 105 ++++++++++++++ .../prog/en/includes/acquisitions-menu.inc | 1 + .../prog/en/modules/acqui/duplicatesearch.tt | 145 ++++++++++++++++++++ 5 files changed, 360 insertions(+), 0 deletions(-) create mode 100755 acqui/duplicatesearch.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicatesearch.tt --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -98,6 +98,7 @@ BEGIN { &CountBiblioInOrders &GetSubscriptionsId &GetHolds + &FindBiblios ); # To modify something @@ -3708,6 +3709,60 @@ sub GetHolds { return ($holds); } +=head2 FindBiblios + +Find biblios matching title, author, isbn and return a array containing details of matching biblios. + +=cut + +sub FindBiblios { + my $dbh = C4::Context->dbh; + my %params = @_; + my $title = $params{title}; + my $author = $params{author}; + 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 "; + 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 $author ) { + if( $author eq ""){ + + } else { + $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%"; + } + } + + my $sth = $dbh->prepare($query); + $sth->execute( @query_params ); + my @bib_loop; + while (my $data=$sth->fetchrow_hashref){ + push @bib_loop,$data; + } + + return \@bib_loop; +} + =head2 prepare_host_field $marcfield = prepare_host_field( $hostbiblioitem, $marcflavour ); --- a/C4/Suggestions.pm +++ a/C4/Suggestions.pm @@ -47,6 +47,7 @@ our @EXPORT = qw< NewSuggestion SearchSuggestion DelSuggestionsOlderThan + FindSuggestions >; =head1 NAME @@ -448,6 +449,59 @@ sub ModSuggestion { return $status_update_table; } +=head2 FindSuggestions + +Find Suggestions matching title, author, isbn and return a array containing details of matching Suggestions. + +=cut + +sub FindSuggestions { + my $dbh = C4::Context->dbh; + my %params = @_; + 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 @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); + } + + return \@sugg_loop; +} + =head2 ConnectSuggestionAndBiblio &ConnectSuggestionAndBiblio($ordernumber,$biblionumber) --- a/acqui/duplicatesearch.pl +++ a/acqui/duplicatesearch.pl @@ -0,0 +1,105 @@ +#!/usr/bin/perl + +#script to duplicate search (Orders, suggestions, bibliographic records) +#written by amit.gupta@osslabs.biz 08/06/2012 + +# Copyright 2012 Nucsoft Osslabs +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +=head1 NAME + +duplicatesearch.pl + +=head1 DESCRIPTION + +This script is used to search duplicate orders, suggestions and catalog records + +=cut + +use strict; +use warnings; +use CGI; +use C4::Auth; # get_template_and_user +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'); + +# getting the template +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "acqui/duplicatesearch.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + 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, + ); + + my $sugg_loop = FindSuggestions( + title => $title, + author => $author, + isbn => $isbn, + ); + + my $bib_loop = FindBiblios( + 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), + ); +} + +$template->param( + title => $title, + author => $author, + isbn => $isbn, +); + +output_html_with_http_headers $input, $cookie, $template->output; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc @@ -5,6 +5,7 @@ [% IF ( CAN_user_acquisition_budget_manage ) %]
Basket Name | +Order Number | +Summary | +Vendor | +
---|---|---|---|
[% orders_loo.basketname %] | +[% orders_loo.ordernumber %] | +[% orders_loo.title |html %] [% orders_loo.author %] |
+ [% orders_loo.name %] | +
Title | +Author | +ISBN | +
---|---|---|
[% bib_loo.title %] | +[% bib_loo.author %] | +[% bib_loo.isbn %] | +
No Result
+[% END %] + + + + +