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