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