Line 0
Link Here
|
|
|
1 |
use Modern::Perl; |
2 |
|
3 |
use DateTime; |
4 |
|
5 |
use C4::Biblio; |
6 |
use C4::Circulation; |
7 |
use C4::Items; |
8 |
use C4::Members; |
9 |
use Koha::Database; |
10 |
use Data::Dumper; |
11 |
|
12 |
my $schema = Koha::Database->schema; |
13 |
$schema->storage->txn_begin; |
14 |
|
15 |
|
16 |
C4::Context->_new_userenv('xxx'); |
17 |
C4::Context->set_userenv(0,0,0,'firstname','surname', 'VC', 'Midway Public Library', '', '', ''); |
18 |
my $limit = 100; |
19 |
my $dbh = C4::Context->dbh; |
20 |
$dbh->do(q|DELETE FROM issues|); |
21 |
|
22 |
my @items = $dbh->selectall_array("SELECT barcode FROM items WHERE barcode IS NOT NULL LIMIT $limit", { Slice => {} }); |
23 |
my @borrowers = $dbh->selectall_array("SELECT borrowernumber FROM borrowers WHERE borrowernumber IS NOT NULL LIMIT $limit", { Slice => {} }); |
24 |
|
25 |
############################ |
26 |
# Checkouts |
27 |
########################### |
28 |
|
29 |
sub checkouts { |
30 |
|
31 |
for (my $i = 0; $i < $limit; $i++) { |
32 |
my $barcode = $items[$i]->{barcode}; |
33 |
my $borrowernumber = $borrowers[$i]->{borrowernumber}; |
34 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
35 |
|
36 |
my $due_date = DateTime->new(year => 2016, month => 10, day => 1); |
37 |
# my $due_date = DateTime->today; |
38 |
my $issuedate = DateTime->new(year => 2016, month => 7, day => 1); |
39 |
|
40 |
AddIssue( $borrower, $barcode, $due_date, undef, $issuedate, undef, undef ); |
41 |
} |
42 |
} |
43 |
checkouts(); |
44 |
############################ |
45 |
# Checkins |
46 |
########################### |
47 |
|
48 |
sub checkins { |
49 |
|
50 |
for (my $i = 0; $i < $limit; $i++) { |
51 |
my $barcode = $items[$i]->{barcode}; |
52 |
|
53 |
AddReturn($barcode, undef, undef, undef, DateTime->today); |
54 |
} |
55 |
} |
56 |
checkins(); |
57 |
|
58 |
$schema->storage->txn_rollback; |
59 |
1; |