Bug 13618: Add html filters to all the variables
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / add_fields.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE AuthorisedValues %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Serials &rsaquo; Manage new fields for subscriptions
7   [% IF op == "list" %] &rsaquo; List of fields
8   [% ELSIF op == "add_form" %]
9     [% IF field %] &rsaquo; Modify field
10     [% ELSE %] &rsaquo; Add field
11     [% END %]
12   [% END %]
13 </title>
14 [% INCLUDE 'doc-head-close.inc' %]
15 [% Asset.css("css/datatables.css") | $raw %]
16 </head>
17
18 <body id="ser_add_fields" class="ser">
19   [% INCLUDE 'header.inc' %]
20   [% INCLUDE 'serials-search.inc' %]
21
22   <div id="breadcrumbs">
23     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> &rsaquo; Manage new fields for subscriptions
24   </div>
25
26   <div id="doc3" class="yui-t2">
27   <div id="bd">
28   <div id="yui-main">
29   <div class="yui-b">
30   [% IF op == 'list' %]
31     <div id="toolbar" class="btn-toolbar">
32       <a class="btn btn-default btn-sm" id="newfields" href="/cgi-bin/koha/serials/add_fields.pl?op=add_form"><i class="fa fa-plus"></i> New fields</a>
33     </div>
34   [% END %]
35
36   [% IF messages %]
37     [% FOR message IN messages %]
38       [% IF message.code == 'insert' %]
39         [% IF message.number > 0 %]
40           <div class="dialog message">Field created.</div>
41         [% ELSE %]
42           <div class="dialog alert">The field could not be created. Perhaps the name already exists?</div>
43         [% END %]
44       [% ELSIF message.code == 'update' %]
45         [% IF message.number > 0 %]
46           <div class="dialog message">Field updated.</div>
47         [% ELSE %]
48           <div class="dialog alert">The field could not be updated. Perhaps the name already exists?</div>
49         [% END %]
50       [% ELSIF message.code == 'delete' %]
51         [% IF message.number > 0 %]
52           <div class="dialog message">Field deleted.</div>
53         [% ELSE %]
54           <div class="dialog alert">The field could not be deleted. Check the log for errors.</div>
55         [% END %]
56       [% END %]
57     [% END %]
58   [% END %]
59
60   [% IF op == 'list' %]
61     <h3>Additional fields for subscriptions</h3>
62     [% IF fields %]
63       <table id="fieldst">
64         <thead>
65           <tr>
66             <th>Name</th>
67             <th>Authorised value category</th>
68             <th>Marc field</th>
69             <th>Searchable</th>
70             <th>Actions</th>
71           </tr>
72         </thead>
73         <tbody>
74           [% FOR field IN fields %]
75             <tr>
76               <td>[% field.name | html %]</td>
77               <td>[% field.authorised_value_category | html %]</td>
78               <td>[% field.marcfield | html %]</td>
79               <td>
80                 [% IF field.searchable %]Yes[% ELSE %]No[% END %]
81               </td>
82               <td class="actions">
83                 <a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/add_fields.pl?op=add_form&amp;field_id=[% field.id | html %]"><i class="fa fa-pencil"></i> Edit</a>
84                 <a class="confirmdelete btn btn-default btn-xs" href="/cgi-bin/koha/serials/add_fields.pl?op=delete&amp;field_id=[% field.id | html %]"><i class="fa fa-trash"></i> Delete</a>
85               </td>
86             </tr>
87           [% END %]
88         </tbody>
89       </table>
90     [% ELSE %]
91       There is no field defined.
92     [% END %]
93   [% ELSIF op == 'add_form' %]
94     [% IF field %]
95       <h3>Modify field</h3>
96     [% ELSE %]
97       <h3>Add field</h3>
98     [% END %]
99     <form action="/cgi-bin/koha/serials/add_fields.pl" name="add_form" id="add_field" method="post">
100       <fieldset class="rows">
101         <ol>
102           <li>
103             <label for="name" class="required">Name: </label>
104             <input type="text" name="name" id="name" value="[% field.name | html %]" class="required" required="required" />
105             <span class="required">Required</span>
106           </li>
107           <li>
108             <label for="av">Authorised value category: </label>
109             <select name="authorised_value_category">
110               <option value="">None</option>
111               [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => field.authorised_value_category ) %]
112             </select>
113           </li>
114           <li>
115             <label for="marcfield">Marc field: </label>
116             <input type="text" name="marcfield" id="marcfield" value="[% field.marcfield | html %]" />
117           </li>
118           <li>
119             <label for="searchable">Searchable: </label>
120             [% IF field.searchable %]
121               <input type="checkbox" name="searchable" id="searchable" checked="checked" />
122             [% ELSE %]
123               <input type="checkbox" name="searchable" id="searchable" />
124             [% END %]
125           </li>
126         </ol>
127       </fieldset>
128       <fieldset class="action">
129         [% IF field %]
130           <input type="hidden" name="field_id" value="[% field.id | html %]" />
131         [% END %]
132         <input type="hidden" name="op" value="add" />
133         <input type="submit" value="Save" />
134         <a href="/cgi-bin/koha/serials/add_fields.pl" class="cancel">Cancel</a>
135       </fieldset>
136     </form>
137   [% END %]
138
139   </div>
140   </div>
141
142 <div class="yui-b">
143 [% INCLUDE 'serials-menu.inc' %]
144 </div>
145 </div>
146
147 [% MACRO jsinclude BLOCK %]
148     [% INCLUDE "datatables.inc" %]
149     <script type="text/javascript">
150         $(document).ready(function(){
151
152             $("#fieldst").dataTable($.extend(true, {}, dataTablesDefaults, {
153                 'bAutoWidth': false,
154                 'sDom': 't<"bottom pager"ilpf>',
155                 'sPaginationType': 'four_button',
156                 'aLengthMenu': [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
157                 'iDisplayLength': 20,
158                 'aaSorting': [[ 0, "asc" ]],
159                 "aoColumnDefs": [
160                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
161                 ]
162             }));
163
164             $(".confirmdelete").click(function(){
165                 return confirm(_("Are you sure you want to delete this field?"));
166             });
167
168             $("#add_field").on('submit', function(){
169                 if ( $("#marcfield").val().length > 0
170                     && $("select[name='authorised_value_category']" ).val().length > 0 ) {
171                     alert("You cannot select an authorised value category and a marcfield");
172                     return false;
173                 }
174                 return true;
175             });
176         });
177     </script>
178 [% END %]
179
180 [% INCLUDE 'intranet-bottom.inc' %]