fix weekdaysInMonth, thanks to jankowa. fix filters on aggregations

This commit is contained in:
Milan
2018-04-17 12:01:53 +02:00
parent 23d5261e57
commit 777a49c371
7 changed files with 63 additions and 33 deletions

View File

@@ -416,7 +416,7 @@ sub get_week_of_month_dates{
return undef if $frequency eq'';
return undef if $frequency==0;
my $start_dates=time::get_nth_weekday_in_month($start, $end, $week, $weekday-1);
my $start_dates=time::get_nth_weekday_in_month($start, $end, $week, $weekday);
if ((defined $nextDay) && ($nextDay>0)){
for (my $i=0;$i<@$start_dates;$i++){

View File

@@ -24,7 +24,7 @@ our @EXPORT_OK = qw(
date_cond time_cond check_date check_time check_datetime check_year_month
datetime_to_rfc822 get_datetime datetime_to_utc datetime_to_utc_datetime
get_duration get_duration_seconds
get_durations get_names get_all_names get_weekdays weekday_index
get_durations get_names get_all_names weekday_index
$names
);
@@ -86,24 +86,24 @@ our $weekday_index={
sub get_weekdays{
return{
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
'Mo'=>0,
'Tu'=>1,
'Di'=>1,
'We'=>2,
'Mi'=>2,
'Th'=>3,
'Do'=>3,
'Fr'=>4,
'Sa'=>5,
'Su'=>6,
'So'=>6
7 => 7,
'Mo'=>1,
'Tu'=>2,
'Di'=>2,
'We'=>3,
'Mi'=>3,
'Th'=>4,
'Do'=>4,
'Fr'=>5,
'Sa'=>6,
'Su'=>7,
'So'=>7
};
}
@@ -518,14 +518,15 @@ sub get_event_date{
my $datetime=time::time_to_datetime(time());
my $hour=(time::datetime_to_array($datetime))->[3];
#print STDERR "datetime=$datetime hour=$hour\n";
#today: between 0:00 and starting_hour show last day
if ($hour < $config->{date}->{day_starting_hour}){
my $date=time::datetime_to_array(time::add_hours_to_datetime($datetime,-24));
return $date->[0].'-'.$date->[1].'-'.$date->[2];
my $date=time::datetime_to_array(time::add_days_to_datetime($datetime,-1));
return join('-', ($date->[0], $date->[1], $date->[2]) );
}else{
#today: between starting_hour and end of day show current day
my $date=time::datetime_to_array(time::time_to_datetime(time()));
return $date->[0]."-".$date->[1]."-".$date->[2];
return join('-', ($date->[0], $date->[1], $date->[2]) );
}
}
@@ -559,15 +560,22 @@ sub get_datetime{
#get list of nth weekday in month from start to end
sub get_nth_weekday_in_month{
my $start=shift; # datetime string
my $end=shift; # datetime string
my $nth=shift; # every nth week of month
my $weekday=shift; # weekday [0..6,'Mo'-'Su','Mo'-'Fr']
my $start = shift; # datetime string
my $end = shift; # datetime string
my $nth = shift; # every nth week of month
my $weekday = shift; # weekday [1..7,'Mo'-'Su','Mo'-'Fr']
my $weekdays=time::get_weekdays();
$weekday=$weekdays->{$weekday+1};
return [] unless defined $start;
return [] unless defined $end;
return [] unless defined $nth;
return [] unless defined $weekday;
my $weekdays = time::get_weekdays();
return [] unless defined $weekdays->{$weekday};
$weekday = $weekdays->{$weekday};
my $dates=[];
if ($start=~/(\d\d\d\d)-(\d\d)-(\d\d)[ T](\d\d)\:(\d\d)/){
my $hour=int($4);
my $min=int($5);

View File

@@ -57,15 +57,31 @@ sub get_user{
# get all users
sub get_users{
my $config=shift;
my $config = shift;
my $condition = shift;
my @conditions=();
my @bind_values=();
for my $key ('name', 'email'){
my $value = $condition->{$key};
next unless defined $value;
next if $value eq '';
push @conditions, $key.'=?';
push @bind_values, $value;
}
my $conditions='';
$conditions=" where ".join(" and ",@conditions) if (scalar @conditions>0);
my $query=qq{
select id, name, full_name, email, disabled, modified_at, created_at
from calcms_users
$conditions
};
my $dbh=db::connect($config);
my $users=db::get($dbh, $query);
my $dbh = db::connect($config);
my $users = db::get($dbh, $query, \@bind_values);
return $users;
}
@@ -93,7 +109,7 @@ sub get_users_by_studio{
}
my $conditions='';
$conditions=" and ".join(" and ",@conditions) if (@conditions>0);
$conditions=" and ".join(" and ",@conditions) if (scalar @conditions>0);
my $query=qq{
select distinct(u.id), u.name, u.full_name
@@ -808,9 +824,11 @@ sub print_warn{
}
sub print_error{
my $message=shift;
print STDERR "ERROR:".$message."\n";
print '<div class="error" head>'
.'<span class="ui-icon ui-icon-alert" style="float:left"></span>&nbsp;'
.$_[0].
.$message.
'</div>'."\n";
}

View File

@@ -247,7 +247,7 @@ sub get_week_of_month_dates{
return undef if $frequency eq'';
return undef if $frequency==0;
my $start_dates=time::get_nth_weekday_in_month($start, $end, $week, $weekday-1);
my $start_dates=time::get_nth_weekday_in_month($start, $end, $week, $weekday);
my $results=[];

View File

@@ -31,8 +31,6 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
my %params = $cgi->Vars();
my $params = \%params;
#print STDERR Dumper($params);
my $config = config::get('config/config.cgi');
my $debug = $config->{system}->{debug};
my $mem_debug = $config->{system}->{debug_memory};
@@ -44,8 +42,11 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
$output_header .= "Content-type:text/html; charset=UTF-8;\n\n";
}
# $output_header.='<!DOCTYPE html>'."\n";
$params->{exclude_locations} = 1;
$params->{exclude_projects} = 1;
$params->{exclude_event_images} = 1;
# $output_header.='<!DOCTYPE html>'."\n";
my $request = {
url => $ENV{QUERY_STRING},
params => {
@@ -54,6 +55,7 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
},
};
$params = $request->{params}->{checked};
#print STDERR Dumper($params);
my $mem = 0;
log::init($request);

View File

@@ -104,6 +104,8 @@ project Corax
# limit creating comments in days before and after start of event
no_new_comments_before 10
no_new_comments_after 60
# hide_event_images 1
</permissions>
<access>

View File

@@ -747,7 +747,7 @@ a#calcms_search_show_details #plus{
#player{
border:0;
padding:0;
height:64px;
height:3rem;
}
#player:hover{
opacity:0.9;