X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=circ%2Ftransferstoreceive.pl;h=86f799275c20e7609296f7fc65ad4a1e40561fe4;hb=a0c815033acd1ba514c2fa812e3e0dcc1858fcc9;hp=5ec5dac3f85b53d8edced640b2e1949556923162;hpb=9f42b8ad49fb17c4cbea4825639de7c4212f681c;p=koha_fer diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl old mode 100644 new mode 100755 index 5ec5dac3f8..86f799275c --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -1,6 +1,5 @@ #!/usr/bin/perl -# $Id$ # Copyright 2000-2002 Katipo Communications # @@ -15,21 +14,21 @@ # 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, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; +use warnings; use CGI; use C4::Context; use C4::Output; -use C4::Branch; +use C4::Branch; # GetBranches use C4::Auth; -use C4::Date; +use C4::Dates qw/format_date/; use C4::Biblio; use C4::Circulation; use C4::Members; -use C4::Interface::CGI::Output; use Date::Calc qw( Today Add_Delta_Days @@ -40,15 +39,7 @@ use C4::Koha; use C4::Reserves; my $input = new CGI; - -my $theme = $input->param('theme'); # only used if allowthemeoverride is set my $itemnumber = $input->param('itemnumber'); -my $todaysdate = join "-", &Today; - -# if we have a resturn of the form to delete the transfer, we launch the subrroutine -if ($itemnumber) { - C4::Circulation::Circ2::DeleteTransfer($itemnumber); -} my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -56,7 +47,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( query => $input, type => "intranet", authnotrequired => 0, - flagsrequired => { circulate => 1 }, + flagsrequired => { circulate => "circulate_remaining_permissions" }, debug => 1, } ); @@ -67,15 +58,16 @@ my $default = C4::Context->userenv->{'branch'}; # get the all the branches for reference my $branches = GetBranches(); my @branchesloop; +my $latetransfers; foreach my $br ( keys %$branches ) { my @transferloop; my %branchloop; - $branchloop{'branchname'} = $branches->{$br}->{'branchname'}; - $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'}; my @gettransfers = GetTransfersFromTo( $branches->{$br}->{'branchcode'}, $default ); if (@gettransfers) { + $branchloop{'branchname'} = $branches->{$br}->{'branchname'}; + $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'}; foreach my $num (@gettransfers) { my %getransf; @@ -87,37 +79,34 @@ 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'} ); + my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $gettitle->{'itype'} : $gettitle->{'itemtype'} ); - $getransf{'title'} = $gettitle->{'title'}; $getransf{'datetransfer'} = format_date( $num->{'datesent'} ); - $getransf{'biblionumber'} = $gettitle->{'biblionumber'}; - $getransf{'itemnumber'} = $gettitle->{'itemnumber'}; - $getransf{'barcode'} = $gettitle->{'barcode'}; - $getransf{'itemtype'} = $itemtypeinfo->{'description'}; - $getransf{'homebranch'} = $gettitle->{'homebranch'}; - $getransf{'holdingbranch'} = $gettitle->{'holdingbranch'}; - $getransf{'itemcallnumber'} = $gettitle->{'itemcallnumber'}; - - # we check if we have a reserv for this transfer - my @checkreserv = GetReservations( $num->{'itemnumber'} ); + $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'})); + + # 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'}; + 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'}; - + $getransf{'borrowermail'} = $getborrower->{'emailaddress'} if $getborrower->{'emailaddress'}; + $getransf{'borrowerphone'} = $getborrower->{'phone'}; } push( @transferloop, \%getransf ); } @@ -125,18 +114,15 @@ foreach my $br ( keys %$branches ) { # If we have a return of reservloop we put it in the branchloop sequence $branchloop{'reserv'} = \@transferloop; } - else { - -# if we don't have a retrun from reservestobranch we unset branchname and branchcode - $branchloop{'branchname'} = 0; - $branchloop{'branchcode'} = 0; - } - push( @branchesloop, \%branchloop ); + push( @branchesloop, \%branchloop ) if %branchloop; } $template->param( branchesloop => \@branchesloop, - show_date => format_date($todaysdate), + show_date => format_date(C4::Dates->today('iso')), + 'dateformat_' . (C4::Context->preference("dateformat") || '') => 1, + TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'), + latetransfers => $latetransfers ? 1 : 0, ); output_html_with_http_headers $input, $cookie, $template->output;