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