To test:
1. Go to patron card creator and make a patron card batch, card layout, and card template.
2. In the card layout leave some values blank for Lower left X coordinate and Lower left Y coordinate.
3. Now go create a card batch while tailing the plack-intranet-error log/
4. Notice in the logs:
[2023/08/14 20:50:54] [WARN] Argument "" isn't numeric in multiplication (*) at /kohadevbox/koha/C4/Patroncards/Patroncard.pm line 109.
[2023/08/14 20:50:54] [WARN] Argument "" isn't numeric in multiplication (*) at /kohadevbox/koha/C4/Patroncards/Patroncard.pm line 248.
[2023/08/14 20:50:54] [WARN] Argument "" isn't numeric in multiplication (*) at /kohadevbox/koha/C4/Patroncards/Patroncard.pm line 249.
5. Apply patch, restart_all
6. Try again and notice the WARNS should be gone from the logs now.
7. Make sure you can still create patron cards and the PDF's the generate look right.
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 1164402b49)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
It seems the wrapping here works with words, not characters. If a line is too long,
or too far over, we can't trim it enough. We need to escape if successive loops are
not changing the line
To test:
1 - Using sample data, edit the layout to match picture in comment 9
2 - Add some borrowers to a batch
3 - Attempt to export batch and save PDF
4 - Staff client waits
5 - ps aux | grep card
6 - Note the job keeps running
7 - Kill it
8 - Apply patch
9 - Restart_all
10 - Export batch again
11 - Success, you get a badly formatted PDF, rather than nothing
12 - Note the PDF does not show "Yakama Nation Library"
13 - Edit layout, male "Lower left X" 20 instead of 220
14 - Export again and note text field 1 shows correctly
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
When using any unit besides postscript points, barcode positionning
doesn't work correctly. There is an error in the calculation: the unit
factor must be applied to the individual card part only and not to the
full page position.
This patch moves the unit part of the calculation to the right place.
To test :
1. Create a working patron card setup, using postscript points:
card template, layout and card batch. Use barcode and at least
one other element (text or images) in the layout.
=> Some tips for testing:
- activate guides for the layout
- use a template and a batch containing more than one card; the
displacement will be different for each card and depend on the
barcode position relative to the bottom left of the entire page.
2. Change units from postscript points to any other unit.
=> At least for the layout, but changing it in the template will
scale the page as well.
4. Export the card batch.
3. Note the guides are scaled to fit the new unit and the lower left
corner of text and images are still correctly placed relative to the
guides, but the barcode is not.
=> In some cases, the barcode even seem to not print at all since
it's new coordinates are out of screen.
4. Apply patch.
5. Generate the batch again.
6. Note the barcode now appears exactly where it should.
Signed-off-by: George Veranis <gveranis@dataly.gr>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
On bug 17591 we discovered that there was something weird going on with
the way we export and use subroutines/modules.
This patch tries to standardize our EXPORT to use EXPORT_OK only.
That way we will need to explicitely define the subroutine we want to
use from a module.
This patch is a squashed version of:
Bug 17600: After export.pl
Bug 17600: After perlimport
Bug 17600: Manual changes
Bug 17600: Other manual changes after second perlimports run
Bug 17600: Fix tests
And a lot of other manual changes.
export.pl is a dirty script that can be found on bug 17600.
"perlimport" is:
git clone https://github.com/oalders/App-perlimports.git
cd App-perlimports/
cpanm --installdeps .
export PERL5LIB="$PERL5LIB:/kohadevbox/koha/App-perlimports/lib"
find . \( -name "*.pl" -o -name "*.pm" \) -exec perl App-perlimports/script/perlimports --inplace-edit --no-preserve-unused --filename {} \;
The ideas of this patch are to:
* use EXPORT_OK instead of EXPORT
* perltidy the EXPORT_OK list
* remove '&' before the subroutine names
* remove some uneeded use statements
* explicitely import the subroutines we need within the controllers or
modules
Note that the private subroutines (starting with _) should not be
exported (and not used from outside of the module except from tests).
EXPORT vs EXPORT_OK (from
https://www.thegeekstuff.com/2010/06/perl-exporter-examples/)
"""
Export allows to export the functions and variables of modules to user’s namespace using the standard import method. This way, we don’t need to create the objects for the modules to access it’s members.
@EXPORT and @EXPORT_OK are the two main variables used during export operation.
@EXPORT contains list of symbols (subroutines and variables) of the module to be exported into the caller namespace.
@EXPORT_OK does export of symbols on demand basis.
"""
If this patch caused a conflict with a patch you wrote prior to its
push:
* Make sure you are not reintroducing a "use" statement that has been
removed
* "$subroutine" is not exported by the C4::$MODULE module
means that you need to add the subroutine to the @EXPORT_OK list
* Bareword "$subroutine" not allowed while "strict subs"
means that you didn't imported the subroutine from the module:
- use $MODULE qw( $subroutine list );
You can also use the fully qualified namespace: C4::$MODULE::$subroutine
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
We should remove the debug statements or use Koha::Logger when we want
to keep it.
Test plan:
Confirm that occurrences of remaining occurrences of DEBUG need to be
kept (historical scripts for instance)
Confirm that the occurrences removed by this patch can be removed
Confirm that the occurrences replaced by Koha::Logger are correct
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Looks good to me, noting a few minor points on BZ.
JD amended patch: replace "warn #Finished" with "#warn Finished", and
put the statement on a single line
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
We are using Koha::Logger when it makes sense to keep the info,
otherwise we simply remove it
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Bug 28572: Replace missing occurrence in misc/admin/koha-preferences
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This patch adds a .perlcriticrc (copied from qa-test-tools) and fixes
almost all perlcrictic violations according to this .perlcriticrc
The remaining violations are silenced out by appending a '## no critic'
to the offending lines. They can still be seen by using the --force
option of perlcritic
This patch also modify t/00-testcritic.t to check all Perl files using
the new .perlcriticrc.
I'm not sure if this test script is still useful as it is now equivalent
to `perlcritic --quiet .` and it looks like it is much slower
(approximatively 5 times slower on my machine)
Test plan:
1. Run `perlcritic --quiet .` from the root directory. It should output
nothing
2. Run `perlcritic --quiet --force .`. It should output 7 errors (6
StringyEval, 1 BarewordFileHandles)
3. Run `TEST_QA=1 prove t/00-testcritic.t`
4. Read the patch. Check that all changes make sense and do not
introduce undesired behaviour
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
When wrapping long lines of text, the line is divided by removing each
word from the end of the line and putting it in a new one until the line
is the right width. When the word to be removed appears multiple time
in the line, it is not the last occurrence that is removed.
This patch changes the regular expression used to remove the part of
the text that is wrapped to a new line, making sure it removes it at
the end of the text.
Test plan:
1. Go to Tools > Patron card creator
2. Have a card template and a card batch
-> If needs be, you can create them by using
New > Card template or New > Card batch
3. Create a layout and use one text field containing a long text with
at least one word which is repeated a minimum of 2 times
(preferably towrdds the end of the text, since it has to be picked
as one of the words to appear in the new line). You can use this:
one two three one two three one two three one two three
one two three one two three one two three one two three ...
4. Go to Manage > Card batches and export a batch
5. Choose the layout set up in 3.
6. Click the Export button and open the resulting pdf file
7. Notice all the repeated word have been grouped
-> For this example : all of the ones appear first, followed by
all the twos and only then the threes.
8. Apply patch
9. Repeat step 4 through 7
=> this time the order of the words has not changed!
Signed-off-by: Gabriel DeCarufel <gabriel@inlibro.com>
Signed-off-by: William Frazilien <william.frazilien@inlibro.com>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Text fields in Patron Card Text Layouts can contain regular
expression metacharacters, which - instead of being treated as
literal values - are interpreted and prevent line wrapping. This
causes the process to get stuck in an infinite loop, which keeps
running even after the web server has timed out (at least when
using CGI).
This patch escapes the relevant input from the text field so the
regular expression substitution treats characters as literals
instead of as metacharacters.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
== Test plan ==
This is an oversimplification of a full patron card setup used in production.
1. Create a batch with 1 patron
2. Create a layout and set
the name
"Print card number as barcode"
"Barcode type:" to "Code 39"
3. Create a card template without filling anything
4. Export the batch using the layout and template
5. You should have a white page with a barcode
And no errors in the relevant log file
This show that this setup isn't completely bogus
(although Code 39 is the only type working...)
6. Layout: set "Barcode type:" to Industrial2of5
7. Export the batch
8. You should have a white page with no barcode
And errors in the relevant log file
"Invalid Characters"
This is the bug.
9. Layout: set "Barcode type:" to COOP2of5
10. Export the batch
11. You should have a white page with no barcode
And errors in the relevant log file
"Invalid Characters"
This is the bug.
12. Apply this patch
13. Retry with both non-working patches
1. You should have a white page with a barcode
2. And no errors in the relevant log file
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This patch simply adds POD descriptions to subs affected by first patch.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
To reproduce:
Text, images and barcode positions are always layed out based on PostScript points, regardless of unit defined in card layout.
To reproduce:
- Test on top of Bug 18541 (introduces layout grid)
- Create a card layout with a text field, an image and a barcode. Use points
as layout unit
- Activate layout grid
- Create PDF output, save
- Change layout unit to mm
- Create PDF output, save
- Compare PDFs. Verify that the positions are unchanged (still using points)
To test:
- Apply patch
- Create again PDF
- Verify that elements are positionad as expected (using unit, e.g. mm)
- Bonus test: Repeat with other units
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Add description to POD for draw_guide_grid
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Amended: Moved the description from draw_guide_box to .._grid.
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Just adding the POD framework to make qa tools happy. The authors
are encouraged to complete this information.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Add a layout grid to patron card creator to figure out the positions of text
fields, barcode and images.
To test:
- Apply on top of patch 18465
- Go to Home > Tools > Patron card creator
- Edit or create a layout
- Turn on new choice 'Guide grid' in section 'General settings'
- Leave 'Units' unchanged
- Crate a PDF using 'Card batches'
- Notice that card is printed with a layout grid that reflects selected unit
with each 5th and 10th line in different color, unit description displayed
bottom left, card dimensions displayed top right in small print inside the
layout grid
- Print PDF. Set printer settings in Adobe Reader or other PDF printing
software to 'Actual size' to prevent scaling to printer's printable
region
- Mesure out printed PDF and verify that grid corresponds to selecte unit.
- Go back to layout definition and choose an other unit, repeat steps
to verify that grid respects selected unit.
- Go back to layout definition, turn grid off, create PDF, verify that grid
does not display in PDF
Note for testers / QAers: Position of card elements (text, image...) do not
respect the unit, this will be fixed in Bug 18550
Followed test plan and it worked as intended
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Fields with underscore like B_address do not print on patron cards.
To reproduce:
- Create patron card layout using fields with underscore in their name
(e.g. <surname><B_address> )
- Print (export) patron card
- Verify that fields without underscore are replaced by their value,
but fields with underscore do not replace but show the field name
To test:
- Apply patch
- Try to reproduce and verify that fields with underscore are replace
as expected
Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Mainly a
perl -p -i -e 's/^.*3.07.00.049.*\n//' **/*.pm
Then some adjustements
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
The size of the barcode in patron card creator was hardcoded to 1% of the card height and 80% of the card width.
This patch exposes both values in the layout editor. If no values are given, the previousely hard coded values (0.01 / 0.8) are used in order to work with existing card definitions.
To test:
- Go to Home > Tools > Patron card creator
- Export a patron card (PDF) from en existing definition
- Apply patch
- Export patron card again, compare results (should be the same)
- Go to Home > Tools > Patron card creator > Manage card layouts
- Edit the layout you use for testing and set barcode scaling values e.g. to 0.03 for height and 0.4 for widht
- Export patron card again, verify that barcode size changed
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>
Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Most of them were found and fixed using codespell.
Fix also some related grammar issues.
In C4/Serials.pm a variable was renamed to make future codespelling
checks easier.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
http://bugs.koha-community.org/show_bug.cgi?id=14383
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
http://bugs.koha-community.org/show_bug.cgi?id=9987
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This patch provides a much better quality of images on patron cards.
It inserts images at a higher resolution into the PDF file and then scales it down internally in PDF.
Additionaly, the patch removes the follwing warning:
"my" variable $template masks earlier declaration in same scope at /usr/share/kohaclone/patroncards/create-pdf.pl line 66
To test:
- Create patron cards, save them as PDF and display them with a PDF viewer, e.g. at 400%
- Without patch, the images are very pixelated.
- Apply patch
- Verify that in the PDF the images now display with a much better quality.
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This change is similar to Bug 8375 which introduced ttf fonts for
labels printing in order to support diacritics and utf-8 encoding,
but this change was never implemented for patron cards.
Test scenario:
1. make sure that you have <ttf> font mapping in koha-conf.xml
2. define partron card layout, template, profile and batch
(with utf-8 chars, probably in patron firstname or surname)
3. verify that without this patch pdf export file is error message
Wide character in compress at /usr/share/perl5/PDF/Reuse.pm line 820
4. apply this patch and verify that generated pdf has correct encoding
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This patch touches a lot of code, but basically it removes version
information from use C4::* in our code.
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
All script still compiles after the patch (confirmed by pre-applypatch hook)
Can't use an undefined value as an ARRAY reference at /home/koha/koha.prod/C4/Patroncards/Patroncard.pm line 86.
This is caused by testing for text at line 87 rather than line 85. This patch moves the test to line 85.
This patch fixes two bugs:
1. Correcting the text alignment alogrithms for center and right alignment
2. Changes a reference to layout to a copy of the layout to avoid performing
operations on the layout.
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
As discussed with Chris Nighswonger on #koha, this patch
removes the calls to syslog and replaces them with warns
so that error messages generated by the labels code
are sent to the Apache error log. This avoids splitting
this sort of logging across multiple files and is consistent
with current practice in most of the rest of Koha.
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This is simply cut&paste from the older labels module code in an effort to preserve the existing patron card code for use
in the patron card creator module. This is NOT functioning code at the moment.