X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=request.pl;h=379418a7ffe90ea450ad63db93da4e6f3daf8662;hb=3b9defca8705e61c212dc005c03f8e27f23de64c;hp=8ed764e4400493205589bba0e06119e6f472eab1;hpb=13e7c898dff603108d79380cc3bad38a2df0ba4d;p=koha.git diff --git a/request.pl b/request.pl index 8ed764e440..379418a7ff 100755 --- a/request.pl +++ b/request.pl @@ -1,5 +1,7 @@ #!/usr/bin/perl +# $Id$ + #script to place reserves/requests #writen 2/1/00 by chris@katipo.oc.nz @@ -25,10 +27,12 @@ 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 CGI; my $input = new CGI; @@ -48,14 +52,33 @@ foreach my $res (@$reserves) { # make priorities options my $num = $count + 1; -my $priorityoptions = priorityoptions($num, $num); + +#priorityoptions building +my @optionloop; +for (my $i=1; $i<=$num; $i++){ + my %option; + $option{num}=$i; + $option{selected}=($i==$num); + push(@optionloop, \%option); +} # get branch information my $branch = $input->cookie('branch'); ($branch) || ($branch = 'L'); my $branches = getbranches(); -my $branchoptions = branchoptions($branch); +# make branch selection options... +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 $branch); + $abranch{'branch'}=$br; + $abranch{'branchname'}=$branches->{$br}->{'branchname'}; + push(@branchloop,\%abranch); +} # todays date @@ -65,239 +88,110 @@ $mon++; my $date="$mday/$mon/$year"; - - # get biblioitem information and build rows for form my ($count2,@data) = bibitems($bib); -my $bibitemrows = ""; - +my @bibitemloop; foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) { - my @barcodes = barcodes($dat->{'biblioitemnumber'}); - my $barcodestext = ""; - foreach my $num (@barcodes) { - my $message = $num->{'itemlost'} == 1 ? "(lost)" : - $num->{'itemlost'} == 2 ? "(long overdue)" : ""; - $barcodestext .= "$num->{'barcode'} $message
"; - } - $barcodestext = substr($barcodestext, 0, -4); - $dat->{'dewey'}="" if ($dat->{'dewey'} == 0); - $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'}; $dat->{'dewey'}=~ s/\.0000$//; $dat->{'dewey'}=~ s/00$//; - my $class="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}"; - my $select; - if (($dat->{'notforloan'}) - || ($dat->{'itemlost'} == 1)) { - $select = "Cannot be reserved."; - } else { - $select = " {'biblioitemnumber'}>{'biblioitemnumber'}>"; - } - $bibitemrows .= <<"EOF"; - -$select -$dat->{'description'} -$class -$dat->{'volumeddesc'} -$dat->{'publicationyear'} -$barcodestext - -EOF -} - - - -my $existingreserves = ""; -foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){ - my $prioropt = priorityoptions($totalcount, $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 $notes = $res->{'reservenotes'}." "; - my $rank; - my $pickup; - 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 $wbrcd = $res->{'branchcode'}; - my $wbra = $branches->{$wbrcd}->{'branchname'}; - $type = $item; - $rank = ""; - $pickup = "Item waiting at ".$wbra." "; - } else { - $rank = ""; - $pickup = ""; + 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); } - $existingreserves .= <<"EOF"; - - -{'borrowernumber'}> -{'biblionumber'}> -$rank - -$res->{'firstname'} $res->{'surname'} - -$notes -$date -$pickup -$type - -EOF + $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); } -sub priorityoptions { - my ($count, $sel) = @_; - my $out = ""; - for (my $i=1; $i<=$count; $i++){ - $out .= "\n"; - } - return $out; -} - -# make branch selection options... -sub branchoptions { - my ($selbr) = @_; - my $out = ""; - foreach my $br (keys %$branches) { - (next) unless $branches->{$br}->{'IS'}; - my $selected = ""; - if ($br eq $selbr) { - $selected = "selected"; +# my $bropt = branchoptions($res->{'branchcode'}); + 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); } - $out .= "\n"; + + if ($res->{'found'} eq 'W') { + my %env; + my $item = $res->{'itemnumber'}; + $item = getiteminformation(\%env,$item); + $reserve{'barcode'}=$item->{'barcode'}; + $reserve{'biblionumber'}=$item->{'biblionumber'}; + $reserve{'wbrcode'} = $res->{'branchcode'}; + $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'}; } - return $out; + $reserve{'date'} = slashifyDate($res->{'reservedate'}); + $reserve{'borrowernumber'}=$res->{'borrowernumber'}; + $reserve{'biblionumber'}=$res->{'biblionumber'}; + $reserve{'bornum'}=$res->{'borrowernumber'}; + $reserve{'firstname'}=$res->{'firstname'}; + $reserve{'bornum'}=$res->{'borrowernumber'}; + $reserve{'notes'}=$res->{'reservenotes'}; + $reserve{'wait'}=($res->{'found'} eq 'W'); + $reserve{'constrainttypea'}=($res->{'constrainttype'} eq 'a'); + $reserve{'constrainttypeo'}=($res->{'constrainttype'} eq 'o'); + $reserve{'voldesc'}=$res->{'volumeddesc'}; + $reserve{'itemtype'}=$res->{'itemtype'}; + $reserve{'branchloop'}=\@branchloop; + $reserve{'optionloop'}=\@optionloop; + push(@reserveloop,\%reserve); } - #get the time for the form name... my $time = time(); -# printout the page - -print $input->header(-expires=>'now'); - - #setup colours -print startmenu('catalogue'); - - - - -print < - - - - -Requesting:
-$dat->{'title'} -($dat->{'author'})

-

- - - - - - - - - - - - - - - - - - - - - -
RankMember NumberNotesDatePickupRequest
$dateNext Available, -
(or choose from list below)
- - - - - - - - - - - - - -$bibitemrows -
RequestItem TypeClassificationVolumePubdateCopies
- - -

 

- - - - - -
- - - - - - - - - - - - - - - - -$existingreserves - - - -
MODIFY EXISTING REQUESTS
RankMemberNotesDatePickupRequest
-Delete a request by selecting "del" from the rank list. -
-

-
-

- -printend -; - -print endmenu(); -print endpage(); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "request.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + }); +$template->param( optionloop =>\@optionloop, + branchloop => \@branchloop, + reserveloop => \@reserveloop, + 'time' => $time, + bibitemloop => \@bibitemloop, + date => $date); +# printout the page +print $input->header(-expires=>'now'), $template->output;