Bug 7468 - Add label to batch by barcode range
Summary: Add label to batch by barcode range
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Label/patron card printing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Charles Farmer
QA Contact:
URL:
Keywords:
: 10203 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-01-25 15:59 UTC by wrmslibrary
Modified: 2020-02-06 22:31 UTC (History)
17 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Who signed the patch off:
Text to go in the release notes:
This enhancement to the label creator tool adds an option to let you generate a range of barcode numbers (for example, from 05000 to 05500) and save these as a PDF, ready for printing.
Version(s) released in:
20.05.00


Attachments
Bug 7468 - Print barcodes by range (15.22 KB, patch)
2017-09-18 15:04 UTC, David Bourgault
Details | Diff | Splinter Review
Bug 7468 - Fix 'false' message on Firefox (1.93 KB, patch)
2017-10-04 13:12 UTC, David Bourgault
Details | Diff | Splinter Review
Bug 7468 - Add warning when range has non-existent barcodes (2.91 KB, patch)
2017-10-05 13:40 UTC, David Bourgault
Details | Diff | Splinter Review
Bug 7468 - Showing the error message according to the community interface patterns, fixing a javascript condition (3.83 KB, patch)
2018-01-26 21:00 UTC, Charles Farmer
Details | Diff | Splinter Review
Bug 7468 - (follow-up) Make sure only integers are accepted as from/to values (2.11 KB, patch)
2018-08-08 20:21 UTC, Charles Farmer
Details | Diff | Splinter Review
Bug 7468 - Print barcodes by range (15.34 KB, patch)
2018-10-24 15:15 UTC, Pierre-Marc Thibault
Details | Diff | Splinter Review
Bug 7468 - Fix 'false' message on Firefox (1.93 KB, patch)
2018-10-24 15:15 UTC, Pierre-Marc Thibault
Details | Diff | Splinter Review
Bug 7468 - Add warning when range has non-existent barcodes (2.91 KB, patch)
2018-10-24 15:15 UTC, Pierre-Marc Thibault
Details | Diff | Splinter Review
Bug 7468 - Showing the error message according to the community interface patterns, fixing a javascript condition (3.83 KB, patch)
2018-10-24 15:15 UTC, Pierre-Marc Thibault
Details | Diff | Splinter Review
Bug 7468 - (follow-up) Make sure only integers are accepted as from/to values (2.11 KB, patch)
2018-10-24 15:15 UTC, Pierre-Marc Thibault
Details | Diff | Splinter Review
Bug7468: (follow-up) fix label-edit-range template (9.00 KB, patch)
2019-07-17 15:33 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: (follow-up) fix label-edit-range template (9.00 KB, patch)
2019-07-17 15:45 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: (follow-up) Add missing filters (2.60 KB, patch)
2019-07-17 15:58 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: Print barcodes by range (15.34 KB, patch)
2020-01-16 15:56 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: Fix 'false' message on Firefox (1.93 KB, patch)
2020-01-16 15:56 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: Add warning when range has non-existent barcodes (2.91 KB, patch)
2020-01-16 15:56 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: Showing the error message according to the community interface patterns, fixing a javascript condition (3.83 KB, patch)
2020-01-16 15:56 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: (follow-up) Make sure only integers are accepted as from/to values (2.11 KB, patch)
2020-01-16 15:56 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: (follow-up) fix label-edit-range template (9.00 KB, patch)
2020-01-16 15:56 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: (follow-up) Add missing filters (2.60 KB, patch)
2020-01-16 15:56 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: fix the export labels popup header (1.04 KB, patch)
2020-01-16 15:56 UTC, Maryse Simard
Details | Diff | Splinter Review
Bug 7468: Print barcodes by range (15.43 KB, patch)
2020-01-17 18:57 UTC, David Nind
Details | Diff | Splinter Review
Bug 7468: Fix 'false' message on Firefox (1.98 KB, patch)
2020-01-17 18:57 UTC, David Nind
Details | Diff | Splinter Review
Bug 7468: Add warning when range has non-existent barcodes (2.97 KB, patch)
2020-01-17 18:57 UTC, David Nind
Details | Diff | Splinter Review
Bug 7468: Showing the error message according to the community interface patterns, fixing a javascript condition (3.89 KB, patch)
2020-01-17 18:57 UTC, David Nind
Details | Diff | Splinter Review
Bug 7468: (follow-up) Make sure only integers are accepted as from/to values (2.16 KB, patch)
2020-01-17 18:57 UTC, David Nind
Details | Diff | Splinter Review
Bug 7468: (follow-up) fix label-edit-range template (9.05 KB, patch)
2020-01-17 18:57 UTC, David Nind
Details | Diff | Splinter Review
Bug 7468: (follow-up) Add missing filters (2.65 KB, patch)
2020-01-17 18:57 UTC, David Nind
Details | Diff | Splinter Review
Bug 7468: fix the export labels popup header (1.09 KB, patch)
2020-01-17 18:57 UTC, David Nind
Details | Diff | Splinter Review
Bug 7468: Print barcodes by range (15.49 KB, patch)
2020-01-20 21:35 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 7468: Fix 'false' message on Firefox (2.04 KB, patch)
2020-01-20 21:35 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 7468: Add warning when range has non-existent barcodes (3.03 KB, patch)
2020-01-20 21:35 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 7468: Showing the error message according to the community interface patterns, fixing a javascript condition (3.94 KB, patch)
2020-01-20 21:35 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 7468: (follow-up) Make sure only integers are accepted as from/to values (2.22 KB, patch)
2020-01-20 21:35 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 7468: (follow-up) fix label-edit-range template (9.11 KB, patch)
2020-01-20 21:35 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 7468: (follow-up) Add missing filters (2.71 KB, patch)
2020-01-20 21:35 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 7468: fix the export labels popup header (1.15 KB, patch)
2020-01-20 21:35 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 7468: Use Modern::Perl (791 bytes, patch)
2020-01-20 21:35 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description wrmslibrary 2012-01-25 15:59:00 UTC
It would be nice to be able to add an item to a label batch by barcode without having to scan the barcode.  If a barcode has not yet been printed, it cannot be scanned to add the item to a label batch.  Would like to be able to search by barcode range to add items to a label batch.
Comment 1 Katrin Fischer 2014-11-02 11:46:42 UTC
*** Bug 10203 has been marked as a duplicate of this bug. ***
Comment 2 David Bourgault 2017-09-18 15:04:50 UTC
Created attachment 67184 [details] [review]
Bug 7468 - Print barcodes by range

