Line 0
Link Here
|
0 |
- |
1 |
[% USE raw %] |
|
|
2 |
[% USE Asset %] |
3 |
[% SET footerjs = 1 %] |
4 |
[% USE TablesSettings %] |
5 |
[% INCLUDE 'doc-head-open.inc' %] |
6 |
<title>Koha › Administration › SMTP servers |
7 |
[% IF op == 'add_form' %] |
8 |
›[% IF library %]Modify SMTP server[% ELSE %]New SMTP server[% END %] |
9 |
[% ELSIF op == 'delete_confirm' %] |
10 |
› Confirm deletion of SMTP server '[% server.name | html %]' |
11 |
[% END %] |
12 |
</title> |
13 |
[% INCLUDE 'doc-head-close.inc' %] |
14 |
</head> |
15 |
|
16 |
<body id="admin_smtp_servers" class="admin"> |
17 |
[% INCLUDE 'header.inc' %] |
18 |
[% INCLUDE 'prefs-admin-search.inc' %] |
19 |
|
20 |
<div id="breadcrumbs"> |
21 |
<a href="/cgi-bin/koha/mainpage.pl">Home</a> › |
22 |
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › |
23 |
<a href="/cgi-bin/koha/admin/smtp_servers.pl">SMTP servers</a> |
24 |
[% IF op == 'add_form' %] |
25 |
› <span> New</span> |
26 |
[% ELSIF op == 'edit_form' %] |
27 |
› <span> Edit</span> |
28 |
[% END %] |
29 |
</div> |
30 |
|
31 |
<div class="main container-fluid"> |
32 |
<div class="row"> |
33 |
<div class="col-sm-10 col-sm-push-2"> |
34 |
<main> |
35 |
|
36 |
[% FOREACH m IN messages %] |
37 |
<div class="dialog [% m.type | html %]"> |
38 |
[% SWITCH m.code %] |
39 |
[% CASE 'error_on_edit' %] |
40 |
An error occurred trying to open the server for editing. The passed id is invalid. |
41 |
[% CASE 'error_on_insert' %] |
42 |
An error occurred when adding the server. The library already has an SMTP server set. |
43 |
[% CASE 'error_on_delete' %] |
44 |
An error occurred when deleting this server. Check the logs. |
45 |
[% CASE 'success_on_update' %] |
46 |
Server updated successfully. |
47 |
[% CASE 'success_on_insert' %] |
48 |
Server added successfully. |
49 |
[% CASE 'success_on_delete' %] |
50 |
Server deleted successfully. |
51 |
[% CASE %] |
52 |
[% m.code | html %] |
53 |
[% END %] |
54 |
</div> |
55 |
[% END %] |
56 |
|
57 |
[% IF op == 'add_form' %] |
58 |
<h3>New SMTP server</h3> |
59 |
<form action="/cgi-bin/koha/admin/smtp_servers.pl" id="add" name="add" class="validated" method="post"> |
60 |
<input type="hidden" name="op" value="add" /> |
61 |
<fieldset class="rows"> |
62 |
<ol> |
63 |
<li> |
64 |
<label for="library_id" class="required">Library: </label> |
65 |
<select name="library_id" id="library_id"> |
66 |
[%- UNLESS default_set -%] |
67 |
<option value="*">All libraries</option> |
68 |
[%- END -%] |
69 |
[%- FOREACH library IN unset_libraries -%] |
70 |
<option value="[% library.branchcode | html %]">[% library.branchname | html %]</option> |
71 |
[%- END -%] |
72 |
</select> |
73 |
<span class="required">Required</span> |
74 |
</li> |
75 |
</select> |
76 |
<li> |
77 |
<label for="smtp_name" class="required">Name: </label> |
78 |
<input type="text" name="smtp_name" id="smtp_name" size="60" class="required" required="required" /> |
79 |
<span class="required">Required</span> |
80 |
</li> |
81 |
</ol> |
82 |
</fieldset> |
83 |
|
84 |
<fieldset class="rows"> |
85 |
<ol> |
86 |
<li> |
87 |
<label for="smtp_host">Host: </label> |
88 |
<input type="text" name="smtp_host" id="smtp_host" size="60" class="required"/> |
89 |
<span class="required">Required</span> |
90 |
</li> |
91 |
<li> |
92 |
<label for="smtp_port">Port: </label> |
93 |
<input type="number" step="1" value="25" name="smtp_port" id="smtp_port" size="20" class="required"/> |
94 |
<span class="required">Required</span> |
95 |
</li> |
96 |
<li> |
97 |
<label for="smtp_timeout">Timeout (seconds): </label> |
98 |
<input type="number" step="1" value="120" name="smtp_timeout" id="smtp_timeout" size="20" /> |
99 |
</li> |
100 |
<li> |
101 |
<label for="smtp_ssl">SSL: </label> |
102 |
<select name="smtp_ssl" id="smtp_ssl"> |
103 |
<option value="1" selected="selected">Yes</option> |
104 |
<option value="0">No</option> |
105 |
</select> |
106 |
</li> |
107 |
<li> |
108 |
<label for="smtp_user_name">User name: </label> |
109 |
<input type="text" name="smtp_user_name" id="smtp_user_name" size="60" /> |
110 |
</li> |
111 |
<li> |
112 |
<label for="smtp_password">Password: </label> |
113 |
<input type="password" name="smtp_password" id="smtp_password" size="60" /> |
114 |
</li> |
115 |
</ol> |
116 |
</fieldset> |
117 |
<fieldset class="action"> |
118 |
<input type="submit" value="Submit" /> |
119 |
<a class="cancel" href="/cgi-bin/koha/admin/smtp_servers.pl">Cancel</a> |
120 |
</fieldset> |
121 |
</form> |
122 |
[% END %] |
123 |
|
124 |
[% IF op == 'edit_form' %] |
125 |
<h3>Edit SMTP server</h3> |
126 |
<form action="/cgi-bin/koha/admin/smtp_servers.pl" id="edit_save" name="edit_save" class="validated" method="post"> |
127 |
<input type="hidden" name="op" value="edit_save" /> |
128 |
<input type="hidden" name="smtp_server_id" value="[%- smtp_server.id | html -%]" /> |
129 |
<fieldset class="rows"> |
130 |
<ol> |
131 |
<li> |
132 |
<label for="library_id">Library: </label> |
133 |
[% IF smtp_server.library %] |
134 |
<span name="library_id" id="library_id">[%- smtp_server.library.branchname | html -%]</span> |
135 |
[%- ELSE -%] |
136 |
<span name="library_id" id="library_id">All libraries</span> |
137 |
[%- END -%] |
138 |
</li> |
139 |
</select> |
140 |
<li> |
141 |
<label for="smtp_name" class="required">Name: </label> |
142 |
<input type="text" name="smtp_name" id="smtp_name" size="60" class="required" required="required" value="[%- smtp_server.name | html -%]"/> |
143 |
<span class="required">Required</span> |
144 |
</li> |
145 |
</ol> |
146 |
</fieldset> |
147 |
|
148 |
<fieldset class="rows"> |
149 |
<ol> |
150 |
<li> |
151 |
<label for="smtp_host">Host: </label> |
152 |
<input type="text" name="smtp_host" id="smtp_host" size="60" class="required" value="[%- smtp_server.host | html -%]"/> |
153 |
<span class="required">Required</span> |
154 |
</li> |
155 |
<li> |
156 |
<label for="smtp_port">Port: </label> |
157 |
<input type="number" step="1" value="25" name="smtp_port" id="smtp_port" size="20" class="required" value="[%- smtp_server.port | html -%]"/> |
158 |
<span class="required">Required</span> |
159 |
</li> |
160 |
<li> |
161 |
<label for="smtp_timeout">Timeout (seconds): </label> |
162 |
<input type="number" step="1" value="120" name="smtp_timeout" id="smtp_timeout" size="20" value="[%- smtp_server.timeout | html -%]"/> |
163 |
</li> |
164 |
<li> |
165 |
<label for="smtp_ssl">SSL: </label> |
166 |
<select name="smtp_ssl" id="smtp_ssl"> |
167 |
[%- IF smtp_server.ssl -%] |
168 |
<option value="1" selected="selected">Yes</option> |
169 |
<option value="0">No</option> |
170 |
[%- ELSE -%] |
171 |
<option value="1">Yes</option> |
172 |
<option value="0" selected="selected">No</option> |
173 |
[%- END -%] |
174 |
</select> |
175 |
</li> |
176 |
<li> |
177 |
<label for="smtp_user_name">User name: </label> |
178 |
<input type="text" name="smtp_user_name" id="smtp_user_name" size="60" value="[%- smtp_server.user_name | html -%]"/> |
179 |
</li> |
180 |
<li> |
181 |
<label for="smtp_password">Password: </label> |
182 |
<input type="password" name="smtp_password" id="smtp_password" size="60" value="[%- smtp_server.password | html -%]"/> |
183 |
</li> |
184 |
</ol> |
185 |
</fieldset> |
186 |
<fieldset class="action"> |
187 |
<input type="submit" value="Submit" /> |
188 |
<a class="cancel" href="/cgi-bin/koha/admin/smtp_servers.pl">Cancel</a> |
189 |
</fieldset> |
190 |
</form> |
191 |
[% END %] |
192 |
|
193 |
[% IF op == 'list' %] |
194 |
|
195 |
[%- IF unset_libraries.count > 0 -%] |
196 |
<div id="toolbar" class="btn-toolbar"> |
197 |
<a class="btn btn-default" id="new_smtp_server" href="/cgi-bin/koha/admin/smtp_servers.pl?op=add_form"><i class="fa fa-plus"></i> New SMTP server</a> |
198 |
</div> |
199 |
[%- END -%] |
200 |
|
201 |
<h3>SMTP servers</h3> |
202 |
|
203 |
[% IF servers_count > 0 %] |
204 |
<table id="smtp_servers"> |
205 |
<thead> |
206 |
<tr> |
207 |
<th>Library</th> |
208 |
<th>Name</th> |
209 |
<th>Host</th> |
210 |
<th>Port</th> |
211 |
<th>Timeout (secs)</th> |
212 |
<th>SSL</th> |
213 |
<th>Authenticated</th> |
214 |
<th data-class-name="actions">Actions</th> |
215 |
</tr> |
216 |
</thead> |
217 |
</table> |
218 |
[% ELSE %] |
219 |
<div class="dialog message">No user-defined SMTP servers. Using the default configuration: |
220 |
<ul> |
221 |
<li><strong>Host</strong>: [%- default_config.host | html -%]</li> |
222 |
<li><strong>Port</strong>: [%- default_config.port | html -%]</li> |
223 |
<li><strong>Timeout (secs)</strong>: [%- default_config.timeout | html -%]</li> |
224 |
<li><strong>SSL</strong>: [%- IF default_config.ssl -%]Yes[%- ELSE -%]No[%- END -%]</li> |
225 |
</ul> |
226 |
</pre> |
227 |
</div> |
228 |
[% END %] |
229 |
[% END %] |
230 |
|
231 |
<div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> |
232 |
<div class="modal-dialog"> |
233 |
<div class="modal-content"> |
234 |
<div class="modal-header"> |
235 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
236 |
<h3 id="delete_confirm_modal_label">Delete server</h3> |
237 |
</div> |
238 |
<div class="modal-body"> |
239 |
<div id="delete_confirm_dialog"></div> |
240 |
</div> |
241 |
<div class="modal-footer"> |
242 |
<a href="#" class="btn btn-default" id="delete_confirm_modal_button" role="button" data-toggle="modal">Delete</a> |
243 |
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> |
244 |
</div> |
245 |
</div> <!-- /.modal-content --> |
246 |
</div> <!-- /.modal-dialog --> |
247 |
</div> <!-- #delete_confirm_modal --> |
248 |
|
249 |
</main> |
250 |
</div> <!-- /.col-sm-10.col-sm-push-2 --> |
251 |
|
252 |
<div class="col-sm-2 col-sm-pull-10"> |
253 |
<aside> |
254 |
[% INCLUDE 'admin-menu.inc' %] |
255 |
</aside> |
256 |
</div> <!-- /.col-sm-2.col-sm-pull-10 --> |
257 |
</div> <!-- /.row --> |
258 |
|
259 |
|
260 |
[% MACRO jsinclude BLOCK %] |
261 |
[% Asset.js("js/admin-menu.js") | $raw %] |
262 |
[% INCLUDE 'datatables.inc' %] |
263 |
[% INCLUDE 'columns_settings.inc' %] |
264 |
[% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] |
265 |
[% INCLUDE 'str/tinymce_i18n.inc' %] |
266 |
<script> |
267 |
$(document).ready(function() { |
268 |
|
269 |
var smtp_servers_url = '/api/v1/config/smtp_servers'; |
270 |
var smtp_servers = $("#smtp_servers").api({ |
271 |
"ajax": { |
272 |
"url": smtp_servers_url |
273 |
}, |
274 |
"embed": [ |
275 |
"library" |
276 |
], |
277 |
'emptyTable': '<div class="dialog message">'+_("There are no SMTP servers defined.")+'</div>', |
278 |
"columnDefs": [ { |
279 |
"targets": [0,1,2], |
280 |
"render": function (data, type, row, meta) { |
281 |
if ( type == 'display' ) { |
282 |
if ( data != null ) { |
283 |
return data.escapeHtml(); |
284 |
} |
285 |
else { |
286 |
return "Default"; |
287 |
} |
288 |
} |
289 |
return data; |
290 |
} |
291 |
} ], |
292 |
"columns": [ |
293 |
{ |
294 |
"data": "library.name", |
295 |
"searchable": true, |
296 |
"orderable": true |
297 |
}, |
298 |
{ |
299 |
"data": "name", |
300 |
"searchable": true, |
301 |
"orderable": true |
302 |
}, |
303 |
{ |
304 |
"data": "host", |
305 |
"searchable": true, |
306 |
"orderable": true |
307 |
}, |
308 |
{ |
309 |
"data": "port", |
310 |
"searchable": true, |
311 |
"orderable": false |
312 |
}, |
313 |
{ |
314 |
"data": "timeout", |
315 |
"searchable": true, |
316 |
"orderable": false |
317 |
}, |
318 |
{ |
319 |
"data": "ssl", |
320 |
"render": function (data, type, row, meta) { |
321 |
if (data) { |
322 |
return _("Yes"); |
323 |
} |
324 |
else { |
325 |
return _("No"); |
326 |
} |
327 |
}, |
328 |
"searchable": false, |
329 |
"orderable": false |
330 |
}, |
331 |
{ |
332 |
"data": function( row, type, val, meta ) { |
333 |
if ( row.user_name != null ) { |
334 |
return _("Yes"); |
335 |
} |
336 |
else { |
337 |
return _("No"); |
338 |
} |
339 |
}, |
340 |
"searchable": false, |
341 |
"orderable": false |
342 |
}, |
343 |
{ |
344 |
"data": function( row, type, val, meta ) { |
345 |
var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/smtp_servers.pl?op=edit_form&smtp_server_id='+ encodeURIComponent(row.smtp_server_id) +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n"; |
346 |
result += '<a class="btn btn-default btn-xs delete_server" role="button" href="#" data-toggle="modal" data-target="#delete_confirm_modal" data-smtp-server-id="'+ encodeURIComponent(row.smtp_server_id) +'" data-smtp-server-name="'+ encodeURIComponent(row.name) +'"><i class="fa fa-trash" aria-hidden="true"></i>'+_("Delete")+'</a>'; |
347 |
return result; |
348 |
}, |
349 |
"searchable": false, |
350 |
"orderable": false |
351 |
} |
352 |
] |
353 |
}); |
354 |
|
355 |
$('#smtp_servers').on( "click", '.delete_server', function () { |
356 |
var smtp_server_id = $(this).data('smtp-server-id'); |
357 |
var smtp_server_name = $(this).data('smtp-server-name'); |
358 |
|
359 |
$("#delete_confirm_dialog").html( |
360 |
_("You are about to delete the \"%s\" SMTP server.").format(smtp_server_name) |
361 |
); |
362 |
$("#delete_confirm_modal_button").attr("href", "/cgi-bin/koha/admin/smtp_servers.pl?op=delete&smtp_server_id=" + encodeURIComponent(smtp_server_id)); |
363 |
}); |
364 |
}); |
365 |
</script> |
366 |
[% END %] |
367 |
|
368 |
[% INCLUDE 'intranet-bottom.inc' %] |