[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha acqui/neworderbiblio.pl koha-tmpl/intranet... [rel_3_0]
From: |
Antoine Farnault |
Subject: |
[Koha-cvs] koha acqui/neworderbiblio.pl koha-tmpl/intranet... [rel_3_0] |
Date: |
Mon, 30 Oct 2006 11:24:07 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/10/30 11:24:07
Modified files:
acqui : neworderbiblio.pl
koha-tmpl/intranet-tmpl/prog/en/acqui: neworderbiblio.tmpl
Log message:
this script now use zebra to search the catalog.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/neworderbiblio.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/acqui/neworderbiblio.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.2.2.1&r2=1.2.2.2
Patches:
Index: acqui/neworderbiblio.pl
===================================================================
RCS file: /sources/koha/koha/acqui/Attic/neworderbiblio.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- acqui/neworderbiblio.pl 23 Oct 2006 09:06:13 -0000 1.1.2.1
+++ acqui/neworderbiblio.pl 30 Oct 2006 11:24:07 -0000 1.1.2.2
@@ -25,6 +25,7 @@
neworderbiblio.pl
=head1 DESCRIPTION
+
this script allows to perform a new order from an existing record.
=head1 CGI PARAMETERS
@@ -34,18 +35,14 @@
=item search
the title the librarian has typed to search an existing record.
-=item type
-To know if this script is called from intranet or from the opac.
-
-=item d
+=item q
the keyword the librarian has typed to search an existing record.
=item author
the author of the new record.
-=item offset
-
=item num
+the number of result per page to display
=item booksellerid
the id of the bookseller this script has to add an order.
@@ -53,14 +50,10 @@
=item basketno
the basket number to know on which basket this script have to add a new order.
-=item sub
-FIXME : is this param still used ?
-
=back
=cut
-
use strict;
use C4::Search;
use CGI;
@@ -70,56 +63,23 @@
use HTML::Template;
use C4::Auth;
use C4::Interface::CGI::Output;
+use C4::Koha;
-
-#use Data::Dumper;
-
-my $env;
my $input = new CGI;
-#print $input->header;
-
-#whether it is called from the opac of the intranet
-my $type = $input->param('type');
-if ( $type eq '' ) {
- $type = 'intra';
-}
-
-#print $input->dump;
-my $blah;
-my %search;
-
-#build hash of users input
-my $title = $input->param('search');
-$search{'title'} = $title;
-my $keyword = $input->param('d');
-$search{'keyword'} = $keyword;
-my $author = $input->param('author');
-$search{'author'} = $author;
-
-my @results;
-my $offset = $input->param('offset');
-
-#default value for offset
-my $offset = 0 unless $offset;
-
-my $num = $input->param('num');
+#getting all CGI params into a hash.
+my $params = $input->Vars;
-#default value for num
-my $num = 10 unless $num;
-
-my $donation;
-my $booksellerid = $input->param('booksellerid');
-if ( $booksellerid == 72 ) {
- $donation = 'yes';
-}
-my $basketno = $input->param('basketno');
-my $sub = $input->param('sub');
-
-#print $sub;
-my @booksellers = GetBookSeller($booksellerid);
-my $count = scalar @booksellers;
+my $offset = $params->{'offset'} || 0;
+my $query = $params->{'q'};
+my $num = $params->{'num'};
+$num = 20 unless $num;
+
+my $booksellerid = $params->{'booksellerid'};
+my $basketno = $params->{'basketno'};
+my $sub = $params->{'sub'};
+# getting the template
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "acqui/neworderbiblio.tmpl",
@@ -127,229 +87,55 @@
type => "intranet",
authnotrequired => 0,
flagsrequired => { order => 1 },
- debug => 1,
}
);
-#my $template = gettemplate("acqui/neworderbiblio.tmpl");
-#print startpage();
-#print startmenu('acquisitions');
-my $invalidsearch;
-
-if ( $keyword ne '' ) {
- ( $count, @results ) =
- KeywordSearch( undef, 'intra', \%search, $num, $offset );
-}
-elsif ( $search{'front'} ne '' ) {
- ( $count, @results ) =
- FrontSearch( undef, 'intra', \%search, $num, $offset );
-}
-elsif ( $search{'author'} || $search{'title'} ) {
- # FIXME :: This function is deprecated !!
- ( $count, @results ) = CatSearch( undef, 'loose', \%search, $num, $offset
);
-}
-else {
- $invalidsearch = 1;
-}
+# Searching the catalog.
+my ($error, $marcresults) = SimpleSearch($query);
-my @loopsearch;
-
-while ( my ( $key, $value ) = each %search ) {
- if ( $value ne '' ) {
- my %linesearch;
- $value =~ s/\\//g;
- $linesearch{key} = $key;
- $linesearch{value} = $value;
- push( @loopsearch, \%linesearch );
- }
-}
-
-my $offset2 = $num + $offset;
-my $dispnum = $offset + 1;
-if ( $offset2 > $count ) {
- $offset2 = $count;
+if (defined $error) {
+ $template->param(query_error => $error);
+ warn "error: ".$error;
+ output_html_with_http_headers $input, $cookie, $template->output;
+ exit;
}
-my $count2 = @results;
-if ( $keyword ne '' && $offset > 0 ) {
- $count2 = $count - $offset;
- if ( $count2 > 10 ) {
- $count2 = 10;
- }
-}
-my $i = 0;
-my $colour = 0;
-
-my @loopresult;
-
-while ( $i < $count2 ) {
- my %lineres;
- my $toggle;
-
- my $result = $results[$i];
- $result->{'title'} =~ s/\`/\\\'/g;
- my $title2 = $result->{'title'};
- my $author2 = $result->{'author'};
- $author2 =~ s/ /%20/g;
- $title2 =~ s/ /%20/g;
- $title2 =~ s/\#/\&\#x23;/g;
- $title2 =~ s/\"/\"\;/g;
-
- my $itemcount;
- my $location = '';
- my $location_only = '';
- my $word = $result->{'author'};
- $word =~ s/([a-z]) +([a-z])/$1%20$2/ig;
- $word =~ s/ //g;
- $word =~ s/ /%20/g;
- $word =~ s/\,/\,%20/g;
- $word =~ s/\n//g;
- $lineres{word} = $word;
- $lineres{type} = $type;
-
- my ( $counts, $branchcounts ) =
- C4::Search::itemcount( $env, $result->{'biblionumber'}, $type );
-
- if ( $counts->{'nacount'} > 0 ) {
- $location .= "On Loan";
- if ( $counts->{'nacount'} > 1 ) {
- $location .= "=($counts->{'nacount'})";
- }
- $location .= " ";
- $lineres{'on-loan-p'} = 1;
- }
- foreach my $key ( keys %$branchcounts ) {
- if ( $branchcounts->{$key} > 0 ) {
- $location .= $key;
- $location_only .= $key;
-
- if ( $branchcounts->{$key} > 1 ) {
- $location .= "=$branchcounts->{$key}";
- $location_only .= "=$branchcounts->{$key}";
- }
- $location .= " ";
- $location_only .= " ";
- }
- }
- if ( $counts->{'lostcount'} > 0 ) {
- $location .= "Lost";
- if ( $counts->{'lostcount'} > 1 ) {
- $location .= "=($counts->{'lostcount'})";
- }
- $location .= " ";
- $lineres{'lost-p'} = 1;
- }
- if ( $counts->{'mending'} > 0 ) {
- $location .= "Mending";
- if ( $counts->{'mending'} > 1 ) {
- $location .= "=($counts->{'mending'})";
- }
- $location .= " ";
- $lineres{'mending-p'} = 1;
- }
- if ( $counts->{'transit'} > 0 ) {
- $location .= "In Transit";
- if ( $counts->{'transit'} > 1 ) {
- $location .= "=($counts->{'transit'})";
- }
- $location .= " ";
- $lineres{'in-transit-p'} = 1;
- }
- if ( $colour eq 0 ) {
- $toggle = 1;
- $colour = 1;
- }
- else {
- $colour = 0;
- $toggle = 0;
- }
- $lineres{author2} = $author2;
- $lineres{title2} = $title2;
- $lineres{copyright} = $result->{'copyrightdate'};
- $lineres{booksellerid} = $booksellerid;
- $lineres{basketno} = $basketno;
- $lineres{sub} = $sub;
- $lineres{biblionumber} = $result->{biblionumber};
- $lineres{title} = $result->{title};
- $lineres{author} = $result->{author};
- $lineres{toggle} = $toggle;
- $lineres{itemcount} = $counts->{'count'};
- $lineres{location} = $location;
- $lineres{'location-only'} = $location_only;
-
- # lets get a list on existing orders for all bibitems.
- my @bibitems = GetBiblioItemByBiblioNumber( $result->{biblionumber} );
- my $count1 = scalar @bibitems;
- my $order, my $ordernumber;
-
- my $i1 = 0;
-
- my @ordernumbers;
- foreach my $bibitem (@bibitems) {
- my $ordernumber =
GetOrderNumber($result->{biblionumber},$bibitem->{biblioitemnumber});
- $order = &GetOrder($ordernumber);
-
- #only show order if its current;
- my %order;
- $order{'number'} = $ordernumber;
- if ( ( !$order->{cancelledby} )
- && ( $order->{quantityreceived} < $order->{quantity} ) )
- {
- push @ordernumbers, \%order;
- }
- }
- $lineres{existingorder} = address@hidden;
- push( @loopresult, \%lineres );
- $i++;
-}
-
-my $prevoffset = $offset - $num;
-my $offsetprev = 1;
-if ( $prevoffset < 0 ) {
- $offsetprev = 0;
-}
-
-$offset = $num + $offset;
+my $hits = scalar @$marcresults;
+my @results;
-my @numbers = ();
-if ( $count > 10 ) {
- for ( my $i = 0 ; $i < ( $count / $num ) ; $i++ ) {
- my $highlight = 0;
- my $numberoffset = $i * $num;
- if ( ( $numberoffset + $num ) == $offset ) { $highlight = 1 }
+for(my $i=0;$i<$hits;$i++) {
+ my %resultsloop;
+ my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]);
+ my $biblio = MARCmarc2koha(C4::Context->dbh,$marcrecord,'');
+
+ #build the hash for the template.
+ $resultsloop{highlight} = ($i % 2)?(1):(0);
+ $resultsloop{title} = $biblio->{'title'};
+ $resultsloop{subtitle} = $biblio->{'subtitle'};
+ $resultsloop{biblionumber} = $biblio->{'biblionumber'};
+ $resultsloop{author} = $biblio->{'author'};
+ $resultsloop{publishercode} = $biblio->{'publishercode'};
+ $resultsloop{publicationyear} = $biblio->{'publicationyear'};
- # warn "I $i | N $num | O $offset | NO $numberoffset | H
$highlight";
- push @numbers,
- {
- number => ( $i + 1 ),
- highlight => $highlight,
- numberoffset => $numberoffset
- };
- }
+ push @results, \%resultsloop;
}
$template->param(
- bookselname => $booksellers[0]->{'name'},
- booksellerid => $booksellerid,
basketno => $basketno,
- parsub => $sub,
- count => $count,
- offset2 => $offset2,
- dispnum => $dispnum,
- offsetover => ( $offset < $count ),
- num => $num,
- offset => $prevoffset,
- offsetprev => $offsetprev,
- type => $type,
- title => $title,
- author => $author,
- donation => $donation,
- loopsearch => address@hidden,
- loopresult => address@hidden,
- numbers => address@hidden,
- invalidsearch => $invalidsearch,
- 'use-location-flags-p' => 1
+ bookselname => $booksellerid,
+ resultsloop => address@hidden,
+ total => $hits,
+ query => $query,
+ virtualshelves => C4::Context->preference("virtualshelves"),
+ LibraryName => C4::Context->preference("LibraryName"),
+ OpacNav => C4::Context->preference("OpacNav"),
+ opaccredits => C4::Context->preference("opaccredits"),
+ AmazonContent => C4::Context->preference("AmazonContent"),
+ opacsmallimage => C4::Context->preference("opacsmallimage"),
+ opaclayoutstylesheet =>
C4::Context->preference("opaclayoutstylesheet"),
+ opaccolorstylesheet =>
C4::Context->preference("opaccolorstylesheet"),
+
"BiblioDefaultView".C4::Context->preference("IntranetBiblioDefaultView") => 1,
);
+# BUILD THE TEMPLATE
output_html_with_http_headers $input, $cookie, $template->output;
-
Index: koha-tmpl/intranet-tmpl/prog/en/acqui/neworderbiblio.tmpl
===================================================================
RCS file:
/sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/acqui/Attic/neworderbiblio.tmpl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -b -r1.2.2.1 -r1.2.2.2
--- koha-tmpl/intranet-tmpl/prog/en/acqui/neworderbiblio.tmpl 13 Oct 2006
10:25:55 -0000 1.2.2.1
+++ koha-tmpl/intranet-tmpl/prog/en/acqui/neworderbiblio.tmpl 30 Oct 2006
11:24:07 -0000 1.2.2.2
@@ -5,65 +5,56 @@
<h1>Shopping Basket For: <!-- TMPL_VAR name="bookselname" --></h1>
-<div id="acqui_newbasket2_add">
- <a href="neworderempty.pl?id=<!-- TMPL_VAR name="id"
-->&basket=<!-- TMPL_VAR name="basket" -->&sub=<!-- TMPL_VAR
name="parsub" -->">Add New Biblio</a>
- | <a href="basket.pl?basket=<!-- TMPL_VAR name="basket" -->">View
Basket</a> |
- <form class="inline" action="/cgi-bin/koha/acqui/neworderbiblio.pl">
- <input type="hidden" name="id" value="<!-- TMPL_VAR name="id" -->" />
- <input type="hidden" name="basket" value="<!-- TMPL_VAR name="basket"
-->" />
- New Search: <input type="text" size="25" name="search" /></form>
-</div>
-<div id="acqui_newbasket2_search_result">
- <h2>You searched for
- <!-- TMPL_LOOP name="loopsearch" -->
- <!-- TMPL_VAR name="key" --> <!-- TMPL_VAR name="value" -->
- <!-- /TMPL_LOOP -->
- </h2>
- <p>Results <!-- TMPL_VAR name="dispnum" --> to <!-- TMPL_VAR
name="offset2" --> of <!-- TMPL_VAR name="count" --> results displayed.</p>
+<!-- TMPL_IF NAME="total" -->
+<b><!-- TMPL_VAR NAME="total" --> results found.</b>
+<!-- TMPL_ELSE -->
+<h3> No Result found !</h3>
+<p>
+ No results match your search for <span style="font-weight:
bold;">“<!-- TMPL_VAR NAME="query" -->”</span> in <!-- TMPL_VAR
NAME="LibraryName" --> Catalog.
+</p>
+<a href="JavaScript:back();" title="New search">Perform a new search</a>
+<!-- /TMPL_IF -->
+
+<!-- TMPL_IF NAME="query_error" -->
+<br /><br />
+<b>Error :</b>
+<span class="problem">
+ <!-- TMPL_VAR NAME="query_error" -->
+</span>
+<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="total"-->
+<div class="searchresults">
<table>
<tr>
<th>Title</th>
<th>Author</th>
- <th>©</th>
- <th>Count</th>
- <th>Location</th>
+ <th>publisher</th>
+ <th>Publication year</th>
</tr>
-
- <!-- TMPL_LOOP name="loopresult" -->
+ <!-- TMPL_LOOP NAME="resultsloop" -->
<tr>
<td>
- <a
href="/cgi-bin/koha/acqui/neworderempty.pl?sub=<!-- TMPL_VAR name="sub"
-->&author=<!-- TMPL_VAR name="author2" -->&copyright=<!-- TMPL_VAR
name="copyright" -->&id=<!-- TMPL_VAR name="id" -->&basket=<!--
TMPL_VAR name="basket" -->&biblio=<!-- TMPL_VAR name="biblionumber"
-->&title=<!-- TMPL_VAR name="title2" -->">
- <!-- TMPL_VAR name="title" -->
- </a>
- </td>
- <td>
- <a
href="/cgi-bin/koha/catalogue/search.pl?author=<!-- TMPL_VAR name="word"
-->&type=<!-- TMPL_VAR name="type" -->">
- <!-- TMPL_VAR name="author" -->
+ <a href="/cgi-bin/koha/acqui/addorder.pl?biblionumber=<!--
TMPL_VAR NAME="biblionumber" -->" title="order this one !">
+ <!-- TMPL_VAR NAME="title" -->
</a>
+ <br />
+ <small><!-- TMPL_VAR NAME="subtitle" --></small>
</td>
<td>
- <!-- TMPL_VAR name="copyright" -->
+ <!-- TMPL_VAR NAME="author" -->
</td>
<td>
- <!-- TMPL_VAR name="itemcount" -->
+ <!-- TMPL_VAR NAME="publishercode" -->
</td>
<td>
- <!-- TMPL_VAR name="location" -->
+ <!-- TMPL_VAR NAME="publicationyear" -->
</td>
</tr>
-
<!-- /TMPL_LOOP -->
-
</table>
-
- <!-- TMPL_IF name="offsetover" -->
- <a href="/cgi-bin/koha/acqui/neworderbiblio.pl?num=<!--
TMPL_VAR name="num" -->&offset=<!-- TMPL_VAR name="offset"
-->&type=<!-- TMPL_VAR name="type" -->&id=<!-- TMPL_VAR name="id"
-->&basket=<!-- TMPL_VAR name="basket" -->&search=<!-- TMPL_VAR
name="title" -->&author=<!-- TMPL_VAR name="author" -->">
- Next
- </a>
- <!-- /TMPL_IF -->
</div>
-
+<!-- /TMPL_IF -->
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha acqui/neworderbiblio.pl koha-tmpl/intranet... [rel_3_0],
Antoine Farnault <=