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

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

Return to bug 13517