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/transferstoreceive.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) {
82 my ( $sent_year, $sent_month, $sent_day ) = split "-",
84 $sent_day = ( split " ", $sent_day )[0];
85 ( $sent_year, $sent_month, $sent_day ) =
86 Add_Delta_Days( $sent_year, $sent_month, $sent_day,
87 C4::Context->preference('TransfersMaxDaysWarning'));
88 my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day );
89 my $today = Date_to_Days(&Today);
90 my $warning = ( $today > $calcDate );
93 $getransf{'messcompa'} = 1;
95 my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} );
96 my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
98 $getransf{'title'} = $gettitle->{'title'};
99 $getransf{'datetransfer'} = format_date( $num->{'datesent'} );
100 $getransf{'biblionumber'} = $gettitle->{'biblionumber'};
101 $getransf{'itemnumber'} = $gettitle->{'itemnumber'};
102 $getransf{'barcode'} = $gettitle->{'barcode'};
103 $getransf{'itemtype'} = $itemtypeinfo->{'description'};
104 $getransf{'homebranch'} = $gettitle->{'homebranch'};
105 $getransf{'holdingbranch'} = $gettitle->{'holdingbranch'};
106 $getransf{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
108 # we check if we have a reserv for this transfer
109 my @checkreserv = GetReservations( $num->{'itemnumber'} );
110 if ( $checkreserv[0] ) {
112 GetMemberDetails( $checkreserv[1] );
113 $getransf{'borrowernum'} = $getborrower->{'borrowernumber'};
114 $getransf{'borrowername'} = $getborrower->{'surname'};
115 $getransf{'borrowerfirstname'} = $getborrower->{'firstname'};
116 if ( $getborrower->{'emailaddress'} ) {
117 $getransf{'borrowermail'} = $getborrower->{'emailaddress'};
119 $getransf{'borrowerphone'} = $getborrower->{'phone'};
122 push( @transferloop, \%getransf );
125 # If we have a return of reservloop we put it in the branchloop sequence
126 $branchloop{'reserv'} = \@transferloop;
130 # if we don't have a retrun from reservestobranch we unset branchname and branchcode
131 $branchloop{'branchname'} = 0;
132 $branchloop{'branchcode'} = 0;
134 push( @branchesloop, \%branchloop );
138 branchesloop => \@branchesloop,
139 show_date => format_date($todaysdate),
142 output_html_with_http_headers $input, $cookie, $template->output;