Adds an option to the label creator to print a range of barcodes.
Only allows printing to PDF.

C4/Label.pm had to get minor changes to override database-based barcode
generation. Same with labels/label-create-pdf.pl. By default, the
barcode is fetched from the database using the itemnumber, but when
printing ranges, you might not have a corresponding  database entry.

Test plan : 
1) Apply patch
2) Print a range of barcodes
Comment 3 David Bourgault 2017-09-18 15:07:23 UTC
Printing ranges of small numbers with the Code39 format can result in ugly barcodes. Bug 19325 could be helpful in those situations.
Comment 4 Katrin Fischer 2017-10-02 23:19:01 UTC
Hi David, please change Assignee to yourself when you want to adopt a bug and provide patches :)
Comment 5 Alex Buckley 2017-10-04 00:42:27 UTC
Hi David

Whilst testing this patch I notice after writing in a range of valid, existing barcodes and then click the 'Print range' button all I get is a message 'false' on the loaded page.

The URL of this printed page is 'javascript:print()'. I assume this is not what is wanted.

No Javascript error is thrown although there is a Javascript warning that there is unreachable code after the return statement in label-edit-range.pl on line 163 (which is actually line 14 in the label-edit-range.tt file)
Comment 6 David Bourgault 2017-10-04 13:12:50 UTC
Created attachment 67598 [details] [review]
Bug 7468 - Fix 'false' message on Firefox

It seems I was using an href to a javascript function in the 'Print Range' button, which Chrome didn't mind, but Firefox did understand.
Comment 7 David Bourgault 2017-10-04 13:21:21 UTC
Additionally : this function works for any range, regardless of if they actually exist. (You can print your barcodes before your books arrive)
Comment 8 Alex Buckley 2017-10-04 19:34:49 UTC
Hi David

Thanks for fixing that :)

I have tried testing again and I am sorry to say that it  exports a blank page. Can you please fix this and I will be happy to test again
Comment 9 David Bourgault 2017-10-04 19:41:38 UTC
(In reply to Alex Buckley from comment #8)
> Hi David
> 
> Thanks for fixing that :)
> 
> I have tried testing again and I am sorry to say that it  exports a blank
> page. Can you please fix this and I will be happy to test again

This can happen if the selected layout does not include barcodes (Manage layout > Edit > Layout type), and there is no item with the given barcode. Can you check those parameters and tell me if the issue persists? Thanks.

I'll see if I can add a warning to the layout selection page when I have the time.
Comment 10 Alex Buckley 2017-10-04 20:13:12 UTC
Hi David

