Lines 65-73
BEGIN {
Link Here
|
65 |
ModDateLastSeen |
65 |
ModDateLastSeen |
66 |
ModItemTransfer |
66 |
ModItemTransfer |
67 |
DelItem |
67 |
DelItem |
68 |
|
68 |
|
69 |
CheckItemPreSave |
69 |
CheckItemPreSave |
70 |
|
70 |
|
71 |
GetItemsForInventory |
71 |
GetItemsForInventory |
72 |
GetItemsByBiblioitemnumber |
72 |
GetItemsByBiblioitemnumber |
73 |
GetItemsInfo |
73 |
GetItemsInfo |
Lines 102-108
C4::Items - item management functions
Link Here
|
102 |
|
102 |
|
103 |
=head1 DESCRIPTION |
103 |
=head1 DESCRIPTION |
104 |
|
104 |
|
105 |
This module contains an API for manipulating item |
105 |
This module contains an API for manipulating item |
106 |
records in Koha, and is used by cataloguing, circulation, |
106 |
records in Koha, and is used by cataloguing, circulation, |
107 |
acquisitions, and serials management. |
107 |
acquisitions, and serials management. |
108 |
|
108 |
|
Lines 116-122
modification transaction must keep the items table
Link Here
|
116 |
and the MARC XML in sync at all times. |
116 |
and the MARC XML in sync at all times. |
117 |
|
117 |
|
118 |
Consequently, all code that creates, modifies, or deletes |
118 |
Consequently, all code that creates, modifies, or deletes |
119 |
item records B<must> use an appropriate function from |
119 |
item records B<must> use an appropriate function from |
120 |
C<C4::Items>. If no existing function is suitable, it is |
120 |
C<C4::Items>. If no existing function is suitable, it is |
121 |
better to add one to C<C4::Items> than to use add |
121 |
better to add one to C<C4::Items> than to use add |
122 |
one-off SQL statements to add or modify items. |
122 |
one-off SQL statements to add or modify items. |
Lines 222-228
sub ShelfToCart {
Link Here
|
222 |
|
222 |
|
223 |
=head2 AddItemFromMarc |
223 |
=head2 AddItemFromMarc |
224 |
|
224 |
|
225 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
225 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
226 |
= AddItemFromMarc($source_item_marc, $biblionumber); |
226 |
= AddItemFromMarc($source_item_marc, $biblionumber); |
227 |
|
227 |
|
228 |
Given a MARC::Record object containing an embedded item |
228 |
Given a MARC::Record object containing an embedded item |
Lines 237-243
sub AddItemFromMarc {
Link Here
|
237 |
# parse item hash from MARC |
237 |
# parse item hash from MARC |
238 |
my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber ); |
238 |
my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber ); |
239 |
my ($itemtag,$itemsubfield)=C4::Biblio::GetMarcFromKohaField("items.itemnumber",$frameworkcode); |
239 |
my ($itemtag,$itemsubfield)=C4::Biblio::GetMarcFromKohaField("items.itemnumber",$frameworkcode); |
240 |
|
240 |
|
241 |
my $localitemmarc=MARC::Record->new; |
241 |
my $localitemmarc=MARC::Record->new; |
242 |
$localitemmarc->append_fields($source_item_marc->field($itemtag)); |
242 |
$localitemmarc->append_fields($source_item_marc->field($itemtag)); |
243 |
my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items'); |
243 |
my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items'); |
Lines 247-253
sub AddItemFromMarc {
Link Here
|
247 |
|
247 |
|
248 |
=head2 AddItem |
248 |
=head2 AddItem |
249 |
|
249 |
|
250 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
250 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
251 |
= AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields]); |
251 |
= AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields]); |
252 |
|
252 |
|
253 |
Given a hash containing item column names as keys, |
253 |
Given a hash containing item column names as keys, |
Lines 261-267
The final optional parameter, C<$unlinked_item_subfields>, contains
Link Here
|
261 |
an arrayref containing subfields present in the original MARC |
261 |
an arrayref containing subfields present in the original MARC |
262 |
representation of the item (e.g., from the item editor) that are |
262 |
representation of the item (e.g., from the item editor) that are |
263 |
not mapped to C<items> columns directly but should instead |
263 |
not mapped to C<items> columns directly but should instead |
264 |
be stored in C<items.more_subfields_xml> and included in |
264 |
be stored in C<items.more_subfields_xml> and included in |
265 |
the biblio items tag for display and indexing. |
265 |
the biblio items tag for display and indexing. |
266 |
|
266 |
|
267 |
=cut |
267 |
=cut |
Lines 309-315
sub AddItem {
Link Here
|
309 |
|
309 |
|
310 |
=head2 AddItemBatchFromMarc |
310 |
=head2 AddItemBatchFromMarc |
311 |
|
311 |
|
312 |
($itemnumber_ref, $error_ref) = AddItemBatchFromMarc($record, |
312 |
($itemnumber_ref, $error_ref) = AddItemBatchFromMarc($record, |
313 |
$biblionumber, $biblioitemnumber, $frameworkcode); |
313 |
$biblionumber, $biblioitemnumber, $frameworkcode); |
314 |
|
314 |
|
315 |
Efficiently create item records from a MARC biblio record with |
315 |
Efficiently create item records from a MARC biblio record with |
Lines 374-380
sub AddItemBatchFromMarc {
Link Here
|
374 |
# and there is no TransformMarcFieldToKoha |
374 |
# and there is no TransformMarcFieldToKoha |
375 |
my $temp_item_marc = MARC::Record->new(); |
375 |
my $temp_item_marc = MARC::Record->new(); |
376 |
$temp_item_marc->append_fields($item_field); |
376 |
$temp_item_marc->append_fields($item_field); |
377 |
|
377 |
|
378 |
# add biblionumber and biblioitemnumber |
378 |
# add biblionumber and biblioitemnumber |
379 |
my $item = TransformMarcToKoha( $temp_item_marc, $frameworkcode, 'items' ); |
379 |
my $item = TransformMarcToKoha( $temp_item_marc, $frameworkcode, 'items' ); |
380 |
my $unlinked_item_subfields = _get_unlinked_item_subfields($temp_item_marc, $frameworkcode); |
380 |
my $unlinked_item_subfields = _get_unlinked_item_subfields($temp_item_marc, $frameworkcode); |
Lines 397-403
sub AddItemBatchFromMarc {
Link Here
|
397 |
push @itemnumbers, $itemnumber; # FIXME not checking error |
397 |
push @itemnumbers, $itemnumber; # FIXME not checking error |
398 |
$item->{'itemnumber'} = $itemnumber; |
398 |
$item->{'itemnumber'} = $itemnumber; |
399 |
|
399 |
|
400 |
logaction("CATALOGUING", "ADD", $itemnumber, "item") if C4::Context->preference("CataloguingLog"); |
400 |
logaction("CATALOGUING", "ADD", $itemnumber, "item") if C4::Context->preference("CataloguingLog"); |
401 |
|
401 |
|
402 |
my $new_item_marc = _marc_from_item_hash($item, $frameworkcode, $unlinked_item_subfields); |
402 |
my $new_item_marc = _marc_from_item_hash($item, $frameworkcode, $unlinked_item_subfields); |
403 |
$item_field->replace_with($new_item_marc->field($itemtag)); |
403 |
$item_field->replace_with($new_item_marc->field($itemtag)); |
Lines 420-426
sub AddItemBatchFromMarc {
Link Here
|
420 |
|
420 |
|
421 |
This function updates an item record based on a supplied |
421 |
This function updates an item record based on a supplied |
422 |
C<MARC::Record> object containing an embedded item field. |
422 |
C<MARC::Record> object containing an embedded item field. |
423 |
This API is meant for the use of C<additem.pl>; for |
423 |
This API is meant for the use of C<additem.pl>; for |
424 |
other purposes, C<ModItem> should be used. |
424 |
other purposes, C<ModItem> should be used. |
425 |
|
425 |
|
426 |
This function uses the hash %default_values_for_mod_from_marc, |
426 |
This function uses the hash %default_values_for_mod_from_marc, |
Lines 539-549
C<$unlinked_item_subfields> contains an arrayref containing
Link Here
|
539 |
subfields present in the original MARC |
539 |
subfields present in the original MARC |
540 |
representation of the item (e.g., from the item editor) that are |
540 |
representation of the item (e.g., from the item editor) that are |
541 |
not mapped to C<items> columns directly but should instead |
541 |
not mapped to C<items> columns directly but should instead |
542 |
be stored in C<items.more_subfields_xml> and included in |
542 |
be stored in C<items.more_subfields_xml> and included in |
543 |
the biblio items tag for display and indexing. |
543 |
the biblio items tag for display and indexing. |
544 |
|
544 |
|
545 |
If one of the changed columns is used to calculate |
545 |
If one of the changed columns is used to calculate |
546 |
the derived value of a column such as C<items.cn_sort>, |
546 |
the derived value of a column such as C<items.cn_sort>, |
547 |
this routine will perform the necessary calculation |
547 |
this routine will perform the necessary calculation |
548 |
and set the value. |
548 |
and set the value. |
549 |
|
549 |
|
Lines 771-777
sub CheckItemPreSave {
Link Here
|
771 |
|
771 |
|
772 |
=head1 EXPORTED SPECIAL ACCESSOR FUNCTIONS |
772 |
=head1 EXPORTED SPECIAL ACCESSOR FUNCTIONS |
773 |
|
773 |
|
774 |
The following functions provide various ways of |
774 |
The following functions provide various ways of |
775 |
getting an item record, a set of item records, or |
775 |
getting an item record, a set of item records, or |
776 |
lists of authorized values for certain item fields. |
776 |
lists of authorized values for certain item fields. |
777 |
|
777 |
|
Lines 947-955
sub GetItemsByBiblioitemnumber {
Link Here
|
947 |
my $sth = $dbh->prepare("SELECT * FROM items WHERE items.biblioitemnumber = ?") || die $dbh->errstr; |
947 |
my $sth = $dbh->prepare("SELECT * FROM items WHERE items.biblioitemnumber = ?") || die $dbh->errstr; |
948 |
# Get all items attached to a biblioitem |
948 |
# Get all items attached to a biblioitem |
949 |
my $i = 0; |
949 |
my $i = 0; |
950 |
my @results; |
950 |
my @results; |
951 |
$sth->execute($bibitem) || die $sth->errstr; |
951 |
$sth->execute($bibitem) || die $sth->errstr; |
952 |
while ( my $data = $sth->fetchrow_hashref ) { |
952 |
while ( my $data = $sth->fetchrow_hashref ) { |
953 |
# Foreach item, get circulation information |
953 |
# Foreach item, get circulation information |
954 |
my $sth2 = $dbh->prepare( "SELECT * FROM issues,borrowers |
954 |
my $sth2 = $dbh->prepare( "SELECT * FROM issues,borrowers |
955 |
WHERE itemnumber = ? |
955 |
WHERE itemnumber = ? |
Lines 964-972
sub GetItemsByBiblioitemnumber {
Link Here
|
964 |
} |
964 |
} |
965 |
else { |
965 |
else { |
966 |
# set date_due to blank, so in the template we check itemlost, and withdrawn |
966 |
# set date_due to blank, so in the template we check itemlost, and withdrawn |
967 |
$data->{'date_due'} = ''; |
967 |
$data->{'date_due'} = ''; |
968 |
} # else |
968 |
} # else |
969 |
# Find the last 3 people who borrowed this item. |
969 |
# Find the last 3 people who borrowed this item. |
970 |
my $query2 = "SELECT * FROM old_issues, borrowers WHERE itemnumber = ? |
970 |
my $query2 = "SELECT * FROM old_issues, borrowers WHERE itemnumber = ? |
971 |
AND old_issues.borrowernumber = borrowers.borrowernumber |
971 |
AND old_issues.borrowernumber = borrowers.borrowernumber |
972 |
ORDER BY returndate desc,timestamp desc LIMIT 3"; |
972 |
ORDER BY returndate desc,timestamp desc LIMIT 3"; |
Lines 980-987
sub GetItemsByBiblioitemnumber {
Link Here
|
980 |
$i2++; |
980 |
$i2++; |
981 |
} |
981 |
} |
982 |
push(@results,$data); |
982 |
push(@results,$data); |
983 |
} |
983 |
} |
984 |
return (\@results); |
984 |
return (\@results); |
985 |
} |
985 |
} |
986 |
|
986 |
|
987 |
=head2 GetItemsInfo |
987 |
=head2 GetItemsInfo |
Lines 1165-1171
The intranet description for the Shelving Location as set in authorised_values '
Link Here
|
1165 |
|
1165 |
|
1166 |
=item C<$data-E<gt>{location_opac}> |
1166 |
=item C<$data-E<gt>{location_opac}> |
1167 |
|
1167 |
|
1168 |
The OPAC description for the Shelving Location as set in authorised_values 'LOC'. Falls back to intranet description if no OPAC |
1168 |
The OPAC description for the Shelving Location as set in authorised_values 'LOC'. Falls back to intranet description if no OPAC |
1169 |
description is set. |
1169 |
description is set. |
1170 |
|
1170 |
|
1171 |
=item C<$data-E<gt>{itemcallnumber}> |
1171 |
=item C<$data-E<gt>{itemcallnumber}> |
Lines 1177-1183
Item's itemcallnumber
Link Here
|
1177 |
Item's call number normalized for sorting |
1177 |
Item's call number normalized for sorting |
1178 |
|
1178 |
|
1179 |
=back |
1179 |
=back |
1180 |
|
1180 |
|
1181 |
=cut |
1181 |
=cut |
1182 |
|
1182 |
|
1183 |
sub GetItemsLocationInfo { |
1183 |
sub GetItemsLocationInfo { |
Lines 1185-1194
sub GetItemsLocationInfo {
Link Here
|
1185 |
my @results; |
1185 |
my @results; |
1186 |
|
1186 |
|
1187 |
my $dbh = C4::Context->dbh; |
1187 |
my $dbh = C4::Context->dbh; |
1188 |
my $query = "SELECT a.branchname as homebranch, b.branchname as holdingbranch, |
1188 |
my $query = "SELECT a.branchname as homebranch, b.branchname as holdingbranch, |
1189 |
location, itemcallnumber, cn_sort |
1189 |
location, itemcallnumber, cn_sort |
1190 |
FROM items, branches as a, branches as b |
1190 |
FROM items, branches as a, branches as b |
1191 |
WHERE homebranch = a.branchcode AND holdingbranch = b.branchcode |
1191 |
WHERE homebranch = a.branchcode AND holdingbranch = b.branchcode |
1192 |
AND biblionumber = ? |
1192 |
AND biblionumber = ? |
1193 |
ORDER BY cn_sort ASC"; |
1193 |
ORDER BY cn_sort ASC"; |
1194 |
my $sth = $dbh->prepare($query); |
1194 |
my $sth = $dbh->prepare($query); |
Lines 1243-1249
sub GetHostItemsInfo {
Link Here
|
1243 |
|
1243 |
|
1244 |
=head2 GetLastAcquisitions |
1244 |
=head2 GetLastAcquisitions |
1245 |
|
1245 |
|
1246 |
my $lastacq = GetLastAcquisitions({'branches' => ('branch1','branch2'), |
1246 |
my $lastacq = GetLastAcquisitions({'branches' => ('branch1','branch2'), |
1247 |
'itemtypes' => ('BK','BD')}, 10); |
1247 |
'itemtypes' => ('BK','BD')}, 10); |
1248 |
|
1248 |
|
1249 |
=cut |
1249 |
=cut |
Lines 1252-1294
sub GetLastAcquisitions {
Link Here
|
1252 |
my ($data,$max) = @_; |
1252 |
my ($data,$max) = @_; |
1253 |
|
1253 |
|
1254 |
my $itemtype = C4::Context->preference('item-level_itypes') ? 'itype' : 'itemtype'; |
1254 |
my $itemtype = C4::Context->preference('item-level_itypes') ? 'itype' : 'itemtype'; |
1255 |
|
1255 |
|
1256 |
my $number_of_branches = @{$data->{branches}}; |
1256 |
my $number_of_branches = @{$data->{branches}}; |
1257 |
my $number_of_itemtypes = @{$data->{itemtypes}}; |
1257 |
my $number_of_itemtypes = @{$data->{itemtypes}}; |
1258 |
|
1258 |
|
1259 |
|
1259 |
|
1260 |
my @where = ('WHERE 1 '); |
1260 |
my @where = ('WHERE 1 '); |
1261 |
$number_of_branches and push @where |
1261 |
$number_of_branches and push @where |
1262 |
, 'AND holdingbranch IN (' |
1262 |
, 'AND holdingbranch IN (' |
1263 |
, join(',', ('?') x $number_of_branches ) |
1263 |
, join(',', ('?') x $number_of_branches ) |
1264 |
, ')' |
1264 |
, ')' |
1265 |
; |
1265 |
; |
1266 |
|
1266 |
|
1267 |
$number_of_itemtypes and push @where |
1267 |
$number_of_itemtypes and push @where |
1268 |
, "AND $itemtype IN (" |
1268 |
, "AND $itemtype IN (" |
1269 |
, join(',', ('?') x $number_of_itemtypes ) |
1269 |
, join(',', ('?') x $number_of_itemtypes ) |
1270 |
, ')' |
1270 |
, ')' |
1271 |
; |
1271 |
; |
1272 |
|
1272 |
|
1273 |
my $query = "SELECT biblio.biblionumber as biblionumber, title, dateaccessioned |
1273 |
my $query = "SELECT biblio.biblionumber as biblionumber, title, dateaccessioned |
1274 |
FROM items RIGHT JOIN biblio ON (items.biblionumber=biblio.biblionumber) |
1274 |
FROM items RIGHT JOIN biblio ON (items.biblionumber=biblio.biblionumber) |
1275 |
RIGHT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) |
1275 |
RIGHT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) |
1276 |
@where |
1276 |
@where |
1277 |
GROUP BY biblio.biblionumber |
1277 |
GROUP BY biblio.biblionumber |
1278 |
ORDER BY dateaccessioned DESC LIMIT $max"; |
1278 |
ORDER BY dateaccessioned DESC LIMIT $max"; |
1279 |
|
1279 |
|
1280 |
my $dbh = C4::Context->dbh; |
1280 |
my $dbh = C4::Context->dbh; |
1281 |
my $sth = $dbh->prepare($query); |
1281 |
my $sth = $dbh->prepare($query); |
1282 |
|
1282 |
|
1283 |
$sth->execute((@{$data->{branches}}, @{$data->{itemtypes}})); |
1283 |
$sth->execute((@{$data->{branches}}, @{$data->{itemtypes}})); |
1284 |
|
1284 |
|
1285 |
my @results; |
1285 |
my @results; |
1286 |
while( my $row = $sth->fetchrow_hashref){ |
1286 |
while( my $row = $sth->fetchrow_hashref){ |
1287 |
push @results, {date => $row->{dateaccessioned} |
1287 |
push @results, {date => $row->{dateaccessioned} |
1288 |
, biblionumber => $row->{biblionumber} |
1288 |
, biblionumber => $row->{biblionumber} |
1289 |
, title => $row->{title}}; |
1289 |
, title => $row->{title}}; |
1290 |
} |
1290 |
} |
1291 |
|
1291 |
|
1292 |
return @results; |
1292 |
return @results; |
1293 |
} |
1293 |
} |
1294 |
|
1294 |
|
Lines 1492-1509
sub GetMarcItem {
Link Here
|
1492 |
# Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work. |
1492 |
# Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work. |
1493 |
# Also, don't emit a subfield if the underlying field is blank. |
1493 |
# Also, don't emit a subfield if the underlying field is blank. |
1494 |
|
1494 |
|
1495 |
|
1495 |
|
1496 |
return Item2Marc($itemrecord,$biblionumber); |
1496 |
return Item2Marc($itemrecord,$biblionumber); |
1497 |
|
1497 |
|
1498 |
} |
1498 |
} |
|
|
1499 |
|
1500 |
=head2 GetMarcItems |
1501 |
|
1502 |
my @items_marc = GetMarcItems($biblionumber, \@hiddenitemnumbers); |
1503 |
|
1504 |
Returns array of MARC::Records of the items for the biblio passed in parameter. |
1505 |
|
1506 |
=cut |
1507 |
|
1508 |
sub GetMarcItems { |
1509 |
my ( $biblionumber, $hiddenitems, $itemtag ) = @_; |
1510 |
my $params; |
1511 |
$params->{biblionumber} = $biblionumber; |
1512 |
$params->{itemnumber} = {'not in' => @$hiddenitems} if defined $hiddenitems && scalar @$hiddenitems; |
1513 |
my $items = Koha::Items->search($params ); |
1514 |
return unless $items; |
1515 |
|
1516 |
# Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work. |
1517 |
# Also, don't emit a subfield if the underlying field is blank. |
1518 |
|
1519 |
my $framework = Koha::Biblios->find( $biblionumber)->frameworkcode(); |
1520 |
my @marc_items; |
1521 |
while ( my $this_item = $items->next() ){ |
1522 |
push @marc_items, Item2Marc($this_item->unblessed,$biblionumber,$framework)->field($itemtag); |
1523 |
} |
1524 |
return \@marc_items; |
1525 |
} |
1526 |
|
1499 |
sub Item2Marc { |
1527 |
sub Item2Marc { |
1500 |
my ($itemrecord,$biblionumber)=@_; |
1528 |
my ($itemrecord,$biblionumber, $frameworkcode)=@_; |
1501 |
my $mungeditem = { |
1529 |
my $mungeditem = { |
1502 |
map { |
1530 |
map { |
1503 |
defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () |
1531 |
defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () |
1504 |
} keys %{ $itemrecord } |
1532 |
} keys %{ $itemrecord } |
1505 |
}; |
1533 |
}; |
1506 |
my $framework = C4::Biblio::GetFrameworkCode( $biblionumber ); |
1534 |
my $framework = $frameworkcode // C4::Biblio::GetFrameworkCode( $biblionumber ); |
1507 |
my $itemmarc = C4::Biblio::TransformKohaToMarc( |
1535 |
my $itemmarc = C4::Biblio::TransformKohaToMarc( |
1508 |
$mungeditem, { no_split => 1}, |
1536 |
$mungeditem, { no_split => 1}, |
1509 |
); |
1537 |
); |
Lines 1553-1559
my %derived_columns = (
Link Here
|
1553 |
} |
1581 |
} |
1554 |
); |
1582 |
); |
1555 |
|
1583 |
|
1556 |
=head2 _set_derived_columns_for_add |
1584 |
=head2 _set_derived_columns_for_add |
1557 |
|
1585 |
|
1558 |
_set_derived_column_for_add($item); |
1586 |
_set_derived_column_for_add($item); |
1559 |
|
1587 |
|
Lines 1577-1583
sub _set_derived_columns_for_add {
Link Here
|
1577 |
} |
1605 |
} |
1578 |
} |
1606 |
} |
1579 |
|
1607 |
|
1580 |
=head2 _set_derived_columns_for_mod |
1608 |
=head2 _set_derived_columns_for_mod |
1581 |
|
1609 |
|
1582 |
_set_derived_column_for_mod($item); |
1610 |
_set_derived_column_for_mod($item); |
1583 |
|
1611 |
|
Lines 1680-1691
row specified by C<$itemnumber>.
Link Here
|
1680 |
sub _get_single_item_column { |
1708 |
sub _get_single_item_column { |
1681 |
my $column = shift; |
1709 |
my $column = shift; |
1682 |
my $itemnumber = shift; |
1710 |
my $itemnumber = shift; |
1683 |
|
1711 |
|
1684 |
my $dbh = C4::Context->dbh; |
1712 |
my $dbh = C4::Context->dbh; |
1685 |
my $sth = $dbh->prepare("SELECT $column FROM items WHERE itemnumber = ?"); |
1713 |
my $sth = $dbh->prepare("SELECT $column FROM items WHERE itemnumber = ?"); |
1686 |
$sth->execute($itemnumber); |
1714 |
$sth->execute($itemnumber); |
1687 |
my ($value) = $sth->fetchrow(); |
1715 |
my ($value) = $sth->fetchrow(); |
1688 |
return $value; |
1716 |
return $value; |
1689 |
} |
1717 |
} |
1690 |
|
1718 |
|
1691 |
=head2 _calc_items_cn_sort |
1719 |
=head2 _calc_items_cn_sort |
Lines 1703-1709
sub _calc_items_cn_sort {
Link Here
|
1703 |
$item->{'items.cn_sort'} = GetClassSort($source_values->{'items.cn_source'}, $source_values->{'itemcallnumber'}, ""); |
1731 |
$item->{'items.cn_sort'} = GetClassSort($source_values->{'items.cn_source'}, $source_values->{'itemcallnumber'}, ""); |
1704 |
} |
1732 |
} |
1705 |
|
1733 |
|
1706 |
=head2 _set_defaults_for_add |
1734 |
=head2 _set_defaults_for_add |
1707 |
|
1735 |
|
1708 |
_set_defaults_for_add($item_hash); |
1736 |
_set_defaults_for_add($item_hash); |
1709 |
|
1737 |
|
Lines 1714-1720
columns:
Link Here
|
1714 |
|
1742 |
|
1715 |
=over 2 |
1743 |
=over 2 |
1716 |
|
1744 |
|
1717 |
=item * |
1745 |
=item * |
1718 |
|
1746 |
|
1719 |
C<items.dateaccessioned> |
1747 |
C<items.dateaccessioned> |
1720 |
|
1748 |
|
Lines 1754-1760
Perform the actual insert into the C<items> table.
Link Here
|
1754 |
|
1782 |
|
1755 |
sub _koha_new_item { |
1783 |
sub _koha_new_item { |
1756 |
my ( $item, $barcode ) = @_; |
1784 |
my ( $item, $barcode ) = @_; |
1757 |
my $dbh=C4::Context->dbh; |
1785 |
my $dbh=C4::Context->dbh; |
1758 |
my $error; |
1786 |
my $error; |
1759 |
$item->{permanent_location} //= $item->{location}; |
1787 |
$item->{permanent_location} //= $item->{location}; |
1760 |
_mod_item_dates( $item ); |
1788 |
_mod_item_dates( $item ); |
Lines 1885-1891
sub MoveItemFromBiblio {
Link Here
|
1885 |
if ($return == 1) { |
1913 |
if ($return == 1) { |
1886 |
ModZebra( $tobiblio, "specialUpdate", "biblioserver" ); |
1914 |
ModZebra( $tobiblio, "specialUpdate", "biblioserver" ); |
1887 |
ModZebra( $frombiblio, "specialUpdate", "biblioserver" ); |
1915 |
ModZebra( $frombiblio, "specialUpdate", "biblioserver" ); |
1888 |
# Checking if the item we want to move is in an order |
1916 |
# Checking if the item we want to move is in an order |
1889 |
require C4::Acquisition; |
1917 |
require C4::Acquisition; |
1890 |
my $order = C4::Acquisition::GetOrderFromItemnumber($itemnumber); |
1918 |
my $order = C4::Acquisition::GetOrderFromItemnumber($itemnumber); |
1891 |
if ($order) { |
1919 |
if ($order) { |
Lines 2016-2022
routine accepts a hashref specifying the columns to update.
Link Here
|
2016 |
|
2044 |
|
2017 |
sub _koha_modify_item { |
2045 |
sub _koha_modify_item { |
2018 |
my ( $item ) = @_; |
2046 |
my ( $item ) = @_; |
2019 |
my $dbh=C4::Context->dbh; |
2047 |
my $dbh=C4::Context->dbh; |
2020 |
my $error; |
2048 |
my $error; |
2021 |
|
2049 |
|
2022 |
my $query = "UPDATE items SET "; |
2050 |
my $query = "UPDATE items SET "; |
Lines 2126-2137
sub _marc_from_item_hash {
Link Here
|
2126 |
if (@_) { |
2154 |
if (@_) { |
2127 |
$unlinked_item_subfields = shift; |
2155 |
$unlinked_item_subfields = shift; |
2128 |
} |
2156 |
} |
2129 |
|
2157 |
|
2130 |
# Tack on 'items.' prefix to column names so lookup from MARC frameworks will work |
2158 |
# Tack on 'items.' prefix to column names so lookup from MARC frameworks will work |
2131 |
# Also, don't emit a subfield if the underlying field is blank. |
2159 |
# Also, don't emit a subfield if the underlying field is blank. |
2132 |
my $mungeditem = { map { (defined($item->{$_}) and $item->{$_} ne '') ? |
2160 |
my $mungeditem = { map { (defined($item->{$_}) and $item->{$_} ne '') ? |
2133 |
(/^items\./ ? ($_ => $item->{$_}) : ("items.$_" => $item->{$_})) |
2161 |
(/^items\./ ? ($_ => $item->{$_}) : ("items.$_" => $item->{$_})) |
2134 |
: () } keys %{ $item } }; |
2162 |
: () } keys %{ $item } }; |
2135 |
|
2163 |
|
2136 |
my $item_marc = MARC::Record->new(); |
2164 |
my $item_marc = MARC::Record->new(); |
2137 |
foreach my $item_field ( keys %{$mungeditem} ) { |
2165 |
foreach my $item_field ( keys %{$mungeditem} ) { |
Lines 2175-2181
sub _repack_item_errors {
Link Here
|
2175 |
$repacked_error->{'error_code'} = $error_code; |
2203 |
$repacked_error->{'error_code'} = $error_code; |
2176 |
$repacked_error->{'error_information'} = $error_ref->{$error_code}; |
2204 |
$repacked_error->{'error_information'} = $error_ref->{$error_code}; |
2177 |
push @repacked_errors, $repacked_error; |
2205 |
push @repacked_errors, $repacked_error; |
2178 |
} |
2206 |
} |
2179 |
|
2207 |
|
2180 |
return @repacked_errors; |
2208 |
return @repacked_errors; |
2181 |
} |
2209 |
} |
Lines 2225-2231
sub _get_unlinked_subfields_xml {
Link Here
|
2225 |
# use of tag 999 is arbitrary, and doesn't need to match the item tag |
2253 |
# use of tag 999 is arbitrary, and doesn't need to match the item tag |
2226 |
# used in the framework |
2254 |
# used in the framework |
2227 |
$marc->append_fields(MARC::Field->new('999', ' ', ' ', @$unlinked_item_subfields)); |
2255 |
$marc->append_fields(MARC::Field->new('999', ' ', ' ', @$unlinked_item_subfields)); |
2228 |
$marc->encoding("UTF-8"); |
2256 |
$marc->encoding("UTF-8"); |
2229 |
$xml = $marc->as_xml("USMARC"); |
2257 |
$xml = $marc->as_xml("USMARC"); |
2230 |
} |
2258 |
} |
2231 |
|
2259 |
|
Lines 2257-2263
sub _parse_unlinked_item_subfields_from_xml {
Link Here
|
2257 |
|
2285 |
|
2258 |
$count= &GetAnalyticsCount($itemnumber) |
2286 |
$count= &GetAnalyticsCount($itemnumber) |
2259 |
|
2287 |
|
2260 |
counts Usage of itemnumber in Analytical bibliorecords. |
2288 |
counts Usage of itemnumber in Analytical bibliorecords. |
2261 |
|
2289 |
|
2262 |
=cut |
2290 |
=cut |
2263 |
|
2291 |
|
2264 |
- |
|
|