Bug 23473: Allow overwrite of passwords during 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                 [% END %]
119             </ul>
120         </div>
121     [% END %]
122 [% ELSE %]
123     <ul>
124         <li>Select a file to import into the borrowers table</li>
125         <li>If a cardnumber exists in the table, you can choose whether to ignore the new one or overwrite the old one.</li>
126     </ul>
127
128     <form method="post" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data">
129         <fieldset class="rows">
130             <legend>Import into the borrowers table</legend>
131
132             <ol>
133                 <li>
134                     <label for="uploadborrowers">Select the file to import: </label>
135                     <input type="file" id="uploadborrowers" name="uploadborrowers" />
136                 </li>
137
138                 <li>
139                     <label for "createpatronlist">Create patron list: </label>
140                     <input name="createpatronlist" id="createpatronlist" value="1" type="checkbox">
141                     <span class="hint">List name will be file name with timestamp</span>
142                 </li>
143             </ol>
144         </fieldset>
145
146         <fieldset class="rows">
147             <legend>Field to use for record matching</legend>
148             <ol>
149                 <li class="radio">
150                     <select name="matchpoint" id="matchpoint">
151                         <option value="cardnumber">Cardnumber</option>
152                         <option value="userid">Username</option>
153                         [% FOREACH matchpoint IN matchpoints %]
154                             <option value="[% matchpoint.code | html %]">[% matchpoint.description | html %]</option>
155                         [% END %]
156                     </select>
157                 </li>
158             </ol>
159         </fieldset>
160
161         <fieldset class="rows">
162             <legend>
163                 <a href="#" class="expand_defaults"><i class="fa fa-plus-square"></i> Enter default values</a>
164                 <a href="#" class="expand_defaults" style="display:none;"><i class="fa fa-minus-square"></i> Hide default value fields</a>
165             </legend>
166
167             <ol class="default_values" style="display:none;">
168                 [% FOREACH borrower_field IN borrower_fields %]
169
170                     [% SWITCH borrower_field.field %]
171                     [% CASE 'branchcode' %]
172                         <li>
173                             <label class="description" for="branchcode">[% borrower_field.description | html %]: </label>
174                             <select id="branchcode" name="branchcode">
175                                 <option value="" selected="selected"></option>
176                                 [% FOREACH library IN Branches.all() %]
177                                     <option value="[% library.branchcode | html %]">[% library.branchname | html %]</option>
178                                 [% END %]
179                             </select>
180                             <span class="field_hint">[% borrower_field.field | html %]</span>
181                         </li>
182                     [% CASE 'categorycode' %]
183                         <li>
184                             <label class="description" for="categorycode">[% borrower_field.description | html %]: </label>
185                             <select id="categorycode" name="categorycode">
186                                 <option value="" selected="selected"></option>
187                                 [% FOREACH category IN categories %]
188                                     <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
189                                 [% END %]
190                             </select>
191                             <span class="field_hint">[% borrower_field.field | html %]</span>
192                         </li>
193                     [% CASE %]
194                         <li>
195                             <label class="description" for="[% borrower_field.field | html %]">[% borrower_field.description | html %]: </label>
196                             <input id="[% borrower_field.field | html %]" name="[% borrower_field.field | html %]" type="text" />
197                             <span class="field_hint">[% borrower_field.field | html %]</span>
198                         </li>
199                     [% END %]
200                 [% END %]
201
202                 [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
203                     <li>
204                         <label class="description" for="patron_attributes">Patron attributes: </label>
205                         <input id="patron_attributes" name="patron_attributes" type="text" />
206                         <span class="field_hint">patron_attributes</span>
207                     </li>
208                 [% END %]
209
210             </ol>
211         </fieldset>
212
213         <fieldset class="rows">
214             <legend>If matching record is already in the borrowers table:</legend>
215
216             <ol>
217                 <li class="radio">
218                     <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>
219                 </li>
220
221                 <li class="radio">
222                     <input type="radio" id="overwrite_cardnumberyes" name="overwrite_cardnumber" value="1" /><label for="overwrite_cardnumberyes">Overwrite the existing one with this</label>
223                     <ul>
224                         <li>
225                             <input type="checkbox" id="overwrite_passwords" name="overwrite_passwords" disabled="true"/>
226                             <label for="overwrite_passwords">Replace patron passwords with those in the file</label>
227                         </li
228                     </ul>
229                 </li>
230             </ol>
231         </fieldset>
232
233         [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
234             <fieldset class="rows">
235                 <legend>Patron attributes</legend>
236
237                 <ol>
238                     <li class="radio">
239                         <input type="radio" id="ext_preserve_0" name="ext_preserve" value="0" /><label for="ext_preserve_0">Replace all patron attributes</label>
240                     </li>
241
242                     <li class="radio">
243                         <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>
244                     </li>
245                 </ol>
246             </fieldset>
247         [% END %]
248
249         <fieldset class="action">
250             <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
251             <input type="submit" value="Import" />
252         </fieldset>
253     </form>
254 [% END %]
255
256 </div>
257
258 <div class="col-sm-6">
259     <h2>Notes:</h2>
260     <ul>
261         <li>The first line in the file must be a header row defining which columns you are supplying in the import file.</li>
262
263         <li><b>Download a starter CSV file with all the columns <a href="?sample=1">here</a>.</b>  Values are comma-separated.</li>
264
265         <li>
266             OR choose which fields you want to supply from the following list:
267             <ul>
268                 <li>
269                     [% FOREACH columnkey IN borrower_fields %]'[% columnkey.field | html %]', [% END %]
270                 </li>
271             </ul>
272         </li>
273
274         [% IF ( Koha.Preference('ExtendedPatronAttributes') ) %]
275             <li>
276                 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.
277             </li>
278         [% END %]
279
280         <li>
281             <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.
282         </li>
283
284         <li>
285             '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.
286         </li>
287
288         <li>
289             Date formats should match your system preference, and <b>must</b> be zero-padded, e.g. '01/02/2008'.  Alternatively,
290 you can supply dates in ISO format (e.g., '2010-10-28').
291         </li>
292     </ul>
293 </div>
294 </div>
295
296             </main>
297         </div> <!-- /.col-sm-10.col-sm-push-2 -->
298
299         <div class="col-sm-2 col-sm-pull-10">
300             <aside>
301                 [% INCLUDE 'tools-menu.inc' %]
302             </aside>
303         </div> <!-- .col-sm-2.col-sm-pull-10 -->
304      </div> <!-- /.row -->
305
306 [% MACRO jsinclude BLOCK %]
307     [% INCLUDE 'calendar.inc' %]
308     [% Asset.js("js/tools-menu.js") | $raw %]
309     [% INCLUDE 'str/members-menu.inc' %]
310     [% Asset.js("js/members-menu.js") | $raw %]
311     <script>
312         $(document).ready(function() {
313             [%# Make date fields have the datepicker %]
314             $("#dateenrolled, #dateexpiry, #dateofbirth").datepicker();
315
316             $(".expand_defaults").click(function(e){
317                 e.preventDefault();
318                 $(".default_values").toggle();
319                 $(".expand_defaults").toggle();
320             });
321         });
322
323         $("#overwrite_cardnumberno").click(function(){
324             $("#overwrite_passwords").prop('checked',false).prop('disabled',true);
325         });
326         $("#overwrite_cardnumberyes").click(function(){
327             $("#overwrite_passwords").prop('disabled',false);
328         });
329     </script>
330 [% END %]
331 [% INCLUDE 'intranet-bottom.inc' %]