Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 288 lines (264 sloc) 9.572 kB
#!/usr/bin/env perl
# WARNING: This file uses 4-character tabs!
#written 11/3/2002 by Finlay
#script to execute branch transfers of books
# 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 warnings;
use CGI;
use C4::Circulation;
use C4::Output;
use C4::Reserves;
use C4::Biblio;
use C4::Items;
use C4::Auth qw/:DEFAULT get_session/;
use C4::Branch; # GetBranches
use C4::Koha;
use C4::Members;
use C4::Dates;
###############################################
# Getting state
my $query = CGI->new();
if (!C4::Context->userenv){
my $sessionID = $query->cookie("CGISESSID");
my $session;
$session = get_session($sessionID) if $sessionID;
if (!$session or $session->param('branch') eq 'NO_LIBRARY_SET'){
# no branch set we can't transfer
print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
exit;
}
}
#######################################################################################
# Make the page .....
my ($template, $user, $cookie) = get_template_and_user(
{
template_name => "circ/branchtransfers.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { circulate => "circulate_remaining_permissions" },
}
);
my $branches = GetBranches;
my $messages;
my $found;
my $reserved;
my $waiting;
my $reqmessage;
my $cancelled;
my $setwaiting;
my $request = $query->param('request') || '';
my $borrowernumber = $query->param('borrowernumber') || 0;
my $tobranchcd = $query->param('tobranchcd') || '';
my $reservenumber = $query->param('reservenumber') || '';
my $ignoreRs = 0;
############
# Deal with the requests....
if ( $request eq "KillWaiting" ) {
my $item = $query->param('itemnumber');
CancelReserve( $reservenumber );
$cancelled = 1;
$reqmessage = 1;
}
elsif ( $request eq "SetWaiting" ) {
my $item = $query->param('itemnumber');
ModReserveAffect( $item, $borrowernumber );
$ignoreRs = 1;
$setwaiting = 1;
$reqmessage = 1;
}
elsif ( $request eq 'KillReserved' ) {
my $biblio = $query->param('biblionumber');
CancelReserve( $reservenumber );
$cancelled = 1;
$reqmessage = 1;
}
elsif ($request eq 'CancelTransfer') {
C4::Circulation::DeleteTransfer($query->param('itemnumber'));
}
# collect the stack of books already transfered so they can be printed...
my @trsfitemloop;
my %transfereditems;
my $transfered;
my $barcode = $query->param('barcode');
# strip whitespace
defined $barcode and $barcode =~ s/\s*//g; # FIXME: barcodeInputFilter
# warn "barcode : $barcode";
my $exactBarcode;
my $itemnumber;
my $biblionumber;
my $frbranchcd = my $currBranch = C4::Context->userenv->{'branch'};
if ($barcode) {
$exactBarcode = $query->param('exactBarcode');
if (!$exactBarcode) {
my @itemsbc = @{C4::Circulation::GetItemnumbersFromBarcodeStr($barcode)};
if (@itemsbc==1) {
$barcode = $itemsbc[0]{barcode};
}
elsif (@itemsbc) {
my @itemnumbers = ();
foreach(@itemsbc) { push @itemnumbers, $$_{itemnumber} }
my @items = @{C4::Items::GetItemsFreeDetails(itemnumbers => \@itemnumbers)};
$template->param(
items => \@items,
tobranchcd => $tobranchcd,
);
$barcode = undef;
}
}
if ($barcode) {
my $iteminformation;
( $transfered, $messages, $iteminformation, $itemnumber ) =
C4::Circulation::transferbook( $tobranchcd, $barcode, $ignoreRs )
if ($tobranchcd ne $currBranch);
$found = $messages->{'ResFound'};
if ($transfered) {
my %item;
# if ( not($found) ) {
$item{'biblionumber'} = $iteminformation->{'biblionumber'};
$item{'title'} = $iteminformation->{'title'};
$item{'author'} = $iteminformation->{'author'};
$item{'itemtype'} = $iteminformation->{'itemtype'};
$item{'ccode'} = $iteminformation->{'ccode'};
$item{'frbrname'} = $branches->{$frbranchcd}->{'branchname'};
$item{'tobrname'} = $branches->{$tobranchcd}->{'branchname'};
# }
$item{counter} = 0;
$item{barcode} = $barcode;
$item{frombrcd} = $frbranchcd;
$item{tobrcd} = $tobranchcd;
push( @trsfitemloop, \%item );
}
}
}
foreach ( $query->param ) {
(next) unless (/bc-(\d*)/);
my $counter = $1;
my %item;
my $bc = $query->param("bc-$counter");
my $frbcd = $query->param("fb-$counter");
my $tobcd = $query->param("tb-$counter");
$counter++;
$item{counter} = $counter;
$item{barcode} = $bc;
$item{frombrcd} = $frbcd;
$item{tobrcd} = $tobcd;
my ($iteminformation) = GetBiblioFromItemNumber( GetItemnumberFromBarcode($bc) );
$item{'itemnumber'} = $iteminformation->{'itemnumber'};
$item{'biblionumber'} = $iteminformation->{'biblionumber'};
$item{'title'} = $iteminformation->{'title'};
$item{'author'} = $iteminformation->{'author'};
$item{'itemtype'} = $iteminformation->{'itemtype'};
$item{'ccode'} = $iteminformation->{'ccode'};
$item{'frbrname'} = $branches->{$frbcd}->{'branchname'};
$item{'tobrname'} = $branches->{$tobcd}->{'branchname'};
push( @trsfitemloop, \%item );
}
#####################
if ($found) {
my $res = $messages->{'ResFound'};
my $reservenumber = $res->{'reservenumber'};
$itemnumber = $res->{'itemnumber'};
if ( $res->{'ResFound'} eq "Waiting" ) {
$waiting = 1;
}
elsif ( $res->{'ResFound'} eq "Reserved" ) {
$reserved = 1;
$biblionumber = $res->{'biblionumber'};
}
}
#####################
# Used for branch transfer limits error messages.
my $codeTypeDescription = 'Collection Code';
my $codeType = C4::Context->preference("BranchTransferLimitsType");
if ( $codeType eq 'itemtype' ) {
$codeTypeDescription = 'Item Type';
}
my @errmsgloop;
if ($tobranchcd eq $currBranch) {
$$messages{errdesteqcurr} = 1;
}
foreach my $code ( keys %$messages ) {
my %err;
if ( $code eq 'BadBarcode' ) {
$err{msg} = $messages->{'BadBarcode'};
$err{errbadcode} = 1;
}
elsif ( $code eq "NotAllowed" ) {
warn "NotAllowed: $messages->{'NotAllowed'} to " . $branches->{ $messages->{'NotAllowed'} }->{'branchname'};
# Do we really want a error log message here? --atz
$err{errnotallowed} = 1;
my ( $tbr, $typecode ) = split( /::/, $messages->{'NotAllowed'} );
$err{tbr} = $branches->{ $tbr }->{'branchname'};
$err{code} = $typecode;
$err{codeType} = $codeTypeDescription;
}
elsif ( $code eq 'IsPermanent' ) {
$err{errispermanent} = 1;
$err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
}
elsif ( $code eq 'WasReturned' ) {
$err{errwasreturned} = 1;
foreach(qw(borrowernumber title firstname surname cardnumber overdue)) {
$err{$_} = $messages->{$code}->{$_};
}
$err{duedate} = C4::Dates->new($$messages{$code}{date_due},'iso')->output;
}
elsif ($code eq 'PendingTransfer') {
$err{errpending} = 1;
$err{frombranchname} = $$branches{$$messages{PendingTransfer}{frombranch}}{branchname};
$err{tobranchname} = $$branches{$$messages{PendingTransfer}{tobranch}}{branchname};
$err{datesent} = $$messages{PendingTransfer}{datesent};
$err{itemnumber} = $itemnumber || GetItemnumberFromBarcode($exactBarcode);
}
elsif ($code eq 'errdesteqcurr') {
$err{errdesteqcurr} = 1;
}
elsif ($code eq 'DestinationEqualsHolding') {
$err{errdesteqholding} = 1;
}
push( @errmsgloop, \%err ) if %err;
}
# use Data::Dumper;
# warn "FINAL ============= ".Dumper(@trsfitemloop);
my @brloop = ();
foreach(@{GetBranchesLoop($tobranchcd) // []}) {
push @brloop, $_ if $$_{'value'} ne $currBranch;
}
$template->param(
found => $found,
reserved => $reserved,
waiting => $waiting,
borrowernumber => $borrowernumber,
itemnumber => $itemnumber,
reservenumber => $reservenumber,
barcode => $barcode,
biblionumber => $biblionumber,
tobranchcd => $tobranchcd,
reqmessage => $reqmessage,
cancelled => $cancelled,
setwaiting => $setwaiting,
trsfitemloop => \@trsfitemloop,
branchoptionloop => \@brloop,
errmsgloop => \@errmsgloop,
CircAutocompl => C4::Context->preference("CircAutocompl")
);
output_html_with_http_headers $query, $cookie, $template->output;
exit;
__END__
Jump to Line
Something went wrong with that request. Please try again.
https://github.com/liblime/LibLime-Koha/blob/v4.08.00/circ/branchtransfers.pl
github.com
crawl=CC-MAIN-2015-32
167822
application/http; msgtype=response
sha1:TDRH5SUQOPZ7D7ZYSECW3ROJAYIUO63T
<urn:uuid:f1c956dc-7b45-4f7b-9e97-f4111c88e7fb>
2015-08-05T13:48:01Z
192.30.252.130
sha1:4UO6DXVZUPXJJ74OJXYMT2HUWJU7SY3R
<urn:uuid:0303c30e-d27f-4092-b7b7-d90a07305b9f>
https://github.com/liblime/LibLime-Koha/blob/v4.08.00/circ/branchtransfers.pl
length
response
<urn:uuid:a66d0447-7a69-487e-adc0-7de52dc01fb3>
robots: classic
hostname: ip-10-236-191-2.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2015-32
operator: CommonCrawl Admin
description: Wide crawl of the web for August 2015
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf