FROM subscription
LEFT JOIN serial ON serial.subscriptionid=subscription.subscriptionid
LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
- WHERE id > 0 AND ((planneddate < now() AND serial.status=1) OR serial.STATUS = 3 OR serial.STATUS = 4) ORDER BY name|;
+ WHERE id > 0
+ AND (
+ (planneddate < now() AND serial.status=1)
+ OR serial.STATUS = 3 OR serial.STATUS = 4
+ )
+ AND subscription.closed = 0
+ ORDER BY name|;
return $dbh->selectall_arrayref($query, { Slice => {} });
}
LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
WHERE ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3)
AND subscription.aqbooksellerid=?
+ AND subscription.closed = 0
ORDER BY title
|;
$sth = $dbh->prepare($query);
LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber
LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
WHERE ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3)
+ AND subscription.closed = 0
ORDER BY title
|;
$sth = $dbh->prepare($query);
=cut
-sub GetSubscriptionHistoryFromSubscriptionId() {
+sub GetSubscriptionHistoryFromSubscriptionId {
my $dbh = C4::Context->dbh;
my $query = qq|
SELECT *
=cut
-sub GetSerialStatusFromSerialId() {
+sub GetSerialStatusFromSerialId {
my $dbh = C4::Context->dbh;
my $query = qq|
SELECT status
push @where_args, $args->{biblionumber};
}
if( $args->{title} ){
- push @where_strs, "biblio.title LIKE ?";
- push @where_args, "%$args->{title}%";
+ my @words = split / /, $args->{title};
+ my (@strs, @args);
+ foreach my $word (@words) {
+ push @strs, "biblio.title LIKE ?";
+ push @args, "%$word%";
+ }
+ if (@strs) {
+ push @where_strs, '(' . join (' AND ', @strs) . ')';
+ push @where_args, @args;
+ }
}
if( $args->{issn} ){
push @where_strs, "biblioitems.issn LIKE ?";
push @where_strs, "subscription.branchcode = ?";
push @where_args, "$args->{branch}";
}
-
+ if( defined $args->{closed} ){
+ push @where_strs, "subscription.closed = ?";
+ push @where_args, "$args->{closed}";
+ }
if(@where_strs){
$query .= " WHERE " . join(" AND ", @where_strs);
}
=cut
-sub GetNextExpected($) {
+sub GetNextExpected {
my ($subscriptionid) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare('SELECT serialid, planneddate FROM serial WHERE subscriptionid=? AND status=?');
=cut
-sub ModNextExpected($$) {
+sub ModNextExpected {
my ( $subscriptionid, $date ) = @_;
my $dbh = C4::Context->dbh;
=cut
-sub GetNextDate(@) {
+sub GetNextDate {
my ( $planneddate, $subscription ) = @_;
my @irreg = split( /\,/, $subscription->{irregularity} );
return @{$occurences};
}
+=head2 CloseSubscription
+Close a subscription given a subscriptionid
+=cut
+sub CloseSubscription {
+ my ( $subscriptionid ) = @_;
+ return unless $subscriptionid;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare( qq{
+ UPDATE subscription
+ SET closed = 1
+ WHERE subscriptionid = ?
+ } );
+ $sth->execute( $subscriptionid );
+
+ # Set status = missing when status = stopped
+ $sth = $dbh->prepare( qq{
+ UPDATE serial
+ SET status = 8
+ WHERE subscriptionid = ?
+ AND status = 1
+ } );
+ $sth->execute( $subscriptionid );
+}
+
+=head2 ReopenSubscription
+Reopen a subscription given a subscriptionid
+=cut
+sub ReopenSubscription {
+ my ( $subscriptionid ) = @_;
+ return unless $subscriptionid;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare( qq{
+ UPDATE subscription
+ SET closed = 0
+ WHERE subscriptionid = ?
+ } );
+ $sth->execute( $subscriptionid );
+
+ # Set status = expected when status = stopped
+ $sth = $dbh->prepare( qq{
+ UPDATE serial
+ SET status = 1
+ WHERE subscriptionid = ?
+ AND status = 8
+ } );
+ $sth->execute( $subscriptionid );
+}
+
1;
__END__