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