Bug 35241: Fix markup errors in point of sale template
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / marc_modification_templates.tt
1 [% USE raw %]
2 [% USE JSON.Escape %]
3 [% USE Asset %]
4 [% USE TablesSettings %]
5 [% PROCESS 'i18n.inc' %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 [% IF ( TemplatesLoop ) %]
9     [% FOREACH TemplatesLoo IN TemplatesLoop %]
10         [% IF ( TemplatesLoo.selected ) %]
11             [% SET template_name = TemplatesLoo.name %]
12         [% END %]
13     [% END %]
14 [% END %]
15 <title>[% FILTER collapse %]
16     [% IF ( template_name ) %]
17         [% tx("Actions for template '{template_name}'", template_name = template_name ) | html %] &rsaquo;
18     [% END %]
19     [% t("MARC modification templates") | html %] &rsaquo;
20     [% t("Cataloging") | html %] &rsaquo;
21     [% t("Koha") | html %]
22 [% END %]</title>
23 [% INCLUDE 'doc-head-close.inc' %]
24 [% FILTER collapse %]
25     <style>
26         #add_action {
27             display: none;
28         }
29
30         .action_line {
31             margin-bottom: 1em;
32         }
33     </style>
34 [% END %]
35 </head>
36
37 <body id="tools_marc_modification_templates" class="tools">
38 [% WRAPPER 'header.inc' %]
39     [% INCLUDE 'cat-search.inc' %]
40 [% END %]
41
42 [% WRAPPER 'sub-header.inc' %]
43     [% WRAPPER breadcrumbs %]
44         [% WRAPPER breadcrumb_item %]
45             <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
46         [% END %]
47
48         [% IF ( template_name ) %]
49             [% WRAPPER breadcrumb_item %]
50                 <a href="/cgi-bin/koha/tools/marc_modification_templates.pl">MARC modification templates</a>
51             [% END %]
52             [% WRAPPER breadcrumb_item bc_active= 1 %]
53                 [% tx("Actions for template '{template_name}'", template_name = template_name ) | html %]
54             [% END %]
55         [% ELSE %]
56             [% WRAPPER breadcrumb_item bc_active= 1 %]
57                 <span>MARC modification templates</span>
58             [% END %]
59         [% END %]
60     [% END #/ WRAPPER breadcrumbs %]
61 [% END #/ WRAPPER sub-header.inc %]
62
63 <div class="main container-fluid">
64     <div class="row">
65         <div class="col-sm-10 col-sm-push-2">
66             <main>
67
68             <div id="toolbar" class="btn-toolbar">
69                 <a href="#" data-toggle="modal" data-template_id="" data-target="#createTemplate" id="new_template" class="btn btn-default duplicate_template"><i class="fa fa-plus"></i> New template</a>
70                 [% IF ( template_id != '' ) %]
71                     <a href="#" class="btn btn-default new_action"><i class="fa fa-plus"></i> New action</a>
72                     <a class="btn btn-default delete_template" href="/cgi-bin/koha/tools/marc_modification_templates.pl?template_id=[% template_id | html %]&amp;op=delete_template"><i class="fa fa-fw fa-trash-can"></i> Delete template</a>
73                 [% END %]
74             </div>
75
76             [% IF error %]
77                 [% IF error == 'no_from_field' %]
78                     <div class="dialog message">Error: no field value specified.</div>
79                 [% END %]
80             [% END %]
81
82             [% IF ( TemplatesLoop ) %]
83
84                 [% IF ( template_id == '' ) %]
85
86                     <h1>MARC modification templates [% template_id | html %]</h1>
87
88                     <div class="page-section">
89                         <table id="templatest">
90                             <thead>
91                                 <tr>
92                                     <th>Id</th>
93                                     <th>Template</th>
94                                     <th class="NoSort noExport">Actions</th>
95                                 </tr>
96                             </thead>
97                             <tbody>
98                                 [% FOREACH TemplatesLoo IN TemplatesLoop %]
99                                     <tr>
100                                         <td>[% TemplatesLoo.template_id | html %]</td>
101                                         <td>[% TemplatesLoo.name | html %]</td>
102                                         <td class="actions">
103                                             <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/marc_modification_templates.pl?template_id=[% TemplatesLoo.template_id | html %]&amp;op=select_template" ><i class="fa-fw fa-solid fa-pencil" aria-hidden="true"></i> Edit actions</a>
104                                             <a class="btn btn-default btn-xs duplicate_template" href="#" data-toggle="modal" data-template_id="[% TemplatesLoo.template_id | html %]" data-target="#createTemplate"><i class="fa fa-fw fa-copy"></i> Duplicate</a>
105                                             <a class="btn btn-default btn-xs delete_template" href="/cgi-bin/koha/tools/marc_modification_templates.pl?template_id=[% TemplatesLoo.template_id | html %]&amp;op=delete_template"><i class="fa fa-fw fa-trash-can"></i> Delete</a>
106                                         </td>
107                                     </tr>
108                                 [% END %]
109                             </tbody>
110                         </table>
111                     </div> <!-- /.page-section -->
112
113                 [% ELSE %]
114
115                     <h1>[% tx("Actions for template '{template_name}'", template_name = template_name ) | html %]</em></h1>
116
117                     [% IF ( ActionsLoop ) %]
118                         <div class="page-section">
119                             <table id="template_actions" class="template_actions">
120                                 <thead>
121                                     <tr>
122                                         <th>Change order</th>
123                                         <th>Rank</th>
124                                         <th>Action</th>
125                                         <th>Description</th>
126                                         <th>&nbsp;</th>
127                                         <th>&nbsp;</th>
128                                     </tr>
129                                 </thead>
130                                 <tbody>
131                                     [% FOREACH ActionsLoo IN ActionsLoop %]
132                                         <tr>
133                                             <td class="actions">
134                                                 <a title="Move action up" href="marc_modification_templates.pl?op=move_action&amp;where=up&amp;template_id=[% ActionsLoo.template_id | html %]&amp;mmta_id=[% ActionsLoo.mmta_id | html %]">
135                                                     <i class="fa fa-arrow-up fa-lg order-control"></i>
136                                                 </a>
137
138                                                 <a title="Move action to top" href="marc_modification_templates.pl?op=move_action&amp;where=top&amp;template_id=[% ActionsLoo.template_id | html %]&amp;mmta_id=[% ActionsLoo.mmta_id | html %]">
139                                                     <i class="fa fa-arrow-up fa-lg overline order-control"></i>
140                                                 </a>
141
142                                                 <a title="Move action to bottom" href="marc_modification_templates.pl?op=move_action&amp;where=bottom&amp;template_id=[% ActionsLoo.template_id | html %]&amp;mmta_id=[% ActionsLoo.mmta_id | html %]">
143                                                     <i class="fa fa-arrow-down fa-lg underline order-control"></i>
144                                                 </a>
145
146                                                 <a title="Move action down" href="marc_modification_templates.pl?op=move_action&amp;where=down&amp;template_id=[% ActionsLoo.template_id | html %]&amp;mmta_id=[% ActionsLoo.mmta_id | html %]">
147                                                     <i class="fa fa-arrow-down fa-lg order-control"></i>
148                                                 </a>
149                                             </td>
150
151                                             <td>[% ActionsLoo.ordering | html %]</td>
152                                             <td>
153                                                 [% IF ( ActionsLoo.action_delete_field ) %] <span>Delete</span> [% END %]
154                                                 [% IF ( ActionsLoo.action_add_field ) %] <span>Add new</span> [% END %]
155                                                 [% IF ( ActionsLoo.action_update_field ) %] <span>Update existing or add new</span> [% END %]
156                                                 [% IF ( ActionsLoo.action_move_field ) %] <span>Move</span> [% END %]
157                                                 [% IF ( ActionsLoo.action_copy_field ) %] <span>Copy</span> [% END %]
158                                                 [% IF ( ActionsLoo.action_copy_and_replace_field ) %] <span>Copy and replace</span> [% END %]
159
160                                                 [% UNLESS ( ActionsLoo.action_update_field ) %]
161                                                     [% IF ( ActionsLoo.field_number ) %]
162                                                         <span>1st</span>
163                                                     [% END %]
164                                                 [% END %]
165
166                                                 <span>field</span>
167
168                                                 [% ActionsLoo.from_field | html %][% IF ( ActionsLoo.from_subfield.length ) %]$[% ActionsLoo.from_subfield | html %][% END %]
169
170                                                 [% IF ( ActionsLoo.field_value ) %]
171                                                     <span>with value</span> <em>[% ActionsLoo.field_value | html %]</em>
172                                                 [% END %]
173
174                                                 [% IF ( ActionsLoo.to_field ) %]
175                                                     <span>to</span> [% ActionsLoo.to_field | html %][% IF ( ActionsLoo.to_subfield.length ) %]$[% ActionsLoo.to_subfield | html %][% END %]
176
177                                                     [% IF ( ActionsLoo.to_regex_search ) %]
178                                                         <span>using RegEx</span> s<strong>/[% ActionsLoo.to_regex_search | html %]/[% ActionsLoo.to_regex_replace | html %]/[% ActionsLoo.to_regex_modifiers | html %]</strong>
179                                                     [% END %]
180                                                 [% END %]
181
182                                                 [% IF ( ActionsLoo.conditional ) %]
183                                                     [% IF ( ActionsLoo.conditional_if ) %] <span>if</span> [% END %]
184                                                     [% IF ( ActionsLoo.conditional_unless ) %] <span>unless</span> [% END %]
185
186                                                     [% ActionsLoo.conditional_field | html %][% IF ( ActionsLoo.conditional_subfield.length ) %]$[% ActionsLoo.conditional_subfield | html %][% END %]
187
188                                                     [% IF ( ActionsLoo.conditional_comparison_exists ) %] <span>exists</span> [% END %]
189                                                     [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] <span>does not exist</span> [% END %]
190                                                     [% IF ( ActionsLoo.conditional_comparison_equals ) %] <span>matches</span> [% END %]
191                                                     [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] <span>does not match</span> [% END %]
192
193                                                     [% IF ( ActionsLoo.conditional_regex ) %] <span>RegEx</span> m/[% END %]<strong>[% ActionsLoo.conditional_value | html %]</strong>[% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
194                                                 [% END %]
195                                             </td>
196                                             <td>[% ActionsLoo.description | html %]</td>
197                                             <td>
198                                                 <a class="btn btn-default btn-xs edit_action" href="#modaction" data-mmta_id="[% ActionsLoo.mmta_id | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
199                                             </td>
200                                             <td>
201                                                 <a class="btn btn-default btn-xs" href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id | html %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id | html %]" onclick="return confirmDeleteAction();"><i class="fa fa-trash-can"></i> Delete</a>
202                                             </td>
203                                         </tr>
204                                     [% END # /FOREACH ActionsLoo %]
205                                 </tbody>
206                             </table>
207                         </div> <!-- /.page-section -->
208                     [% ELSE %]
209                         <div class="dialog message" id="no_defined_actions">
210                             <p>There are no defined actions for this template.</p>
211                             <p><a href="#" class="btn btn-default approve new_action"><i class="fa fa-plus" aria-hidden="true"></i> New action</a></p>
212                         </div>
213                     [% END # /IF ActionsLoop %]
214
215                     <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
216                         <a name="modaction"></a>
217                         <fieldset>
218                             <legend id="modaction_legend">Add a new action</legend>
219                             <div id="warning_multivalued" style="color:red; display:none;">You have chosen a condition on the same field as the original field. If your records contain multivalued fields it is highly recommended not to do that.</div>
220
221                             <div class="action_line">
222                                 <select name="action" id="action" onchange="onActionChange(this);">
223                                     <option value="delete_field">Delete</option>
224                                     <option value="add_field">Add new</option>
225                                     <option value="update_field">Update existing or add new</option>
226                                     <option value="move_field">Move</option>
227                                     <option value="copy_field">Copy</option>
228                                     <option value="copy_and_replace_field">Copy and replace</option>
229                                 </select>
230
231                                 <span id="field_number_block">
232                                     <select name="field_number" id="field_number">
233                                         <option value="0">All</option>
234                                         <option value="1">1st</option>
235                                     </select>
236                                 </span>
237
238                                 field(s) <input type="text" name="from_field" id="from_field" size="3" maxlength="3" /> <input type="text" name="from_subfield" id="from_subfield" size="1" maxlength="1" title="let blank for the entire field" />
239
240                                 <span name="with_value_block" id="with_value_block" style="display:none;">
241                                     with value <input type="text" name="field_value" id="field_value" />
242                                 </span>
243
244                                 <span name="to_field_block" id="to_field_block" style="display:none;">
245                                     to field <input type="text" name="to_field" id="to_field" size="3" maxlength="3" /> <input type="text" name="to_subfield" id="to_subfield" size="1" maxlength="1" title="let blank for the entire field" />
246
247                                     <span name="to_field_regex_block" id="to_field_regex_block">
248                                         <sup>
249                                             <label for="to_field_regex">RegEx</label>
250                                             <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
251
252                                             <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
253                                                 s/<input type="text" name="to_regex_search" id="to_regex_search" placeholder="regex pattern" />/<input type="text" name="to_regex_replace" id="to_regex_replace" placeholder="regex replacement" />/<input type="text" name="to_regex_modifiers" id="to_regex_modifiers" placeholder="ig" size="3" />
254                                             </span>
255                                         </sup>
256                                     </span>
257                                 </span>
258                             </div>
259
260                             <div class="action_line">
261                                 <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
262                                     <option value="" selected="selected" />
263                                     <option value="if">if</option>
264                                     <option value="unless">unless</option>
265                                 </select>
266
267                                 <span name="conditional_block" id="conditional_block" style="display:none;">
268                                     field <input type="text" name="conditional_field" id="conditional_field" size="3" maxlength="3" /> <input type="text" name="conditional_subfield" id="conditional_subfield" size="1" maxlength="1" />
269
270                                     <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
271                                         <option value="" />
272                                         <option value="exists">exists</option>
273                                         <option value="not_exists">doesn't exist</option>
274                                         <option value="equals">matches</option>
275                                         <option value="not_equals">doesn't match</option>
276                                     </select>
277
278                                     <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
279
280                                         <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
281
282                                         <sup>
283                                             <label for="conditional_regex">RegEx</label>
284                                             <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
285                                         </sup>
286
287                                     </span>
288                                 </span>
289                             </div>
290
291                             <div class="action_line">
292                                 <label for="description">Description:</label>
293                                 <input type="text" name="description" id="description" size="60" />
294                             </div>
295
296                             <fieldset class="action">
297                                 <input type="hidden" name="template_id" value="[% template_id | html %]" />
298                                 <input type="hidden" name="mmta_id" id="mmta_id" />
299                                 <input type="hidden" name="op" value="add_action" />
300                                 <input type="submit" id="action_submit" class="btn btn-primary" value="Add action" />
301                                 <a href="#modaction" class="cancel" id="cancel_edit" onclick="cancelEditAction();">Cancel</a>
302                             </fieldset>
303
304                         </fieldset>
305                     </form>
306
307                 [% END %]
308
309             [% ELSE %]
310                 <h1>MARC modification templates</h1>
311                 <div class="dialog message">
312                     <p>There are no defined templates. Please create a template first.</p>
313                     <a href="#" data-toggle="modal" data-target="#createTemplate" class="btn btn-default"><i class="fa fa-plus" aria-hidden="true"></i> Create a new template</a>
314                 </div>
315             [% END # /IF TemplatesLoop %]
316
317             <!-- Modal to create new template -->
318             <div class="modal" id="createTemplate" tabindex="-1" role="dialog" aria-labelledby="LabelcreateTemplate" aria-hidden="true">
319                 <div class="modal-dialog">
320                 <div class="modal-content">
321                 <div class="modal-header">
322                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
323                     <h2 id="LabelcreateTemplate">Create a new template</h2>
324                 </div>
325                 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" class="validated">
326                     <div class="modal-body">
327                         <fieldset>
328                             <p>
329                                 <label for="template_name" class="required">Name: </label>
330                                 <input name="template_name" id="template_name" type="text" size="30" required="required" class="required" />
331                                 <span class="required">Required</span>
332                             </p>
333
334                             <input type="hidden" name="op" value="create_template" />
335
336                             <p>
337                                 <label for="duplicate_a_template">Duplicate a template:</label>
338                                 <select name="template_id" id="duplicate_a_template">
339                                     <option value=""> -- None --</option>
340                                     [% FOREACH TemplatesLoo IN TemplatesLoop %]
341                                         <option value="[% TemplatesLoo.template_id | html %]"> [% TemplatesLoo.name | html %]</option>
342                                     [% END %]
343                                 </select>
344                                 <input type="hidden" name="duplicate_current_template" id="duplicate_current_template" />
345                             </p>
346                         </fieldset>
347                     </div>
348                     <div class="modal-footer">
349                         <button type="submit" class="btn btn-default">Submit</button>
350                         <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
351                     </div>
352                 </form>
353                 </div>
354                 </div>
355             </div>
356
357             </main>
358         </div> <!-- /.col-sm-10.col-sm-push-2 -->
359
360         <div class="col-sm-2 col-sm-pull-10">
361             <aside>
362                 [% INCLUDE 'cat-menu.inc' %]
363             </aside>
364         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
365      </div> <!-- /.row -->
366
367 [% MACRO jsinclude BLOCK %]
368     [% INCLUDE 'datatables.inc' %]
369     [% INCLUDE 'columns_settings.inc' %]
370     <script>
371         table_settings = [% TablesSettings.GetTableSettings('tools', 'marc-modification-templates', 'templatest', 'json') | $raw %];
372         [% IF ActionsLoop %]
373             var mmtas = [% ActionsLoop.json | $raw %]
374         [% END %]
375     </script>
376     [% Asset.js("js/marc_modification_templates.js") | $raw %]
377 [% END %]
378
379 [% INCLUDE 'intranet-bottom.inc' %]