Bug 27846: admin folder
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / z3950servers.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5
6 [% BLOCK ServerType %]
7     [% IF (server.servertype||type) == 'sru' %]
8         SRU
9     [% ELSIF (server.servertype||type) == 'zed' %]
10         Z39.50
11     [% END %]
12 [% END %]
13
14 <title>Koha &rsaquo; Administration &rsaquo; Z39.50/SRU servers
15 [% IF op == 'edit' %] &rsaquo; Modify [% PROCESS ServerType %] server [% server.servername | html %][% END %]
16 [% IF op ==  'add' %] &rsaquo; New [% PROCESS ServerType %] server[% END %]
17 </title>
18 [% INCLUDE 'doc-head-close.inc' %]
19 </head>
20
21 <body id="admin_z3950servers" class="admin">
22 [% INCLUDE 'header.inc' %]
23 [% INCLUDE 'z3950-admin-search.inc' %]
24
25 <nav aria-label="Breadcrumb" class="breadcrumb">
26     <ol>
27         <li>
28             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
29         </li>
30         <li>
31             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
32         </li>
33
34         [% IF op == 'edit' %]
35             <li>
36                 <a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a>
37             </li>
38             <li>
39                 <a href="#" aria-current="page">
40                     Modify [% PROCESS ServerType %] server [% server.servername | html %]
41                 </a>
42             </li>
43
44         [% ELSIF op == 'add' %]
45             <li>
46                 <a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a>
47             </li>
48             <li>
49                 <a href="#" aria-current="page">
50                     New [% PROCESS ServerType %] server
51                 </a>
52             </li>
53
54         [% ELSE %]
55             <li>
56                 <a href="#" aria-current="page">
57                     Z39.50/SRU servers
58                 </a>
59             </li>
60         [% END %]
61
62     </ol>
63 </nav>
64
65 <div class="main container-fluid">
66     <div class="row">
67         <div class="col-sm-10 col-sm-push-2">
68             <main>
69
70 [% IF msg_deleted %]
71     <div class="dialog alert">Z39.50/SRU server deleted ([% msg_add | html %])</div>
72 [% ELSIF msg_updated %]
73     <div class="dialog message">Z39.50/SRU server updated ([% msg_add | html %])</div>
74 [% ELSIF msg_added %]
75     <div class="dialog message">Z39.50/SRU server added ([% msg_add | html %])</div>
76 [% ELSIF msg_notfound %]
77     <div class="dialog alert">Error: Server with id [% msg_add | html %] not found</div>
78 [% END %]
79
80 [% IF ( add_form ) %]
81     <form action="[% script_name | html %]" name="Aform" method="post" id="serverentry">
82         <input type="hidden" name="op" value="add_validated" />
83         <input type="hidden" name="servertype" value="[% server.servertype||type||'zed' | html %]"/>
84         [% IF op == 'edit' %]
85             <h1>Modify [% PROCESS ServerType %] server</h1>
86             <input type="hidden" name="id" value="[% server.id | html %]" />
87         [% ELSE %]
88             <h1>New [% PROCESS ServerType %] server</h1>
89         [% END %]
90         <fieldset class="rows">
91         <ol>
92         <li><label for="name" class="required">Server name: </label>
93             <input type="text" name="servername" id="servername" size="65" maxlength="100" value="[% server.servername | html %]" required="required" /> <span class="required">Required</span>
94         </li>
95
96         <li><label for="host" class="required">Hostname: </label> <input type="text" name="host" id="host" size="30" value="[% server.host | html %]" required="required" /> <span class="required">Required</span>
97             [% IF (server.servertype||type) == 'sru' %]
98                 <div class="hint">Includes the domain part, but the path part of the URL should go into Database.</div>
99             [% END %]
100         </li>
101         <li><label for="port" class="required">Port: </label> <input type="text" name="port" id="port" size="5" value="[% server.port | html %]" required="required" /> <span class="required">Required</span>
102         </li>
103         <li><label for="db" class="required">Database: </label> <input type="text" name="db" id="db" value="[% server.db | html %]" required="required" /> <span class="required">Required</span>
104         </li>
105         <li><label for="userid">Userid: </label> <input type="text" name="userid" id="userid" value="[% server.userid | html %]" />
106         </li>
107         <li><label for="password">Password: </label> <input type="text" name="password" id="password" value="[% server.password | html %]" />
108         </li>
109         <li><label for="checked">Preselected (searched by default): </label>
110         [% IF ( server.checked ) %]
111             <input type="checkbox" name="checked" id="checked" value="1" checked="checked" />
112         [% ELSE %]
113             <input type="checkbox" name="checked" id="checked" value="1" />
114         [% END %]
115         </li>
116         <li><label for="rank">Rank (display order): </label> <input type="text" name="rank" id="rank" size="4" value="[% server.rank | html %]" />
117         </li>
118         [% IF (server.servertype||type) == 'zed' %]
119         <li><label for="attributes">Attributes (additional PQF attributes added to each query): </label><input type="text" name="attributes" id="attributes" size="30" value="[% server.attributes | html %]" />
120         </li>
121         [% END %]
122
123         <li><label for="syntax">Syntax (z3950 can send<br /> records in various format. Choose one): </label>
124         <select name="syntax" id="syntax">
125             <option value="UNIMARC">UNIMARC</option>
126             <option value="INTERMARC">INTERMARC</option>
127             <option value="CCF">CCF</option>
128             <option value="USMARC">MARC21/USMARC</option>
129             <option value="UKMARC">UKMARC</option>
130             <option value="NORMARC">NORMARC</option>
131             <option value="LIBRISMARC">LIBRISMARC</option>
132             <option value="DANMARC">DANMARC</option>
133             <option value="FINMARC">FINMARC</option>
134             <option value="CANMARC">CANMARC</option>
135             <option value="SBN">SBN</option>
136             <option value="PICAMARC">PICAMARC</option>
137             <option value="AUSMARC">AUSMARC</option>
138             <option value="IBERMARC">IBERMARC</option>
139             <option value="CATMARC">CATMARC</option>
140             <option value="MALMARC">MALMARC</option>
141         </select>
142         </li>
143
144         <li><label for="encoding">Encoding (z3950 can send<br /> records in various encodings. Choose one): </label>
145         <select name="encoding" id="encoding">
146             [% FOREACH enc IN [ 'utf8' 'EUC-KR' 'ISO_5426' 'ISO_6937' 'ISO_8859-1' 'MARC-8' ] %]
147                 <option value="[% enc | html %]">[% enc | html %]</option>
148             [% END %]
149         </select>
150         </li>
151
152         <li><label for="timeout">Timeout (0 its like not set): </label>
153         <input type="text" name="timeout" id="timeout" size="4" value="[% server.timeout | html %]" /> seconds
154         </li>
155         <li><label for="recordtype">Record type: </label>
156         <select name="recordtype" id="recordtype">
157             <option value="biblio">Bibliographic</option>
158             <option value="authority">Authority</option>
159         </select>
160         </li>
161         [% IF (server.servertype||type) == 'sru' %]
162         <li>
163         <label for="sru_options">Additional SRU options: </label>
164         <input type="text" name="sru_options" id="sru_options" size="50" value="[% server.sru_options | html %]"/>
165         <div class="hint">Separate options by commas. Example: sru=get,sru_version=1.1. See also http://www.indexdata.com/yaz/doc/zoom.html.</div>
166         </li>
167         <li>
168         <label for="sru_fields">SRU Search fields mapping: </label>
169         <input type="hidden" name="sru_fields" id="sru_fields" value="[% server.sru_fields | html %]" />
170             <input type="text" name="show_sru_fields" id="show_sru_fields" size="100" value="[% server.sru_fields | html %]" disabled="disabled" /> <input type="button" id="modify_sru_fields" value="Modify" />
171         </li>
172         [% END %]
173         <li>
174         <label for="add_xslt">XSLT File(s) for transforming results: </label>
175         <input type="text" name="add_xslt" id="add_xslt" size="100" value="[% server.add_xslt | html %]"/>
176         <div class="hint">Separate multiple filenames by commas.</div>
177         </li>
178
179         </ol>
180         </fieldset>
181
182         <fieldset class="action"><input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/z3950servers.pl">Cancel</a></fieldset>
183     </form>
184 [% END %]
185
186 [% IF op == 'list' %]
187     <div id="toolbar" class="btn-toolbar">
188         <a id="newserver" class="btn btn-default" href="/cgi-bin/koha/admin/z3950servers.pl?op=add&type=zed"><i class="fa fa-plus"></i> New Z39.50 server</a>
189         <a id="newserver" class="btn btn-default" href="/cgi-bin/koha/admin/z3950servers.pl?op=add&type=sru"><i class="fa fa-plus"></i> New SRU server</a>
190     </div>
191     <h3>Z39.50/SRU servers administration</h3>
192     [% IF id %]
193         You searched for record [% id | html %]
194     [% ELSIF searchfield %]
195         You searched for [% searchfield | html %]
196     [% END %]
197     <table id="serverst">
198
199         <thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Preselected</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>Record type</th><th>Attributes</th><th class="noExport">Actions</th>
200         </tr></thead>
201         <tbody>
202         [% FOREACH loo IN loop %]
203             <tr>
204             <td><a href="/cgi-bin/koha/admin/z3950servers.pl?op=edit&amp;id=[% loo.id | uri %]">[% loo.servername | html %]</a></td><td>[% loo.host | html %]:[% loo.port | html %]</td><td>[% loo.db | html %]</td><td>[% loo.userid | html %]</td><td>[% IF loo.password %]########[% END %]</td><td>[% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %]</td><td>[% loo.rank | html %]</td>
205             <td>[% loo.syntax | html %]</td><td>[% loo.encoding | html %]</td><td>[% loo.timeout | html %]</td>
206             <td>[% IF ( loo.recordtype == 'biblio' )  %]
207                 <span>Bibliographic</span>
208                 [% ELSIF ( loo.recordtype == 'authority' ) %]
209                 <span>Authority</span>
210                 [% END %]
211             </td>
212             <td>[% loo.attributes | html %]</td>
213             <td>
214                 <div class="btn-group dropup">
215                     <a class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown" href="#">
216                         Actions <b class="caret"></b>
217                     </a>
218                     <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
219                         <li><a href="/cgi-bin/koha/admin/z3950servers.pl?op=edit&amp;id=[% loo.id | uri %]"><i class="fa fa-pencil"></i> Edit</a></li>
220                         <li><a href="/cgi-bin/koha/admin/z3950servers.pl?op=add&amp;id=[% loo.id | uri %]"><i class="fa fa-copy"></i> Copy</a></li>
221                         <li><a href="/cgi-bin/koha/admin/z3950servers.pl?op=delete_confirmed&amp;id=[% loo.id | uri %]" class="delete" data-servername="[% loo.servername | html %]"><i class="fa fa-trash"></i> Delete</a></li>
222                     </ul>
223                 </div>
224             </td>
225             </tr>
226         [% END %]
227         </tbody>
228     </table>
229 [% END %]
230
231             </main>
232         </div> <!-- /.col-sm-10.col-sm-push-2 -->
233
234         <div class="col-sm-2 col-sm-pull-10">
235             <aside>
236                 [% INCLUDE 'admin-menu.inc' %]
237             </aside>
238         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
239      </div> <!-- /.row -->
240
241 [% MACRO jsinclude BLOCK %]
242     [% Asset.js("js/admin-menu.js") | $raw %]
243     [% IF op == 'list' %]
244         [% INCLUDE 'datatables.inc' %]
245     [% END %]
246
247     <script>
248         [% IF ( add_form ) %]
249             $(document).ready(function(){
250                 // Update selects for syntax, encoding and recordtype
251                 [% IF server %]
252                     $("#syntax").val('[% server.syntax | html %]');
253                     $("#encoding").val('[% server.encoding | html %]');
254                     $("#recordtype").val('[% server.recordtype | html %]');
255                 [% END %]
256                 $( "#serverentry" ).validate({
257                     rules: {
258                         servername: { required: true },
259                         host: { required: true },
260                         port: {
261                             required: true,
262                             number: true
263                         },
264                         db: { required: true },
265                         rank: { number: true },
266                         timeout: { number: true }
267                     }
268                 });
269                 $("#serverentry").submit(function( event ) {
270                     // first test if show_sru_fields exists
271                     if( $('#show_sru_fields').length && $('#show_sru_fields').val()=='' && !confirm( _("No SRU search field mappings have been defined. This means that all field searches will go through the whole record. Continue?"))) {
272                         return false;
273                     }
274                     // copy show_sru_fields to hidden counterpart
275                     $('#sru_fields').val( $('#show_sru_fields').val() );
276                     // enable recordtype to include field in post
277                     $('#recordtype').prop('disabled',false);
278                 });
279                 $("#servername").on("blur",function(){
280                     toUC(this);
281                 });
282                 $("#modify_sru_fields").on("click",function(){
283                     ModMapping();
284                 });
285             });
286             function ModMapping () {
287                 var map= $('#show_sru_fields').val();
288                 var type= $('#recordtype').val();
289                 window.open('/cgi-bin/koha/admin/sru_modmapping.pl?mapping='+map + '&type=' + type,'popup','width=800,height=400,resizable=yes,toolbar=false,scrollbars=yes,top');
290             }
291         [% ELSE %]
292             $(document).ready(function() {
293                 $("#serverst").dataTable($.extend(true, {}, dataTablesDefaults, {
294                     "aoColumnDefs": [
295                         { "aTargets": [-1], "bSortable": false, "bSearchable": false },
296                     ],
297                     "sPaginationType": "full"
298                 }));
299                 $(".delete").on("click",function(e){
300                     var servername = $(this).data("servername");
301                     if( confirm( _("Are you sure you want to delete server %s?").format(servername) ) ) {
302                         return true;
303                     } else {
304                         e.preventDefault();
305                     }
306                 });
307             });
308         [% END %]
309     </script>
310 [% END %]
311 [% INCLUDE 'intranet-bottom.inc' %]