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
index 2d4cf10..7528e9a 100644 (file)
@@ -1,27 +1,28 @@
 [% INCLUDE 'doc-head-open.inc' %]
     <title>Koha &rsaquo; Serials &rsaquo; Claims</title>
     [% INCLUDE 'doc-head-close.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">
+[% INCLUDE 'calendar.inc' %]
+<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,-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>");
 
            // 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");
+               // 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.'));
+                       alert(_("Please select at least one item to export."));
                        return false;
                }
                
                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 date
        function filterByDate() {
-           var beginDate = Date_from_syspref($("#begindate").val()).getTime();
-           var endDate   = Date_from_syspref($("#enddate").val()).getTime();
+        var beginDate = Date_from_syspref($("#from").val()).getTime();
+        var endDate   = Date_from_syspref($("#to").val()).getTime();
            
            // 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;
            }
 
 
 //]]>
 </script>
-[% INCLUDE 'calendar.inc' %]
 </head>
-<body>
+<body id="ser_claims" class="ser">
     [% INCLUDE 'header.inc' %]
 [% UNLESS ( preview ) %]
     [% INCLUDE 'serials-search.inc' %]
 [% UNLESS ( letter ) %]<div class="dialog alert">No claims notice defined. <a href="/cgi-bin/koha/tools/letter.pl">Please define one</a>.</div>[% END %]
     <form id="claims" name="claims" action="claims.pl" method="post">
     <fieldset>
-           <label for="supplierid">Supplier: </label>
+           <label for="supplierid">Vendor: </label>
            <select id="supplierid" name="supplierid">
                [% FOREACH suploo IN suploop %]
                    [% IF ( suploo.selected ) %]
 </form>
 
    [% IF ( missingissues ) %]  
-    <h3>Missing Issues</h3>
+    <h3>Missing issues</h3>
     <form action="claims.pl" onsubmit="return false;">
        <fieldset class="rows">
        <legend>Filters :</legend>
                <option>Late</option>
                <option>Missing</option>
                <option>Claimed</option>
+        <option>Stopped</option>
            </select>
        </li>
        
        <li>
            <label for="titlefilter">Title : </label>
-           <input id="titlefilter" type="text" />
-           <label for="branchfilter">Branch: </label>
+        <input id="titlefilter" type="text" />
+    </li>
+    <li>
+           <label for="branchfilter">Library: </label>
            <select id="branchfilter" onchange="filterByBranch();">
             [% FOREACH branchloo IN branchloop %]
                 [% IF ( branchloo.selected ) %]
        </li>
        
        <li>
-           <label for="begindate">From</label>
-           <img src="[% themelang %]/lib/calendar/cal.gif" id="begindatebutton" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
-           <input type="text" name="begindate" id="begindate" value="[% begindate %]" size="10" maxlength="10" />
-           <script type="text/javascript">
-                //<![CDATA[ 
-               Calendar.setup({
-                   inputField  : "begindate", 
-                   button              : "begindatebutton",
-                   ifFormat    : "[% DHTMLcalendar_dateformat %]"
-               });
-               //]]>
-           </script>
-
-           <label for="enddate" style="float:none;">To</label>
-           <img src="[% themelang %]/lib/calendar/cal.gif" id="enddatebutton" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
-           <input type="text" name="enddate" id="enddate" value="[% enddate %]" size="10" maxlength="10" />
-           <script type="text/javascript">
-                //<![CDATA[ 
-                Calendar.setup({
-                   inputField      : "enddate", 
-                   button          : "enddatebutton",
-                   ifFormat        : "[% DHTMLcalendar_dateformat %]"
-               });
-               //]]>
-           </script> <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
+        <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>
+        <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();" />
         </li>
        
        <li>
-           <input type="reset" value="Clear Filters" onclick="clearFilters();" />
+        <input type="reset" value="Clear filters" onclick="clearFilters();" />
        </li>
        </ol>
        </fieldset>
                     <th><input type="checkbox" id="CheckAll"></th>
                     [% END %]
                     <th>Vendor</th>
-                    <th>Branch</th>
+                    <th>Library</th>
                     <th>Title</th>
                     <th>Issue number</th>
                     <th>Status</th>
                     <th>Since</th>
-                    <th>Claim Date</th>
-                <th>Begin Claim</th>
+                    <th>Claim date</th>
+                <th>Begin claim</th>
                 </tr></thead>
                 <tbody>[% FOREACH missingissue IN missingissues %]
                     <tr>
                             [% IF ( missingissue.status3 ) %]Late[% END %]
                             [% IF ( missingissue.status4 ) %]Missing[% END %]
                             [% IF ( missingissue.status7 ) %]Claimed[% END %]
+                            [% IF ( missingissue.status8 ) %]Stopped[% END %]
                         </td>
                         <td class="planneddate">
                         [% missingissue.planneddate %]
         [% END %]
 [% END %]
         [% IF ( missingissues ) %]
-        <h3>Missing Issues</h3>
+        <h3>Missing issues</h3>
         <table>
             <tr>
                 <td><b>Vendor<b></td>