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