Bug 19036: Add ability to auto generate a number for account credits
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / additional-fields.tt
bloba2dbb632e2798fc079e5dd0672e1f2a718f3bc68
1 [% USE AuthorisedValues %]
2 [% SET footerjs = 1 %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Administration &rsaquo;
5     [% SWITCH op %]
6         [% CASE 'add_form' %][% IF field %]Modify additional field '[% field.name | html %]'[% ELSE %]Add additional field[% END %]
7         [% CASE %]Manage additional fields
8     [% END %]
9 </title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 </head>
13 [% marcfield_tables = ['subscription'] %]
14 [% show_marcfield = marcfield_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %]
16 <body id="ser_add_fields" class="ser">
17     [% INCLUDE 'header.inc' %]
18     [% INCLUDE 'cat-search.inc' %]
20     <div id="breadcrumbs">
21         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
22         [% SWITCH op %]
23             [% CASE 'add_form' %]<a href="/cgi-bin/koha/admin/additional-fields.pl">Manage additional fields</a> &rsaquo; [% IF field %]Modify field '[% field.name | html %]'[% ELSE %]Add field[% END %]
24             [% CASE 'list' %]<a href="/cgi-bin/koha/admin/additional-fields.pl">Manage additional fields</a> &rsaquo; Modify fields for '[% tablename | html %]'
25             [% CASE %]Manage additional fields
26         [% END %]
27     </div>
29 <div class="main container-fluid">
30     <div class="row">
31         <div class="col-sm-10 col-sm-push-2">
32             <main>
34     [% IF op == 'list' %]
35         <div id="toolbar" class="btn-toolbar">
36             <a class="btn btn-default" id="newfields" href="?op=add_form&amp;tablename=[% tablename | uri %]"><i class="fa fa-plus"></i> Create field</a>
37         </div>
38     [% END %]
40     [% IF messages %]
41         [% FOR message IN messages %]
42             [% IF message.code == 'insert' %]
43                 [% IF message.number > 0 %]
44                     <div class="dialog message">The field has been inserted</div>
45                 [% ELSE %]
46                     <div class="dialog alert">The field could not be inserted. Perhaps the name already exists?</div>
47                 [% END %]
48             [% ELSIF message.code == 'update' %]
49                 [% IF message.number > 0 %]
50                     <div class="dialog message">The field has been updated</div>
51                 [% ELSE %]
52                     <div class="dialog alert">The field could not be updated. Perhaps the name already exists?</div>
53                 [% END %]
54             [% ELSIF message.code == 'delete' %]
55                 [% IF message.number > 0 %]
56                     <div class="dialog message">The field has been deleted</div>
57                 [% ELSE %]
58                     <div class="dialog alert">The field could not be deleted. Check the log for errors.</div>
59                 [% END %]
60             [% END %]
61         [% END %]
62     [% END %]
64     [% IF op == 'list_tables' %]
65         [% IF CAN_user_acquisitions_order_manage || CAN_user_serials_edit_subscription %]
66         <h3>Additional fields</h3>
67         <p>Select a table:</p>
68         [% BLOCK table_option %]
69             <li><a href="?tablename=[% value | uri %]">[% content | html %] (<span class="ex">[% value | html %]</span>)</a></li>
70         [% END %]
71         <ul>
72             [% IF CAN_user_acquisition_order_manage %]
73                 [% WRAPPER table_option value="aqbasket" %]Order baskets[% END %]
74             [% END %]
75             [% IF CAN_user_serials_edit_subscription %]
76                 [% WRAPPER table_option value="subscription" %]Subscriptions[% END %]
77             [% END %]
78         </ul>
79         [% ELSE %]
80             Additional permissions in the acquisitions or serials modules are required for editing additional fields
81         [% END %]
82     [% ELSIF op == 'list' %]
83         <h3>Additional fields for '[% tablename | html %]'</h3>
84         [% IF fields %]
85             <table id="fieldst">
86                 <thead>
87                     <tr>
88                         <th>Name</th>
89                         <th>Authorised value category</th>
90                         [% IF show_marcfield %]
91                             <th>MARC field</th>
92                         [% END %]
93                         <th>Searchable</th>
94                         <th>Actions</th>
95                     </tr>
96                 </thead>
97                 <tbody>
98                     [% FOR field IN fields %]
99                         <tr>
100                             <td>[% field.name | html %]</td>
101                             <td>[% field.authorised_value_category | html %]</td>
102                             [% IF show_marcfield %]
103                                 <td>[% field.marcfield | html %]</td>
104                             [% END %]
105                             <td>
106                                 [% IF field.searchable %]Yes[% ELSE %]No[% END %]
107                             </td>
108                             <td class="actions">
109                                 <a class="btn btn-default btn-xs" href="?op=add_form&amp;field_id=[% field.id | html %]"><i class="fa fa-pencil"></i> Edit</a>
110                                 <a class="confirmdelete btn btn-default btn-xs" href="?op=delete&amp;field_id=[% field.id | uri %]&amp;tablename=[% tablename | uri %]"><i class="fa fa-trash"></i> Delete</a>
111                             </td>
112                         </tr>
113                     [% END %]
114                 </tbody>
115             </table>
116         [% ELSE %]
117             [% IF tablename %]There are no additional fields defined for this table.[% END %]
118         [% END %]
119     [% ELSIF op == 'add_form' %]
120         [% IF field %]
121             <h3>Modify field</h3>
122         [% ELSE %]
123             <h3>Add field</h3>
124         [% END %]
125         <form action="" name="add_form" id="add_field" method="post">
126             <fieldset class="rows">
127                 <ol>
128                     <li>
129                         <label for="name" class="required">Name: </label>
130                         <input type="text" name="name" id="name" value="[% field.name | html %]" class="required" required="required" />
131                         <span class="required">Required</span>
132                     </li>
133                     <li>
134                         <label for="av">Authorised value category: </label>
135                         <select name="authorised_value_category">
136                             <option value="">None</option>
137                             [% PROCESS options_for_authorised_value_categories authorised_value_categories = AuthorisedValues.GetCategories({selected => field.authorised_value_category}) %]
138                         </select>
139                     </li>
140                     [% IF show_marcfield %]
141                         <li>
142                             <label for="marcfield">MARC field: </label>
143                             <input type="text" name="marcfield" id="marcfield" value="[% field.marcfield | html %]" />
144                         </li>
145                     [% END %]
146                     <li>
147                         <label for="searchable">Searchable: </label>
148                         [% IF field.searchable %]
149                             <input type="checkbox" name="searchable" id="searchable" checked="checked" />
150                         [% ELSE %]
151                             <input type="checkbox" name="searchable" id="searchable" />
152                         [% END %]
153                     </li>
154                 </ol>
155             </fieldset>
156             <fieldset class="action">
157                 [% IF field %]
158                     <input type="hidden" name="field_id" value="[% field.id | html %]" />
159                 [% END %]
160                 <input type="hidden" name="tablename" value="[% tablename | html %]" />
161                 <input type="hidden" name="op" value="add" />
162                 <input type="submit" value="Save" />
163                 <a href="?tablename=[% tablename | uri %]" class="cancel">Cancel</a>
164             </fieldset>
165         </form>
166     [% END %]
168             </main>
169         </div> <!-- /.col-sm-10.col-sm-push-2 -->
171         <div class="col-sm-2 col-sm-pull-10">
172             <aside>
173                 [% INCLUDE 'admin-menu.inc' %]
174             </aside>
175         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
176     </div> <!-- /.row -->
179 [% MACRO jsinclude BLOCK %]
180     [% INCLUDE "datatables.inc" %]
181     <script>
182         $(document).ready(function(){
183             $('#selecttable').find(":submit").hide();
184             $('#selecttable select').change(function() {
185                 $('#selecttable').submit();
186             });
188             $("#fieldst").dataTable($.extend(true, {}, dataTablesDefaults, {
189                 'bAutoWidth': false,
190                 'sDom': 't<"bottom pager"ilpf>',
191                 'sPaginationType': 'full',
192                 'aLengthMenu': [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
193                 'iDisplayLength': 20,
194                 'aaSorting': [[ 0, "asc" ]],
195             }));
197             $(".confirmdelete").click(function(){
198                 return confirm(_("Are you sure you want to delete this field?"));
199             });
201             $("#add_field").on('submit', function() {
202                 if ( $("#marcfield").length && $("select[name='authorised_value_category']").length ) {
203                     if ( $("#marcfield").val().length > 0
204                         && $("select[name='authorised_value_category']" ).val().length > 0 ) {
205                         alert(_("You cannot select an authorised value category and a MARC field") );
206                         return false;
207                     }
208                 }
209                 return true;
210             });
211         });
212     </script>
213 [% END %]
215 [% INCLUDE 'intranet-bottom.inc' %]