X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;ds=sidebyside;f=circ%2Ftransferstoreceive.pl;h=939891211ddcd15fbceaa9ac729f43007d4eecb7;hb=a0a72c9653e546155bca210605ac9cabb74de09c;hp=b3698223752b01754114e1be4a70ead2e75f5fb7;hpb=2fbaac98da391f029c920b4e7656ff0e09c3ae75;p=srvgit diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index b369822375..939891211d 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -18,37 +18,32 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . -use strict; -use warnings; +use Modern::Perl; use CGI qw ( -utf8 ); use C4::Context; -use C4::Output; -use C4::Branch; # GetBranches -use C4::Auth; -use Koha::DateUtils; -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( GetTransfers 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; +use Koha::Items; +use Koha::ItemTypes; +use Koha::Libraries; +use Koha::DateUtils qw( dt_from_string output_pref ); +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.tt", query => $input, type => "intranet", - authnotrequired => 0, flagsrequired => { circulate => "circulate_remaining_permissions" }, - debug => 1, } ); @@ -56,18 +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; 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,28 +81,43 @@ 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'} = $num->{'datesent'}; - $getransf{'itemtype'} = $itemtypeinfo ->{'description'}; - foreach (qw(title author biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) { - $getransf{$_} = $gettitle->{$_}; - } + my $item = Koha::Items->find( $num->{itemnumber} ); + my $biblio = $item->biblio; + my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); - my $record = GetMarcBiblio($gettitle->{'biblionumber'}); - $getransf{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($gettitle->{'biblionumber'})); + $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 @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->{'email'} if $getborrower->{'email'}; - $getransf{'borrowerphone'} = $getborrower->{'phone'}; + 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 ); } @@ -120,9 +130,12 @@ foreach my $br ( keys %$branches ) { $template->param( branchesloop => \@branchesloop, show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), - TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'), - latetransfers => $latetransfers ? 1 : 0, + 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;