-
Notifications
You must be signed in to change notification settings - Fork 0
/
randitems.pl
46 lines (42 loc) · 2.03 KB
/
randitems.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/perl
use t::lib::TestBuilder;
use Koha::Libraries;
use Koha::Holds;
use Koha::Patrons;
use Koha::DateUtils;
my @branchcodes = Koha::Libraries->search()->get_column('branchcode');
my @itypes = Koha::ItemTypes->search()->get_column('itemtype');
my @ccodes = Koha::AuthorisedValues->search( { category => 'ccode' } )->get_column('authorised_value');
my @locations = Koha::AuthorisedValues->search( { category => 'LOC' } )->get_column('authorised_value');
my @notforloans = Koha::AuthorisedValues->search( { category => 'NOT_LOAN' } )->get_column('authorised_value');
my @damaged = Koha::AuthorisedValues->search( { category => 'DAMAGED' } )->get_column('authorised_value');
my @withdrawn = Koha::AuthorisedValues->search( { category => 'WITHDRAWN' } )->get_column('authorised_value');
push @withdrawn, 0;
push @damaged, 0;
push @notforloans, 0;
my @callnumbers = ('FIC','NF','J','YA');
my $biblios = Koha::Biblios->search({biblionumber => 3});
my $builder = t::lib::TestBuilder->new();
while( my $biblio = $biblios->next) {
my $several = 100;#int( rand(10) ) * 10;
for( my $i = 0; $i < $several; $i++ ){
my $dewey = $i%2 ? " ".int(rand(1000))." " : " " ;
my $call = $callnumbers[rand @callnumbers] . "$dewey" . substr($biblio-> author,0,3);
my $homelibrary = $branchcodes[rand @branchcodes ];
my $holdlibrary = $branchcodes[rand @branchcodes ];
my $item = $builder->build_sample_item({
library => $homelibrary, #Without this we create a new library everytime
homebranch => $homelibrary,
holdingbranch => $holdlibrary,
biblionumber => $biblio->biblionumber,
itype => $itypes[rand @itypes ],
notforloan => $notforloans[rand @notforloans],
location => $locations[rand @locations],
ccode => $ccodes[rand @ccodes],
damaged => $damaged[rand @damaged],
withdrawn => $withdrawn[rand @withdrawn],
itemcallnumber => $call
});
}
}
1;