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