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