0d29051ad3
Reasoning Librarians will be doing patron card things in the following frequencies, from most frequent to least frequent: 1. Creating new patron card batches - every day/every few days 2. Managing existing card batches - every day/every few days 3. Managing existing card layouts - as needed, infrequent 5. Managing existing card templates - as needed, infrequent 6. Creating new card layouts - as needed, infrequent 7. Creating new card templates - as needed, infrequent 8. Managing existing printer profiles - possibly once only! 9. Creating new printer profiles - possibly once only! This change to the patron card creator aims to make the most frequently used items easily accessible at the top of the main area, reduces clutter on the page, and makes the label creator fall in line with UI paradigms found elsewhere in Koha. I think I've also improved the translatability here somewhat, please check that. To test: Open the patron card creator: More -> Tools -> Patron card creator Note that the toolbar has changed. It should be consistent across all of the patron card creator (it is an include). + New menu: patron card batch 1. make sure it looks ok - toolbar buttons are consistent at the top of the main block. 2. add patrons both by borrowernumber, and by search 3. note that the usual buttons have moved below the textarea, and now have icons. 4. delete and export single patrons using the buttons corresponding to each patron 5. select multiple and use the buttons above the table to remove and export selected patrons 6. export a full batch 7. deduplicate a batch There should be no regressions in functionality. Image 1. This menu item should take you directly to the upload/delete images interface 2. Upload an image, note success message is now below the form, eliminating the jumping box. 3. Delete single images using the buttons 4. Delete multiple images using the tickboxes and "Delete selected" 5. Not deletion success message is below the table, eliminating the jumping box. Layout 1. This menu item should take you directly to the "Edit layout" screen. 2. no functional changes here. 3. note toolbar at top is consistent Card template 1. this menu item should take you directly to the "Edit patron card template" page. 2. no functional changes here. 3. note toolbar at top is consistent. Printer profile 1. this menu item should take you directly to the "Edit printer profile" page. 2. no functional changes here. 3. note toolbar at top is consistent. + Manage menu: Card batches 1. This menu item should take you directly to the "currently available batches" page. 2. select a batch to edit using the buttons - it should take you to the editing interface 3. select a batch to delete using the buttons - it should ask for confirm. 4. select several batches using the tickboxes, and select Export selected. Batches should be exported as normal. 5. note toolbar at top is consistent. Images (this is actually the same page as on the new menu, I included it in both because it does both functions - can change if requested) 1. This menu item should take you directly to the upload/delete images interface 2. Upload an image, note success message is now below the form, eliminating the jumping box. 3. Delete single images using the buttons 4. Delete multiple images using the tickboxes and "Delete selected" 5. Not deletion success message is below the table, eliminating the jumping box. Layouts 1. This menu item should take you directly to the "currently available layouts" page. 2. select a layout to edit using the buttons 3. select a layout to delete using the buttons 4. note toolbar at top is consistent. Card templates 1. This menu item should take you directly to the "currently available templates" page. 2. select a template to edit using the buttons 3. select a template to delete using the buttons 4. note toolbar at top is consistent. Printer profiles 1. This menu item should take you directly to the "currently available profiles" page. 2. select a profile to edit using the buttons 3. select a profile to delete using the buttons 4. note toolbar at top is consistent + General * note that sidebar now only has "labels home" instead of the full "manage" list. It seemed redundant with the toolbar tidied up. Please note that I am happy to take suggestions/amendments to these changes. Followed test plan, behaves as advertised. Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
192 lines
6.5 KiB
Perl
Executable file
192 lines
6.5 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
use strict;
|
|
|
|
use CGI qw ( -utf8 );
|
|
use Graphics::Magick;
|
|
use POSIX qw(ceil);
|
|
use autouse 'Data::Dumper' => qw(Dumper);
|
|
|
|
use C4::Context;
|
|
use C4::Auth;
|
|
use C4::Output;
|
|
use C4::Debug;
|
|
use C4::Creators;
|
|
use C4::Patroncards;
|
|
|
|
my $cgi = CGI->new;
|
|
|
|
my ($template, $loggedinuser, $cookie) = get_template_and_user({
|
|
template_name => "patroncards/image-manage.tt",
|
|
query => $cgi,
|
|
type => "intranet",
|
|
authnotrequired => 0,
|
|
flagsrequired => {tools => 'batch_upload_patron_images'}, # FIXME: establish flag for patron card creator
|
|
debug => 0,
|
|
});
|
|
|
|
my $image_name = $cgi->param('image_name') || '';
|
|
my $file_name = $cgi->param('uploadfile') || '';
|
|
my $upload_file = $cgi->upload('uploadfile') || '';
|
|
my $op = $cgi->param('op') || 'none';
|
|
my @image_ids = $cgi->param('image_id') if $cgi->param('image_id');
|
|
|
|
my $source_file = "$file_name"; # otherwise we end up with what amounts to a pointer to a filehandle rather than a user-friendly filename
|
|
|
|
my $display_columns = { image => [ #{db column => {label => 'col label', is link? }},
|
|
{image_id => {label => 'ID', link_field => 0}},
|
|
{image_name => {label => 'Name', link_field => 0}},
|
|
{_delete => {label => 'Delete', link_field => 0}},
|
|
{select => {label => 'Select', value => 'image_id'}},
|
|
],
|
|
};
|
|
my $table = html_table($display_columns->{'image'}, get_image(undef, "image_id, image_name"));
|
|
|
|
my $image_limit = C4::Context->preference('ImageLimit') || '';
|
|
my $errstr = ''; # NOTE: For error codes see error-messages.inc
|
|
|
|
if ($op eq 'upload') {
|
|
if (!$upload_file) {
|
|
warn sprintf('An error occurred while attempting to upload file %s.', $source_file);
|
|
$errstr = 301;
|
|
$template->param(
|
|
IMPORT_SUCCESSFUL => 0,
|
|
SOURCE_FILE => $source_file,
|
|
IMAGE_NAME => $image_name,
|
|
TABLE => $table,
|
|
error => $errstr,
|
|
);
|
|
}
|
|
else {
|
|
my $image = Graphics::Magick->new;
|
|
eval{$image->Read($cgi->tmpFileName($file_name));};
|
|
if ($@) {
|
|
warn sprintf('An error occurred while creating the image object: %s',$@);
|
|
$errstr = 202;
|
|
$template->param(
|
|
IMPORT_SUCCESSFUL => 0,
|
|
SOURCE_FILE => $source_file,
|
|
IMAGE_NAME => $image_name,
|
|
TABLE => $table,
|
|
error => $errstr,
|
|
);
|
|
}
|
|
else {
|
|
my $errstr = '';
|
|
my $size = $image->Get('filesize');
|
|
$errstr = 302 if $size > 500000;
|
|
$image->Set(magick => 'png'); # convert all images to png as this is a lossless format which is important for resizing operations later on
|
|
my $err = put_image($image_name, $image->ImageToBlob()) || '0';
|
|
$errstr = 101 if $err == 1;
|
|
$errstr = 303 if $err == 202;
|
|
if ($errstr) {
|
|
$template->param(
|
|
IMPORT_SUCCESSFUL => 0,
|
|
SOURCE_FILE => $source_file,
|
|
IMAGE_NAME => $image_name,
|
|
TABLE => $table,
|
|
error => $errstr,
|
|
image_limit => $image_limit,
|
|
);
|
|
}
|
|
else {
|
|
$table = html_table($display_columns->{'image'}, get_image(undef, "image_id, image_name")); # refresh table data after successfully performing save operation
|
|
$template->param(
|
|
IMPORT_SUCCESSFUL => 1,
|
|
SOURCE_FILE => $source_file,
|
|
IMAGE_NAME => $image_name,
|
|
TABLE => $table,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
elsif ($op eq 'delete') {
|
|
my $err = '';
|
|
my $errstr = '';
|
|
if (@image_ids) {
|
|
$err = rm_image(\@image_ids);
|
|
$errstr = 102 if $err;
|
|
}
|
|
else {
|
|
warn sprintf('No image ids passed in to delete.');
|
|
$errstr = 202;
|
|
}
|
|
if ($errstr) {
|
|
$template->param(
|
|
DELETE_SUCCESSFULL => 0,
|
|
IMAGE_IDS => join(', ', @image_ids),
|
|
TABLE => $table,
|
|
error => $errstr,
|
|
image_ids => join(',',@image_ids),
|
|
);
|
|
}
|
|
else {
|
|
$table = html_table($display_columns->{'image'}, get_image(undef, "image_id, image_name")); # refresh table data after successfully performing delete operation
|
|
$template->param(
|
|
DELETE_SUCCESSFULL => 1,
|
|
TABLE => $table,
|
|
);
|
|
}
|
|
}
|
|
elsif ($op eq 'none') {
|
|
$template->param(
|
|
IMPORT_SUCCESSFUL => 0,
|
|
SOURCE_FILE => $source_file,
|
|
IMAGE_NAME => $image_name,
|
|
TABLE => $table,
|
|
);
|
|
}
|
|
else { # to trap unsupported operations
|
|
warn sprintf('Image upload interface called an unsupported operation: %s',$op);
|
|
$errstr = 201;
|
|
$template->param(
|
|
IMPORT_SUCCESSFUL => 0,
|
|
SOURCE_FILE => $source_file,
|
|
IMAGE_NAME => $image_name,
|
|
TABLE => $table,
|
|
error => $errstr,
|
|
);
|
|
}
|
|
|
|
output_html_with_http_headers $cgi, $cookie, $template->output;
|
|
|
|
__END__
|
|
|
|
=head1 NAME
|
|
|
|
image-upload.pl - Script for handling uploading of single images and importing them into the database.
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
image-upload.pl
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
This script is called and presents the user with an interface allowing him/her to upload a single image file. Files greater than 500K will be refused.
|
|
|
|
=head1 AUTHOR
|
|
|
|
Chris Nighswonger <cnighswonger AT foundations DOT edu>
|
|
|
|
=head1 COPYRIGHT
|
|
|
|
Copyright 2009 Foundations Bible College.
|
|
|
|
=head1 LICENSE
|
|
|
|
This file is part of Koha.
|
|
|
|
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
|
|
Foundation; either version 2 of the License, or (at your option) any later version.
|
|
|
|
You should have received a copy of the GNU General Public License along with Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
|
|
Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
=head1 DISCLAIMER OF WARRANTY
|
|
|
|
Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
=cut
|