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

(-)a/C4/Reserves.pm (-42 / +18 lines)
Lines 40-45 use Koha::DateUtils; Link Here
40
use Koha::Calendar;
40
use Koha::Calendar;
41
use Koha::Database;
41
use Koha::Database;
42
use Koha::Hold;
42
use Koha::Hold;
43
use Koha::Old::Hold;
43
use Koha::Holds;
44
use Koha::Holds;
44
use Koha::Libraries;
45
use Koha::Libraries;
45
use Koha::Items;
46
use Koha::Items;
Lines 1228-1283 whose keys are fields from the reserves table in the Koha database. Link Here
1228
1229
1229
sub ModReserveFill {
1230
sub ModReserveFill {
1230
    my ($res) = @_;
1231
    my ($res) = @_;
1231
    my $dbh = C4::Context->dbh;
1232
    # fill in a reserve record....
1233
    my $reserve_id = $res->{'reserve_id'};
1232
    my $reserve_id = $res->{'reserve_id'};
1234
    my $biblionumber = $res->{'biblionumber'};
1233
1235
    my $borrowernumber    = $res->{'borrowernumber'};
1234
    my $dbh = C4::Context->dbh;
1236
    my $resdate = $res->{'reservedate'};
1235
1236
    my $hold = Koha::Holds->find($reserve_id);
1237
1237
1238
    # get the priority on this record....
1238
    # get the priority on this record....
1239
    my $priority;
1239
    my $priority = $hold->priority;
1240
    my $query = "SELECT priority
1241
                 FROM   reserves
1242
                 WHERE  biblionumber   = ?
1243
                  AND   borrowernumber = ?
1244
                  AND   reservedate    = ?";
1245
    my $sth = $dbh->prepare($query);
1246
    $sth->execute( $biblionumber, $borrowernumber, $resdate );
1247
    ($priority) = $sth->fetchrow_array;
1248
1240
1249
    # update the database...
1241
    # update the hold statuses, no need to store it though, we will be deleting it anyway
1250
    $query = "UPDATE reserves
1242
    $hold->set(
1251
                  SET    found            = 'F',
1243
        {
1252
                         priority         = 0
1244
            found    => 'F',
1253
                 WHERE  biblionumber     = ?
1245
            priority => 0,
1254
                    AND reservedate      = ?
1246
        }
1255
                    AND borrowernumber   = ?
1247
    );
1256
                ";
1248
1257
    $sth = $dbh->prepare($query);
1249
    my $old_hold = Koha::Old::Hold->new( $hold->unblessed() )->store();
1258
    $sth->execute( $biblionumber, $resdate, $borrowernumber );
1250
1259
1251
    $hold->delete();
1260
    # move to old_reserves
1261
    $query = "INSERT INTO old_reserves
1262
                 SELECT * FROM reserves
1263
                 WHERE  biblionumber     = ?
1264
                    AND reservedate      = ?
1265
                    AND borrowernumber   = ?
1266
                ";
1267
    $sth = $dbh->prepare($query);
1268
    $sth->execute( $biblionumber, $resdate, $borrowernumber );
1269
    $query = "DELETE FROM reserves
1270
                 WHERE  biblionumber     = ?
1271
                    AND reservedate      = ?
1272
                    AND borrowernumber   = ?
1273
                ";
1274
    $sth = $dbh->prepare($query);
1275
    $sth->execute( $biblionumber, $resdate, $borrowernumber );
1276
1252
1277
    # now fix the priority on the others (if the priority wasn't
1253
    # now fix the priority on the others (if the priority wasn't
1278
    # already sorted!)....
1254
    # already sorted!)....
1279
    unless ( $priority == 0 ) {
1255
    unless ( $priority == 0 ) {
1280
        _FixPriority({ reserve_id => $reserve_id, biblionumber => $biblionumber });
1256
        _FixPriority( { reserve_id => $reserve_id, biblionumber => $hold->biblionumber } );
1281
    }
1257
    }
1282
}
1258
}
1283
1259
(-)a/Koha/Old/Hold.pm (+51 lines)
Line 0 Link Here
1
package Koha::Old::Hold;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use base qw(Koha::Hold);
23
24
=head1 NAME
25
26
Koha::Old::Hold - Koha Old Hold object class
27
28
This object represents a hold that has been filled or canceled
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
37
=head3 type
38
39
=cut
40
41
sub type {
42
    return 'OldReserve';
43
}
44
45
=head1 AUTHOR
46
47
Kyle M Hall <kyle@bywatersolutions.com>
48
49
=cut
50
51
1;
(-)a/Koha/Old/Holds.pm (-1 / +64 lines)
Line 0 Link Here
0
- 
1
package Koha::Old::Holds;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Old::Hold;
27
28
use base qw(Koha::Holds);
29
30
=head1 NAME
31
32
Koha::Old::Holds - Koha Old Hold object set class
33
34
This object represents a set of holds that have been filled or canceled
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 type
43
44
=cut
45
46
sub type {
47
    return 'OldReserve';
48
}
49
50
=head3 object_class
51
52
=cut
53
54
sub object_class {
55
    return 'Koha::Old::Hold';
56
}
57
58
=head1 AUTHOR
59
60
Kyle M Hall <kyle@bywatersolutions.com>
61
62
=cut
63
64
1;

Return to bug 14695