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