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

(-)a/C4/Reserves.pm (-36 lines)
Lines 104-110 BEGIN { Link Here
104
    @EXPORT = qw(
104
    @EXPORT = qw(
105
        &AddReserve
105
        &AddReserve
106
106
107
        &GetReservesForBranch
108
        &GetReserveStatus
107
        &GetReserveStatus
109
108
110
        &GetOtherReserves
109
        &GetOtherReserves
Lines 562-602 SELECT COUNT(*) FROM reserves WHERE biblionumber=? AND borrowernumber<>? Link Here
562
    return $fee;
561
    return $fee;
563
}
562
}
564
563
565
=head2 GetReservesForBranch
566
567
  @transreserv = GetReservesForBranch($frombranch);
568
569
=cut
570
571
sub GetReservesForBranch {
572
    my ($frombranch) = @_;
573
    my $dbh = C4::Context->dbh;
574
575
    my $query = "
576
        SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate, expirationdate
577
        FROM   reserves
578
        WHERE   priority='0'
579
        AND found='W'
580
    ";
581
    $query .= " AND branchcode=? " if ( $frombranch );
582
    $query .= "ORDER BY waitingdate" ;
583
584
    my $sth = $dbh->prepare($query);
585
    if ($frombranch){
586
     $sth->execute($frombranch);
587
    } else {
588
        $sth->execute();
589
    }
590
591
    my @transreserv;
592
    my $i = 0;
593
    while ( my $data = $sth->fetchrow_hashref ) {
594
        $transreserv[$i] = $data;
595
        $i++;
596
    }
597
    return (@transreserv);
598
}
599
600
=head2 GetReserveStatus
564
=head2 GetReserveStatus
601
565
602
  $reservestatus = GetReserveStatus($itemnumber);
566
  $reservestatus = GetReserveStatus($itemnumber);
(-)a/circ/waitingreserves.pl (-25 / +23 lines)
Lines 84-137 $template->param( all_branches => 1 ) if $all_branches; Link Here
84
84
85
my (@reservloop, @overloop);
85
my (@reservloop, @overloop);
86
my ($reservcount, $overcount);
86
my ($reservcount, $overcount);
87
my @getreserves = $all_branches ? GetReservesForBranch() : GetReservesForBranch($default);
87
# FIXME - Is priority => 0 useful? If yes it must be moved to waiting, otherwise we need to remove it from here.
88
my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : ( branchcode => $default ) ) }, { order_by => ['waitingdate'] });
88
# get reserves for the branch we are logged into, or for all branches
89
# get reserves for the branch we are logged into, or for all branches
89
90
90
my $today = Date_to_Days(&Today);
91
my $today = Date_to_Days(&Today);
91
my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay');
92
my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay');
92
93
93
foreach my $num (@getreserves) {
94
while ( my $hold = $holds->next ) {
94
    next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00');
95
    next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00');
95
96
96
    my $itemnumber = $num->{'itemnumber'};
97
    my $item = $hold->item;
97
    my $item = Koha::Items->find( $itemnumber );
98
    my $patron = $hold->borrower;
98
    my $biblio = $item->biblio;
99
    my $biblio = $item->biblio;
99
    my $borrowernum = $num->{'borrowernumber'};
100
    my $holdingbranch = $item->holdingbranch;
100
    my $holdingbranch = $item->holdingbranch;
101
    my $homebranch = $item->homebranch;
101
    my $homebranch = $item->homebranch;
102
102
103
    my %getreserv = (
103
    my %getreserv = (
104
        itemnumber => $itemnumber,
104
        title             => $biblio->title,
105
        borrowernum => $borrowernum,
105
        itemnumber        => $item->itemnumber,
106
        waitingdate       => $hold->waitingdate,
107
        borrowernum       => $patron->borrowernumber,
108
        biblionumber      => $biblio->biblionumber,
109
        barcode           => $item->barcode,
110
        homebranch        => $homebranch,
111
        holdingbranch     => $item->holdingbranch,
112
        itemcallnumber    => $item->itemcallnumber,
113
        enumchron         => $item->enumchron,
114
        copynumber        => $item->copynumber,
115
        borrowername      => $patron->surname, # FIXME Let's send $patron to the template
116
        borrowerfirstname => $patron->firstname,
117
        borrowerphone     => $patron->phone,
106
    );
118
    );
107
119
108
    my $patron = Koha::Patrons->find( $num->{borrowernumber} );
109
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
120
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
110
    $getreserv{'waitingdate'} = $num->{'waitingdate'};
121
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate);
111
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
112
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
122
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
113
123
114
    $getreserv{'itemtype'}       = $itemtype->description; # FIXME Should not it be translated_description?
124
    $getreserv{'itemtype'}       = $itemtype->description; # FIXME Should not it be translated_description?
115
    $getreserv{'title'}          = $biblio->title;
116
    $getreserv{'subtitle'}       = GetRecordValue(
125
    $getreserv{'subtitle'}       = GetRecordValue(
117
        'subtitle',
126
        'subtitle',
118
        GetMarcBiblio({ biblionumber => $biblio->biblionumber }),
127
        GetMarcBiblio({ biblionumber => $biblio->biblionumber }),
119
        $biblio->frameworkcode);
128
        $biblio->frameworkcode);
120
    $getreserv{'biblionumber'}   = $biblio->biblionumber;
121
    $getreserv{'barcode'}        = $item->barcode;
122
    $getreserv{'homebranch'}     = $homebranch;
123
    $getreserv{'holdingbranch'}  = $item->holdingbranch;
124
    $getreserv{'itemcallnumber'} = $item->itemcallnumber;
125
    $getreserv{'enumchron'}      = $item->enumchron;
126
    $getreserv{'copynumber'}     = $item->copynumber;
127
    if ( $homebranch ne $holdingbranch ) {
129
    if ( $homebranch ne $holdingbranch ) {
128
        $getreserv{'dotransfer'} = 1;
130
        $getreserv{'dotransfer'} = 1;
129
    }
131
    }
130
    $getreserv{'borrowername'}      = $patron->surname;
131
    $getreserv{'borrowerfirstname'} = $patron->firstname;
132
    $getreserv{'borrowerphone'}     = $patron->phone;
133
132
134
    my $borEmail = GetFirstValidEmailAddress( $borrowernum );
133
    my $borEmail = $patron->first_valid_email_address;
135
134
136
    if ( $borEmail ) {
135
    if ( $borEmail ) {
137
        $getreserv{'borrowermail'}  = $borEmail;
136
        $getreserv{'borrowermail'}  = $borEmail;
Lines 139-145 foreach my $num (@getreserves) { Link Here
139
138
140
    if ($today > $calcDate) {
139
    if ($today > $calcDate) {
141
        if ($cancelall) {
140
        if ($cancelall) {
142
            my $res = cancel( $itemnumber, $borrowernum, $holdingbranch, $homebranch, !$transfer_when_cancel_all );
141
            my $res = cancel( $item->itemnumber, $patron->borrowernumber, $holdingbranch, $homebranch, !$transfer_when_cancel_all );
143
            push @cancel_result, $res if $res;
142
            push @cancel_result, $res if $res;
144
            next;
143
            next;
145
        } else {
144
        } else {
146
- 

Return to bug 19299