Bug 7298: (follow-up) various QA fixes
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / claims.tt
index c1f3aa1..6b0b89d 100644 (file)
@@ -2,30 +2,29 @@
     <title>Koha &rsaquo; Serials &rsaquo; Claims</title>
     [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'calendar.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.uitablefilter.js"></script>
-<script type="text/JavaScript" language="JavaScript">
+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" />
+<script type="text/javascript" src="[% interface %]/[% theme %]/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
+[% INCLUDE 'datatables-strings.inc' %]
+<script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
+<script type="text/javascript">
 //<![CDATA[
+    [% IF (dateformat == 'metric') %]dt_add_type_uk_date();[% END %]
         $(document).ready(function() {
-               [% UNLESS ( preview ) %]$("#claimst").tablesorter({[% IF ( dateformat == 'metric' ) %]
-                       dateFormat: 'uk',[% END %]
-                       headers: { 0: { sorter: false },1:{sorter:false}}
-               });[% END %]
+        [% UNLESS ( preview ) %]
+         var sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "sDom": 't',
+            "aoColumnDefs": [
+                { "aTargets": [ 0,1 ], "bSortable": false, "bSearchable": false }
+            ],
+            "bPaginate": false
+        }));
+        [% END %]
            $('#supplierid').change(function() {
            $('#claims').submit();
            });
 
-           // Case-insensitive version of jquery's contains function
-           jQuery.extend(
-               jQuery.expr[':'], { 
-                   icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" 
-               }
-           );
-
-
            // Checkboxes : Select All / None
            $("span.checkall").html("<input type=\"checkbox\" name=\"CheckAll\"> "+_("Check All")+"</input>");
-           $("span.exportSelected").html("<a id=\"ExportSelected\" href=\"/cgi-bin/koha/serials/claims.pl\"> "+_("Export selected items data") +"<\/a>");
 
         $("#CheckAll").click(function() {
             $("#claimst tr:visible :checkbox").attr('checked', $("#CheckAll").is(':checked'));
 
            // Generates a dynamic link for exporting the selection's data as CSV
            $("#ExportSelected").click(function() {
-               // We use input:checked because it's faster, but if there must new checkboxes  
-               // used for other purpose on this page, please use [name=serialid]:checked instead
-               var selected = $("input:checked");
-
-               if (selected.length == 0) {
-                       alert(_('Please select at least one item to export.'));
-                       return false;
-               }
-               
-               // Building the url from currently checked boxes
-               var url = '/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=&amp;op=claims';
-               for (var i = 0; i < selected.length; i++) {
-                   url += '&amp;serialid=' + selected[i].value;
-               }
-               // And redirecting to the CSV page
-               location.href = url;
-               return false;
-           }); 
+               // 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.
+             var selected = $("input[name=serialid]:checked");
+
+        if (selected.length == 0) {
+            alert(_("Please select at least one item to export."));
+            return false;
+        }
+
+        // Building the url from currently checked boxes
+        var url = '/cgi-bin/koha/serials/lateissues-export.pl?supplierid=&amp;op=claims';
+        for (var i = 0; i < selected.length; i++) {
+            url += '&amp;serialid=' + selected[i].value;
+        }
+        url += '&amp;csv_profile=' + $("#csv_profile_for_export option:selected").val();
+        // And redirecting to the CSV page
+        location.href = url;
+        return false;
+        });
 
-        $("#titlefilter").keyup(function() {
-            $.uiTableFilter($("#claimst"), $("#titlefilter").val())
-           });
+        $("#titlefilter").keyup( function () {
+            sTable.fnFilter( this.value, 3 ); // 3 is position of title column
+        );
 
         $("#branchfilter").keyup(function() {
-            $.uiTableFilter($("#claimst"), $("#branchfilter").val())
+            sTable.fnFilter( this.value, 2 ); // 2 is the position of the author column
            });
         });
 
        // Checks if the form can be sent (at least one checkbox must be checked)
        function checkForm() {
            if ($("input:checked").length == 0) {
-               alert(_('Please select at least one item.'));
+               alert(_("Please select at least one item."));
                return false;
            }
        }
 
