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