Bug 23473: Don't allow setting blank passwords via import
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / import_borrowers.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE Branches %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Tools &rsaquo; Import patrons [% IF ( uploadborrowers ) %]&rsaquo; Results[% END %]</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 <style>
10     .yui-u fieldset.rows .widelabel { width: 12em; }
11     label.description { width: 20em; }
12     .line_error { width: 100%; }
13     code { background-color: yellow; }
14 </style>
15 </head>
16
17 <body id="tools_import_borrowers" class="tools">
18 [% INCLUDE 'header.inc' %]
19 [% INCLUDE 'patron-search.inc' %]
20
21 <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>
22
23 [% INCLUDE 'blocking_errors.inc' %]
24 <div class="main container-fluid">
25     <div class="row">
26         <div class="col-sm-10 col-sm-push-2">
27             <main>
28
29     <div class="row">
30      <div class="col-sm-6">
31 <h1>Import patrons</h1>
32 [% IF ( uploadborrowers ) %]
33     <h5>Import results :</h5>
34     <ul>
35         <li>[% imported | html %] imported records [% IF ( lastimported ) %](last was [% lastimported | html %])[% END %]</li>
36         [% IF imported and patronlistname %]
37             <li>Patronlist with imported patrons: [% patronlistname | html %]</li>
38         [% END %]
39         <li>[% overwritten | html %] overwritten [% IF ( lastoverwritten ) %](last was [% lastoverwritten | html %])[% END %]</li>
40         <li>[% alreadyindb | html %] not imported because already in borrowers table and overwrite disabled [% IF ( lastalreadyindb ) %](last was [% lastalreadyindb | html %])[% END %]</li>
41         <li>[% invalid | html %] not imported because they are not in the expected format [% IF ( lastinvalid ) %](last was [% lastinvalid | html %])[% END %]</li>
42         <li>[% total | html %] records parsed</li>
43         <li><a href="/cgi-bin/koha/tools/tools-home.pl">Back to Tools</a></li>
44     </ul>
45
46     [% IF ( feedback ) %]
47         <br /><br />
48
49         <div>
50             <h5>Feedback:</h5>
51                 <ul class="feedback">
52                     [% FOREACH f IN feedback %]
53                         <li>
54                             [% IF ( f.filename ) %]
55                                 Parsing upload file <span class="filename">[% f.filename | html %]</span>
56                             [% ELSIF ( f.backend ) %]
57                                 Upload parsed using [% f.backend | html %]
58                             [% ELSIF ( f.headerrow ) %]
59                                 These fields found: [% f.value | html %]
60                             [% ELSIF ( f.already_in_db ) %]
61                                 Patron already in database: [% f.value | html %]
62                             [% ELSE %]
63                                 [% f.name | html %] : [% f.value | html %]
64                             [% END %]
65                         </li>
66                     [% END %]
67                 </ul>
68         </div>
69     [% END %]
70
71     [% IF ( errors ) %]
72         <br /><br />
73
74         <div>
75             <h5>Error analysis:</h5>
76             <ul>
77                 [% FOREACH e IN errors %]
78                     [% IF ( e.badheader ) %]<li>Header row could not be parsed</li>[% END %]
79
80                     [% FOREACH missing_critical IN e.missing_criticals %]
81                         <li class="line_error">
82                             Line <span class="linenumber">[% missing_critical.line | html %]</span>
83
84                             [% IF ( missing_critical.badparse ) %]
85                                 could not be parsed!
86                             [% ELSIF ( missing_critical.bad_date ) %]
87                                 has &quot;[% missing_critical.key | html %]&quot; in unrecognized format: &quot;[% missing_critical.value | html %]&quot;
88                             [% ELSE %]
89                                 Critical field &quot;[% missing_critical.key | html %]&quot;
90
91                                 [% IF ( missing_critical.branch_map ) %]
92                                     has unrecognized value &quot;[% missing_critical.value | html %]&quot;
93                                 [% ELSIF ( missing_critical.category_map ) %]
94                                     has unrecognized value &quot;[% missing_critical.value | html %]&quot;
95                                 [% ELSE %]
96                                     missing
97                                 [% END %]
98
99                                 (borrowernumber: [% missing_critical.borrowernumber | html %]; surname: [% missing_critical.surname | html %]).
100                             [% END %]
101
102                             <br/>
103                             <code>[% missing_critical.lineraw | html %]</code>
104                         </li>
105                     [% END %]
106
107                     [% IF e.invalid_cardnumber %]
108                         <li class="line_error">
109                             Cardnumber [% e.cardnumber | html %] is not a valid cardnumber
110                             [% IF e.borrowernumber %] (for patron with borrowernumber [% e.borrowernumber | html %])[% END %]
111                         </li>
112                     [% END %]
113                     [% IF e.duplicate_userid %]
114                         <li class="line_error">
115                             Userid [% e.userid | html %] is already used by another patron.
116                         </li>
117                     [% END %]
118                     [% IF e.passwd_too_short %]
119                         <li class="line_error">
120                             Password is too short for patron with borrowernumber [% e.borrowernumber | html %]. Minimum length is [% e.min_length %], length is [% e.length %]
121                         </li>
122                     [% END %]
123                     [% IF e.passwd_whitespace %]
124                         <li class="line_error">
125                             Password contains whitespace for patron with borrowernumber [% e.borrowernumber | html %].
126                         </li>
127                     [% END %]
128                     [% IF e.passwd_too_weak %]
129                         <li class="line_error">
130                             Password is too weak for patron with borrowernumber [% e.borrowernumber | html %].
131                         </li>
132                     [% END %]
133                     [% IF e.passwd_plugin_err %]
134                         <li class="line_error">
135                             Password plugin error for patron with borrowernumber [% e.borrowernumber | html %].
136                         </li>
137                     [% END %]
138                     [% IF e.passwd_unknown_err %]
139                         <li class="line_error">
140                             Password error for patron with borrowernumber [% e.borrowernumber | html %].
141                         </li>
142                     [% END %]
143                 [% END %]
144             </ul>
145         </div>
146     [% END %]
147 [% ELSE %]
148     <ul>
149         <li>Select a file to import into the borrowers table</li>
150         <li>If a cardnumber exists in the table, you can choose whether to ignore the new one or overwrite the old one.</li>
151     </ul>
152
153     <form method="post" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data">
154         <fieldset class="rows">
155             <legend>Import into the borrowers table</legend>
156
157             <ol>
158                 <li>
159                     <label for="uploadborrowers">Select the file to import: </label>
160                     <input type="file" id="uploadborrowers" name="uploadborrowers" />
161                 </li>
162
163                 <li>
164                     <label for "createpatronlist">Create patron list: </label>
165                     <input name="createpatronlist" id="createpatronlist" value="1" type="checkbox">
166                     <span class="hint">List name will be file name with timestamp</span>
167                 </li>
168             </ol>
169         </fieldset>
170
171         <fieldset class="rows">
172             <legend>Field to use for record matching</legend>
173             <ol>
174                 <li class="radio">
175                     <select name="matchpoint" id="matchpoint">
176                         <option value="cardnumber">Cardnumber</option>
177                         <option value="userid">Username</option>
178                         [% FOREACH matchpoint IN matchpoints %]
179                             <option value="[% matchpoint.code | html %]">[% matchpoint.description | html %]</option>
180                         [% END %]
181                     </select>
182                 </li>
183             </ol>
184         </fieldset>
185
186         <fieldset class="rows">
187             <legend>
188                 <a href="#" class="expand_defaults"><i class="fa fa-plus-square"></i> Enter default values</a>
189                 <a href="#" class="expand_defaults" style="display:none;"><i class="fa fa-minus-square"></i> Hide default value fields</a>
190             </legend>
191
192             <ol class="default_values" style="display:none;">
193                 [% FOREACH borrower_field IN borrower_fields %]
194
195                     [% SWITCH borrower_field.field %]
196                     [% CASE 'branchcode' %]
197                         <li>
198                             <label class="description" for="branchcode">[% borrower_field.description | html %]: </label>
199                             <select id="branchcode" name="branchcode">
200                                 <option value="" selected="selected"></option>
201                                 [% FOREACH library IN Branches.all() %]
202                                     <option value="[% library.branchcode | html %]">[% library.branchname | html %]</option>
203                                 [% END %]
204                             </select>
205                             <span class="field_hint">[% borrower_field.field | html %]</span>
206                         </li>
207                     [% CASE 'categorycode' %]
208                         <li>
209                             <label class="description" for="categorycode">[% borrower_field.description | html %]: </label>
210                             <select id="categorycode" name="categorycode">
211                                 <option value="" selected="selected"></option>
212                                 [% FOREACH category IN categories %]
213                                     <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
214                                 [% END %]
215                             </select>
216                             <span class="field_hint">[% borrower_field.field | html %]</span>
217                         </li>
218                     [% CASE %]
219                         <li>
220                             <label class="description" for="[% borrower_field.field | html %]">[% borrower_field.description | html %]: </label>
221                             <input id="[% borrower_field.field | html %]" name="[% borrower_field.field | html %]" type="text" />
222                             <span class="field_hint">[% borrower_field.field | html %]</span>
223                         </li>
224                     [% END %]
225                 [% END %]
226
227                 [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
228                     <li>
229                         <label class="description" for="patron_attributes">Patron attributes: </label>
230                         <input id="patron_attributes" name="patron_attributes" type="text" />
231                         <span class="field_hint">patron_attributes</span>
232                     </li>
233                 [% END %]
234
235             </ol>
236         </fieldset>
237
238         <fieldset class="rows">
239             <legend>If matching record is already in the borrowers table:</legend>
240
241             <ol>
242                 <li class="radio">
243                     <input type="radio" id="overwrite_cardnumberno" name="overwrite_cardnumber" value="0" checked="checked" /><label for="overwrite_cardnumberno">Ignore this one, keep the existing one</label>
244                 </li>
245
246                 <li class="radio">
247                     <input type="radio" id="overwrite_cardnumberyes" name="overwrite_cardnumber" value="1" /><label for="overwrite_cardnumberyes">Overwrite the existing one with this</label>
248                     <ul>
249                         <li>
250                             <input class="overwrite_passwords" type="checkbox" id="overwrite_passwords" name="overwrite_passwords" disabled/>
251                             <label class="overwrite_passwords" for="overwrite_passwords">Replace patron passwords with those in the file (blank passwords will be ignored)</label>
252                         </li
253                     </ul>
254                 </li>
255             </ol>
256         </fieldset>
257
258         [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
259             <fieldset class="rows">
260                 <legend>Patron attributes</legend>
261
262                 <ol>
263                     <li class="radio">
264                         <input type="radio" id="ext_preserve_0" name="ext_preserve" value="0" /><label for="ext_preserve_0">Replace all patron attributes</label>
265                     </li>
266
267                     <li class="radio">
268                         <input type="radio" id="ext_preserve_1" name="ext_preserve" value="1" checked="checked" /><label for="ext_preserve_1">Replace only included patron attributes</label>
269                     </li>
270                 </ol>
271             </fieldset>
272         [% END %]
273
274         <fieldset class="action">
275             <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
276             <input type="submit" value="Import" />
277         </fieldset>
278     </form>
279 [% END %]
280
281 </div>
282
283 <div class="col-sm-6">
284     <h2>Notes:</h2>
285     <ul>
286         <li>The first line in the file must be a header row defining which columns you are supplying in the import file.</li>
287
288         <li><b>Download a starter CSV file with all the columns <a href="?sample=1">here</a>.</b>  Values are comma-separated.</li>
289
290         <li>
291             OR choose which fields you want to supply from the following list:
292             <ul>
293                 <li>
294                     [% FOREACH columnkey IN borrower_fields %]'[% columnkey.field | html %]', [% END %]
295                 </li>
296             </ul>
297         </li>
298
299         [% IF ( Koha.Preference('ExtendedPatronAttributes') ) %]
300             <li>
301                 If loading patron attributes, the 'patron_attributes' field should contain a comma-separated list of attribute types and values. The attribute type code and a colon should precede each value. For example: <b>INSTID:12345,LANG:fr</b> or <b>STARTDATE:January 1 2010,TRACK:Day</b>. If an input record has more than one attribute, the fields should either be entered as an unquoted string (previous examples), or with each field wrapped in separate double quotes and delimited by a comma: <b>&quot;STARTDATE:January 1, 2010&quot;,&quot;TRACK:Day&quot;</b>.  The second syntax would be required if the data might have a comma in it, like a date string.
302             </li>
303         [% END %]
304
305         <li>
306             <strong>Required fields:</strong> The fields 'surname', 'branchcode', and 'categorycode' are <em>required</em> and 'branchcode' and 'categorycode' <b>must match</b> valid entries in your database.
307         </li>
308
309         <li>
310             'password' should be stored in plaintext, and will be converted to a Bcrypt hash (if your passwords are already encrypted, talk to your system administrator about options). Passwords will not be updated on overwrite unless replace passwords option is checked.
311         </li>
312
313         <li>
314             Date formats should match your system preference, and <b>must</b> be zero-padded, e.g. '01/02/2008'.  Alternatively,
315 you can supply dates in ISO format (e.g., '2010-10-28').
316         </li>
317     </ul>
318 </div>
319 </div>
320
321             </main>
322         </div> <!-- /.col-sm-10.col-sm-push-2 -->
323
324         <div class="col-sm-2 col-sm-pull-10">
325             <aside>
326                 [% INCLUDE 'tools-menu.inc' %]
327             </aside>
328         </div> <!-- .col-sm-2.col-sm-pull-10 -->
329      </div> <!-- /.row -->
330
331 [% MACRO jsinclude BLOCK %]
332     [% INCLUDE 'calendar.inc' %]
333     [% Asset.js("js/tools-menu.js") | $raw %]
334     [% INCLUDE 'str/members-menu.inc' %]
335     [% Asset.js("js/members-menu.js") | $raw %]
336     <script>
337         $(document).ready(function() {
338             [%# Make date fields have the datepicker %]
339             $("#dateenrolled, #dateexpiry, #dateofbirth").datepicker();
340
341             $(".expand_defaults").click(function(e){
342                 e.preventDefault();
343                 $(".default_values").toggle();
344                 $(".expand_defaults").toggle();
345             });
346         });
347
348         $("#overwrite_cardnumberno").click(function(){
349             $("#overwrite_passwords").prop('checked',false).prop('disabled',true);
350         });
351         $("#overwrite_cardnumberyes").click(function(){
352             $("#overwrite_passwords").prop('disabled',false);
353         });
354     </script>
355 [% END %]
356 [% INCLUDE 'intranet-bottom.inc' %]