Bug 10457: fix SQL error when using 'export select items data' in serials claims...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / claims.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2     <title>Koha &rsaquo; Serials &rsaquo; Claims</title>
3     [% INCLUDE 'doc-head-close.inc' %]
4 [% INCLUDE 'calendar.inc' %]
5 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" />
6 <script type="text/javascript" src="[% interface %]/[% theme %]/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
7 [% INCLUDE 'datatables-strings.inc' %]
8 <script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
9 <script type="text/javascript">
10 //<![CDATA[
11     [% IF (dateformat == 'metric') %]dt_add_type_uk_date();[% END %]
12          $(document).ready(function() {
13         [% UNLESS ( preview ) %]
14          var sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
15             "sDom": 't',
16             "aoColumnDefs": [
17                 { "aTargets": [ 0,1,-1 ], "bSortable": false, "bSearchable": false }
18             ],
19             "bPaginate": false
20         }));
21         [% END %]
22             $('#supplierid').change(function() {
23             $('#claims').submit();
24             });
25
26             // Checkboxes : Select All / None
27             $("span.checkall").html("<input type=\"checkbox\" name=\"CheckAll\"> "+_("Check All")+"</input>");
28             $("span.exportSelected").html("<a id=\"ExportSelected\" href=\"/cgi-bin/koha/serials/claims.pl\"> "+_("Export selected items data") +"<\/a>");
29
30         $("#CheckAll").click(function() {
31             $("#claimst tr:visible :checkbox").attr('checked', $("#CheckAll").is(':checked'));
32         });
33
34             // Generates a dynamic link for exporting the selection's data as CSV
35             $("#ExportSelected").click(function() {
36                // 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.
37              var selected = $("input[name=serialid]:checked");
38
39                 if (selected.length == 0) {
40                         alert(_("Please select at least one item to export."));
41                         return false;
42                 }
43                 
44                 // Building the url from currently checked boxes
45                 var url = '/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=&amp;op=claims';
46                 for (var i = 0; i < selected.length; i++) {
47                     url += '&amp;serialid=' + selected[i].value;
48                 }
49                 // And redirecting to the CSV page
50                 location.href = url;
51                 return false;
52             }); 
53
54         $("#titlefilter").keyup( function () {
55             sTable.fnFilter( this.value, 3 ); // 3 is position of title column
56         } );
57
58         $("#branchfilter").keyup(function() {
59             sTable.fnFilter( this.value, 2 ); // 2 is the position of the author column
60             });
61          });
62
63         // Checks if the form can be sent (at least one checkbox must be checked)
64         function checkForm() {
65             if ($("input:checked").length == 0) {
66                 alert(_("Please select at least one item."));
67                 return false;
68             }
69         }
70
71         // Filter by status
72         function filterByStatus() {
73             selectedStatus = $("#statusfilter").val();
74             if (selectedStatus == "all") {
75                 clearFilters();
76             } else {
77                 $("table#claimst tbody tr").hide();
78                 $("table#claimst tbody tr:contains(" + selectedStatus + ")").show();
79             }
80         }
81
82         // Filter by branch
83         function filterByBranch() {
84             selectedBranch = $("#branchfilter").val();
85             if (selectedBranch == "all") {
86                 clearFilters();
87             } else {
88                 $("table#claimst tbody tr").hide();
89                 $("table#claimst tbody tr:contains(" + selectedBranch + ")").show();
90             }
91         }
92         // Filter by date
93         function filterByDate() {
94         var beginDate = Date_from_syspref($("#from").val()).getTime();
95         var endDate   = Date_from_syspref($("#to").val()).getTime();
96             
97             // Checks if the beginning date is valid
98             if (!parseInt(beginDate)) {
99                 alert(_("The beginning date is missing or invalid."));
100                 return false;
101             }
102
103             // Checks if the ending date is valid
104             if (!parseInt(endDate)) {
105                 alert(_("The ending date is missing or invalid."));
106                 return false;
107             }
108
109             // Checks if beginning date is before ending date
110             if (beginDate > endDate) {
111                 // If not, we swap them
112                 var tmpDate = endDate;
113                 endDate = beginDate;
114                 beginDate = tmpDate;
115             }
116            
117             // We hide everything
118             $("table#claimst tbody tr").hide();
119
120             // For each date in the table
121             $(".planneddate").each(function() {
122
123                 // We make a JS Date Object, according to the locale
124                 var pdate = Date_from_syspref($(this).text()).getTime();
125
126                 // And checks if the date is between the beginning and ending dates
127                 if (pdate > beginDate && 
128                     pdate < endDate) {
129                         // If so, we can show the row
130                         $(this).parent().show();
131                     }
132
133             });
134         }
135
136         // Clears filters : shows everything
137         function clearFilters() {
138             $("table#claimst tbody tr").show();
139         }
140
141         function popup(supplierid,serialid){
142                 window.open('claims.pl?supplierid='+ supplierid +'&amp;serialid='+ serialid +'&amp;op=preview' ,'popup', 'width=600,height=400,toolbar=no,scrollbars=yes');
143         }
144
145 //]]>
146 </script>
147 </head>
148 <body id="ser_claims" class="ser">
149     [% INCLUDE 'header.inc' %]
150 [% UNLESS ( preview ) %]
151     [% INCLUDE 'serials-search.inc' %]
152 [% END %]
153
154 <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>
155
156 [% UNLESS ( preview ) %]
157
158 <div id="doc3" class="yui-t2">
159    
160    <div id="bd">
161         <div id="yui-main">
162         <div class="yui-b">
163
164     <h1>Claims</h1>
165
166 [% IF ( letter ) %][% 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 %]
167         
168              [% IF ( SHOWCONFIRMATION ) %]
169      <div class="dialog alert">Your notification has been sent.</div>
170      [% END %]
171 [% UNLESS ( letter ) %]<div class="dialog alert">No claims notice defined. <a href="/cgi-bin/koha/tools/letter.pl">Please define one</a>.</div>[% END %]
172     <form id="claims" name="claims" action="claims.pl" method="post">
173     <fieldset>
174             <label for="supplierid">Vendor: </label>
175             <select id="supplierid" name="supplierid">
176                 [% FOREACH suploo IN suploop %]
177                     [% IF ( suploo.selected ) %]
178                     <option value="[% suploo.id %]" selected="selected" >
179                     [% ELSE %]
180                     <option value="[% suploo.id %]">
181                     [% END %]
182                         [% suploo.name %]
183                         ([% suploo.count %])
184                     </option>
185                 [% END %]
186             </select>
187         <input type="submit" value="OK" />
188         [% IF ( phone ) %]Phone: [% phone %][% END %]
189         [% IF ( booksellerfax ) %]Fax: [% booksellerfax %][% END %]
190         [% IF ( bookselleremail ) %]</p><p><a href="mailto:[% bookselleremail %]">[% bookselleremail %]</a>[% END %]
191     </fieldset>
192 </form>
193
194    [% IF ( missingissues ) %]   
195     <h3>Missing issues</h3>
196     <form action="claims.pl" onsubmit="return false;">
197         <fieldset class="rows">
198         <legend>Filters :</legend>
199         
200         <ol>
201         <li>
202             <label for="statusfilter">Status : </label>
203             <select id="statusfilter" onchange="filterByStatus();">
204                 <option value="all" selected="selected">(All)</option>
205                 <option>Expected</option>
206                 <option>Arrived</option>
207                 <option>Late</option>
208                 <option>Missing</option>
209                 <option>Claimed</option>
210         <option>Stopped</option>
211             </select>
212         </li>
213         
214         <li>
215             <label for="titlefilter">Title : </label>
216         <input id="titlefilter" type="text" />
217     </li>
218     <li>
219             <label for="branchfilter">Library: </label>
220             <select id="branchfilter" onchange="filterByBranch();">
221             [% FOREACH branchloo IN branchloop %]
222                 [% IF ( branchloo.selected ) %]
223                 <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
224                 [% ELSE %]
225                 <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
226                 [% END %]
227             [% END %]
228         </select>
229         </li>
230         
231         <li>
232         <label for="from">From:</label>
233         <input type="text" name="begindate" id="from" value="[% begindate %]" size="10" maxlength="10" class="datepickerfrom" />
234         <label for="to" style="float:none;">To:</label>
235         <input type="text" name="enddate" id="to" value="[% enddate %]" size="10" maxlength="10" class="datepickerto" />
236         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
237             <input type="button" value="OK" onclick="filterByDate();" />
238         </li>
239         
240         <li>
241         <input type="reset" value="Clear filters" onclick="clearFilters();" />
242         </li>
243         </ol>
244         </fieldset>
245     </form>
246
247     <fieldset>
248         <form action="claims.pl" method="post" class="checkboxed" onsubmit="return checkForm()">
249         <input type="hidden" name="order" value="[% order %]" />
250          <table id="claimst">
251                 <thead><tr>
252                     [% IF ( letter ) %]
253                     <th><input type="checkbox" id="CheckAll"></th>
254                     [% END %]
255                     <th>Vendor</th>
256                     <th>Library</th>
257                     <th>Title</th>
258                     <th>Issue number</th>
259                     <th>Status</th>
260                     <th>Since</th>
261                     <th>Claim date</th>
262                 <th>Begin claim</th>
263                 </tr></thead>
264                 <tbody>[% FOREACH missingissue IN missingissues %]
265                     <tr>
266                         [% IF ( letter ) %]
267                             <td>
268                     <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
269                             </td>
270                         [% END %]
271                         <td>
272                         [% missingissue.name %]
273                         </td>
274                         <td>
275                         [% missingissue.branchcode %]
276                         </td>
277                         <td>
278                         <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% missingissue.subscriptionid %]">[% missingissue.title |html %]</a>
279                         </td>
280                         <td>
281                         [% missingissue.serialseq %]
282                         </td>
283                         <td>
284                             [% IF ( missingissue.status1 ) %]Expected[% END %]
285                             [% IF ( missingissue.status2 ) %]Arrived[% END %]
286                             [% IF ( missingissue.status3 ) %]Late[% END %]
287                             [% IF ( missingissue.status4 ) %]Missing[% END %]
288                             [% IF ( missingissue.status7 ) %]Claimed[% END %]
289                             [% IF ( missingissue.status8 ) %]Stopped[% END %]
290                         </td>
291                         <td class="planneddate">
292                         [% missingissue.planneddate %]
293                         </td>
294                         <td>
295                         [% missingissue.claimdate %]
296                         </td>
297                         <td>
298                             <a href="/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
299                         </td>
300                     </tr>
301                 [% END %]</tbody>
302             </table>
303              <p><span class="exportSelected"></span></p>
304
305 [% IF ( letter ) %]
306         <fieldset class="action"> <label for="letter_code">Select notice:</label>
307             <select name="letter_code" id="letter_code">
308                 [% FOREACH letter IN letters %]
309                     <option value="[% letter.code %]">[% letter.name %]</option>
310                 [% END %]
311                         </select>
312             <input type="hidden" name="op" value="send_alert" /><input type="submit" name="submit" class="button" value="Send notification" /></fieldset>
313             [% END %]
314         </form>
315     </fieldset>
316 [% END %]
317
318 [% ELSE %]
319
320 <div id="doc" class="yui-t7">
321    <div id="bd">
322         
323 [% IF ( supplierloop ) %]
324         [% FOREACH supplierloo IN supplierloop %]
325         [% IF ( supplierloo.name ) %]
326         <p><b>[% supplierloo.name %]</b><br />
327         [% END %]
328         [% IF ( supplierloo.postal ) %]
329         [% supplierloo.postal %]<br />
330         [% END %]
331         [% IF ( supplierloo.contphone ) %]
332         Ph: [% supplierloo.contphone %]<br />
333         [% END %]
334         [% IF ( supplierloo.contfax ) %]
335         Fax: [% supplierloo.contfax %]<br />
336         [% END %]
337         [% IF ( supplierloo.contemail ) %]
338         Email: [% supplierloo.contemail %]<br />
339         [% END %]
340         [% IF ( supplierloo.accountnumber ) %]
341         A/C: [% supplierloo.accountnumber %]</p>
342         [% END %]
343         [% IF ( supplierloo.contact ) %]
344         <p>Dear [% supplierloo.contact %]</p>
345         [% ELSE %]
346         <p>To whom it may concern</p>
347         [% END %]
348         <p>The following items have not been received from you and are now considered missing:</p>
349         [% END %]
350 [% END %]
351         [% IF ( missingissues ) %]
352         <h3>Missing issues</h3>
353         <table>
354             <tr>
355                 <td><b>Vendor<b></td>
356                 <td><b>Title</b></td>
357                 <td><b>Issue number</b></td>
358                 <td><b>Missing since</b></td>
359             </tr>
360             [% FOREACH missingissue IN missingissues %]
361                 <tr>
362                     <td>
363                     [% missingissue.name %]
364                     </td>
365                     <td>
366                     [% missingissue.Title |html %]
367                     </td>
368                     <td>
369                     [% missingissue.serialseq %]
370                     </td>
371                     <td>
372                     [% missingissue.planneddate %]
373                     </td>
374                 </tr>
375             [% END %]
376         </table>
377         [% END %]
378
379 <p class="noprint"><a href="#" onclick="window.print(); return false;">Print</a> &nbsp; <a href="#" class="close">Close</a></p>
380 [% END %]
381
382 </div>
383 </div>
384
385 [% UNLESS ( preview ) %]
386 <div class="yui-b">
387 [% INCLUDE 'serials-menu.inc' %]
388 </div>
389 [% END %]
390 </div>
391 [% INCLUDE 'intranet-bottom.inc' %]