added 440* and 490* 'series' indexes
[koha.git] / circ / transferstodo.pl
blob18466ab16a0964cea5888bc50fc3d77206272302
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 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
11 # version.
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
21 use strict;
22 use C4::Context;
23 use C4::Output;
24 use CGI;
25 use C4::Branch; # GetBranches
26 use C4::Auth;
27 use C4::Dates qw/format_date/;
28 use C4::Circulation;
29 use C4::Reserves;
30 use C4::Members;
31 use Date::Calc qw(
32 Today
33 Add_Delta_Days
34 Date_to_Days
36 use C4::Koha;
37 use C4::Biblio;
38 use C4::Items;
40 my $input = new CGI;
42 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
44 template_name => "circ/transferstodo.tmpl",
45 query => $input,
46 type => "intranet",
47 authnotrequired => 0,
48 flagsrequired => { circulate => 1 },
49 debug => 1,
53 # set the userenv branch
54 my $default = C4::Context->userenv->{'branch'};
56 my @datearr = localtime( time() );
57 my $todaysdate =
58 ( 1900 + $datearr[5] ) . '-'
59 . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
60 . sprintf( "%0.2d", $datearr[3] );
62 my $item = $input->param('itemnumber');
63 my $fbr = $input->param('fbr');
64 my $tbr = $input->param('tbr');
66 # If we have a return of the form dotransfer, we launch the subroutine dotransfer
67 if ($item) {
68 C4::Circulation::Circ2::ModItemTransfer( $item, $fbr, $tbr );
71 # get the all the branches for reference
72 my $branches = GetBranches();
74 my @branchesloop;
75 foreach my $br ( keys %$branches ) {
76 my @reservloop;
77 my %branchloop;
78 my @getreserves =
79 GetReservesToBranch( $branches->{$br}->{'branchcode'} );
80 if (@getreserves) {
81 $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
82 $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
83 foreach my $num (@getreserves) {
84 my %getreserv;
85 my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} );
86 # use Data::Dumper;
87 # warn Dumper($gettitle);
88 my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
89 if ( $gettitle->{'holdingbranch'} eq $default ) {
90 my $getborrower =
91 GetMemberDetails( $num->{'borrowernumber'} );
92 $getreserv{'reservedate'} =
93 format_date( $num->{'reservedate'} );
94 my ( $reserve_year, $reserve_month, $reserve_day ) = split /-/,
95 $num->{'reservedate'};
96 ( $reserve_year, $reserve_month, $reserve_day ) =
97 Add_Delta_Days( $reserve_year, $reserve_month, $reserve_day,
98 C4::Context->preference('ReservesMaxPickUpDelay'));
99 my $calcDate =
100 Date_to_Days( $reserve_year, $reserve_month, $reserve_day );
101 my $today = Date_to_Days(&Today);
102 my $warning = ( $today > $calcDate );
104 if ( $warning > 0 ) {
105 $getreserv{'messcompa'} = 1;
107 $getreserv{'title'} = $gettitle->{'title'};
108 $getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
109 $getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
110 $getreserv{'barcode'} = $gettitle->{'barcode'};
111 $getreserv{'itemtype'} = $itemtypeinfo->{'description'};
112 $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
113 $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
114 $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
115 $getreserv{'borrowername'} = $getborrower->{'surname'};
116 $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'};
117 $getreserv{'borrowermail'} = $getborrower->{'emailaddress'};
118 $getreserv{'borrowerphone'} = $getborrower->{'phone'};
119 push( @reservloop, \%getreserv );
123 # If we have a return of reservloop we put it in the branchloop sequence
124 if (@reservloop) {
125 $branchloop{'reserv'} = \@reservloop;
127 # else, we unset the value of the branchcode .
128 else {
129 $branchloop{'branchcode'} = 0;
132 push( @branchesloop, \%branchloop ) if %branchloop;
135 $template->param(
136 branchesloop => \@branchesloop,
137 show_date => format_date($todaysdate)
140 output_html_with_http_headers $input, $cookie, $template->output;