Thanks for clarifying, yes after including barcodes in the selected layout the exported PDF now contains barcodes. 

One point though like you say if you write in a non-existing barcode e.g. 1, then a blank page is exported. If you could create a warning to inform the user that the inputted barcode does not exist then that would be good. Then I should be able to sign off on these patches as they pass the QA test tool
Comment 11 David Bourgault 2017-10-05 13:40:53 UTC
Created attachment 67636 [details] [review]
Bug 7468 - Add warning when range has non-existent barcodes

+ Added a warning when the user selects a range with some non-existent barcodes, and a layout without barcodes.
This allows the user to print barcodes of items not in the database if he so desires, but will warn him if he tries to print only biblios (which results in missing entries or a blank page).
Comment 12 Katrin Fischer 2017-10-07 20:23:20 UTC
When I choose 'Label test' from the sample data for printing, the PDF link doesn't work, but I can see lots of errors with koha-plack-err:

GetMarcBiblio called with undefined biblionumber at /home/vagrant/kohaclone/C4/Labels/Label.pm line 399.

Maybe it needs some check?
Comment 13 Katrin Fischer 2017-10-07 20:25:25 UTC
Ah, I tried to trigger the new warns, but didn't succeed. Can you add a more detailed test plan please?

It might also be good to use some standard styling for the message instad of:
<div style="color: red; font-weight: bold;">

See here: https://wiki.koha-community.org/wiki/Interface_patterns
Comment 14 Charles Farmer 2018-01-26 21:00:38 UTC
Created attachment 70980 [details] [review]
Bug 7468 - Showing the error message according to the community interface patterns, fixing a javascript condition

TEST PLAN++

1) Apply all the patches
2) Connect to the intranet with an account with permissions to visit the "Tools" page
3) Go to /cgi-bin/koha/labels/label-home.pl
    . Either by entering the URL directly
    . OR, from the front page, by clicking "Tools", followed by the hyperlink "Label creator" under the "Catalog" section
4) Under the "+ New" button, a new option should be available: "Barcode range"
5) Fill the "From:" and the "To:" fields of the "Print barcode range" form
    . Keeping both fields at "0" should trigger a warning beside the first field: "*Cannot be smaller than 1"
    . If the value "From:" is greater the "To:" value, a warning should appear beside the second field: "*Cannot be smaller than the starting value"
    . Make sure the form doesn't let you enter non-numerical values
    . For a casual test, use "From: 1000" and "To: 1100"
6) After pressing the "Print Range" button, choose a template, a layout, and a starting position
    . The "DEFAULT TEMPLATE 01" has a page height of 5pt and a page width of 0pt, don't use it
    . All the default layouts should look alike, since we're only printing a barcode over a number, and not bibliographic information
    . Using a layout not defined as 'Barcode' will show a warning message
7) Clicking the "Export" button should lead to a second dialog window with a "Download as PDF" hyperlink. Clicking the link should prop up a download dialog box
8) Save the PDF locally, or simply open it, and make sure the options you used were taken into account
Comment 15 Jovana Dunisijevic 2018-01-28 23:11:28 UTC
Hi everyone,

This is what we are trying to do, which is similar to your idea, David.
Our idea is to preprint barcodes, given the starting barcode value and the number/amount of barcodes that will be printed. With additional verification as to check if one of the new barcodes haven't already been used. 

I am already working on this. Would like to hear some thoughts about it.
Comment 16 Hugo Agud 2018-03-13 08:27:17 UTC
The patch applies fine

