Bug 10429: improve display of library and library filter on serials claim page
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / claims.tt
1 [% USE Branches %]
2
3 [% INCLUDE 'doc-head-open.inc' %]
4     <title>Koha &rsaquo; Serials &rsaquo; Claims</title>
5     [% INCLUDE 'doc-head-close.inc' %]
6 [% INCLUDE 'calendar.inc' %]
7 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" />
8 <script type="text/javascript" src="[% interface %]/[% theme %]/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
9 [% INCLUDE 'datatables-strings.inc' %]
10 <script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
11 <script type="text/javascript">
12 //<![CDATA[
13     [% IF (dateformat == 'metric') %]dt_add_type_uk_date();[% END %]
14          $(document).ready(function() {
15         [% UNLESS ( preview ) %]
16          var sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
17             "sDom": 't',
18             "aoColumnDefs": [
19                 { "aTargets": [ 0,1 ], "bSortable": false, "bSearchable": false }
20             ],
21             "bPaginate": false
22         }));
23         [% END %]
24             $('#supplierid').change(function() {
25             $('#claims').submit();
26             });
27
28             // Checkboxes : Select All / None
29             $("span.checkall").html("<input type=\"checkbox\" name=\"CheckAll\"> "+_("Check All")+"</input>");
30
31         $("#CheckAll").click(function() {
32             $("#claimst tr:visible :checkbox").attr('checked', $("#CheckAll").is(':checked'));
33         });
34
35             // Generates a dynamic link for exporting the selection's data as CSV
36             $("#ExportSelected").click(function() {
37                // We need to use "input[name=serialid]:checked" instead of "input:checked". Otherwise, the "check all" box will pass the value of "on" as a serialid, which produces a SQL error.
38              var selected = $("input[name=serialid]:checked");
39
40         if (selected.length == 0) {
41             alert(_("Please select at least one item to export."));
42             return false;
43         }
44
45         // Building the url from currently checked boxes
46         var url = '/cgi-bin/koha/serials/lateissues-export.pl?supplierid=&amp;op=claims';
47         for (var i = 0; i < selected.length; i++) {
48             url += '&amp;serialid=' + selected[i].value;
49         }
50         url += '&amp;csv_profile=' + $("#csv_profile_for_export option:selected").val();
51         // And redirecting to the CSV page
52         location.href = url;
53         return false;
54         });
55
56         $("#titlefilter").keyup( function () {
57             sTable.fnFilter( this.value, 3 ); // 3 is position of title column
58         } );
59
60         $("#branchfilter").keyup(function() {
61             sTable.fnFilter( this.value, 2 ); // 2 is the position of the author column
62             });
63          });
64
65         // Checks if the form can be sent (at least one checkbox must be checked)
66         function checkForm() {
67             if ($("input:checked").length == 0) {
68                 alert(_("Please select at least one item."));
69                 return false;
70             }
71         }
72
73     // Filter by status
74     function filterByStatus() {
75         selectedStatus = $("#statusfilter").val();
76         if (selectedStatus == "all") {
77             clearFilters();
78         } else {
79             $("table#claimst tbody tr").hide();
80             $("table#claimst tbody tr").each( function() {
81                 if ( $(this).find("span.status-" + selectedStatus).size() > 0 ) {
82                     $(this).show();
83                 }
84             });
85         }
86     }
87
88     // Filter by branch
89     function filterByBranch() {
90         selectedBranch = $("#branchfilter").val();
91         if (selectedBranch == "all") {
92             clearFilters();
93         } else {
94             $("table#claimst tbody tr").hide();
95             $("table#claimst tbody tr").each( function() {
96                 if ( $(this).find("span.branch-" + selectedBranch).size() > 0 ) {
97                     $(this).show();
98                 }
99             });
100         }
101     }
102
103         // Filter by date
104         function filterByDate() {
105         var beginDate = Date_from_syspref($("#from").val()).getTime();
106         var endDate   = Date_from_syspref($("#to").val()).getTime();
107             
108             // Checks if the beginning date is valid
109             if (!parseInt(beginDate)) {
110                 alert(_("The beginning date is missing or invalid."));
111                 return false;
112             }
113
114             // Checks if the ending date is valid
115             if (!parseInt(endDate)) {
116                 alert(_("The ending date is missing or invalid."));
117                 return false;
118             }
119
120             // Checks if beginning date is before ending date
121             if (beginDate > endDate) {
122                 // If not, we swap them
123                 var tmpDate = endDate;
124                 endDate = beginDate;
125                 beginDate = tmpDate;
126             }
127            
128             // We hide everything
129             $("table#claimst tbody tr").hide();
130
131             // For each date in the table
132             $(".planneddate").each(function() {
133
134                 // We make a JS Date Object, according to the locale
135                 var pdate = Date_from_syspref($(this).text()).getTime();
136
137                 // And checks if the date is between the beginning and ending dates
138                 if (pdate > beginDate && 
139                     pdate < endDate) {
140                         // If so, we can show the row
141                         $(this).parent().show();
142                     }
143
144             });
145         }
146
147         // Clears filters : shows everything
148         function clearFilters() {
149             $("table#claimst tbody tr").show();
150         }
151
152         function popup(supplierid,serialid){
153                 window.open('claims.pl?supplierid='+ supplierid +'&amp;serialid='+ serialid +'&amp;op=preview' ,'popup', 'width=600,height=400,toolbar=no,scrollbars=yes');
154         }
155
156 //]]>
157 </script>
158 </head>
159 <body id="ser_claims" class="ser">
160     [% INCLUDE 'header.inc' %]
161 [% UNLESS ( preview ) %]
162     [% INCLUDE 'serials-search.inc' %]
163 [% END %]
164
165 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> &rsaquo; Claims</div>
166
167 [% UNLESS ( preview ) %]
168
169 <div id="doc3" class="yui-t2">
170    
171    <div id="bd">
172         <div id="yui-main">
173         <div class="yui-b">
174
175     <h1>Claims</h1>
176
177 [% IF ( letter ) %][% UNLESS ( missingissues ) %][% IF ( supplierid ) %] <div class="dialog alert">No missing issues found.</div>[% ELSE %]<div class="dialog message">Please choose a vendor.</div>[% END %][% END %][% END %]
178         
179              [% IF ( SHOWCONFIRMATION ) %]
180      <div class="dialog alert">Your notification has been sent.</div>
181      [% END %]
182 [% UNLESS ( letter ) %]<div class="dialog alert">No claims notice defined. <a href="/cgi-bin/koha/tools/letter.pl">Please define one</a>.</div>[% END %]
183     <form id="claims" name="claims" action="claims.pl" method="post">
184     <fieldset>
185             <label for="supplierid">Vendor: </label>
186             <select id="supplierid" name="supplierid">
187                 [% FOREACH suploo IN suploop %]
188                     [% IF ( suploo.selected ) %]
189                     <option value="[% suploo.id %]" selected="selected" >
190                     [% ELSE %]
191                     <option value="[% suploo.id %]">
192                     [% END %]
193                         [% suploo.name %]
194                         ([% suploo.count %])
195                     </option>
196                 [% END %]
197             </select>
198         <input type="submit" value="OK" />
199         [% IF ( phone ) %]Phone: [% phone %][% END %]
200         [% IF ( booksellerfax ) %]Fax: [% booksellerfax %][% END %]
201         [% IF ( bookselleremail ) %]</p><p><a href="mailto:[% bookselleremail %]">[% bookselleremail %]</a>[% END %]
202     </fieldset>
203 </form>
204
205    [% IF ( missingissues ) %]   
206     <h3>Missing issues</h3>
207     <form action="claims.pl" onsubmit="return false;">
208         <fieldset class="rows">
209         <legend>Filters :</legend>
210         
211         <ol>
212         <li>
213             <label for="statusfilter">Status : </label>
214             <select id="statusfilter" onchange="filterByStatus();">
215             <option value="all" selected="selected">(All)</option>
216             <option value="expected">Expected</option>
217             <option value="late">Late</option>
218             <option value="missing">Missing</option>
219             <option value="claimed">Claimed</option>
220             </select>
221         </li>
222         
223         <li>
224             <label for="titlefilter">Title : </label>
225         <input id="titlefilter" type="text" />
226     </li>
227     <li>
228             <label for="branchfilter">Library: </label>
229             <select id="branchfilter" onchange="filterByBranch();">
230             <option value="all" selected="selected">(All)</option>
231             [% FOREACH branchloo IN branchloop %]
232                 <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
233             [% END %]
234         </select>
235         </li>
236         
237         <li>
238         <label for="from">From:</label>
239         <input type="text" name="begindate" id="from" value="[% begindate %]" size="10" maxlength="10" class="datepickerfrom" />
240         <label for="to" style="float:none;">To:</label>
241         <input type="text" name="enddate" id="to" value="[% enddate %]" size="10" maxlength="10" class="datepickerto" />
242         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
243             <input type="button" value="OK" onclick="filterByDate();" />
244         </li>
245         
246         <li>
247         <input type="reset" value="Clear filters" onclick="clearFilters();" />
248         </li>
249         </ol>
250         </fieldset>
251     </form>
252
253     <fieldset>
254         <form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
255         <input type="hidden" name="order" value="[% order %]" />
256          <table id="claimst">
257                 <thead><tr>
258                     [% IF ( letter ) %]
259                     <th><input type="checkbox" id="CheckAll"></th>
260                     [% END %]
261                     <th>Vendor</th>
262                     <th>Library</th>
263                     <th>Title</th>
264                     <th>Issue number</th>
265                     <th>Status</th>
266                     <th>Since</th>
267                     <th>Claim date</th>
268                 </tr></thead>
269                 <tbody>[% FOREACH missingissue IN missingissues %]
270                     <tr>
271                         [% IF ( letter ) %]
272                             <td>
273                     <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
274                             </td>
275                         [% END %]
276                         <td>
277                         [% missingissue.name %]
278                         </td>
279                         <td>
280                             <span class="branch-[% missingissue.branchcode %]">[% Branches.GetName( missingissue.branchcode ) %]</span>
281                         </td>
282                         <td>
283                         <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
284                         </td>
285                         <td>
286                         [% missingissue.serialseq %]
287                         </td>
288                         <td>
289                             [% IF ( missingissue.status1 ) %]<span class="status-expected">Expected</span>[% END %]
290                             [% IF ( missingissue.status3 ) %]<span class="status-late">Late</span>[% END %]
291                             [% IF ( missingissue.status4 ) %]<span class="status-missing">Missing</span>[% END %]
292                             [% IF ( missingissue.status7 ) %]<span class="status-claimed">Claimed</span>[% END %]
293                         </td>
294                         <td class="planneddate">
295                         [% missingissue.planneddate %]
296                         </td>
297                         <td>
298                         [% missingissue.claimdate %]
299                         </td>
300                     </tr>
301                 [% END %]</tbody>
302             </table>
303
304         [% IF csv_profiles %]
305           <fieldset class="action">
306             <label for="csv_code">Select CSV profile:</label>
307             <select id="csv_profile_for_export">
308               [% FOR csv IN csv_profiles %]
309                 <option value="[% csv.export_format_id %]">[% csv.profile %]</option>
310                [% END %]
311             </select>
312             <span class="exportSelected"><a id="ExportSelected" href="/cgi-bin/koha/serials/claims.pl">Download selected claims</a></span>
313         [% END %]
314
315 [% IF ( letter ) %]
316         <fieldset class="action"> <label for="letter_code">Select notice:</label>
317             <select name="letter_code" id="letter_code">
318                 [% FOREACH letter IN letters %]
319                     <option value="[% letter.code %]">[% letter.name %]</option>
320                 [% END %]
321                         </select>
322             <input type="hidden" name="op" value="send_alert" /><input type="submit" name="submit" class="button" value="Send notification" /></fieldset>
323             [% END %]
324         </form>
325     </fieldset>
326 [% END %]
327
328 [% ELSE %]
329
330 <div id="doc" class="yui-t7">
331    <div id="bd">
332         
333 [% IF ( supplierloop ) %]
334         [% FOREACH supplierloo IN supplierloop %]
335         [% IF ( supplierloo.name ) %]
336         <p><b>[% supplierloo.name %]</b><br />
337         [% END %]
338         [% IF ( supplierloo.postal ) %]
339         [% supplierloo.postal %]<br />
340         [% END %]
341         [% IF ( supplierloo.contphone ) %]
342         Ph: [% supplierloo.contphone %]<br />
343         [% END %]
344         [% IF ( supplierloo.contfax ) %]
345         Fax: [% supplierloo.contfax %]<br />
346         [% END %]
347         [% IF ( supplierloo.contemail ) %]
348         Email: [% supplierloo.contemail %]<br />
349         [% END %]
350         [% IF ( supplierloo.accountnumber ) %]
351         A/C: [% supplierloo.accountnumber %]</p>
352         [% END %]
353         [% IF ( supplierloo.contact ) %]
354         <p>Dear [% supplierloo.contact %]</p>
355         [% ELSE %]
356         <p>To whom it may concern</p>
357         [% END %]
358         <p>The following items have not been received from you and are now considered missing:</p>
359         [% END %]
360 [% END %]
361         [% IF ( missingissues ) %]
362         <h3>Missing issues</h3>
363         <table>
364             <tr>
365                 <td><b>Vendor<b></td>
366                 <td><b>Title</b></td>
367                 <td><b>Issue number</b></td>
368                 <td><b>Missing since</b></td>
369             </tr>
370             [% FOREACH missingissue IN missingissues %]
371                 <tr>
372                     <td>
373                     [% missingissue.name %]
374                     </td>
375                     <td>
376                     [% missingissue.Title |html %]
377                     </td>
378                     <td>
379                     [% missingissue.serialseq %]
380                     </td>
381                     <td>
382                     [% missingissue.planneddate %]
383                     </td>
384                 </tr>
385             [% END %]
386         </table>
387         [% END %]
388
389 <p class="noprint"><a href="#" onclick="window.print(); return false;">Print</a> &nbsp; <a href="#" class="close">Close</a></p>
390 [% END %]
391
392 </div>
393 </div>
394
395 [% UNLESS ( preview ) %]
396 <div class="yui-b">
397 [% INCLUDE 'serials-menu.inc' %]
398 </div>
399 [% END %]
400 </div>
401 [% INCLUDE 'intranet-bottom.inc' %]