X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=request.pl;h=568f22174a21d875c8c142ddaf537f55b5bc508c;hb=3617982fc097e111b1ba6100c0d332311c63af8c;hp=27d0eda9d81e95b39d886cc221e99a0132bb8fe3;hpb=6c98407c18feefcf75473687aecdfb9a7e606373;p=koha.git diff --git a/request.pl b/request.pl index 27d0eda9d8..568f22174a 100755 --- a/request.pl +++ b/request.pl @@ -1,18 +1,41 @@ #!/usr/bin/perl +# $Id$ + #script to place reserves/requests #writen 2/1/00 by chris@katipo.oc.nz + +# Copyright 2000-2002 Katipo Communications +# +# 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., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + use strict; -#use DBI; use C4::Search; use C4::Output; +use C4::Auth; use C4::Reserves2; -use C4::Acquisitions; +use C4::Biblio; use C4::Koha; use C4::Circulation::Circ2; - +use HTML::Template; +use C4::Catalogue; use CGI; +use C4::Date; + my $input = new CGI; # get biblio information.... @@ -21,6 +44,7 @@ my $dat = bibdata($bib); # get existing reserves ..... my ($count,$reserves) = FindReserves($bib); +my $totalcount = $count; foreach my $res (@$reserves) { if ($res->{'found'} eq 'W') { $count--; @@ -29,249 +53,140 @@ foreach my $res (@$reserves) { # make priorities options my $num = $count + 1; -my $priorityoptions = priorityoptions($num, $num); - - -# get branch information -my $branch = $input->cookie('branch'); -my $branches = getbranches(); - - -my $branchoptions = branchoptions($branch); +#priorityoptions building +my @optionloop; +for (my $i=1; $i<=$num; $i++){ + my %option; + $option{num}=$i; + $option{selected}=($i==$num); + push(@optionloop, \%option); +} # todays date my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time); $year=$year+1900; $mon++; -my $date="$mday/$mon/$year"; - - +my $date=format_date("$year-$mon-$mday"); # get biblioitem information and build rows for form my ($count2,@data) = bibitems($bib); -my $bibitemrows = ""; -for (my $i=0; $i<$count2; $i++) { - if ($data[$i]->{'renewalsallowed'}){ - my @barcodes = barcodes($data[$i]->{'biblioitemnumber'}); - if ($data[$i]->{'dewey'} == 0){ - $data[$i]->{'dewey'}=""; - } - $data[$i]->{'volumeddesc'} = " " unless $data[$i]->{'volumeddesc'}; - $data[$i]->{'dewey'}=~ s/\.0000$//; - $data[$i]->{'dewey'}=~ s/00$//; - my $class="$data[$i]->{'classification'}$data[$i]->{'dewey'}$data[$i]->{'subclass'}"; - $bibitemrows .= <<"EOF"; - -{'biblioitemnumber'}> -{'biblioitemnumber'}> - -$data[$i]->{'description'} -$class -$data[$i]->{'volumeddesc'} -$data[$i]->{'isbn'} -$dat->{'copyrightdate'} -$data[$i]->{'publicationyear'} -@barcodes - -EOF + +my @bibitemloop; +foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) { + $dat->{'dewey'}="" if ($dat->{'dewey'} == 0); + $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'}; + $dat->{'dewey'}=~ s/\.0000$//; + $dat->{'dewey'}=~ s/00$//; + + my %abibitem; + my @barcodeloop; + my @barcodes = barcodes($dat->{'biblioitemnumber'}); + foreach my $num (@barcodes) { + my %barcode; + $barcode{'barcode'}=$num->{'barcode'}; + $barcode{'message'}=$num->{'itemlost'} == 1 ? "(lost)" : + $num->{'itemlost'} == 2 ? "(long overdue)" : ""; + push(@barcodeloop, \%barcode); } + $abibitem{'barcodeloop'}=\@barcodeloop; + $abibitem{'class'}="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}"; + my $select; + $abibitem{'itemlost'}=(($dat->{'notforloan'})|| ($dat->{'itemlost'} == 1)) ; + $abibitem{'biblioitemnumber'}=$dat->{'biblioitemnumber'}; + $abibitem{'description'}=$dat->{'description'}; + $abibitem{'volumeddesc'}=$dat->{'volumeddesc'}; + $abibitem{'publicationyear'}=$dat->{'publicationyear'}; + push(@bibitemloop,\%abibitem); } -my $existingreserves = ""; +#existingreserves building +my @reserveloop; +my $branches = getbranches(); foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){ - my $prioropt = priorityoptions($count, $res->{'priority'}); - my $bropt = branchoptions($res->{'branchcode'}); - my $bor=$res->{'borrowernumber'}; - $date = slashifyDate($res->{'reservedate'}); - - my $type=$res->{'constrainttype'}; - if ($type eq 'a'){ - $type='Next Available'; - } elsif ($type eq 'o'){ - $type="This type only $res->{'volumeddesc'} $res->{'itemtype'}"; - } + my %reserve; +# my $prioropt = priorityoptions($totalcount, $res->{'priority'}); + my @optionloop; + for (my $i=1; $i<=$totalcount; $i++){ + my %option; + $option{num}=$i; + $option{selected}=($i==$res->{'priority'}); + push(@optionloop, \%option); + } + my @branchloop; + foreach my $br (keys %$branches) { +# (next) unless $branches->{$br}->{'IS'}; + # Only branches with the 'IS' branchrelation + # can issue books + my %abranch; + $abranch{'selected'}=($br eq $res->{'branchcode'}); + $abranch{'branch'}=$br; + $abranch{'branchname'}=$branches->{$br}->{'branchname'}; + push(@branchloop,\%abranch); + } - my $notes = $res->{'reservenotes'}." "; - my $rank; - my $pickup; - my $change; if ($res->{'found'} eq 'W') { - my %env; - my $item = $res->{'itemnumber'}; - $item = getiteminformation(\%env,$item); - $item = "{'biblionumber'} &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$item->{'barcode'}"; - my $wbra = $branches->{$res->{'branchcode'}}->{'branchname'}; - $rank = "Item waiting"; - $type = $item; - $pickup = "at ".$wbra.""; - $change = "delete"; - } else { - $rank = ""; - $pickup = ""; - $change = ""; - } - $existingreserves .= <<"EOF"; -{'borrowernumber'}> -{'biblionumber'}> - -$rank - -$res->{'firstname'} $res->{'surname'} - -$notes -$date -$pickup -$type -$change - -EOF -} - - - -sub priorityoptions { - my ($count, $sel) = @_; - my $out = ""; - for (my $i=1; $i<=$count; $i++){ - $out .= "