1. It prints propertly the range of barcode
2. It warns you if you use a to smaller than from
3. BUT doesn't warn you if you use non-numeric... it allow you to write A, B, C or A1000 to A20000... it only pop up a blank pdf
Comment 17 Charles Farmer 2018-08-08 20:18:36 UTC
(In reply to Jovana Dunisijevic from comment #15)
> Hi everyone,
> 
> This is what we are trying to do, which is similar to your idea, David.
> Our idea is to preprint barcodes, given the starting barcode value and the
> number/amount of barcodes that will be printed. With additional verification
> as to check if one of the new barcodes haven't already been used. 
> 
> I am already working on this. Would like to hear some thoughts about it.
Do you have any links to that patch? A BZ number?

You're more than welcome to submit additional changes to this bug, but as it is right now, we're following the original usecase of the client who sponsored this development, and I don't see myself swerving too far off what we already have here.

(In reply to Hugo Agud from comment #16)
> The patch applies fine
> 
> 1. It prints propertly the range of barcode
> 2. It warns you if you use a to smaller than from
> 3. BUT doesn't warn you if you use non-numeric... it allow you to write A,
> B, C or A1000 to A20000... it only pop up a blank pdf
Well, it *kinda* warns you by highlighting the whole input box in red if you don't follow the defined type, but I get what you mean. Another patch coming up for this.
Comment 18 Charles Farmer 2018-08-08 20:21:35 UTC
Created attachment 77592 [details] [review]
Bug 7468 - (follow-up) Make sure only integers are accepted as from/to values
Comment 19 Pierre-Marc Thibault 2018-10-24 15:15:22 UTC
Created attachment 81071 [details] [review]
Bug 7468 - Print barcodes by range

Adds an option to the label creator to print a range of barcodes.
Only allows printing to PDF.

C4/Label.pm had to get minor changes to override database-based barcode
generation. Same with labels/label-create-pdf.pl. By default, the
barcode is fetched from the database using the itemnumber, but when
printing ranges, you might not have a corresponding  database entry.
Comment 20 Pierre-Marc Thibault 2018-10-24 15:15:26 UTC
Created attachment 81072 [details] [review]
Bug 7468 - Fix 'false' message on Firefox

It seems I was using an href to a javascript function in the 'Print Range' button, which Chrome didn't mind, but Firefox did understand.
Comment 21 Pierre-Marc Thibault 2018-10-24 15:15:30 UTC
Created attachment 81073 [details] [review]
Bug 7468 - Add warning when range has non-existent barcodes

+ Added a warning when the user selects a range with some non-existent barcodes, and a layout without barcodes.
This allows the user to print barcodes of items not in the database if he so desires, but will warn him if he tries to print only biblios (which results in missing entries or a blank page).
Comment 22 Pierre-Marc Thibault 2018-10-24 15:15:35 UTC
Created attachment 81074 [details] [review]
Bug 7468 - Showing the error message according to the community interface patterns, fixing a javascript condition

TEST PLAN++

1) Apply all the patches
2) Connect to the intranet with an account with permissions to visit the "Tools" page
3) Go to /cgi-bin/koha/labels/label-home.pl
    . Either by entering the URL directly
    . OR, from the front page, by clicking "Tools", followed by the hyperlink "Label creator" under the "Catalog" section
4) Under the "+ New" button, a new option should be available: "Barcode range"
5) Fill the "From:" and the "To:" fields of the "Print barcode range" form
    . Keeping both fields at "0" should trigger a warning beside the first field: "*Cannot be smaller than 1"
    . If the value "From:" is greater the "To:" value, a warning should appear beside the second field: "*Cannot be smaller than the starting value"
    . Make sure the form doesn't let you enter non-numerical values
    . For a casual test, use "From: 1000" and "To: 1100"
6) After pressing the "Print Range" button, choose a template, a layout, and a starting position
    . The "DEFAULT TEMPLATE 01" has a page height of 5pt and a page width of 0pt, don't use it
    . All the default layouts should look alike, since we're only printing a barcode over a number, and not bibliographic information
    . Using a layout not defined as 'Barcode' will show a warning message
7) Clicking the "Export" button should lead to a second dialog window with a "Download as PDF" hyperlink. Clicking the link should prop up a download dialog box
8) Save the PDF locally, or simply open it, and make sure the options you used were taken into account
Comment 23 Pierre-Marc Thibault 2018-10-24 15:15:39 UTC
Created attachment 81075 [details] [review]
Bug 7468 - (follow-up) Make sure only integers are accepted as from/to values
Comment 24 Pierre-Marc Thibault 2018-10-24 15:16:33 UTC
All the patches have been rebased.
Comment 25 Hayley Mapley 2019-04-18 05:24:06 UTC
I completed steps 1-5 in the test plan. After clicking on Print range though, clicking on the template and layout dropdowns shows no options. Am I missing something? Then, with neither of those options chosen, clicking Export and then Download as PDF results in an error.

Also, the close link in the corner doesn't look like the rest of the close icons, instead is a red square next to the word 'Close'.

Error trace:

Can't bless non-reference value at /home/vagrant/kohaclone/C4/Creators/Layout.pm line 110

1.    in C4::Creators::Layout::retrieve at /home/vagrant/kohaclone/C4/Creators/Layout.pm line 110

      107:         return -1;
      108:     }
      109:     my $self = $sth->fetchrow_hashref;
      110:     bless ($self, $type);
      111:     return $self;
      112: }
      113: 

