Bug 20538: Remove the need of writing [% KOHA_VERSION %] everywhere
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / claims.tt
1 [% USE Asset %]
2 [% USE AuthorisedValues %]
3 [% USE Branches %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6     <title>Koha &rsaquo; Serials &rsaquo; Claims</title>
7     [% INCLUDE 'doc-head-close.inc' %]
8 [% Asset.css("css/datatables.css") %]
9 </head>
10
11 <body id="ser_claims" class="ser">
12     [% INCLUDE 'header.inc' %]
13     [% INCLUDE 'serials-search.inc' %]
14
15 <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>
16
17 <div id="doc3" class="yui-t2">
18    
19    <div id="bd">
20         <div id="yui-main">
21         <div class="yui-b">
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 %]</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 %]" selected="selected" >
51                     [% ELSE %]
52                     <option value="[% suploo.id %]">
53                     [% END %]
54                         [% suploo.name %]
55                         ([% suploo.count %])
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 %]" 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 %]" 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 %]</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 %]" placeholder="Search [% field.name %]" /></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 %]" />
125                           [% END %]
126                         </td>
127                         <td>[% missingissue.name %]</td>
128                         <td>
129                             <span class="branch-[% missingissue.branchcode %]">[% Branches.GetName( missingissue.branchcode ) %]</span>
130                         </td>
131                         <td>
132                         <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
133                         </td>
134                         <td>[% missingissue.issn %]</td>
135                         <td>[% missingissue.serialseq %]</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 %]">[% missingissue.planneddate %]</span>
149                             [% ELSE %]
150                                 <span title="0000-00-00"></span>
151                             [% END %]
152                         </td>
153                         <td>[% missingissue.claims_count %]</td>
154                         <td>
155                             [% IF ( missingissue.claimdate ) %]
156                                 <span title="[% missingissue.claimdateISO %]">[% missingissue.claimdate %]</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} ) %]</td>
164                           [% ELSE %]
165                             <td>[% missingissue.additional_fields.${field.name} %]</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 %]">[% csv.profile %]</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 %]">[% letter.name %]</option>
189                         [% END %]
190                     </select>
191                     <input type="hidden" name="op" value="send_alert" />
192                     <input type="hidden" name="supplierid" value="[% supplierid %]" />
193                     <input type="submit" name="submit" class="button" value="Send notification" />
194                 </fieldset>
195             [% END %]
196         </form>
197     </fieldset>
198 [% END %]
199
200 </div>
201 </div>
202
203 <div class="yui-b">
204 [% INCLUDE 'serials-menu.inc' %]
205 </div>
206 </div>
207
208 [% MACRO jsinclude BLOCK %]
209     [% INCLUDE 'calendar.inc' %]
210     [% INCLUDE 'datatables.inc' %]
211     <script type="text/javascript">
212         var sTable;
213         $(document).ready(function() {
214             sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
215                 "sDom": 't',
216                     "aoColumnDefs": [
217                         { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
218                         { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] },
219                         { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
220                     ],
221                 "bPaginate": false
222             }));
223             sTable.fnAddFilters("filter", "200");
224             $('#supplierid').change(function() {
225                 $('#claims').submit();
226             });
227
228             // Checkboxes : Select All / None
229             $("span.checkall").html("<input type=\"checkbox\" name=\"CheckAll\"> "+_("Check All")+"</input>");
230
231             $("#CheckAll").click(function() {
232                 $("#claimst tr:visible :checkbox").prop('checked', $("#CheckAll").is(':checked'));
233             });
234
235             // Generates a dynamic link for exporting the selections data as CSV
236             $("#ExportSelected").click(function() {
237                 // 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.
238                 var selected = $("input[name=serialid]:checked");
239
240             if (selected.length == 0) {
241                 alert(_("Please select at least one item to export."));
242                 return false;
243             }
244
245             // Building the url from currently checked boxes
246             var url = '/cgi-bin/koha/serials/lateissues-export.pl?supplierid=&amp;op=claims';
247             for (var i = 0; i < selected.length; i++) {
248                 url += '&amp;serialid=' + selected[i].value;
249             }
250             url += '&amp;csv_profile=' + $("#csv_profile_for_export option:selected").val();
251             // And redirecting to the CSV page
252             location.href = url;
253             return false;
254             });
255             $("#filterByDate").on("click",function(e){
256                 e.preventDefault();
257                 filterByDate();
258             });
259             $("#clearfilter").on("click",function(e){
260                 e.preventDefault();
261                 $("#from,#to").val("");
262                 $("table#claimst tbody tr").show();
263             });
264             $("#claims_form").on("submit",function(){
265                 return checkForm();
266             });
267             $("#filter_claims_form").on("submit",function(){
268                 return false;
269             });
270          });
271
272         // Checks if the form can be sent (at least one checkbox must be checked)
273         function checkForm() {
274             if ($("input:checked").length == 0) {
275             alert(_("Please select at least one issue."));
276             return false;
277             }
278         }
279
280         // Filter by date
281         function filterByDate() {
282             var beginDate = Date_from_syspref($("#from").val()).getTime();
283             var endDate   = Date_from_syspref($("#to").val()).getTime();
284
285             // Checks if the beginning date is valid
286             if (!parseInt(beginDate)) {
287                 alert(_("The beginning date is missing or invalid."));
288                 return false;
289             }
290
291             // Checks if the ending date is valid
292             if (!parseInt(endDate)) {
293                 alert(_("The ending date is missing or invalid."));
294                 return false;
295             }
296
297             // Checks if beginning date is before ending date
298             if (beginDate > endDate) {
299                 // If not, we swap them
300                 var tmpDate = endDate;
301                 endDate = beginDate;
302                 beginDate = tmpDate;
303             }
304
305             // We hide everything
306             $("table#claimst tbody tr").hide();
307
308             // For each date in the table
309             $(".planneddate").each(function() {
310
311             // We make a JS Date Object, according to the locale
312             var pdate = Date_from_syspref($(this).text()).getTime();
313
314             // And checks if the date is between the beginning and ending dates
315             if (pdate > beginDate &&
316                 pdate < endDate) {
317                 // If so, we can show the row
318                 $(this).parent().show();
319                 }
320             });
321         }
322     </script>
323 [% END %]
324
325 [% INCLUDE 'intranet-bottom.inc' %]