Bugzilla – Attachment 189872 Details for
Bug 9750
Bring routing lists into notices & slips
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9750: DB updates
Bug-9750-DB-updates.patch (text/plain), 5.00 KB, created by
Lucas Gass (lukeg)
on 2025-11-21 20:52:50 UTC
(
hide
)
Description:
Bug 9750: DB updates
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-11-21 20:52:50 UTC
Size:
5.00 KB
patch
obsolete
>From 090ad73ed14916a2ad3790c85daa877ca3aaff95 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 20 Nov 2025 21:58:57 +0000 >Subject: [PATCH] Bug 9750: DB updates > >--- > installer/data/mysql/atomicupdate/bug_9750.pl | 120 ++++++++++++++++++ > 1 file changed, 120 insertions(+) > create mode 100755 installer/data/mysql/atomicupdate/bug_9750.pl > >diff --git a/installer/data/mysql/atomicupdate/bug_9750.pl b/installer/data/mysql/atomicupdate/bug_9750.pl >new file mode 100755 >index 00000000000..fceda63662d >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_9750.pl >@@ -0,0 +1,120 @@ >+use Modern::Perl; >+use Koha::Installer::Output qw(say_warning say_success say_info); >+use Koha::AdditionalContents; >+ >+return { >+ bug_number => "9750", >+ description => "Add serials routing list to notices", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ # Do you stuffs here >+ $dbh->do( >+ q{ >+ INSERT IGNORE INTO letter >+ (module, code, branchcode, name, is_html, title, content, message_transport_type, lang) >+ VALUES ('serial','ROUTING_LIST','','Serials routing list',1,'','<table>\n<tr>\n<td colspan="2"><h3>[% branch.branchname %]</h3></td>\n</tr>\n<tr>\n<td colspan="2"><strong>Title:</strong> [% biblio.title %]<br />[% serial.serialseq %] ([% serial.planneddate | $KohaDates %])</td>\n</tr>\n<tr>\n<td><strong>Names:</strong></td>\n</tr>\n[% FOREACH borrower IN borrowers %]\n<tr>\n<td>[% borrower.firstname %] [% borrower.surname %]</td>\n</tr>\n[% END %]\n<tr>\n<td colspan="2"><strong>Notes:</strong> [% serial.routingnotes %]</td>\n</tr>\n</table>\n','print','default'); >+ } >+ ); >+ say_success( $out, "Added ROUTING_LIST letter" ); >+ >+ #get RoutingListNote from additional_contents >+ my $routing_notes = Koha::AdditionalContents->search( >+ { >+ location => 'RoutingListNote', >+ } >+ ); >+ >+ my $translate_notices = C4::Context->preference('TranslateNotices'); >+ >+ while ( my $note = $routing_notes->next ) { >+ my $branchcode = $note->branchcode || ''; >+ my $localizations = $note->translated_contents->as_list; # Add ->as_list here >+ >+ if ($translate_notices) { >+ >+ #deal with each language >+ foreach my $localization (@$localizations) { >+ my $lang = $localization->lang; >+ my $content = $localization->content; >+ next unless $content; >+ >+ _append_routing_note( $dbh, $branchcode, $lang, $content ); >+ } >+ } else { >+ >+ #TranslateNotices, only move the default >+ my ($default_localization) = grep { $_->lang eq 'default' } @$localizations; >+ if ( $default_localization && $default_localization->content ) { >+ _append_routing_note( $dbh, $branchcode, 'default', $default_localization->content ); >+ } >+ } >+ } >+ >+ say_success( $out, "Added ROUTING_LIST letter and migrated routing notes" ); >+ >+ # Delete the RoutingListNote additional contents after migration >+ $dbh->do( >+ q{ >+ DELETE FROM additional_contents >+ WHERE location = 'RoutingListNote' >+ } >+ ); >+ >+ say_success( >+ $out, >+ "Added ROUTING_LIST letter, migrated routing notes, and removed RoutingListNote additional contents" >+ ); >+ }, >+}; >+ >+sub _append_routing_note { >+ my ( $dbh, $branchcode, $lang, $content ) = @_; >+ >+ # Check if letter exists for this branch/lang >+ my $exists = $dbh->selectrow_array( >+ q{ >+ SELECT COUNT(*) FROM letter >+ WHERE module = 'serial' AND code = 'ROUTING_LIST' >+ AND branchcode = ? AND lang = ? >+ }, >+ undef, >+ $branchcode, >+ $lang >+ ); >+ >+ if ($exists) { >+ >+ # Append to existing letter >+ $dbh->do( >+ q{ >+ UPDATE letter >+ SET content = CONCAT(content, ?) >+ WHERE module = 'serial' AND code = 'ROUTING_LIST' >+ AND branchcode = ? AND lang = ? >+ }, >+ undef, >+ "\n<div id=\"routingnotes\">\n$content\n</div>", >+ $branchcode, >+ $lang >+ ); >+ } else { >+ >+ # Copy default letter and append note >+ $dbh->do( >+ q{ >+ INSERT INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type, lang) >+ SELECT module, code, ?, name, is_html, title, CONCAT(content, ?), message_transport_type, ? >+ FROM letter >+ WHERE module = 'serial' AND code = 'ROUTING_LIST' >+ AND branchcode = '' AND lang = 'default' >+ LIMIT 1 >+ }, >+ undef, >+ $branchcode, >+ "\n<div id=\"routingnotes\">\n$content\n</div>", >+ $lang >+ ); >+ } >+} >-- >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 9750
:
189816
|
189817
|
189871
| 189872 |
189873
|
189874