2.    in C4::Labels::Layout::retrieve at /home/vagrant/kohaclone/C4/Labels/Layout.pm line 29

       26: sub retrieve {
       27:     my $self = shift;
       28:     push @_, "creator", $me;
       29:     return $self->SUPER::retrieve(@_);
       30: }
       31: 
       32: sub delete {

3.    in (eval) at /home/vagrant/kohaclone/labels/label-create-pdf.pl line 63

       60: our $pdf = C4::Creators::PDF->new(InitVars => 0);
       61: my $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
       62: our $template = C4::Labels::Template->retrieve(template_id => $template_id, profile_id => 1);
       63: my $layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
       64: 
       65: sub _calc_next_label_pos {
       66:     my ($row_count, $col_count, $llx, $lly) = @_;
Comment 26 Maryse Simard 2019-07-17 15:33:25 UTC
Created attachment 91568 [details] [review]
Bug7468: (follow-up) fix label-edit-range template

Edit the labels/label-edit-range.tt template to follow current
standards :
    - Use footer javascript
    - Use bootstrap grid
    - Use jQuery Validation plugin for validation

Also fixes breadcrumbs to be more specific.

To test:
Make sure the page looks correct and still works as expected.
Comment 27 Maryse Simard 2019-07-17 15:33:52 UTC
I added a follow-up patch to update the template to current standards.

(In reply to Hayley Mapley from comment #25)
> I completed steps 1-5 in the test plan. After clicking on Print range
> though, clicking on the template and layout dropdowns shows no options. Am I
> missing something?

Thank you for testing! The dropdowns should show the templates and layouts that you have defined. Do you have existing templates/layouts? If not, you can create one by clicking New > Layout or New > Batch template in the labels toolbar.

> Then, with neither of those options chosen, clicking
> Export and then Download as PDF results in an error.

The labels/label-create-pdf.pl does result in an error when no layout is chosen. But this is not caused by these patches. It also happens when exporting label batches to pdf. Maybe open another bug?

> Also, the close link in the corner doesn't look like the rest of the close
> icons, instead is a red square next to the word 'Close'.

The barcode range uses the same popup as the rest of the label creator tools. (see for example labels/label-manage.pl when exporting some batches) Still, I can change it if it is a problem.
Comment 28 Maryse Simard 2019-07-17 15:45:12 UTC
Created attachment 91569 [details] [review]
Bug 7468: (follow-up) fix label-edit-range template

Edit the labels/label-edit-range.tt template to follow current
standards :
    - Use footer javascript
    - Use bootstrap grid
    - Use jQuery Validation plugin for validation

Also fixes breadcrumbs to be more specific.

To test:
Make sure the page looks correct and still works as expected.
Comment 29 Maryse Simard 2019-07-17 15:46:58 UTC
I forgot to run the qa script on my last patch. Amended it to fix issues.
Comment 30 Maryse Simard 2019-07-17 15:58:06 UTC
Created attachment 91570 [details] [review]
Bug 7468: (follow-up) Add missing filters
Comment 31 Owen Leonard 2020-01-15 19:53:02 UTC
This is looking good--still applies! I see one very minor thing: When you click the "Print range" button the window which pops up says "0 batches to export." Technically true since it's not a batch in the sense of other label batches, but probably confusing.

There are also some warnings about commit messages:

Processing additional checks

        * Commit title does not start with 'Bug XXXXX: ' - e72dcde082d
        * Commit title does not start with 'Bug XXXXX: ' - f8f861abdd7
        * Commit title does not start with 'Bug XXXXX: ' - 20d7bc7c535
        * Commit title does not start with 'Bug XXXXX: ' - fc83b5fd01e
        * Commit title does not start with 'Bug XXXXX: ' - c48815db50e
Comment 32 Maryse Simard 2020-01-16 15:56:24 UTC
Created attachment 97454 [details] [review]
Bug 7468: Print barcodes by range

Adds an option to the label creator to print a range of barcodes.
Only allows printing to PDF.

C4/Label.pm had to get minor changes to override database-based barcode
generation. Same with labels/label-create-pdf.pl. By default, the
barcode is fetched from the database using the itemnumber, but when
printing ranges, you might not have a corresponding  database entry.
Comment 33 Maryse Simard 2020-01-16 15:56:28 UTC
Created attachment 97455 [details] [review]
Bug 7468: Fix 'false' message on Firefox

It seems I was using an href to a javascript function in the 'Print Range' button, which Chrome didn't mind, but Firefox did understand.
Comment 34 Maryse Simard 2020-01-16 15:56:31 UTC
Created attachment 97456 [details] [review]
Bug 7468: Add warning when range has non-existent barcodes

+ Added a warning when the user selects a range with some non-existent barcodes, and a layout without barcodes.
This allows the user to print barcodes of items not in the database if he so desires, but will warn him if he tries to print only biblios (which results in missing entries or a blank page).
Comment 35 Maryse Simard 2020-01-16 15:56:35 UTC
Created attachment 97457 [details] [review]
Bug 7468: Showing the error message according to the community interface patterns, fixing a javascript condition

TEST PLAN++

1) Apply all the patches
2) Connect to the intranet with an account with permissions to visit the "Tools" page
3) Go to /cgi-bin/koha/labels/label-home.pl
    . Either by entering the URL directly
    . OR, from the front page, by clicking "Tools", followed by the hyperlink "Label creator" under the "Catalog" section
