From ac162468290f24cdc105f8848740a52c805dd481 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sun, 12 Apr 2020 22:06:05 +0000 Subject: [PATCH] Bug 14369: Only show 'Create labels' link on staged records import when status is imported The label creator won't be able to add a batch for items, if they are not imported into the database (missing itemnumber). This patch hides the link, when the status is not imported, to avoid the error situation. To test: - Export a record with items from your Koha installation - Delete items and record from Koha - Stage the record with the items - the "Create labels" link should be showing - Try to create the labels - note error - Apply patch - Retry - the link should no longer show - Import the records - the link should show now - Create labels again - a new batch should have been created - Verify the link on the batch # leads to the batch in the labels module Bonus: Moves the message from the .pl file to the template to make it translatable. Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson --- .../prog/en/modules/tools/manage-marc-import.tt | 16 +++++++++++++--- tools/manage-marc-import.pl | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt index e214e80998..b1b8424cab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -45,7 +45,13 @@ [% ELSE %]
[% END %] -

[% label_batch_msg | html %]

+

+ [% IF ( label_batch_msg == "error" ) %] + Error attempting to create label batch. Please ask your system administrator to check the log for more details. + [% ELSE %] + Label batch #[% label_batch_msg | html %] created. + [% END %] +

[% END %] @@ -353,7 +359,11 @@ [% batch_lis.upload_timestamp | html %] [% batch_lis.num_records | html %] - [% batch_lis.num_items | html %][% IF ( batch_lis.num_items ) %] (Create label batch)[% END %] + [% batch_lis.num_items | html %] + [% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %] + (Create label batch) + [% END %] + [% IF ( batch_lis.can_clean ) %]
@@ -578,4 +588,4 @@ [% END %] -[% END %] \ No newline at end of file +[% END %] diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl index 4fea4005d7..6f9405d281 100755 --- a/tools/manage-marc-import.pl +++ b/tools/manage-marc-import.pl @@ -69,12 +69,12 @@ if ($op eq "create_labels") { #create a batch of labels, then lose $op & $import_batch_id so we get back to import batch list. my $label_batch_id = create_labelbatch_from_importbatch($import_batch_id); if ($label_batch_id == -1) { - $template->param( label_batch_msg => "Error attempting to create label batch. Please ask your system administrator to check the log for more details.", + $template->param( label_batch_msg => "error", message_type => 'alert', ); } else { - $template->param( label_batch_msg => "Label batch #$label_batch_id created.", + $template->param( label_batch_msg => $label_batch_id, message_type => 'dialog', ); } -- 2.39.5