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 <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Katrin Fischer 2020-04-12 22:06:05 +00:00 committed by Martin Renvoize
parent e94ea221df
commit 4a2cc4e903
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 15 additions and 5 deletions

View File

@ -45,7 +45,13 @@
[% ELSE %]
<div class="dialog message">
[% END %]
<b><p>[% label_batch_msg | html %]</p></b>
<p><b>
[% 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 <a href="/cgi-bin/koha/labels/label-edit-batch.pl?op=edit&element_id=[% label_batch_msg | uri %]" >batch #[% label_batch_msg | html %]</a> created.
[% END %]
</b></p>
</div>
[% END %]
@ -353,7 +359,11 @@
</td>
<td>[% batch_lis.upload_timestamp | html %]</td>
<td>[% batch_lis.num_records | html %]</td>
<td>[% batch_lis.num_items | html %][% IF ( batch_lis.num_items ) %] <a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]&amp;op=create_labels">(Create label batch)</a>[% END %]</td>
<td>[% batch_lis.num_items | html %]
[% IF ( batch_lis.num_items && batch_lis.import_status == 'imported' ) %]
(<a href="[% batch_lis.script_name | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]&amp;op=create_labels">Create label batch</a>)
[% END %]
</td>
<td class="actions">
[% IF ( batch_lis.can_clean ) %]
<form method="post" action="[% batch_lis.script_name | html %]" name="clean_batch_[% batch_lis.import_batch_id | html %]" id="clean_batch_[% batch_lis.import_batch_id | html %]" class="batch_form batch_clean">
@ -591,4 +601,4 @@
[% END %]
</ul>
</nav>
[% END %]
[% END %]

View File

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