4) Under the "+ New" button, a new option should be available: "Barcode range"
5) Fill the "From:" and the "To:" fields of the "Print barcode range" form
    . Keeping both fields at "0" should trigger a warning beside the first field: "*Cannot be smaller than 1"
    . If the value "From:" is greater the "To:" value, a warning should appear beside the second field: "*Cannot be smaller than the starting value"
    . Make sure the form doesn't let you enter non-numerical values
    . For a casual test, use "From: 1000" and "To: 1100"
6) After pressing the "Print Range" button, choose a template, a layout, and a starting position
    . The "DEFAULT TEMPLATE 01" has a page height of 5pt and a page width of 0pt, don't use it
    . All the default layouts should look alike, since we're only printing a barcode over a number, and not bibliographic information
    . Using a layout not defined as 'Barcode' will show a warning message
7) Clicking the "Export" button should lead to a second dialog window with a "Download as PDF" hyperlink. Clicking the link should prop up a download dialog box
8) Save the PDF locally, or simply open it, and make sure the options you used were taken into account
Comment 36 Maryse Simard 2020-01-16 15:56:39 UTC
Created attachment 97458 [details] [review]
Bug 7468: (follow-up) Make sure only integers are accepted as from/to values
Comment 37 Maryse Simard 2020-01-16 15:56:46 UTC
Created attachment 97459 [details] [review]
Bug 7468: (follow-up) fix label-edit-range template

Edit the labels/label-edit-range.tt template to follow current
standards :
    - Use footer javascript
    - Use bootstrap grid
    - Use jQuery Validation plugin for validation

Also fixes breadcrumbs to be more specific.

To test:
Make sure the page looks correct and still works as expected.
Comment 38 Maryse Simard 2020-01-16 15:56:52 UTC
Created attachment 97460 [details] [review]
Bug 7468: (follow-up) Add missing filters
Comment 39 Maryse Simard 2020-01-16 15:56:57 UTC
Created attachment 97461 [details] [review]
Bug 7468: fix the export labels popup header

When exporting a barcode range, the export popup should display "1 batch
to export" instead of "0 batches to export". In this context, it can be
considered a label batch and should be counted as such.

To test:
When clicking the "Print range" button, the popup should show "1 batch
to export".
Comment 40 Maryse Simard 2020-01-16 15:59:57 UTC
I've reattached the commits with corrected message titles. I also added a new patch to correct the popup message, it should now show "1 batch to export" when exporting a barcode range.
Comment 41 David Nind 2020-01-17 12:03:46 UTC
I can't seem to apply the patches on the latest master (testing using koha-testing-docker). Here is what I get:

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 7468 - Print barcodes by range
Applying: Bug 7468 - Fix 'false' message on Firefox
Applying: Bug 7468 - Add warning when range has non-existent barcodes
Applying: Bug 7468 - Showing the error message according to the community interface patterns, fixing a javascript condition
Applying: Bug 7468 - (follow-up) Make sure only integers are accepted as from/to values
Applying: Bug 7468: Print barcodes by range
Using index info to reconstruct a base tree...
M	C4/Labels/Label.pm
M	koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc
M	koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-print.tt
M	labels/label-create-pdf.pl
M	labels/label-print.pl
Falling back to patching base and 3-way merge...
Auto-merging labels/label-print.pl
CONFLICT (content): Merge conflict in labels/label-print.pl
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt
CONFLICT (add/add): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt
error: Failed to merge in the changes.
Patch failed at 0001 Bug 7468: Print barcodes by range
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-7468-Print-barcodes-by-range-ZVR8Tv.patch
Comment 42 Maryse Simard 2020-01-17 13:20:16 UTC
Sorry! I forgot to obsolete the patches for which I changed the title, therefore it didn't apply. You can test again now, it should work.
Comment 43 David Nind 2020-01-17 18:57:04 UTC
Created attachment 97551 [details] [review]
Bug 7468: Print barcodes by range

