use C4::Debug;
use C4::Serials::Frequency;
use C4::Serials::Numberpattern;
-use Koha::AdditionalField;
+use Koha::AdditionalFieldValues;
use Koha::DateUtils;
use Koha::Serial;
use Koha::Subscriptions;
use Koha::Subscription::Histories;
+use Koha::SharedContent;
+use Scalar::Util qw( looks_like_number );
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
&GetNextSeq &GetSeq &NewIssue &GetSerials
&GetLatestSerials &ModSerialStatus &GetNextDate &GetSerials2
- &ReNewSubscription &GetLateOrMissingIssues
+ &GetSubscriptionLength &ReNewSubscription &GetLateOrMissingIssues
&GetSerialInformation &AddItem2Serial
&PrepareSerialsData &GetNextExpected &ModNextExpected
&GetPreviousSerialid
- &GetSuppliersWithLateIssues &getsupplierbyserialid
- &GetDistributedTo &SetDistributedTo
+ &GetSuppliersWithLateIssues
&getroutinglist &delroutingmember &addroutingmember
&reorder_members
&check_routing &updateClaim
&CountIssues
HasItems
- &GetSubscriptionsFromBorrower
&subscriptionCurrentlyOnOrder
);
return $results;
}
-=head2 GetSerialStatusFromSerialId
-
-$sth = GetSerialStatusFromSerialId();
-this function returns a statement handle
-After this function, don't forget to execute it by using $sth->execute($serialid)
-return :
-$sth = $dbh->prepare($query).
-
-=cut
-
-sub GetSerialStatusFromSerialId {
- my $dbh = C4::Context->dbh;
- my $query = qq|
- SELECT status
- FROM serial
- WHERE serialid = ?
- |;
- return $dbh->prepare($query);
-}
-
=head2 GetSerialInformation
$data = GetSerialInformation($serialid);
$subs = GetSubscription($subscriptionid)
this function returns the subscription which has $subscriptionid as id.
return :
-a hashref. This hash containts
+a hashref. This hash contains
subscription, subscriptionhistory, aqbooksellers.name, biblio.title
=cut
$sth->execute($subscriptionid);
my $subscription = $sth->fetchrow_hashref;
+ return unless $subscription;
+
$subscription->{cannotedit} = not can_edit_subscription( $subscription );
- # Add additional fields to the subscription into a new key "additional_fields"
- my $additional_field_values = Koha::AdditionalField->fetch_all_values({
- tablename => 'subscription',
- record_id => $subscriptionid,
- });
- $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
+ if ( my $mana_id = $subscription->{mana_id} ) {
+ my $mana_subscription = Koha::SharedContent::get_entity_by_id(
+ 'subscription', $mana_id, {usecomments => 1});
+ $subscription->{comments} = $mana_subscription->{data}->{comments};
+ }
return $subscription;
}
serial.publisheddatetext,
serial.status,
serial.notes as notes,
- year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
+ year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year,
aqbooksellers.name as aqbooksellername,
biblio.title as bibliotitle,
subscription.branchcode AS branchcode,
LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber
WHERE serial.subscriptionid = ?
ORDER BY year DESC,
- IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate) DESC,
+ IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC,
serial.subscriptionid
|;
$debug and warn "GetFullSubscription query: $query";
my $sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
my $subscriptions = $sth->fetchall_arrayref( {} );
- for my $subscription ( @$subscriptions ) {
- $subscription->{cannotedit} = not can_edit_subscription( $subscription );
+ if (scalar @$subscriptions) {
+ my $cannotedit = not can_edit_subscription( $subscriptions->[0] );
+ for my $subscription ( @$subscriptions ) {
+ $subscription->{cannotedit} = $cannotedit;
+ }
}
+
return $subscriptions;
}
my $year;
my @res;
my $startdate;
- my $aqbooksellername;
- my $bibliotitle;
- my @loopissues;
my $first;
my $previousnote = "";
while ( my $subs = $sth->fetchrow_hashref ) {
$subs->{startdate} = output_pref( { dt => dt_from_string( $subs->{startdate} ), dateonly => 1 } );
$subs->{histstartdate} = output_pref( { dt => dt_from_string( $subs->{histstartdate} ), dateonly => 1 } );
- $subs->{histenddate} = output_pref( { dt => dt_from_string( $subs->{histenddate} ), dateonly => 1 } );
- $subs->{opacnote} =~ s/\n/\<br\/\>/g;
- $subs->{missinglist} =~ s/\n/\<br\/\>/g;
- $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
+ if ( defined $subs->{histenddate} ) {
+ $subs->{histenddate} = output_pref( { dt => dt_from_string( $subs->{histenddate} ), dateonly => 1 } );
+ } else {
+ $subs->{histenddate} = "";
+ }
+ $subs->{opacnote} //= "";
$subs->{ "periodicity" . $subs->{periodicity} } = 1;
$subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
$subs->{ "status" . $subs->{'status'} } = 1;
- if ( $subs->{enddate} eq '0000-00-00' ) {
+ if (not defined $subs->{enddate} ) {
$subs->{enddate} = '';
} else {
$subs->{enddate} = output_pref( { dt => dt_from_string( $subs->{enddate}), dateonly => 1 } );
serial.publisheddatetext,
serial.status,
serial.notes as notes,
- year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
+ year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year,
biblio.title as bibliotitle,
subscription.branchcode AS branchcode,
subscription.subscriptionid AS subscriptionid
LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber
WHERE subscription.biblionumber = ?
ORDER BY year DESC,
- IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate) DESC,
+ IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC,
serial.subscriptionid
|;
my $sth = $dbh->prepare($query);
$sth->execute($biblionumber);
my $subscriptions = $sth->fetchall_arrayref( {} );
- for my $subscription ( @$subscriptions ) {
- $subscription->{cannotedit} = not can_edit_subscription( $subscription );
+ if (scalar @$subscriptions) {
+ my $cannotedit = not can_edit_subscription( $subscriptions->[0] );
+ for my $subscription ( @$subscriptions ) {
+ $subscription->{cannotedit} = $cannotedit;
+ }
}
+
return $subscriptions;
}
my $additional_fields = $args->{additional_fields} // [];
my $matching_record_ids_for_additional_fields = [];
if ( @$additional_fields ) {
- $matching_record_ids_for_additional_fields = Koha::AdditionalField->get_matching_record_ids({
- fields => $additional_fields,
- tablename => 'subscription',
- exact_match => 0,
- });
- return () unless @$matching_record_ids_for_additional_fields;
+ my @subscriptions = Koha::Subscriptions->filter_by_additional_fields($additional_fields);
+
+ return () unless @subscriptions;
+
+ $matching_record_ids_for_additional_fields = [ map {
+ $_->subscriptionid
+ } @subscriptions ];
}
my $query = q|
$subscription->{cannotedit} = not can_edit_subscription( $subscription );
$subscription->{cannotdisplay} = not can_show_subscription( $subscription );
- my $additional_field_values = Koha::AdditionalField->fetch_all_values({
- record_id => $subscription->{subscriptionid},
- tablename => 'subscription'
- });
- $subscription->{additional_fields} = $additional_field_values->{$subscription->{subscriptionid}};
+ my $subscription_object = Koha::Subscriptions->find($subscription->{subscriptionid});
+ $subscription->{additional_fields} = { map { $_->field->name => $_->value }
+ $subscription_object->additional_field_values->as_list };
+
}
return @$results;
publisheddatetext, planneddate,notes, routingnotes
FROM serial
WHERE subscriptionid = ? AND status NOT IN ( $statuses )
- ORDER BY IF(publisheddate<>'0000-00-00',publisheddate,planneddate) DESC";
+ ORDER BY IF(publisheddate IS NULL,planneddate,publisheddate) DESC";
my $sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
FROM serial
WHERE subscriptionid = ?
AND status IN ( $statuses )
- ORDER BY IF(publisheddate<>'0000-00-00',publisheddate,planneddate) DESC
+ ORDER BY IF(publisheddate IS NULL,planneddate,publisheddate) DESC
";
$sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
return unless ($subscription and @$statuses);
- my $statuses_string = join ',', @$statuses;
-
my $dbh = C4::Context->dbh;
- my $query = qq|
+ my $query = q|
SELECT serialid,serialseq, status, planneddate, publisheddate,
publisheddatetext, notes, routingnotes
FROM serial
- WHERE subscriptionid=$subscription AND status IN ($statuses_string)
+ WHERE subscriptionid=?
+ |
+ . q| AND status IN (| . join( ",", ('?') x @$statuses ) . q|)|
+ . q|
ORDER BY publisheddate,serialid DESC
- |;
+ |;
$debug and warn "GetSerials2 query: $query";
my $sth = $dbh->prepare($query);
- $sth->execute;
+ $sth->execute( $subscription, @$statuses );
my @serials;
while ( my $line = $sth->fetchrow_hashref ) {
my @serials;
while ( my $line = $sth->fetchrow_hashref ) {
$line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list
- $line->{planneddate} = output_pref( { dt => dt_from_string( $line->{planneddate} ), dateonly => 1 } );
- $line->{publisheddate} = output_pref( { dt => dt_from_string( $line->{publisheddate} ), dateonly => 1 } );
push @serials, $line;
}
return $return;
}
-
-
-=head2 GetDistributedTo
-
-$distributedto=GetDistributedTo($subscriptionid)
-This function returns the field distributedto for the subscription matching subscriptionid
-
-=cut
-
-sub GetDistributedTo {
- my $dbh = C4::Context->dbh;
- my $distributedto;
- my ($subscriptionid) = @_;
-
- return unless ($subscriptionid);
-
- my $query = "SELECT distributedto FROM subscription WHERE subscriptionid=?";
- my $sth = $dbh->prepare($query);
- $sth->execute($subscriptionid);
- return ($distributedto) = $sth->fetchrow;
-}
-
=head2 GetNextSeq
my (
$nextseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
$newinnerloop1, $newinnerloop2, $newinnerloop3
- ) = GetNextSeq( $subscription, $pattern, $planneddate );
+ ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate );
$subscription is a hashref containing all the attributes of the table
'subscription'.
$pattern is a hashref containing all the attributes of the table
'subscription_numberpatterns'.
+$frequency is a hashref containing all the attributes of the table 'subscription_frequencies'
$planneddate is a date string in iso format.
This function get the next issue for the subscription given on input arg
=cut
sub GetNextSeq {
- my ($subscription, $pattern, $planneddate) = @_;
+ my ($subscription, $pattern, $frequency, $planneddate) = @_;
return unless ($subscription and $pattern);
if(@irreg > 0) {
my $irregularities = {};
$irregularities->{$_} = 1 foreach(@irreg);
- my $issueno = GetFictiveIssueNumber($subscription, $planneddate) + 1;
+ my $issueno = GetFictiveIssueNumber($subscription, $planneddate, $frequency) + 1;
while($irregularities->{$issueno}) {
$count++;
$issueno++;
#calculate the date of the last issue.
for ( my $i = 1 ; $i <= $length ; $i++ ) {
- $enddate = GetNextDate( $subscription, $enddate );
+ $enddate = GetNextDate( $subscription, $enddate, $frequency );
}
} elsif ( $subscription->{monthlength} ) {
if ( $$subscription{startdate} ) {
#It is a usual serial
# 1st, get previous status :
my $dbh = C4::Context->dbh;
- my $query = "SELECT serial.subscriptionid,serial.status,subscription.periodicity
+ my $query = "SELECT serial.subscriptionid,serial.status,subscription.periodicity,serial.routingnotes
FROM serial, subscription
WHERE serial.subscriptionid=subscription.subscriptionid
AND serialid=?";
my $sth = $dbh->prepare($query);
$sth->execute($serialid);
- my ( $subscriptionid, $oldstatus, $periodicity ) = $sth->fetchrow;
+ my ( $subscriptionid, $oldstatus, $periodicity, $routingnotes ) = $sth->fetchrow;
my $frequency = GetSubscriptionFrequency($periodicity);
# change status & update subscriptionhistory
if ( $status == DELETED ) {
DelIssue( { 'serialid' => $serialid, 'subscriptionid' => $subscriptionid, 'serialseq' => $serialseq } );
} else {
-
my $query = '
UPDATE serial
SET serialseq = ?, publisheddate = ?, publisheddatetext = ?,
- planneddate = ?, status = ?, notes = ?
+ planneddate = ?, status = ?, notes = ?, routingnotes = ?
WHERE serialid = ?
';
$sth = $dbh->prepare($query);
$sth->execute( $serialseq, $publisheddate, $publisheddatetext,
- $planneddate, $status, $notes, $serialid );
+ $planneddate, $status, $notes, $routingnotes, $serialid );
$query = "SELECT * FROM subscription WHERE subscriptionid = ?";
$sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
my ( $missinglist, $recievedlist ) = $sth->fetchrow;
if ( $status == ARRIVED || ($oldstatus == ARRIVED && $status != ARRIVED) ) {
- $recievedlist .= "; $serialseq"
- if ($recievedlist !~ /(^|;)\s*$serialseq(?=;|$)/);
+ $recievedlist = _handle_seqno($serialseq, $recievedlist);
}
# in case serial has been previously marked as missing
if (grep /$status/, (EXPECTED, ARRIVED, LATE, CLAIMED)) {
- $missinglist=~ s/(^|;)\s*$serialseq(?=;|$)//g;
+ $missinglist = _handle_seqno($serialseq, $missinglist, 'REMOVE');
}
- $missinglist .= "; $serialseq"
- if ( ( grep { $_ == $status } ( MISSING_STATUSES ) ) && ( $missinglist !~/(^|;)\s*$serialseq(?=;|$)/ ) );
- $missinglist .= "; not issued $serialseq"
- if ( $status == NOT_ISSUED && $missinglist !~ /(^|;)\s*$serialseq(?=;|$)/ );
+ $missinglist = _handle_seqno($serialseq, $missinglist) if grep { $_ == $status } MISSING_STATUSES;
+ $missinglist .= "; not issued $serialseq" if $status == NOT_ISSUED and not _handle_seqno($serialseq, $missinglist, 'CHECK');
$query = "UPDATE subscriptionhistory SET recievedlist=?, missinglist=? WHERE subscriptionid=?";
$sth = $dbh->prepare($query);
if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) {
my $subscription = GetSubscription($subscriptionid);
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
+ my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
# next issue number
my (
$newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
$newinnerloop1, $newinnerloop2, $newinnerloop3
)
- = GetNextSeq( $subscription, $pattern, $publisheddate );
+ = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate );
# next date (calculated from actual date & frequency parameters)
- my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1);
+ my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency, 1);
my $nextpubdate = $nextpublisheddate;
$query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
WHERE subscriptionid = ?";
$sth = $dbh->prepare($query);
$sth->execute( $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3, $subscriptionid );
-
- NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate );
-
+ my $newnote = C4::Context->preference('PreserveSerialNotes') ? $notes : "";
+ NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate, undef, $newnote, $routingnotes );
# check if an alert must be sent... (= a letter is defined & status became "arrived"
if ( $subscription->{letter} && $status == ARRIVED && $oldstatus != ARRIVED ) {
require C4::Letters;
return;
}
+sub _handle_seqno {
+# Adds or removes seqno from list when needed; returns list
+# Or checks and returns true when present
+
+ my ( $seq, $list, $op ) = @_; # op = ADD | REMOVE | CHECK (default: ADD)
+ my $seq_r = $seq;
+ $seq_r =~ s/([()])/\\$1/g; # Adjust disturbing parentheses for regex, maybe extend in future
+
+ if( !$op or $op eq 'ADD' ) {
+ $list .= "; $seq" if $list !~ /(^|;)\s*$seq_r(?=;|$)/;
+ } elsif( $op eq 'REMOVE' ) {
+ $list=~ s/(^|;)\s*(not issued )?$seq_r(?=;|$)//g;
+ } else { # CHECK
+ return $list =~ /(^|;)\s*$seq_r(?=;|$)/ ? 1 : q{};
+ }
+ return $list;
+}
+
=head2 GetNextExpected
$nextexpected = GetNextExpected($subscriptionid)
$biblionumber, $callnumber, $notes, $letter, $manualhistory,
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
- $itemtype, $previousitemtype
+ $itemtype, $previousitemtype, $mana_id
) = @_;
- my $dbh = C4::Context->dbh;
- my $query = "UPDATE subscription
- SET librarian=?, branchcode=?, aqbooksellerid=?, cost=?, aqbudgetid=?,
- startdate=?, periodicity=?, firstacquidate=?, irregularity=?,
- numberpattern=?, locale=?, numberlength=?, weeklength=?, monthlength=?,
- lastvalue1=?, innerloop1=?, lastvalue2=?, innerloop2=?,
- lastvalue3=?, innerloop3=?, status=?, biblionumber=?,
- callnumber=?, notes=?, letter=?, manualhistory=?,
- internalnotes=?, serialsadditems=?, staffdisplaycount=?,
- opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
- skip_serialseq=?, itemtype=?, previousitemtype=?
- WHERE subscriptionid = ?";
-
- my $sth = $dbh->prepare($query);
- $sth->execute(
- $auser, $branchcode, $aqbooksellerid, $cost,
- $aqbudgetid, $startdate, $periodicity, $firstacquidate,
- $irregularity, $numberpattern, $locale, $numberlength,
- $weeklength, $monthlength, $lastvalue1, $innerloop1,
- $lastvalue2, $innerloop2, $lastvalue3, $innerloop3,
- $status, $biblionumber, $callnumber, $notes,
- $letter, ($manualhistory ? $manualhistory : 0),
- $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
- $graceperiod, $location, $enddate, $skip_serialseq,
- $itemtype, $previousitemtype,
- $subscriptionid
- );
- my $rows = $sth->rows;
+ my $subscription = Koha::Subscriptions->find($subscriptionid);
+ $subscription->set(
+ {
+ librarian => $auser,
+ branchcode => $branchcode,
+ aqbooksellerid => $aqbooksellerid,
+ cost => $cost,
+ aqbudgetid => $aqbudgetid,
+ biblionumber => $biblionumber,
+ startdate => $startdate,
+ periodicity => $periodicity,
+ numberlength => $numberlength,
+ weeklength => $weeklength,
+ monthlength => $monthlength,
+ lastvalue1 => $lastvalue1,
+ innerloop1 => $innerloop1,
+ lastvalue2 => $lastvalue2,
+ innerloop2 => $innerloop2,
+ lastvalue3 => $lastvalue3,
+ innerloop3 => $innerloop3,
+ status => $status,
+ notes => $notes,
+ letter => $letter,
+ firstacquidate => $firstacquidate,
+ irregularity => $irregularity,
+ numberpattern => $numberpattern,
+ locale => $locale,
+ callnumber => $callnumber,
+ manualhistory => $manualhistory,
+ internalnotes => $internalnotes,
+ serialsadditems => $serialsadditems,
+ staffdisplaycount => $staffdisplaycount,
+ opacdisplaycount => $opacdisplaycount,
+ graceperiod => $graceperiod,
+ location => $location,
+ enddate => $enddate,
+ skip_serialseq => $skip_serialseq,
+ itemtype => $itemtype,
+ previousitemtype => $previousitemtype,
+ mana_id => $mana_id,
+ }
+ )->store;
logaction( "SERIAL", "MODIFY", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog");
- return $rows;
+
+ $subscription->discard_changes;
+ return $subscription;
}
=head2 NewSubscription
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
$numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
- $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype
+ $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id
) = @_;
my $dbh = C4::Context->dbh;
- #save subscription (insert into database)
- my $query = qq|
- INSERT INTO subscription
- (librarian, branchcode, aqbooksellerid, cost, aqbudgetid,
- biblionumber, startdate, periodicity, numberlength, weeklength,
- monthlength, lastvalue1, innerloop1, lastvalue2, innerloop2,
- lastvalue3, innerloop3, status, notes, letter, firstacquidate,
- irregularity, numberpattern, locale, callnumber,
- manualhistory, internalnotes, serialsadditems, staffdisplaycount,
- opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
- itemtype, previousitemtype)
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
- |;
- my $sth = $dbh->prepare($query);
- $sth->execute(
- $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
- $startdate, $periodicity, $numberlength, $weeklength,
- $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2,
- $lastvalue3, $innerloop3, $status, $notes, $letter,
- $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
- $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
- $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
- $itemtype, $previousitemtype
- );
-
- my $subscriptionid = $dbh->{'mysql_insertid'};
+ my $subscription = Koha::Subscription->new(
+ {
+ librarian => $auser,
+ branchcode => $branchcode,
+ aqbooksellerid => $aqbooksellerid,
+ cost => $cost,
+ aqbudgetid => $aqbudgetid,
+ biblionumber => $biblionumber,
+ startdate => $startdate,
+ periodicity => $periodicity,
+ numberlength => $numberlength,
+ weeklength => $weeklength,
+ monthlength => $monthlength,
+ lastvalue1 => $lastvalue1,
+ innerloop1 => $innerloop1,
+ lastvalue2 => $lastvalue2,
+ innerloop2 => $innerloop2,
+ lastvalue3 => $lastvalue3,
+ innerloop3 => $innerloop3,
+ status => $status,
+ notes => $notes,
+ letter => $letter,
+ firstacquidate => $firstacquidate,
+ irregularity => $irregularity,
+ numberpattern => $numberpattern,
+ locale => $locale,
+ callnumber => $callnumber,
+ manualhistory => $manualhistory,
+ internalnotes => $internalnotes,
+ serialsadditems => $serialsadditems,
+ staffdisplaycount => $staffdisplaycount,
+ opacdisplaycount => $opacdisplaycount,
+ graceperiod => $graceperiod,
+ location => $location,
+ enddate => $enddate,
+ skip_serialseq => $skip_serialseq,
+ itemtype => $itemtype,
+ previousitemtype => $previousitemtype,
+ mana_id => $mana_id,
+ }
+ )->store;
+ $subscription->discard_changes;
+ my $subscriptionid = $subscription->subscriptionid;
+ my ( $query, $sth );
unless ($enddate) {
$enddate = GetExpirationDate( $subscriptionid, $startdate );
$query = qq|
# then create the 1st expected number
$query = qq(
INSERT INTO subscriptionhistory
- (biblionumber, subscriptionid, histstartdate)
- VALUES (?,?,?)
+ (biblionumber, subscriptionid, histstartdate, missinglist, recievedlist)
+ VALUES (?,?,?, '', '')
);
$sth = $dbh->prepare($query);
$sth->execute( $biblionumber, $subscriptionid, $startdate);
# reread subscription to get a hash (for calculation of the 1st issue number)
- my $subscription = GetSubscription($subscriptionid);
+ $subscription = GetSubscription($subscriptionid); # We should not do that
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
# calculate issue number
logaction( "SERIAL", "ADD", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog");
#set serial flag on biblio if not already set.
- my $bib = GetBiblio($biblionumber);
- if ( $bib and !$bib->{'serial'} ) {
- my $record = GetMarcBiblio($biblionumber);
- my ( $tag, $subf ) = GetMarcFromKohaField( 'biblio.serial', $bib->{'frameworkcode'} );
+ my $biblio = Koha::Biblios->find( $biblionumber );
+ if ( $biblio and !$biblio->serial ) {
+ my $record = GetMarcBiblio({ biblionumber => $biblionumber });
+ my ( $tag, $subf ) = GetMarcFromKohaField( 'biblio.serial' );
if ($tag) {
eval { $record->field($tag)->update( $subf => 1 ); };
}
- ModBiblio( $record, $biblionumber, $bib->{'frameworkcode'} );
+ ModBiblio( $record, $biblionumber, $biblio->frameworkcode );
}
return $subscriptionid;
}
+=head2 GetSubscriptionLength
+
+my ($numberlength, $weeklength, $monthlength) = GetSubscriptionLength( $subtype, $sublength );
+
+This function calculates the subscription length.
+
+=cut
+
+sub GetSubscriptionLength {
+ my ($subtype, $length) = @_;
+
+ return unless looks_like_number($length);
+
+ return
+ (
+ $subtype eq 'issues' ? $length : 0,
+ $subtype eq 'weeks' ? $length : 0,
+ $subtype eq 'months' ? $length : 0,
+ );
+}
+
+
=head2 ReNewSubscription
-ReNewSubscription($subscriptionid,$user,$startdate,$numberlength,$weeklength,$monthlength,$note)
+ReNewSubscription($params);
+
+$params is a hashref with the following keys: subscriptionid, user, startdate, numberlength, weeklength, monthlength, note, branchcode
this function renew a subscription with values given on input args.
=cut
sub ReNewSubscription {
- my ( $subscriptionid, $user, $startdate, $numberlength, $weeklength, $monthlength, $note ) = @_;
+ my ( $params ) = @_;
+ my $subscriptionid = $params->{subscriptionid};
+ my $user = $params->{user};
+ my $startdate = $params->{startdate};
+ my $numberlength = $params->{numberlength};
+ my $weeklength = $params->{weeklength};
+ my $monthlength = $params->{monthlength};
+ my $note = $params->{note};
+ my $branchcode = $params->{branchcode};
+
my $dbh = C4::Context->dbh;
my $subscription = GetSubscription($subscriptionid);
my $query = qq|
'title' => $subscription->{bibliotitle},
'author' => $biblio->{author},
'publishercode' => $biblio->{publishercode},
- 'note' => $biblio->{note},
- 'biblionumber' => $subscription->{biblionumber}
+ 'note' => $note,
+ 'biblionumber' => $subscription->{biblionumber},
+ 'branchcode' => $branchcode,
}
);
}
+ $numberlength ||= 0; # Should not we raise an exception instead?
+ $weeklength ||= 0;
+
# renew subscription
$query = qq|
UPDATE subscription
|;
$sth = $dbh->prepare($query);
$sth->execute( $enddate, $subscriptionid );
- $query = qq|
- UPDATE subscriptionhistory
- SET histenddate=?
- WHERE subscriptionid=?
- |;
- $sth = $dbh->prepare($query);
- $sth->execute( $enddate, $subscriptionid );
logaction( "SERIAL", "RENEW", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog");
return;
=head2 NewIssue
-NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes)
+NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes, $routingnotes)
Create a new issue stored on the database.
Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription.
sub NewIssue {
my ( $serialseq, $subscriptionid, $biblionumber, $status, $planneddate,
- $publisheddate, $publisheddatetext, $notes ) = @_;
+ $publisheddate, $publisheddatetext, $notes, $routingnotes ) = @_;
### FIXME biblionumber CAN be provided by subscriptionid. So Do we STILL NEED IT ?
return unless ($subscriptionid);
publisheddate => $publisheddate,
publisheddatetext => $publisheddatetext,
notes => $notes,
+ routingnotes => $routingnotes
}
)->store();
### Would use substr and index But be careful to previous presence of ()
$recievedlist .= "; $serialseq" unless ( index( $recievedlist, $serialseq ) > 0 );
}
- if ( grep { /^$status$/ } (MISSING_STATUSES) ) {
+ if ( grep { $_ eq $status } (MISSING_STATUSES) ) {
$missinglist .= "; $serialseq" unless ( index( $missinglist, $serialseq ) > 0 );
}
return 0; # Notice that you'll never get here.
}
-=head2 SetDistributedto
-
-SetDistributedto($distributedto,$subscriptionid);
-This function update the value of distributedto for a subscription given on input arg.
-
-=cut
-
-sub SetDistributedto {
- my ( $distributedto, $subscriptionid ) = @_;
- my $dbh = C4::Context->dbh;
- my $query = qq|
- UPDATE subscription
- SET distributedto=?
- WHERE subscriptionid=?
- |;
- my $sth = $dbh->prepare($query);
- $sth->execute( $distributedto, $subscriptionid );
- return;
-}
-
=head2 DelSubscription
DelSubscription($subscriptionid)
my ($subscriptionid) = @_;
my $dbh = C4::Context->dbh;
$dbh->do("DELETE FROM subscription WHERE subscriptionid=?", undef, $subscriptionid);
- $dbh->do("DELETE FROM subscriptionhistory WHERE subscriptionid=?", undef, $subscriptionid);
- $dbh->do("DELETE FROM serial WHERE subscriptionid=?", undef, $subscriptionid);
- my $afs = Koha::AdditionalField->all({tablename => 'subscription'});
- foreach my $af (@$afs) {
- $af->delete_values({record_id => $subscriptionid});
- }
+ Koha::AdditionalFieldValues->search({
+ 'field.tablename' => 'subscription',
+ 'me.record_id' => $subscriptionid,
+ }, { join => 'field' })->delete;
logaction( "SERIAL", "DELETE", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog");
}
}
$line->{"status".$line->{status}} = 1;
- my $additional_field_values = Koha::AdditionalField->fetch_all_values({
- record_id => $line->{subscriptionid},
- tablename => 'subscription'
- });
- %$line = ( %$line, additional_fields => $additional_field_values->{$line->{subscriptionid}} );
+ my $subscription_object = Koha::Subscriptions->find($line->{subscriptionid});
+ $line->{additional_fields} = { map { $_->field->name => $_->value }
+ $subscription_object->additional_field_values->as_list };
push @issuelist, $line;
}
{}, CLAIMED, @$serialids );
}
-=head2 getsupplierbyserialid
-
-$result = getsupplierbyserialid($serialid)
-
-this function is used to find the supplier id given a serial id
-
-return :
-hashref containing serialid, subscriptionid, and aqbooksellerid
-
-=cut
-
-sub getsupplierbyserialid {
- my ($serialid) = @_;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare(
- "SELECT serialid, serial.subscriptionid, aqbooksellerid
- FROM serial
- LEFT JOIN subscription ON serial.subscriptionid = subscription.subscriptionid
- WHERE serialid = ?
- "
- );
- $sth->execute($serialid);
- my $line = $sth->fetchrow_hashref;
- my $result = $line->{'aqbooksellerid'};
- return $result;
-}
-
=head2 check_routing
$result = &check_routing($subscriptionid)
my $sth = $dbh->prepare(
"SELECT count(routingid) routingids FROM subscription LEFT JOIN subscriptionroutinglist
ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid
- WHERE subscription.subscriptionid = ? ORDER BY ranking ASC
+ WHERE subscription.subscriptionid = ? GROUP BY routingid ORDER BY ranking ASC
"
);
$sth->execute($subscriptionid);
my $expirationdate = GetExpirationDate($subscriptionid);
my ($res) = $dbh->selectrow_array('select max(planneddate) from serial where subscriptionid = ?', undef, $subscriptionid);
- my $nextdate = GetNextDate($subscription, $res);
+ my $nextdate = GetNextDate($subscription, $res, $frequency);
# only compare dates if both dates exist.
if ($nextdate and $expirationdate) {
}
}
- } elsif ($subscription->{numberlength}>0) {
+ } elsif ( $subscription->{numberlength} && $subscription->{numberlength}>0) {
return (countissuesfrom($subscriptionid,$subscription->{'startdate'}) >=$subscription->{numberlength}-1);
}
return 0;
}
-sub in_array { # used in next sub down
- my ( $val, @elements ) = @_;
- foreach my $elem (@elements) {
- if ( $val == $elem ) {
- return 1;
- }
- }
- return 0;
-}
-
-=head2 GetSubscriptionsFromBorrower
-
-($count,@routinglist) = GetSubscriptionsFromBorrower($borrowernumber)
-
-this gets the info from subscriptionroutinglist for each $subscriptionid
-
-return :
-a count of the serial subscription routing lists to which a patron belongs,
-with the titles of those serial subscriptions as an array. Each element of the array
-contains a hash_ref with subscriptionID and title of subscription.
-
-=cut
-
-sub GetSubscriptionsFromBorrower {
- my ($borrowernumber) = @_;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare(
- "SELECT subscription.subscriptionid, biblio.title
- FROM subscription
- JOIN biblio ON biblio.biblionumber = subscription.biblionumber
- JOIN subscriptionroutinglist USING (subscriptionid)
- WHERE subscriptionroutinglist.borrowernumber = ? ORDER BY title ASC
- "
- );
- $sth->execute($borrowernumber);
- my @routinglist;
- my $count = 0;
- while ( my $line = $sth->fetchrow_hashref ) {
- $count++;
- push( @routinglist, $line );
- }
- return ( $count, @routinglist );
-}
-
-
=head2 GetFictiveIssueNumber
-$issueno = GetFictiveIssueNumber($subscription, $publishedate);
+$issueno = GetFictiveIssueNumber($subscription, $publishedate, $frequency);
Get the position of the issue published at $publisheddate, considering the
first issue (at firstacquidate) is at position 1, the next is at position 2, etc...
The issue number calculation is based on subscription frequency, first acquisition
date, and $publisheddate.
+Returns undef when called for irregular frequencies.
+
+The routine is used to skip irregularities when calculating the next issue
+date (in GetNextDate) or the next issue number (in GetNextSeq).
+
=cut
sub GetFictiveIssueNumber {
- my ($subscription, $publisheddate) = @_;
+ my ($subscription, $publisheddate, $frequency) = @_;
- my $frequency = GetSubscriptionFrequency($subscription->{'periodicity'});
my $unit = $frequency->{unit} ? lc $frequency->{'unit'} : undef;
- my $issueno = 0;
-
- if($unit) {
- my ($year, $month, $day) = split /-/, $publisheddate;
- my ($fa_year, $fa_month, $fa_day) = split /-/, $subscription->{'firstacquidate'};
- my $wkno;
- my $delta;
-
- if($unit eq 'day') {
- $delta = Delta_Days($fa_year, $fa_month, $fa_day, $year, $month, $day);
- } elsif($unit eq 'week') {
- ($wkno, $year) = Week_of_Year($year, $month, $day);
- my ($fa_wkno, $fa_yr) = Week_of_Year($fa_year, $fa_month, $fa_day);
- $delta = ($fa_yr == $year) ? ($wkno - $fa_wkno) : ( ($year-$fa_yr-1)*52 + (52-$fa_wkno+$wkno) );
- } elsif($unit eq 'month') {
- $delta = ($fa_year == $year)
- ? ($month - $fa_month)
- : ( ($year-$fa_year-1)*12 + (12-$fa_month+$month) );
- } elsif($unit eq 'year') {
- $delta = $year - $fa_year;
- }
- if($frequency->{'unitsperissue'} == 1) {
- $issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'};
- } else {
- # Assuming issuesperunit == 1
- $issueno = int( ($delta + $frequency->{'unitsperissue'}) / $frequency->{'unitsperissue'} );
- }
+ return if !$unit;
+ my $issueno;
+
+ my ( $year, $month, $day ) = split /-/, $publisheddate;
+ my ( $fa_year, $fa_month, $fa_day ) = split /-/, $subscription->{'firstacquidate'};
+ my $delta = _delta_units( [$fa_year, $fa_month, $fa_day], [$year, $month, $day], $unit );
+
+ if( $frequency->{'unitsperissue'} == 1 ) {
+ $issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'};
+ } else { # issuesperunit == 1
+ $issueno = 1 + int( $delta / $frequency->{'unitsperissue'} );
}
return $issueno;
}
+sub _delta_units {
+ my ( $date1, $date2, $unit ) = @_;
+ # date1 and date2 are array refs in the form [ yy, mm, dd ]
+
+ if( $unit eq 'day' ) {
+ return Delta_Days( @$date1, @$date2 );
+ } elsif( $unit eq 'week' ) {
+ return int( Delta_Days( @$date1, @$date2 ) / 7 );
+ }
+
+ # In case of months or years, this is a wrapper around N_Delta_YMD.
+ # Note that N_Delta_YMD returns 29 days between e.g. 22-2-72 and 22-3-72
+ # while we expect 1 month.
+ my @delta = N_Delta_YMD( @$date1, @$date2 );
+ if( $delta[2] > 27 ) {
+ # Check if we could add a month
+ my @jump = Add_Delta_YM( @$date1, $delta[0], 1 + $delta[1] );
+ if( Delta_Days( @jump, @$date2 ) >= 0 ) {
+ $delta[1]++;
+ }
+ }
+ if( $delta[1] >= 12 ) {
+ $delta[0]++;
+ $delta[1] -= 12;
+ }
+ # if unit is year, we only return full years
+ return $unit eq 'month' ? $delta[0] * 12 + $delta[1] : $delta[0];
+}
+
sub _get_next_date_day {
my ($subscription, $freqdata, $year, $month, $day) = @_;
- if ($subscription->{countissuesperunit} + 1 > $freqdata->{issuesperunit}){
- ($year,$month,$day) = Add_Delta_Days($year,$month, $day , $freqdata->{unitsperissue} );
- $subscription->{countissuesperunit} = 1;
- } else {
+ my @newissue; # ( yy, mm, dd )
+ # We do not need $delta_days here, since it would be zero where used
+
+ if( $freqdata->{issuesperunit} == 1 ) {
+ # Add full days
+ @newissue = Add_Delta_Days(
+ $year, $month, $day, $freqdata->{"unitsperissue"} );
+ } elsif ( $subscription->{countissuesperunit} < $freqdata->{issuesperunit} ) {
+ # Add zero days
+ @newissue = ( $year, $month, $day );
$subscription->{countissuesperunit}++;
+ } else {
+ # We finished a cycle of issues within a unit.
+ # No subtraction of zero needed, just add one day
+ @newissue = Add_Delta_Days( $year, $month, $day, 1 );
+ $subscription->{countissuesperunit} = 1;
}
-
- return ($year, $month, $day);
+ return @newissue;
}
sub _get_next_date_week {
my ($subscription, $freqdata, $year, $month, $day) = @_;
- my ($wkno, $yr) = Week_of_Year($year, $month, $day);
- my $fa_dow = Day_of_Week(split /-/, $subscription->{firstacquidate});
+ my @newissue; # ( yy, mm, dd )
+ my $delta_days = int( 7 / $freqdata->{issuesperunit} );
- if ($subscription->{countissuesperunit} + 1 > $freqdata->{issuesperunit}){
- $subscription->{countissuesperunit} = 1;
- $wkno += $freqdata->{unitsperissue};
- if($wkno > 52){
- $wkno = $wkno % 52;
- $yr++;
- }
- ($year,$month,$day) = Monday_of_Week($wkno, $yr);
- ($year,$month,$day) = Add_Delta_Days($year, $month, $day, $fa_dow - 1);
- } else {
- # Try to guess the next day of week
- my $delta_days = int((7 - ($fa_dow - 1)) / $freqdata->{issuesperunit});
- ($year,$month,$day) = Add_Delta_Days($year, $month, $day, $delta_days);
+ if( $freqdata->{issuesperunit} == 1 ) {
+ # Add full weeks (of 7 days)
+ @newissue = Add_Delta_Days(
+ $year, $month, $day, 7 * $freqdata->{"unitsperissue"} );
+ } elsif ( $subscription->{countissuesperunit} < $freqdata->{issuesperunit} ) {
+ # Add rounded number of days based on frequency.
+ @newissue = Add_Delta_Days( $year, $month, $day, $delta_days );
$subscription->{countissuesperunit}++;
+ } else {
+ # We finished a cycle of issues within a unit.
+ # Subtract delta * (issues - 1), add 1 week
+ @newissue = Add_Delta_Days( $year, $month, $day,
+ -$delta_days * ($freqdata->{issuesperunit} - 1) );
+ @newissue = Add_Delta_Days( @newissue, 7 );
+ $subscription->{countissuesperunit} = 1;
}
-
- return ($year, $month, $day);
+ return @newissue;
}
sub _get_next_date_month {
my ($subscription, $freqdata, $year, $month, $day) = @_;
- my $fa_day;
- (undef, undef, $fa_day) = split /-/, $subscription->{firstacquidate};
+ my @newissue; # ( yy, mm, dd )
+ my $delta_days = int( 30 / $freqdata->{issuesperunit} );
- if ($subscription->{countissuesperunit} + 1 > $freqdata->{issuesperunit}){
- $subscription->{countissuesperunit} = 1;
- ($year,$month,$day) = Add_Delta_YM($year,$month,$day, 0,
- $freqdata->{unitsperissue});
- my $days_in_month = Days_in_Month($year, $month);
- $day = $fa_day <= $days_in_month ? $fa_day : $days_in_month;
- } else {
- # Try to guess the next day in month
- my $days_in_month = Days_in_Month($year, $month);
- my $delta_days = int(($days_in_month - ($fa_day - 1)) / $freqdata->{issuesperunit});
- ($year,$month,$day) = Add_Delta_Days($year, $month, $day, $delta_days);
+ if( $freqdata->{issuesperunit} == 1 ) {
+ # Add full months
+ @newissue = Add_Delta_YM(
+ $year, $month, $day, 0, $freqdata->{"unitsperissue"} );
+ } elsif ( $subscription->{countissuesperunit} < $freqdata->{issuesperunit} ) {
+ # Add rounded number of days based on frequency.
+ @newissue = Add_Delta_Days( $year, $month, $day, $delta_days );
$subscription->{countissuesperunit}++;
+ } else {
+ # We finished a cycle of issues within a unit.
+ # Subtract delta * (issues - 1), add 1 month
+ @newissue = Add_Delta_Days( $year, $month, $day,
+ -$delta_days * ($freqdata->{issuesperunit} - 1) );
+ @newissue = Add_Delta_YM( @newissue, 0, 1 );
+ $subscription->{countissuesperunit} = 1;
}
-
- return ($year, $month, $day);
+ return @newissue;
}
sub _get_next_date_year {
my ($subscription, $freqdata, $year, $month, $day) = @_;
- my ($fa_year, $fa_month, $fa_day) = split /-/, $subscription->{firstacquidate};
+ my @newissue; # ( yy, mm, dd )
+ my $delta_days = int( 365 / $freqdata->{issuesperunit} );
- if ($subscription->{countissuesperunit} + 1 > $freqdata->{issuesperunit}){
- $subscription->{countissuesperunit} = 1;
- ($year) = Add_Delta_YM($year,$month,$day, $freqdata->{"unitsperissue"},0);
- $month = $fa_month;
- my $days_in_month = Days_in_Month($year, $month);
- $day = $fa_day <= $days_in_month ? $fa_day : $days_in_month;
- } else {
- # Try to guess the next day in year
- my $days_in_year = Days_in_Year($year,12); #Sum the days of all the months of this year
- my $delta_days = int(($days_in_year - ($fa_day - 1)) / $freqdata->{issuesperunit});
- ($year,$month,$day) = Add_Delta_Days($year, $month, $day, $delta_days);
+ if( $freqdata->{issuesperunit} == 1 ) {
+ # Add full years
+ @newissue = Add_Delta_YM( $year, $month, $day, $freqdata->{"unitsperissue"}, 0 );
+ } elsif ( $subscription->{countissuesperunit} < $freqdata->{issuesperunit} ) {
+ # Add rounded number of days based on frequency.
+ @newissue = Add_Delta_Days( $year, $month, $day, $delta_days );
$subscription->{countissuesperunit}++;
+ } else {
+ # We finished a cycle of issues within a unit.
+ # Subtract delta * (issues - 1), add 1 year
+ @newissue = Add_Delta_Days( $year, $month, $day, -$delta_days * ($freqdata->{issuesperunit} - 1) );
+ @newissue = Add_Delta_YM( @newissue, 1, 0 );
+ $subscription->{countissuesperunit} = 1;
}
-
- return ($year, $month, $day);
+ return @newissue;
}
=head2 GetNextDate
-$resultdate = GetNextDate($publisheddate,$subscription)
+$resultdate = GetNextDate($publisheddate,$subscription,$freqdata,$updatecount)
this function it takes the publisheddate and will return the next issue's date
and will skip dates if there exists an irregularity.
$publisheddate has to be an ISO date
-$subscription is a hashref containing at least 'periodicity', 'firstacquidate', 'irregularity', and 'countissuesperunit'
+$subscription is a hashref containing at least 'firstacquidate', 'irregularity', and 'countissuesperunit'
+$frequency is a hashref containing frequency informations
$updatecount is a boolean value which, when set to true, update the 'countissuesperunit' in database
- eg if periodicity is monthly and $publisheddate is 2007-02-10 but if March and April is to be
skipped then the returned date will be 2007-05-10
=cut
sub GetNextDate {
- my ( $subscription, $publisheddate, $updatecount ) = @_;
+ my ( $subscription, $publisheddate, $freqdata, $updatecount ) = @_;
return unless $subscription and $publisheddate;
- my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
if ($freqdata->{'unit'}) {
my ( $year, $month, $day ) = split /-/, $publisheddate;
# Get the 'fictive' next issue number
# It is used to check if next issue is an irregular issue.
- my $issueno = GetFictiveIssueNumber($subscription, $publisheddate) + 1;
+ my $issueno = GetFictiveIssueNumber($subscription, $publisheddate, $freqdata) + 1;
# Then get the next date
my $unit = lc $freqdata->{'unit'};
-monthabrv
-season
-seasonabrv
-=cut
-#'
+=cut
sub _numeration {
my ($value, $num_type, $locale) = @_;
return $string;
}
-=head2 is_barcode_in_use
+=head2 CloseSubscription
-Returns number of occurrences of the barcode in the items table
-Can be used as a boolean test of whether the barcode has
-been deployed as yet
+Close a subscription given a subscriptionid
=cut
-sub is_barcode_in_use {
- my $barcode = shift;
- my $dbh = C4::Context->dbh;
- my $occurrences = $dbh->selectall_arrayref(
- 'SELECT itemnumber from items where barcode = ?',
- {}, $barcode
-
- );
-
- return @{$occurrences};
-}
-
-=head2 CloseSubscription
-Close a subscription given a subscriptionid
-=cut
sub CloseSubscription {
my ( $subscriptionid ) = @_;
return unless $subscriptionid;
}
=head2 ReopenSubscription
+
Reopen a subscription given a subscriptionid
+
=cut
+
sub ReopenSubscription {
my ( $subscriptionid ) = @_;
return unless $subscriptionid;