X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=circ%2Ftransferstoreceive.pl;h=88f9aa607a4caa75d35257c145d4fee059b563ce;hb=a66c0b1dd76a2fe08ed7ac189ad8a564372ab3a9;hp=a0377260594f09ec9353d6c14c777accf6106715;hpb=a469663d7b0993894582759235c2475f662c8da4;p=koha.git diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index a037726059..88f9aa607a 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -5,27 +5,25 @@ # # 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., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use strict; use warnings; -use CGI; +use CGI qw ( -utf8 ); use C4::Context; use C4::Output; -use C4::Branch; # GetBranches use C4::Auth; -use C4::Dates qw/format_date/; use C4::Biblio; use C4::Circulation; use C4::Members; @@ -37,13 +35,19 @@ use Date::Calc qw( use C4::Koha; use C4::Reserves; +use Koha::Items; +use Koha::ItemTypes; +use Koha::Libraries; +use Koha::DateUtils; +use Koha::BiblioFrameworks; +use Koha::Patrons; my $input = new CGI; 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, @@ -56,18 +60,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; my $latetransfers; -foreach my $br ( keys %$branches ) { +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; @@ -86,27 +90,38 @@ foreach my $br ( keys %$branches ) { $getransf{'messcompa'} = 1; $getransf{'diff'} = $diff; } - my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} ); - my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $gettitle->{'itype'} : $gettitle->{'itemtype'} ); - $getransf{'datetransfer'} = format_date( $num->{'datesent'} ); - $getransf{'itemtype'} = $itemtypeinfo ->{'description'}; - foreach (qw(title author biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) { - $getransf{$_} = $gettitle->{$_}; - } - - my $record = GetMarcBiblio($gettitle->{'biblionumber'}); - $getransf{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($gettitle->{'biblionumber'})); + 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, + author => $biblio->author, + biblionumber => $biblio->biblionumber, + itemnumber => $item->itemnumber, + barcode => $item->barcode, + homebranch => $item->homebranch, + holdingbranch => $item->holdingbranch, + itemcallnumber => $item->itemcallnumber, + ); + + my $record = GetMarcBiblio($biblio->biblionumber); + $getransf{'subtitle'} = GetRecordValue('subtitle', $record, $biblio->frameworkcode); # 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'}; - $getransf{'borrowermail'} = $getborrower->{'emailaddress'} if $getborrower->{'emailaddress'}; - $getransf{'borrowerphone'} = $getborrower->{'phone'}; + my $holds = $item->current_holds; + if ( my $first_hold = $holds->next ) { + my $patron = Koha::Patrons->find( $first_hold->borrowernumber ); + # FIXME The full patron object should be passed to the template + $getransf{'borrowernum'} = $patron->borrowernumber; + $getransf{'borrowername'} = $patron->surname; + $getransf{'borrowerfirstname'} = $patron->firstname; + $getransf{'borrowermail'} = $patron->email if $patron->email; + $getransf{'borrowerphone'} = $patron->phone; } push( @transferloop, \%getransf ); } @@ -119,10 +134,13 @@ foreach my $br ( keys %$branches ) { $template->param( branchesloop => \@branchesloop, - show_date => format_date(C4::Dates->today('iso')), + show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 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;