View | Details | Raw Unified | Return to bug 12716
Collapse All | Expand All

(-)a/C4/Templates.pm (+47 lines)
Lines 307-310 sub getlanguagecookie { Link Here
307
    return $cookie;
307
    return $cookie;
308
}
308
}
309
309
310
=head2 GetColumnDefs
311
312
    my $columns = GetColumnDefs( $cgi )
313
314
It is passed a CGI object and returns a hash of hashes containing
315
the column names and descriptions for each table defined in the
316
columns.def file corresponding to the CGI object.
317
318
=cut
319
320
sub GetColumnDefs {
321
322
    my $query = shift;
323
324
    my $columns = {};
325
326
    my $htdocs = C4::Context->config('intrahtdocs');
327
    my $columns_file = 'columns.def';
328
329
    # Get theme and language to build the path to columns.def
330
    my ($theme, $lang, $availablethemes) =
331
        themelanguage($htdocs, 'about.tt', 'intranet', $query);
332
    # Build columns.def path
333
    my $path = "$htdocs/$theme/$lang/$columns_file";
334
    my $fh;
335
    if ( ! open ( $fh, q{<}, $path ) )  {
336
        carp "Error opening $path. Check your templates.";
337
        return;
338
    }
339
    # Loop through the columns.def file
340
    while ( my $input = <$fh> ){
341
        chomp $input;
342
        if ( $input =~ m|<field name="(.*)">(.*)</field>| ) {
343
            my ( $table, $column ) =  split( '\.', $1);
344
            my $description        = $2;
345
            # Initialize the table array if needed.
346
            @{$columns->{ $table }} = () if ! defined $columns->{ $table };
347
            # Push field and description
348
            push @{$columns->{ $table }},
349
                { field => $column, description => $description };
350
        }
351
    }
352
    close $fh;
353
354
    return $columns;
355
}
356
310
1;
357
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (+6 lines)
Lines 1844-1849 fieldset.rows+h3 {clear:both;padding-top:.5em;} Link Here
1844
    padding-bottom: 10px;
1844
    padding-bottom: 10px;
