Bugzilla – Attachment 183386 Details for
Bug 29996
Show an alert on main page when serial issues are late
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29996: Show an alert on main page when serial issues are late
Bug-29996-Show-an-alert-on-main-page-when-serial-i.patch (text/plain), 19.09 KB, created by
Julian Maurice
on 2025-06-20 11:44:52 UTC
(
hide
)
Description:
Bug 29996: Show an alert on main page when serial issues are late
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2025-06-20 11:44:52 UTC
Size:
19.09 KB
patch
obsolete
>From 9be876c27b726ad9613c36566e4bfc818afbe882 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Tue, 23 Nov 2021 15:38:39 +0000 >Subject: [PATCH] Bug 29996: Show an alert on main page when serial issues are > late >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >The alert is disabled by default and can be enabled for each >subscription individually. >Alerts are shown on the main page only for subscriptions that have this >feature enabled and that are of the same library than the connection >library > >Test plan: >1. Run `installer/data/mysql/updatedatabase.pl` and > `misc/devel/update_dbix_class_files.pl --koha-conf`. Restart Koha if > needed. >2. Create a subscription, set its library to your connection library > and enable "Warn when late" >3. Verify that you can see the value of "warn when late" setting on > subscription-detail.pl >4. The automatically generated serial issue should have the status > "Expected". Change it to "Late". >5. Go back to the main page. You should see an alert with a link to your > subscription >6. Change your library using the menu in the upper right corner of the > screen. Now the alert should not appear. >7. Set your library back to its original value to make the alert > reappear. >8. Edit your subscription and disable "Warn when late". Verify that the > alert does not appear. > >Sponsored-by: Ãcoles Nationales Supérieures d'Architecture >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Serials.pm | 10 ++++--- > Koha/Serial.pm | 15 ++++++++++ > .../data/mysql/atomicupdate/bug-29996.pl | 19 ++++++++++++ > installer/data/mysql/kohastructure.sql | 1 + > .../prog/en/modules/intranet-main.tt | 19 +++++++++++- > .../en/modules/serials/subscription-add.tt | 9 ++++++ > .../en/modules/serials/subscription-detail.tt | 8 +++++ > mainpage.pl | 29 +++++++++++++++++++ > serials/subscription-add.pl | 22 +++++++------- > 9 files changed, 117 insertions(+), 15 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug-29996.pl > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 18f7318e50..c8edbfaee0 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1346,8 +1346,8 @@ sub ModSubscription { > $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 >+ $graceperiod, $warn_when_late, $location, $enddate, $subscriptionid, $skip_serialseq, >+ $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template > ) = @_; > > my $subscription = Koha::Subscriptions->find($subscriptionid); >@@ -1384,6 +1384,7 @@ sub ModSubscription { > staffdisplaycount => $staffdisplaycount, > opacdisplaycount => $opacdisplaycount, > graceperiod => $graceperiod, >+ warn_when_late => $warn_when_late // 0, > location => $location, > enddate => $enddate, > skip_serialseq => $skip_serialseq, >@@ -1429,8 +1430,8 @@ sub NewSubscription { > $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, >+ $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $warn_when_late, >+ $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, > $published_on_template, > ) = @_; > my $dbh = C4::Context->dbh; >@@ -1468,6 +1469,7 @@ sub NewSubscription { > staffdisplaycount => $staffdisplaycount, > opacdisplaycount => $opacdisplaycount, > graceperiod => $graceperiod, >+ warn_when_late => $warn_when_late // 0, > location => $location, > enddate => $enddate, > skip_serialseq => $skip_serialseq, >diff --git a/Koha/Serial.pm b/Koha/Serial.pm >index 4ed0c4507a..76c3987ee3 100644 >--- a/Koha/Serial.pm >+++ b/Koha/Serial.pm >@@ -20,6 +20,7 @@ package Koha::Serial; > use Modern::Perl; > > use Koha::Database; >+use Koha::Subscription; > > use base qw(Koha::Object); > >@@ -33,6 +34,20 @@ Koha::Serial - Koha Serial Object class > > =cut > >+=head3 subscription >+ >+Returns the subscription this serial belongs to >+ >+ $subscription = $serial->subscription() >+ >+=cut >+ >+sub subscription { >+ my ($self) = @_; >+ >+ return Koha::Subscription->_new_from_dbic( $self->_result->subscriptionid ); >+} >+ > =head3 type > > =cut >diff --git a/installer/data/mysql/atomicupdate/bug-29996.pl b/installer/data/mysql/atomicupdate/bug-29996.pl >new file mode 100755 >index 0000000000..9b1617d15d >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug-29996.pl >@@ -0,0 +1,19 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => '29996', >+ description => 'Add subscription.warn_when_late', >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ unless ( column_exists( 'subscription', 'warn_when_late' ) ) { >+ $dbh->do( >+ q{ >+ ALTER TABLE subscription >+ ADD COLUMN warn_when_late INT NOT NULL DEFAULT 0 COMMENT 'if enabled, late issues will be shown on main page' AFTER graceperiod >+ } >+ ); >+ } >+ }, >+}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 5d7139383c..8d44238539 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -6179,6 +6179,7 @@ CREATE TABLE `subscription` ( > `staffdisplaycount` int(11) DEFAULT NULL COMMENT 'how many issues to show to the staff', > `opacdisplaycount` int(11) DEFAULT NULL COMMENT 'how many issues to show to the public', > `graceperiod` int(11) NOT NULL DEFAULT 0 COMMENT 'grace period in days', >+ `warn_when_late` INT NOT NULL DEFAULT 0 COMMENT 'if enabled, late issues will be shown on main page', > `enddate` date DEFAULT NULL COMMENT 'subscription end date', > `closed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'yes / no if the subscription is closed', > `reneweddate` date DEFAULT NULL COMMENT 'date of last renewal for the subscription', >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >index 91172dac2a..c045d943b2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >@@ -182,7 +182,7 @@ > <div class="row"> > <div class="col-sm-12"> > [%# Following statement must be in one line for translatability %] >- [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.Preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count || ( holds_with_cancellation_requests && CAN_user_circulate_circulate_remaining_permissions ) || self_registered_count %] >+ [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.Preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count || ( holds_with_cancellation_requests && CAN_user_circulate_circulate_remaining_permissions ) || self_registered_count || late_subscriptions %] > <div id="area-pending" class="page-section"> > [% IF pending_article_requests %] > <div class="pending-info" id="article_requests_pending"> >@@ -294,6 +294,23 @@ > [% END %] > </div> > [% END %] >+ >+ [% IF late_subscriptions %] >+ <div class="pending-info" id="problem_late_subscriptions"> >+ <span>The following serials are late:</span> >+ <ul> >+ [% FOREACH s IN late_subscriptions %] >+ <li> >+ <a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% s.subscription.subscriptionid | uri %]">[% s.subscription.biblio.title | html %]</a>: >+ [% FOREACH serial IN s.serials %] >+ [% serial.serialseq | html %] >+ [% "," UNLESS loop.last %] >+ [% END %] >+ </li> >+ [% END %] >+ </ul> >+ </div> >+ [% END %] > </div> > [% END %] > </div> >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..7d1db72f8b 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 >@@ -262,6 +262,15 @@ > <label for="graceperiod">Grace period:</label> > <input type="text" name="graceperiod" id="graceperiod" value="[% graceperiod | html %]" size="5" /> day(s) > </li> >+ <li> >+ <label for="warn_when_late">Warn when late</label> >+ [% IF warn_when_late %] >+ <input type="checkbox" name="warn_when_late" id="warn_when_late" value="1" checked /> >+ [% ELSE %] >+ <input type="checkbox" name="warn_when_late" id="warn_when_late" value="1" /> >+ [% END %] >+ <div class="hint">Show an alert on main page when issues are late</div> >+ </li> > <li> > <label class="widelabel" for="staffdisplaycount">Number of issues to display to staff: </label> > <input type="text" name="staffdisplaycount" id="staffdisplaycount" value="[% staffdisplaycount | html %]" inputmode="numeric" pattern="[0-9]*" size="4" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >index 6d25533f1a..8484dc2a7a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >@@ -138,6 +138,14 @@ > [% END %] > </li> > <li><span class="label">Grace period:</span> [% graceperiod | html %]</li> >+ <li> >+ <span class="label">Warn when late:</span> >+ [% IF warn_when_late %] >+ Yes >+ [% ELSE %] >+ No >+ [% END %] >+ </li> > </ol> > </div> > <!-- /.rows --> >diff --git a/mainpage.pl b/mainpage.pl >index 87f784631f..9cb91ef540 100755 >--- a/mainpage.pl >+++ b/mainpage.pl >@@ -25,6 +25,7 @@ use C4::Output qw( output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user ); > use C4::Koha; > use C4::Tags qw( get_count_by_tag_status ); >+use C4::Serials; > use Koha::AdditionalContents; > use Koha::Patron::Modifications; > use Koha::Patron::Discharge; >@@ -33,6 +34,7 @@ use Koha::ArticleRequests; > use Koha::BiblioFrameworks; > use Koha::ProblemReports; > use Koha::Quotes; >+use Koha::Serials; > use Koha::Suggestions; > use Koha::BackgroundJobs; > use Koha::CurbsidePickups; >@@ -153,6 +155,32 @@ if ( C4::Context->preference('PatronSelfRegistrationAlert') ) { > ); > } > >+my @late_serials = Koha::Serials->search( >+ { >+ 'me.status' => C4::Serials::LATE, >+ 'subscriptionid.warn_when_late' => 1, >+ 'subscriptionid.branchcode' => C4::Context->userenv->{branch}, >+ }, >+ { >+ join => 'subscriptionid', >+ prefetch => { >+ subscriptionid => 'biblionumber', >+ }, >+ } >+)->as_list; >+ >+my %late_serials_grouped_by_subscription; >+foreach my $serial (@late_serials) { >+ my $subscriptionid = $serial->subscriptionid; >+ $late_serials_grouped_by_subscription{$subscriptionid} //= { >+ subscription => $serial->subscription, >+ serials => [], >+ }; >+ push @{ $late_serials_grouped_by_subscription{$subscriptionid}->{serials} }, $serial; >+} >+my @late_subscriptions = sort { $a->{subscription}->subscriptionid <=> $b->{subscription}->subscriptionid } >+ values %late_serials_grouped_by_subscription; >+ > $template->param( > pendingcomments => $pendingcomments, > pendingtags => $pendingtags, >@@ -160,6 +188,7 @@ $template->param( > pending_discharge_requests => $pending_discharge_requests, > pending_article_requests => $pending_article_requests, > pending_problem_reports => $pending_problem_reports, >+ late_subscriptions => \@late_subscriptions, > ); > > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 8dff969978..d93bdbfc39 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -322,6 +322,7 @@ sub redirect_add_subscription { > my @irregularity = $query->multi_param('irregularity'); > my $locale = $query->param('locale'); > my $graceperiod = $query->param('graceperiod') || 0; >+ my $warn_when_late = $query->param('warn_when_late'); > > my $subtype = $query->param('subtype'); > my $sublength = $query->param('sublength'); >@@ -369,14 +370,14 @@ sub redirect_add_subscription { > } > } > my $subscriptionid = NewSubscription( >- $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, >- $startdate, $periodicity, $numberlength, $weeklength, >- $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, >- $lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, >- join( ";", @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, >+ join( ";", @irregularity ), $numberpattern, $locale, $callnumber, >+ $manualhistory, $internalnotes, $serialsadditems, >+ $staffdisplaycount, $opacdisplaycount, $graceperiod, $warn_when_late, $location, $enddate, >+ $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template > ); > if ( ( C4::Context->preference('Mana') == 1 ) > and ( grep { $_ eq "subscription" } split( /,/, C4::Context->preference('AutoShareWithMana') ) ) ) >@@ -452,6 +453,7 @@ sub redirect_mod_subscription { > my $staffdisplaycount = $query->param('staffdisplaycount'); > my $opacdisplaycount = $query->param('opacdisplaycount'); > my $graceperiod = $query->param('graceperiod') || 0; >+ my $warn_when_late = $query->param('warn_when_late'); > my $location = $query->param('location'); > my $itemtype = $query->param('itemtype'); > my $previousitemtype = $query->param('previousitemtype'); >@@ -493,8 +495,8 @@ sub redirect_mod_subscription { > $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 >+ $opacdisplaycount, $graceperiod, $warn_when_late, $location, $enddate, $subscriptionid, >+ $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template > ); > > my @additional_fields = >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29996
:
130045
|
143631
|
156794
|
156795
|
175383
|
175384
|
175385
|
175467
|
175468
|
175474
|
175475
| 183386 |
183387
|
183388