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