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