Merge remote-tracking branch 'origin/new/bug_7016'
[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 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
5         <script type="text/javascript">
6         //<![CDATA[
7 $(document).ready(function() {
8         $("#lettert:has(tbody tr)").tablesorter({
9                 widgets : ['zebra'],
10                 sortList: [[0,0]],
11                 headers: { 3: {sorter:false},4: { sorter: false }}
12         }); 
13
14     $('#branch').change(function() {
15             $('#op').val("");
16             $('#selectlibrary').submit();
17     });
18     $('#newnotice').click(function() {
19             $('#op').val("add_form");
20             return true;
21     });
22 }); 
23 [% IF ( add_form ) %]
24         
25     function cancel(f) {
26         $('#op').val("");
27         f.method = "get";
28         f.submit();
29     }
30
31                 function isNotNull(f,noalert) {
32                         if (f.value.length ==0) {
33         return false;
34                         }
35                         return true;
36                 }
37         
38                 function toUC(f) {
39                         var x=f.value.toUpperCase();
40                         f.value=x;
41                         return true;
42                 }
43         
44                 function isNum(v,maybenull) {
45                 var n = new Number(v.value);
46                 if (isNaN(n)) {
47                         return false;
48                         }
49                 if (maybenull==0 && v.value=='') {
50                         return false;
51                 }
52                 return true;
53                 }
54         
55                 function isDate(f) {
56                         var t = Date.parse(f.value);
57                         if (isNaN(t)) {
58                                 return false;
59                         }
60                 }
61         
62                 function Check(f) {
63                         var ok=1;
64                         var _alertString="";
65                         var alertString2;
66 /*                      if (!(isNotNull(window.document.Aform.code))) {
67                                 _alertString += "\n- " + _("Code missing");
68                         }*/
69 /*                      if (!(isNotNull(window.document.Aform.name))) {
70                                 _alertString += "\n- " + _("Name missing");
71                         }*/
72                         if (_alertString.length==0) {
73                                 document.Aform.submit();
74                         } else {
75                                 alertString2  = _("Form not submitted because of the following problem(s)");
76                                 alertString2 += "\n------------------------------------------------------------------------------------\n";
77                                 alertString2 += _alertString;
78                                 alert(alertString2);
79                         }
80                 }
81                 // GPL code coming from PhpMyAdmin
82                 function insertValueQuery() {
83                         var myQuery = document.Aform.content;
84                         var myListBox = document.Aform.SQLfieldname;
85                 
86                         if(myListBox.options.length > 0) {
87                                 var chaineAj = "";
88                                 var NbSelect = 0;
89                                 for(var i=0; i<myListBox.options.length; i++) {
90                                         if (myListBox.options[i].selected){
91                                                 NbSelect++;
92                                                 if (NbSelect > 1)
93                                                         chaineAj += ", ";
94                                                 chaineAj += myListBox.options[i].value;
95                                         }
96                                 }
97                 
98                                 //IE support
99                                 if (document.selection) {
100                                         myQuery.focus();
101                                         sel = document.selection.createRange();
102                                         sel.text = chaineAj;
103                                         document.Aform.insert.focus();
104                                 }
105                                 //MOZILLA/NETSCAPE support
106                                 else if (document.Aform.content.selectionStart || document.Aform.content.selectionStart == "0") {
107                                         var startPos = document.Aform.content.selectionStart;
108                                         var endPos = document.Aform.content.selectionEnd;
109                                         var chaineSql = document.Aform.content.value;
110                                         myQuery.value = chaineSql.substring(0, startPos) +'<<'+ chaineAj+'>>' + chaineSql.substring(endPos, chaineSql.length);
111                                 } else {
112                                         myQuery.value += chaineAj;
113                                 }
114                         }
115                 }
116         [% END %]
117                 //]]>
118                 </script>
119 </head>
120 <body id="tools_letter" class="tools">
121 [% INCLUDE 'header.inc' %]
122 [% INCLUDE 'letters-search.inc' %]
123
124 <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>
125
126 [% IF ( add_form ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
127    
128    <div id="bd">
129         <div id="yui-main">
130         <div class="yui-b">
131
132 [% IF ( no_op_set ) %]
133     <form method="get" action="/cgi-bin/koha/tools/letter.pl" id="selectlibrary">
134       <input type="hidden" name="searchfield" value="[% searchfield %]" />
135     [% UNLESS independant_branch %]
136       <p>
137         Select a library :
138             <select name="branchcode" id="branch" style="width:20em;">
139                 <option value="">All libraries</option>
140             [% FOREACH branchloo IN branchloop %]
141                 [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
142             [% END %]
143             </select>
144       </p>
145     [% END %]
146       <p>
147               <input type="submit" id="newnotice" value="New Notice" />
148         <input type="hidden" id="op" name="op" />
149       </p>
150     </form>
151
152                 [% IF ( search ) %]
153         <p>You searched for <b>[% searchfield %]</b></p>
154                 [% END %]
155                 [% IF ( letter && !independant_branch) %]
156             [% select_for_copy = BLOCK %]
157             <select name="branchcode">
158                 [% FOREACH branchloo IN branchloop %]
159                 <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
160                 [% END %]
161             </select>
162             [% END %]
163         [% END %]
164         <table id="lettert">
165                 <thead><tr>
166                         <th>Library</th>
167                         <th>Module</th>
168                         <th>Code</th>
169                         <th>Name</th>
170                         <th>&nbsp;</th>
171                         <th>&nbsp;</th>
172                         <th>&nbsp;</th>
173                 </tr></thead>
174                 <tbody>
175     [% FOREACH lette IN letter %]
176         [% can_edit = lette.branchcode || !independant_branch %]
177         [% UNLESS ( loop.odd ) %]
178                         <tr class="highlight">
179         [% ELSE %]
180                         <tr>
181         [% END %]
182                                 <td>[% lette.branchname || "(All libraries)" %]</td>
183                                 <td>[% lette.module %]</td>
184                                 <td>[% lette.code %]</td>
185                                 <td>[% lette.name %]</td>
186                                 <td>
187         [% IF can_edit %]
188                                         <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>
189         [% END %]
190                                 </td>
191                                 <td>
192         [% IF !independant_branch || !lette.branchcode %]
193                     <form method="post" action="/cgi-bin/koha/tools/letter.pl">
194                         <input type="hidden" name="op" value="copy" />
195                                         <input type="hidden" name="oldbranchcode" value="[% lette.branchcode %]" />
196                         <input type="hidden" name="module" value="[% lette.module %]" />
197                         <input type="hidden" name="code" value="[% lette.code %]" />
198             [% IF independant_branch %]
199                         <input type="hidden" name="branchcode" value="[% independant_branch %]" />
200             [% ELSE %]
201                         [% select_for_copy %]
202             [% END %]
203                         <input type="submit" value="Copy" />
204                     </form>
205         [% END %]
206                                 </td>
207                                 <td>
208         [% IF !lette.protected && can_edit %]
209                                         <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>
210         [% END %]
211                                 </td>
212                         </tr>
213     [% END %]
214         </tbody>
215                 </table>
216 [% END %]
217
218         
219 [% IF ( add_form ) %]
220         
221                 <form action="?" name="Aform" method="post">
222                 <input type="hidden" name="op" id="op" value="add_validate" />
223                 <input type="hidden" name="checked" value="0" />
224                 [% IF ( modify ) %]
225                 <input type="hidden" name="add" value="0" />
226                 [% ELSE %]
227                 <input type="hidden" name="add" value="1" />
228                 [% END %]
229                 <fieldset class="rows">
230                 <legend>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</legend>
231                                 <input type="hidden" name="oldbranchcode" value="[% branchcode %]" />
232             [% IF independant_branch %]
233                 <input type="hidden" name="branchcode" value="[% independant_branch %]" />
234             [% ELSE %]
235                 <ol>
236                         <li>
237                                 <label for="branch">Library:</label>
238                 <select name="branchcode" id="branch" style="width:20em;">
239                     <option value="">All libraries</option>
240                 [% FOREACH branchloo IN branchloop %]
241                     [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
242                 [% END %]
243                 </select>
244                         </li>
245             [% END %]
246                         <li>
247                                 <label for="module">Koha module:</label>
248                                 <input type="hidden" name="oldmodule" value="[% module %]" />
249                 [% 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 %]
250                                     [% IF ( catalogue ) %]
251                                     <option value="catalogue" selected="selected">Catalog</option>
252                                     [% ELSE %]
253                                     <option value="catalogue" >Catalog</option>
254                                     [% END %]
255                                     [% IF ( circulation ) %]
256                                     <option value="circulation" selected="selected">Circulation</option>
257                                     [% ELSE %]
258                                     <option value="circulation">Circulation</option>
259                                     [% END %]
260                                     [% IF ( claimacquisition ) %]
261                                     <option value="claimacquisition" selected="selected">Claim acquisition</option>
262                                     [% ELSE %]
263                                     <option value="claimacquisition">Claim acquisition</option>
264                                     [% END %]
265                                     [% IF ( claimissues ) %]
266                                     <option value="claimissues" selected="selected">Claim serial issue</option>
267                                     [% ELSE %]
268                                     <option value="claimissues">Claim serial issue</option>
269                                     [% END %]
270                                     [% IF ( reserves ) %]
271                                     <option value="reserves" selected="selected">Holds</option>
272                                     [% ELSE %]
273                                     <option value="reserves">Holds</option>
274                                     [% END %]
275                                     [% IF ( members ) %]
276                                     <option value="members" selected="selected">Members</option>
277                                     [% ELSE %]
278                                     <option value="members">Members</option>
279                                     [% END %]
280                                     [% IF ( serial ) %]
281                                     <option value="serial" selected="selected">Serials (routing list)</option>
282                                     [% ELSE %]
283                                     <option value="serial">Serials (routing list)</option>
284                                     [% END %]
285                                     [% IF ( suggestions ) %]
286                                     <option value="suggestions" selected="selected">Suggestions</option>
287                                     [% ELSE %]
288                                     <option value="suggestions">Suggestions</option>
289                                     [% END %]
290                                 </select>
291                         </li>
292                         <li>
293                                 <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 %]
294                         </li>
295                 <li>
296                         <label for="name">Name:</label><input type="text" id="name" name="name" size="60" value="[% name %]" />
297                 </li>
298                 <li>
299             <label for="is_html">HTML message:</label>
300       [% IF is_html %]
301       <input type="checkbox" id="is_html" name="is_html" value="1" checked />
302       [% ELSE %]
303       <input type="checkbox" id="is_html" name="is_html" value="1" />
304       [% END %]
305                 </li>
306                 <li>
307             <label for="title">Message subject:</label><input type="text" id="title" name="title" size="60" value="[% title %]" />
308                 </li>
309                 <li>
310             <label for="SQLfieldname">Message body:</label>
311                 </li>
312                 <li>
313                 <table>
314                 <tr><td><select name="SQLfieldname" id="SQLfieldname" size="9">
315                         [% FOREACH SQLfieldnam IN SQLfieldname %]
316                                 <option value="[% SQLfieldnam.value %]">[% SQLfieldnam.text %]</option>
317                         [% END %]
318                 </select></td><td><input type="button" name="insert" value="&gt;&gt;" onclick="insertValueQuery()" title="Insert" /></td><td><textarea name="content" cols="80" rows="15">[% content %]</textarea></td></tr></table>
319
320                 </li>
321                 </ol>
322                 </fieldset>
323                 <fieldset class="action"><input type="button" value="Submit" onclick="Check(this.form)" class="button" /> <a class="cancel" href="/cgi-bin/koha/tools/letter.pl">Cancel</a></fieldset>
324       <input type="hidden" name="searchfield" value="[% searchfield %]" />
325                 </form>
326 [% END %]
327         
328 [% IF ( add_validate ) %]
329         Data recorded
330         <form action="[% action %]" method="post">
331         <input type="submit" value="OK" />
332         </form>
333 [% END %]
334         
335 [% IF ( delete_confirm ) %]
336     <div class="dialog alert"><h3>Delete notice?</h3>
337         <table>
338         <thead>
339                 <tr>
340                         <th>Library</th>
341                         <th>Module</th>
342                         <th>Code</th>
343                         <th>Name</th>
344                 </tr>
345         </thead>
346                 <tr>
347                         <td>[% branchname %]</td>
348                         <td>[% module %]</td>
349             <td>[% code %]</td>
350                         <td>[% name %]</td>
351                 </tr>
352         </table>
353                 <form action="[% action %]" method="post">
354                 <input type="hidden" name="op" value="delete_confirmed">
355                 <input type="hidden" name="branchcode" value="[% branchcode %]" />
356                 <input type="hidden" name="code" value="[% code %]" />
357                 <input type="hidden" name="module" value="[% module %]" />
358                 <input type="submit" value="Yes, delete" class="approve" />
359                                 </form>
360
361                                 <form action="[% action %]" method="get">
362                     <input type="submit" value="No, do not delete" class="deny" />
363                                 </form>
364                 </div>
365
366 [% END %]
367         
368 [% IF ( delete_confirmed ) %]
369         Data deleted
370         <form action="[% action %]" method="post">
371         <input type="submit" value="OK" />
372         </form>
373 [% END %]
374
375 </div>
376 </div>
377 [% UNLESS ( add_form ) %]
378     <div class="yui-b noprint">
379         [% INCLUDE 'tools-menu.inc' %]
380     </div>
381 [% END %]
382 </div>
383 [% INCLUDE 'intranet-bottom.inc' %]