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