Bug 23385: (follow-up) Update link
[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                 </li>
224             </ol>
225         </fieldset>
226
227         [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
228             <fieldset class="rows">
229                 <legend>Patron attributes</legend>
230
231                 <ol>
232                     <li class="radio">
233                         <input type="radio" id="ext_preserve_0" name="ext_preserve" value="0" /><label for="ext_preserve_0">Replace all patron attributes</label>
234                     </li>
235
236                     <li class="radio">
237                         <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>
238                     </li>
239                 </ol>
240             </fieldset>
241         [% END %]
242
243         <fieldset class="action">
244             <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
245             <input type="submit" value="Import" />
246         </fieldset>
247     </form>
248 [% END %]
249
250 </div>
251
252 <div class="col-sm-6">
253     <h2>Notes:</h2>
254     <ul>
255         <li>The first line in the file must be a header row defining which columns you are supplying in the import file.</li>
256
257         <li><b>Download a starter CSV file with all the columns <a href="?sample=1">here</a>.</b>  Values are comma-separated.</li>
258
259         <li>
260             OR choose which fields you want to supply from the following list:
261             <ul>
262                 <li>
263                     [% FOREACH columnkey IN borrower_fields %]'[% columnkey.field | html %]', [% END %]
264                 </li>
265             </ul>
266         </li>
267
268         [% IF ( Koha.Preference('ExtendedPatronAttributes') ) %]
269             <li>
270                 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.
271             </li>
272         [% END %]
273
274         <li>
275             <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.
276         </li>
277
278         <li>
279             '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).
280         </li>
281
282         <li>
283             Date formats should match your system preference, and <b>must</b> be zero-padded, e.g. '01/02/2008'.  Alternatively,
284 you can supply dates in ISO format (e.g., '2010-10-28').
285         </li>
286     </ul>
287 </div>
288 </div>
289
290             </main>
291         </div> <!-- /.col-sm-10.col-sm-push-2 -->
292
293         <div class="col-sm-2 col-sm-pull-10">
294             <aside>
295                 [% INCLUDE 'tools-menu.inc' %]
296             </aside>
297         </div> <!-- .col-sm-2.col-sm-pull-10 -->
298      </div> <!-- /.row -->
299
300 [% MACRO jsinclude BLOCK %]
301     [% INCLUDE 'calendar.inc' %]
302     [% Asset.js("js/tools-menu.js") | $raw %]
303     [% INCLUDE 'str/members-menu.inc' %]
304     [% Asset.js("js/members-menu.js") | $raw %]
305     <script>
306         $(document).ready(function() {
307             [%# Make date fields have the datepicker %]
308             $("#dateenrolled, #dateexpiry, #dateofbirth").datepicker();
309
310             $(".expand_defaults").click(function(e){
311                 e.preventDefault();
312                 $(".default_values").toggle();
313                 $(".expand_defaults").toggle();
314             });
315         });
316     </script>
317 [% END %]
318 [% INCLUDE 'intranet-bottom.inc' %]