1ced2d5a4965a299cf33f76cad0bf30e37a11cfe
[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 <div class="main container-fluid">
24     <div class="row">
25         <div class="col-sm-10 col-sm-push-2">
26             <main>
27
28     <div class="row">
29      <div class="col-sm-6">
30 <h1>Import patrons</h1>
31 [% IF ( uploadborrowers ) %]
32     <h5>Import results :</h5>
33     <ul>
34         <li>[% imported | html %] imported records [% IF ( lastimported ) %](last was [% lastimported | html %])[% END %]</li>
35         [% IF imported and patronlistname %]
36             <li>Patronlist with imported patrons: [% patronlistname | html %]</li>
37         [% END %]
38         <li>[% overwritten | html %] overwritten [% IF ( lastoverwritten ) %](last was [% lastoverwritten | html %])[% END %]</li>
39         <li>[% alreadyindb | html %] not imported because already in borrowers table and overwrite disabled [% IF ( lastalreadyindb ) %](last was [% lastalreadyindb | html %])[% END %]</li>
40         <li>[% invalid | html %] not imported because they are not in the expected format [% IF ( lastinvalid ) %](last was [% lastinvalid | html %])[% END %]</li>
41         <li>[% total | html %] records parsed</li>
42         <li><a href="/cgi-bin/koha/tools/tools-home.pl">Back to Tools</a></li>
43     </ul>
44
45     [% IF ( feedback ) %]
46         <br /><br />
47
48         <div>
49             <h5>Feedback:</h5>
50                 <ul class="feedback">
51                     [% FOREACH f IN feedback %]
52                         <li>
53                             [% IF ( f.filename ) %]
54                                 Parsing upload file <span class="filename">[% f.filename | html %]</span>
55                             [% ELSIF ( f.backend ) %]
56                                 Upload parsed using [% f.backend | html %]
57                             [% ELSIF ( f.headerrow ) %]
58                                 These fields found: [% f.value | html %]
59                             [% ELSIF ( f.already_in_db ) %]
60                                 Patron already in database: [% f.value | html %]
61                             [% ELSE %]
62                                 [% f.name | html %] : [% f.value | html %]
63                             [% END %]
64                         </li>
65                     [% END %]
66                 </ul>
67         </div>
68     [% END %]
69
70     [% IF ( errors ) %]
71         <br /><br />
72
73         <div>
74             <h5>Error analysis:</h5>
75             <ul>
76                 [% FOREACH e IN errors %]
77                     [% IF ( e.badheader ) %]<li>Header row could not be parsed</li>[% END %]
78
79                     [% FOREACH missing_critical IN e.missing_criticals %]
80                         <li class="line_error">
81                             Line <span class="linenumber">[% missing_critical.line | html %]</span>
82
83                             [% IF ( missing_critical.badparse ) %]
84                                 could not be parsed!
85                             [% ELSIF ( missing_critical.bad_date ) %]
86                                 has &quot;[% missing_critical.key | html %]&quot; in unrecognized format: &quot;[% missing_critical.value | html %]&quot;
87                             [% ELSE %]
88                                 Critical field &quot;[% missing_critical.key | html %]&quot;
89
90                                 [% IF ( missing_critical.branch_map ) %]
91                                     has unrecognized value &quot;[% missing_critical.value | html %]&quot;
92                                 [% ELSIF ( missing_critical.category_map ) %]
93                                     has unrecognized value &quot;[% missing_critical.value | html %]&quot;
94                                 [% ELSE %]
95                                     missing
96                                 [% END %]
97
98                                 (borrowernumber: [% missing_critical.borrowernumber | html %]; surname: [% missing_critical.surname | html %]).
99                             [% END %]
100
101                             <br/>
102                             <code>[% missing_critical.lineraw | html %]</code>
103                         </li>
104                     [% END %]
105
106                     [% IF e.invalid_cardnumber %]
107                         <li class="line_error">
108                             Cardnumber [% e.cardnumber | html %] is not a valid cardnumber
109                             [% IF e.borrowernumber %] (for patron with borrowernumber [% e.borrowernumber | html %])[% END %]
110                         </li>
111                     [% END %]
112                     [% IF e.duplicate_userid %]
113                         <li class="line_error">
114                             Userid [% e.userid | html %] is already used by another patron.
115                         </li>
116                     [% END %]
117                 [% END %]
118             </ul>
119         </div>
120     [% END %]
121 [% ELSE %]
122     <ul>
123         <li>Select a file to import into the borrowers table</li>
124         <li>If a cardnumber exists in the table, you can choose whether to ignore the new one or overwrite the old one.</li>
125     </ul>
126
127     <form method="post" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data">
128         <fieldset class="rows">
129             <legend>Import into the borrowers table</legend>
130
131             <ol>
132                 <li>
133                     <label for="uploadborrowers">Select the file to import: </label>
134                     <input type="file" id="uploadborrowers" name="uploadborrowers" />
135                 </li>
136
137                 <li>
138                     <label for "createpatronlist">Create patron list: </label>
139                     <input name="createpatronlist" id="createpatronlist" value="1" type="checkbox">
140                     <span class="hint">List name will be file name with timestamp</span>
141                 </li>
142             </ol>
143         </fieldset>
144
145         <fieldset class="rows">
146             <legend>Field to use for record matching</legend>
147             <ol>
148                 <li class="radio">
149                     <select name="matchpoint" id="matchpoint">
150                         <option value="cardnumber">Cardnumber</option>
151                         <option value="userid">Username</option>
152                         [% FOREACH matchpoint IN matchpoints %]
153                             <option value="[% matchpoint.code | html %]">[% matchpoint.description | html %]</option>
154                         [% END %]
155                     </select>
156                 </li>
157             </ol>
158         </fieldset>
159
160         <fieldset class="rows">
161             <legend>Default values</legend>
162
163             <ol>
164                 [% FOREACH borrower_field IN borrower_fields %]
165
166                     [% SWITCH borrower_field.field %]
167                     [% CASE 'branchcode' %]
168                         <li>
169                             <label class="description" for="branchcode">[% borrower_field.description | html %]: </label>
170                             <select id="branchcode" name="branchcode">
171                                 <option value="" selected="selected"></option>
172                                 [% FOREACH library IN Branches.all() %]
173                                     <option value="[% library.branchcode | html %]">[% library.branchname | html %]</option>
174                                 [% END %]
175                             </select>
176                             <span class="field_hint">[% borrower_field.field | html %]</span>
177                         </li>
178                     [% CASE 'categorycode' %]
179                         <li>
180                             <label class="description" for="categorycode">[% borrower_field.description | html %]: </label>
181                             <select id="categorycode" name="categorycode">
182                                 <option value="" selected="selected"></option>
183                                 [% FOREACH category IN categories %]
184                                     <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
185                                 [% END %]
186                             </select>
187                             <span class="field_hint">[% borrower_field.field | html %]</span>
188                         </li>
189                     [% CASE %]
190                         <li>
191                             <label class="description" for="[% borrower_field.field | html %]">[% borrower_field.description | html %]: </label>
192                             <input id="[% borrower_field.field | html %]" name="[% borrower_field.field | html %]" type="text" />
193                             <span class="field_hint">[% borrower_field.field | html %]</span>
194                         </li>
195                     [% END %]
196                 [% END %]
197
198                 [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
199                     <li>
200                         <label class="description" for="patron_attributes">Patron attributes: </label>
201                         <input id="patron_attributes" name="patron_attributes" type="text" />
202                         <span class="field_hint">patron_attributes</span>
203                     </li>
204                 [% END %]
205
206             </ol>
207         </fieldset>
208
209         <fieldset class="rows">
210             <legend>If matching record is already in the borrowers table:</legend>
211
212             <ol>
213                 <li class="radio">
214                     <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>
215                 </li>
216
217                 <li class="radio">
218                     <input type="radio" id="overwrite_cardnumberyes" name="overwrite_cardnumber" value="1" /><label for="overwrite_cardnumberyes">Overwrite the existing one with this</label>
219                 </li>
220             </ol>
221         </fieldset>
222
223         [% IF ( Koha.Preference('ExtendedPatronAttributes') == 1 ) %]
224             <fieldset class="rows">
225                 <legend>Patron attributes</legend>
226
227                 <ol>
228                     <li class="radio">
229                         <input type="radio" id="ext_preserve_0" name="ext_preserve" value="0" checked="checked" /><label for="ext_preserve_0">Replace all patron attributes</label>
230                     </li>
231
232                     <li class="radio">
233                         <input type="radio" id="ext_preserve_1" name="ext_preserve" value="1" /><label for="ext_preserve_1">Replace only included patron attributes</label>
234                     </li>
235                 </ol>
236             </fieldset>
237         [% END %]
238
239         <fieldset class="action">
240             <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
241             <input type="submit" value="Import" />
242         </fieldset>
243     </form>
244 [% END %]
245
246 </div>
247
248 <div class="col-sm-6">
249     <h2>Notes:</h2>
250     <ul>
251         <li>The first line in the file must be a header row defining which columns you are supplying in the import file.</li>
252
253         <li><b>Download a starter CSV file with all the columns <a href="?sample=1">here</a>.</b>  Values are comma-separated.</li>
254
255         <li>
256             OR choose which fields you want to supply from the following list:
257             <ul>
258                 <li>
259                     [% FOREACH columnkey IN borrower_fields %]'[% columnkey.field | html %]', [% END %]
260                 </li>
261             </ul>
262         </li>
263
264         [% IF ( ExtendedPatronAttributes ) %]
265             <li>
266                 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.
267             </li>
268         [% END %]
269
270         <li>
271             The fields 'branchcode' and 'categorycode' are <b>required</b> and <b>must match</b> valid entries in your database.
272         </li>
273
274         <li>
275             '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).
276         </li>
277
278         <li>
279             Date formats should match your system preference, and <b>must</b> be zero-padded, e.g. '01/02/2008'.  Alternatively,
280 you can supply dates in ISO format (e.g., '2010-10-28').
281         </li>
282     </ul>
283 </div>
284 </div>
285
286             </main>
287         </div> <!-- /.col-sm-10.col-sm-push-2 -->
288
289         <div class="col-sm-2 col-sm-pull-10">
290             <aside>
291                 [% INCLUDE 'tools-menu.inc' %]
292             </aside>
293         </div> <!-- .col-sm-2.col-sm-pull-10 -->
294      </div> <!-- /.row -->
295
296 [% MACRO jsinclude BLOCK %]
297     [% INCLUDE 'calendar.inc' %]
298     [% Asset.js("js/tools-menu.js") | $raw %]
299     [% INCLUDE 'str/members-menu.inc' %]
300     [% Asset.js("js/members-menu.js") | $raw %]
301     <script>
302         $(document).ready(function() {
303             [%# Make date fields have the datepicker %]
304             $("#dateenrolled, #dateexpiry, #dateofbirth").datepicker();
305         });
306     </script>
307 [% END %]
308 [% INCLUDE 'intranet-bottom.inc' %]