Bugzilla – Attachment 30728 Details for
Bug 12716
Import patrons form should have drop-downs for some values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12716: Allow the import patrons form have drop-downs and datepickers
Bug-12716-Allow-the-import-patrons-form-have-drop-.patch (text/plain), 9.83 KB, created by
Biblibre Sandboxes
on 2014-08-12 05:17:56 UTC
(
hide
)
Description:
Bug 12716: Allow the import patrons form have drop-downs and datepickers
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2014-08-12 05:17:56 UTC
Size:
9.83 KB
patch
obsolete
>From 71e72ad1d0396ab099d351b484ae26af7dbc8f54 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Mon, 4 Aug 2014 12:31:24 -0300 >Subject: [PATCH] Bug 12716: Allow the import patrons form have drop-downs and datepickers > >To reproduce: >- Go to Tools > Import patrons >- Notice branchcode and categorycode don't have dropdown menus with > valid options. >- Notice dateofbirth, dateenrolled and dateexpiry don't have date-pickers >- Notice each input field is labeled with the column name instead of a > proper description. > >To test: >- Apply the patch, go to Tools > Import patrons >- Notice branchcode and categorycode have dropdown menus with valid options, > and by default the empty value is selected. >- Notice that if you go into the dateofbirth, dateenrolled and dateexpiry > fields, a nice date picker widget appears. >- Notice each field is labeled with the field description, and that the > column name is conveniently shown at the right of the input field. > >Important: test switching the ExtendedPatronAttributes syspref, and verify that >if enabled, the patron_attributes field appears, and also the checkbox selector >controlling the extended patron attributes import behaviour shows too. > >Bonus points: Verify that on a different language, the descriptions get translated, >and the column names show correctly > >Regards >To+ > >Signed-off-by: Aleisha <aleishaamohia@hotmail.com> >--- > C4/Templates.pm | 47 +++++++++++++++ > .../intranet-tmpl/prog/en/css/staff-global.css | 6 ++ > .../prog/en/modules/tools/import_borrowers.tt | 60 +++++++++++++++++--- > tools/import_borrowers.pl | 19 ++++--- > 4 files changed, 116 insertions(+), 16 deletions(-) > >diff --git a/C4/Templates.pm b/C4/Templates.pm >index 16eeec1..6a9d48b 100644 >--- a/C4/Templates.pm >+++ b/C4/Templates.pm >@@ -307,4 +307,51 @@ sub getlanguagecookie { > return $cookie; > } > >+=head2 GetColumnDefs >+ >+ my $columns = GetColumnDefs( $cgi ) >+ >+It is passed a CGI object and returns a hash of hashes containing >+the column names and descriptions for each table defined in the >+columns.def file corresponding to the CGI object. >+ >+=cut >+ >+sub GetColumnDefs { >+ >+ my $query = shift; >+ >+ my $columns = {}; >+ >+ my $htdocs = C4::Context->config('intrahtdocs'); >+ my $columns_file = 'columns.def'; >+ >+ # Get theme and language to build the path to columns.def >+ my ($theme, $lang, $availablethemes) = >+ themelanguage($htdocs, 'about.tt', 'intranet', $query); >+ # Build columns.def path >+ my $path = "$htdocs/$theme/$lang/$columns_file"; >+ my $fh; >+ if ( ! open ( $fh, q{<}, $path ) ) { >+ carp "Error opening $path. Check your templates."; >+ return; >+ } >+ # Loop through the columns.def file >+ while ( my $input = <$fh> ){ >+ chomp $input; >+ if ( $input =~ m|<field name="(.*)">(.*)</field>| ) { >+ my ( $table, $column ) = split( '\.', $1); >+ my $description = $2; >+ # Initialize the table array if needed. >+ @{$columns->{ $table }} = () if ! defined $columns->{ $table }; >+ # Push field and description >+ push @{$columns->{ $table }}, >+ { field => $column, description => $description }; >+ } >+ } >+ close $fh; >+ >+ return $columns; >+} >+ > 1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >index a4ef390..bbd8458 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -1844,6 +1844,12 @@ fieldset.rows+h3 {clear:both;padding-top:.5em;} > padding-bottom: 10px; > } > >+.field_hint { >+ color: grey; >+ font-style: italic; >+ padding-left: 1em; >+} >+ > .m880 { > display:block; > text-align:right; >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 40410f8..a0727b8 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 >@@ -1,15 +1,27 @@ >+[% USE Koha %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Tools › Import patrons [% IF ( uploadborrowers ) %]› Results[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] > <style type="text/css"> >- .yui-u fieldset.rows label.widelabel { width: 12em; } >+ .yui-u fieldset.rows .widelabel { width: 12em; } >+ label.description { width: 20em; } > .line_error { width: 100%; } > code { background-color: yellow; } > </style> >+<script type="text/javascript"> >+//<![CDATA[ >+ $(document).ready(function() { >+ [%# Make date fields have the datepicker %] >+ $("#dateenrolled").addClass('datepicker'); >+ $("#dateexpiry").addClass('datepicker'); >+ $("#dateofbirth").addClass('datepicker'); >+ }); >+</script> > </head> > <body id="tools_import_borrowers" class="tools"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'patron-search.inc' %] >+[% INCLUDE 'calendar.inc' %] > > <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › <a href="/cgi-bin/koha/tools/import_borrowers.pl">Import patrons</a>[% IF ( uploadborrowers ) %] › Results[% END %]</div> > >@@ -112,12 +124,44 @@ > <fieldset class="rows"> > <legend>Default values</legend> > <ol> >- [% FOREACH columnkey IN columnkeys %] >- <li> >- <label class="widelabel" for="[% columnkey.key %]">[% columnkey.key %]: </label> >- <input id="[% columnkey.key %]" name="[% columnkey.key %]" /> >- </li> >- [% END %] >+[% FOREACH borrower_field IN borrower_fields %] >+ [% SWITCH borrower_field.field %] >+ [% CASE 'branchcode' %] >+ <li> >+ <label class="description" for="branchcode">[% borrower_field.description %]: </label> >+ <select id="branchcode" name="branchcode"> >+ <option value="" selected="selected"></option> >+ [% FOREACH branch IN branches %] >+ <option value="[% branch.branchcode %]"> >+ [% branch.branchname %]</option> >+ [% END %] >+ </select><span class="field_hint">[% borrower_field.field %]</span> >+ </li> >+ [% CASE 'categorycode' %] >+ <li> >+ <label class="description" for="categorycode">[% borrower_field.description %]: </label> >+ <select id="categorycode" name="categorycode"> >+ <option value="" selected="selected"></option> >+ [% FOREACH category IN categories %] >+ <option value="[% category.categorycode %]"> >+ [% category.description %]</option> >+ [% END %] >+ </select><span class="field_hint">[% borrower_field.field %]</span> >+ </li> >+ [% CASE %] >+ <li> >+ <label class="description" for="[% borrower_field.field %]">[% borrower_field.description %]: </label> >+ <input id="[% borrower_field.field %]" name="[% borrower_field.field %]" /><span class="field_hint">[% borrower_field.field %]</span> >+ </li> >+ [% END %] >+[% END %] >+[% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %] >+ <li> >+ <label class="description" for="patron_attributes">Patron attributes: </label> >+ <input id="patron_attributes" name="patron_attributes" /> >+ <span class="field_hint">patron_attributes</span> >+ </li> >+[% END %] > </ol></fieldset> > <fieldset class="rows"> > <legend>If matching record is already in the borrowers table:</legend> >@@ -129,7 +173,7 @@ > </li> > </ol> > </fieldset> >- [% IF ( ExtendedPatronAttributes ) %] >+ [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %] > <fieldset class="rows"> > <legend>Patron attributes</legend> > <ol><li class="radio"> >diff --git a/tools/import_borrowers.pl b/tools/import_borrowers.pl >index abbef70..d99db2f 100755 >--- a/tools/import_borrowers.pl >+++ b/tools/import_borrowers.pl >@@ -41,11 +41,13 @@ use C4::Auth; > use C4::Output; > use C4::Dates qw(format_date_in_iso); > use C4::Context; >-use C4::Branch qw(GetBranchName); >+use C4::Branch qw/GetBranchesLoop GetBranchName/; > use C4::Members; > use C4::Members::Attributes qw(:all); > use C4::Members::AttributeTypes; > use C4::Members::Messaging; >+use C4::Reports::Guided; >+use C4::Templates; > use Koha::Borrower::Debarments; > > use Text::CSV; >@@ -60,10 +62,6 @@ my (@errors, @feedback); > my $extended = C4::Context->preference('ExtendedPatronAttributes'); > my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences'); > my @columnkeys = C4::Members::columns(); >-if ($extended) { >- push @columnkeys, 'patron_attributes'; >-} >-my $columnkeystpl = [ map { {'key' => $_} } grep {$_ ne 'borrowernumber' } @columnkeys ]; # ref. to array of hashrefs. > > my $input = CGI->new(); > our $csv = Text::CSV->new({binary => 1}); # binary needed for non-ASCII Unicode >@@ -78,7 +76,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ > debug => 1, > }); > >-$template->param(columnkeys => $columnkeystpl); >+# get the branches and pass them to the template >+my $branches = GetBranchesLoop(); >+$template->param( branches => $branches ) if ( $branches ); >+# get the patron categories and pass them to the template >+my $categories = GetBorrowercategoryList(); >+$template->param( categories => $categories ) if ( $categories ); >+my $columns = C4::Templates::GetColumnDefs( $input ); >+$template->param( borrower_fields => $columns->{borrowers} ); > > if ($input->param('sample')) { > print $input->header( >@@ -98,8 +103,6 @@ my $overwrite_cardnumber = $input->param('overwrite_cardnumber'); > > $template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'} ); > >-($extended) and $template->param(ExtendedPatronAttributes => 1); >- > if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > push @feedback, {feedback=>1, name=>'filename', value=>$uploadborrowers, filename=>$uploadborrowers}; > my $handle = $input->upload('uploadborrowers'); >-- >1.7.2.5
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 12716
:
30557
|
30558
|
30728
|
30729
|
30816
|
30817