ffzg/recall_notices.pl: added --interval and --dedup
[koha.git] / C4 / Utils / DataTables.pm
index 9a8e4e4..e6fc1cc 100644 (file)
@@ -4,26 +4,25 @@ package C4::Utils::DataTables;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
 require Exporter;
 
-use vars qw($VERSION @ISA @EXPORT);
+use vars qw(@ISA @EXPORT);
 
 BEGIN {
-    $VERSION    = 3.04,
 
     @ISA        = qw(Exporter);
     @EXPORT     = qw(dt_build_orderby dt_build_having dt_get_params dt_build_query);
@@ -35,7 +34,7 @@ C4::Utils::DataTables - Utility subs for building query when DataTables source i
 
 =head1 SYNOPSYS
 
-    use CGI;
+    use CGI qw ( -utf8 );
     use C4::Context;
     use C4::Utils::DataTables;
 
@@ -249,11 +248,11 @@ sub dt_build_query_dates {
     my @params;
     if ( $datefrom ) {
         $query .= " AND $field >= ? ";
-        push @params, C4::Dates->new($datefrom)->output('iso');
+        push @params, eval { output_pref( { dt => dt_from_string( $datefrom ), dateonly => 1, dateformat => 'iso' } ); };
     }
     if ( $dateto ) {
         $query .= " AND $field <= ? ";
-        push @params, C4::Dates->new($dateto)->output('iso');
+        push @params, eval { output_pref( { dt => dt_from_string( $dateto ), dateonly => 1, dateformat => 'iso' } ); };
     }
     return ( $query, \@params );
 }
@@ -264,21 +263,21 @@ sub dt_build_query_dates {
 
     This function takes a value and a list of parameters.
 
-    It calls dt_build_query_dates or dt_build_query_simple fonction of $type.
+    It calls dt_build_query_dates or dt_build_query_simple function of $type.
 
-    $type can be 'simple' or 'rage_dates'.
+    $type can contain 'simple' or 'range_dates'.
+    if $type is not matched it returns undef
 
 =cut
 sub dt_build_query {
     my ( $type, @params ) = @_;
-    given ( $type ) {
-        when ( /simple/ ) {
-            return dt_build_query_simple( @params );
-        }
-        when ( /range_dates/ ) {
-            return dt_build_query_dates( @params );
-        }
+    if ( $type =~ m/simple/ ) {
+        return dt_build_query_simple(@params);
+    }
+    elsif ( $type =~ m/range_dates/ ) {
+        return dt_build_query_dates(@params);
     }
+    return;
 }
 
 1;