Escaping the $title in the regexes with \Q and \E to handle nested quantifiers, cheer...
[koha.git] / catalogue / moredetail.pl
blob8b06517ad3e7e5c9678f8c3a0f12fa40abad25d3
1 #!/usr/bin/perl
3 # Copyright 2000-2003 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
21 use strict;
22 require Exporter;
23 use C4::Koha;
24 use CGI;
25 use C4::Biblio;
26 use C4::Items;
27 use C4::Branch;
28 use C4::Acquisition;
29 use C4::Output; # contains gettemplate
30 use C4::Auth;
31 use C4::Dates qw/format_date/;
32 use C4::Circulation; # to use itemissues
34 my $query=new CGI;
36 # FIXME subject is not exported to the template?
37 my $subject=$query->param('subject');
39 # if its a subject we need to use the subject.tmpl
40 my ($template, $loggedinuser, $cookie) = get_template_and_user({
41 template_name => ($subject? 'catalogue/subject.tmpl':
42 'catalogue/moredetail.tmpl'),
43 query => $query,
44 type => "intranet",
45 authnotrequired => 0,
46 flagsrequired => {catalogue => 1},
47 });
49 # get variables
51 my $biblionumber=$query->param('biblionumber');
52 my $title=$query->param('title');
53 # my $bi=$query->param('bi');
54 # $bi = $biblionumber unless $bi;
55 my $data=GetBiblioData($biblionumber);
56 my $dewey = $data->{'dewey'};
58 # FIXME Dewey is a string, not a number, & we should use a function
59 # $dewey =~ s/0+$//;
60 # if ($dewey eq "000.") { $dewey = "";};
61 # if ($dewey < 10){$dewey='00'.$dewey;}
62 # if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
63 # if ($dewey <= 0){
64 # $dewey='';
65 # }
66 # $dewey=~ s/\.$//;
67 # $data->{'dewey'}=$dewey;
69 my @results;
70 my $fw = GetFrameworkCode($biblionumber);
71 my @items= GetItemsInfo($biblionumber);
72 my $count=@items;
73 $data->{'count'}=$count;
75 my $ordernum = GetOrderNumber($biblionumber);
76 my $order = GetOrder($ordernum);
77 my $ccodes= GetKohaAuthorisedValues('items.ccode',$fw);
78 my $itemtypes = GetItemTypes;
80 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'description'};
81 $results[0]=$data;
82 foreach my $item (@items){
83 $item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw);
84 $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw);
85 $item->{'collection'} = $ccodes->{$item->{ccode}};
86 $item->{'itype'} = $itemtypes->{$item->{'itype'}}->{'description'};
87 $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'});
88 $item->{'datelastborrowed'}= format_date($item->{'datelastborrowed'});
89 $item->{'dateaccessioned'} = format_date($item->{'dateaccessioned'});
90 $item->{'datelastseen'} = format_date($item->{'datelastseen'});
91 $item->{'ordernumber'} = $ordernum;
92 $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
93 $item->{'homebranchname'} = GetBranchName($item->{'homebranch'});
94 $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'});
95 if ($item->{'onloan'} eq ''){
96 $item->{'issue'}= 0;
97 } else {
98 $item->{'onloan'} = format_date($item->{'onloan'});
99 $item->{'issue'}= 1;
102 $template->param(count => $data->{'count'});
103 $template->param(BIBITEM_DATA => \@results);
104 $template->param(ITEM_DATA => \@items);
105 $template->param(moredetailview => 1);
106 $template->param(loggedinuser => $loggedinuser);
107 $template->param(biblionumber => $biblionumber);
109 output_html_with_http_headers $query, $cookie, $template->output;