-       // Filter by status
-       function filterByStatus() {
-           selectedStatus = $("#statusfilter").val();
-           if (selectedStatus == "all") {
-               clearFilters();
-           } else {
-               $("table#claimst tbody tr").hide();
-               $("table#claimst tbody tr:contains(" + selectedStatus + ")").show();
-           }
-       }
+    // Filter by status
+    function filterByStatus() {
+        selectedStatus = $("#statusfilter").val();
+        if (selectedStatus == "all") {
+            clearFilters();
+        } else {
+            $("table#claimst tbody tr").hide();
+            $("table#claimst tbody tr").each( function() {
+                if ( $(this).find("span.status-" + selectedStatus).size() > 0 ) {
+                    $(this).show();
+                }
+            });
+        }
+    }
 
        // Filter by branch
        function filterByBranch() {
            
            // Checks if the beginning date is valid
            if (!parseInt(beginDate)) {
-               alert(_('The beginning date is missing or invalid.'));
+               alert(_("The beginning date is missing or invalid."));
                return false;
            }
 
            // Checks if the ending date is valid
            if (!parseInt(endDate)) {
-               alert(_('The ending date is missing or invalid.'));
+               alert(_("The ending date is missing or invalid."));
                return false;
            }
 
        <li>
            <label for="statusfilter">Status : </label>
            <select id="statusfilter" onchange="filterByStatus();">
-               <option value="all" selected="selected">(All)</option>
-               <option>Expected</option>
-               <option>Arrived</option>
-               <option>Late</option>
-               <option>Missing</option>
-               <option>Claimed</option>
-        <option>Stopped</option>
+            <option value="all" selected="selected">(All)</option>
+            <option value="expected">Expected</option>
+            <option value="late">Late</option>
+            <option value="missing">Missing</option>
+            <option value="claimed">Claimed</option>
            </select>
        </li>
        
        <li>
            <label for="titlefilter">Title : </label>
-           <input id="titlefilter" type="text" />
+        <input id="titlefilter" type="text" />
+    </li>
+    <li>
            <label for="branchfilter">Library: </label>
            <select id="branchfilter" onchange="filterByBranch();">
             [% FOREACH branchloo IN branchloop %]
        </li>
        
        <li>
-        <label for="from">From</label>
+        <label for="from">From:</label>
         <input type="text" name="begindate" id="from" value="[% begindate %]" size="10" maxlength="10" class="datepickerfrom" />
-        <label for="to" style="float:none;">To</label>
+        <label for="to" style="float:none;">To:</label>
         <input type="text" name="enddate" id="to" value="[% enddate %]" size="10" maxlength="10" class="datepickerto" />
         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
            <input type="button" value="OK" onclick="filterByDate();" />
                     <th>Status</th>
                     <th>Since</th>
                     <th>Claim date</th>
-                <th>Begin claim</th>
                 </tr></thead>
                 <tbody>[% FOREACH missingissue IN missingissues %]
                     <tr>
                         [% missingissue.serialseq %]
                         </td>
                         <td>
-                            [% IF ( missingissue.status1 ) %]Expected[% END %]
-                            [% IF ( missingissue.status2 ) %]Arrived[% END %]
-                            [% IF ( missingissue.status3 ) %]Late[% END %]
-                            [% IF ( missingissue.status4 ) %]Missing[% END %]
-                            [% IF ( missingissue.status7 ) %]Claimed[% END %]
-                            [% IF ( missingissue.status8 ) %]Stopped[% END %]
+                            [% IF ( missingissue.status1 ) %]<span class="status-expected">Expected</span>[% END %]
+                            [% IF ( missingissue.status3 ) %]<span class="status-late">Late</span>[% END %]
+                            [% IF ( missingissue.status4 ) %]<span class="status-missing">Missing</span>[% END %]
+                            [% IF ( missingissue.status7 ) %]<span class="status-claimed">Claimed</span>[% END %]
                         </td>
                         <td class="planneddate">
                         [% missingissue.planneddate %]
                         <td>
                         [% missingissue.claimdate %]
                         </td>
-                        <td>
-                            <a href="/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
-                        </td>
                     </tr>
                 [% END %]</tbody>
             </table>
-            <p><span class="exportSelected"></span></p>
+
+        [% IF csv_profiles %]
+          <fieldset class="action">
+            <label for="csv_code">Select CSV profile:</label>
+            <select id="csv_profile_for_export">
+              [% FOR csv IN csv_profiles %]
+                <option value="[% csv.export_format_id %]">[% csv.profile %]</option>
+               [% END %]
+            </select>
+            <span class="exportSelected"><a id="ExportSelected" href="/cgi-bin/koha/serials/claims.pl">Download selected claims</a></span>
+        [% END %]
 
 [% IF ( letter ) %]
         <fieldset class="action"> <label for="letter_code">Select notice:</label>