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_[% KOHA_VERSION %].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 %]
17 <div class="main container-fluid">
19 <div class="col-md-8 col-md-offset-2">
21 <div id="doc3" class="yui-t2">
28 [% IF ( no_op_set ) %]
29 <h1>Notices and Slips</h1>
30 <form method="get" action="/cgi-bin/koha/tools/letter.pl" id="selectlibrary">
31 <input type="hidden" name="searchfield" value="[% searchfield | html %]" />
32 [% UNLESS independant_branch %]
35 <select name="branchcode" id="branch" style="width:20em;">
36 <option value="*">All libraries</option>
37 [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
41 <div id="toolbar" class="btn-toolbar">
42 <button type="submit" class="btn btn-default btn-sm" id="newnotice"><i class="fa fa-plus"></i> New notice</button>
43 <input type="hidden" id="op" name="op" />
48 <p>You searched for <b>[% searchfield | html %]</b></p>
50 [% IF ( letter && !independant_branch) %]
51 [% select_for_copy = BLOCK %]
52 <select name="branchcode">
53 [% FOREACH l IN Branches.all() %]
54 <option value="[% l.branchcode %]">Copy to [% l.branchname %]</option>
67 <th class="nosort">Copy notice</th>
68 <th class="nosort">Actions</th>
72 [% FOREACH lette IN letter %]
73 [% can_edit = lette.branchcode || !independant_branch %]
75 <td>[% IF lette.branchname %][% lette.branchname %][% ELSE %](All libraries)[% END %]</td>
76 <td>[% lette.module %]</td>
77 <td>[% lette.code %]</td>
78 <td>[% lette.name %]</td>
80 [% IF !independant_branch || !lette.branchcode %]
81 <form method="post" action="/cgi-bin/koha/tools/letter.pl">
82 <input type="hidden" name="op" value="copy_form" />
83 <input type="hidden" name="oldbranchcode" value="[% lette.branchcode %]" />
84 <input type="hidden" name="module" value="[% lette.module %]" />
85 <input type="hidden" name="code" value="[% lette.code %]" />
86 [% IF independant_branch %]
87 <input type="hidden" name="branchcode" value="[% independant_branch %]" />
91 <button class="btn btn-default btn-xs"><i class="fa fa-clone"></i> Copy</button>
97 <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>
99 [% IF !lette.protected && can_edit %]
100 <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>
108 <div class="dialog message">
109 [% IF ( branchcode ) %]
110 <p>There are no notices for this library.</p>
112 <p>There are no notices.</p>
119 [% IF add_form or copy_form %]
120 <h1>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</h1>
122 <div id="toolbar" class="btn-toolbar">
123 <div class="btn-group">
124 <button class="btn btn-default btn-sm" id="submit_form"><i class="fa fa-save"></i> Save</button>
125 <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
126 <span class="caret"></span>
128 <ul class="dropdown-menu">
129 <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
132 <a class="btn btn-default btn-sm cancel" href="/cgi-bin/koha/tools/letter.pl"><i class="fa fa-remove"></i> Cancel</a>
135 <form id="add_notice" name="Aform" method="post" enctype="multipart/form-data" class="validate">
137 <input type="hidden" name="op" id="op" value="add_validate" />
139 <input type="hidden" name="op" id="op" value="copy_validate" />
142 <input type="hidden" name="checked" value="0" />
144 <input type="hidden" name="add" value="0" />
146 <input type="hidden" name="add" value="1" />
148 <fieldset class="rows">
149 <input type="hidden" name="oldbranchcode" value="[% oldbranchcode %]" />
151 [% IF independant_branch %]
152 <input type="hidden" name="branchcode" value="[% independant_branch %]" />
157 <label for="branch">Library:</label>
158 <select name="branchcode" id="branch" style="width:20em;">
159 <option value="">All libraries</option>
160 [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
163 <span class="label">Library:</span>
164 <input type="hidden" id="branch" name="branchcode" value="[% branchcode %]" />
165 [% IF ( branchcode ) %]
166 [% Branches.GetName( branchcode ) %]
174 <label for="module">Koha module:</label>
175 <input type="hidden" name="oldmodule" value="[% module %]" />
177 <select name="module" id="newmodule">
179 <select name="module" id="module">
181 [% IF ( module == "acquisition" ) %]
182 <option value="acquisition" selected="selected">Acquisition</option>
184 <option value="acquisition" >Acquisition</option>
186 [% IF ( module == "catalogue" ) %]
187 <option value="catalogue" selected="selected">Catalog</option>
189 <option value="catalogue" >Catalog</option>
191 [% IF ( module == "circulation" ) %]
192 <option value="circulation" selected="selected">Circulation</option>
194 <option value="circulation">Circulation</option>
196 [% IF ( module == "orderacquisition" ) %]
197 <option value="orderacquisition" selected="selected">Order acquisition</option>
199 <option value="orderacquisition">Order acquisition</option>
201 [% IF ( module == "claimacquisition" ) %]
202 <option value="claimacquisition" selected="selected">Claim acquisition</option>
204 <option value="claimacquisition">Claim acquisition</option>
206 [% IF ( module == "claimissues" ) %]
207 <option value="claimissues" selected="selected">Claim serial issue</option>
209 <option value="claimissues">Claim serial issue</option>
211 [% IF ( module == "reserves" ) %]
212 <option value="reserves" selected="selected">Holds</option>
214 <option value="reserves">Holds</option>
216 [% IF ( module == "members" ) %]
217 <option value="members" selected="selected">Members</option>
219 <option value="members">Members</option>
221 [% IF ( module == "serial" ) %]
222 <option value="serial" selected="selected">Serials (routing list)</option>
224 <option value="serial">Serials (routing list)</option>
226 [% IF ( module == "suggestions" ) %]
227 <option value="suggestions" selected="selected">Suggestions</option>
229 <option value="suggestions">Suggestions</option>
235 <label for="code" class="required">Code:</label>
236 <input type="text" id="code" name="code" size="20" maxlength="20" value="" required="required"/>
237 <span class="required">Required</span>
239 <span class="label">Code:</span>
240 <input type="hidden" id="code" name="code" value="[% code %]" />
245 <label for="name" class="required">Name:</label>
246 <input type="text" id="name" name="name" size="60" value="[% letter_name %]" required="required" />
247 <span class="required">Required</span>
251 [% IF Koha.Preference('TranslateNotices') %]
252 <div style="clear:both"></div>
255 <li><a href="#lang_default">Default</a></li>
256 [% FOR language IN languages %]
257 [% FOR sublanguage IN language.sublanguages_loop %]
258 [% IF language.plural %]
259 <li><a href="#lang_[% sublanguage.rfc4646_subtag %]">[% sublanguage.native_description %] [% sublanguage.region_description %] ([% sublanguage.rfc4646_subtag %])</a></li>
261 <li><a href="#lang_[% sublanguage.rfc4646_subtag %]">[% sublanguage.native_description %] ([% sublanguage.rfc4646_subtag %])</a></li>
268 [% FOREACH lang IN letters.keys %]
269 <div id="lang_[% lang %]">
270 <div class="transport-types" style="clear:both">
271 [% FOR mtt IN letters.$lang.templates.keys.sort %]
272 [% SET letter = letters.$lang.templates.$mtt %]
274 [% SWITCH letter.message_transport_type %]
286 [% letter.message_transport_type %]
289 [% IF letter.message_transport_type == "sms" and not Koha.Preference("SMSSendDriver") %]
290 <fieldset class="rows mtt" id="[% letter.message_transport_type %]_[% lang %]" disabled="disabled">
291 <div class="dialog message">You should enable the SMSSendDriver preference to use the SMS templates.</div>
292 [% ELSIF letter.message_transport_type == "phone" and not Koha.Preference("TalkingTechItivaPhoneNotification") %]
293 <fieldset class="rows mtt" id="[% letter.message_transport_type %]_[% lang %]" disabled="disabled">
294 <div class="dialog message">You should enable the TalkingTechItivaPhoneNotification preference to use the phone templates.</div>
296 <fieldset class="rows mtt" id="[% letter.message_transport_type %]_[% lang %]">
300 <input type="hidden" name="message_transport_type" value="[% letter.message_transport_type %]" />
301 <input type="hidden" name="lang" value="[% lang %]" />
302 <label for="is_html_[% letter.message_transport_type %]_[% lang %]">HTML message:</label>
303 [% IF letter.is_html %]
304 <input type="checkbox" name="is_html_[% letter.message_transport_type %]" id="is_html_[% letter.message_transport_type %]_[% lang %]" value="1" checked="checked" />
306 <input type="checkbox" name="is_html_[% letter.message_transport_type %]" id="is_html_[% letter.message_transport_type %]_[% lang %]" value="1" />
310 <label for="title_[% letter.message_transport_type %]_[% lang %]">Message subject:</label><input type="text" id="title_[% letter.message_transport_type %]_[% lang %]" name="title" size="60" value="[% letter.title %]" />
313 <label for="SQLfieldname_[% letter.message_transport_type %]_[% lang %]">Message body:</label>
314 [% IF letter.message_transport_type == 'sms' %]
315 <span class="sms_counter" id="sms_counter_[% lang %]">[% IF letter.content && letter.content.length > 0 %][% letter.content.length %][% ELSE %]0[% END %]/160 characters</span>
320 <select name="SQLfieldname" id="SQLfieldname_[% letter.message_transport_type %]_[% lang %]" multiple="multiple" size="9">
321 [% FOREACH SQLfieldname IN SQLfieldnames %]
322 <option value="[% SQLfieldname.value %]">[% SQLfieldname.text %]</option>
327 <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>
329 <td><textarea name="content" data-lang="[% lang %]" class="content_[% letter.message_transport_type %]" id="content_[% letter.message_transport_type %]_[% lang %]" cols="80" rows="15">[% letter.content %]</textarea></td>
337 </div> <!-- / #transport-types -->
339 [% IF Koha.Preference('TranslateNotices') %]
343 [% 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 %]
345 <input type="hidden" id="redirect" name="redirect" value="" />
346 <input type="hidden" name="searchfield" value="[% searchfield %]" />
350 [% IF ( add_validate or copy_validate) %]
352 <form action="[% action %]" method="post">
353 <input type="submit" value="OK" />
357 [% IF ( delete_confirm ) %]
358 <div class="dialog alert">
359 <h3>Delete notice?</h3>
370 <td>[% IF letter.branchcode %][% Branches.GetName( letter.branchcode ) %][% ELSE %](All libraries)[% END %]</td>
371 <td>[% letter.module %]</td>
372 <td>[% letter.code %]</td>
373 <td>[% letter.name %]</td>
376 <form action="[% action %]" method="post">
377 <input type="hidden" name="op" value="delete_confirmed">
378 <input type="hidden" name="branchcode" value="[% letter.branchcode %]" />
379 <input type="hidden" name="code" value="[% letter.code %]" />
380 <input type="hidden" name="module" value="[% letter.module %]" />
381 <button type="submit" class="approve"><i class="fa fa-check"></i> Yes, delete</button>
384 <form action="[% action %]" method="get">
385 <button type="submit" class="deny"><i class="fa fa-times"></i> No, do not delete</button>
390 [% IF ( delete_confirmed ) %]
392 <form action="[% action %]" method="post">
393 <input type="submit" value="OK" />
399 [% UNLESS add_form or copy_form %]
400 <div class="yui-b noprint">
401 [% INCLUDE 'tools-menu.inc' %]
406 [% MACRO jsinclude BLOCK %]
407 <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu_[% KOHA_VERSION %].js"></script>
408 [% INCLUDE 'datatables.inc' %]
409 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat_[% KOHA_VERSION %].js"></script>
410 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.insertatcaret_[% KOHA_VERSION %].js"></script>
411 <script type="text/javascript">
412 $(document).ready(function() {
413 [% IF add_form or copy_form %]
414 $('#toolbar').fixFloat();
416 $("#lettert:has(tbody tr)").dataTable($.extend(true, {}, dataTablesDefaults, {
419 { "bSortable": false, "bSearchable": false, 'aTargets': [ 'nosort' ] }
424 $('#branch').change(function() {
426 $('#selectlibrary').submit();
428 $('#newnotice').click(function() {
429 $('#op').val("add_form");
434 $("#newmodule").on("change",function(){
435 if( $("#branch").val() == ""){
436 var branchcode = "*";
438 var branchcode = $("#branch").val();
440 window.location.href = "/cgi-bin/koha/tools/letter.pl?op=add_form&module=" + $(this).val() + "&branchcode=" + branchcode;
443 $("#submit_form").click( function(event) {
444 event.preventDefault();
445 var at_least_one_exists = 0;
447 $("fieldset.mtt").each( function(){
448 var title = $(this).find('input[name="title"]').val();
449 var content = $(this).find('textarea[name="content"]').val();
451 ( title.length == 0 && content.length > 0 )
452 || ( title.length > 0 && content.length == 0 )
454 var mtt = $(this).find('input[name="message_transport_type"]').val();
455 var msg = _("Please specify title and content for %s");
456 msg = msg.replace( "%s", mtt );
457 at_least_one_exists = 1;
459 return are_valid = false;
460 } else if ( title.length > 0 && content.length > 0 ) {
461 at_least_one_exists = 1;
464 if ( ! at_least_one_exists ) {
465 alert( _("Please fill at least one template.") );
472 // Test if code already exists in DB
473 var new_lettercode = $("#code").val();
474 var new_branchcode = $("#branch").val();
475 [% IF ( add_form and code ) # IF edit %]
476 if ( new_lettercode != '[% code %]' ) {
479 data: { code: new_lettercode, branchcode: new_branchcode },
481 url: '/cgi-bin/koha/svc/letters/',
482 success: function (data) {
483 if ( data.letters.length > 0 ) {
484 if( new_branchcode == '' ) {
485 alert( _("A default letter with the code '%s' already exists.").format(new_lettercode) );
487 alert( _("A letter with the code '%s' already exists for '%s'.").format(new_lettercode, new_branchcode) );
491 $("#add_notice").submit();
495 [% IF ( add_form and code ) %]
497 $("#add_notice").submit();
503 $(".content_sms").on("keyup", function(){
504 var length = $(this).val().length;
505 var sms_counter = ("#sms_counter_" + $(this).data('lang'));
506 $(sms_counter).html(length + "/" + sms_limit + _(" characters"));
507 if ( length > sms_limit ) {
508 $(sms_counter).css("color", "red");
510 $(sms_counter).css("color", "black");
513 $( ".transport-types" ).accordion({ collapsible: true, active:false, animate: 200 });
514 $(".insert").on("click",function(){
515 var containerid = $(this).data("containerid");
516 insertValueQuery( containerid );
521 $("#saveandcontinue").on("click",function(e){
523 $("#redirect").val("just_save");
524 $("#submit_form").click();
528 [% IF add_form or copy_form %]
535 function isNotNull(f,noalert) {
536 if (f.value.length ==0) {
542 function isNum(v,maybenull) {
543 var n = new Number(v.value);
547 if (maybenull==0 && v.value==''){
552 function insertValueQuery(containerid) {
553 var fieldset = $("#" + containerid);
554 var myQuery = $(fieldset).find('textarea[name="content"]');
555 var myListBox = $(fieldset).find('select[name="SQLfieldname"]');
557 if($(myListBox).find('option').length > 0) {
558 $(myListBox).find('option').each( function (){
559 if ( $(this).attr('selected') && $(this).val().length > 0 ) {
560 $(myQuery).insertAtCaret("<<" + $(this).val() + ">>");
569 [% INCLUDE 'intranet-bottom.inc' %]