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 with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
25 use C4::Branch; # GetBranches
41 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43 template_name => "circ/transferstodo.tmpl",
47 flagsrequired => { circulate => 1 },
52 # set the userenv branch
53 my $default = C4::Context->userenv->{'branch'};
55 my @datearr = localtime( time() );
57 ( 1900 + $datearr[5] ) . '-'
58 . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
59 . sprintf( "%0.2d", $datearr[3] );
61 my $item = $input->param('itemnumber');
62 my $fbr = $input->param('fbr');
63 my $tbr = $input->param('tbr');
65 # If we have a return of the form dotransfer, we launch the subroutine dotransfer
67 C4::Circulation::Circ2::ModItemTransfer( $item, $fbr, $tbr );
70 # get the all the branches for reference
71 my $branches = GetBranches();
74 foreach my $br ( keys %$branches ) {
78 GetReservesToBranch( $branches->{$br}->{'branchcode'} );
80 $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
81 $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
82 foreach my $num (@getreserves) {
84 my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} );
86 # warn Dumper($gettitle);
87 my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
88 if ( $gettitle->{'holdingbranch'} eq $default ) {
90 GetMemberDetails( $num->{'borrowernumber'} );
91 $getreserv{'reservedate'} =
92 format_date( $num->{'reservedate'} );
93 my ( $reserve_year, $reserve_month, $reserve_day ) = split /-/,
94 $num->{'reservedate'};
95 ( $reserve_year, $reserve_month, $reserve_day ) =
96 Add_Delta_Days( $reserve_year, $reserve_month, $reserve_day,
97 C4::Context->preference('ReservesMaxPickUpDelay'));
99 Date_to_Days( $reserve_year, $reserve_month, $reserve_day );
100 my $today = Date_to_Days(&Today);
101 my $warning = ( $today > $calcDate );
103 if ( $warning > 0 ) {
104 $getreserv{'messcompa'} = 1;
106 $getreserv{'title'} = $gettitle->{'title'};
107 $getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
108 $getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
109 $getreserv{'barcode'} = $gettitle->{'barcode'};
110 $getreserv{'itemtype'} = $itemtypeinfo->{'description'};
111 $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
112 $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
113 $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
114 $getreserv{'borrowername'} = $getborrower->{'surname'};
115 $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'};
116 $getreserv{'borrowermail'} = $getborrower->{'emailaddress'};
117 $getreserv{'borrowerphone'} = $getborrower->{'phone'};
118 push( @reservloop, \%getreserv );
122 # If we have a return of reservloop we put it in the branchloop sequence
124 $branchloop{'reserv'} = \@reservloop;
126 # else, we unset the value of the branchcode .
128 $branchloop{'branchcode'} = 0;
131 push( @branchesloop, \%branchloop ) if %branchloop;
135 branchesloop => \@branchesloop,
136 show_date => format_date($todaysdate)
139 output_html_with_http_headers $input, $cookie, $template->output;