Bugzilla – Attachment 156794 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), 15.49 KB, created by
Julian Maurice
on 2023-10-10 13:08:55 UTC
(
hide
)
Description:
Bug 29996: Show an alert on main page when serial issues are late
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2023-10-10 13:08:55 UTC
Size:
15.49 KB
patch
obsolete
>From 14e82ec5d493c0e629d694d967e9633f907dea5f 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 > >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. The automatically generated serial issue should have the status > "Expected". Change it to "Late". >4. Go back to the main page. You should see an alert with a link to your > subscription >5. Change your library using the menu in the upper right corner of the > screen. Now the alert should not appear. >6. Set your library back to its original value to make the alert > reappear. >7. Edit your subscription and disable "Warn when late". Verify that the > alert does not appear. >--- > C4/Serials.pm | 6 ++-- > Koha/Serial.pm | 7 ++++ > .../data/mysql/atomicupdate/bug-29996.pl | 17 ++++++++++ > installer/data/mysql/kohastructure.sql | 1 + > .../prog/en/modules/intranet-main.tt | 18 ++++++++++- > .../en/modules/serials/subscription-add.tt | 9 ++++++ > mainpage.pl | 32 ++++++++++++++++++- > serials/subscription-add.pl | 6 ++-- > 8 files changed, 90 insertions(+), 6 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug-29996.pl > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index b01172dc10..24471b9fb5 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1291,7 +1291,7 @@ sub ModSubscription { > $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status, > $biblionumber, $callnumber, $notes, $letter, $manualhistory, > $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, >- $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, >+ $graceperiod, $warn_when_late, $location, $enddate, $subscriptionid, $skip_serialseq, > $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template > ) = @_; > >@@ -1329,6 +1329,7 @@ sub ModSubscription { > staffdisplaycount => $staffdisplaycount, > opacdisplaycount => $opacdisplaycount, > graceperiod => $graceperiod, >+ warn_when_late => $warn_when_late, > location => $location, > enddate => $enddate, > skip_serialseq => $skip_serialseq, >@@ -1373,7 +1374,7 @@ sub NewSubscription { > $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, > $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, > $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, >- $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, >+ $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $warn_when_late, > $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, > $published_on_template, > ) = @_; >@@ -1412,6 +1413,7 @@ sub NewSubscription { > staffdisplaycount => $staffdisplaycount, > opacdisplaycount => $opacdisplaycount, > graceperiod => $graceperiod, >+ warn_when_late => $warn_when_late, > location => $location, > enddate => $enddate, > skip_serialseq => $skip_serialseq, >diff --git a/Koha/Serial.pm b/Koha/Serial.pm >index 052290ed46..36c56d7b27 100644 >--- a/Koha/Serial.pm >+++ b/Koha/Serial.pm >@@ -21,6 +21,7 @@ use Modern::Perl; > > > use Koha::Database; >+use Koha::Subscription; > > use base qw(Koha::Object); > >@@ -34,6 +35,12 @@ Koha::Serial - Koha Serial Object class > > =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 100644 >index 0000000000..4132bc76c5 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug-29996.pl >@@ -0,0 +1,17 @@ >+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 add4518807..e238ffe51b 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -5528,6 +5528,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 1b4dfe93dd..920fb0a77a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >@@ -172,7 +172,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 %] >+ [% 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 || late_subscriptions %] > <div id="area-pending" class="page-section"> > [% IF pending_article_requests %] > <div class="pending-info" id="article_requests_pending"> >@@ -261,6 +261,22 @@ > </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 %] >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 19d53a1c33..b643bf0b9f 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 >@@ -237,6 +237,15 @@ fieldset.rows table { clear: none; margin: 0; } > <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/mainpage.pl b/mainpage.pl >index 855913ae72..570813c48e 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; >@@ -135,13 +137,41 @@ if ( C4::Context->preference('CurbsidePickup') ) { > ); > } > >+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, > pending_borrower_modifications => $pending_borrower_modifications, > pending_discharge_requests => $pending_discharge_requests, > pending_article_requests => $pending_article_requests, >- pending_problem_reports => $pending_problem_reports >+ 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 f8cbc572f2..54c23920fd 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -303,6 +303,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'); >@@ -356,7 +357,7 @@ sub redirect_add_subscription { > $lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, > join(";",@irregularity), $numberpattern, $locale, $callnumber, > $manualhistory, $internalnotes, $serialsadditems, >- $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, >+ $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'))) ){ >@@ -434,6 +435,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'); >@@ -474,7 +476,7 @@ sub redirect_mod_subscription { > $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, > $status, $biblionumber, $callnumber, $notes, $letter, > $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, >- $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid, >+ $opacdisplaycount, $graceperiod, $warn_when_late, $location, $enddate, $subscriptionid, > $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template > ); > >-- >2.30.2
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