Bug 27920: (QA follow-up) Change radios to a single select pulldown
[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>
8     [% IF ( uploadborrowers ) %]
9         Results &rsaquo; [% END %]
10     Import patrons &rsaquo; Tools &rsaquo; Koha
11 </title>
12 [% INCLUDE 'doc-head-close.inc' %]
13 <style>
14     label.description { width: 20em; }
15     .line_error { width: 100%; }
16     code { background-color: yellow; }
17 </style>
18 </head>
19
20 <body id="tools_import_borrowers" class="tools">
21 [% WRAPPER 'header.inc' %]
22     [% INCLUDE 'patron-search-header.inc' %]
23 [% END %]
24
25 [% WRAPPER 'sub-header.inc' %]
26 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
27     <ol>
28         <li>
29             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
30         </li>
31         <li>
32             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
33         </li>
34         [% IF ( uploadborrowers ) %]
35             <li>
36                 <a href="/cgi-bin/koha/tools/import_borrowers.pl">Import patrons</a>
37             </li>
38             <li>
39                 <a href="#" aria-current="page">
40                     Results
41                 </a>
42             </li>
43         [% ELSE %]
44             <li>
45                 <a href="#" aria-current="page">
46                     Import patrons
47                 </a>
48             </li>
49         [% END %]
50     </ol>
51 </nav>
52 [% END %]
53
54 [% INCLUDE 'blocking_errors.inc' %]
55 <div class="main container-fluid">
56     <div class="row">
57         <div class="col-sm-10 col-sm-push-2">
58             <main>
59
60     <div class="row">
61      <div class="col-sm-6">
62 <h1>Import patrons</h1>
63 [% IF ( uploadborrowers ) %]
64     <h5>Import results :</h5>
65     <ul>
66         <li>[% imported | html %] imported records [% IF ( lastimported ) %](last was [% lastimported | html %])[% END %]</li>
67         [% IF imported and patronlistname %]
68             <li>Patronlist with imported patrons: [% patronlistname | html %]</li>
69         [% END %]
70         <li>[% overwritten | html %] overwritten [% IF ( lastoverwritten ) %](last was [% lastoverwritten | html %])[% END %]</li>
71         <li>[% alreadyindb | html %] not imported because already in borrowers table and overwrite disabled [% IF ( lastalreadyindb ) %](last was [% lastalreadyindb | html %])[% END %]</li>
72         <li>[% invalid | html %] not imported because they are not in the expected format [% IF ( lastinvalid ) %](last was [% lastinvalid | html %])[% END %]</li>
73         <li>[% total | html %] records parsed</li>
74         <li><a href="/cgi-bin/koha/tools/tools-home.pl">Back to Tools</a></li>
75     </ul>
76
77     [% IF ( feedback ) %]
78         <br /><br />
79
80         <div>
81             <h5>Feedback:</h5>
82                 <ul class="feedback">
83                     [% FOREACH f IN feedback %]
84                         <li>
85                             [% IF ( f.filename ) %]
86                                 <span>Parsing upload file</span> <span class="filename">[% f.filename | html %]</span>
87                             [% ELSIF ( f.backend ) %]
88                                 <span>Upload parsed using [% f.backend | html %]</span>
89                             [% ELSIF ( f.headerrow ) %]
90                                 <span>These fields found: [% f.value | html %]</span>
91                             [% ELSIF ( f.already_in_db ) %]
92                                 <span>Patron already in database: [% f.value | html %]</span>
93                             [% ELSE %]
94                                 [% f.name | html %] : [% f.value | html %]
95                             [% END %]
96                         </li>
97                     [% END %]
98                 </ul>
99         </div>
100     [% END %]
101
102     [% IF ( errors ) %]
103         <br /><br />
104
105         <div>
106             <h5>Error analysis:</h5>
107             <ul>
108                 [% FOREACH e IN errors %]
109                     [% IF ( e.badheader ) %]<li>Header row could not be parsed</li>[% END %]
110
111                     [% FOREACH missing_critical IN e.missing_criticals %]
112                         <li class="line_error">
113                             Line <span class="linenumber">[% missing_critical.line | html %]</span>
114
115                             [% IF ( missing_critical.badparse ) %]
116                                 <span>could not be parsed!</span>
117                             [% ELSIF ( missing_critical.bad_date ) %]
118                                 <span>has &quot;[% missing_critical.key | html %]&quot; in unrecognized format:</span> &quot;[% missing_critical.value | html %]&quot;
119                             [% ELSE %]
120                                 <span>Critical field &quot;[% missing_critical.key | html %]&quot;</span>
121
122                                 [% IF ( missing_critical.branch_map ) %]
123                                     <span>has unrecognized value &quot;[% missing_critical.value | html %]&quot;</span>
124                                 [% ELSIF ( missing_critical.category_map ) %]
125                                     <span>has unrecognized value &quot;[% missing_critical.value | html %]&quot;</span>
126                                 [% ELSE %]
127                                     <span>missing</span>
128                                 [% END %]
129
130                                 (<span>borrowernumber: [% missing_critical.borrowernumber | html %]</span>; <span>surname: [% missing_critical.surname | html %]</span>).
131                             [% END %]
132
133                             <br/>
134                             <code>[% missing_critical.lineraw | html %]</code>
135                         </li>
136                     [% END %]
137
138                     [% IF e.invalid_cardnumber %]
139                         <li class="line_error">
140                             Card number [% e.cardnumber | html %] is not a valid card number
141                             [% IF e.borrowernumber %] (for patron with borrowernumber [% e.borrowernumber | html %])[% END %]
142                         </li>
143                     [% END %]
144                     [% IF e.duplicate_userid %]
145                         <li class="line_error">
146                             Userid [% e.userid | html %] is already used by another patron.
147                         </li>
148                     [% END %]
149                     [% IF e.passwd_too_short %]
150                         <li class="line_error">
151                             Password is too short for patron with borrowernumber [% e.borrowernumber | html %]. Minimum length is [% e.min_length | html %], length is [% e.length | html %]
152                         </li>
153                     [% END %]
154                     [% IF e.passwd_whitespace %]
155                         <li class="line_error">
156                             Password contains whitespace for patron with borrowernumber [% e.borrowernumber | html %].
157                         </li>
158                     [% END %]
159                     [% IF e.passwd_too_weak %]
160                         <li class="line_error">
161                             Password is too weak for patron with borrowernumber [% e.borrowernumber | html %].
162                         </li>
163                     [% END %]
164                     [% IF e.passwd_plugin_err %]
165                         <li class="line_error">
166                             Password plugin error for patron with borrowernumber [% e.borrowernumber | html %].
167                         </li>
168                     [% END %]
169                     [% IF e.passwd_unknown_err %]
170                         <li class="line_error">
171                             Password error for patron with borrowernumber [% e.borrowernumber | html %].
172                         </li>
173                     [% END %]
174                     [% IF e.patron_attribute_unique_id_constraint %]
175                         <li class="line_error">
176                             [% IF e.borrowernumber %]
177                                 <span>Patron attribute [% e.attribute.code | html %] must be unique for patron with borrowernumber [% e.borrowernumber | html %].</span>
178                             [% ELSE %]
179                                 <span>Patron attribute [% e.attribute.code | html %] must be unique for patron [% e.patron_id | html %].</span>
180                             [% END %]
181                         </li>
182                     [% END %]
183                     [% IF e.patron_attribute_invalid_type %]
184                         <li class="line_error">
185                             [% IF e.borrowernumber %]
186                                 <span>Patron attribute [% e.attribute_type_code | html %] is invalid for patron with borrowernumber [% e.borrowernumber | html %].</span>
187                             [% ELSE %]
188                                 <span>Patron attribute [% e.attribute_type_code | html %] is invalid for patron [% e.patron_id | html %].</span>
189                             [% END %]
190                         </li>
191                     [% END %]
192                     [% IF e.patron_attribute_non_repeatable %]
193                         <li class="line_error">
194                             [% IF e.borrowernumber %]
195                                 <span>Patron attribute [% e.attribute.code | html %] is non-repeatable for patron with borrowernumber [% e.borrowernumber | html %].</span>
196                             [% ELSE %]
197                                 <span>Patron attribute [% e.attribute.code | html %] is non-repeatable for patron [% e.patron_id | html %].</span>
198                             [% END %]
199                         </li>
200                     [% END %]
201                 [% END %]
202             </ul>
203         </div>
204     [% END %]
205 [% ELSE %]
206     <ul>
207         <li>Select a file to import into the borrowers table</li>
208         <li>If a card number exists in the table, you can choose whether to ignore the new one or overwrite the old one.</li>
209     </ul>
210
211     <form method="post" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data">
212         <fieldset class="rows">
213             <legend>Import into the borrowers table</legend>
214
215             <ol>
216                 <li>
217                     <label for="uploadborrowers">Select the file to import: </label>
218                     <input type="file" id="uploadborrowers" name="uploadborrowers" />
219                 </li>
220
221                 <li>
222                     <label for "createpatronlist">Create patron list: </label>
223                     <input name="createpatronlist" id="createpatronlist" value="1" type="checkbox">
224                     <span class="hint">List name will be file name with timestamp</span>
225                 </li>
226             </ol>
227         </fieldset>
228
229         <fieldset class="rows">
230             <legend>Field to use for record matching</legend>
231             <ol>
232                 <li class="radio">
233                     <select name="matchpoint" id="matchpoint">
234                         <option value="cardnumber">Card number</option>
235                         <option value="userid">Username</option>
236                         [% FOREACH matchpoint IN matchpoints %]
237                             <option value="[% matchpoint.code | html %]">[% matchpoint.description | html %]</option>
238                         [% END %]
239                     </select>
240                 </li>
241             </ol>
242         </fieldset>
243
244         <fieldset class="rows">
245             <legend>
246                 <a href="#" class="expand_defaults"><i class="fa fa-plus-square"></i> Enter default values</a>
247                 <a href="#" class="expand_defaults" style="display:none;"><i class="fa fa-minus-square"></i> Hide default value fields</a>
248             </legend>
249
250             <ol class="default_values" style="display:none;">
251                 [% FOREACH borrower_db_column IN borrower_fields.keys.sort %]
252                     [% SWITCH borrower_db_column %]
253                     [% CASE 'branchcode' %]
254                         <li>
255                             <label class="description" for="branchcode">[% borrower_fields.$borrower_db_column | html %]: </label>
256                             <select id="branchcode" name="branchcode">
257                                 <option value="" selected="selected"></option>
258                                 [% FOREACH library IN Branches.all() %]
259                                     <option value="[% library.branchcode | html %]">[% library.branchname | html %]</option>
260                                 [% END %]
261                             </select>
262                             <span class="field_hint">[% borrower_db_column | html %]</span>
263                         </li>
264                     [% CASE 'categorycode' %]
265                         <li>
266                             <label class="description" for="categorycode">[% borrower_fields.$borrower_db_column | html %]: </label>
267                             <select id="categorycode" name="categorycode">
268                                 <option value="" selected="selected"></option>
269                                 [% FOREACH category IN categories %]
270                                     <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
271                                 [% END %]
272                             </select>
273                             <span class="field_hint">[% borrower_db_column | html %]</span>
274                         </li>
275                     [% CASE %]
276                         <li>
277                             <label class="description" for="[% borrower_db_column| html %]">[% borrower_fields.$borrower_db_column | html %]: </label>
278                             <input id="[% borrower_db_column | html %]" name="[% borrower_db_column | html %]" type="text" />
279                             <span class="field_hint">[% borrower_db_column | html %]</span>
280                         </li>
281                     [% END %]
282                 [% END %]
283
284                 [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
285                     <li>
286                         <label class="description" for="patron_attributes">Patron attributes: </label>
287                         <input id="patron_attributes" name="patron_attributes" type="text" />
288                         <span class="field_hint">patron_attributes</span>
289                     </li>
290                 [% END %]
291
292             </ol>
293         </fieldset>
294         <fieldset class="rows">
295             <legend>
296                 <a href="#" class="expand_preserves"><i class="fa fa-plus-square"></i> Preserve existing values</a>
297                 <a href="#" class="expand_preserves" style="display:none;"><i class="fa fa-minus-square"></i> Hide preserve value fields</a>
298             </legend>
299
300             <ol class="preserve_values" style="display:none;">
301                 <div class="hint">Selected fields will be preserved from original patron record when overwriting existing patron.</div>
302                 [% FOREACH borrower_db_column IN borrower_fields.keys.sort %]
303                         <li>
304                             <label class="description" for="preserve_existing_[% borrower_db_column | html %]">[% borrower_fields.$borrower_db_column | html %]: </label>
305                             <input name="preserve_existing" id="preserve_existing_[%  borrower_db_column | html %]" value="[%  borrower_db_column | html %]" type="checkbox">
306                             <span class="field_hint">[% borrower_db_column | html %]</span>
307                         </li>
308                 [% END %]
309             </ol>
310         </fieldset>
311
312         <fieldset class="rows">
313             <legend>If matching record is already in the borrowers table:</legend>
314
315             <ol>
316                 <li class="radio">
317                     <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>
318                 </li>
319
320                 <li class="radio">
321                     <input type="radio" id="overwrite_cardnumberyes" name="overwrite_cardnumber" value="1" /><label for="overwrite_cardnumberyes">Overwrite the existing one with this</label>
322                     <ul>
323                         <li>
324                             <label class="update_dateexpiry" for="update_dateexpiry">Renew existing patrons</label>
325                             <select class="update_dateexpiry" type="select" id="update_dateexpiry" name="update_dateexpiry" disabled/>
326                                 <option value="">using the datexpiry value in the file, if present</option>
327                                 <option value="dateexpiry">from the current membership expiry date</option>
328                                 <option value="now">from the current date</option>
329                             </select>
330                         </li>
331                         <li>
332                             <input class="overwrite_passwords" type="checkbox" id="overwrite_passwords" name="overwrite_passwords" disabled/>
333                             <label class="overwrite_passwords" for="overwrite_passwords">Replace patron passwords with those in the file (blank passwords will be ignored)</label>
334                         </li>
335                     </ul>
336                 </li>
337             </ol>
338         </fieldset>
339
340         [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
341             <fieldset class="rows">
342                 <legend>Patron attributes</legend>
343
344                 <ol>
345                     <li class="radio">
346                         <input type="radio" id="ext_preserve_0" name="ext_preserve" value="0" /><label for="ext_preserve_0">Replace all patron attributes</label>
347                     </li>
348
349                     <li class="radio">
350                         <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>
351                     </li>
352                 </ol>
353             </fieldset>
354         [% END %]
355
356         <fieldset class="rows">
357             <legend>Welcome email</legend>
358             <ol>
359                 <li>
360                     <input class="welcome_new" type="checkbox" id="welcome_new" name="welcome_new"/>
361                     <label class="welcome_new" for="welcome_new">Send email to new patrons</label>
362                     <span class="hint"> WELCOME notice is used</span>
363                 </li>
364             </ol>
365         </fieldset>
366
367         <fieldset class="action">
368             <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
369             <input type="submit" value="Import" />
370         </fieldset>
371     </form>
372 [% END %]
373
374 </div>
375
376 <div class="col-sm-6 page-section bg-info">
377     <h2>Notes:</h2>
378     <ul>
379         <li>The first line in the file must be a header row defining which columns you are supplying in the import file.</li>
380
381         <li><strong>Download a <a href="?sample=1">Starter CSV file</a> with all the columns.</strong>  Values are comma-separated.</li>
382
383         <li>
384             OR choose which fields you want to supply from the following list:
385             <ul>
386                 <li>
387                     [% FOREACH columnkey IN borrower_fields.keys.sort %]'[% columnkey | html %]', [% END %]
388                 </li>
389             </ul>
390         </li>
391
392         [% IF ( Koha.Preference('ExtendedPatronAttributes') ) %]
393             <li>
394                 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: <strong>INSTID:12345,LANG:fr</strong> or <strong>STARTDATE:January 1 2010,TRACK:Day</strong>. 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: <strong>&quot;STARTDATE:January 1, 2010&quot;,&quot;TRACK:Day&quot;</strong>.  The second syntax would be required if the data might have a comma in it, like a date string.
395             </li>
396         [% END %]
397
398         <li>
399             <strong>Required fields:</strong> The fields 'surname', 'branchcode', and 'categorycode' are <em>required</em> and 'branchcode' and 'categorycode' <strong>must match</strong> valid entries in your database.
400         </li>
401
402         <li>
403             '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.
404         </li>
405
406         <li>
407             Date formats should match your system preference, and <strong>must</strong> be zero-padded, e.g. '01/02/2008'.  Alternatively,
408 you can supply dates in ISO format (e.g., '2010-10-28').
409         </li>
410     </ul>
411 </div>
412 </div>
413
414             </main>
415         </div> <!-- /.col-sm-10.col-sm-push-2 -->
416
417         <div class="col-sm-2 col-sm-pull-10">
418             <aside>
419                 [% INCLUDE 'tools-menu.inc' %]
420             </aside>
421         </div> <!-- .col-sm-2.col-sm-pull-10 -->
422      </div> <!-- /.row -->
423
424 [% MACRO jsinclude BLOCK %]
425     [% INCLUDE 'calendar.inc' %]
426     [% Asset.js("js/tools-menu.js") | $raw %]
427     [% INCLUDE 'str/members-menu.inc' %]
428     [% Asset.js("js/members-menu.js") | $raw %]
429     <script>
430         $(document).ready(function() {
431             [%# Make date fields have the datepicker %]
432             $("#dateenrolled, #dateexpiry, #dateofbirth").flatpickr({
433                 altInput: true,
434                 altFormat: flatpickr_dateformat_string,
435                 altInputClass: 'flatpickr-input',
436                 dateFormat: "Y-m-d",
437             });
438
439             $(".expand_defaults").click(function(e){
440                 e.preventDefault();
441                 $(".default_values").toggle();
442                 $(".expand_defaults").toggle();
443             });
444
445             $(".expand_preserves").click(function(e){
446                 e.preventDefault();
447                 $(".preserve_values").toggle();
448                 $(".expand_preserves").toggle();
449             });
450         });
451
452         $("#overwrite_cardnumberno").click(function(){
453             $("#overwrite_passwords").prop('checked',false).prop('disabled',true);
454             $("#update_dateexpiry").prop('checked',false).prop('disabled',true);
455             $("#update_dateexpiry_from_today").prop('checked',false).prop('disabled',true);
456         });
457         $("#overwrite_cardnumberyes").click(function(){
458             $("#overwrite_passwords").prop('disabled',false);
459             $("#update_dateexpiry").prop('disabled',false);
460             $("#update_dateexpiry_from_today").prop('disabled',false);
461         });
462     </script>
463 [% END %]
464 [% INCLUDE 'intranet-bottom.inc' %]