Bug 27846: (follow-up) Add id back to breadcrumbs container
[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 class="title-string">Since</th>
109                         <th>Claims count</th>
110                         <th class="title-string">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">
160                             [% IF ( missingissue.planneddate ) %]
161                                 <span title="[% missingissue.planneddateISO | html %]">[% missingissue.planneddate | html %]</span>
162                             [% ELSE %]
163                                 <span title="0000-00-00"></span>
164                             [% END %]
165                         </td>
166                         <td>[% missingissue.claims_count | html %]</td>
167                         <td>
168                             [% IF ( missingissue.claimdate ) %]
169                                 <span title="[% missingissue.claimdateISO | html %]">[% missingissue.claimdate | html %]</span>
170                             [% ELSE %]
171                                 <span title="0000-00-00"></span>
172                             [% END %]
173                         </td>
174                         [% FOR field IN additional_fields_for_subscription %]
175                           [% IF field.authorised_value_category %]
176                             <td>[% AuthorisedValues.GetByCode( field.authorised_value_category, missingissue.additional_fields.${field.name} ) | html %]</td>
177                           [% ELSE %]
178                             <td>[% missingissue.additional_fields.${field.name} | html %]</td>
179                           [% END %]
180                         [% END %]
181                     </tr>
182                 [% END %]</tbody>
183             </table>
184
185             [% IF csv_profiles %]
186               <fieldset class="action">
187                 <label for="csv_code">Select CSV profile:</label>
188                 <select id="csv_profile_for_export">
189                   [% FOR csv IN csv_profiles %]
190                     <option value="[% csv.export_format_id | html %]">[% csv.profile | html %]</option>
191                    [% END %]
192                 </select>
193                 <span class="exportSelected"><a id="ExportSelected" href="/cgi-bin/koha/serials/claims.pl">Download selected claims</a></span>
194             [% END %]
195
196             [% IF letters %]
197                 <fieldset class="action">
198                     <label for="letter_code">Select notice:</label>
199                     <select name="letter_code" id="letter_code">
200                         [% FOREACH letter IN letters %]
201                             <option value="[% letter.code | html %]">[% letter.name | html %]</option>
202                         [% END %]
203                     </select>
204                     <input type="hidden" name="op" value="send_alert" />
205                     <input type="hidden" name="supplierid" value="[% supplierid | html %]" />
206                     <input type="submit" name="submit" class="button" value="Send notification" />
207                 </fieldset>
208             [% END %]
209         </form>
210     </fieldset>
211 [% END %]
212
213             </main>
214         </div> <!-- /.col-sm-10.col-sm-push-2 -->
215
216         <div class="col-sm-2 col-sm-pull-10">
217             <aside>
218                 [% INCLUDE 'serials-menu.inc' %]
219             </aside>
220         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
221      </div> <!-- /.row -->
222
223 [% MACRO jsinclude BLOCK %]
224     [% INCLUDE 'calendar.inc' %]
225     [% INCLUDE 'datatables.inc' %]
226     <script>
227         var sTable;
228         $(document).ready(function() {
229             sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
230                 "sDom": 't',
231                     "aoColumnDefs": [
232                         { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
233                         { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] },
234                         { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
235                     ],
236                 "bPaginate": false
237             }));
238             sTable.fnAddFilters("filter", "200");
239             $('#supplierid').change(function() {
240                 $('#claims').submit();
241             });
242
243             // Checkboxes : Select All / None
244             $("span.checkall").html("<input type=\"checkbox\" name=\"CheckAll\"> "+_("Check All")+"</input>");
245
246             $("#CheckAll").click(function() {
247                 $("#claimst tr:visible :checkbox").prop('checked', $("#CheckAll").is(':checked'));
248             });
249
250             // Generates a dynamic link for exporting the selections data as CSV
251             $("#ExportSelected").click(function() {
252                 // 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.
253                 var selected = $("input[name=serialid]:checked");
254
255             if (selected.length == 0) {
256                 alert(_("Please select at least one item to export."));
257                 return false;
258             }
259
260             // Building the url from currently checked boxes
261             var url = '/cgi-bin/koha/serials/lateissues-export.pl?supplierid=&amp;op=claims';
262             for (var i = 0; i < selected.length; i++) {
263                 url += '&amp;serialid=' + selected[i].value;
264             }
265             url += '&amp;csv_profile=' + $("#csv_profile_for_export option:selected").val();
266             // And redirecting to the CSV page
267             location.href = url;
268             return false;
269             });
270             $("#filterByDate").on("click",function(e){
271                 e.preventDefault();
272                 filterByDate();
273             });
274             $("#clearfilter").on("click",function(e){
275                 e.preventDefault();
276                 $("#from,#to").val("");
277                 $("table#claimst tbody tr").show();
278             });
279             $("#claims_form").on("submit",function(){
280                 return checkForm();
281             });
282             $("#filter_claims_form").on("submit",function(){
283                 return false;
284             });
285          });
286
287         // Checks if the form can be sent (at least one checkbox must be checked)
288         function checkForm() {
289             if ($("input:checked").length == 0) {
290             alert(_("Please select at least one issue."));
291             return false;
292             }
293         }
294
295         // Filter by date
296         function filterByDate() {
297             var beginDate = Date_from_syspref($("#from").val()).getTime();
298             var endDate   = Date_from_syspref($("#to").val()).getTime();
299
300             // Checks if the beginning date is valid
301             if (!parseInt(beginDate)) {
302                 alert(_("The beginning date is missing or invalid."));
303                 return false;
304             }
305
306             // Checks if the ending date is valid
307             if (!parseInt(endDate)) {
308                 alert(_("The ending date is missing or invalid."));
309                 return false;
310             }
311
312             // Checks if beginning date is before ending date
313             if (beginDate > endDate) {
314                 // If not, we swap them
315                 var tmpDate = endDate;
316                 endDate = beginDate;
317                 beginDate = tmpDate;
318             }
319
320             // We hide everything
321             $("table#claimst tbody tr").hide();
322
323             // For each date in the table
324             $(".planneddate").each(function() {
325
326             // We make a JS Date Object, according to the locale
327             var pdate = Date_from_syspref($(this).text()).getTime();
328
329             // And checks if the date is between the beginning and ending dates
330             if (pdate > beginDate &&
331                 pdate < endDate) {
332                 // If so, we can show the row
333                 $(this).parent().show();
334                 }
335             });
336         }
337     </script>
338 [% END %]
339
340 [% INCLUDE 'intranet-bottom.inc' %]