The current searching in labels is a bit minimal, and current only does keyword searc...
[koha.git] / circ / transferstoreceive.pl
blobc070a171eaa51973762f60481139535a72d8898f
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');
45 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
47 template_name => "circ/transferstoreceive.tmpl",
48 query => $input,
49 type => "intranet",
50 authnotrequired => 0,
51 flagsrequired => { circulate => "circulate_remaining_permissions" },
52 debug => 1,
56 # set the userenv branch
57 my $default = C4::Context->userenv->{'branch'};
59 # get the all the branches for reference
60 my $branches = GetBranches();
61 my @branchesloop;
62 foreach my $br ( keys %$branches ) {
63 my @transferloop;
64 my %branchloop;
65 my @gettransfers =
66 GetTransfersFromTo( $branches->{$br}->{'branchcode'}, $default );
68 if (@gettransfers) {
69 $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
70 $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
71 foreach my $num (@gettransfers) {
72 my %getransf;
74 my ( $sent_year, $sent_month, $sent_day ) = split "-",
75 $num->{'datesent'};
76 $sent_day = ( split " ", $sent_day )[0];
77 ( $sent_year, $sent_month, $sent_day ) =
78 Add_Delta_Days( $sent_year, $sent_month, $sent_day,
79 C4::Context->preference('TransfersMaxDaysWarning'));
80 my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day );
81 my $today = Date_to_Days(&Today);
82 my $warning = ( $today > $calcDate );
84 if ( $warning > 0 ) {
85 $getransf{'messcompa'} = 1;
87 my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} );
88 my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
90 $getransf{'datetransfer'} = format_date( $num->{'datesent'} );
91 $getransf{'itemtype'} = $itemtypeinfo->{'description'};
92 foreach (qw(title biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) {
93 $getransf{$_} = $gettitle->{$_};
96 # we check if we have a reserv for this transfer
97 my @checkreserv = GetReservesFromItemnumber($num->{'itemnumber'} );
98 if ( $checkreserv[0] ) {
99 my $getborrower =
100 GetMemberDetails( $checkreserv[1] );
101 $getransf{'borrowernum'} = $getborrower->{'borrowernumber'};
102 $getransf{'borrowername'} = $getborrower->{'surname'};
103 $getransf{'borrowerfirstname'} = $getborrower->{'firstname'};
104 if ( $getborrower->{'emailaddress'} ) {
105 $getransf{'borrowermail'} = $getborrower->{'emailaddress'};
107 $getransf{'borrowerphone'} = $getborrower->{'phone'};
110 push( @transferloop, \%getransf );
113 # If we have a return of reservloop we put it in the branchloop sequence
114 $branchloop{'reserv'} = \@transferloop;
116 push( @branchesloop, \%branchloop ) if %branchloop;
119 $template->param(
120 branchesloop => \@branchesloop,
121 show_date => format_date(C4::Dates->today('iso')),
122 dateformat => C4::Context->preference("dateformat"),
125 output_html_with_http_headers $input, $cookie, $template->output;