Some libraries wish to track what the current location of items was at the time they were checked out. This will help libraries track which physical locations in the library patrons are more likely to check out a given book from.
Test Plan:
1) Apply this patch
2) Run updatedatabase.pl
3) Check out an item that has a location set
4) Renew that item
5) View the checkout and renewal in the statistics table,
verify each has the location column populated correctly
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
other => ( $sipmode ? "SIP-$sipmode" : '' ),
itemnumber => $item->{'itemnumber'},
itemtype => $item->{'itype'},
+ location => $item->{location},
borrowernumber => $borrower->{'borrowernumber'},
ccode => $item->{'ccode'}
}
amount => $charge,
itemnumber => $itemnumber,
itemtype => $item->{itype},
+ location => $item->{location},
borrowernumber => $borrowernumber,
ccode => $item->{'ccode'}
}
# make some controls
return () if ! defined $params;
# change these arrays if new types of transaction or new parameters are allowed
- my @allowed_keys = qw (type branch amount other itemnumber itemtype borrowernumber accountno ccode);
+ my @allowed_keys = qw (type branch amount other itemnumber itemtype borrowernumber accountno ccode location);
my @allowed_circulation_types = qw (renew issue localuse return onsite_checkout);
my @allowed_accounts_types = qw (writeoff payment);
my @circulation_mandatory_keys = qw (type branch borrowernumber itemnumber ccode itemtype);
my $amount = exists $params->{amount} ? $params->{amount} :'';
my $other = exists $params->{other} ? $params->{other} :'';
my $itemtype = exists $params->{itemtype} ? $params->{itemtype} :'';
+ my $location = exists $params->{location} ? $params->{location} :'';
my $accountno = exists $params->{accountno} ? $params->{accountno} :'';
my $ccode = exists $params->{ccode} ? $params->{ccode} :'';
"INSERT INTO statistics
(datetime,
branch, type, value,
- other, itemnumber, itemtype,
+ other, itemnumber, itemtype, location,
borrowernumber, proccode, ccode)
- VALUES (now(),?,?,?,?,?,?,?,?,?)"
+ VALUES (now(),?,?,?,?,?,?,?,?,?,?)"
);
$sth->execute(
- $branch, $type, $amount,
- $other, $itemnumber, $itemtype,
- $borrowernumber, $accountno, $ccode
+ $branch, $type, $amount, $other,
+ $itemnumber, $itemtype, $location, $borrowernumber,
+ $accountno, $ccode
);
}
--- /dev/null
+$DBversion = 'XXX';
+if ( CheckVersion($DBversion) ) {
+ if ( !column_exists( 'statistics', 'location' ) ) {
+ $dbh->do('ALTER TABLE statistics ADD COLUMN location VARCHAR(80) default NULL AFTER itemtype');
+ }
+
+ SetVersion($DBversion);
+ print "Upgrade to $DBversion done (Bug 18882 - Add location code to statistics table for checkouts and renewals)\n";
+}
`usercode` varchar(10) default NULL, -- unused in Koha
`itemnumber` int(11) default NULL, -- foreign key from the items table, links transaction to a specific item
`itemtype` varchar(10) default NULL, -- foreign key from the itemtypes table, links transaction to a specific item type
+ `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
`borrowernumber` int(11) default NULL, -- foreign key from the borrowers table, links transaction to a specific borrower
`associatedborrower` int(11) default NULL, -- unused in Koha
`ccode` varchar(10) default NULL, -- foreign key from the items table, links transaction to a specific collection code
use Modern::Perl;
use C4::Stats;
-use Test::More tests => 17;
+use Test::More tests => 18;
BEGIN {
use_ok('C4::Stats');
amount =>5.1,
other => "bla",
itemtype => "BK",
+ location => "LOC",
accountno => 51,
ccode => "CODE",
};
amount =>5.1,
other => "bla",
itemtype => "BK",
+ location => "LOC",
accountno => 51,
ccode => "CODE",
type => "return"
my $sth = $dbh->prepare("SELECT * FROM statistics");
$sth->execute();
my $line = ${ $sth->fetchall_arrayref( {} ) }[0];
-is ($params-> {branch}, $line->{branch}, "UpdateStats save branch param in branch field of statistics table");
-is ($params-> {type}, $line->{type}, "UpdateStats save type param in type field of statistics table");
-is ($params-> {borrowernumber}, $line->{borrowernumber}, "UpdateStats save borrowernumber param in borrowernumber field of statistics table");
-cmp_ok($params-> {amount},'==', $line->{value}, "UpdateStats save amount param in value field of statistics table");
-is ($params-> {other}, $line->{other}, "UpdateStats save other param in other field of statistics table");
-is ($params-> {itemtype}, $line->{itemtype}, "UpdateStats save itemtype param in itemtype field of statistics table");
-is ($params-> {accountno}, $line->{proccode}, "UpdateStats save accountno param in proccode field of statistics table");
-is ($params-> {ccode}, $line->{ccode}, "UpdateStats save ccode param in ccode field of statistics table");
+is ($params->{branch}, $line->{branch}, "UpdateStats save branch param in branch field of statistics table");
+is ($params->{type}, $line->{type}, "UpdateStats save type param in type field of statistics table");
+is ($params->{borrowernumber}, $line->{borrowernumber}, "UpdateStats save borrowernumber param in borrowernumber field of statistics table");
+cmp_ok($params->{amount},'==', $line->{value}, "UpdateStats save amount param in value field of statistics table");
+is ($params->{other}, $line->{other}, "UpdateStats save other param in other field of statistics table");
+is ($params->{itemtype}, $line->{itemtype}, "UpdateStats save itemtype param in itemtype field of statistics table");
+is ($params->{location}, $line->{location}, "UpdateStats save location param in location field of statistics table");
+is ($params->{accountno}, $line->{proccode}, "UpdateStats save accountno param in proccode field of statistics table");
+is ($params->{ccode}, $line->{ccode}, "UpdateStats save ccode param in ccode field of statistics table");
#
# Test TotalPaid