#
# 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.07.00.049,
@ISA = qw(Exporter);
@EXPORT = qw(dt_build_orderby dt_build_having dt_get_params dt_build_query);
=head1 SYNOPSYS
- use CGI;
+ use CGI qw ( -utf8 );
use C4::Context;
use C4::Utils::DataTables;
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 );
}
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;