Adds an option to the label creator to print a range of barcodes.
Only allows printing to PDF.

C4/Label.pm had to get minor changes to override database-based barcode
generation. Same with labels/label-create-pdf.pl. By default, the
barcode is fetched from the database using the itemnumber, but when
printing ranges, you might not have a corresponding  database entry.

Signed-off-by: David Nind <david@davidnind.com>
Comment 44 David Nind 2020-01-17 18:57:08 UTC
Created attachment 97552 [details] [review]
Bug 7468: Fix 'false' message on Firefox

It seems I was using an href to a javascript function in the 'Print Range' button, which Chrome didn't mind, but Firefox did understand.

Signed-off-by: David Nind <david@davidnind.com>
Comment 45 David Nind 2020-01-17 18:57:13 UTC
Created attachment 97553 [details] [review]
Bug 7468: Add warning when range has non-existent barcodes

+ Added a warning when the user selects a range with some non-existent barcodes, and a layout without barcodes.
This allows the user to print barcodes of items not in the database if he so desires, but will warn him if he tries to print only biblios (which results in missing entries or a blank page).

Signed-off-by: David Nind <david@davidnind.com>
Comment 46 David Nind 2020-01-17 18:57:18 UTC
Created attachment 97554 [details] [review]
Bug 7468: Showing the error message according to the community interface patterns, fixing a javascript condition

TEST PLAN++

1) Apply all the patches
2) Connect to the intranet with an account with permissions to visit the "Tools" page
3) Go to /cgi-bin/koha/labels/label-home.pl
    . Either by entering the URL directly
    . OR, from the front page, by clicking "Tools", followed by the hyperlink "Label creator" under the "Catalog" section
4) Under the "+ New" button, a new option should be available: "Barcode range"
5) Fill the "From:" and the "To:" fields of the "Print barcode range" form
    . Keeping both fields at "0" should trigger a warning beside the first field: "*Cannot be smaller than 1"
    . If the value "From:" is greater the "To:" value, a warning should appear beside the second field: "*Cannot be smaller than the starting value"
    . Make sure the form doesn't let you enter non-numerical values
    . For a casual test, use "From: 1000" and "To: 1100"
6) After pressing the "Print Range" button, choose a template, a layout, and a starting position
    . The "DEFAULT TEMPLATE 01" has a page height of 5pt and a page width of 0pt, don't use it
    . All the default layouts should look alike, since we're only printing a barcode over a number, and not bibliographic information
    . Using a layout not defined as 'Barcode' will show a warning message
7) Clicking the "Export" button should lead to a second dialog window with a "Download as PDF" hyperlink. Clicking the link should prop up a download dialog box
8) Save the PDF locally, or simply open it, and make sure the options you used were taken into account

Signed-off-by: David Nind <david@davidnind.com>
Comment 47 David Nind 2020-01-17 18:57:25 UTC
Created attachment 97555 [details] [review]
Bug 7468: (follow-up) Make sure only integers are accepted as from/to values

Signed-off-by: David Nind <david@davidnind.com>
Comment 48 David Nind 2020-01-17 18:57:30 UTC
Created attachment 97556 [details] [review]
Bug 7468: (follow-up) fix label-edit-range template

Edit the labels/label-edit-range.tt template to follow current
standards :
    - Use footer javascript
    - Use bootstrap grid
    - Use jQuery Validation plugin for validation

Also fixes breadcrumbs to be more specific.

To test:
Make sure the page looks correct and still works as expected.

Signed-off-by: David Nind <david@davidnind.com>
Comment 49 David Nind 2020-01-17 18:57:35 UTC
Created attachment 97557 [details] [review]
Bug 7468: (follow-up) Add missing filters

Signed-off-by: David Nind <david@davidnind.com>
Comment 50 David Nind 2020-01-17 18:57:40 UTC
Created attachment 97558 [details] [review]
Bug 7468: fix the export labels popup header

When exporting a barcode range, the export popup should display "1 batch
to export" instead of "0 batches to export". In this context, it can be
considered a label batch and should be counted as such.

To test:
When clicking the "Print range" button, the popup should show "1 batch
to export".

Signed-off-by: David Nind <david@davidnind.com>
Comment 51 Katrin Fischer 2020-01-20 21:35:11 UTC
Created attachment 97638 [details] [review]
Bug 7468: Print barcodes by range

Adds an option to the label creator to print a range of barcodes.
Only allows printing to PDF.

