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