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