C4/Label.pm had to get minor changes to override database-based barcode
generation. Same with labels/label-create-pdf.pl. By default, the
barcode is fetched from the database using the itemnumber, but when
printing ranges, you might not have a corresponding  database entry.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 52 Katrin Fischer 2020-01-20 21:35:16 UTC
Created attachment 97639 [details] [review]
Bug 7468: Fix 'false' message on Firefox

It seems I was using an href to a javascript function in the 'Print Range' button, which Chrome didn't mind, but Firefox did understand.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 53 Katrin Fischer 2020-01-20 21:35:21 UTC
Created attachment 97640 [details] [review]
Bug 7468: Add warning when range has non-existent barcodes

+ Added a warning when the user selects a range with some non-existent barcodes, and a layout without barcodes.
This allows the user to print barcodes of items not in the database if he so desires, but will warn him if he tries to print only biblios (which results in missing entries or a blank page).

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 54 Katrin Fischer 2020-01-20 21:35:26 UTC
Created attachment 97641 [details] [review]
Bug 7468: Showing the error message according to the community interface patterns, fixing a javascript condition

TEST PLAN++

1) Apply all the patches
2) Connect to the intranet with an account with permissions to visit the "Tools" page
3) Go to /cgi-bin/koha/labels/label-home.pl
    . Either by entering the URL directly
    . OR, from the front page, by clicking "Tools", followed by the hyperlink "Label creator" under the "Catalog" section
4) Under the "+ New" button, a new option should be available: "Barcode range"
5) Fill the "From:" and the "To:" fields of the "Print barcode range" form
    . Keeping both fields at "0" should trigger a warning beside the first field: "*Cannot be smaller than 1"
    . If the value "From:" is greater the "To:" value, a warning should appear beside the second field: "*Cannot be smaller than the starting value"
    . Make sure the form doesn't let you enter non-numerical values
    . For a casual test, use "From: 1000" and "To: 1100"
6) After pressing the "Print Range" button, choose a template, a layout, and a starting position
    . The "DEFAULT TEMPLATE 01" has a page height of 5pt and a page width of 0pt, don't use it
    . All the default layouts should look alike, since we're only printing a barcode over a number, and not bibliographic information
    . Using a layout not defined as 'Barcode' will show a warning message
7) Clicking the "Export" button should lead to a second dialog window with a "Download as PDF" hyperlink. Clicking the link should prop up a download dialog box
8) Save the PDF locally, or simply open it, and make sure the options you used were taken into account

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 55 Katrin Fischer 2020-01-20 21:35:31 UTC
Created attachment 97642 [details] [review]
Bug 7468: (follow-up) Make sure only integers are accepted as from/to values

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 56 Katrin Fischer 2020-01-20 21:35:36 UTC
Created attachment 97643 [details] [review]
Bug 7468: (follow-up) fix label-edit-range template

Edit the labels/label-edit-range.tt template to follow current
standards :
    - Use footer javascript
    - Use bootstrap grid
    - Use jQuery Validation plugin for validation

Also fixes breadcrumbs to be more specific.

To test:
Make sure the page looks correct and still works as expected.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 57 Katrin Fischer 2020-01-20 21:35:41 UTC
Created attachment 97644 [details] [review]
Bug 7468: (follow-up) Add missing filters

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 58 Katrin Fischer 2020-01-20 21:35:46 UTC
Created attachment 97645 [details] [review]
Bug 7468: fix the export labels popup header

When exporting a barcode range, the export popup should display "1 batch
to export" instead of "0 batches to export". In this context, it can be
considered a label batch and should be counted as such.

To test:
When clicking the "Print range" button, the popup should show "1 batch
to export".

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 59 Katrin Fischer 2020-01-20 21:35:50 UTC
Created attachment 97646 [details] [review]
Bug 7468: Use Modern::Perl

Just a tiny coding guidelines fix.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 60 Martin Renvoize 2020-01-21 11:32:03 UTC
It would have been nice to have a test for the functional change in Letter.pm.. but as this is a very old bug I'm willing to let that slide this time.
Comment 61 Martin Renvoize 2020-01-21 11:36:39 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 62 Katrin Fischer 2020-01-21 12:43:40 UTC
(In reply to Martin Renvoize from comment #60)
> It would have been nice to have a test for the functional change in
> Letter.pm.. but as this is a very old bug I'm willing to let that slide this
> time.

Are you really meaning Letter.pm?
Comment 63 Martin Renvoize 2020-01-21 16:52:10 UTC
Label.pm of course.. I was never good at multi-tasking ;)
Comment 64 Joy Nelson 2020-02-06 22:31:49 UTC
enhancement not backported to 19.11.x