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