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/Objects.pm (-1 / +3 lines)
Lines 84-90 sub find { Link Here
84
84
85
    my $result = $self->_resultset()->find($id);
85
    my $result = $self->_resultset()->find($id);
86
86
87
    my $object = $self->object_class()->_new_from_dbic( $result );
87
    my $object;
88
    eval { $object = $self->object_class()->_new_from_dbic( $result ) };
89
    confess $@ if $@;
88
90
89
    return $object;
91
    return $object;
90
}
92
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-2 / +8 lines)
Lines 674-685 function checkMultiHold() { Link Here
674
        </td>
674
        </td>
675
        <td>[% reserveloo.notes %]</td>
675
        <td>[% reserveloo.notes %]</td>
676
        <td>[% reserveloo.date %]</td>
676
        <td>[% reserveloo.date %]</td>
677
	<td>[% reserveloo.expirationdate %]</td>
677
        <td>
678
            [% IF reserveloo.waiting_until %]
679
                [% reserveloo.waiting_until | $KohaDates %]
680
            [% ELSE %]
681
                [% reserveloo.expirationdate %]
682
            [% END %]
683
        </td>
678
        <td>
684
        <td>
679
    [% IF ( reserveloo.wait ) %]
685
    [% IF ( reserveloo.wait ) %]
680
    	[% IF ( reserveloo.atdestination ) %]
686
    	[% IF ( reserveloo.atdestination ) %]
681
            [% IF ( reserveloo.found ) %]
687
            [% IF ( reserveloo.found ) %]
682
                Item waiting at <b> [% reserveloo.wbrname %]</b> <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" />
688
                Item waiting at <b> [% reserveloo.wbrname %]</b> <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" /> since [% reserveloo.waiting_date | $KohaDates %]
683
            [% ELSE %]
689
            [% ELSE %]
684
                Waiting to be pulled <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" />
690
                Waiting to be pulled <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" />
685
            [% END %]
691
            [% END %]
(-)a/reserve/request.pl (-62 / +67 lines)
Lines 43-48 use C4::Dates qw/format_date/; Link Here
43
use C4::Members;
43
use C4::Members;
44
use C4::Search;		# enabled_staff_search_views
44
use C4::Search;		# enabled_staff_search_views
45
use Koha::DateUtils;
45
use Koha::DateUtils;
46
use Koha::Holds;
46
47
47
my $dbh = C4::Context->dbh;
48
my $dbh = C4::Context->dbh;
48
my $sth;
49
my $sth;
Lines 463-549 foreach my $biblionumber (@biblionumbers) { Link Here
463
464
464
    # existingreserves building
465
    # existingreserves building
465
    my @reserveloop;
466
    my @reserveloop;
466
    $reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
467
    my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } );
