4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha › Tools › Notices[% IF ( add_form or copy_form ) %][% IF ( modify ) %] › Modify notice[% ELSE %] › Add notice[% END %][% END %][% IF ( add_validate or copy_validate) %] › Notice added[% END %][% IF ( delete_confirm ) %] › Confirm deletion[% END %]</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
10 <body id="tools_letter" class="tools">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'letters-search.inc' %]
14 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › [% IF ( add_form or copy_form) %][% IF ( modify ) %]<a href="/cgi-bin/koha/tools/letter.pl">Notices & Slips</a> › Modify notice[% ELSE %] <a href="/cgi-bin/koha/tools/letter.pl">Notices & Slips</a> › Add notice[% END %][% ELSE %][% IF ( add_validate or copy_validate) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices & Slips</a> › Notice added[% ELSE %][% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices & Slips</a> › Confirm deletion[% ELSE %]Notices & Slips[% END %][% END %][% END %]</div>
16 [% IF add_form or copy_form %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
22 [% IF ( no_op_set ) %]
23 <h1>Notices and Slips</h1>
24 <form method="get" action="/cgi-bin/koha/tools/letter.pl" id="selectlibrary">
25 <input type="hidden" name="searchfield" value="[% searchfield | html %]" />
26 [% UNLESS independant_branch %]
29 <select name="branchcode" id="branch" style="width:20em;">
30 <option value="*">All libraries</option>
31 [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
35 <div id="toolbar" class="btn-toolbar">
36 <button type="submit" class="btn btn-default btn-sm" id="newnotice"><i class="fa fa-plus"></i> New notice</button>
37 <input type="hidden" id="op" name="op" />
42 <p>You searched for <b>[% searchfield | html %]</b></p>
44 [% IF ( letter && !independant_branch) %]
45 [% select_for_copy = BLOCK %]
46 <select name="branchcode">
47 [% FOREACH l IN Branches.all() %]
48 <option value="[% l.branchcode %]">Copy to [% l.branchname %]</option>
61 <th class="nosort">Copy notice</th>
62 <th class="nosort">Actions</th>
66 [% FOREACH lette IN letter %]
67 [% can_edit = lette.branchcode || !independant_branch %]
69 <td>[% IF lette.branchname %][% lette.branchname %][% ELSE %](All libraries)[% END %]</td>
70 <td>[% lette.module %]</td>
71 <td>[% lette.code %]</td>
72 <td>[% lette.name %]</td>
74 [% IF !independant_branch || !lette.branchcode %]
75 <form method="post" action="/cgi-bin/koha/tools/letter.pl">
76 <input type="hidden" name="op" value="copy_form" />
77 <input type="hidden" name="oldbranchcode" value="[% lette.branchcode %]" />
78 <input type="hidden" name="module" value="[% lette.module %]" />
79 <input type="hidden" name="code" value="[% lette.code %]" />
80 [% IF independant_branch %]
81 <input type="hidden" name="branchcode" value="[% independant_branch %]" />
85 <button class="btn btn-default btn-xs"><i class="fa fa-clone"></i> Copy</button>
91 <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/letter.pl?op=add_form&branchcode=[% lette.branchcode %]&module=[% lette.module %]&code=[% lette.code %]"><i class="fa fa-pencil"></i> Edit</a>
93 [% IF !lette.protected && can_edit %]
94 <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/letter.pl?op=delete_confirm&branchcode=[%lette.branchcode %]&module=[% lette.module %]&code=[% lette.code %]"><i class="fa fa-trash"></i> Delete</a>
102 <div class="dialog message">
103 [% IF ( branchcode ) %]
104 <p>There are no notices for this library.</p>
106 <p>There are no notices.</p>
113 [% IF add_form or copy_form %]
114 <h1>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</h1>
116 <div id="toolbar" class="btn-toolbar">
117 <div class="btn-group">
118 <button class="btn btn-default btn-sm" id="submit_form"><i class="fa fa-save"></i> Save</button>
119 <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
120 <span class="caret"></span>
122 <ul class="dropdown-menu">
123 <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
126 <a class="btn btn-default btn-sm cancel" href="/cgi-bin/koha/tools/letter.pl"><i class="fa fa-remove"></i> Cancel</a>
129 <form id="add_notice" name="Aform" method="post" enctype="multipart/form-data" class="validate">
131 <input type="hidden" name="op" id="op" value="add_validate" />
133 <input type="hidden" name="op" id="op" value="copy_validate" />
136 <input type="hidden" name="checked" value="0" />
138 <input type="hidden" name="add" value="0" />
140 <input type="hidden" name="add" value="1" />
142 <fieldset class="rows">
143 <input type="hidden" name="oldbranchcode" value="[% oldbranchcode %]" />
145 [% IF independant_branch %]
146 <input type="hidden" name="branchcode" value="[% independant_branch %]" />
151 <label for="branch">Library:</label>
152 <select name="branchcode" id="branch" style="width:20em;">
153 <option value="">All libraries</option>
154 [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
157 <span class="label">Library:</span>
158 <input type="hidden" id="branch" name="branchcode" value="[% branchcode %]" />
159 [% IF ( branchcode ) %]
160 [% Branches.GetName( branchcode ) %]
168 <label for="module">Koha module:</label>
169 <input type="hidden" name="oldmodule" value="[% module %]" />
171 <select name="module" id="newmodule">
173 <select name="module" id="module">
175 [% IF ( module == "acquisition" ) %]
176 <option value="acquisition" selected="selected">Acquisition</option>
178 <option value="acquisition" >Acquisition</option>
180 [% IF ( module == "catalogue" ) %]
181 <option value="catalogue" selected="selected">Catalog</option>
183 <option value="catalogue" >Catalog</option>
185 [% IF ( module == "circulation" ) %]
186 <option value="circulation" selected="selected">Circulation</option>
188 <option value="circulation">Circulation</option>
190 [% IF ( module == "orderacquisition" ) %]
191 <option value="orderacquisition" selected="selected">Order acquisition</option>
193 <option value="orderacquisition">Order acquisition</option>
195 [% IF ( module == "claimacquisition" ) %]
196 <option value="claimacquisition" selected="selected">Claim acquisition</option>
198 <option value="claimacquisition">Claim acquisition</option>
200 [% IF ( module == "claimissues" ) %]
201 <option value="claimissues" selected="selected">Claim serial issue</option>
203 <option value="claimissues">Claim serial issue</option>
205 [% IF ( module == "reserves" ) %]
206 <option value="reserves" selected="selected">Holds</option>
208 <option value="reserves">Holds</option>
210 [% IF ( module == "members" ) %]
211 <option value="members" selected="selected">Members</option>
213 <option value="members">Members</option>
215 [% IF ( module == "serial" ) %]
216 <option value="serial" selected="selected">Serials (routing list)</option>
218 <option value="serial">Serials (routing list)</option>
220 [% IF ( module == "suggestions" ) %]
221 <option value="suggestions" selected="selected">Suggestions</option>
223 <option value="suggestions">Suggestions</option>
229 <label for="code" class="required">Code:</label>
230 <input type="text" id="code" name="code" size="20" maxlength="20" value="" required="required"/>
231 <span class="required">Required</span>
233 <span class="label">Code:</span>
234 <input type="hidden" id="code" name="code" value="[% code %]" />
239 <label for="name" class="required">Name:</label>
240 <input type="text" id="name" name="name" size="60" value="[% letter_name %]" required="required" />
241 <span class="required">Required</span>
245 [% IF Koha.Preference('TranslateNotices') %]
246 <div style="clear:both"></div>
249 <li><a href="#lang_default">Default</a></li>
250 [% FOR language IN languages %]
251 [% FOR sublanguage IN language.sublanguages_loop %]
252 [% IF language.plural %]
253 <li><a href="#lang_[% sublanguage.rfc4646_subtag %]">[% sublanguage.native_description %] [% sublanguage.region_description %] ([% sublanguage.rfc4646_subtag %])</a></li>
255 <li><a href="#lang_[% sublanguage.rfc4646_subtag %]">[% sublanguage.native_description %] ([% sublanguage.rfc4646_subtag %])</a></li>
262 [% FOREACH lang IN letters.keys %]
263 <div id="lang_[% lang %]">
264 <div class="transport-types" style="clear:both">
265 [% FOR mtt IN letters.$lang.templates.keys.sort %]
266 [% SET letter = letters.$lang.templates.$mtt %]
268 [% SWITCH letter.message_transport_type %]
280 [% letter.message_transport_type %]
283 [% IF letter.message_transport_type == "sms" and not Koha.Preference("SMSSendDriver") %]
284 <fieldset class="rows mtt" id="[% letter.message_transport_type %]_[% lang %]" disabled="disabled">
285 <div class="dialog message">You should enable the SMSSendDriver preference to use the SMS templates.</div>
286 [% ELSIF letter.message_transport_type == "phone" and not Koha.Preference("TalkingTechItivaPhoneNotification") %]
287 <fieldset class="rows mtt" id="[% letter.message_transport_type %]_[% lang %]" disabled="disabled">
288 <div class="dialog message">You should enable the TalkingTechItivaPhoneNotification preference to use the phone templates.</div>
290 <fieldset class="rows mtt" id="[% letter.message_transport_type %]_[% lang %]">
294 <input type="hidden" name="message_transport_type" value="[% letter.message_transport_type %]" />
295 <input type="hidden" name="lang" value="[% lang %]" />
296 <label for="is_html_[% letter.message_transport_type %]">HTML message:</label>
297 [% IF letter.is_html %]
298 <input type="checkbox" name="is_html_[% letter.message_transport_type %]" id="is_html_[% letter.message_transport_type %]" value="1" checked="checked" />
300 <input type="checkbox" name="is_html_[% letter.message_transport_type %]" id="is_html_[% letter.message_transport_type %]" value="1" />
304 <label for="title_[% letter.message_transport_type %]">Message subject:</label><input type="text" id="title_[% letter.message_transport_type %]" name="title" size="60" value="[% letter.title %]" />
307 <label for="SQLfieldname_[% letter.message_transport_type %]">Message body:</label>
308 [% IF letter.message_transport_type == 'sms' %]
309 <span id="sms_counter">[% IF letter.content && letter.content.length > 0 %][% letter.content.length %][% ELSE %]0[% END %]/160 characters</span>
314 <select name="SQLfieldname" id="SQLfieldname_[% letter.message_transport_type %]" multiple="multiple" size="9">
315 [% FOREACH SQLfieldname IN SQLfieldnames %]
316 <option value="[% SQLfieldname.value %]">[% SQLfieldname.text %]</option>
321 <button type="button" data-containerid="[% letter.message_transport_type %]_[% lang %]" class="btn btn-default btn-sm insert">Insert <i class="fa fa-long-arrow-right"></i></button>
323 <td><textarea name="content" id="content_[% letter.message_transport_type %]" cols="80" rows="15">[% letter.content %]</textarea></td>
331 </div> <!-- / #transport-types -->
333 [% IF Koha.Preference('TranslateNotices') %]
337 [% IF code.search('DGST') %] <span class="overdue">Warning, this is a template for a Digest, as such, any references to branch data ( e.g. branches.branchname ) will refer to the borrower's home branch.</span> [% END %]
339 <input type="hidden" id="redirect" name="redirect" value="" />
340 <input type="hidden" name="searchfield" value="[% searchfield %]" />
344 [% IF ( add_validate or copy_validate) %]
346 <form action="[% action %]" method="post">
347 <input type="submit" value="OK" />
351 [% IF ( delete_confirm ) %]
352 <div class="dialog alert">
353 <h3>Delete notice?</h3>
364 <td>[% IF letter.branchcode %][% Branches.GetName( letter.branchcode ) %][% ELSE %](All libraries)[% END %]</td>
365 <td>[% letter.module %]</td>
366 <td>[% letter.code %]</td>
367 <td>[% letter.name %]</td>
370 <form action="[% action %]" method="post">
371 <input type="hidden" name="op" value="delete_confirmed">
372 <input type="hidden" name="branchcode" value="[% letter.branchcode %]" />
373 <input type="hidden" name="code" value="[% letter.code %]" />
374 <input type="hidden" name="module" value="[% letter.module %]" />
375 <button type="submit" class="approve"><i class="fa fa-check"></i> Yes, delete</button>
378 <form action="[% action %]" method="get">
379 <button type="submit" class="deny"><i class="fa fa-times"></i> No, do not delete</button>
384 [% IF ( delete_confirmed ) %]
386 <form action="[% action %]" method="post">
387 <input type="submit" value="OK" />
393 [% UNLESS add_form or copy_form %]
394 <div class="yui-b noprint">
395 [% INCLUDE 'tools-menu.inc' %]
400 [% MACRO jsinclude BLOCK %]
401 <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
402 [% INCLUDE 'datatables.inc' %]
403 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
404 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.insertatcaret.js"></script>
405 <script type="text/javascript">
406 $(document).ready(function() {
407 [% IF add_form or copy_form %]
408 $('#toolbar').fixFloat();
410 $("#lettert:has(tbody tr)").dataTable($.extend(true, {}, dataTablesDefaults, {
413 { "bSortable": false, "bSearchable": false, 'aTargets': [ 'nosort' ] }
418 $('#branch').change(function() {
420 $('#selectlibrary').submit();
422 $('#newnotice').click(function() {
423 $('#op').val("add_form");
428 $("#newmodule").on("change",function(){
429 if( $("#branch").val() == ""){
430 var branchcode = "*";
432 var branchcode = $("#branch").val();
434 window.location.href = "/cgi-bin/koha/tools/letter.pl?op=add_form&module=" + $(this).val() + "&branchcode=" + branchcode;
437 $("#submit_form").click( function(event) {
438 event.preventDefault();
439 var at_least_one_exists = 0;
441 $("fieldset.mtt").each( function(){
442 var title = $(this).find('input[name="title"]').val();
443 var content = $(this).find('textarea[name="content"]').val();
445 ( title.length == 0 && content.length > 0 )
446 || ( title.length > 0 && content.length == 0 )
448 var mtt = $(this).find('input[name="message_transport_type"]').val();
449 var msg = _("Please specify title and content for %s");
450 msg = msg.replace( "%s", mtt );
451 at_least_one_exists = 1;
453 return are_valid = false;
454 } else if ( title.length > 0 && content.length > 0 ) {
455 at_least_one_exists = 1;
458 if ( ! at_least_one_exists ) {
459 alert( _("Please fill at least one template.") );
466 // Test if code already exists in DB
467 var new_lettercode = $("#code").val();
468 var new_branchcode = $("#branch").val();
469 [% IF ( add_form and code ) # IF edit %]
470 if ( new_lettercode != '[% code %]' ) {
473 data: { code: new_lettercode, branchcode: new_branchcode },
475 url: '/cgi-bin/koha/svc/letters/',
476 success: function (data) {
477 if ( data.letters.length > 0 ) {
478 if( new_branchcode == '' ) {
479 alert( _("A default letter with the code '%s' already exists.").format(new_lettercode) );
481 alert( _("A letter with the code '%s' already exists for '%s'.").format(new_lettercode, new_branchcode) );
485 $("#add_notice").submit();
489 [% IF ( add_form and code ) %]
491 $("#add_notice").submit();
497 $("#content_sms").on("keyup", function(){
498 var length = $(this).val().length;
499 $("#sms_counter").html(length + "/" + sms_limit + _(" characters"));
500 if ( length > sms_limit ) {
501 $("#sms_counter").css("color", "red");
503 $("#sms_counter").css("color", "black");
506 $( ".transport-types" ).accordion({ collapsible: true, active:false, animate: 200 });
507 $(".insert").on("click",function(){
508 var containerid = $(this).data("containerid");
509 insertValueQuery( containerid );
514 $("#saveandcontinue").on("click",function(e){
516 $("#redirect").val("just_save");
517 $("#submit_form").click();
521 [% IF add_form or copy_form %]
528 function isNotNull(f,noalert) {
529 if (f.value.length ==0) {
535 function isNum(v,maybenull) {
536 var n = new Number(v.value);
540 if (maybenull==0 && v.value==''){
545 function insertValueQuery(containerid) {
546 var fieldset = $("#" + containerid);
547 var myQuery = $(fieldset).find('textarea[name="content"]');
548 var myListBox = $(fieldset).find('select[name="SQLfieldname"]');
550 if($(myListBox).find('option').length > 0) {
551 $(myListBox).find('option').each( function (){
552 if ( $(this).attr('selected') && $(this).val().length > 0 ) {
553 $(myQuery).insertAtCaret("<<" + $(this).val() + ">>");
562 [% INCLUDE 'intranet-bottom.inc' %]