added 440* and 490* 'series' indexes
[koha.git] / circ / transferstoreceive.pl
blob878425bbd91f59b46003546e692ca251d5896b09
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 CGI;
23 use C4::Context;
24 use C4::Output;
25 use C4::Branch;
26 use C4::Auth;
27 use C4::Dates qw/format_date/;
28 use C4::Biblio;
29 use C4::Circulation;
30 use C4::Members;
31 use Date::Calc qw(
32 Today
33 Add_Delta_Days
34 Date_to_Days
37 use C4::Koha;
38 use C4::Reserves;
40 my $input = new CGI;
42 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
43 my $itemnumber = $input->param('itemnumber');
46 # if we have a resturn of the form to delete the transfer, we launch the subrroutine
47 if ($itemnumber) {
48 C4::Circulation::Circ2::DeleteTransfer($itemnumber);
51 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
53 template_name => "circ/transferstoreceive.tmpl",
54 query => $input,
55 type => "intranet",
56 authnotrequired => 0,
57 flagsrequired => { circulate => 1 },
58 debug => 1,
62 # set the userenv branch
63 my $default = C4::Context->userenv->{'branch'};
65 # get the all the branches for reference
66 my $branches = GetBranches();
67 my @branchesloop;
68 foreach my $br ( keys %$branches ) {
69 my @transferloop;
70 my %branchloop;
71 my @gettransfers =
72 GetTransfersFromTo( $branches->{$br}->{'branchcode'}, $default );
74 if (@gettransfers) {
75 $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
76 $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
77 foreach my $num (@gettransfers) {
78 my %getransf;
80 my ( $sent_year, $sent_month, $sent_day ) = split "-",
81 $num->{'datesent'};
82 $sent_day = ( split " ", $sent_day )[0];
83 ( $sent_year, $sent_month, $sent_day ) =
84 Add_Delta_Days( $sent_year, $sent_month, $sent_day,
85 C4::Context->preference('TransfersMaxDaysWarning'));
86 my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day );
87 my $today = Date_to_Days(&Today);
88 my $warning = ( $today > $calcDate );
90 if ( $warning > 0 ) {
91 $getransf{'messcompa'} = 1;
93 my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} );
94 my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
96 $getransf{'datetransfer'} = format_date( $num->{'datesent'} );
97 $getransf{'itemtype'} = $itemtypeinfo->{'description'};
98 foreach (qw(title biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) {
99 $getransf{$_} = $gettitle->{$_};
102 # we check if we have a reserv for this transfer
103 my @checkreserv = GetReservesFromItemnumber($num->{'itemnumber'} );
104 if ( $checkreserv[0] ) {
105 my $getborrower =
106 GetMemberDetails( $checkreserv[1] );
107 $getransf{'borrowernum'} = $getborrower->{'borrowernumber'};
108 $getransf{'borrowername'} = $getborrower->{'surname'};
109 $getransf{'borrowerfirstname'} = $getborrower->{'firstname'};
110 if ( $getborrower->{'emailaddress'} ) {
111 $getransf{'borrowermail'} = $getborrower->{'emailaddress'};
113 $getransf{'borrowerphone'} = $getborrower->{'phone'};
116 push( @transferloop, \%getransf );
119 # If we have a return of reservloop we put it in the branchloop sequence
120 $branchloop{'reserv'} = \@transferloop;
122 push( @branchesloop, \%branchloop ) if %branchloop;
125 $template->param(
126 branchesloop => \@branchesloop,
127 show_date => format_date(join("-", &Today)),
130 output_html_with_http_headers $input, $cookie, $template->output;