467
    foreach my $res ( sort {
468
    foreach my $res (
468
            my $a_found = $a->{found} || '';
469
        sort {
469
            my $b_found = $a->{found} || '';
470
            my $a_found = $a->found() || '';
471
            my $b_found = $a->found() || '';
470
            $a_found cmp $b_found;
472
            $a_found cmp $b_found;
471
        } @$reserves ) {
473
        } @reserves
474
      )
475
    {
472
        my %reserve;
476
        my %reserve;
473
        my @optionloop;
477
        my @optionloop;
474
        for ( my $i = 1 ; $i <= $totalcount ; $i++ ) {
478
        for ( my $i = 1 ; $i <= $totalcount ; $i++ ) {
475
            push(
479
            push(
476
                 @optionloop,
480
                @optionloop,
477
                 {
481
                {
478
                  num      => $i,
482
                    num      => $i,
479
                  selected => ( $i == $res->{priority} ),
483
                    selected => ( $i == $res->priority() ),
480
                 }
484
                }
481
                );
485
            );
482
        }
486
        }
483
487
484
        if ( defined $res->{'found'} && ($res->{'found'} eq 'W' || $res->{'found'} eq 'T' )) {
488
        if ( $res->is_found() ) {
485
            my $item = $res->{'itemnumber'};
489
            $reserve{'wait'}          = 1;
486
            $item = GetBiblioFromItemNumber($item,undef);
490
            $reserve{'holdingbranch'} = $res->item()->holdingbranch();
487
            $reserve{'wait'}= 1;
491
            $reserve{'biblionumber'}  = $res->item()->biblionumber();
488
            $reserve{'holdingbranch'}=$item->{'holdingbranch'};
492
            $reserve{'barcodenumber'} = $res->item()->barcode();
489
            $reserve{'biblionumber'}=$item->{'biblionumber'};
493
            $reserve{'wbrcode'}       = $res->branchcode();
490
            $reserve{'barcodenumber'}   = $item->{'barcode'};
494
            $reserve{'itemnumber'}    = $res->itemnumber();
491
            $reserve{'wbrcode'} = $res->{'branchcode'};
495
            $reserve{'wbrname'}       = $res->branch()->branchname();
492
            $reserve{'itemnumber'}  = $res->{'itemnumber'};
496
493
            $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
497
            if ( $reserve{'holdingbranch'} eq $reserve{'wbrcode'} ) {
494
            if($reserve{'holdingbranch'} eq $reserve{'wbrcode'}){
498
495
                # Just because the holdingbranch matches the reserve branch doesn't mean the item
499
                # Just because the holdingbranch matches the reserve branch doesn't mean the item
496
                # has arrived at the destination, check for an open transfer for the item as well
500
                # has arrived at the destination, check for an open transfer for the item as well
497
                my ( $transfertwhen, $transfertfrom, $transferto ) = C4::Circulation::GetTransfers( $res->{itemnumber} );
501
                my ( $transfertwhen, $transfertfrom, $transferto ) =
498
                if ( not $transferto or $transferto ne $res->{branchcode} ) {
502
                  C4::Circulation::GetTransfers( $res->itemnumber() );
503
                if ( not $transferto or $transferto ne $res->branchcode() ) {
499
                    $reserve{'atdestination'} = 1;
504
                    $reserve{'atdestination'} = 1;
500
                }
505
                }
501
            }
506
            }
507
502
            # set found to 1 if reserve is waiting for patron pickup
508
            # set found to 1 if reserve is waiting for patron pickup
503
            $reserve{'found'} = 1 if $res->{'found'} eq 'W';
509
            $reserve{'found'}     = $res->is_found();
504
            $reserve{'intransit'} = 1 if $res->{'found'} eq 'T';
510
            $reserve{'intransit'} = $res->is_in_transit();
505
        } elsif ($res->{priority} > 0) {
511
        }
506
            if (defined($res->{itemnumber})) {
512
        elsif ( $res->priority() > 0 ) {
507
                my $item = GetItem($res->{itemnumber});
513
            if ( my $item = $res->item() )  {
508
                $reserve{'itemnumber'}  = $res->{'itemnumber'};
514
                $reserve{'itemnumber'}      = $item->id();
509
                $reserve{'barcodenumber'}   = $item->{'barcode'};
515
                $reserve{'barcodenumber'}   = $item->barcode();
510
                $reserve{'item_level_hold'} = 1;
516
                $reserve{'item_level_hold'} = 1;
511
            }
517
            }
512
        }
518
        }
513
519
514
        #     get borrowers reserve info
520
        #     get borrowers reserve info
515
        my $reserveborrowerinfo = GetMember( borrowernumber => $res->{'borrowernumber'} );
521
        if ( C4::Context->preference('HidePatronName') ) {
516
        if (C4::Context->preference('HidePatronName')){
522
            $reserve{'hidename'}   = 1;
517
	    $reserve{'hidename'} = 1;
523
            $reserve{'cardnumber'} = $res->borrower()->cardnumber();
518
	    $reserve{'cardnumber'} = $reserveborrowerinfo->{'cardnumber'};
524
        }
519
	}
525
        $reserve{'expirationdate'} = format_date( $res-expirationdate() )
520
        $reserve{'expirationdate'} = format_date( $res->{'expirationdate'} )
526
          unless ( !defined( $res->expirationdate() ) || $res->expirationdate() eq '0000-00-00' );
521
            unless ( !defined($res->{'expirationdate'}) || $res->{'expirationdate'} eq '0000-00-00' );
527
        $reserve{'date'}           = format_date( $res->reservedate() );
522
        $reserve{'date'}           = format_date( $res->{'reservedate'} );
528
        $reserve{'borrowernumber'} = $res->borrowernumber();
523
        $reserve{'borrowernumber'} = $res->{'borrowernumber'};
529
        $reserve{'biblionumber'}   = $res->biblionumber();
524
        $reserve{'biblionumber'}   = $res->{'biblionumber'};
530
        $reserve{'borrowernumber'} = $res->borrowernumber();
525
        $reserve{'borrowernumber'} = $res->{'borrowernumber'};
531
        $reserve{'firstname'}      = $res->borrower()->firstname();
526
        $reserve{'firstname'}      = $reserveborrowerinfo->{'firstname'};
532
        $reserve{'surname'}        = $res->borrower()->surname();
527
        $reserve{'surname'}        = $reserveborrowerinfo->{'surname'};
533
        $reserve{'notes'}          = $res->reservenotes();
528
        $reserve{'notes'}          = $res->{'reservenotes'};
534
        $reserve{'wait'}           = $res->is_waiting();
529
        $reserve{'wait'}           =
535
        $reserve{'waiting_date'}   = $res->waitingdate();
530
          ( ( defined $res->{'found'} and $res->{'found'} eq 'W' ) or ( $res->{'priority'} eq '0' ) );
536
        $reserve{'waiting_until'}  = $res->is_waiting() ? $res->waiting_expires_on() : undef;
531
        $reserve{'constrainttypea'} = ( $res->{'constrainttype'} eq 'a' );
537
        $reserve{'constrainttypea'} = ( $res->constrainttype() eq 'a' );
532
        $reserve{'constrainttypeo'} = ( $res->{'constrainttype'} eq 'o' );
538
        $reserve{'constrainttypeo'} = ( $res->constrainttype() eq 'o' );
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