From b6d6b85c36e0b3d8e3811e76a097c69fba6bfd2a Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Fri, 9 May 2025 09:39:38 +0100 Subject: [PATCH] Bug 38061: Add a checkbox to determine whether collection table issues should be pre-selected Test plan: Apply the patches and update the database 1) Create a new subscription with items, there should be a checkbox at the bottom of the form to pre-select collection table issues - make sure this is checked 2) Receive some items against the subscription 3) Navigate to the collections table 4) The checkboxes should be pre-selected as per previous behaviour in Koha 5) Edit the subscription and uncheck the checkbox 6) Return to the collections table and the checkboxes should all be unchecked Signed-off-by: Nathalie --- C4/Serials.pm | 201 +++++++++--------- Koha/Schema/Result/Subscription.pm | 14 +- .../bug_38061-collections_preselect_column.pl | 19 ++ installer/data/mysql/kohastructure.sql | 1 + .../en/modules/serials/subscription-add.tt | 9 + serials/subscription-add.pl | 100 ++++----- 6 files changed, 198 insertions(+), 146 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_38061-collections_preselect_column.pl diff --git a/C4/Serials.pm b/C4/Serials.pm index 206bec0b81..8aad03b546 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -328,7 +328,8 @@ sub GetFullSubscription { aqbooksellers.name as aqbooksellername, biblio.title as bibliotitle, subscription.branchcode AS branchcode, - subscription.subscriptionid AS subscriptionid + subscription.subscriptionid AS subscriptionid, + subscription.preselect_issues_in_collections_table AS preselect_issues_in_collections_table FROM serial LEFT JOIN subscription ON (serial.subscriptionid=subscription.subscriptionid ) @@ -373,6 +374,11 @@ sub PrepareSerialsData { foreach my $subs ( @{$lines} ) { $subs->{ "status" . $subs->{'status'} } = 1; + if ( $subs->{preselect_issues_in_collections_table} && grep { $_ == $subs->{status} } + ( EXPECTED, LATE, MISSING_STATUSES, CLAIMED ) ) + { + $subs->{"checked"} = 1; + } if ($add_itemnumbers) { my $serialitem = Koha::Serial::Items->find( { serialid => $subs->{'serialid'} } ); $subs->{"itemnumber"} = $serialitem->itemnumber if $serialitem; @@ -470,7 +476,8 @@ sub GetFullSubscriptionsFromBiblionumber { biblio.title as bibliotitle, subscription.branchcode AS branchcode, subscription.subscriptionid AS subscriptionid, - subscription.location AS location + subscription.location AS location, + subscription.preselect_issues_in_collections_table AS preselect_issues_in_collections_table FROM serial LEFT JOIN subscription ON (serial.subscriptionid=subscription.subscriptionid) @@ -1341,58 +1348,59 @@ returns the number of rows affected sub ModSubscription { my ( - $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, - $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, - $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, - $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template + $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, + $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, + $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, + $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template, $preselect_issues_in_collections_table ) = @_; 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, - ccode => $ccode, - published_on_template => $published_on_template, + 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, + ccode => $ccode, + published_on_template => $published_on_template, + preselect_issues_in_collections_table => $preselect_issues_in_collections_table, } )->store; @@ -1425,58 +1433,59 @@ the id of this new subscription sub NewSubscription { my ( - $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, $mana_id, $ccode, - $published_on_template, + $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, $mana_id, $ccode, + $published_on_template, $preselect_issues_in_collections_table ) = @_; my $dbh = C4::Context->dbh; 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, - ccode => $ccode, - published_on_template => $published_on_template, + 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, + ccode => $ccode, + published_on_template => $published_on_template, + preselect_issues_in_collections_table => $preselect_issues_in_collections_table, } )->store; $subscription->discard_changes; diff --git a/Koha/Schema/Result/Subscription.pm b/Koha/Schema/Result/Subscription.pm index be2df21770..e8813da625 100644 --- a/Koha/Schema/Result/Subscription.pm +++ b/Koha/Schema/Result/Subscription.pm @@ -341,6 +341,14 @@ collection code to assign to serial items Template Toolkit syntax to generate the default "Published on (text)" field when receiving an issue this serial +=head2 preselect_issues_in_collections_table + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + +yes / no if the subscription should preselect issues in the collections table + =cut __PACKAGE__->add_columns( @@ -434,6 +442,8 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 80 }, "published_on_template", { data_type => "text", is_nullable => 1 }, + "preselect_issues_in_collections_table", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, ); =head1 PRIMARY KEY @@ -586,8 +596,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-11-11 14:57:59 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1Ht7Nfl870dv1NOs4vr04g +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-05-09 08:07:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TZz+AyW1pPFbUMdo2mneuw __PACKAGE__->has_many( "additional_field_values", diff --git a/installer/data/mysql/atomicupdate/bug_38061-collections_preselect_column.pl b/installer/data/mysql/atomicupdate/bug_38061-collections_preselect_column.pl new file mode 100755 index 0000000000..c741f7530b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_38061-collections_preselect_column.pl @@ -0,0 +1,19 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "38061", + description => + "Add a column to determine whether a subscription's issues should be preselected in the collections table", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + if ( !column_exists( 'subscription', 'preselect_issues_in_collections_table' ) ) { + $dbh->do( + q{ ALTER TABLE subscription ADD COLUMN `preselect_issues_in_collections_table` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'yes / no if the subscription should preselect issues in the collections table' AFTER published_on_template} + ); + say_success( $out, "Added column 'subscription.preselect_issues_in_collections_table'" ); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 5d7139383c..2c3bed4a70 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -6187,6 +6187,7 @@ CREATE TABLE `subscription` ( `mana_id` int(11) DEFAULT NULL, `ccode` varchar(80) DEFAULT NULL COMMENT 'collection code to assign to serial items', `published_on_template` text DEFAULT NULL COMMENT 'Template Toolkit syntax to generate the default "Published on (text)" field when receiving an issue this serial', + `preselect_issues_in_collections_table` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'yes / no if the subscription should preselect issues in the collections table', PRIMARY KEY (`subscriptionid`), KEY `subscription_ibfk_1` (`periodicity`), KEY `subscription_ibfk_2` (`numberpattern`), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index 1e62a1108e..e3c7386bb5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -286,6 +286,15 @@ [% END %] +
  • + + [% IF (preselect_issues_in_collections_table) %] + + [% ELSE %] + + [% END %] +
    Determines whether the checkboxes in the left hand column of the collections table will be automatically checked based on the issue's status.
    +
  • diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 8dff969978..020310d295 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -326,29 +326,30 @@ sub redirect_add_subscription { my $subtype = $query->param('subtype'); my $sublength = $query->param('sublength'); my ( $numberlength, $weeklength, $monthlength ) = GetSubscriptionLength( $subtype, $sublength ); - my $add1 = $query->param('add1'); - my $lastvalue1 = $query->param('lastvalue1'); - my $innerloop1 = $query->param('innerloop1'); - my $innerloop2 = $query->param('innerloop2'); - my $lastvalue2 = $query->param('lastvalue2'); - my $lastvalue3 = $query->param('lastvalue3'); - my $innerloop3 = $query->param('innerloop3'); - my $status = 1; - my $biblionumber = $query->param('biblionumber'); - my $callnumber = $query->param('callnumber'); - my $notes = $query->param('notes'); - my $internalnotes = $query->param('internalnotes'); - my $letter = $query->param('letter'); - my $manualhistory = $query->param('manualhist') ? 1 : 0; - my $serialsadditems = $query->param('serialsadditems'); - my $staffdisplaycount = $query->param('staffdisplaycount'); - my $opacdisplaycount = $query->param('opacdisplaycount'); - my $location = $query->param('location'); - my $itemtype = $query->param('itemtype'); - my $previousitemtype = $query->param('previousitemtype'); - my $skip_serialseq = $query->param('skip_serialseq'); - my $ccode = $query->param('ccode'); - my $published_on_template = $query->param('published_on_template'); + my $add1 = $query->param('add1'); + my $lastvalue1 = $query->param('lastvalue1'); + my $innerloop1 = $query->param('innerloop1'); + my $innerloop2 = $query->param('innerloop2'); + my $lastvalue2 = $query->param('lastvalue2'); + my $lastvalue3 = $query->param('lastvalue3'); + my $innerloop3 = $query->param('innerloop3'); + my $status = 1; + my $biblionumber = $query->param('biblionumber'); + my $callnumber = $query->param('callnumber'); + my $notes = $query->param('notes'); + my $internalnotes = $query->param('internalnotes'); + my $letter = $query->param('letter'); + my $manualhistory = $query->param('manualhist') ? 1 : 0; + my $serialsadditems = $query->param('serialsadditems'); + my $staffdisplaycount = $query->param('staffdisplaycount'); + my $opacdisplaycount = $query->param('opacdisplaycount'); + my $location = $query->param('location'); + my $itemtype = $query->param('itemtype'); + my $previousitemtype = $query->param('previousitemtype'); + my $skip_serialseq = $query->param('skip_serialseq'); + my $ccode = $query->param('ccode'); + my $published_on_template = $query->param('published_on_template'); + my $preselect_issues_in_collections_table = $query->param('preselect_issues_in_collections_table') ? 1 : 0; my $mana_id; if ( $query->param('mana_id') ne "" ) { @@ -376,7 +377,8 @@ sub redirect_add_subscription { join( ";", @irregularity ), $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, - $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template + $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template, + $preselect_issues_in_collections_table ); if ( ( C4::Context->preference('Mana') == 1 ) and ( grep { $_ eq "subscription" } split( /,/, C4::Context->preference('AutoShareWithMana') ) ) ) @@ -435,29 +437,30 @@ sub redirect_mod_subscription { my $subtype = $query->param('subtype'); my $sublength = $query->param('sublength'); my ( $numberlength, $weeklength, $monthlength ) = GetSubscriptionLength( $subtype, $sublength ); - my $locale = $query->param('locale'); - my $lastvalue1 = $query->param('lastvalue1'); - my $innerloop1 = $query->param('innerloop1'); - my $lastvalue2 = $query->param('lastvalue2'); - my $innerloop2 = $query->param('innerloop2'); - my $lastvalue3 = $query->param('lastvalue3'); - my $innerloop3 = $query->param('innerloop3'); - my $status = 1; - my $callnumber = $query->param('callnumber'); - my $notes = $query->param('notes'); - my $internalnotes = $query->param('internalnotes'); - my $letter = $query->param('letter'); - my $manualhistory = $query->param('manualhist') ? 1 : 0; - my $serialsadditems = $query->param('serialsadditems'); - my $staffdisplaycount = $query->param('staffdisplaycount'); - my $opacdisplaycount = $query->param('opacdisplaycount'); - my $graceperiod = $query->param('graceperiod') || 0; - my $location = $query->param('location'); - my $itemtype = $query->param('itemtype'); - my $previousitemtype = $query->param('previousitemtype'); - my $skip_serialseq = $query->param('skip_serialseq'); - my $ccode = $query->param('ccode'); - my $published_on_template = $query->param('published_on_template'); + my $locale = $query->param('locale'); + my $lastvalue1 = $query->param('lastvalue1'); + my $innerloop1 = $query->param('innerloop1'); + my $lastvalue2 = $query->param('lastvalue2'); + my $innerloop2 = $query->param('innerloop2'); + my $lastvalue3 = $query->param('lastvalue3'); + my $innerloop3 = $query->param('innerloop3'); + my $status = 1; + my $callnumber = $query->param('callnumber'); + my $notes = $query->param('notes'); + my $internalnotes = $query->param('internalnotes'); + my $letter = $query->param('letter'); + my $manualhistory = $query->param('manualhist') ? 1 : 0; + my $serialsadditems = $query->param('serialsadditems'); + my $staffdisplaycount = $query->param('staffdisplaycount'); + my $opacdisplaycount = $query->param('opacdisplaycount'); + my $graceperiod = $query->param('graceperiod') || 0; + my $location = $query->param('location'); + my $itemtype = $query->param('itemtype'); + my $previousitemtype = $query->param('previousitemtype'); + my $skip_serialseq = $query->param('skip_serialseq'); + my $ccode = $query->param('ccode'); + my $published_on_template = $query->param('published_on_template'); + my $preselect_issues_in_collections_table = $query->param('preselect_issues_in_collections_table') ? 1 : 0; my $mana_id; if ( $query->param('mana_id') ne "" ) { @@ -494,7 +497,8 @@ sub redirect_mod_subscription { $status, $biblionumber, $callnumber, $notes, $letter, $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid, - $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template + $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template, + $preselect_issues_in_collections_table ); my @additional_fields = -- 2.39.5