Bug 18858: Prevent warn when deleting a borrower debarment
[koha.git] / circ / transferstoreceive.pl
blob88f9aa607a4caa75d35257c145d4fee059b563ce
1 #!/usr/bin/perl
4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 use strict;
22 use warnings;
23 use CGI qw ( -utf8 );
24 use C4::Context;
25 use C4::Output;
26 use C4::Auth;
27 use C4::Biblio;
28 use C4::Circulation;
29 use C4::Members;
30 use Date::Calc qw(
31 Today
32 Add_Delta_Days
33 Date_to_Days
36 use C4::Koha;
37 use C4::Reserves;
38 use Koha::Items;
39 use Koha::ItemTypes;
40 use Koha::Libraries;
41 use Koha::DateUtils;
42 use Koha::BiblioFrameworks;
43 use Koha::Patrons;
45 my $input = new CGI;
46 my $itemnumber = $input->param('itemnumber');
48 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
50 template_name => "circ/transferstoreceive.tt",
51 query => $input,
52 type => "intranet",
53 authnotrequired => 0,
54 flagsrequired => { circulate => "circulate_remaining_permissions" },
55 debug => 1,
59 # set the userenv branch
60 my $default = C4::Context->userenv->{'branch'};
62 # get the all the branches for reference
63 my $libraries = Koha::Libraries->search({}, { order_by => 'branchname' });
64 my @branchesloop;
65 my $latetransfers;
66 while ( my $library = $libraries->next ) {
67 my @transferloop;
68 my %branchloop;
69 my @gettransfers =
70 GetTransfersFromTo( $library->branchcode, $default );
72 if (@gettransfers) {
73 $branchloop{'branchname'} = $library->branchname;
74 $branchloop{'branchcode'} = $library->branchcode;
75 foreach my $num (@gettransfers) {
76 my %getransf;
78 my ( $sent_year, $sent_month, $sent_day ) = split "-",
79 $num->{'datesent'};
80 $sent_day = ( split " ", $sent_day )[0];
81 ( $sent_year, $sent_month, $sent_day ) =
82 Add_Delta_Days( $sent_year, $sent_month, $sent_day,
83 C4::Context->preference('TransfersMaxDaysWarning'));
84 my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day );
85 my $today = Date_to_Days(&Today);
86 my $diff = $today - $calcDate;
88 if ($today > $calcDate) {
89 $latetransfers = 1;
90 $getransf{'messcompa'} = 1;
91 $getransf{'diff'} = $diff;
94 my $item = Koha::Items->find( $num->{itemnumber} );
95 my $biblio = $item->biblio;
96 my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
98 $getransf{'datetransfer'} = $num->{'datesent'};
99 $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description?
100 %getransf = (
101 %getransf,
102 title => $biblio->title,
103 author => $biblio->author,
104 biblionumber => $biblio->biblionumber,
105 itemnumber => $item->itemnumber,
106 barcode => $item->barcode,
107 homebranch => $item->homebranch,
108 holdingbranch => $item->holdingbranch,
109 itemcallnumber => $item->itemcallnumber,
112 my $record = GetMarcBiblio($biblio->biblionumber);
113 $getransf{'subtitle'} = GetRecordValue('subtitle', $record, $biblio->frameworkcode);
115 # we check if we have a reserv for this transfer
116 my $holds = $item->current_holds;
117 if ( my $first_hold = $holds->next ) {
118 my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
119 # FIXME The full patron object should be passed to the template
120 $getransf{'borrowernum'} = $patron->borrowernumber;
121 $getransf{'borrowername'} = $patron->surname;
122 $getransf{'borrowerfirstname'} = $patron->firstname;
123 $getransf{'borrowermail'} = $patron->email if $patron->email;
124 $getransf{'borrowerphone'} = $patron->phone;
126 push( @transferloop, \%getransf );
129 # If we have a return of reservloop we put it in the branchloop sequence
130 $branchloop{'reserv'} = \@transferloop;
132 push( @branchesloop, \%branchloop ) if %branchloop;
135 $template->param(
136 branchesloop => \@branchesloop,
137 show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }),
138 TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'),
139 latetransfers => $latetransfers ? 1 : 0,
142 # Checking if there is a Fast Cataloging Framework
143 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
145 output_html_with_http_headers $input, $cookie, $template->output;