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