5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
32 use C4::Interface::CGI::Output;
44 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
45 my $itemnumber = $input->param('itemnumber');
46 my $todaysdate = join "-", &Today;
48 # if we have a resturn of the form to delete the transfer, we launch the subrroutine
50 C4::Circulation::Circ2::DeleteTransfer($itemnumber);
53 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
55 template_name => "circ/currenttransfers.tmpl",
59 flagsrequired => { circulate => 1 },
64 # set the userenv branch
65 my $default = C4::Context->userenv->{'branch'};
67 # get the all the branches for reference
68 my $branches = GetBranches();
70 foreach my $br ( keys %$branches ) {
73 $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
74 $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
76 GetTransfersFromTo( $branches->{$br}->{'branchcode'}, $default );
79 foreach my $num (@gettransfers) {
83 my ( $sent_year, $sent_month, $sent_day ) = split "-",
85 $sent_day = ( split " ", $sent_day )[0];
86 ( $sent_year, $sent_month, $sent_day ) =
87 Add_Delta_Days( $sent_year, $sent_month, $sent_day,
88 C4::Context->preference('TransfersMaxDaysWarning'));
89 my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day );
90 my $today = Date_to_Days(&Today);
91 my $warning = ( $today > $calcDate );
94 $getransf{'messcompa'} = 1;
96 my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} );
97 my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
99 $getransf{'title'} = $gettitle->{'title'};
100 $getransf{'datetransfer'} = format_date( $num->{'datesent'} );
101 $getransf{'biblionumber'} = $gettitle->{'biblionumber'};
102 $getransf{'itemnumber'} = $gettitle->{'itemnumber'};
103 $getransf{'barcode'} = $gettitle->{'barcode'};
104 $getransf{'itemtype'} = $itemtypeinfo->{'description'};
105 $getransf{'homebranch'} = $gettitle->{'homebranch'};
106 $getransf{'holdingbranch'} = $gettitle->{'holdingbranch'};
107 $getransf{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
109 # we check if we have a reserv for this transfer
110 my @checkreserv = GetReservations( $num->{'itemnumber'} );
111 if ( $checkreserv[0] ) {
113 GetMemberDetails( $checkreserv[1] );
114 $getransf{'borrowernum'} = $getborrower->{'borrowernumber'};
115 $getransf{'borrowername'} = $getborrower->{'surname'};
116 $getransf{'borrowerfirstname'} = $getborrower->{'firstname'};
117 if ( $getborrower->{'emailaddress'} ) {
118 $getransf{'borrowermail'} = $getborrower->{'emailaddress'};
120 $getransf{'borrowerphone'} = $getborrower->{'phone'};
123 push( @transferloop, \%getransf );
126 # If we have a return of reservloop we put it in the branchloop sequence
127 $branchloop{'reserv'} = \@transferloop;
131 # if we don't have a retrun from reservestobranch we unset branchname and branchcode
132 $branchloop{'branchname'} = 0;
133 $branchloop{'branchcode'} = 0;
135 push( @branchesloop, \%branchloop );
139 branchesloop => \@branchesloop,
140 show_date => format_date($todaysdate),
143 output_html_with_http_headers $input, $cookie, $template->output;