Bug 19012: Note additional columns that are required during patron 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>Default values</legend>
163
164             <ol>
165                 [% FOREACH borrower_field IN borrower_fields %]
166
167                     [% SWITCH borrower_field.field %]
168                     [% CASE 'branchcode' %]
169                         <li>
170                             <label class="description" for="branchcode">[% borrower_field.description | html %]: </label>
171                             <select id="branchcode" name="branchcode">
172                                 <option value="" selected="selected"></option>
173                                 [% FOREACH library IN Branches.all() %]
174                                     <option value="[% library.branchcode | html %]">[% library.branchname | html %]</option>
175                                 [% END %]
176                             </select>
177                             <span class="field_hint">[% borrower_field.field | html %]</span>
178                         </li>
179                     [% CASE 'categorycode' %]
180                         <li>
181                             <label class="description" for="categorycode">[% borrower_field.description | html %]: </label>
182                             <select id="categorycode" name="categorycode">
183                                 <option value="" selected="selected"></option>
184                                 [% FOREACH category IN categories %]
185                                     <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
186                                 [% END %]
187                             </select>
188                             <span class="field_hint">[% borrower_field.field | html %]</span>
189                         </li>
190                     [% CASE %]
191                         <li>
192                             <label class="description" for="[% borrower_field.field | html %]">[% borrower_field.description | html %]: </label>
193                             <input id="[% borrower_field.field | html %]" name="[% borrower_field.field | html %]" type="text" />
194                             <span class="field_hint">[% borrower_field.field | html %]</span>
195                         </li>
196                     [% END %]
197                 [% END %]
198
199                 [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
200                     <li>
201                         <label class="description" for="patron_attributes">Patron attributes: </label>
202                         <input id="patron_attributes" name="patron_attributes" type="text" />
203                         <span class="field_hint">patron_attributes</span>
204                     </li>
205                 [% END %]
206
207             </ol>
208         </fieldset>
209
210         <fieldset class="rows">
211             <legend>If matching record is already in the borrowers table:</legend>
212
213             <ol>
214                 <li class="radio">
215                     <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>
216                 </li>
217
218                 <li class="radio">
219                     <input type="radio" id="overwrite_cardnumberyes" name="overwrite_cardnumber" value="1" /><label for="overwrite_cardnumberyes">Overwrite the existing one with this</label>
220                 </li>
221             </ol>
222         </fieldset>
223
224         [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
225             <fieldset class="rows">
226                 <legend>Patron attributes</legend>
227
228                 <ol>
229                     <li class="radio">
230                         <input type="radio" id="ext_preserve_0" name="ext_preserve" value="0" /><label for="ext_preserve_0">Replace all patron attributes</label>
231                     </li>
232
233                     <li class="radio">
234                         <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>
235                     </li>
236                 </ol>
237             </fieldset>
238         [% END %]
239
240         <fieldset class="action">
241             <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
242             <input type="submit" value="Import" />
243         </fieldset>
244     </form>
245 [% END %]
246
247 </div>
248
249 <div class="col-sm-6">
250     <h2>Notes:</h2>
251     <ul>
252         <li>The first line in the file must be a header row defining which columns you are supplying in the import file.</li>
253
254         <li><b>Download a starter CSV file with all the columns <a href="?sample=1">here</a>.</b>  Values are comma-separated.</li>
255
256         <li>
257             OR choose which fields you want to supply from the following list:
258             <ul>
259                 <li>
260                     [% FOREACH columnkey IN borrower_fields %]'[% columnkey.field | html %]', [% END %]
261                 </li>
262             </ul>
263         </li>
264
265         [% IF ( Koha.Preference('ExtendedPatronAttributes') ) %]
266             <li>
267                 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.
268             </li>
269         [% END %]
270
271         <li>
272             <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.
273         </li>
274
275         <li>
276             '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).
277         </li>
278
279         <li>
280             Date formats should match your system preference, and <b>must</b> be zero-padded, e.g. '01/02/2008'.  Alternatively,
281 you can supply dates in ISO format (e.g., '2010-10-28').
282         </li>
283     </ul>
284 </div>
285 </div>
286
287             </main>
288         </div> <!-- /.col-sm-10.col-sm-push-2 -->
289
290         <div class="col-sm-2 col-sm-pull-10">
291             <aside>
292                 [% INCLUDE 'tools-menu.inc' %]
293             </aside>
294         </div> <!-- .col-sm-2.col-sm-pull-10 -->
295      </div> <!-- /.row -->
296
297 [% MACRO jsinclude BLOCK %]
298     [% INCLUDE 'calendar.inc' %]
299     [% Asset.js("js/tools-menu.js") | $raw %]
300     [% INCLUDE 'str/members-menu.inc' %]
301     [% Asset.js("js/members-menu.js") | $raw %]
302     <script>
303         $(document).ready(function() {
304             [%# Make date fields have the datepicker %]
305             $("#dateenrolled, #dateexpiry, #dateofbirth").datepicker();
306         });
307     </script>
308 [% END %]
309 [% INCLUDE 'intranet-bottom.inc' %]