X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=circ%2Ftransferstoreceive.pl;h=0116278145e782bd8274be01e188e93e60dee8eb;hb=0d7ba6e5201b16f7e7a2332af7204cb6416c289a;hp=c070a171eaa51973762f60481139535a72d8898f;hpb=c15e1206fdda1fa2fd366c5f38d23b0014ba4022;p=koha-ffzg.git diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index c070a171ea..0116278145 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -5,51 +5,45 @@ # # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . -use strict; -use CGI; +use Modern::Perl; +use CGI qw ( -utf8 ); use C4::Context; -use C4::Output; -use C4::Branch; -use C4::Auth; -use C4::Dates qw/format_date/; -use C4::Biblio; -use C4::Circulation; +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); +use C4::Circulation qw( GetTransfersFromTo ); use C4::Members; -use Date::Calc qw( - Today - Add_Delta_Days - Date_to_Days -); +use Date::Calc qw( Add_Delta_Days Date_to_Days Today ); -use C4::Koha; use C4::Reserves; - -my $input = new CGI; - -my $theme = $input->param('theme'); # only used if allowthemeoverride is set +use Koha::Items; +use Koha::ItemTypes; +use Koha::Libraries; +use Koha::DateUtils qw( dt_from_string ); +use Koha::BiblioFrameworks; +use Koha::Patrons; + +my $input = CGI->new; my $itemnumber = $input->param('itemnumber'); -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( { - template_name => "circ/transferstoreceive.tmpl", + template_name => "circ/transferstoreceive.tt", query => $input, type => "intranet", - authnotrequired => 0, flagsrequired => { circulate => "circulate_remaining_permissions" }, - debug => 1, } ); @@ -57,17 +51,18 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $default = C4::Context->userenv->{'branch'}; # get the all the branches for reference -my $branches = GetBranches(); +my $libraries = Koha::Libraries->search({}, { order_by => 'branchname' }); my @branchesloop; -foreach my $br ( keys %$branches ) { +my $latetransfers; +while ( my $library = $libraries->next ) { my @transferloop; my %branchloop; my @gettransfers = - GetTransfersFromTo( $branches->{$br}->{'branchcode'}, $default ); + GetTransfersFromTo( $library->branchcode, $default ); if (@gettransfers) { - $branchloop{'branchname'} = $branches->{$br}->{'branchname'}; - $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'}; + $branchloop{'branchname'} = $library->branchname; + $branchloop{'branchcode'} = $library->branchcode; foreach my $num (@gettransfers) { my %getransf; @@ -79,34 +74,50 @@ foreach my $br ( keys %$branches ) { C4::Context->preference('TransfersMaxDaysWarning')); my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day ); my $today = Date_to_Days(&Today); - my $warning = ( $today > $calcDate ); + my $diff = $today - $calcDate; - if ( $warning > 0 ) { + if ($today > $calcDate) { + $latetransfers = 1; $getransf{'messcompa'} = 1; + $getransf{'diff'} = $diff; } - my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} ); - my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} ); - - $getransf{'datetransfer'} = format_date( $num->{'datesent'} ); - $getransf{'itemtype'} = $itemtypeinfo->{'description'}; - foreach (qw(title biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) { - $getransf{$_} = $gettitle->{$_}; - } - - # we check if we have a reserv for this transfer - my @checkreserv = GetReservesFromItemnumber($num->{'itemnumber'} ); - if ( $checkreserv[0] ) { - my $getborrower = - GetMemberDetails( $checkreserv[1] ); - $getransf{'borrowernum'} = $getborrower->{'borrowernumber'}; - $getransf{'borrowername'} = $getborrower->{'surname'}; - $getransf{'borrowerfirstname'} = $getborrower->{'firstname'}; - if ( $getborrower->{'emailaddress'} ) { - $getransf{'borrowermail'} = $getborrower->{'emailaddress'}; - } - $getransf{'borrowerphone'} = $getborrower->{'phone'}; + my $item = Koha::Items->find( $num->{itemnumber} ); + my $biblio = $item->biblio; + my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); + + $getransf{'datetransfer'} = $num->{'datesent'}; + $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? + %getransf = ( + %getransf, + title => $biblio->title, + subtitle => $biblio->subtitle, + medium => $biblio->medium, + part_number => $biblio->part_number, + part_name => $biblio->part_name, + author => $biblio->author, + biblionumber => $biblio->biblionumber, + itemnumber => $item->itemnumber, + barcode => $item->barcode, + homebranch => $item->homebranch, + holdingbranch => $item->holdingbranch, + itemcallnumber => $item->itemcallnumber, + ); + + # we check if we have a reserv for this transfer + my $holds = $item->current_holds; + if ( my $first_hold = $holds->next ) { + $getransf{patron} = Koha::Patrons->find( $first_hold->borrowernumber ); } + + # check for a recall for this transfer + if ( C4::Context->preference('UseRecalls') ) { + my $recall = $item->recall; + if ( defined $recall ) { + $getransf{recall} = $recall; + } + } + push( @transferloop, \%getransf ); } @@ -118,9 +129,13 @@ foreach my $br ( keys %$branches ) { $template->param( branchesloop => \@branchesloop, - show_date => format_date(C4::Dates->today('iso')), - dateformat => C4::Context->preference("dateformat"), + show_date => dt_from_string, + TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'), + latetransfers => $latetransfers ? 1 : 0, ); +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + output_html_with_http_headers $input, $cookie, $template->output;