Bug 27846: admin folder
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / matching-rules.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>
6     Koha &rsaquo; Administration &rsaquo; Record matching rules
7     [% IF ( matching_rule_form ) %]
8         [% IF ( edit_matching_rule ) %]
9             &rsaquo; Modify record matching rule
10         [% ELSE %]
11             &rsaquo; Add record matching rule
12         [% END %]
13     [% END %]
14     [% IF ( delete_matching_rule_form ) %]
15         &rsaquo; Confirm deletion of record matching rule &quot;[% code | html %]&quot;
16     [% END %]
17 </title>
18 [% INCLUDE 'doc-head-close.inc' %]
19
20 [% BLOCK norms_text %]
21     [% SWITCH norm %]
22         [% CASE 'none' %]None
23         [% CASE 'remove_spaces' %]Remove spaces
24         [% CASE 'upper_case' %]Uppercase
25         [% CASE 'lower_case' %]Lowercase
26         [% CASE 'legacy_default' %]Legacy default
27         [% CASE 'ISBN' %]ISBN
28         [% CASE %][% norm | html %]
29     [% END %]
30 [% END %]
31
32 [% BLOCK norms_options %]
33     [%# PARAMS: selected_norm %]
34     [% FOREACH norm IN valid_norms %]
35         [% IF ( norm == selected_norm ) %]
36             <option value="[% norm | html %]" selected="selected">[% PROCESS norms_text norm=norm %]</option>
37         [% ELSE %]
38             <option value="[% norm | html %]">[% PROCESS norms_text norm=norm %]</option>
39         [% END %]
40     [% END %]
41 [% END %]
42
43 [% BLOCK norms_select %]
44     [%# PARAMS: selected_norm, id, name %]
45     [% UNLESS valid_norms.grep(selected_norm).size %]
46         [%# Fallback to 'none' %]
47         [% selected_norm = 'none' %]
48     [% END %]
49     <select id="[% id | html %]" name="[% name | html %]">
50         [% PROCESS norms_options selected_norm=selected_norm %]
51     </select>
52 [% END %]
53
54 <style>
55     fieldset.rows fieldset.rows { border-width : 0; }
56     fieldset.rows fieldset.rows fieldset.rows { border-width : 1px; }
57     fieldset, fieldset.rows { width : 90%; padding: .3em .6em .3em .6em; }
58     fieldset.rows fieldset {font-size:100%;}
59     div.matchgroup { border:1px solid #DDD; border-left-width: 15px; padding:.4em; margin-bottom:.6em;}
60 </style>
61 </head>
62 <body id="admin_matching-rules" class="admin">
63 [% INCLUDE 'header.inc' %]
64 [% INCLUDE 'prefs-admin-search.inc' %]
65
66 <nav aria-label="Breadcrumb" class="breadcrumb">
67     <ol>
68         <li>
69             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
70         </li>
71         <li>
72             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
73         </li>
74
75         [% IF ( matching_rule_form ) %]
76             <li>
77                 <a href="/cgi-bin/koha/admin/matching-rules.pl">Record matching rules</a>
78             </li>
79             <li>
80                 <a href="#" aria-current="page">
81                     [% IF ( edit_matching_rule ) %]
82                         Modify record matching rule
83                     [% ELSE %]
84                         Add record matching rule
85                     [% END %]
86                 </a>
87             </li>
88
89         [% ELSIF ( delete_matching_rule_form ) %]
90             <li>
91                 <a href="/cgi-bin/koha/admin/matching-rules.pl">Record matching rules</a>
92             </li>
93             <li>
94                 <a href="#" aria-current="page">
95                     Confirm deletion of record matching rule &quot;[% code | html %]&quot;
96                 </a>
97             </li>
98
99         [% ELSE %]
100             <li>
101                 <a href="#" aria-current="page">
102                     Record matching rules
103                 </a>
104             </li>
105         [% END %]
106     </ol>
107 </nav> <!-- /#breadcrumbs -->
108
109 <div class="main container-fluid">
110     <div class="row">
111         <div class="col-sm-10 col-sm-push-2">
112             <main>
113
114                 [% IF ( matching_rule_form ) %]
115                     [% IF ( edit_matching_rule ) %]
116                         <h2>Modify record matching rule</h2>
117                     [% ELSE %]
118                         <h2>Add record matching rule</h2>
119                     [% END %]
120                     <form action="[% script_name | html %]" name="Aform" method="post">
121                         <input type="hidden" name="op" value="[% confirm_op | html %]" />
122                         <fieldset class="rows">
123                             <ol>
124                                 <li>
125                                     [% IF ( edit_matching_rule ) %]
126                                         <span class="label">Matching rule code: </span>
127                                         <input type="hidden" name="matcher_id" value="[% matcher_id | html %]" />
128                                         <input type="hidden" name="code" value="[% code | html %]" />
129                                         [% code | html %]
130                                     [% ELSE %]
131                                         <label for="code" class="required">Matching rule code: </label>
132                                         <input type="text" id="code" name="code"  size="10" maxlength="10" /> <span class="required">Required</span>
133                                     [% END %]
134                                 </li>
135                                 <li>
136                                     <label for="description" class="required">Description: </label>
137                                     <input type="text" id="description" name="description" size="50" maxlength="250" value="[% description | html %]" /> <span class="required">Required</span>
138                                 </li>
139                                 <li>
140                                     <label for="threshold" class="required">Match threshold: </label>
141                                     <input type="text" id="threshold" name="threshold" size="5" maxlength="5" value="[% threshold | html %]" /> <span class="required">Required</span>
142                                 </li>
143                                 <li>
144                                     <label for="record_type" class="required">Record type: </label>
145                                     <select id="record_type" name="record_type">
146                                         [% IF ( record_type == "authority" ) %]
147                                             <option value="biblio">Bibliographic record</option>
148                                             <option value="authority" selected="selected">Authority record</option>
149                                         [% ELSE %]
150                                             <option value="biblio" selected="selected">Bibliographic record</option>
151                                             <option value="authority">Authority record</option>
152                                         [% END %]
153                                     </select><span class="required">Required</span>
154                                 </li>
155                             </ol>
156                         </fieldset> <!-- /.rows -->
157
158                         <fieldset class="rows" id="match_points">
159                             <h4>Match points</h4>
160                             [% IF ( edit_matching_rule ) %]
161                                 [% IF ( matchpoints ) %]
162                                     <p id="addMatchPoint" style="display:none;">
163                                 [% ELSE %]
164                                     <p id="addMatchPoint">
165                                 [% END %]
166                                     <a href="#" class="button" onclick="InsertMatchpoint('mp_1', 'mp_template'); return false;">Add match point</a>
167                                 </p>
168                             [% ELSE %]
169                                 <p id="addMatchPoint" style="display:none;"><a href="#" class="button" onclick="InsertMatchpoint('mp_1', 'mp_template'); return false;">
170                                     Add match point</a>
171                                 </p>
172                             [% END %]
173
174                             [% IF ( edit_matching_rule ) %]
175                                 [% FOREACH matchpoint IN matchpoints %]
176                                     <div id="mp_[% matchpoint.mp_num | html %]" class="matchgroup">
177                                         <fieldset class="rows">
178                                             <legend>Match point [% matchpoint.mp_num | html %] | <a href="#" class="button" onclick="InsertMatchpoint('mp_[% matchpoint.mp_num | html %]', 'mp_template'); return false;">Add match point</a> | <a href="#" class="button" onclick="DeleteMatchpoint(this); return false;">Remove this match point</a></legend>
179                                             <ol>
180                                                 <li>
181                                                     <label for="mp_[% matchpoint.mp_num | html %]_search_index">Search index: </label>
182                                                     <input type ="text" id="mp_[% matchpoint.mp_num | html %]_search_index" name="mp_[% matchpoint.mp_num | html %]_search_index" size="20" value="[% matchpoint.index | html %]" maxlength="30" />
183                                                 </li>
184                                                 <li>
185                                                     <label for="mp_[% matchpoint.mp_num | html %]_score">Score: </label>
186                                                     <input type ="text" id="mp_[% matchpoint.mp_num | html %]_score" name="mp_[% matchpoint.mp_num | html %]_score" size="5" value="[% matchpoint.score | html %]" maxlength="5" />
187                                                 </li>
188                                             </ol>
189                                             [% FOREACH component IN matchpoint.components %]
190                                                 <fieldset class="rows" id="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]">
191                                                     <legend>Matchpoint components</legend>
192                                                     <ol>
193                                                         <li>
194                                                             <label for="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_tag">Tag: </label>
195                                                             <input type="text" id="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_tag" name="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_tag" value="[% component.tag | html %]" size="3" maxlength="3" />
196                                                         </li>
197                                                         <li>
198                                                           <label for="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_subfields">Subfields: </label>
199                                                           <input type="text" id="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_subfields" name="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_subfields" value="[% component.subfields | html %]"
200                                                                  size="10" maxlength="40" />
201                                                         </li>
202                                                         <li>
203                                                           <label for="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_offset">Offset: </label>
204                                                           <input type="text" id="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_offset" name="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_offset" value="[% component.offset | html %]"
205                                                                  size="5" maxlength="5" />
206                                                         </li>
207                                                         <li>
208                                                           <label for="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_length">Length: </label>
209                                                           <input type="text" id="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_length" name="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_length" value="[% component.length | html %]"
210                                                                  size="5" maxlength="5" />
211                                                         </li>
212                                                         [% FOREACH norm IN component.norms %]
213                                                             <li id="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_n_[% norm.norm_num | html %]">
214                                                                 <label for="mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %]_n__[% norm.norm_num | html %]_norm">Normalization rule: </label>
215                                                                 [%# Note: Following directive in one line, otherwise we have translatabiltiy problems %]
216                                                                 [% PROCESS norms_select selected_norm=norm.norm id="mp_${norm.mp_num}_c_${component.comp_num}_n__${norm.norm_num}_norm" name="mp_${matchpoint.mp_num}_c_${component.comp_num}_n_${norm.norm_num}_norm" %]
217                                                             </li>
218                                                         [% END %]
219                                                     </ol>
220                                                 </fieldset> <!-- /#mp_[% matchpoint.mp_num | html %]_c_[% component.comp_num | html %] -->
221                                             [% END #/FOREACH component %]
222                                         </fieldset> <!-- /.rows -->
223                                         <br style="clear:both;" />
224                                     </div> <!-- /#mp_[% matchpoint.mp_num | html %] -->
225                                 [% END # /FOREACH matchpoint %]
226                             [% ELSE # IF ( edit_matching_rule ) %]
227                                 <div id="mp_1" class="matchgroup">
228                                     <fieldset class="rows">
229                                         <legend>Match point 1 | <a href="#" class="button" onclick="InsertMatchpoint('mp_1', 'mp_template'); return false;">Add match point</a> | <a href="#" class="button" onclick="DeleteMatchpoint(this); return false;">Remove this match point</a></legend>
230                                         <ol>
231                                             <li>
232                                                 <label for="mp_1_search_index">Search index: </label>
233                                                 <input type ="text" id="mp_1_search_index" name="mp_1_search_index" size="20" maxlength="30" />
234                                             </li>
235                                             <li>
236                                                 <label for="mp_1_score">Score: </label>
237                                                 <input type ="text" id="mp_1_score" name="mp_1_score" size="5" maxlength="5" />
238                                             </li>
239                                         </ol>
240                                         <fieldset class="rows" id="mp_1_c_1">
241                                             <legend>Matchpoint components</legend>
242                                             <ol>
243                                                 <li>
244                                                     <label for="mp_1_c_1_tag">Tag: </label>
245                                                     <input type="text" id="mp_1_c_1_tag" name="mp_1_c_1_tag" size="3" maxlength="3" />
246                                                 </li>
247                                                 <li>
248                                                     <label for="mp_1_c_1_subfields">Subfields: </label>
249                                                     <input type="text" id="mp_1_c_1_subfields" name="mp_1_c_1_subfields" size="10" maxlength="40" />
250                                                 </li>
251                                                 <li>
252                                                     <label for="mp_1_c_1_offset">Offset: </label>
253                                                     <input type="text" id="mp_1_c_1_offset" name="mp_1_c_1_offset" size="5" maxlength="5" />
254                                                 </li>
255                                                 <li>
256                                                     <label for="mp_1_c_1_length">Length: </label>
257                                                     <input type="text" id="mp_1_c_1_length" name="mp_1_c_1_length" size="5" maxlength="5" />
258                                                 </li>
259                                                 <li id="mp_1_c_1_n_1">
260                                                     <label for="mp_1_c_1_n_1_norm">Normalization rule: </label>
261                                                     [% PROCESS norms_select selected_norm="none" id="mp_1_c_1_n_1_norm" name="mp_1_c_1_n_1_norm" %]
262                                                 </li>
263                                             </ol>
264                                         </fieldset> <!-- /#mp_1_c_1 -->
265                                     </fieldset> <!-- /.rows -->
266                                     <br style="clear:both;" />
267                                 </div> <!-- /#mp_1 -->
268                             [% END # /IF ( edit_matching_rule ) %]
269                         </fieldset> <!-- /#match_points -->
270
271                         <fieldset class="rows" id="match_checks">
272                             <h4>Required match checks</h4>
273                             [% IF ( edit_matching_rule ) %]
274                                 [% IF ( matchchecks ) %]
275                                     <p id="addMatchCheck" style="display:none;">
276                                 [% ELSE %]
277                                     <p id="addMatchCheck">
278                                 [% END %]
279                                 <a href="#" class="button" onclick="InsertMatchcheck('mc_1', 'mc_template'); return false;">Add match check</a></p>
280                             [% ELSE %]
281                                 <p id="addMatchCheck" style="display:none;"><a href="#" class="button" onclick="InsertMatchcheck('mc_1', 'mc_template'); return false;">Add match check</a></p>
282                             [% END %]
283
284                             [% IF ( edit_matching_rule ) %]
285                                 [% FOREACH matchcheck IN matchchecks %]
286                                     <div id="mc_[% matchcheck.mc_num | html %]" class="matchgroup">
287                                         <fieldset class="rows">
288                                             <legend>Match check [% matchcheck.mc_num | html %]<a href="#" class="button" onclick="InsertMatchcheck('mc_[% matchcheck.mc_num | html %]', 'mc_template'); return false;">Add match check</a> | <a href="#" class="button" onclick="DeleteMatchcheck(this); return false;">Remove this match check</a></legend>
289                                             <input type="hidden" id="mc_[% matchcheck.mc_num | html %]_id" name="mc_[% matchcheck.mc_num | html %]_id" value="1" />
290                                             [% FOREACH src_component IN matchcheck.src_components %]
291                                                 <fieldset class="rows" id="mc_[% src_component.mc_num | html %]_src_c_[% src_component.comp_num | html %]">
292                                                     <legend>Source (incoming) record check field</legend>
293                                                     <ol>
294                                                         <li>
295                                                             <label for="mc_[% src_component.mc_num | html %]_src_c_[% src_component.comp_num | html %]_tag">Tag: </label>
296                                                             <input type="text" id="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_tag" name="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_tag" value="[% src_component.tag | html %]" size="3" maxlength="3" />
297                                                         </li>
298                                                         <li>
299                                                             <label for="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_subfields">Subfields: </label>
300                                                             <input type="text" id="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_subfields" name="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_subfields" value="[% src_component.subfields | html %]" size="10" maxlength="40" />
301                                                         </li>
302                                                         <li>
303                                                             <label for="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_offset">Offset: </label>
304                                                             <input type="text" id="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_offset" name="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_offset" value="[% src_component.offset | html %]" size="5" maxlength="5" />
305                                                         </li>
306                                                         <li>
307                                                             <label for="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_length">Length: </label>
308                                                             <input type="text" id="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_length" name="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_length" value="[% src_component.length | html %]" size="5" maxlength="5" />
309                                                         </li>
310                                                         [% FOREACH norm IN src_component.norms %]
311                                                             <li id="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_n_[% norm.norm_num | html %]">
312                                                                 <label for="mc_[% matchcheck.mc_num | html %]_src_c_[% src_component.comp_num | html %]_n_[% norm.norm_num | html %]_norm">Normalization rule: </label>
313                                                                 [%# Note: Following directive in one line, otherwise we have translatabiltiy problems %]
314                                                                 [% PROCESS norms_select selected_norm=norm.norm id="mc_${matchcheck.mc_num}_src_c_${src_component.comp_num}_n_${norm.norm_num}_norm" name="mc_${matchcheck.mc_num}_src_c_${src_component.comp_num}_n_${norm.norm_num}_norm" %]
315                                                             </li>
316                                                         [% END %]
317                                                     </ol>
318                                                 </fieldset> <!-- /#mc_[% src_component.mc_num | html %]_src_c_[% src_component.comp_num | html %] -->
319                                             [% END # /FOREACH src_component %]
320
321                                             [% FOREACH tgt_component IN matchcheck.tgt_components %]
322                                                 <fieldset class="rows" id="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]">
323                                                     <legend>Target (database) record check field</legend>
324                                                     <ol>
325                                                         <li>
326                                                             <label for="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_tag">Tag: </label>
327                                                             <input type="text" id="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_tag" name="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_tag" value="[% tgt_component.tag | html %]" size="3" maxlength="3" />
328                                                         </li>
329                                                         <li>
330                                                             <label for="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_subfields">Subfields: </label>
331                                                             <input type="text" id="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_subfields" name="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_subfields" value="[% tgt_component.subfields | html %]" size="10" maxlength="40" />
332                                                         </li>
333                                                         <li>
334                                                             <label for="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_offset">Offset: </label>
335                                                             <input type="text" id="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_offset" name="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_offset" value="[% tgt_component.offset | html %]" size="5" maxlength="5" />
336                                                         </li>
337                                                         <li>
338                                                             <label for="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_length">Length: </label>
339                                                             <input type="text" id="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_length" name="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_length" value="[% tgt_component.length | html %]" size="5" maxlength="5" />
340                                                         </li>
341                                                         [% FOREACH norm IN tgt_component.norms %]
342                                                             <li id="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_n_[% norm.norm_num | html %]">
343                                                                 <label for="mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %]_n_[% norm.norm_num | html %]_norm">Normalization rule: </label>
344                                                                 [%# Note: Following directive in one line, otherwise we have translatabiltiy problems %]
345                                                                 [% PROCESS norms_select selected_norm=norm.norm id="mc_${matchcheck.mc_num}_tgt_c_${tgt_component.comp_num}_n_${norm.norm_num}_norm" name="mc_${matchcheck.mc_num}_tgt_c_${tgt_component.comp_num}_n_${norm.norm_num}_norm" %]
346                                                             </li>
347                                                         [% END %]
348                                                     </ol>
349                                                 </fieldset> <!-- /#mc_[% matchcheck.mc_num | html %]_tgt_c_[% tgt_component.comp_num | html %] -->
350                                             [% END # /FOREACH tgt_component %]
351                                         </fieldset> <!-- /.rows -->
352                                         <br style="clear:both;" />
353                                     </div> <!-- /#mc_[% matchcheck.mc_num | html %] -->
354                                 [% END # /FOREACH matchcheck %]
355                             [% ELSE # IF ( edit_matching_rule ) %]
356                                 <div id="mc_1" class="matchgroup">
357                                     <fieldset class="rows">
358                                         <legend>Match check 1 | <a href="#" class="button" onclick="InsertMatchcheck('mc_1', 'mc_template'); return false;">Add match check</a> | <a href="#" class="button" onclick="DeleteMatchcheck(this); return false;">Remove this match check</a></legend>
359                                         <input type="hidden" id="mc_1_id" name="mc_1_id" value="1" />
360                                         <fieldset class="rows" id="mc_1_src_c_1">
361                                             <legend>Source (incoming) record check field</legend>
362                                             <ol>
363                                                 <li>
364                                                     <label for="mc_1_src_c_1_tag">Tag: </label>
365                                                     <input type="text" id="mc_1_src_c_1_tag" name="mc_1_src_c_1_tag" size="3" maxlength="3" />
366                                                 </li>
367                                                 <li>
368                                                     <label for="mc_1_src_c_1_subfields">Subfields: </label>
369                                                     <input type="text" id="mc_1_src_c_1_subfields" name="mc_1_src_c_1_subfields" size="10" maxlength="40" />
370                                                 </li>
371                                                 <li>
372                                                     <label for="mc_1_src_c_1_offset">Offset: </label>
373                                                     <input type="text" id="mc_1_src_c_1_offset" name="mc_1_src_c_1_offset" size="5" maxlength="5" />
374                                                 </li>
375                                                 <li>
376                                                     <label for="mc_1_src_c_1_length">Length: </label>
377                                                     <input type="text" id="mc_1_src_c_1_length" name="mc_1_src_c_1_length" size="5" maxlength="5" />
378                                                 </li>
379                                                 <li id="mc_1_src_c_1_n_1">
380                                                     <label for="mc_1_src_c_1_n_1_norm">Normalization rule: </label>
381                                                     [% PROCESS norms_select selected_norm="none" id="mc_1_src_c_1_n_1_norm" name="mc_1_src_c_1_n_1_norm" %]
382                                                 </li>
383                                             </ol>
384                                         </fieldset>
385
386                                         <fieldset class="rows" id="mc_1_tgt_c_1">
387                                             <legend>Target (database) record check field</legend>
388                                             <ol>
389                                                 <li>
390                                                     <label for="mc_1_tgt_c_1_tag">Tag: </label>
391                                                     <input type="text" id="mc_1_tgt_c_1_tag" name="mc_1_tgt_c_1_tag" size="3" maxlength="3" />
392                                                 </li>
393                                                 <li>
394                                                     <label for="mc_1_tgt_c_1_subfields">Subfields: </label>
395                                                     <input type="text" id="mc_1_tgt_c_1_subfields" name="mc_1_tgt_c_1_subfields" size="10" maxlength="40" />
396                                                 </li>
397                                                 <li>
398                                                     <label for="mc_1_tgt_c_1_offset">Offset: </label>
399                                                     <input type="text" id="mc_1_tgt_c_1_offset" name="mc_1_tgt_c_1_offset" size="5" maxlength="5" />
400                                                 </li>
401                                                 <li>
402                                                     <label for="mc_1_tgt_c_1_length">Length: </label>
403                                                     <input type="text" id="mc_1_tgt_c_1_length" name="mc_1_tgt_c_1_length" size="5" maxlength="5" />
404                                                 </li>
405                                                 <li id="mc_1_tgt_c_1_n_1">
406                                                     <label for="mc_1_tgt_c_1_n_1_norm">Normalization rule: </label>
407                                                     [% PROCESS norms_select selected_norm="none" id="mc_1_tgt_c_1_n_1_norm" name="mc_1_tgt_c_1_n_1_norm" %]
408                                                 </li>
409                                             </ol>
410                                         </fieldset> <!-- /#mc_1_tgt_c_1 -->
411                                     </fieldset> <!-- /.rows -->
412                                     <br style="clear:both;" />
413                                 </div> <!-- /#mc_1 -->
414                             [% END # /IF ( edit_matching_rule ) %]
415                         </fieldset>
416                         <fieldset class="action">
417                             [% IF ( edit_matching_rule ) %]
418                                 <input type="button" value="Save" onclick="CheckMatchingRuleForm(this.form)" />
419                             [% ELSE %]
420                                 <input type="button" value="Save" onclick="CheckMatchingRuleForm(this.form)" />
421                             [% END %]
422                             <a class="cancel" href="/cgi-bin/koha/admin/matching-rules.pl">Cancel</a>
423                         </fieldset> <!-- /.action -->
424                     </form>
425                 [% END # /IF ( matching_rule_form ) %]
426
427                 [% IF ( delete_matching_rule_form ) %]
428                     <div class="dialog alert">
429                         <h3>Confirm deletion of record matching rule <span class="ex">'[% code | html %]' ([% description | html %])</span>?</h3>
430                         <form action="[% script_name | html %]" name="Aform" method="post">
431                             <input type="hidden" name="op" value="[% confirm_op | html %]" />
432                             <input type="hidden" name="matcher_id" value="[% matcher_id | html %]" />
433                             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete record matching rule</button>
434                         </form>
435                         <form action="[% script_name | html %]" method="get">
436                             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
437                         </form>
438                     </div>
439                 [% END # /IF ( delete_matching_rule_form ) %]
440
441                 [% IF ( display_list ) %]
442
443                     <div id="toolbar" class="btn-toolbar">
444                         <a class="btn btn-default" id="newrule" href="[% script_name | url %]?op=add_matching_rule"><i class="fa fa-plus"></i> New record matching rule</a>
445                     </div>
446
447                     <h2>Record matching rules</h2>
448
449                     [% IF ( added_matching_rule ) %]
450                         <div class="dialog message">Added record matching rule &quot;[% added_matching_rule | html %]&quot;</div>
451                     [% END %]
452                     [% IF ( edited_matching_rule ) %]
453                         <div class="dialog message">Modified record matching rule &quot;[% edited_matching_rule | html %]&quot;</div>
454                     [% END %]
455                     [% IF ( deleted_matching_rule ) %]
456                         <div class="dialog message">Deleted record matching rule &quot;[% deleted_matching_rule | html %]&quot;</div>
457                     [% END %]
458                     [% IF ( available_matching_rules ) %]
459                         <table>
460                             <tr>
461                                 <th>#</th>
462                                 <th>Code</th>
463                                 <th>Description</th>
464                                 <th class="noExport">Actions</th>
465                             </tr>
466                             [% FOREACH available_matching_rule IN available_matching_rules %]
467                                 <tr>
468                                     <td>[% available_matching_rule.matcher_id | html %]</td>
469                                     <td>[% available_matching_rule.code | html %]</td>
470                                     <td>[% available_matching_rule.description | html %]</td>
471                                     <td class="actions">
472                                         <a class="btn btn-default btn-xs" href="[% available_matching_rule.script_name | url %]?op=edit_matching_rule&amp;matcher_id=[% available_matching_rule.matcher_id | uri %]"><i class="fa fa-pencil"></i> Edit</a>
473                                         <a class="btn btn-default btn-xs" href="[% available_matching_rule.script_name | url %]?op=delete_matching_rule&amp;matcher_id=[% available_matching_rule.matcher_id | uri %]"><i class="fa fa-trash"></i> Delete</a>
474                                     </td>
475                                 </tr>
476                             [% END %]
477                         </table>
478                     [% ELSE %]
479                         <p>There are no saved matching rules.</p>
480                     [% END # /IF ( available_matching_rules ) %]
481
482                     <div class="pages">[% pagination_bar | $raw %]</div>
483                 [% END # /IF ( display_list ) %]
484
485                 [% IF ( matching_rule_form ) %]
486                     <div id="mp_template" class="matchgroup" style="display:none;">
487                         <fieldset class="rows">
488                             <legend>Match point <span class="counter"></span> | <a href="#" class="button" onclick="DeleteMatchpoint(this); return false;">Remove this match point</a></legend>
489                             <ol>
490                                 <li>
491                                     <label for="mp_num_search_index">Search index: </label>
492                                     <input type ="text" id="mp_num_search_index" name="mp_num_search_index" size="20" maxlength="30" />
493                                 </li>
494                                 <li>
495                                     <label for="mp_num_score">Score: </label>
496                                     <input type ="text" id="mp_num_score" name="mp_num_score" size="5" maxlength="5" />
497                                 </li>
498                             </ol>
499                             <fieldset id="mp_num_c_1" class="rows">
500                                 <legend>Matchpoint components</legend>
501                                 <ol>
502                                     <li>
503                                         <label for="mp_num_c_1_tag">Tag: </label>
504                                         <input type="text" id="mp_num_c_1_tag" name="mp_num_c_1_tag" size="3" maxlength="3" />
505                                     </li>
506                                     <li>
507                                         <label for="mp_num_c_1_subfields">Subfields: </label>
508                                         <input type="text" id="mp_num_c_1_subfields" name="mp_num_c_1_subfields" size="10" maxlength="40" />
509                                     </li>
510                                     <li>
511                                         <label for="mp_num_c_1_offset">Offset: </label>
512                                         <input type="text" id="mp_num_c_1_offset" name="mp_num_c_1_offset" size="5" maxlength="5" />
513                                     </li>
514                                     <li>
515                                         <label for="mp_num_c_1_length">Length: </label>
516                                         <input type="text" id="mp_num_c_1_length" name="mp_num_c_1_length" size="5" maxlength="5" />
517                                     </li>
518                                     <li id="mp_num_c_1_n_1">
519                                         <label for="mp_num_c_1_n_1_norm">Normalization rule: </label>
520                                         [% PROCESS norms_select selected_norm="none" id="mp_num_c_1_n_1_norm" name="mp_num_c_1_n_1_norm" %]
521                                     </li>
522                                 </ol>
523                             </fieldset> <!-- /#mp_num_c_1 -->
524                         </fieldset> <!-- /.rows -->
525                         <br style="clear:both;" />
526                     </div> <!-- /#mp_template -->
527
528                     <div id="mc_template" class="matchgroup" style="display:none">
529                         <fieldset class="rows">
530                             <legend>Match check <span class="counter"></span> | <a href="#" class="button" onclick="DeleteMatchcheck(this); return false;">Remove this match check</a></legend>
531                             <input type="hidden" id="mc_num_id" name="mc_num_id" value="1" />
532                             <fieldset class="rows" id="mc_num_src_c_1">
533                                 <legend>Source (incoming) record check field</legend>
534                                 <ol>
535                                     <li>
536                                         <label for="mc_num_src_c_1_tag">Tag: </label>
537                                         <input type="text" id="mc_num_src_c_1_tag" name="mc_num_src_c_1_tag" size="3" maxlength="3" />
538                                     </li>
539                                     <li>
540                                         <label for="mc_num_src_c_1_subfields">Subfields: </label>
541                                         <input type="text" id="mc_num_src_c_1_subfields" name="mc_num_src_c_1_subfields" size="10" maxlength="40" />
542                                     </li>
543                                     <li>
544                                         <label for="mc_num_src_c_1_offset">Offset: </label>
545                                         <input type="text" id="mc_num_src_c_1_offset" name="mc_num_src_c_1_offset" size="5" maxlength="5" />
546                                     </li>
547                                     <li>
548                                         <label for="mc_num_src_c_1_length">Length: </label>
549                                         <input type="text" id="mc_num_src_c_1_length" name="mc_num_src_c_1_length" size="5" maxlength="5" />
550                                     </li>
551                                     <li id="mc_num_src_c_1_n_1">
552                                         <label for="mc_num_src_c_1_n_1_norm">Normalization rule: </label>
553                                         [% PROCESS norms_select selected_norm="none" id="mc_num_src_c_1_n_1_norm" name="mc_num_src_c_1_n_1_norm" %]
554                                     </li>
555                                 </ol>
556                             </fieldset> <!-- /#mc_num_src_c_1 -->
557                             <fieldset class="rows" id="mc_num_tgt_c_1">
558                                 <legend>Target (database) record check field</legend>
559                                 <ol>
560                                     <li>
561                                         <label for="mc_num_tgt_c_1_tag">Tag: </label>
562                                         <input type="text" id="mc_num_tgt_c_1_tag" name="mc_num_tgt_c_1_tag" size="3" maxlength="3" />
563                                     </li>
564                                     <li>
565                                         <label for="mc_num_tgt_c_1_subfields">Subfields: </label>
566                                         <input type="text" id="mc_num_tgt_c_1_subfields" name="mc_num_tgt_c_1_subfields" size="10" maxlength="40" />
567                                     </li>
568                                     <li>
569                                         <label for="mc_num_tgt_c_1_offset">Offset: </label>
570                                         <input type="text" id="mc_num_tgt_c_1_offset" name="mc_num_tgt_c_1_offset" size="5" maxlength="5" />
571                                     </li>
572                                     <li>
573                                         <label for="mc_num_tgt_c_1_length">Length: </label>
574                                         <input type="text" id="mc_num_tgt_c_1_length" name="mc_num_tgt_c_1_length" size="5" maxlength="5" />
575                                     </li>
576                                     <li id="mc_num_tgt_c_1_n_1">
577                                         <label for="mc_num_tgt_c_1_n_1_norm">Normalization rule: </label>
578                                         [% PROCESS norms_select selected_norm="none" id="mc_num_tgt_c_1_n_1_norm" name="mc_num_tgt_c_1_n_1_norm" %]
579                                     </li>
580                                 </ol>
581                             </fieldset> <!-- #mc_num_tgt_c_1 -->
582                         </fieldset> <!-- /.rows -->
583                         <br style="clear:both;" />
584                     </div> <!-- /#mc_template -->
585                 [% END # /IF ( matching_rule_form ) %]
586
587             </main>
588         </div> <!-- /.col-sm-10.col-sm-push-2 -->
589
590         <div class="col-sm-2 col-sm-pull-10">
591             <aside>
592                 [% INCLUDE 'admin-menu.inc' %]
593             </aside>
594         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
595      </div> <!-- /.row -->
596
597 [% MACRO jsinclude BLOCK %]
598     [% Asset.js("js/admin-menu.js") | $raw %]
599     <script>
600         var maxMatchPoint = [% max_matchpoint | html %];
601         var maxMatchCheck = [% max_matchcheck | html %];
602
603         function InsertMatchpoint(loc, index) {
604             var original= $("#"+index);
605             var clone = original.clone();
606             clone.show();
607
608             // update IDs and form names
609             maxMatchPoint++;
610             clone.attr('id', 'mp_' + maxMatchPoint);
611             $("span.counter",clone).html(maxMatchPoint);
612             $("label",clone).each(function(){
613               var s = $(this).attr("for");
614                 if (s.match(/mp_num/)) {
615                     $(this).attr("for",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
616                 }
617             });
618
619             $("div",clone).each(function(){
620               var s = $(this).attr("id");
621                 if (s.match(/mp_num/)) {
622                     $(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
623                 }
624             });
625             $("input",clone).each(function(){
626                 var s = $(this).attr("id");
627                 if(s.match(/mp_num/)){
628                   $(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
629                 }
630
631                 var s = $(this).attr("name");
632                 if(s.match(/mp_num/)){
633                   $(this).attr("name",s.replace(/mp_num/, 'mp_' + maxMatchPoint));
634                 }
635             });
636             $("#match_points").append(clone);
637         }
638
639         function InsertMatchcheck(loc, index) {
640             var original= $("#"+index);
641             var clone = original.clone();
642             clone.show();
643
644             // update IDs and form names
645             maxMatchCheck++;
646             clone.attr('id', 'mc_' + maxMatchCheck);
647             $("span.counter",clone).html(maxMatchCheck);
648             $("label",clone).each(function(){
649               var s = $(this).attr("for");
650                 if (s.match(/mc_num/)) {
651                     $(this).attr("for",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
652                 }
653             });
654
655             $("div",clone).each(function(){
656               var s = $(this).attr("id");
657                 if (s.match(/mc_num/)) {
658                     $(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
659                 }
660             });
661             $("input",clone).each(function(){
662                 var s = $(this).attr("id");
663                 if(s.match(/mc_num/)){
664                   $(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
665                 }
666
667                 var s = $(this).attr("name");
668                 if(s.match(/mc_num/)){
669                   $(this).attr("name",s.replace(/mc_num/, 'mc_' + maxMatchCheck));
670                 }
671             });
672             $("#match_checks").append(clone);
673         }
674
675         function DeleteMatchpoint(loc) {
676             $(loc).parent().parent().parent().remove();
677             if($(".matchgroup",$("#match_points")).length == 0){
678               maxMatchPoint = 0;
679               $("#addMatchPoint").show();
680             }
681         }
682
683         function DeleteMatchcheck(loc) {
684             $(loc).parent().parent().parent().remove();
685             if($(".matchgroup",$("#match_checks")).length == 0){
686               maxMatchCheck = 0;
687               $("#addMatchCheck").show();
688             }
689         }
690
691         function DoCancel(f) {
692           f.op.value='';
693           document.Aform.submit();
694         }
695
696         function CheckMatchingRuleForm(f) {
697             var ok=1;
698             var _alertString="";
699             var alertString2;
700             if (f.code.value.length==0) {
701                 _alertString += "\n- " + _("Matching rule code missing");
702             }
703             if (f.description.value.length==0) {
704                 _alertString += "\n- " + _("Description missing");
705             }
706             if (f.threshold.value.length==0) {
707                 _alertString += "\n- " + _("Threshold missing");
708             }
709             if (_alertString.length==0) {
710                 document.Aform.submit();
711             } else {
712                 alertString2  = _("Form not submitted because of the following problem(s)");
713                 alertString2 += "\n------------------------------------------------------------------------------------\n";
714                 alertString2 += _alertString;
715                 alert(alertString2);
716             }
717         }
718
719         function CheckRuleForm(f) {
720             var ok=1;
721             var _alertString="";
722             var alertString2;
723             if (f.sort_rule.value.length==0) {
724                 _alertString += "\n- " + _("Filing rule code missing");
725             }
726             if (f.description.value.length==0) {
727                 _alertString += "\n- " + _("Description missing");
728             }
729             if (f.sort_routine.value.length==0) {
730                 _alertString += "\n- " + _("Sort routine missing");
731             }
732             if (_alertString.length==0) {
733                 document.Aform.submit();
734             } else {
735                 alertString2  = _("Form not submitted because of the following problem(s)");
736                 alertString2 += "\n------------------------------------------------------------------------------------\n";
737                 alertString2 += _alertString;
738                 alert(alertString2);
739             }
740         }
741     </script>
742 [% END %]
743 [% INCLUDE 'intranet-bottom.inc' %]