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