Bug 12660:Correct mispelling of accomodate in comments
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / letter.tt
1 [% USE Koha %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Tools &rsaquo; Notices[% IF ( add_form or copy_form ) %][% IF ( modify ) %] &rsaquo; Modify notice[% ELSE %] &rsaquo; Add notice[% END %][% END %][% IF ( add_validate or copy_validate) %] &rsaquo; Notice added[% END %][% IF ( delete_confirm ) %] &rsaquo; Confirm deletion[% END %]</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6 [% INCLUDE 'datatables.inc' %]
7 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.insertatcaret.js"></script>
8 <script type="text/javascript">
9 //<![CDATA[
10 $(document).ready(function() {
11     $("#lettert:has(tbody tr)").dataTable($.extend(true, {}, dataTablesDefaults, {
12         "sDom": 't',
13         "aoColumnDefs": [
14             { "aTargets": [ -1,-2, -3 ], "bSortable": false, "bSearchable": false }
15         ],
16         "bPaginate": false
17     }));
18     [% IF no_op_set %]
19       $('#branch').change(function() {
20             $('#op').val("");
21             $('#selectlibrary').submit();
22       });
23       $('#newnotice').click(function() {
24             $('#op').val("add_form");
25             return true;
26       });
27     [% END %]
28
29     $("#submit_form").click( function(event) {
30         event.preventDefault();
31         var at_least_one_exists = 0;
32         $("fieldset.mtt").each( function(){
33             var title = $(this).find('input[name="title"]').val();
34             var content = $(this).find('textarea[name="content"]').val();
35             if (
36                     ( title.length == 0 && content.length > 0 )
37                  || ( title.length > 0 && content.length == 0 )
38             ) {
39                 var mtt = $(this).find('input[name="message_transport_type"]').val();
40                 var msg = _("Please specify title and content for %s");
41                 msg = msg.replace( "%s", mtt );
42                 at_least_one_exists = 1;
43                 alert(msg)
44                 return false;
45             } else if ( title.length > 0 && content.length > 0 ) {
46                 at_least_one_exists = 1;
47             }
48         } );
49         if ( ! at_least_one_exists ) {
50             alert( _("Please fill at least one template.") );
51             return false;
52         }
53
54         // Test if code already exists in DB
55         var new_lettercode = $("#code").val();
56         [% IF copy_form %]
57           if ( new_lettercode == '[% code %]' ) {
58             alert( _("Please change the code.") );
59             return false;
60           }
61         [% END %]
62
63         [% IF ( add_form and code ) # IF edit %]
64           if ( new_lettercode != '[% code %]' ) {
65         [% END %]
66           $.ajax({
67             data: { code: new_lettercode },
68             type: 'GET',
69             url: '/cgi-bin/koha/svc/letters/',
70             success: function (data) {
71               if ( data.letters.length > 0 ) {
72                 alert( _("This letter code is already used for another letter.") );
73                 return false;
74               } else {
75                 $("#add_notice").submit();
76               }
77             },
78           });
79         [% IF ( add_form and code ) %]
80           } else {
81             $("#add_notice").submit();
82           }
83         [% END %]
84     });
85
86     var sms_limit = 160;
87     $("#content_sms").on("keyup", function(){
88         var length = $(this).val().length;
89         $("#sms_counter").html(length + "/" + sms_limit + _(" characters"));
90         if ( length  > sms_limit ) {
91             $("#sms_counter").css("color", "red");
92         } else {
93             $("#sms_counter").css("color", "black");
94         }
95     });
96     $( "#transport-types" ).accordion({ collapsible: true, active:false, animate: 200 });
97 }); 
98 [% IF add_form or copy_form %]
99         
100     function cancel(f) {
101         $('#op').val("");
102         f.method = "get";
103         f.submit();
104     }
105
106                 function isNotNull(f,noalert) {
107                         if (f.value.length ==0) {
108         return false;
109                         }
110                         return true;
111                 }
112
113                 function isNum(v,maybenull) {
114                 var n = new Number(v.value);
115                 if (isNaN(n)) {
116                         return false;
117                         }
118                 if (maybenull==0 && v.value=='') {
119                         return false;
120                 }
121                 return true;
122                 }
123         function insertValueQuery(mtt_id) {
124             var fieldset = $("#" + mtt_id);
125             var myQuery = $(fieldset).find('textarea[name="content"]');
126             var myListBox = $(fieldset).find('select[name="SQLfieldname"]');
127
128             if($(myListBox).find('option').length > 0) {
129                 var chaineAj = "";
130                 var NbSelect = 0;
131                 $(myListBox).find('option').each( function (){
132                     if ( $(this).attr('selected') ) {
133                         NbSelect++;
134                         if (NbSelect > 1)
135                             chaineAj += ", ";
136                         chaineAj += $(this).val();
137                     }
138                 } );
139                 $(myQuery).insertAtCaret("<<" + chaineAj + ">>");
140             }
141         }
142         [% END %]
143                 //]]>
144                 </script>
145 </head>
146 <body id="tools_letter" class="tools">
147 [% INCLUDE 'header.inc' %]
148 [% INCLUDE 'letters-search.inc' %]
149
150 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( add_form or copy_form) %][% IF ( modify ) %]<a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Modify notice[% ELSE %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Add notice[% END %][% ELSE %][% IF ( add_validate or copy_validate) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Notice added[% ELSE %][% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Confirm deletion[% ELSE %]Notices &amp; Slips[% END %][% END %][% END %]</div>
151
152 [% IF add_form or copy_form %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
153    
154    <div id="bd">
155         <div id="yui-main">
156         <div class="yui-b">
157
158 [% IF ( no_op_set ) %]
159     <h1>Notices and Slips</h1>
160     <form method="get" action="/cgi-bin/koha/tools/letter.pl" id="selectlibrary">
161       <input type="hidden" name="searchfield" value="[% searchfield %]" />
162     [% UNLESS independant_branch %]
163       <p>
164         Select a library :
165             <select name="branchcode" id="branch" style="width:20em;">
166                 <option value="">All libraries</option>
167             [% FOREACH branchloo IN branchloop %]
168                 [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
169             [% END %]
170             </select>
171       </p>
172     [% END %]
173       <div id="toolbar" class="btn-toolbar">
174           <button type="submit" class="btn btn-small" id="newnotice"><i class="icon-plus"></i> New notice</button>
175         <input type="hidden" id="op" name="op" />
176       </div>
177     </form>
178
179                 [% IF ( search ) %]
180         <p>You searched for <b>[% searchfield %]</b></p>
181                 [% END %]
182                 [% IF ( letter && !independant_branch) %]
183             [% select_for_copy = BLOCK %]
184             <select name="branchcode">
185                 [% FOREACH branchloo IN branchloop %]
186                 <option value="[% branchloo.value %]">Copy to [% branchloo.branchname %]</option>
187                 [% END %]
188             </select>
189             [% END %]
190         [% END %]
191         [% IF letter %]
192           <table id="lettert">
193             <thead>
194               <tr>
195                 <th>Library</th>
196                 <th>Module</th>
197                 <th>Code</th>
198                 <th>Name</th>
199                 <th>Copy notice</th>
200                 <th>&nbsp;</th>
201                 <th>&nbsp;</th>
202               </tr>
203             </thead>
204             <tbody>
205               [% FOREACH lette IN letter %]
206                 [% can_edit = lette.branchcode || !independant_branch %]
207                 <tr>
208                   <td>[% IF lette.branchname %][% lette.branchname %][% ELSE %](All libraries)[% END %]</td>
209                   <td>[% lette.module %]</td>
210                   <td>[% lette.code %]</td>
211                   <td>[% lette.name %]</td>
212                   <td style="white-space: nowrap">
213                     [% IF !independant_branch || !lette.branchcode %]
214                       <form method="post" action="/cgi-bin/koha/tools/letter.pl">
215                         <input type="hidden" name="op" value="copy_form" />
216                         <input type="hidden" name="oldbranchcode" value="[% lette.branchcode %]" />
217                         <input type="hidden" name="module" value="[% lette.module %]" />
218                         <input type="hidden" name="code" value="[% lette.code %]" />
219                         [% IF independant_branch %]
220                           <input type="hidden" name="branchcode" value="[% independant_branch %]" />
221                         [% ELSE %]
222                           [% select_for_copy %]
223                         [% END %]
224                         <input type="submit" value="Copy" />
225                       </form>
226                     [% END %]
227                   </td>
228                   <td>
229                     [% IF can_edit %]
230                       <a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;branchcode=[% lette.branchcode %]&amp;module=[% lette.module %]&amp;code=[% lette.code %]">Edit</a>
231                     [% END %]
232                   </td>
233                   <td>
234                     [% IF !lette.protected && can_edit %]
235                       <a href="/cgi-bin/koha/tools/letter.pl?op=delete_confirm&amp;branchcode=[%lette.branchcode %]&amp;module=[% lette.module %]&amp;code=[% lette.code %]">Delete</a>
236                     [% END %]
237                   </td>
238                 </tr>
239               [% END %]
240             </tbody>
241           </table>
242         [% ELSE %]
243           <div class="dialog message">
244           [% IF ( branchcode ) %]
245              <p>There are no notices for this library.</p>
246           [% ELSE %]
247               <p>There are no notices.</p>
248           [% END %]
249           </div>
250         [% END %]
251 [% END %]
252
253         
254 [% IF add_form or copy_form %]
255 <h1>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</h1>
256         <form id="add_notice" name="Aform" method="post" enctype="multipart/form-data" class="validate">
257         [% IF add_form %]
258           <input type="hidden" name="op" id="op" value="add_validate" />
259         [% ELSE %]
260           <input type="hidden" name="op" id="op" value="copy_validate" />
261         [% END %]
262
263                 <input type="hidden" name="checked" value="0" />
264                 [% IF ( modify ) %]
265                 <input type="hidden" name="add" value="0" />
266                 [% ELSE %]
267                 <input type="hidden" name="add" value="1" />
268                 [% END %]
269                 <fieldset class="rows">
270             <input type="hidden" name="oldbranchcode" value="[% oldbranchcode %]" />
271             [% IF independant_branch %]
272                 <input type="hidden" name="branchcode" value="[% independant_branch %]" />
273             [% ELSE %]
274                 <ol>
275                         <li>
276                                 <label for="branch">Library:</label>
277                 <select name="branchcode" id="branch" style="width:20em;">
278                     <option value="">All libraries</option>
279                 [% FOREACH branchloo IN branchloop %]
280                     [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
281                 [% END %]
282                 </select>
283                         </li>
284             [% END %]
285                         <li>
286                                 <label for="module">Koha module:</label>
287                                 <input type="hidden" name="oldmodule" value="[% module %]" />
288                 [% IF adding  %]
289                   <select name="module" id="module" onchange="javascript:window.location.href = unescape(window.location.pathname)+'?op=add_form&amp;module='+this.value+'&amp;content='+window.document.forms['Aform'].elements['content'].value;">
290                 [% ELSE %]
291                   <select name="module" id="module">
292                 [% END %]
293                                     [% IF ( module == "catalogue" ) %]
294                                       <option value="catalogue" selected="selected">Catalog</option>
295                                     [% ELSE %]
296                                       <option value="catalogue" >Catalog</option>
297                                     [% END %]
298                                     [% IF ( module == "circulation" ) %]
299                                       <option value="circulation" selected="selected">Circulation</option>
300                                     [% ELSE %]
301                                       <option value="circulation">Circulation</option>
302                                     [% END %]
303                                     [% IF ( module == "claimacquisition" ) %]
304                                       <option value="claimacquisition" selected="selected">Claim acquisition</option>
305                                     [% ELSE %]
306                                       <option value="claimacquisition">Claim acquisition</option>
307                                     [% END %]
308                                     [% IF ( module == "claimissues" ) %]
309                                       <option value="claimissues" selected="selected">Claim serial issue</option>
310                                     [% ELSE %]
311                                       <option value="claimissues">Claim serial issue</option>
312                                     [% END %]
313                                     [% IF ( module == "reserves" ) %]
314                                       <option value="reserves" selected="selected">Holds</option>
315                                     [% ELSE %]
316                                       <option value="reserves">Holds</option>
317                                     [% END %]
318                                     [% IF ( module == "members" ) %]
319                                       <option value="members" selected="selected">Members</option>
320                                     [% ELSE %]
321                                       <option value="members">Members</option>
322                                     [% END %]
323                                     [% IF ( module == "serial" ) %]
324                                       <option value="serial" selected="selected">Serials (routing list)</option>
325                                     [% ELSE %]
326                                       <option value="serial">Serials (routing list)</option>
327                                     [% END %]
328                                     [% IF ( module == "suggestions" ) %]
329                                       <option value="suggestions" selected="selected">Suggestions</option>
330                                     [% ELSE %]
331                                       <option value="suggestions">Suggestions</option>
332                                     [% END %]
333                 </select>
334             </li>
335             <li>
336               <label for="code" class="required">Code:</label>
337               <input type="text" id="code" name="code" size="20" maxlength="20" value="[% code %]" required="required"/>
338               <span class="required">Required</span>
339               [% IF copying %]
340                 You must change this code to reflect the copy.
341               [% END %]
342               <input type="hidden" name="oldcode" value="[% oldcode %]" />
343             </li>
344             <li>
345               <label for="name" class="required">Name:</label>
346               <input type="text" id="name" name="name" size="60" value="[% letter_name %]" required="required" />
347               <span class="required">Required</span>
348             </li>
349         </ol>
350     </fieldset>
351         <div id="transport-types" style="clear:both">
352         [% FOREACH letter IN letters %]
353             <h3>
354                 [% SWITCH letter.message_transport_type %]
355                 [% CASE 'email' %]
356                   Email
357                 [% CASE 'print' %]
358                   Print
359                 [% CASE 'sms' %]
360                   SMS
361                 [% CASE 'feed' %]
362                   Feed
363                 [% CASE 'phone' %]
364                   Phone
365                 [% CASE %]
366                   [% letter.message_transport_type %]
367                 [% END %]
368             </h3>
369             [% IF letter.message_transport_type == "sms" and not Koha.Preference("SMSSendDriver") %]
370               <fieldset class="rows mtt" id="[% letter.message_transport_type %]" disabled="disabled">
371                 <div class="dialog message">You should enable the SMSSendDriver preference to use the SMS templates.</div>
372             [% ELSIF letter.message_transport_type == "phone" and not Koha.Preference("TalkingTechItivaPhoneNotification") %]
373               <fieldset class="rows mtt" id="[% letter.message_transport_type %]" disabled="disabled">
374                 <div class="dialog message">You should enable the TalkingTechItivaPhoneNotification preference to use the phone templates.</div>
375             [% ELSE %]
376               <fieldset class="rows mtt" id="[% letter.message_transport_type %]">
377             [% END %]
378               <ol>
379                 <li>
380                   <input type="hidden" name="message_transport_type" value="[% letter.message_transport_type %]" />
381                   <label for="is_html_[% letter.message_transport_type %]">HTML message:</label>
382                   [% IF letter.is_html %]
383                     <input type="checkbox" name="is_html_[% letter.message_transport_type %]" id="is_html_[% letter.message_transport_type %]" value="1" checked="checked" />
384                   [% ELSE %]
385                     <input type="checkbox" name="is_html_[% letter.message_transport_type %]" id="is_html_[% letter.message_transport_type %]" value="1" />
386                   [% END %]
387                 </li>
388                 <li>
389                   <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 %]" />
390                 </li>
391                 <li>
392                   <label for="SQLfieldname_[% letter.message_transport_type %]">Message body:</label>
393                   [% IF letter.message_transport_type == 'sms' %]
394                     <span id="sms_counter">[% IF letter.content.length > 0 %][% letter.content.length %][% ELSE %]0[% END %]/160 characters</span>
395                   [% END %]
396                   <table>
397                     <tr>
398                       <td>
399                         <select name="SQLfieldname" id="SQLfieldname_[% letter.message_transport_type %]" multiple="multiple" size="9">
400                           [% FOREACH SQLfieldnam IN SQLfieldname %]
401                             <option value="[% SQLfieldnam.value %]">[% SQLfieldnam.text %]</option>
402                           [% END %]
403                         </select>
404                       </td>
405                       <td><input type="button" name="insert" value="&gt;&gt;" onclick="insertValueQuery('[% letter.message_transport_type %]')" title="Insert" /></td>
406                       <td><textarea name="content" id="content_[% letter.message_transport_type %]" cols="80" rows="15">[% letter.content %]</textarea></td>
407                     </tr>
408                   </table>
409                 </li>
410               </ol>
411             </fieldset>
412         [% END %]
413         </div> <!-- / #transport-types -->
414
415         [% 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 %]
416         <fieldset class="action"><input type="submit" id="submit_form" value="Submit" class="button" /> <a class="cancel" href="/cgi-bin/koha/tools/letter.pl">Cancel</a></fieldset>
417       <input type="hidden" name="searchfield" value="[% searchfield %]" />
418     </form>
419 [% END %]
420
421 [% IF ( add_validate or copy_validate) %]
422         Data recorded
423         <form action="[% action %]" method="post">
424         <input type="submit" value="OK" />
425         </form>
426 [% END %]
427         
428 [% IF ( delete_confirm ) %]
429     <div class="dialog alert"><h3>Delete notice?</h3>
430         <table>
431         <thead>
432                 <tr>
433                         <th>Library</th>
434                         <th>Module</th>
435                         <th>Code</th>
436                         <th>Name</th>
437                 </tr>
438         </thead>
439                 <tr>
440                         <td>[% branchname %]</td>
441                         <td>[% module %]</td>
442             <td>[% code %]</td>
443                         <td>[% name %]</td>
444                 </tr>
445         </table>
446                 <form action="[% action %]" method="post">
447                 <input type="hidden" name="op" value="delete_confirmed">
448                 <input type="hidden" name="branchcode" value="[% branchcode %]" />
449                 <input type="hidden" name="code" value="[% code %]" />
450                 <input type="hidden" name="module" value="[% module %]" />
451         <input type="hidden" name="message_transport_type" value="*" />
452                 <input type="submit" value="Yes, delete" class="approve" />
453                                 </form>
454
455                                 <form action="[% action %]" method="get">
456                     <input type="submit" value="No, do not delete" class="deny" />
457                                 </form>
458                 </div>
459
460 [% END %]
461         
462 [% IF ( delete_confirmed ) %]
463         Data deleted
464         <form action="[% action %]" method="post">
465         <input type="submit" value="OK" />
466         </form>
467 [% END %]
468
469 </div>
470 </div>
471 [% UNLESS add_form or copy_form %]
472     <div class="yui-b noprint">
473         [% INCLUDE 'tools-menu.inc' %]
474     </div>
475 [% END %]
476 </div>
477 [% INCLUDE 'intranet-bottom.inc' %]