|
Lines 97-102
BEGIN {
Link Here
|
| 97 |
&TransformKohaToMarc |
97 |
&TransformKohaToMarc |
| 98 |
&PrepHostMarcField |
98 |
&PrepHostMarcField |
| 99 |
|
99 |
|
|
|
100 |
&UpdateDatereceived |
| 100 |
&CountItemsIssued |
101 |
&CountItemsIssued |
| 101 |
&CountBiblioInOrders |
102 |
&CountBiblioInOrders |
| 102 |
&GetSubscriptionsId |
103 |
&GetSubscriptionsId |
|
Lines 2210-2215
sub GetFrameworkCode {
Link Here
|
| 2210 |
return $frameworkcode; |
2211 |
return $frameworkcode; |
| 2211 |
} |
2212 |
} |
| 2212 |
|
2213 |
|
|
|
2214 |
=head UpdateDatereceived |
| 2215 |
|
| 2216 |
my $error = C4::Biblio::UpdateDatereceived($bibliodataOrBiblionumber, $datereceived, $record); |
| 2217 |
my $error = C4::Biblio::UpdateDatereceived({biblionumber => 1213, datereceived => '2014-12-10 10:12:33', ...}, DateTime, MARC::Record); |
| 2218 |
|
| 2219 |
Updates the biblioitems.datereceived and the corresponding MARC-Subfield if the datereceived |
| 2220 |
hasn't been set for this Biblio yet. Datereceived for the Biblio is the first moment |
| 2221 |
the Biblio became available for the library and shouldn't be updated for subsequent receivals. |
| 2222 |
|
| 2223 |
@PARAM1 MANDATORY |
| 2224 |
Integer, koha.biblio.biblionumber |
| 2225 |
OR |
| 2226 |
Hash, Like returned by C4::Biblio::GetBiblioData(). |
| 2227 |
biblionumber must be a hash key! |
| 2228 |
datereceived must be present as well, otherwise the koha.biblioitems.datereceived |
| 2229 |
will be overwritten, unless this is intended. |
| 2230 |
@PARAM2 OPTIONAL |
| 2231 |
DateTime-object, of the moment of receival. |
| 2232 |
Defaults to Now() if not given. |
| 2233 |
@PARAM3 OPTIONAL |
| 2234 |
MARC::Record, of the biblio to be updated. |
| 2235 |
By default is fetched using the supplied biblionumber. |
| 2236 |
@RETURNS String, error code: |
| 2237 |
'NO_BIBLIODATA', couldn't find the koha.biblioitems-row |
| 2238 |
'NO_BIBLIONUMBER', no biblionumber given as parameter or couldn't |
| 2239 |
find it from the Hash |
| 2240 |
'NOT_DATETIME', $datereceived is not a DateTime-object |
| 2241 |
'NO_RECORD', The given MARC::Record is invalid, or no MARC Record |
| 2242 |
could be found using the supplied biblionumber. |
| 2243 |
'MODBIBLIO_ERROR', C4::Biblio::ModBiblio() failed. |
| 2244 |
|
| 2245 |
=cut |
| 2246 |
sub UpdateDatereceived { |
| 2247 |
my ($biblionumberOrBibliodata, $datereceived, $record) = @_; |
| 2248 |
|
| 2249 |
my $bibdata; |
| 2250 |
unless (ref $biblionumberOrBibliodata) { #We have a SCALAR, eg. a biblionumber. |
| 2251 |
my @biblioitems = C4::Biblio::GetBiblioItemByBiblioNumber($biblionumberOrBibliodata); |
| 2252 |
$bibdata = $biblioitems[0]; |
| 2253 |
} |
| 2254 |
else { |
| 2255 |
$bibdata = $biblionumberOrBibliodata; |
| 2256 |
} |
| 2257 |
return 'NO_BIBLIODATA' if (not($bibdata)); |
| 2258 |
return 'NO_BIBLIONUMBER' if (not($bibdata->{biblionumber})); |
| 2259 |
|
| 2260 |
if ($datereceived && ref $datereceived ne 'DateTime') { |
| 2261 |
return 'NOT_DATETIME'; |
| 2262 |
} |
| 2263 |
#Use the given DateTime or Use Now() |
| 2264 |
$datereceived = ($datereceived) ? $datereceived->iso8601() : DateTime->now( time_zone => C4::Context->tz() )->iso8601(); |
| 2265 |
|
| 2266 |
#Make sure to only update the datereceived for the Biblio if it hasn't been set yet. |
| 2267 |
if ($bibdata->{datereceived}) { |
| 2268 |
return undef; #All is OK and we will preserve the first moment of datereceived. |
| 2269 |
} |
| 2270 |
|
| 2271 |
if (not($record)) { |
| 2272 |
$record = C4::Biblio::GetMarcBiblio($bibdata->{biblionumber}); |
| 2273 |
} |
| 2274 |
elsif (ref($record) ne 'MARC::Record') { |
| 2275 |
return 'NO_RECORD'; |
| 2276 |
} |
| 2277 |
return 'NO_RECORD' unless $record; |
| 2278 |
|
| 2279 |
my $frameworkcode = ($bibdata->{frameworkcode}) ? $bibdata->{frameworkcode} : C4::Biblio::GetFrameworkCode($bibdata->{biblionumber}); |
| 2280 |
|
| 2281 |
#Get the mapped MARC-fields for items.datereceived |
| 2282 |
my ( $datereceivedFieldCode, $datereceivedSubfieldCode ) = |
| 2283 |
C4::Biblio::GetMarcFromKohaField( "biblioitems.datereceived", $frameworkcode ); |
| 2284 |
( $datereceivedFieldCode, $datereceivedSubfieldCode ) = |
| 2285 |
C4::Biblio::GetMarcFromKohaField( "biblioitems.datereceived", '' ) unless ($datereceivedFieldCode); |
| 2286 |
|
| 2287 |
#UPSERT the datereceived DB column to MARC |
| 2288 |
my @existingFields = $record->field($datereceivedFieldCode); |
| 2289 |
if ($existingFields[0]) { |
| 2290 |
$existingFields[0]->update($datereceivedSubfieldCode => $datereceived); |
| 2291 |
} |
| 2292 |
else { |
| 2293 |
my $newField = MARC::Field->new($datereceivedFieldCode, '', '', $datereceivedSubfieldCode => $datereceived); |
| 2294 |
$record->insert_fields_ordered($newField); |
| 2295 |
} |
| 2296 |
|
| 2297 |
my $ok = C4::Biblio::ModBiblio($record, $bibdata->{biblionumber}, $frameworkcode); |
| 2298 |
return 'MODBIBLIO_ERROR' unless $ok; |
| 2299 |
return undef; #All is OK! |
| 2300 |
} |
| 2301 |
|
| 2302 |
|
| 2213 |
=head2 TransformKohaToMarc |
2303 |
=head2 TransformKohaToMarc |
| 2214 |
|
2304 |
|
| 2215 |
$record = TransformKohaToMarc( $hash ) |
2305 |
$record = TransformKohaToMarc( $hash ) |
|
Lines 3255-3260
sub _koha_modify_biblioitem_nonmarc {
Link Here
|
| 3255 |
issn = ?, |
3345 |
issn = ?, |
| 3256 |
publicationyear = ?, |
3346 |
publicationyear = ?, |
| 3257 |
publishercode = ?, |
3347 |
publishercode = ?, |
|
|
3348 |
datereceived = ?, |
| 3258 |
volumedate = ?, |
3349 |
volumedate = ?, |
| 3259 |
volumedesc = ?, |
3350 |
volumedesc = ?, |
| 3260 |
collectiontitle = ?, |
3351 |
collectiontitle = ?, |
|
Lines 3282-3288
sub _koha_modify_biblioitem_nonmarc {
Link Here
|
| 3282 |
my $sth = $dbh->prepare($query); |
3373 |
my $sth = $dbh->prepare($query); |
| 3283 |
$sth->execute( |
3374 |
$sth->execute( |
| 3284 |
$biblioitem->{'biblionumber'}, $biblioitem->{'volume'}, $biblioitem->{'number'}, $biblioitem->{'itemtype'}, |
3375 |
$biblioitem->{'biblionumber'}, $biblioitem->{'volume'}, $biblioitem->{'number'}, $biblioitem->{'itemtype'}, |
| 3285 |
$biblioitem->{'isbn'}, $biblioitem->{'issn'}, $biblioitem->{'publicationyear'}, $biblioitem->{'publishercode'}, |
3376 |
$biblioitem->{'isbn'}, $biblioitem->{'issn'}, $biblioitem->{'publicationyear'}, $biblioitem->{'publishercode'}, $biblioitem->{datereceived}, |
| 3286 |
$biblioitem->{'volumedate'}, $biblioitem->{'volumedesc'}, $biblioitem->{'collectiontitle'}, $biblioitem->{'collectionissn'}, |
3377 |
$biblioitem->{'volumedate'}, $biblioitem->{'volumedesc'}, $biblioitem->{'collectiontitle'}, $biblioitem->{'collectionissn'}, |
| 3287 |
$biblioitem->{'collectionvolume'}, $biblioitem->{'editionstatement'}, $biblioitem->{'editionresponsibility'}, $biblioitem->{'illus'}, |
3378 |
$biblioitem->{'collectionvolume'}, $biblioitem->{'editionstatement'}, $biblioitem->{'editionresponsibility'}, $biblioitem->{'illus'}, |
| 3288 |
$biblioitem->{'pages'}, $biblioitem->{'bnotes'}, $biblioitem->{'size'}, $biblioitem->{'place'}, |
3379 |
$biblioitem->{'pages'}, $biblioitem->{'bnotes'}, $biblioitem->{'size'}, $biblioitem->{'place'}, |