Browse Source

Bug 12375 [4] - Replace use of DBI with Koha::Database in C4::Serials::NewIssue

Currently, all serials enumeration data is stored in conglomerated
fashion in serial.serialseq. This makes it extremely difficult to do any
reporting based on the individual sequence values due to this fact. In
addition to the formatted version of the sequence, we should be storing
the individual values as well.

Test Plan:
1) Apply this patch
2) Run updatedatabase.pl
3) Create a new subscription, and add serials to it. The new x y and
   z fields should be populated with the same data the replaces {X} {Y} and
   {Z} in the enumeration field.
4) Inspect some existing serials. The update script will have made a
   best effort to recover the existing enumeration data to store in
   separate fields.

Signed-off-by: Paul Landers <paul.landers@ttuhsc.edu>
new_12478_elasticsearch
Kyle Hall 10 years ago
parent
commit
0e2ccf0801
  1. 37
      C4/Serials.pm

37
C4/Serials.pm

@ -1578,36 +1578,29 @@ sub NewIssue {
}
);
my $dbh = C4::Context->dbh;
my $serialid = $serial->id();
my $query = qq|
SELECT missinglist,recievedlist
FROM subscriptionhistory
WHERE subscriptionid=?
|;
my $sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
my ( $missinglist, $recievedlist ) = $sth->fetchrow;
my $subscription_history = $schema->resultset('Subscriptionhistory')->find($subscriptionid);
my $missinglist = $subscription_history->missinglist();
my $recievedlist = $subscription_history->recievedlist();
if ( $status == ARRIVED ) {
### TODO Add a feature that improves recognition and description.
### As such count (serialseq) i.e. : N18,2(N19),N20
### Would use substr and index But be careful to previous presence of ()
$recievedlist .= "; $serialseq" unless (index($recievedlist,$serialseq)>0);
### TODO Add a feature that improves recognition and description.
### As such count (serialseq) i.e. : N18,2(N19),N20
### Would use substr and index But be careful to previous presence of ()
$recievedlist .= "; $serialseq" unless ( index( $recievedlist, $serialseq ) > 0 );
}
if ( grep {/^$status$/} ( MISSING_STATUSES ) ) {
$missinglist .= "; $serialseq" unless (index($missinglist,$serialseq)>0);
if ( grep { /^$status$/ } (MISSING_STATUSES) ) {
$missinglist .= "; $serialseq" unless ( index( $missinglist, $serialseq ) > 0 );
}
$query = qq|
UPDATE subscriptionhistory
SET recievedlist=?, missinglist=?
WHERE subscriptionid=?
|;
$sth = $dbh->prepare($query);
$recievedlist =~ s/^; //;
$missinglist =~ s/^; //;
$sth->execute( $recievedlist, $missinglist, $subscriptionid );
$subscription_history->recievedlist($recievedlist);
$subscription_history->missinglist($missinglist);
$subscription_history->update();
return $serialid;
}

Loading…
Cancel
Save