Bugzilla – Attachment 63242 Details for
Bug 18555
Create patron list from patron import
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18555: Create patron list from patron import
Bug-18555-Create-patron-list-from-patron-import.patch (text/plain), 5.12 KB, created by
Marc Véron
on 2017-05-08 14:28:17 UTC
(
hide
)
Description:
Bug 18555: Create patron list from patron import
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2017-05-08 14:28:17 UTC
Size:
5.12 KB
patch
obsolete
>From 0e5dd418db6a531d6ffe0641afcad79c3edbb99b Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Mon, 8 May 2017 16:18:41 +0200 >Subject: [PATCH] Bug 18555: Create patron list from patron import > >Create a patron list from imported patrons to be used for printing patron >cards and other patron list related actions. > >To test: >- Apply patch >- Go to Home > Tools > Import patrons >- Select a file to import and check new checkbox 'Create patron list' >- Import file >- Verify that in import results you see the time stamped name of the > patronlist containig the imported patrons (if any patrons were imported) >- Go to Home > Tools > Patron lists >- Verify that the list shows up and contains the imported patrons >--- > .../prog/en/modules/tools/import_borrowers.tt | 9 +++++++++ > tools/import_borrowers.pl | 23 ++++++++++++++++++++++ > 2 files changed, 32 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt >index ea3a3c9..7e8245d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt >@@ -37,6 +37,9 @@ > <h5>Import results :</h5> > <ul> > <li>[% imported %] imported records [% IF ( lastimported ) %](last was [% lastimported %])[% END %]</li> >+ [% IF imported and patronlistname %] >+ <li>Patronlist with imported patrons: [% patronlistname %]</li> >+ [% END %] > <li>[% overwritten %] overwritten [% IF ( lastoverwritten ) %](last was [% lastoverwritten %])[% END %]</li> > <li>[% alreadyindb %] not imported because already in borrowers table and overwrite disabled [% IF ( lastalreadyindb ) %](last was [% lastalreadyindb %])[% END %]</li> > <li>[% invalid %] not imported because they are not in the expected format [% IF ( lastinvalid ) %](last was [% lastinvalid %])[% END %]</li> >@@ -113,6 +116,12 @@ > <label for="uploadborrowers">Select the file to import: </label> > <input type="file" id="uploadborrowers" name="uploadborrowers" /> > </li> >+ <li> >+ <label for "createpatronlist">Create patron list: </label> >+ <input name="createpatronlist" id="createpatronlist" value="1" type="checkbox"> >+ <span class="hint">List name will be file name with timestamp</span> >+ </li> >+ > </ol></fieldset> > <fieldset class="rows"> > <legend>Field to use for record matching</legend> >diff --git a/tools/import_borrowers.pl b/tools/import_borrowers.pl >index 58c2266..ab8e230 100755 >--- a/tools/import_borrowers.pl >+++ b/tools/import_borrowers.pl >@@ -52,6 +52,7 @@ use Koha::DateUtils; > use Koha::Token; > use Koha::Libraries; > use Koha::Patron::Categories; >+use Koha::List::Patron; > > use Text::CSV; > # Text::CSV::Unicode, even in binary mode, fails to parse lines with these diacriticals: >@@ -105,6 +106,12 @@ if ($matchpoint) { > } > my $overwrite_cardnumber = $input->param('overwrite_cardnumber'); > >+#create a patronlist >+my $createpatronlist = $input->param('createpatronlist') || 0; >+my $dt = dt_from_string(); >+my $timestamp = $dt->ymd('-').' '.$dt->hms(':'); >+my $patronlistname = $uploadborrowers . ' (' . $timestamp .')'; >+ > $template->param( SCRIPT_NAME => '/cgi-bin/koha/tools/import_borrowers.pl' ); > > if ( $uploadborrowers && length($uploadborrowers) > 0 ) { >@@ -114,13 +121,21 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > token => scalar $input->param('csrf_token'), > }); > >+ #create a patronlist >+ my $createpatronlist = $input->param('createpatronlist'); >+ my $dt = dt_from_string(); >+ my $timestamp = $dt->ymd('-').' '.$dt->hms(':'); >+ my $patronlistname = $uploadborrowers. ' (' . $timestamp .')'; >+ > push @feedback, {feedback=>1, name=>'filename', value=>$uploadborrowers, filename=>$uploadborrowers}; > my $handle = $input->upload('uploadborrowers'); > my $uploadinfo = $input->uploadInfo($uploadborrowers); > foreach (keys %$uploadinfo) { > push @feedback, {feedback=>1, name=>$_, value=>$uploadinfo->{$_}, $_=>$uploadinfo->{$_}}; > } >+ > my $imported = 0; >+ my @imported_borrowers; > my $alreadyindb = 0; > my $overwritten = 0; > my $invalid = 0; >@@ -355,6 +370,7 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > > $imported++; > $template->param('lastimported'=>$borrower{'surname'}.' / '.$borrowernumber); >+ push @imported_borrowers, $borrowernumber; #for patronlist > } else { > $invalid++; > push @errors, {unknown_error => 1}; >@@ -362,6 +378,13 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > } > } > } >+ >+ if ( $imported && $createpatronlist ) { >+ my $patronlist = AddPatronList({ name => $patronlistname }); >+ AddPatronsToList({ list => $patronlist, borrowernumbers => \@imported_borrowers }); >+ $template->param('patronlistname' => $patronlistname); >+ } >+ > (@errors ) and $template->param( ERRORS=>\@errors ); > (@feedback) and $template->param(FEEDBACK=>\@feedback); > $template->param( >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18555
:
63241
|
63242
|
63284
|
65614
|
65852
|
65853