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