X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FSerials.pm;h=0b31a2b143e3cf8e11a5381fd972e983f9d09349;hb=4dbd7c452878ef9eea411f54e3f90820bc8a3e1f;hp=cedbcfff867291906b757aaa4649b9a00a25c830;hpb=65be03846d064dd6d9e7159550a269a352054b65;p=koha.git diff --git a/C4/Serials.pm b/C4/Serials.pm index cedbcfff86..0b31a2b143 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -93,7 +93,13 @@ sub GetSuppliersWithLateIssues { 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 => {} }); } @@ -122,6 +128,7 @@ sub GetLateIssues { 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); @@ -134,6 +141,7 @@ sub GetLateIssues { 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); @@ -299,7 +307,7 @@ $subs = GetSubscription($subscriptionid) this function returns the subscription which has $subscriptionid as id. return : a hashref. This hash containts -subscription, subscriptionhistory, aqbudget.bookfundid, biblio.title +subscription, subscriptionhistory, aqbooksellers.name, biblio.title =cut @@ -662,8 +670,16 @@ sub SearchSubscriptions { 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 ?"; @@ -685,7 +701,10 @@ sub SearchSubscriptions { 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); } @@ -2465,6 +2484,54 @@ sub is_barcode_in_use { 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__