Bug 16238: Use .prop() instead of .attr() for 'checked'
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / claims.tt
1 [% USE Branches %]
2
3 [% INCLUDE 'doc-head-open.inc' %]
4 [% USE AuthorisedValues %]
5     <title>Koha &rsaquo; Serials &rsaquo; Claims</title>
6     [% INCLUDE 'doc-head-close.inc' %]
7 [% INCLUDE 'calendar.inc' %]
8 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
9 [% INCLUDE 'datatables.inc' %]
10 <script type="text/javascript">
11 //<![CDATA[
12     var sTable;
13          $(document).ready(function() {
14          sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
15             "sDom": 't',
16                 "aoColumnDefs": [
17                     { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
18                     { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] },
19                     { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
20                 ],
21             "bPaginate": false
22         }));
23         sTable.fnAddFilters("filter", "200");
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").prop('checked', $("#CheckAll").is(':checked'));
33         });
34
35         // Generates a dynamic link for exporting the selections 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          });
57
58         // Checks if the form can be sent (at least one checkbox must be checked)
59         function checkForm() {
60             if ($("input:checked").length == 0) {
61         alert(_("Please select at least one issue."));
62                 return false;
63             }
64         }
65
66         // Filter by date
67         function filterByDate() {
68         var beginDate = Date_from_syspref($("#from").val()).getTime();
69         var endDate   = Date_from_syspref($("#to").val()).getTime();
70             
71             // Checks if the beginning date is valid
72             if (!parseInt(beginDate)) {
73                 alert(_("The beginning date is missing or invalid."));
74                 return false;
75             }
76
77             // Checks if the ending date is valid
78             if (!parseInt(endDate)) {
79                 alert(_("The ending date is missing or invalid."));
80                 return false;
81             }
82
83             // Checks if beginning date is before ending date
84             if (beginDate > endDate) {
85                 // If not, we swap them
86                 var tmpDate = endDate;
87                 endDate = beginDate;
88                 beginDate = tmpDate;
89             }
90            
91             // We hide everything
92             $("table#claimst tbody tr").hide();
93
94             // For each date in the table
95             $(".planneddate").each(function() {
96
97                 // We make a JS Date Object, according to the locale
98                 var pdate = Date_from_syspref($(this).text()).getTime();
99
100                 // And checks if the date is between the beginning and ending dates
101                 if (pdate > beginDate && 
102                     pdate < endDate) {
103                         // If so, we can show the row
104                         $(this).parent().show();
105                     }
106
107             });
108         }
109
110         // Clears filters : shows everything
111         function clearFilters() {
112             $("table#claimst tbody tr").show();
113
114         }
115
116 //]]>
117 </script>
118 </head>
119 <body id="ser_claims" class="ser">
120     [% INCLUDE 'header.inc' %]
121     [% INCLUDE 'serials-search.inc' %]
122
123 <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>
124
125 <div id="doc3" class="yui-t2">
126    
127    <div id="bd">
128         <div id="yui-main">
129         <div class="yui-b">
130
131     <h1>Claims</h1>
132
133     [% IF error_claim %]
134         [% IF error_claim == 'no_vendor_email' %]
135             <div class="error">This vendor has no email defined for late issues.</div>
136         [% ELSIF error_claim == 'no_loggedin_user_email' %]
137             <div class="error">No email is configured for your user.</div>
138         [% ELSE %]
139             <div class="error">[% error_claim %]</div>
140         [% END %]
141     [% END %]
142     [% IF info_claim %]
143         <div class="dialog message">Email has been sent.</div>
144     [% END %]
145
146 [% 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 %]
147         
148              [% IF ( SHOWCONFIRMATION ) %]
149      <div class="dialog alert">Your notification has been sent.</div>
150      [% END %]
151 [% UNLESS letters %]<div class="dialog alert">No claims notice defined. <a href="/cgi-bin/koha/tools/letter.pl">Please define one</a>.</div>[% END %]
152     <form id="claims" name="claims" action="claims.pl" method="post">
153     <fieldset>
154             <label for="supplierid">Vendor: </label>
155             <select id="supplierid" name="supplierid">
156                 [% FOREACH suploo IN suploop %]
157                     [% IF ( suploo.selected ) %]
158                     <option value="[% suploo.id %]" selected="selected" >
159                     [% ELSE %]
160                     <option value="[% suploo.id %]">
161                     [% END %]
162                         [% suploo.name %]
163                         ([% suploo.count %])
164                     </option>
165                 [% END %]
166             </select>
167         <input type="submit" value="OK" />
168     </fieldset>
169 </form>
170
171    [% IF ( missingissues ) %]   
172     <h3>Missing issues</h3>
173     <form action="claims.pl" onsubmit="return false;">
174         <fieldset class="rows">
175         <legend>Filters :</legend>
176         
177         <ol>
178         <li>
179         <label for="from">From:</label>
180         <input type="text" name="begindate" id="from" value="[% begindate %]" size="10" maxlength="10" class="datepickerfrom" />
181         <label for="to" style="float:none;">To:</label>
182         <input type="text" name="enddate" id="to" value="[% enddate %]" size="10" maxlength="10" class="datepickerto" />
183         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
184             <input type="button" value="OK" onclick="filterByDate();" />
185     </li>
186
187         <li>
188         <input type="reset" value="Clear filters" onclick="clearFilters();" />
189         </li>
190         </ol>
191         </fieldset>
192     </form>
193
194     <fieldset>
195         <form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
196             <table id="claimst">
197                 <thead>
198                     <tr>
199                         <th><input type="checkbox" id="CheckAll"></th>
200                         <th>Vendor</th>
201                         <th>Library</th>
202                         <th class="anti-the">Title</th>
203                         <th>ISSN</th>
204                         <th>Issue number</th>
205                         <th>Status</th>
206                         <th class="title-string">Since</th>
207                         <th>Claims count</th>
208                         <th class="title-string">Claim date</th>
209                         [% FOR field IN additional_fields_for_subscription %]
210                           <th>[% field.name %]</th>
211                         [% END %]
212                     </tr>
213                 </thead>
214                 <tfoot>
215                   <tr>
216                     <td></td>
217                     <td><input type="text" class="filter" data-column_num="1" placeholder="Search vendor" /></td>
218                     <td><input type="text" class="filter" data-column_num="2" placeholder="Search library" /></td>
219                     <td><input type="text" class="filter" data-column_num="3" placeholder="Search title" /></td>
220                     <td><input type="text" class="filter" data-column_num="4" placeholder="Search ISSN" /></td>
221                     <td><input type="text" class="filter" data-column_num="5" placeholder="Search issue number" /></td>
222                     <td><input type="text" class="filter" data-column_num="6" placeholder="Search status" /></td>
223                     <td><input type="text" class="filter" data-column_num="7" placeholder="Search since" /></td>
224                     <td><input type="text" class="filter" data-column_num="8" placeholder="Search claim count" /></td>
225                     <td><input type="text" class="filter" data-column_num="9" placeholder="Search claim date" /></td>
226                     [% FOR field IN additional_fields_for_subscription %]
227                       <td><input type="text" class="filter" data-column_num="[% loop.count + 9 %]" placeholder="Search [% field.name %]" /></td>
228                     [% END %]
229                   </tr>
230                 </tfoot>
231                 <tbody>[% FOREACH missingissue IN missingissues %]
232                     <tr>
233                         <td>
234                           [% UNLESS missingissue.cannot_claim %]
235                             <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
236                           [% END %]
237                         </td>
238                         <td>[% missingissue.name %]</td>
239                         <td>
240                             <span class="branch-[% missingissue.branchcode %]">[% Branches.GetName( missingissue.branchcode ) %]</span>
241                         </td>
242                         <td>
243                         <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
244                         </td>
245                         <td>[% missingissue.issn %]</td>
246                         <td>[% missingissue.serialseq %]</td>
247                         <td>
248                             [% IF ( missingissue.status1 ) %]<span class="status-expected">Expected</span>[% END %]
249                             [% IF ( missingissue.status3 ) %]<span class="status-late">Late</span>[% END %]
250                             [% IF ( missingissue.status4 ) %]<span class="status-missing">Missing</span>[% END %]
251                             [% IF ( missingissue.status41 ) %]<span class="status-missing_never_received">Missing (never received)</span>[% END %]
252                             [% IF ( missingissue.status42 ) %]<span class="status-missing_sold_out">Missing (sold out)</span>[% END %]
253                             [% IF ( missingissue.status43 ) %]<span class="status-missing_damaged">Missing (damaged)</span>[% END %]
254                             [% IF ( missingissue.status44 ) %]<span class="status-missing_lost">Missing (lost)</span>[% END %]
255                             [% IF ( missingissue.status7 ) %]<span class="status-claimed">Claimed</span>[% END %]
256                         </td>
257                         <td class="planneddate">
258                             [% IF ( missingissue.planneddate ) %]
259                                 <span title="[% missingissue.planneddateISO %]">[% missingissue.planneddate %]</span>
260                             [% ELSE %]
261                                 <span title="0000-00-00"></span>
262                             [% END %]
263                         </td>
264                         <td>[% missingissue.claims_count %]</td>
265                         <td>
266                             [% IF ( missingissue.claimdate ) %]
267                                 <span title="[% missingissue.claimdateISO %]">[% missingissue.claimdate %]</span>
268                             [% ELSE %]
269                                 <span title="0000-00-00"></span>
270                             [% END %]
271                         </td>
272                         [% FOR field IN additional_fields_for_subscription %]
273                           [% IF field.authorised_value_category %]
274                             <td>[% AuthorisedValues.GetByCode( field.authorised_value_category, missingissue.additional_fields.${field.name} ) %]</td>
275                           [% ELSE %]
276                             <td>[% missingissue.additional_fields.${field.name} %]</td>
277                           [% END %]
278                         [% END %]
279                     </tr>
280                 [% END %]</tbody>
281             </table>
282
283             [% IF csv_profiles %]
284               <fieldset class="action">
285                 <label for="csv_code">Select CSV profile:</label>
286                 <select id="csv_profile_for_export">
287                   [% FOR csv IN csv_profiles %]
288                     <option value="[% csv.export_format_id %]">[% csv.profile %]</option>
289                    [% END %]
290                 </select>
291                 <span class="exportSelected"><a id="ExportSelected" href="/cgi-bin/koha/serials/claims.pl">Download selected claims</a></span>
292             [% END %]
293
294             [% IF letters %]
295                 <fieldset class="action">
296                     <label for="letter_code">Select notice:</label>
297                     <select name="letter_code" id="letter_code">
298                         [% FOREACH letter IN letters %]
299                             <option value="[% letter.code %]">[% letter.name %]</option>
300                         [% END %]
301                     </select>
302                     <input type="hidden" name="op" value="send_alert" />
303                     <input type="hidden" name="supplierid" value="[% supplierid %]" />
304                     <input type="submit" name="submit" class="button" value="Send notification" />
305                 </fieldset>
306             [% END %]
307         </form>
308     </fieldset>
309 [% END %]
310
311 </div>
312 </div>
313
314 <div class="yui-b">
315 [% INCLUDE 'serials-menu.inc' %]
316 </div>
317 </div>
318 [% INCLUDE 'intranet-bottom.inc' %]