View | Details | Raw Unified | Return to bug 13517
Collapse All | Expand All

(-)a/Koha/Hold.pm (-2 / +45 lines)
Lines 22-31 use Modern::Perl; Link Here
22
use Carp;
22
use Carp;
23
23
24
use C4::Context qw(preference);
24
use C4::Context qw(preference);
25
use Koha::Branches;
25
use Koha::DateUtils qw(dt_from_string);
26
27
use Koha::Borrowers;
26
use Koha::Biblios;
28
use Koha::Biblios;
29
use Koha::Branches;
27
use Koha::Items;
30
use Koha::Items;
28
use Koha::DateUtils qw(dt_from_string);
29
31
30
use base qw(Koha::Object);
32
use base qw(Koha::Object);
31
33
Lines 63-68 sub waiting_expires_on { Link Here
63
    return $dt;
65
    return $dt;
64
}
66
}
65
67
68
=head3 is_found
69
70
Returns true if hold is a waiting or in transit
71
72
=cut
73
74
sub is_found {
75
    my ($self) = @_;
76
77
    return 0 unless $self->found();
78
    return 1 if $self->found() eq 'W';
79
    return 1 if $self->found() eq 'T';
80
}
81
66
=head3 is_waiting
82
=head3 is_waiting
67
83
68
Returns true if hold is a waiting hold
84
Returns true if hold is a waiting hold
Lines 76-81 sub is_waiting { Link Here
76
    return $found && $found eq 'W';
92
    return $found && $found eq 'W';
77
}
93
}
78
94
95
=head3 is_in_transit
96
97
Returns true if hold is a in_transit hold
98
99
=cut
100
101
sub is_in_transit {
102
    my ($self) = @_;
103
104
    return 0 unless $self->found();
105
    return $self->found() eq 'T';
106
}
107
79
=head3 biblio
108
=head3 biblio
80
109
81
Returns the related Koha::Biblio object for this hold
110
Returns the related Koha::Biblio object for this hold
Lines 118-123 sub branch { Link Here
118
    return $self->{_branch};
147
    return $self->{_branch};
119
}
148
}
120
149
150
=head3 borrower
151
152
Returns the related Koha::Borrower object for this Hold
153
154
=cut
155
156
sub borrower {
157
    my ($self) = @_;
158
159
    $self->{_borrower} ||= Koha::Borrowers->find( $self->borrowernumber() );
160
161
    return $self->{_borrower};
162
}
163
121
=head3 type
164
=head3 type
122
165
123
=cut
166
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-2 / +8 lines)
Lines 741-752 function checkMultiHold() { Link Here
741
        </td>
741
        </td>
742
        <td>[% reserveloo.notes %]</td>
742
        <td>[% reserveloo.notes %]</td>
743
        <td>[% reserveloo.date %]</td>
743
        <td>[% reserveloo.date %]</td>
744
	<td>[% reserveloo.expirationdate %]</td>
744
        <td>
745
            [% IF reserveloo.waiting_until %]
746
                [% reserveloo.waiting_until | $KohaDates %]
747
            [% ELSE %]
748
                [% reserveloo.expirationdate %]
749
            [% END %]
750
        </td>
745
        <td>
751
        <td>
746
    [% IF ( reserveloo.wait ) %]
752
    [% IF ( reserveloo.wait ) %]
747
    	[% IF ( reserveloo.atdestination ) %]
753
    	[% IF ( reserveloo.atdestination ) %]
748
            [% IF ( reserveloo.found ) %]
754
            [% IF ( reserveloo.found ) %]
749
                Item waiting at <b> [% reserveloo.wbrname %]</b> <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" />
755
                Item waiting at <b> [% reserveloo.wbrname %]</b> <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" /> since [% reserveloo.waiting_date | $KohaDates %]
750
            [% ELSE %]
756
            [% ELSE %]
751
                Waiting to be pulled <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" />
757
                Waiting to be pulled <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" />
752
            [% END %]
758
            [% END %]
(-)a/reserve/request.pl (-60 / +65 lines)
Lines 45-50 use C4::Members; Link Here
45
use C4::Search;		# enabled_staff_search_views
45
use C4::Search;		# enabled_staff_search_views
46
use Koha::DateUtils;
46
use Koha::DateUtils;
47
use Koha::Borrower::Debarments qw(IsDebarred);
47
use Koha::Borrower::Debarments qw(IsDebarred);
48
use Koha::Holds;
48
49
49
my $dbh = C4::Context->dbh;
50
my $dbh = C4::Context->dbh;
50
my $sth;
51
my $sth;
Lines 465-549 foreach my $biblionumber (@biblionumbers) { Link Here
465
466
466
    # existingreserves building
467
    # existingreserves building
467
    my @reserveloop;
468
    my @reserveloop;
468
    $reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
469
    my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } );
469
    foreach my $res ( sort {
470
    foreach my $res (
470
            my $a_found = $a->{found} || '';
471
        sort {
471
            my $b_found = $a->{found} || '';
472
            my $a_found = $a->found() || '';
473
            my $b_found = $a->found() || '';
472
            $a_found cmp $b_found;
474
            $a_found cmp $b_found;
473
        } @$reserves ) {
475
        } @reserves
476
      )
477
    {
474
        my %reserve;
478
        my %reserve;
475
        my @optionloop;
479
        my @optionloop;
476
        for ( my $i = 1 ; $i <= $totalcount ; $i++ ) {
480
        for ( my $i = 1 ; $i <= $totalcount ; $i++ ) {
477
            push(
481
            push(
478
                 @optionloop,
482
                @optionloop,
479
                 {
483
                {
480
                  num      => $i,
484
                    num      => $i,
481
                  selected => ( $i == $res->{priority} ),
485
                    selected => ( $i == $res->priority() ),
482
                 }
486
                }
483
                );
487
            );
484
        }
488
        }
485
489
486
        if ( defined $res->{'found'} && ($res->{'found'} eq 'W' || $res->{'found'} eq 'T' )) {
490
        if ( $res->is_found() ) {
487
            my $item = $res->{'itemnumber'};
491
            $reserve{'wait'}          = 1;
488
            $item = GetBiblioFromItemNumber($item,undef);
492
            $reserve{'holdingbranch'} = $res->item()->holdingbranch();
489
            $reserve{'wait'}= 1;
493
            $reserve{'biblionumber'}  = $res->item()->biblionumber();
490
            $reserve{'holdingbranch'}=$item->{'holdingbranch'};
494
            $reserve{'barcodenumber'} = $res->item()->barcode();
491
            $reserve{'biblionumber'}=$item->{'biblionumber'};
495
            $reserve{'wbrcode'}       = $res->branchcode();
492
            $reserve{'barcodenumber'}   = $item->{'barcode'};
496
            $reserve{'itemnumber'}    = $res->itemnumber();
493
            $reserve{'wbrcode'} = $res->{'branchcode'};
497
            $reserve{'wbrname'}       = $res->branch()->branchname();
494
            $reserve{'itemnumber'}  = $res->{'itemnumber'};
498
495
            $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
499
            if ( $reserve{'holdingbranch'} eq $reserve{'wbrcode'} ) {
496
            if($reserve{'holdingbranch'} eq $reserve{'wbrcode'}){
500
497
                # Just because the holdingbranch matches the reserve branch doesn't mean the item
501
                # Just because the holdingbranch matches the reserve branch doesn't mean the item
498
                # has arrived at the destination, check for an open transfer for the item as well
502
                # has arrived at the destination, check for an open transfer for the item as well
499
                my ( $transfertwhen, $transfertfrom, $transferto ) = C4::Circulation::GetTransfers( $res->{itemnumber} );
503
                my ( $transfertwhen, $transfertfrom, $transferto ) =
500
                if ( not $transferto or $transferto ne $res->{branchcode} ) {
504
                  C4::Circulation::GetTransfers( $res->itemnumber() );
505
                if ( not $transferto or $transferto ne $res->branchcode() ) {
501
                    $reserve{'atdestination'} = 1;
506
                    $reserve{'atdestination'} = 1;
502
                }
507
                }
503
            }
508
            }
509
504
            # set found to 1 if reserve is waiting for patron pickup
510
            # set found to 1 if reserve is waiting for patron pickup
505
            $reserve{'found'} = 1 if $res->{'found'} eq 'W';
511
            $reserve{'found'}     = $res->is_found();
506
            $reserve{'intransit'} = 1 if $res->{'found'} eq 'T';
512
            $reserve{'intransit'} = $res->is_in_transit();
507
        } elsif ($res->{priority} > 0) {
513
        }
508
            if (defined($res->{itemnumber})) {
514
        elsif ( $res->priority() > 0 ) {
509
                my $item = GetItem($res->{itemnumber});
515
            if ( my $item = $res->item() )  {
510
                $reserve{'itemnumber'}  = $res->{'itemnumber'};
516
                $reserve{'itemnumber'}      = $item->id();
511
                $reserve{'barcodenumber'}   = $item->{'barcode'};
517
                $reserve{'barcodenumber'}   = $item->barcode();
512
                $reserve{'item_level_hold'} = 1;
518
                $reserve{'item_level_hold'} = 1;
513
            }
519
            }
514
        }
520
        }
515
521
516
        #     get borrowers reserve info
522
        #     get borrowers reserve info
517
        my $reserveborrowerinfo = GetMember( borrowernumber => $res->{'borrowernumber'} );
523
        if ( C4::Context->preference('HidePatronName') ) {
518
        if (C4::Context->preference('HidePatronName')){
524
            $reserve{'hidename'}   = 1;
519
	    $reserve{'hidename'} = 1;
525
            $reserve{'cardnumber'} = $res->borrower()->cardnumber();
520
	    $reserve{'cardnumber'} = $reserveborrowerinfo->{'cardnumber'};
526
        }
521
	}
527
        $reserve{'expirationdate'} = output_pref( { dt => dt_from_string( $res->expirationdate ), dateonly => 1 } )
522
        $reserve{'expirationdate'} = output_pref({ dt => dt_from_string( $res->{'expirationdate'} ), dateonly => 1 })
528
          unless ( !defined( $res->expirationdate ) || $res->expirationdate eq '0000-00-00' );
523
            unless ( !defined($res->{'expirationdate'}) || $res->{'expirationdate'} eq '0000-00-00' );
529
        $reserve{'date'}           = output_pref( { dt => dt_from_string( $res->reservedate ), dateonly => 1 } );
524
        $reserve{'date'}           = output_pref({ dt => dt_from_string( $res->{'reservedate'} ), dateonly => 1 });
530
        $reserve{'borrowernumber'} = $res->borrowernumber();
525
        $reserve{'borrowernumber'} = $res->{'borrowernumber'};
531
        $reserve{'biblionumber'}   = $res->biblionumber();
526
        $reserve{'biblionumber'}   = $res->{'biblionumber'};
532
        $reserve{'borrowernumber'} = $res->borrowernumber();
527
        $reserve{'borrowernumber'} = $res->{'borrowernumber'};
533
        $reserve{'firstname'}      = $res->borrower()->firstname();
528
        $reserve{'firstname'}      = $reserveborrowerinfo->{'firstname'};
534
        $reserve{'surname'}        = $res->borrower()->surname();
529
        $reserve{'surname'}        = $reserveborrowerinfo->{'surname'};
535
        $reserve{'notes'}          = $res->reservenotes();
530
        $reserve{'notes'}          = $res->{'reservenotes'};
536
        $reserve{'wait'}           = $res->is_waiting();
531
        $reserve{'wait'}           =
537
        $reserve{'waiting_date'}   = $res->waitingdate();
532
          ( ( defined $res->{'found'} and $res->{'found'} eq 'W' ) or ( $res->{'priority'} eq '0' ) );
538
        $reserve{'waiting_until'}  = $res->is_waiting() ? $res->waiting_expires_on() : undef;
533
        $reserve{'voldesc'}         = $res->{'volumeddesc'};
539
        $reserve{'ccode'}          = $res->item() ? $res->item()->ccode() : undef;
534
        $reserve{'ccode'}           = $res->{'ccode'};
540
        $reserve{'barcode'}        = $res->item() ? $res->item()->barcode() : undef;
535
        $reserve{'barcode'}         = $res->{'barcode'};
541
        $reserve{'priority'}       = $res->priority();
536
        $reserve{'priority'}    = $res->{'priority'};
542
        $reserve{'lowestPriority'} = $res->lowestPriority();
537
        $reserve{'lowestPriority'}    = $res->{'lowestPriority'};
543
        $reserve{'optionloop'}     = \@optionloop;
538
        $reserve{'optionloop'} = \@optionloop;
544
        $reserve{'suspend'}        = $res->suspend();
539
        $reserve{'suspend'} = $res->{'suspend'};
545
        $reserve{'suspend_until'}  = $res->suspend_until();
540
        $reserve{'suspend_until'} = $res->{'suspend_until'};
546
        $reserve{'reserve_id'}     = $res->reserve_id();
541
        $reserve{'reserve_id'} = $res->{'reserve_id'};
542
547
543
        if ( C4::Context->preference('IndependentBranches') && $flags->{'superlibrarian'} != 1 ) {
548
        if ( C4::Context->preference('IndependentBranches') && $flags->{'superlibrarian'} != 1 ) {
544
              $reserve{'branchloop'} = [ GetBranchDetail($res->{'branchcode'}) ];
549
            $reserve{'branchloop'} = [ GetBranchDetail( $res->branchcode() ) ];
545
        } else {
550
        }
546
              $reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'});
551
        else {
552
            $reserve{'branchloop'} = GetBranchesLoop( $res->branchcode() );
547
        }
553
        }
548
554
549
        push( @reserveloop, \%reserve );
555
        push( @reserveloop, \%reserve );
550
- 

Return to bug 13517