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 <nathalie.savarit@univ-amu.fr>
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Matt Blenkinsop 2024-10-02 10:54:50 +00:00 committed by Lucas Gass
parent 2894e34c1e
commit f5ede57411
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
6 changed files with 201 additions and 151 deletions

View File

@ -325,7 +325,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 )
@ -370,7 +371,9 @@ sub PrepareSerialsData {
foreach my $subs ( @{$lines} ) {
$subs->{ "status" . $subs->{'status'} } = 1;
if ( grep { $_ == $subs->{status} } ( EXPECTED, LATE, MISSING_STATUSES, CLAIMED ) ) {
if ( $subs->{preselect_issues_in_collections_table} && grep { $_ == $subs->{status} }
( EXPECTED, LATE, MISSING_STATUSES, CLAIMED ) )
{
$subs->{"checked"} = 1;
}
if ($add_itemnumbers) {
@ -470,7 +473,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)
@ -1343,58 +1347,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;
@ -1427,58 +1432,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;

View File

@ -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",
@ -604,10 +614,11 @@ __PACKAGE__->has_many(
);
__PACKAGE__->add_columns(
'+closed' => { is_boolean => 1 },
'+manualhistory' => { is_boolean => 1 },
'+serialsadditems' => { is_boolean => 1 },
'+skip_serialseq' => { is_boolean => 1 },
'+closed' => { is_boolean => 1 },
'+manualhistory' => { is_boolean => 1 },
'+serialsadditems' => { is_boolean => 1 },
'+skip_serialseq' => { is_boolean => 1 },
'+preselect_issues_in_collections_table' => { is_boolean => 1 },
);
1;

View File

@ -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'" );
}
},
};

View File

@ -6497,6 +6497,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`),

View File

@ -286,6 +286,15 @@
[% END %]
</div>
</li>
<li>
<label for="preselect_issues_in_collections_table">Pre-select issues in the collections table:</label>
[% IF (preselect_issues_in_collections_table) %]
<input type="checkbox" id="preselect_issues_in_collections_table" name="preselect_issues_in_collections_table" checked="checked" />
[% ELSE %]
<input type="checkbox" id="preselect_issues_in_collections_table" name="preselect_issues_in_collections_table" />
[% END %]
<div class="hint">Determines whether the checkboxes in the left hand column of the collections table will be automatically checked based on the issue's status.</div>
</li>
</ol>
</fieldset>
<fieldset class="action">

View File

@ -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 =