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 under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 use C4
::Branch
; # GetBranches
28 use C4
::Dates qw
/format_date/;
42 my $itemnumber = $input->param('itemnumber');
44 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
46 template_name
=> "circ/transferstoreceive.tmpl",
50 flagsrequired
=> { circulate
=> "circulate_remaining_permissions" },
55 # set the userenv branch
56 my $default = C4
::Context
->userenv->{'branch'};
58 # get the all the branches for reference
59 my $branches = GetBranches
();
62 foreach my $br ( keys %$branches ) {
66 GetTransfersFromTo
( $branches->{$br}->{'branchcode'}, $default );
69 $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
70 $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
71 foreach my $num (@gettransfers) {
74 my ( $sent_year, $sent_month, $sent_day ) = split "-",
76 $sent_day = ( split " ", $sent_day )[0];
77 ( $sent_year, $sent_month, $sent_day ) =
78 Add_Delta_Days
( $sent_year, $sent_month, $sent_day,
79 C4
::Context
->preference('TransfersMaxDaysWarning'));
80 my $calcDate = Date_to_Days
( $sent_year, $sent_month, $sent_day );
81 my $today = Date_to_Days
(&Today
);
82 my $diff = $today - $calcDate;
84 if ($today > $calcDate) {
86 $getransf{'messcompa'} = 1;
87 $getransf{'diff'} = $diff;
89 my $gettitle = GetBiblioFromItemNumber
( $num->{'itemnumber'} );
90 my $itemtypeinfo = getitemtypeinfo
( (C4
::Context
->preference('item-level_itypes')) ?
$gettitle->{'itype'} : $gettitle->{'itemtype'} );
92 $getransf{'datetransfer'} = format_date
( $num->{'datesent'} );
93 $getransf{'itemtype'} = $itemtypeinfo ->{'description'};
94 foreach (qw(title author biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) {
95 $getransf{$_} = $gettitle->{$_};
98 my $record = GetMarcBiblio
($gettitle->{'biblionumber'});
99 $getransf{'subtitle'} = GetRecordValue
('subtitle', $record, GetFrameworkCode
($gettitle->{'biblionumber'}));
101 # we check if we have a reserv for this transfer
102 my @checkreserv = GetReservesFromItemnumber
($num->{'itemnumber'} );
103 if ( $checkreserv[0] ) {
104 my $getborrower = GetMemberDetails
( $checkreserv[1] );
105 $getransf{'borrowernum'} = $getborrower->{'borrowernumber'};
106 $getransf{'borrowername'} = $getborrower->{'surname'};
107 $getransf{'borrowerfirstname'} = $getborrower->{'firstname'};
108 $getransf{'borrowermail'} = $getborrower->{'emailaddress'} if $getborrower->{'emailaddress'};
109 $getransf{'borrowerphone'} = $getborrower->{'phone'};
111 push( @transferloop, \
%getransf );
114 # If we have a return of reservloop we put it in the branchloop sequence
115 $branchloop{'reserv'} = \
@transferloop;
117 push( @branchesloop, \
%branchloop ) if %branchloop;
121 branchesloop
=> \
@branchesloop,
122 show_date
=> format_date
(C4
::Dates
->today('iso')),
123 'dateformat_' . (C4
::Context
->preference("dateformat") || '') => 1,
124 TransfersMaxDaysWarning
=> C4
::Context
->preference('TransfersMaxDaysWarning'),
125 latetransfers
=> $latetransfers ?
1 : 0,
128 output_html_with_http_headers
$input, $cookie, $template->output;