X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=acqui%2Fnewordersuggestion.pl;h=156dab8f0b56a18eeef4483b5cc97f7e83f6a212;hb=c1e379203319c6120c8efee626d63ed005cb1090;hp=0571d5eaeca033b944feedfc9d196947f71d331c;hpb=3818a8dc384f1687d287e77fdb683b3eb518e036;p=koha.git diff --git a/acqui/newordersuggestion.pl b/acqui/newordersuggestion.pl index 0571d5eaec..156dab8f0b 100755 --- a/acqui/newordersuggestion.pl +++ b/acqui/newordersuggestion.pl @@ -15,158 +15,132 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -# $Id$ =head1 NAME + newordersuggestion.pl =head1 DESCRIPTION + this script allow to add an order from a existing suggestion. +The suggestion must have 'ACCEPTED' as status. =head1 CGI PARAMETERS =over 4 =item basketno -the number of this basket. + + the number of this basket. =item booksellerid -the bookseller who sells this record. + + the bookseller who sells this record. =item title -the title of this record suggested. + + to filter on title when searching among ACCEPTED suggestion. =item author -the author of this suggestion. + + to filter on author when searching among ACCEPTED suggestion. =item note -this param allow to enter a note with this suggestion. + + to filter on note when searching among ACCEPTED suggestion. =item copyrightdate -the copyright date for this suggestion. =item publishercode =item volumedesc =item publicationyear + the publication year of this record. =item place =item isbn + the isbn of this suggestion. =item duplicateNumber + is the biblionumber to put to the new suggestion. =item suggestionid + the id of the suggestion to select. =item op + can be equal to * connectDuplicate : then call to the function : ConnectSuggestionAndBiblio. i.e set the biblionumber of this suggestion. * else : is the default value. + =back =cut use strict; -require Exporter; +#use warnings; FIXME - Bug 2505 + use CGI; -use C4::Auth; # get_template_and_user -use C4::Interface::CGI::Output; +use C4::Auth; # get_template_and_user +use C4::Output; use C4::Suggestions; +use C4::Bookseller; use C4::Biblio; -use C4::Search; my $input = new CGI; -my $basketno = $input->param('basketno'); -my $supplierid = $input->param('booksellerid'); -my $title = $input->param('title'); -my $author = $input->param('author'); -my $note = $input->param('note'); -my $copyrightdate =$input->param('copyrightdate'); -my $publishercode = $input->param('publishercode'); -my $volumedesc = $input->param('volumedesc'); -my $publicationyear = $input->param('publicationyear'); -my $place = $input->param('place'); -my $isbn = $input->param('isbn'); +# getting the CGI params +my $basketno = $input->param('basketno'); +my $supplierid = $input->param('booksellerid'); +my $author = $input->param('author'); +my $title = $input->param('title'); +my $publishercode = $input->param('publishercode'); +my $op = $input->param('op'); +my $suggestionid = $input->param('suggestionid'); my $duplicateNumber = $input->param('duplicateNumber'); -my $suggestionid = $input->param('suggestionid'); +my $uncertainprice = $input->param('uncertainprice'); -my $status = 'ACCEPTED'; # the suggestion had to be accepeted before to order it. -my $suggestedbyme = -1; # search ALL suggestors -my $op = $input->param('op'); $op = 'else' unless $op; my $dbh = C4::Context->dbh; -my ($template, $borrowernumber, $cookie) - = get_template_and_user({template_name => "acqui/newordersuggestion.tmpl", - type => "intranet", - query => $input, - authnotrequired => 1, - flagsrequired => {acquisition => 1}, - }); - -if ($op eq 'connectDuplicate') { - ConnectSuggestionAndBiblio($suggestionid,$duplicateNumber); -} -my $suggestions_loop= &SearchSuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme); -foreach (@$suggestions_loop) { - unless ($_->{biblionumber}) { - my (@kohafields, @and_or, @value, @relation, $offset,$length); - # search on biblio.title - if ($_->{title}) { - push @kohafields, "title"; - push @and_or, "\@and"; - push @relation, "\@attr 5=1"; - push @value, $_->{title}; - } - if ($_->{author}) { - push @kohafields, "author"; - push @and_or, "\@and"; - push @relation, ""; - push @value, $_->{author}; - } - # ... and on publicationyear. - if ($_->{publicationyear}) { - push @kohafields, "copyrightdate"; - push @and_or, "\@and"; - push @relation, ""; - push @value, $_->{publicationyear}; - } - # ... and on publisher. - if ($_->{publishercode}) { - push @kohafields, "publishercode"; - push @and_or, "\@and"; - push @relation, ""; - push @value, $_->{publishercode}; - } - - my ($nbresult,@finalresult) = ZEBRAsearch_kohafields(\@kohafields,\@value,\@relation,"",\@and_or,0,"",0,1); - - # there is at least 1 result => return the 1st one - if ($nbresult) { - $_->{duplicateBiblionumber} = $finalresult[0]->{biblionumber}; - } - } +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "acqui/newordersuggestion.tmpl", + type => "intranet", + query => $input, + authnotrequired => 1, + flagsrequired => { acquisition => 'order_manage' }, + } +); + +if ( $op eq 'connectDuplicate' ) { + ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber ); } -$template->param(suggestions_loop => $suggestions_loop, - title => $title, - author => $author, - publishercode => $publishercode, - status => $status, - suggestedbyme => $suggestedbyme, - basketno => $basketno, - supplierid => $supplierid, - "op_$op" => 1, - intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), + +# getting all suggestions. +my $suggestions_loop = + &SearchSuggestion( + { managedby => $borrowernumber, + author => $author, + title => $title, + publishercode => $publishercode, + STATUS => 'ACCEPTED'}); +my $vendor = GetBookSellerFromId($supplierid); +$template->param( + suggestions_loop => $suggestions_loop, + basketno => $basketno, + supplierid => $supplierid, + name => $vendor->{'name'}, + "op_$op" => 1, ); + output_html_with_http_headers $input, $cookie, $template->output;