1845
}
1845
}
1846
1846
1847
.field_hint {
1848
    color: grey;
1849
    font-style: italic;
1850
    padding-left: 1em;
1851
}
1852
1847
.m880 {
1853
.m880 {
1848
    display:block; 
1854
    display:block; 
1849
    text-align:right; 
1855
    text-align:right; 
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt (-8 / +52 lines)
Lines 1-15 Link Here
1
[% USE Koha %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Import patrons [% IF ( uploadborrowers ) %]&rsaquo; Results[% END %]</title>
3
<title>Koha &rsaquo; Tools &rsaquo; Import patrons [% IF ( uploadborrowers ) %]&rsaquo; Results[% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
4
<style type="text/css">
5
<style type="text/css">
5
    .yui-u fieldset.rows label.widelabel { width: 12em; }
6
    .yui-u fieldset.rows .widelabel { width: 12em; }
7
    label.description { width: 20em; }
6
    .line_error { width: 100%; }
8
    .line_error { width: 100%; }
7
    code { background-color: yellow; }
9
    code { background-color: yellow; }
8
</style>
10
</style>
11
<script type="text/javascript">
12
//<![CDATA[
13
    $(document).ready(function() {
14
        [%# Make date fields have the datepicker %]
15
        $("#dateenrolled").addClass('datepicker');
16
        $("#dateexpiry").addClass('datepicker');
17
        $("#dateofbirth").addClass('datepicker');
18
    });
19
</script>
9
</head>
20
</head>
10
<body id="tools_import_borrowers" class="tools">
21
<body id="tools_import_borrowers" class="tools">
11
[% INCLUDE 'header.inc' %]
22
[% INCLUDE 'header.inc' %]
12
[% INCLUDE 'patron-search.inc' %]
23
[% INCLUDE 'patron-search.inc' %]
24
[% INCLUDE 'calendar.inc' %]
13
25
14
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/tools/import_borrowers.pl">Import patrons</a>[% IF ( uploadborrowers ) %] &rsaquo; Results[% END %]</div>
26
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/tools/import_borrowers.pl">Import patrons</a>[% IF ( uploadborrowers ) %] &rsaquo; Results[% END %]</div>
15
27
Lines 112-123 Link Here
112
<fieldset class="rows">
124
<fieldset class="rows">
113
<legend>Default values</legend>
125
<legend>Default values</legend>
114
<ol>
126
<ol>
115
    [% FOREACH columnkey IN columnkeys %]
127
[% FOREACH borrower_field IN borrower_fields %]
116
	<li>
128
  [% SWITCH borrower_field.field %]
117
        <label class="widelabel" for="[% columnkey.key %]">[% columnkey.key %]: </label>
129
  [% CASE 'branchcode' %]
118
		<input id="[% columnkey.key %]" name="[% columnkey.key %]" />
130
    <li>
119
	</li>
131
        <label class="description" for="branchcode">[% borrower_field.description %]: </label>
120
    [% END %]
132
        <select id="branchcode" name="branchcode">
133
            <option value="" selected="selected"></option>
134
        [% FOREACH branch IN branches %]
135
            <option value="[% branch.branchcode %]">
136
                [% branch.branchname %]</option>
137
        [% END %]
138
        </select><span class="field_hint">[% borrower_field.field %]</span>
139
    </li>
140
  [% CASE 'categorycode' %]
141
    <li>
142
        <label class="description" for="categorycode">[% borrower_field.description %]: </label>
143
        <select id="categorycode" name="categorycode">
144
            <option value="" selected="selected"></option>
145
        [% FOREACH category IN categories %]
146
            <option value="[% category.categorycode %]">
147
                [% category.description %]</option>
148
        [% END %]
149
        </select><span class="field_hint">[% borrower_field.field %]</span>
150
    </li>
151
  [% CASE %]
152
    <li>
153
        <label class="description" for="[% borrower_field.field %]">[% borrower_field.description %]: </label>
154
        <input id="[% borrower_field.field %]" name="[% borrower_field.field %]" /><span class="field_hint">[% borrower_field.field %]</span>
155
    </li>
156
  [% END %]
157
[% END %]
158
[% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
159
    <li>
160
        <label class="description" for="patron_attributes">Patron attributes: </label>
161
        <input id="patron_attributes" name="patron_attributes" />
162
        <span class="field_hint">patron_attributes</span>
163
    </li>
164
[% END %]
121
</ol></fieldset>
165
</ol></fieldset>
122
	<fieldset class="rows">
166
	<fieldset class="rows">
123
	<legend>If matching record is already in the borrowers table:</legend>
167
	<legend>If matching record is already in the borrowers table:</legend>
Lines 129-135 Link Here
129
        </li>
173
        </li>
130
    </ol>
174
    </ol>
131
    </fieldset>
175
    </fieldset>
132
    [% IF ( ExtendedPatronAttributes ) %]
176
    [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
133
	<fieldset class="rows">
177
	<fieldset class="rows">
134
    <legend>Patron attributes</legend>
178
    <legend>Patron attributes</legend>
135
    <ol><li class="radio">
179
    <ol><li class="radio">
(-)a/tools/import_borrowers.pl (-9 / +11 lines)
Lines 41-51 use C4::Auth; Link Here
41
use C4::Output;
41
use C4::Output;
42
use C4::Dates qw(format_date_in_iso);
42
use C4::Dates qw(format_date_in_iso);
43
use C4::Context;
43
use C4::Context;
44
use C4::Branch qw(GetBranchName);
44
use C4::Branch qw/GetBranchesLoop GetBranchName/;
45
use C4::Members;
45
use C4::Members;
46
use C4::Members::Attributes qw(:all);
46
use C4::Members::Attributes qw(:all);
47
use C4::Members::AttributeTypes;
47
use C4::Members::AttributeTypes;
48
use C4::Members::Messaging;
48
use C4::Members::Messaging;
49
use C4::Reports::Guided;
50
use C4::Templates;
49
use Koha::Borrower::Debarments;
51
use Koha::Borrower::Debarments;
50
52
51
use Text::CSV;
53
use Text::CSV;
Lines 60-69 my (@errors, @feedback); Link Here
60
my $extended = C4::Context->preference('ExtendedPatronAttributes');
62
my $extended = C4::Context->preference('ExtendedPatronAttributes');
61
my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences');
63
my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences');
62
my @columnkeys = C4::Members::columns();
64
my @columnkeys = C4::Members::columns();
63
if ($extended) {
64
    push @columnkeys, 'patron_attributes';
65
}
66
my $columnkeystpl = [ map { {'key' => $_} }  grep {$_ ne 'borrowernumber' } @columnkeys ];  # ref. to array of hashrefs.
67
65
68
my $input = CGI->new();
66
my $input = CGI->new();
69
our $csv  = Text::CSV->new({binary => 1});  # binary needed for non-ASCII Unicode
67
our $csv  = Text::CSV->new({binary => 1});  # binary needed for non-ASCII Unicode
Lines 78-84 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ Link Here
78
        debug           => 1,
76
        debug           => 1,
79
});
77
});
80
78
81
$template->param(columnkeys => $columnkeystpl);
79
# get the branches and pass them to the template
80
my $branches = GetBranchesLoop();
81
$template->param( branches => $branches ) if ( $branches );
82
# get the patron categories and pass them to the template
83
my $categories = GetBorrowercategoryList();
84
$template->param( categories => $categories ) if ( $categories );
85
my $columns = C4::Templates::GetColumnDefs( $input );
86
$template->param( borrower_fields => $columns->{borrowers} );
82
87
83
if ($input->param('sample')) {
88
if ($input->param('sample')) {
84
    print $input->header(
89
    print $input->header(
Lines 98-105 my $overwrite_cardnumber = $input->param('overwrite_cardnumber'); Link Here
98
103
99
$template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'} );
104
$template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'} );
100
105
101
($extended) and $template->param(ExtendedPatronAttributes => 1);
102
103
if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
106
if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
104
    push @feedback, {feedback=>1, name=>'filename', value=>$uploadborrowers, filename=>$uploadborrowers};
107
    push @feedback, {feedback=>1, name=>'filename', value=>$uploadborrowers, filename=>$uploadborrowers};
105
    my $handle = $input->upload('uploadborrowers');
108
    my $handle = $input->upload('uploadborrowers');
106
- 

Return to bug 12716