@@ -, +, @@ - close a subscriptionn - reopen a closed subscription - a new field subscription.closed in DB - a new status for serials (8 = stopped) - search subscriptions - close a subscription and check that you cannot receive or generate a new serial - launch another search and check that the closed serial is into the "closed" tab. - You are allowed to reopen a subscription on the subscription detail page and on the subscription result page. A javascript alert ask you if are certain to do this operation. - Check the serial status "stopped" everywhere the status is displayed (catalogue/detail.pl, serials/claims.pl, serials/serial-issues-full.pl, serials/serials-collection.pl, serials/serials-edit.pl, serials/serials-recieve.pl, serials/subscription-detail.pl and opac-full-serial-issues.pl) - The report statistics does not include the closed subscriptions if you don't check the "Include expired subscriptions" checkbox. - Show 'closed' information in biblio detail page - Add a column in serials report table - Search subscriptions on title words instead of string - Prevent serials editing when subscription is closed - Don't change status of "disabled" serials --- C4/Serials.pm | 75 +++++- catalogue/detail.pl | 2 + installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 11 +- .../prog/en/includes/serials-menu.inc | 2 + .../prog/en/includes/serials-toolbar.inc | 77 ++++-- .../prog/en/modules/catalogue/detail.tt | 26 +- .../prog/en/modules/reports/serials_stats.tt | 8 + .../prog/en/modules/serials/claims.tt | 2 + .../prog/en/modules/serials/serial-issues-full.tt | 14 +- .../prog/en/modules/serials/serials-collection.tt | 44 +++- .../prog/en/modules/serials/serials-edit.tt | 116 ++++----- .../prog/en/modules/serials/serials-recieve.tt | 3 + .../prog/en/modules/serials/serials-search.tt | 249 +++++++++++++------- .../prog/en/modules/serials/subscription-detail.tt | 42 ++-- koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 2 + .../prog/en/modules/opac-full-serial-issues.tt | 15 +- misc/cronjobs/serialsUpdate.pl | 1 + opac/opac-detail.pl | 2 + reports/serials_stats.pl | 14 +- serials/checkexpiration.pl | 1 + serials/serials-collection.pl | 3 + serials/serials-edit.pl | 1 + serials/serials-search.pl | 25 +- serials/subscription-detail.pl | 7 + 25 files changed, 512 insertions(+), 231 deletions(-) --- a/C4/Serials.pm +++ a/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); @@ -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__ --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -155,6 +155,8 @@ foreach my $subscription (@subscriptions) { $cell{branchcode} = $subscription->{branchcode}; $cell{branchname} = GetBranchName($subscription->{branchcode}); $cell{hasalert} = $subscription->{hasalert}; + $cell{callnumber} = $subscription->{callnumber}; + $cell{closed} = $subscription->{closed}; #get the three latest serials. $serials_to_display = $subscription->{staffdisplaycount}; $serials_to_display = C4::Context->preference('StaffSerialIssueDisplayCount') unless $serials_to_display; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -1920,6 +1920,7 @@ CREATE TABLE `subscription` ( `opacdisplaycount` VARCHAR(10) NULL, `graceperiod` int(11) NOT NULL default '0', `enddate` date default NULL, + `closed ` INT(1) NOT NULL DEFAULT 0, PRIMARY KEY (`subscriptionid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -6012,7 +6012,6 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } - $DBversion = "3.09.00.062"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $dbh->do("UPDATE systempreferences SET value=0 WHERE variable='NoZebra'"); @@ -6083,6 +6082,16 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.11.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do(qq{ + ALTER TABLE subscription ADD COLUMN closed INT(1) NOT NULL DEFAULT 0 AFTER enddate; + }); + + print "Upgrade to $DBversion done (Bug 8782: Add field subscription.closed)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc @@ -1,6 +1,7 @@ [% IF ( subscriptionid ) %]
This subscription is closed.
[% END %] + [% IF ( subscription.callnumber ) %]Callnumber: [% subscription.callnumber %]
[% END %] [% IF ( subscription.subscriptionnotes ) %][% subscription.subscriptionnotes FILTER html_line_break %]
[% END %] [% IF ( subscription.missinglist ) %]Missing issues: [% subscription.missinglist %]
[% END %] [% IF ( subscription.librariannote ) %]([% subscription.librariannote %])
[% END %] @@ -486,20 +488,16 @@ function verify_images() {- - [% IF ( subscriptions.size == 1 and !serialsadditems ) %] [% END %] + [% UNLESS subscription.closed %] + + [% IF ( subscriptions.size == 1 and !serialsadditems ) %] [% END %] + [% END %]
[% END %] @@ -234,7 +247,14 @@ $(document).ready(function() { [% serial.serialseq %]ISSN | -Title | -Notes | -Library | -Call number | -Expiration date | - [% IF ( routing && CAN_user_serials_routing ) %] -Routing list | - [% END %] -- | - | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
- | - | - | - | - | - [% IF ( routing && CAN_user_serials_routing ) %] | [% END %] - | - | - | ||||||||||||||||||||||||||||||||||||||||||||||||
- [% IF ( subscription.issn ) %][% subscription.issn %] - [% END %] - | -[% subscription.title |html %] - | -[% IF ( subscription.notes ) %][% subscription.notes %][% END %] - [% IF ( subscription.internalnotes ) %]([% subscription.internalnotes %])[% END %] - | -- [% IF ( subscription.branchname ) %][% subscription.branchname %][% END %] - | -- [% IF ( subscription.callnumber ) %][% subscription.callnumber %][% END %] - | -- [% IF ( subscription.enddate ) %][% subscription.enddate | $KohaDates %][% END %] - | - [% IF ( routing && CAN_user_serials_routing ) %] -
- [% IF ( subscription.cannotedit ) %]
-
- [% ELSE %]
- [% IF ( subscription.routingedit ) %]
- Edit
- ([% subscription.routingedit %])
- [% ELSE %]
- New
- [% END %]
+ [% IF ( total ) %]
+
+
+
+ [% IF openedsubscriptions %]
+
+
+ [% IF closedsubscriptions %]
+
|
This subscription is closed.
[% END %] + [% IF ( subscription.subscriptionnotes ) %][% subscription.subscriptionnotes FILTER html_line_break %]
[% END %]Subscription from: [% subscription.histstartdate | $KohaDates %] to:[% IF ( subscription.histenddate ) %] [% subscription.histenddate | $KohaDates %] [% ELSE %] now (current)[% END %]
[% IF ( subscription.missinglist ) %]Missing issues: [% subscription.missinglist %]
[% END %] --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-full-serial-issues.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-full-serial-issues.tt @@ -200,12 +200,15 @@ function showlayer(numlayer){