diff --git a/install/migrate.sql b/install/migrate.sql index 0bcbedb..d788558 100644 --- a/install/migrate.sql +++ b/install/migrate.sql @@ -353,3 +353,12 @@ update calcms_series set image = replace(image , '/agenda_files/media/images/', update calcms_series set image = replace(image , '/agenda_files/media/icons/', '') where image like '%/agenda_files/media/icons/%'; update calcms_series set image = replace(image , '/agenda_files/media/thumbs/', '') where image like '%/agenda_files/media/thumbs/%'; +-- add day of month to studio schedules +ALTER TABLE `calcms`.`calcms_studio_timeslot_schedule` +ADD COLUMN `period_type` VARCHAR(45) NOT NULL AFTER `end_date`, +ADD COLUMN `weekday` INT UNSIGNED NULL AFTER `period_type`, +ADD COLUMN `week_of_month` INT UNSIGNED NULL AFTER `weekday`, +ADD COLUMN `month` INT UNSIGNED NULL AFTER `week_of_month`, +CHANGE COLUMN `frequency` `frequency` INT UNSIGNED NULL ; + +update `calcms_studio_timeslot_schedule` set period_type = 'days' where period_type = ''; \ No newline at end of file diff --git a/lib/calcms/aggregator.pm b/lib/calcms/aggregator.pm index 20302d8..4034263 100644 --- a/lib/calcms/aggregator.pm +++ b/lib/calcms/aggregator.pm @@ -10,7 +10,6 @@ use calendar(); use project(); use Date::Calc; -#use base 'Exporter'; our @EXPORT_OK = qw(get_cache configure_cache put_cache get_list check_params); sub get_list($$) { diff --git a/lib/calcms/audio_recordings.pm b/lib/calcms/audio_recordings.pm index 033cbd1..f39904d 100644 --- a/lib/calcms/audio_recordings.pm +++ b/lib/calcms/audio_recordings.pm @@ -7,7 +7,6 @@ no warnings 'redefine'; use Data::Dumper; use db(); -#use base 'Exporter'; our @EXPORT_OK = qw(get_columns get); # columns: @@ -164,10 +163,9 @@ sub update($$) { sub insert ($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; - return undef unless defined $entry->{event_id}; - return undef unless defined $entry->{path}; + for ('project_id', 'studio_id', 'event_id', 'path') { + return undef unless defined $entry->{$_} + }; my $dbh = db::connect($config); $entry = { @@ -194,10 +192,9 @@ sub insert ($$) { sub delete ($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; - return undef unless defined $entry->{event_id}; - return undef unless defined $entry->{path}; + for ('project_id', 'studio_id', 'event_id', 'path') { + return undef unless defined $entry->{$_} + }; my $dbh = db::connect($config); my $query = qq{ diff --git a/lib/calcms/calendar.pm b/lib/calcms/calendar.pm index 0762fd1..0cb98cb 100644 --- a/lib/calcms/calendar.pm +++ b/lib/calcms/calendar.pm @@ -10,7 +10,6 @@ use Date::Calc(); use template(); use events(); -#use base 'Exporter'; our @EXPORT_OK = qw(init get_cached_or_render get render get_calendar_weeks configure_cache); sub init() { diff --git a/lib/calcms/comments.pm b/lib/calcms/comments.pm index 915e56d..e2780e9 100644 --- a/lib/calcms/comments.pm +++ b/lib/calcms/comments.pm @@ -11,7 +11,6 @@ use markup(); use template(); use time(); -#use base 'Exporter'; our @EXPORT_OK = qw(init get_cached_or_render get modify_results render configure_cache get_query get_by_event get_level get_events check insert set_lock_status set_news_status lock update_comment_count sort); diff --git a/lib/calcms/config.pm b/lib/calcms/config.pm index a50b9be..2358c6a 100644 --- a/lib/calcms/config.pm +++ b/lib/calcms/config.pm @@ -4,15 +4,10 @@ use strict; use warnings; no warnings 'redefine'; - use FindBin(); - -#use base 'Exporter'; our @EXPORT_OK = qw(get set); my $config = undef; - - sub get($) { my ($filename) = @_; return read_config($filename); diff --git a/lib/calcms/creole_wiki.pm b/lib/calcms/creole_wiki.pm index 71fe122..d9bbbb0 100644 --- a/lib/calcms/creole_wiki.pm +++ b/lib/calcms/creole_wiki.pm @@ -7,7 +7,6 @@ no warnings 'redefine'; use Data::Dumper; use markup(); -#use base 'Exporter'; our @EXPORT_OK = qw(extractEventFromWikiText removeMeta eventToWikiText extractMeta removeMeta metaToWiki); diff --git a/lib/calcms/db.pm b/lib/calcms/db.pm index 1e29eeb..75ab8f1 100644 --- a/lib/calcms/db.pm +++ b/lib/calcms/db.pm @@ -187,7 +187,7 @@ sub next_id ($$){ my $query = qq{ select max(id) id from $table - where 1 + where 1 }; my $results = get( $dbh, $query ); return $results->[0]->{id} + 1; @@ -200,7 +200,7 @@ sub get_max_id($$) { my $query = qq{ select max(id) id from $table - where 1 + where 1 }; my $results = get( $dbh, $query ); return $results->[0]->{id}; diff --git a/lib/calcms/eventOps.pm b/lib/calcms/eventOps.pm index 6036cc1..dbbf165 100644 --- a/lib/calcms/eventOps.pm +++ b/lib/calcms/eventOps.pm @@ -13,7 +13,6 @@ use studios(); use series_events(); use user_stats(); -#use base 'Exporter'; our @EXPORT_OK = qw( setAttributesFromSeriesTemplate setAttributesFromSchedule @@ -204,9 +203,7 @@ sub createEvent($$$) { my $user = $request->{user}; my $checklist = [ 'studio', 'user', 'create_events', 'studio_timeslots' ]; - if ( $action eq 'create_event_from_schedule' ) { - push @$checklist, 'schedule' if $action eq 'create_event_from_schedule'; - } + push @$checklist, 'schedule' if $action eq 'create_event_from_schedule'; my $start = $event->{start_date}, my $end = time::add_minutes_to_datetime( $event->{start_date}, $event->{duration} ); diff --git a/lib/calcms/event_history.pm b/lib/calcms/event_history.pm index 48fafea..4e0d3e1 100644 --- a/lib/calcms/event_history.pm +++ b/lib/calcms/event_history.pm @@ -6,7 +6,6 @@ no warnings 'redefine'; use Data::Dumper; -#use base 'Exporter'; our @EXPORT_OK = qw(get_columns get get_by_id insert insert_by_event_id delete); sub get_columns ($){ @@ -79,13 +78,11 @@ sub get ($$){ sub get_by_id($$) { my ($config, $id) = @_; my $dbh = db::connect($config); - my $query = qq{ select * from calcms_event_history where event_id=? }; - my $studios = db::get( $dbh, $query, [$id] ); return undef if ( @$studios != 1 ); return $studios->[0]; @@ -95,7 +92,6 @@ sub insert($$) { my ($config, $entry) = @_; $entry->{modified_at} = time::time_to_datetime( time() ); - $entry->{event_id} = $entry->{id} if ( defined $entry->{id} ) && ( !( defined $entry->{event_id} ) ); delete $entry->{id}; @@ -115,11 +111,9 @@ sub insert($$) { sub insert_by_event_id ($$){ my ($config, $options) = @_; - return undef unless defined $options->{project_id}; - return undef unless defined $options->{studio_id}; - return undef unless defined $options->{series_id}; - return undef unless defined $options->{event_id}; - return undef unless defined $options->{user}; + for ('project_id', 'studio_id', 'series_id', 'event_id', 'user') { + return undef unless defined $options->{$_} + }; my $sql = q{ select * from calcms_events diff --git a/lib/calcms/events.pm b/lib/calcms/events.pm index 55d5127..a9042bf 100644 --- a/lib/calcms/events.pm +++ b/lib/calcms/events.pm @@ -9,10 +9,8 @@ $Data::Dumper::Sortkeys=1; use MIME::Base64(); use Encode(); use Storable 'dclone'; - use DBI(); use template(); - use config(); use time(); use db(); @@ -22,7 +20,6 @@ use log(); use project(); use studios(); -#use base 'Exporter'; our @EXPORT_OK = qw( init get_cached_or_render @@ -184,12 +181,6 @@ sub modify_results ($$$$) { $result->{excerpt} = '' unless defined( $result->{excerpt} ); $result->{excerpt} = "lass dich ueberraschen" if ( $result->{excerpt} eq '' ); - - # $result->{excerpt} =markup::plain_to_xml($result->{excerpt}); - # $result->{title} =markup::plain_to_xml($result->{title}); - # $result->{series_name} =markup::plain_to_xml($result->{series_name}); - # $result->{program} =markup::plain_to_xml($result->{program}); - #print STDERR "created:$result->{created_at} modified:$result->{modified_at}\n"; $result->{modified_at} = time::datetime_to_rfc822( $result->{modified_at} ); if ( $result->{created_at} =~ /[1-9]/ ) { @@ -343,8 +334,6 @@ sub modify_results ($$$$) { } } - #$result->{'project_title'}=$project->{title} if (defined $project->{title} && $project->{title} ne ''); - for my $name ( keys %{ $config->{mapping}->{events} } ) { my $val = ''; if ( ( defined $name ) @@ -357,10 +346,6 @@ sub modify_results ($$$$) { } } - #for my $name (keys %{$config->{controllers}}){ - # $result->{"controller_$name"}=$config->{controllers}->{$name}; - #} - $previous_result = $result; $result->{ 'counter_' . $counter } = 1; @@ -642,8 +627,10 @@ sub set_listen_key{ sub set_upload_status($$){ my ($config, $event) = @_; - return undef unless defined $event->{event_id}; - return undef unless defined $event->{upload_status}; + for ('event_id', 'upload_status') { + return undef unless defined $event->{$_} + }; + my $bindValues = [ $event->{upload_status}, $event->{event_id}, $event->{upload_status} ]; my $query = qq{ @@ -655,9 +642,9 @@ sub set_upload_status($$){ my $recordings = db::put( $dbh, $query, $bindValues ); } -# returns all recordings for a event sub add_recordings($$$$) { my ($dbh, $config, $request, $events) = @_; + return $events unless defined $events; my $eventsById = { map { $_->{event_id} => $_ } @$events }; diff --git a/lib/calcms/help_texts.pm b/lib/calcms/help_texts.pm index f9f037c..2427c9a 100644 --- a/lib/calcms/help_texts.pm +++ b/lib/calcms/help_texts.pm @@ -10,7 +10,6 @@ use Data::Dumper; # columns: id, studio_id, series_id, # table, column, text -#use base 'Exporter'; our @EXPORT_OK = qw(get_columns get insert update delete); sub get_columns($) { diff --git a/lib/calcms/images.pm b/lib/calcms/images.pm index 4df699b..cfa89a0 100644 --- a/lib/calcms/images.pm +++ b/lib/calcms/images.pm @@ -6,9 +6,7 @@ no warnings 'redefine'; use config(); use template(); -use Data::Dumper; -#use base 'Exporter'; our @EXPORT_OK = qw(get insert update insert_or_update delete delete_files); #column 'created_at' will be set at insert diff --git a/lib/calcms/localization.pm b/lib/calcms/localization.pm index 760cc5f..0f1c53a 100644 --- a/lib/calcms/localization.pm +++ b/lib/calcms/localization.pm @@ -8,7 +8,6 @@ use Data::Dumper; use uac(); use user_settings(); -#use base 'Exporter'; our @EXPORT_OK = qw(get getJavascript); # get localisation @@ -46,17 +45,8 @@ sub get($$) { #get all comma separated po files for my $file ( split /\,/, $files ) { - - #read default language - #my $po_file=$config->{locations}->{admin_pot_dir}.'/en/'.$file.'.po'; - #$loc=read_po_file($po_file, $loc); - - #read selected language - #if($language ne 'en'){ my $po_file = $config->{locations}->{admin_pot_dir} . '/' . $language . '/' . $file . '.po'; $loc = read_po_file( $po_file, $loc ); - - #} } return $loc; } @@ -79,7 +69,6 @@ sub read_po_file($$) { while (<$file>) { my $line = $_; - #print STDERR $line; if ( $line =~ /^msgid\s*\"(.*)\"\s*$/ ) { $key = $1; $key =~ s/\'//g; diff --git a/lib/calcms/log.pm b/lib/calcms/log.pm index b4d15f1..696314a 100644 --- a/lib/calcms/log.pm +++ b/lib/calcms/log.pm @@ -4,7 +4,6 @@ use strict; use warnings; no warnings 'redefine'; -#use base 'Exporter'; our @EXPORT_OK = qw(error load_file save_file append_file); use config(); diff --git a/lib/calcms/markup.pm b/lib/calcms/markup.pm index 586c3fe..81190b3 100644 --- a/lib/calcms/markup.pm +++ b/lib/calcms/markup.pm @@ -14,7 +14,6 @@ use Text::Markdown(); use log(); -#use base 'Exporter'; our @EXPORT_OK = qw(fix_line_ends html_to_creole creole_to_html creole_to_plain plain_to_ical ical_to_plain ical_to_xml html_to_plain fix_utf8 uri_encode compress base26); diff --git a/lib/calcms/params.pm b/lib/calcms/params.pm index 57ba64d..c5fb725 100644 --- a/lib/calcms/params.pm +++ b/lib/calcms/params.pm @@ -1,5 +1,4 @@ package params; - use strict; use warnings; no warnings 'redefine'; @@ -7,7 +6,6 @@ no warnings 'redefine'; use Data::Dumper; use Apache2::Request(); -#use base 'Exporter'; our @EXPORT_OK = qw(get isJson); my $isJson = 0; diff --git a/lib/calcms/password_requests.pm b/lib/calcms/password_requests.pm index 0c0fe3c..40181c1 100644 --- a/lib/calcms/password_requests.pm +++ b/lib/calcms/password_requests.pm @@ -8,7 +8,6 @@ use Data::Dumper; use Session::Token(); # table: calcms_password_requests -#use base 'Exporter'; our @EXPORT_OK = qw(get insert delete get_columns); use mail; @@ -26,7 +25,6 @@ sub get ($$) { my ($config, $condition) = @_; my $dbh = db::connect($config); - my @conditions = (); my @bind_values = (); diff --git a/lib/calcms/playout.pm b/lib/calcms/playout.pm index 1bb4d55..06a774c 100644 --- a/lib/calcms/playout.pm +++ b/lib/calcms/playout.pm @@ -6,11 +6,11 @@ no warnings 'redefine'; use Data::Dumper; use Date::Calc(); + use db(); use time(); use series_events(); -#use base 'Exporter'; our @EXPORT_OK = qw(get_columns get sync); sub get_columns ($) { @@ -19,8 +19,6 @@ sub get_columns ($) { return db::get_columns_hash( $dbh, 'calcms_playout' ); } - - # get playout entries sub get_scheduled($$) { my ($config, $condition) = @_; @@ -127,8 +125,9 @@ sub get_scheduled($$) { # get playout entries sub get($$) { my ($config, $condition) = @_; - - return undef unless defined $condition->{studio_id}; + for ('studio_id') { + return undef unless defined $condition->{$_} + }; my $date_range_include = 0; $date_range_include = 1 @@ -227,11 +226,9 @@ sub get($$) { sub sync ($$) { my ($config, $options) = @_; - return undef unless defined $options->{project_id}; - return undef unless defined $options->{studio_id}; - return undef unless defined $options->{from}; - return undef unless defined $options->{till}; - return undef unless defined $options->{events}; + for ('project_id', 'studio_id', 'from', 'till', 'events') { + return undef unless defined $options->{$_} + }; my $project_id = $options->{project_id}; my $studio_id = $options->{studio_id}; diff --git a/lib/calcms/project.pm b/lib/calcms/project.pm index b3b819a..dc5fc45 100644 --- a/lib/calcms/project.pm +++ b/lib/calcms/project.pm @@ -12,7 +12,6 @@ use log(); use template(); use images(); -#use base 'Exporter'; our @EXPORT_OK = qw( check get_columns get insert delete get_date_range get_studios assign_studio unassign_studio is_studio_assigned get_studio_assignments @@ -73,7 +72,10 @@ sub get ($;$) { sub getImageById($$) { my ($config, $conditions) = @_; - return undef unless defined $conditions->{project_id}; + for ('project_id') { + return undef unless defined $conditions->{$_}; + }; + my $projects = project::get( $config, $conditions ); return undef if scalar(@$projects) != 1; return $projects->[0]->{image}; @@ -146,7 +148,9 @@ sub delete ($$) { sub get_studios($$) { my ($config, $options) = @_; - return undef unless defined $options->{project_id}; + for ('project_id') { + return undef unless defined $options->{$_} + }; my $project_id = $options->{project_id}; my $query = qq{ @@ -195,8 +199,9 @@ sub get_studio_assignments($$) { sub is_studio_assigned ($$) { my ($config, $entry) = @_; - return 0 unless defined $entry->{project_id}; - return 0 unless defined $entry->{studio_id}; + for ('project_id', 'studio_id') { + return 0 unless defined $entry->{$_} + }; my $project_id = $entry->{project_id}; my $studio_id = $entry->{studio_id}; @@ -218,8 +223,9 @@ sub is_studio_assigned ($$) { sub assign_studio($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; + for ('project_id', 'studio_id') { + return undef unless defined $entry->{$_} + }; my $project_id = $entry->{project_id}; my $studio_id = $entry->{studio_id}; @@ -236,8 +242,9 @@ sub assign_studio($$) { sub unassign_studio($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; + for ('project_id', 'studio_id') { + return undef unless defined $entry->{$_} + }; my $project_id = $entry->{project_id}; my $studio_id = $entry->{studio_id}; @@ -251,8 +258,9 @@ sub unassign_studio($$) { sub get_series ($$) { my ($config, $options) = @_; - return undef unless defined $options->{project_id}; - return undef unless defined $options->{studio_id}; + for ('project_id', 'studio_id') { + return undef unless defined $options->{$_} + }; my $project_id = $options->{project_id}; my $studio_id = $options->{studio_id}; @@ -308,9 +316,9 @@ sub get_series_assignments ($$) { sub is_series_assigned ($$) { my ($config, $entry) = @_; - return 0 unless defined $entry->{project_id}; - return 0 unless defined $entry->{studio_id}; - return 0 unless defined $entry->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return undef unless defined $entry->{$_} + }; my $project_id = $entry->{project_id}; my $studio_id = $entry->{studio_id}; @@ -333,9 +341,9 @@ sub is_series_assigned ($$) { sub assign_series($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; - return undef unless defined $entry->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return undef unless defined $entry->{$_} + }; my $project_id = $entry->{project_id}; my $studio_id = $entry->{studio_id}; @@ -356,9 +364,9 @@ sub assign_series($$) { sub unassign_series ($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; - return undef unless defined $entry->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return undef unless defined $entry->{$_} + }; my $project_id = $entry->{project_id}; my $studio_id = $entry->{studio_id}; diff --git a/lib/calcms/series.pm b/lib/calcms/series.pm index 03125ff..9885e63 100644 --- a/lib/calcms/series.pm +++ b/lib/calcms/series.pm @@ -5,11 +5,9 @@ use warnings; no warnings 'redefine'; use Data::Dumper; - use events(); use images(); -#use base 'Exporter'; our @EXPORT_OK = qw( get_columns get insert update delete get_users add_user remove_user @@ -125,8 +123,9 @@ sub get ($$) { sub insert ($$) { my ($config, $series) = @_; - return undef unless defined $series->{project_id}; - return undef unless defined $series->{studio_id}; + for ('project_id', 'studio_id') { + return undef unless defined $series->{$_} + }; my $project_id = $series->{project_id}; my $studio_id = $series->{studio_id}; @@ -162,9 +161,9 @@ sub insert ($$) { sub update ($$) { my ($config, $series) = @_; - return undef unless defined $series->{project_id}; - return undef unless defined $series->{studio_id}; - return undef unless defined $series->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return undef unless defined $series->{$_} + }; my $columns = series::get_columns($config); my $entry = {}; @@ -198,9 +197,9 @@ sub update ($$) { sub delete($$) { my ($config, $series) = @_; - return undef unless defined $series->{project_id}; - return undef unless defined $series->{studio_id}; - return undef unless defined $series->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return undef unless defined $series->{$_} + }; my $project_id = $series->{project_id}; my $studio_id = $series->{studio_id}; @@ -328,11 +327,9 @@ sub get_users ($$) { sub add_user ($$) { my ($config, $entry) = @_; - return unless defined $entry->{project_id}; - return unless defined $entry->{studio_id}; - return unless defined $entry->{series_id}; - return unless defined $entry->{user_id}; - return unless defined $entry->{user}; + for ('project_id', 'studio_id', 'series_id', 'user_id', 'user') { + return unless defined $entry->{$_} + }; my $query = qq{ select id @@ -358,9 +355,9 @@ sub add_user ($$) { sub remove_user ($$) { my ($config, $condition) = @_; - return unless defined $condition->{project_id}; - return unless defined $condition->{studio_id}; - return unless defined $condition->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return unless defined $condition->{$_} + }; my @conditions = (); my @bind_values = (); @@ -441,7 +438,6 @@ sub search_events ($$$) { #get events (only assigned ones) by project_id,studio_id,series_id, sub get_events ($$) { my ($config, $options) = @_; - return [] if defined( $options->{series_id} ) && ( $options->{series_id} <= 0 ); my @conditions = (); @@ -611,8 +607,9 @@ sub get_event ($$) { sub get_event_age($$) { my ($config, $options) = @_; - return undef unless defined $options->{project_id}; - return undef unless defined $options->{studio_id}; + for ('project_id', 'studio_id') { + return undef unless defined $options->{$_} + }; my @conditions = (); my @bind_values = (); @@ -694,9 +691,9 @@ sub is_event_older_than_days ($$) { sub get_next_episode($$) { my ($config, $options) = @_; - return 0 unless defined $options->{project_id}; - return 0 unless defined $options->{studio_id}; - return 0 unless defined $options->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return 0 unless defined $options->{$_} + }; #return if episodes should not be counted for this series my $query = q{ @@ -733,9 +730,9 @@ sub get_next_episode($$) { sub get_images ($$) { my ($config, $options) = @_; - return undef unless defined $options->{project_id}; - return undef unless defined $options->{studio_id}; - return undef unless defined $options->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return undef unless defined $options->{$_} + }; #get images from all events of the series my $dbh = db::connect($config); @@ -793,10 +790,9 @@ sub get_images ($$) { sub assign_event($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; - return undef unless defined $entry->{series_id}; - return undef unless defined $entry->{event_id}; + for ('project_id', 'studio_id', 'series_id', 'event_id') { + return undef unless defined $entry->{$_} + }; $entry->{manual} = 0 unless ( defined $entry->{manual} ) && ( $entry->{manual} eq '1' ); my $conditions = ''; @@ -835,10 +831,9 @@ sub assign_event($$) { sub unassign_event($$) { my ($config, $entry) = @_; - return unless defined $entry->{project_id}; - return unless defined $entry->{studio_id}; - return unless defined $entry->{series_id}; - return unless defined $entry->{event_id}; + for ('project_id', 'studio_id', 'series_id', 'event_id') { + return undef unless defined $entry->{$_} + }; my $conditions = ''; $conditions = 'and manual=1' if ( defined $entry->{manual} ) && ( $entry->{manual} eq '1' ); @@ -908,11 +903,10 @@ sub set_event_ids ($$$$$) { my ($config, $project_id, $studio_id, $serie, $event_ids) = @_; my $serie_id = $serie->{series_id}; - return unless defined $project_id; - return unless defined $studio_id; - return unless defined $serie_id; - return unless defined $event_ids; - + for ('project_id', 'studio_id', 'series_id', 'event_id') { + return unless defined $serie->{$_} + }; + #make lookup table from events my $event_id_hash = { map { $_ => 1 } @$event_ids }; @@ -933,7 +927,6 @@ sub set_event_ids ($$$$$) { #insert events from list, not found in db for my $event_id (@$event_ids) { - #print "insert event_id $event_id\n"; series::assign_event( $config, { @@ -947,7 +940,6 @@ sub set_event_ids ($$$$$) { #delete events found in db, but not in list for my $event_id ( keys %$found ) { - #print "delete event_id $event_id\n"; series::unassign_event( $config, @@ -971,10 +963,10 @@ sub can_user_update_events ($$) { my $config = $request->{config}; my $permissions = $request->{permissions}; + for ('project_id', 'studio_id', 'series_id') { + return 0 unless defined $options->{$_} + }; return 0 unless defined $request->{user}; - return 0 unless defined $options->{project_id}; - return 0 unless defined $options->{studio_id}; - return 0 unless defined $options->{series_id}; return 1 if ( defined $permissions->{update_event_of_others} ) && ( $permissions->{update_event_of_others} eq '1' ); return 1 if ( defined $permissions->{is_admin} ) && ( $permissions->{is_admin} eq '1' ); @@ -991,10 +983,10 @@ sub can_user_create_events ($$) { my $config = $request->{config}; my $permissions = $request->{permissions}; + for ('project_id', 'studio_id', 'series_id') { + return 0 unless defined $options->{$_} + }; return 0 unless defined $request->{user}; - return 0 unless defined $options->{project_id}; - return 0 unless defined $options->{studio_id}; - return 0 unless defined $options->{series_id}; return 1 if ( defined $permissions->{create_event} ) && ( $permissions->{create_event} eq '1' ); return 1 if ( defined $permissions->{is_admin} ) && ( $permissions->{is_admin} eq '1' ); @@ -1009,9 +1001,9 @@ sub is_series_assigned_to_user ($$) { my $config = $request->{config}; my $permissions = $request->{permissions}; - return 0 unless defined $options->{project_id}; - return 0 unless defined $options->{studio_id}; - return 0 unless defined $options->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return 0 unless defined $options->{$_} + }; return 0 unless defined $request->{user}; my $series_users = series::get_users( @@ -1034,11 +1026,10 @@ sub is_event_assigned_to_user ($$) { my $config = $request->{config}; - return "missing user" unless defined $request->{user}; - return "missing project_id" unless defined $options->{project_id}; - return "missing studio_id" unless defined $options->{studio_id}; - return "missing series_id" unless defined $options->{series_id}; - return "missing event_id" unless defined $options->{event_id}; + for ('project_id', 'studio_id', 'series_id', 'event_id') { + return "missing $_" unless defined $options->{$_} + }; + return "missing user" unless defined $request->{user}; #check roles my $user_studios = uac::get_studios_by_user( @@ -1081,9 +1072,9 @@ sub is_event_assigned_to_user ($$) { sub get_rebuilt_episodes ($$) { my ($config, $options) = @_; - return "missing project_id" unless defined $options->{project_id}; - return "missing studio_id" unless defined $options->{studio_id}; - return "missing series_id" unless defined $options->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return undef unless defined $options->{$_} + }; # ignore project and studio as series can be used in multiple studios my $events = series::get_events( @@ -1151,10 +1142,9 @@ sub get_event_key ($) { sub update_recurring_events ($$) { my ($config, $options) = @_; - return "missing project_id" unless defined $options->{project_id}; - return "missing studio_id" unless defined $options->{studio_id}; - return "missing series_id" unless defined $options->{series_id}; - return "missing event_id" unless defined $options->{event_id}; + for ('project_id', 'studio_id', 'series_id', 'event_id') { + return "missing $_" unless defined $options->{$_}; + }; my $events = series::get_events( $config, @@ -1221,10 +1211,9 @@ sub update_recurring_events ($$) { sub update_recurring_event($$) { my ($config, $event) = @_; - return undef unless defined $event->{event_id}; - return undef unless defined $event->{recurrence}; - return undef unless defined $event->{recurrence_count}; - return undef unless defined $event->{rerun}; + for ('event_id', 'recurrence', 'recurrence_count', 'rerun') { + return undef unless defined $event->{$_} + }; return unless $event->{event_id} =~ /^\d+$/; return unless $event->{recurrence} =~ /^\d+$/; diff --git a/lib/calcms/series_dates.pm b/lib/calcms/series_dates.pm index cd64b09..d7be3de 100644 --- a/lib/calcms/series_dates.pm +++ b/lib/calcms/series_dates.pm @@ -6,6 +6,7 @@ no warnings 'redefine'; use Data::Dumper; use Date::Calc(); + use time(); use db(); use log(); @@ -16,7 +17,6 @@ use series_schedule(); # table: calcms_series_dates # columns: id, studio_id, series_id, start(datetime), end(datetime) # TODO: delete column schedule_id -#use base 'Exporter'; our @EXPORT_OK = qw(get_columns get insert update delete get_dates get_series); sub get_columns ($) { @@ -108,10 +108,9 @@ sub get ($;$) { sub is_event_scheduled($$) { my ($request, $options) = @_; - return 0 unless defined $options->{project_id}; - return 0 unless defined $options->{studio_id}; - return 0 unless defined $options->{series_id}; - return 0 unless defined $options->{start_at}; + for ('project_id', 'studio_id', 'series_id', 'start_at') { + return 0 unless defined $options->{$_} + }; my $config = $request->{config}; my $schedules = series_dates::get( @@ -281,9 +280,9 @@ sub addSeriesScheduleAttributes ($$) { sub update($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; - return undef unless defined $entry->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return undef unless defined $entry->{$_} + }; my $dbh = db::connect($config); @@ -350,7 +349,6 @@ sub update($$) { $j++; } } - #print STDERR "$i series_dates updates\n"; return $j . " dates out of studio times, " . $i; } @@ -457,8 +455,6 @@ sub get_dates($$$$) { my @start_date = ( $start[0], $start[1], $start[2] ); my $start_time = sprintf( '%02d:%02d:%02d', $start[3], $start[4], $start[5] ); - #print STDERR "$start_datetime,$end_date,$duration,$frequency\n"; - #return on single date my $date = {}; $date->{start} = sprintf( "%04d-%02d-%02d", @start_date ) . ' ' . $start_time; @@ -505,9 +501,9 @@ sub get_dates($$$$) { sub delete ($$) { my ($config, $entry) = @_; - return unless defined $entry->{project_id}; - return unless defined $entry->{studio_id}; - return unless defined $entry->{series_id}; + for ('project_id', 'studio_id', 'series_id') { + return unless defined $entry->{$_} + }; my $dbh = db::connect($config); @@ -525,10 +521,9 @@ sub delete ($$) { sub getDatesWithoutEvent ($$) { my ($config, $options) = @_; - return unless defined $options->{project_id}; - return unless defined $options->{studio_id}; - return unless defined $options->{from}; - return unless defined $options->{till}; + for ('project_id', 'studio_id', 'form', 'till') { + return unless defined $options->{$_} + }; my $dbh = db::connect($config); my $cond = $options->{series_id} ? 'and sd.series_id = ?' : ''; diff --git a/lib/calcms/series_events.pm b/lib/calcms/series_events.pm index 0f3437c..2434567 100644 --- a/lib/calcms/series_events.pm +++ b/lib/calcms/series_events.pm @@ -6,8 +6,8 @@ no warnings 'redefine'; use Data::Dumper; use Date::Calc; -use markup(); +use markup(); use db(); use log(); use time(); @@ -40,7 +40,9 @@ sub get_content_columns($) { # all changed columns are returned for history handling sub save_content($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{id}; + for ('id') { + return undef unless defined $entry->{$_} + }; for my $attr ( keys %$entry ) { next unless defined $entry->{$attr}; @@ -96,8 +98,9 @@ sub save_content($$) { sub set_episode{ my ($config, $entry) = @_; - return undef unless defined $entry->{id}; - return undef unless defined $entry->{episode}; + for ('id', 'episode') { + return undef unless defined $entry->{$_} + }; my $query = qq{ update calcms_events @@ -120,9 +123,9 @@ sub set_episode{ sub save_event_time($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{id}; - return undef unless defined $entry->{duration}; - return undef unless defined $entry->{start_date}; + for ('id', 'duration', 'start_date') { + return undef unless defined $entry->{$_} + }; my $dbh = db::connect($config); my $event = { @@ -161,7 +164,6 @@ sub save_event_time($$) { where id=? }; push @$bind_values, $event->{id}; - db::put( $dbh, $update_sql, $bind_values ); return $event; } @@ -169,13 +171,11 @@ sub save_event_time($$) { sub set_playout_status ($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; - return undef unless defined $entry->{start}; - return undef unless defined $entry->{playout}; + for ('project_id', 'studio_id', 'start', 'playout') { + return undef unless defined $entry->{$_} + }; my $dbh = db::connect($config); - # check if event is assigned to project and studio my $sql = qq{ select se.event_id event_id @@ -206,10 +206,9 @@ sub set_playout_status ($$) { sub is_event_assigned($$) { my ($config, $entry) = @_; - return 0 unless defined $entry->{project_id}; - return 0 unless defined $entry->{studio_id}; - return 0 unless defined $entry->{series_id}; - return 0 unless defined $entry->{event_id}; + for ('project_id', 'studio_id', 'series_id', 'event_id') { + return 0 unless defined $entry->{$_} + }; my $dbh = db::connect($config); @@ -227,11 +226,9 @@ sub is_event_assigned($$) { sub delete_event ($$) { my ($config, $entry) = @_; - return undef unless defined $entry->{project_id}; - return undef unless defined $entry->{studio_id}; - return undef unless defined $entry->{series_id}; - return undef unless defined $entry->{event_id}; - return undef unless defined $entry->{user}; + for ('project_id', 'studio_id', 'series_id', 'event_id', 'user') { + return undef unless defined $entry->{$_} + }; #is event assigned to project, studio and series? unless ( is_event_assigned( $config, $entry ) == 1 ) { @@ -404,16 +401,16 @@ sub check_permission($$) { sub insert_event ($$) { my ($config, $options) = @_; + for ('project_id', 'studio', 'serie', 'event', 'user') { + return 0 unless defined $options->{$_} + }; + my $project_id = $options->{project_id}; my $studio = $options->{studio}; my $serie = $options->{serie}; my $params = $options->{event}; my $user = $options->{user}; - return 0 unless defined $studio; - return 0 unless defined $serie; - return 0 unless defined $params; - return 0 unless defined $user; return 0 unless defined $studio->{location}; my $projects = project::get( $config, { project_id => $project_id } ); @@ -427,7 +424,6 @@ sub insert_event ($$) { location => $studio->{location}, # location from studio }; - #print '
';
     $event = series_events::add_event_dates( $config, $event, $params );
 
     #get event content from series
diff --git a/lib/calcms/series_schedule.pm b/lib/calcms/series_schedule.pm
index 21ee8c5..f94e2f9 100644
--- a/lib/calcms/series_schedule.pm
+++ b/lib/calcms/series_schedule.pm
@@ -18,7 +18,6 @@ use series_dates();
 # month
 # nextDay (add 24 hours to start)
 
-#use base 'Exporter';
 our @EXPORT_OK = qw(get_columns get insert update delete);
 
 sub get_columns ($) {
@@ -99,11 +98,9 @@ sub get($$) {
 
 sub insert($$) {
     my ($config, $entry) = @_;
-
-    return undef unless defined $entry->{project_id};
-    return undef unless defined $entry->{studio_id};
-    return undef unless defined $entry->{series_id};
-    return undef unless defined $entry->{start};
+    for ('project_id', 'studio_id', 'series_id', 'start') {
+        return undef unless defined $entry->{$_}
+    };
     my $dbh = db::connect($config);
     return db::insert( $dbh, 'calcms_series_schedule', $entry );
 }
@@ -112,11 +109,10 @@ sub insert($$) {
 sub update($$) {
     my ($config, $entry) = @_;
 
-    return undef unless defined $entry->{project_id};
-    return undef unless defined $entry->{studio_id};
-    return undef unless defined $entry->{series_id};
-    return undef unless defined $entry->{schedule_id};
-    return undef unless defined $entry->{start};
+    for ('project_id', 'studio_id', 'series_id', 'start', 'schedule_id') {
+        return undef unless defined $entry->{$_}
+    };
+
     $entry->{nextDay} = 0 unless defined $entry->{nextDay};
 
     $entry->{id} = $entry->{schedule_id};
@@ -145,10 +141,9 @@ sub update($$) {
 sub delete($$) {
     my ($config, $entry) = @_;
 
-    return undef unless defined $entry->{project_id};
-    return undef unless defined $entry->{studio_id};
-    return undef unless defined $entry->{series_id};
-    return undef unless defined $entry->{schedule_id};
+    for ('project_id', 'studio_id', 'series_id', 'schedule_id') {
+        return undef unless defined $entry->{$_}
+    };
 
     my $dbh = db::connect($config);
 
diff --git a/lib/calcms/startup.pl b/lib/calcms/startup.pl
index d1f5914..b59bf7b 100644
--- a/lib/calcms/startup.pl
+++ b/lib/calcms/startup.pl
@@ -20,5 +20,8 @@ use time();
 use db();
 use template();
 
+# build compile check include list: 
+# ls -1 lib/calcms/*.pm | perl -ne 'if (/([^\/]+).pm/){ print "use $1(); "}'
+
 #do not delete last line!
 return 1;
diff --git a/lib/calcms/studio_timeslot_dates.pm b/lib/calcms/studio_timeslot_dates.pm
index 6863aef..d4867e8 100644
--- a/lib/calcms/studio_timeslot_dates.pm
+++ b/lib/calcms/studio_timeslot_dates.pm
@@ -4,7 +4,6 @@ use strict;
 use warnings;
 no warnings 'redefine';
 
-use Data::Dumper;
 use Date::Calc();
 use time();
 
@@ -12,8 +11,7 @@ use time();
 # table:   calcms_studio_timeslot_dates
 # columns: id, studio_id, start(datetime), end(datetime)
 # TODO: delete column schedule_id
-#use base 'Exporter';
-our @EXPORT_OK   = qw(get_columns get insert update delete get_dates);
+our @EXPORT_OK = qw(get_columns get insert update delete get_dates);
 
 sub get_columns ($){
     my ($config) = @_;
@@ -124,34 +122,37 @@ sub update {
     my $day_start = $config->{date}->{day_starting_hour};
 
     #get the schedule with schedule id ordered by date
-    my $schedules = studio_timeslot_schedule::get(
-        $config,
-        {
-            schedule_id => $entry->{schedule_id}
-        }
+    my $schedules = studio_timeslot_schedule::get($config,
+        {schedule_id => $entry->{schedule_id}}
     );
 
     #add scheduled dates
     my $i     = 0;
     my $dates = {};
     for my $schedule (@$schedules) {
-
-        #calculate dates from start to end_date
-        my $dateList = get_dates( $schedule->{start}, $schedule->{end}, $schedule->{end_date}, $schedule->{frequency} );
+        my $dateList;
+        if ($schedule->{period_type} eq 'days') {
+            #calculate dates from start to end_date
+            $dateList = get_dates($schedule->{start}, $schedule->{end}, $schedule->{end_date}, $schedule->{frequency});
+        } elsif ($schedule->{period_type} eq 'week_of_month') {
+            my $timezone = $config->{date}->{time_zone};
+            $dateList = get_week_of_month_dates($timezone,
+                $schedule->{start},   $schedule->{end},   $schedule->{end_date},
+                $schedule->{week_of_month}, $schedule->{weekday}, $schedule->{month},
+                $schedule->{nextDay}
+            );
+        }
 
         for my $date (@$dateList) {
-            #set studio i from
-            $date->{project_id}                             = $schedule->{project_id};
-            $date->{studio_id}                              = $schedule->{studio_id};
-            $date->{schedule_id}                            = $schedule->{schedule_id};
-            $dates->{ $date->{start} . $date->{studio_id} } = $date;
+            $date->{project_id}  = $schedule->{project_id};
+            $date->{studio_id}   = $schedule->{studio_id};
+            $date->{schedule_id} = $schedule->{schedule_id};
+            $dates->{$date->{start} . $date->{studio_id}} = $date;
         }
     }
 
-    for my $date ( keys %$dates ) {
+    for my $date (sort keys %$dates) {
         my $timeslot_date = $dates->{$date};
-
-        #insert date
         my $entry = {
             project_id  => $timeslot_date->{project_id},
             studio_id   => $timeslot_date->{studio_id},
@@ -159,9 +160,9 @@ sub update {
             start       => $timeslot_date->{start},
             end         => $timeslot_date->{end},
         };
-        $entry->{start_date} = time::add_hours_to_datetime( $entry->{start}, -$day_start );
-        $entry->{end_date}   = time::add_hours_to_datetime( $entry->{end},   -$day_start );
-        db::insert( $dbh, 'calcms_studio_timeslot_dates', $entry );
+        $entry->{start_date} = time::add_hours_to_datetime($entry->{start}, -$day_start);
+        $entry->{end_date}   = time::add_hours_to_datetime($entry->{end},   -$day_start);
+        db::insert($dbh, 'calcms_studio_timeslot_dates', $entry);
         $i++;
     }
     return $i;
@@ -196,7 +197,6 @@ sub get_dates {
 
     my $dates = [];
     return $dates if ( $date->{end} le $date->{start} );
-
     return $dates if ( $stop_date lt $end_date );
 
     my $j = Date::Calc::Delta_Days( @start_date, @stop_date );
@@ -219,21 +219,19 @@ sub get_dates {
             my $start_date = sprintf( "%04d-%02d-%02d", @start_date );
             my @next_date = Date::Calc::Add_Delta_Days( $start[0], $start[1], $start[2], $i + 1 );
             my $next_date = sprintf( "%04d-%02d-%02d", @next_date );
-            push @$dates,
-              {
+            push @$dates, {
                 start => $start_date . ' 00:00:00',
                 end   => $next_date . ' 00:00:00',
-              };
-            last if ( $c > 1000 );
+            };
+            last if $c > 1000;
             $c++;
         }
 
         #end day
-        push @$dates,
-          {
+        push @$dates, {
             start => $end_date . ' 00:00:00',
             end   => $end_date . ' ' . $end_time,
-          } if ( $end_time ne '00:00:00' );
+        } if $end_time ne '00:00:00';
         return $dates;
     }
 
@@ -247,30 +245,73 @@ sub get_dates {
 
         my $start_date = sprintf( "%04d-%02d-%02d", @start_date );
         my $end_date   = sprintf( "%04d-%02d-%02d", @end_date );
-        push @$dates,
-          {
+        push @$dates, {
             start => $start_date . ' ' . $start_time,
             end   => $end_date . ' ' . $end_time,
-          };
-        last if ( $c > 1000 );
+        };
+        last if $c > 1000;
         $c++;
     }
     return $dates;
 }
 
+# based on series_dates but with (timezone, start, end) instead of (start, duration)
+sub get_week_of_month_dates ($$$$$$$$) {
+    my ($timezone, $start, $end, $end_date, $week, $weekday, $frequency, $nextDay) = @_;
+    #datetime, datetime, date, every nth week of month, weekday [1..7], every 1st,2nd,3th time, add 24 hours to start, (for night hours at last weekday of month)
+
+    return undef if $timezone eq '';
+    return undef if $start eq '';
+    return undef if $end eq '';
+    return undef if $end_date eq '';
+    return undef if $week eq '';
+    return undef if $weekday eq '';
+    return undef if $frequency eq '';
+    return undef if $frequency == 0;
+
+    my $start_dates = time::get_nth_weekday_in_month($start, $end_date, $week, $weekday);
+
+    if (defined $nextDay && $nextDay > 0) {
+        for (my $i = 0; $i < @$start_dates; $i++) {
+            $start_dates->[$i] = time::add_hours_to_datetime($start_dates->[$i], 24);
+        }
+    }
+
+    my $results = [];
+    my $duration = time::get_duration($start, $end, $timezone);
+    my $c = -1;
+    for my $start_datetime (@$start_dates) {
+        $c++;
+        my @start = @{ time::datetime_to_array($start_datetime) };
+        next unless @start >= 6;
+        next if ($c % $frequency) != 0;
+        my @end_datetime = Date::Calc::Add_Delta_DHMS(
+            $start[0], $start[1], $start[2],    # start date
+            $start[3], $start[4], $start[5],    # start time
+            0, 0, $duration, 0                  # delta days, hours, minutes, seconds
+        );
+        my $end_datetime = time::array_to_datetime( \@end_datetime );
+        push @$results, {
+            start => $start_datetime,
+            end   => $end_datetime
+        };
+    }
+    return $results;
+}
+
 #remove all studio_timeslot_dates for studio_id and schedule_id
 sub delete {
     my ($config, $entry) = @_;
 
-    return unless defined $entry->{project_id};
-    return unless defined $entry->{studio_id};
-    return unless defined $entry->{schedule_id};
+    for ('project_id', 'studio_id', 'schedule_id') {
+        return unless defined $entry->{$_}
+    };
 
     my $dbh = db::connect($config);
 
     my $query = qq{
-		delete 
-		from calcms_studio_timeslot_dates 
+		delete
+		from calcms_studio_timeslot_dates
         where schedule_id=?
 	};
     my $bind_values = [ $entry->{schedule_id} ];
@@ -286,10 +327,9 @@ sub can_studio_edit_events {
     my @conditions  = ();
     my @bind_values = ();
 
-    #return 0 unless defined $condition->{project_id};
-    return 0 unless defined $condition->{studio_id};
-    return 0 unless defined $condition->{start};
-    return 0 unless defined $condition->{end};
+    for ('studio_id', 'start', 'end') {
+       return 0 unless defined $condition->{$_}
+    };
 
     if ( ( defined $condition->{project_id} ) && ( $condition->{project_id} ne '' ) ) {
         push @conditions,  'project_id=?';
@@ -332,8 +372,6 @@ sub can_studio_edit_events {
         if (   ( $condition->{start} ge $timeslot->{start} )
             && ( $condition->{end} le $timeslot->{end} ) )
         {
-            #print STDERR "($condition->{start} ge $timeslot->{start}) ".($condition->{start} ge $timeslot->{start});
-            #print STDERR "($condition->{end}   le $timeslot->{end}) ".($condition->{end}   le $timeslot->{end});
             return 1;
         }
     }
@@ -349,10 +387,9 @@ sub getMergedDays {
     my @conditions  = ();
     my @bind_values = ();
 
-    #return 0 unless defined $condition->{project_id};
-    return 0 unless defined $condition->{studio_id};
-    return 0 unless defined $condition->{start};
-    return 0 unless defined $condition->{end};
+    for ('studio_id', 'start', 'end') {
+        return 0 unless defined $condition->{$_}
+    };
 
     if ( ( defined $condition->{project_id} ) && ( $condition->{project_id} ne '' ) ) {
         push @conditions,  'project_id=?';
diff --git a/lib/calcms/studio_timeslot_schedule.pm b/lib/calcms/studio_timeslot_schedule.pm
index 5d30f86..5b9a81b 100644
--- a/lib/calcms/studio_timeslot_schedule.pm
+++ b/lib/calcms/studio_timeslot_schedule.pm
@@ -10,7 +10,6 @@ use studio_timeslot_dates();
 # table:   calcms_studio_timeslot_schedule
 # columns: id, project_id, studio_id, start(datetime), end(datetime), end_date(date),
 #          frequency(days), duration(minutes), create_events(days), publish_events(days)
-#use base 'Exporter';
 our @EXPORT_OK   = qw(get_columns get insert update delete);
 
 sub get_columns($) {
@@ -63,11 +62,9 @@ sub get($$) {
 sub insert($$) {
     my ($config, $entry) = @_;
 
-	return unless defined $entry->{project_id};
-	return unless defined $entry->{studio_id};
-	return unless defined $entry->{start};
-	return unless defined $entry->{end};
-	return unless defined $entry->{frequency};
+    for ('project_id', 'studio_id', 'start', 'end') {
+        return unless defined $entry->{$_}
+    };
 
 	my $dbh = db::connect($config);
 	return db::insert( $dbh, 'calcms_studio_timeslot_schedule', $entry );
@@ -77,12 +74,9 @@ sub insert($$) {
 sub update($$) {
     my ($config, $entry) = @_;
 
-	return unless defined $entry->{project_id};
-	return unless defined $entry->{studio_id};
-	return unless defined $entry->{schedule_id};
-	return unless defined $entry->{start};
-	return unless defined $entry->{end};
-	return unless defined $entry->{frequency};
+    for ('project_id', 'studio_id', 'schedule_id', 'start', 'end') {
+        return unless defined $entry->{$_}
+    };
 
 	$entry->{id} = $entry->{schedule_id};
 	delete $entry->{schedule_id};
@@ -100,8 +94,6 @@ sub update($$) {
 	};
 	db::put( $dbh, $query, \@bind_values );
 
-	#print "done\n";
-
 	$entry->{schedule_id} = $entry->{id};
 	delete $entry->{id};
 
@@ -111,7 +103,9 @@ sub update($$) {
 sub delete ($$){
     my ($config, $entry) = @_;
 
-	return unless defined $entry->{schedule_id};
+    for ('schedule_id') {
+        return unless defined $entry->{$_}
+    };
 
 	my $dbh = db::connect($config);
 
diff --git a/lib/calcms/studios.pm b/lib/calcms/studios.pm
index 0ddbaa5..dad6522 100644
--- a/lib/calcms/studios.pm
+++ b/lib/calcms/studios.pm
@@ -7,7 +7,6 @@ no warnings 'redefine';
 use Data::Dumper;
 use images();
 
-#use base 'Exporter';
 our @EXPORT_OK = qw(get_columns get get_by_id insert update delete check check_studio);
 
 sub get_columns($) {
@@ -74,8 +73,9 @@ sub get($;$) {
 sub getImageById($$) {
     my ($config, $conditions) = @_;
 
-    return undef unless defined $conditions->{project_id};
-    return undef unless defined $conditions->{studio_id};
+    for ('project_id', 'studio_id') {
+        return undef unless defined $conditions->{$_}
+    };
     my $studios = studios::get( $config, $conditions );
     return undef if scalar(@$studios) != 1;
     return $studios->[0]->{image};
diff --git a/lib/calcms/tags.pm b/lib/calcms/tags.pm
index e4b4807..8f27d9b 100644
--- a/lib/calcms/tags.pm
+++ b/lib/calcms/tags.pm
@@ -4,8 +4,6 @@ use strict;
 use warnings;
 no warnings 'redefine';
 use Data::Dumper;
-
-#use base 'Exporter';
 our @EXPORT_OK   = qw(get_tags);
 
 sub get_tags($) {
diff --git a/lib/calcms/template.pm b/lib/calcms/template.pm
index ee5eeaa..7172ed0 100644
--- a/lib/calcms/template.pm
+++ b/lib/calcms/template.pm
@@ -10,7 +10,6 @@ use HTML::Template::Compiled();
 use HTML::Template::Compiled::Plugin::XMLEscape();
 use HTML::Template::Compiled::Plugin::Hyphen();
 
-#use HTML::Template::JIT();
 use JSON();
 use Cwd();
 use Digest::MD5 qw(md5_hex);
@@ -19,7 +18,6 @@ use params();
 use project();
 use log();
 
-#use base 'Exporter';
 our @EXPORT_OK = qw(check process exit_on_missing_permission clear_cache);
 
 # TODO:config
diff --git a/lib/calcms/time.pm b/lib/calcms/time.pm
index dfd90b8..b222fe3 100644
--- a/lib/calcms/time.pm
+++ b/lib/calcms/time.pm
@@ -14,7 +14,6 @@ use Data::Dumper;
 
 use config();
 
-#use base 'Exporter';
 our @EXPORT_OK = qw(
   format_datetime format_time
   date_format time_format
@@ -164,7 +163,6 @@ sub format_time($) {
 sub datetime_to_time ($){
     my $datetime = $_[0];
 
-    #	print $datetime."\n";
     if ( $datetime =~ /(\d\d\d\d)\-(\d+)\-(\d+)[T\s](\d+)\:(\d+)(\:(\d+))?/ ) {
         my $year   = $1;
         my $month  = $2 - 1;
@@ -548,7 +546,6 @@ 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_days_to_datetime( $datetime, -1 ) );
diff --git a/lib/calcms/uac.pm b/lib/calcms/uac.pm
index c4d158c..516b354 100644
--- a/lib/calcms/uac.pm
+++ b/lib/calcms/uac.pm
@@ -15,7 +15,6 @@ use studios();
 use user_settings();
 use user_default_studios();
 
-#use base 'Exporter';
 our @EXPORT_OK = qw(
   get_user get_users update_user insert_user delete_user
   get_roles insert_role update_role  get_role_columns
@@ -404,10 +403,7 @@ sub get_user_roles($$) {
     my $admin_roles = get_admin_user_roles( $config, $condition );
 
     #add admin roles to user roles
-    my @user_roles = ( @$admin_roles, @$user_roles );
-    $user_roles = \@user_roles;
-
-    return $user_roles;
+    return [@$admin_roles, @$user_roles];
 }
 
 #return admin user roles for given conditions: project_id, studio_id, user, user_id
@@ -528,10 +524,9 @@ sub get_role_id ($$) {
 sub assign_user_role($$) {
     my ($config, $options) = @_;
 
-    return undef unless defined $options->{project_id};
-    return undef unless defined $options->{studio_id};
-    return undef unless defined $options->{user_id};
-    return undef unless defined $options->{role_id};
+    for ('project_id', 'studio_id', 'user_id', 'role_id') {
+        return undef unless defined $options->{$_}
+    }
 
     #return if already exists
     my $query = qq{
@@ -560,10 +555,9 @@ sub assign_user_role($$) {
 sub remove_user_role($$) {
     my ($config, $options) = @_;
 
-    return undef unless defined $options->{project_id};
-    return undef unless defined $options->{studio_id};
-    return undef unless defined $options->{user_id};
-    return undef unless defined $options->{role_id};
+    for ('project_id', 'studio_id', 'user_id', 'role_id') {
+        return undef unless defined $options->{$_}
+    }
 
     my $query = qq{
 		delete
@@ -583,20 +577,17 @@ sub is_user_assigned_to_studio ($$) {
     my ($request, $options) = @_;
 
     my $config = $request->{config};
-
+    for ('project_id', 'studio_id') {
+        return 0 unless defined $options->{$_}
+    }
     return 0 unless defined $request->{user};
-    return 0 unless defined $options->{studio_id};
-    return 0 unless defined $options->{project_id};
-
-    my $options2 = {
+ 
+    my $user_studios = uac::get_studios_by_user( $config, {
         user       => $request->{user},
         studio_id  => $options->{studio_id},
         project_id => $options->{project_id}
-    };
-
-    my $user_studios = uac::get_studios_by_user( $config, $options2 );
-    return 1 if scalar @$user_studios == 1;
-    return 0;
+    });
+    return (@$user_studios == 1);
 }
 
 # print errors at get_user_presets and check for project id and studio id
@@ -712,11 +703,6 @@ sub get_user_presets($$) {
         }
     }
 
-    #only admin is allowed to select all projects
-    #    if($permissions->{is_admin}==1){
-    #        $projects=project::get($config);
-    #    }
-
     #set studios and projects as selected, TODO:do in JS
     my $selectedProject = {};
     for my $project (@$projects) {
diff --git a/lib/calcms/user_day_start.pm b/lib/calcms/user_day_start.pm
index 076d375..2223098 100644
--- a/lib/calcms/user_day_start.pm
+++ b/lib/calcms/user_day_start.pm
@@ -3,7 +3,6 @@ package user_day_start;
 use strict;
 use warnings;
 no warnings 'redefine';
-
 use Data::Dumper;
 
 # table:   calcms_user_day_start
@@ -22,9 +21,9 @@ sub get ($$) {
     my @conditions  = ();
     my @bind_values = ();
 
-    return unless defined $condition->{user};
-    return unless defined $condition->{project_id};
-    return unless defined $condition->{studio_id};
+    for ('user', 'project_id', 'studio_id') {
+        return unless defined $condition->{$_}
+    };
 
     for my $field ('user', 'project_id', 'studio_id'){
         if ( ( defined $condition->{$field} ) && ( $condition->{$field} ne '' ) ) {
@@ -59,10 +58,9 @@ sub insert_or_update($$){
 sub insert ($$) {
     my ($config, $entry) = @_;
 
-    return unless defined $entry->{user};
-    return unless defined $entry->{project_id};
-    return unless defined $entry->{studio_id};
-    return unless defined $entry->{day_start};
+    for ('user', 'project_id', 'studio_id', 'day_start') {
+        return unless defined $entry->{$_};
+    }
 
     my $dbh = db::connect($config);
     print STDERR "insert".Dumper($entry );
@@ -96,9 +94,9 @@ sub update($$) {
 sub delete ($$) {
     my ($config, $entry) = @_;
 
-    return unless defined $entry->{user};
-    return unless defined $entry->{project_id};
-    return unless defined $entry->{studio_id};
+    for ('user', 'project_id', 'studio_id') {
+        return unless defined $entry->{$_}
+    };
 
     my $query = qq{
 		delete 
diff --git a/lib/calcms/user_default_studios.pm b/lib/calcms/user_default_studios.pm
index 3ab00ef..056974b 100644
--- a/lib/calcms/user_default_studios.pm
+++ b/lib/calcms/user_default_studios.pm
@@ -3,7 +3,6 @@ package user_default_studios;
 use strict;
 use warnings;
 no warnings 'redefine';
-
 use Data::Dumper;
 
 # table:   calcms_user_default_studios
diff --git a/lib/calcms/user_selected_events.pm b/lib/calcms/user_selected_events.pm
index 5cf8e65..aeb60b6 100644
--- a/lib/calcms/user_selected_events.pm
+++ b/lib/calcms/user_selected_events.pm
@@ -3,7 +3,6 @@ package user_selected_events;
 use strict;
 use warnings;
 no warnings 'redefine';
-
 use Data::Dumper;
 
 # table:   calcms_user_selected_events
@@ -24,10 +23,9 @@ sub get ($$) {
     my @conditions  = ();
     my @bind_values = ();
 
-    return unless defined $condition->{user};
-    return unless defined $condition->{project_id};
-    return unless defined $condition->{studio_id};
-    return unless defined $condition->{series_id};
+    for ('user', 'project_id', 'studio_id', 'series_id') {
+        return unless defined $condition->{$_}
+    };
 
     for my $field ('user', 'project_id', 'studio_id', 'series_id',
         'filter_project_studio', 'filter_series'
@@ -55,11 +53,9 @@ sub get ($$) {
 sub insert ($$) {
     my ($config, $entry) = @_;
 
-    return unless defined $entry->{user};
-    return unless defined $entry->{project_id};
-    return unless defined $entry->{studio_id};
-    return unless defined $entry->{series_id};
-    return unless defined $entry->{selected_event};
+    for ('user', 'project_id', 'studio_id', 'series_id', 'selected_event') {
+        return unless defined $entry->{$_}
+    };
 
     my $dbh = db::connect($config);
     print STDERR "insert".Dumper($entry );
@@ -96,10 +92,9 @@ sub update($$) {
 sub delete ($$) {
     my ($config, $entry) = @_;
 
-    return unless defined $entry->{user};
-    return unless defined $entry->{project_id};
-    return unless defined $entry->{studio_id};
-    return unless defined $entry->{series_id};
+    for ('user', 'project_id', 'studio_id', 'series_id') {
+        return unless defined $entry->{$_}
+    };
 
     my $query = qq{
 		delete 
diff --git a/lib/calcms/user_sessions.pm b/lib/calcms/user_sessions.pm
index 8463e7d..965d2da 100644
--- a/lib/calcms/user_sessions.pm
+++ b/lib/calcms/user_sessions.pm
@@ -3,11 +3,9 @@ package user_sessions;
 use strict;
 use warnings;
 no warnings 'redefine';
-
 use Digest::MD5();
 
 use time;
-
 # access user name by session id
 
 # table:   calcms_user_sessions
@@ -47,7 +45,8 @@ sub get($$) {
         push @bind_values, $condition->{user};
     }
 
-    if ( ( defined $condition->{session_id} ) && ( $condition->{session_id} ne '' ) ) {
+    if ((defined $condition->{session_id}) && ($condition->{session_id} ne ''))
+    {
         push @conditions,  'session_id=?';
         push @bind_values, $condition->{session_id};
     }
@@ -75,8 +74,9 @@ sub get($$) {
 sub insert ($$) {
     my ($config, $entry) = @_;
 
-    return undef unless defined $entry->{user};
-    return undef unless defined $entry->{timeout};
+    for ('user', 'timeout') {
+        return undef unless defined $entry->{$_}
+    };
 
     unless ( defined $entry->{session_id} ) {
         my $md5 = Digest::MD5->new();
@@ -95,8 +95,9 @@ sub insert ($$) {
 sub start($$) {
     my ($config, $entry) = @_;
 
-    return undef unless defined $entry->{user};
-    return undef unless defined $entry->{timeout};
+    for ('user', 'timeout') {
+        return undef unless defined $entry->{$_}
+    };
 
     my $id = insert(
         $config,
@@ -179,7 +180,6 @@ sub update ($$) {
     my @keys        = sort keys %$entry;
     my $values      = join( ",", map { $_ . '=?' } @keys );
     my @bind_values = map { $entry->{$_} } @keys;
-
     push @bind_values, $entry->{session_id};
 
     my $query = qq{
@@ -197,14 +197,12 @@ sub delete($$) {
     return undef unless defined $entry->{session_id};
 
     my $dbh = db::connect($config);
-
     my $query = qq{
         delete 
         from calcms_user_sessions 
         where session_id=?
     };
     my $bind_values = [ $entry->{session_id} ];
-
     return db::put( $dbh, $query, $bind_values );
 }
 
diff --git a/lib/calcms/user_settings.pm b/lib/calcms/user_settings.pm
index 4852ddc..0163f10 100644
--- a/lib/calcms/user_settings.pm
+++ b/lib/calcms/user_settings.pm
@@ -9,7 +9,6 @@ use series_dates();
 
 # table:   calcms_user_settings
 # columns: user, colors
-#use base 'Exporter';
 our @EXPORT_OK = qw(getColors getColorCss get insert update delete get_columns defaultColors);
 
 our $defaultColors = [
@@ -166,7 +165,9 @@ sub get ($$) {
 sub insert ($$) {
     my ($config, $entry) = @_;
 
-    return unless defined $entry->{user};
+    for ('user') {
+        return unless defined $entry->{$_};
+    }
    
     my $dbh = db::connect($config);
     return db::insert( $dbh, 'calcms_user_settings', $entry );
@@ -175,7 +176,9 @@ sub insert ($$) {
 sub update($$) {
     my ($config, $entry) = @_;
 
-    return unless ( defined $entry->{user} );
+    for ('user') {
+        return unless defined $entry->{$_};
+    }
 
     my $dbh         = db::connect($config);
     my @keys        = sort keys %$entry;
@@ -196,7 +199,9 @@ sub update($$) {
 sub delete ($$) {
     my ($config, $entry) = @_;
 
-    return unless ( defined $entry->{user} );
+    for ('user') {
+        return unless defined $entry->{$_};
+    }
 
     my $dbh = db::connect($config);
 
diff --git a/lib/calcms/user_stats.pm b/lib/calcms/user_stats.pm
index 03f7492..53e2679 100644
--- a/lib/calcms/user_stats.pm
+++ b/lib/calcms/user_stats.pm
@@ -5,7 +5,6 @@ use warnings;
 no warnings 'redefine';
 use Data::Dumper;
 
-#use base 'Exporter';
 our @EXPORT_OK = qw(get_columns get update insert get_stats increase);
 
 sub get_columns($) {
@@ -129,10 +128,9 @@ sub get_stats($$) {
 sub insert($$) {
     my ($config, $stats) = @_;
 
-    return undef unless defined $stats->{project_id};
-    return undef unless defined $stats->{studio_id};
-    return undef unless defined $stats->{series_id};
-    return undef unless defined $stats->{user};
+    for ('user', 'project_id', 'studio_id', 'series_id') {
+        return undef unless defined $stats->{$_}
+    };
 
     #TODO:filter for existing attributes
     my $columns = get_columns($config);
@@ -151,10 +149,9 @@ sub insert($$) {
 sub update ($$) {
     my ($config, $stats) = @_;
 
-    return undef unless defined $stats->{project_id};
-    return undef unless defined $stats->{studio_id};
-    return undef unless defined $stats->{series_id};
-    return undef unless defined $stats->{user};
+    for ('user', 'project_id', 'studio_id', 'series_id') {
+        return undef unless defined $stats->{$_}
+    };
 
     my $columns = get_columns($config);
     my $entry   = {};
@@ -185,10 +182,9 @@ sub increase ($$$) {
     my ($config, $usecase, $options) = @_;
 
     return undef unless defined $usecase;
-    return undef unless defined $options->{project_id};
-    return undef unless defined $options->{studio_id};
-    return undef unless defined $options->{series_id};
-    return undef unless defined $options->{user};
+    for ('user', 'project_id', 'studio_id', 'series_id', ) {
+        return undef unless defined $options->{$_}
+    };
 
     my $columns = get_columns($config);
     return undef unless exists $columns->{$usecase};
diff --git a/lib/calcms/work_dates.pm b/lib/calcms/work_dates.pm
index a104bc0..8573b37 100644
--- a/lib/calcms/work_dates.pm
+++ b/lib/calcms/work_dates.pm
@@ -6,6 +6,7 @@ no warnings 'redefine';
 
 use Data::Dumper;
 use Date::Calc();
+
 use time();
 use db();
 use log();
@@ -16,7 +17,6 @@ use work_schedule();
 # table:   calcms_work_dates
 # columns: id, studio_id, schedule_id, start(datetime), end(datetime)
 # TODO: delete column schedule_id
-#use base 'Exporter';
 our @EXPORT_OK = qw(get_columns get insert update delete get_dates);
 
 sub get_columns($) {
@@ -118,9 +118,9 @@ sub get ($$) {
 sub update($$) {
     my ($config, $entry) = @_;
 
-    return undef unless defined $entry->{project_id};
-    return undef unless defined $entry->{studio_id};
-    return undef unless defined $entry->{schedule_id};
+    for ('project_id', 'studio_id', 'schedule_id' ) {
+        return undef unless defined $entry->{$_}
+    };
 
     my $dbh = db::connect($config);
 
@@ -183,15 +183,12 @@ sub update($$) {
             $entry->{start_date} = time::add_hours_to_datetime( $entry->{start}, -$day_start );
             $entry->{end_date}   = time::add_hours_to_datetime( $entry->{end},   -$day_start );
             db::insert( $dbh, 'calcms_work_dates', $entry );
-
-            #print STDERR "$entry->{start_date}\n";
             $i++;
         } else {
             $j++;
         }
     }
 
-    #print STDERR "$i work_dates updates\n";
     return $j . " dates out of studio times, " . $i;
 }
 
@@ -286,8 +283,6 @@ sub get_dates($$$$) {
     my @start_date = ( $start[0], $start[1], $start[2] );
     my $start_time = sprintf( '%02d:%02d:%02d', $start[3], $start[4], $start[5] );
 
-    #print STDERR "$start_datetime,$end_date,$duration,$frequency\n";
-
     #return on single date
     my $date = {};
     $date->{start} = sprintf( "%04d-%02d-%02d", @start_date ) . ' ' . $start_time;
@@ -338,9 +333,9 @@ sub get_dates($$$$) {
 sub delete($$) {
     my ($config, $entry) = @_;
 
-    return undef unless defined $entry->{project_id};
-    return undef unless defined $entry->{studio_id};
-    return undef unless defined $entry->{schedule_id};
+    for ('project_id', 'studio_id', 'schedule_id') {
+        return undef unless defined $entry->{$_}
+    };
 
     my $dbh = db::connect($config);
 
diff --git a/lib/calcms/work_schedule.pm b/lib/calcms/work_schedule.pm
index 36132ed..d05d332 100644
--- a/lib/calcms/work_schedule.pm
+++ b/lib/calcms/work_schedule.pm
@@ -17,7 +17,6 @@ use series_dates();
 # week_of_month (1..5)
 # month
 
-#use base 'Exporter';
 our @EXPORT_OK = qw(get_columns get insert update delete);
 
 sub get_columns($) {
@@ -82,9 +81,9 @@ sub get($$) {
 sub insert ($$) {
     my ($config, $entry) = @_;
 
-    return undef unless defined $entry->{project_id};
-    return undef unless defined $entry->{studio_id};
-    return undef unless defined $entry->{start};
+    for ('project_id', 'studio_id', 'start' ) {
+        return undef unless defined $entry->{$_}
+    };
     my $dbh = db::connect($config);
     return db::insert( $dbh, 'calcms_work_schedule', $entry );
 }
@@ -93,10 +92,9 @@ sub insert ($$) {
 sub update ($$) {
     my ($config, $entry) = @_;
 
-    return undef unless defined $entry->{project_id};
-    return undef unless defined $entry->{studio_id};
-    return undef unless defined $entry->{schedule_id};
-    return undef unless defined $entry->{start};
+    for ('project_id', 'studio_id', 'schedule_id', 'start' ) {
+        return undef unless defined $entry->{$_}
+    };
 
     my $dbh         = db::connect($config);
     my @keys        = sort keys %$entry;
@@ -120,9 +118,9 @@ sub update ($$) {
 sub delete($$) {
     my ($config, $entry) = @_;
 
-    return undef unless defined $entry->{project_id};
-    return undef unless defined $entry->{studio_id};
-    return undef unless defined $entry->{schedule_id};
+    for ('project_id', 'studio_id', 'schedule_id' ) {
+        return undef unless defined $entry->{$_}
+    };
 
     my $dbh = db::connect($config);
 
diff --git a/website/agenda/planung/css/default.css b/website/agenda/planung/css/default.css
index 18c7de2..0a0a5b9 100644
--- a/website/agenda/planung/css/default.css
+++ b/website/agenda/planung/css/default.css
@@ -57,7 +57,7 @@ body {
 body #content {
     color: #000;
     text-align: left;
-    min-width: 480px;
+    min-width: min-content;
     max-width: 960px;
     margin-left: auto;
     margin-right: auto;
@@ -561,7 +561,7 @@ table.tablesorter tr {
     min-width: 5rem;
     border-radius: 1rem;
     color: #fff;
-    height: 2.3rem;
+    min-height: 2.3rem;
     position: relative;
     transition: background-color .3s cubic-bezier(.05, .05, .05, 1),
         box-shadow .3s cubic-bezier(.05, .05, .05, 1);
@@ -682,6 +682,15 @@ ul.tabContainer li.active{
 ul.tabContainer li:hover{
     border-bottom-color:#1678c2;
 }
+
+#content ul.tabContainer {
+    margin: 0 12px -14px 16px;
+}
+#content ul.tabContainer + div.panel {
+    border-top-left-radius:0;
+    border-top-right-radius:0;
+}
+
 #content ul.tabContainer li a:hover{
     text-decoration:none;
 }
@@ -700,13 +709,14 @@ ul.tabContainer li{
     border: 1px solid rgba(0, 0, 0, .03);
     box-shadow: 0 2px 2px rgba(0, 0, 0, .24),
                 0 0   2px rgba(0, 0, 0, .12);
-    margin-left:-3px;
-    margin-bottom:-2px;
+    margin-bottom:2px;
+    margin-right:-2px;
 }
+
 ul.tabContainer li:first-child{
     border-top-left-radius:0.5rem;
-    margin-left:4px;
 }
+
 ul.tabContainer li:last-child{
     border-top-right-radius:0.5rem;
 }
diff --git a/website/agenda/planung/css/series.css b/website/agenda/planung/css/series.css
index c76e5c8..497cedd 100644
--- a/website/agenda/planung/css/series.css
+++ b/website/agenda/planung/css/series.css
@@ -12,7 +12,6 @@
 }
 
 #content .editor td.label {
-    max-width: min-content;
     padding-top:0.5rem;
 }
 
diff --git a/website/agenda/planung/css/studio-timeslots.css b/website/agenda/planung/css/studio-timeslots.css
index 43159c8..64a2093 100644
--- a/website/agenda/planung/css/studio-timeslots.css
+++ b/website/agenda/planung/css/studio-timeslots.css
@@ -48,18 +48,17 @@
 #content .editor .cell {
     display: table-cell ;
     vertical-align:baseline;
-    text-align: center;
+    text-align: left;
 }
 
 #content .frequency {
     width: 6em;
 }
 
-#content div.weekday {
-    padding: 0;
-    width: 2em;
-    margin-right: -0.5em;
-    margin-top: 1.2em;
+#content .editor div.cell.weekday {
+    vertical-align: bottom;
+    width: 2.5ch;
+    padding-bottom: 9px;
 }
 
 #content div.show_schedule_head {
diff --git a/website/agenda/planung/js/studio-timeslots.js b/website/agenda/planung/js/studio-timeslots.js
index 2ce10cf..449f2d7 100644
--- a/website/agenda/planung/js/studio-timeslots.js
+++ b/website/agenda/planung/js/studio-timeslots.js
@@ -61,6 +61,37 @@ function initTable(){
     $('.tablesorter-scroller-table table').css('width','95%');
 }
 
+// show/hide schedule fields depending on period type for a given schedule element
+function showScheduleFields(id){
+    var select='#'+id+' select[name="period_type"]';
+    var type=$(select).val();
+    //hide and show values for different schedule types
+    if (type=='days' || type=='') {
+        $('#'+id+' div.cell.frequency').show();
+        $('#'+id+' div.cell.end').show();
+        $('#'+id+' div.cell.schedule_weekday').hide();
+        $('#'+id+' div.cell.week_of_month').hide();
+        $('#'+id+' div.cell.schedule_month').hide();
+        $('#'+id+' div.cell.nextDay').hide();
+    }else if(type=='week_of_month'){
+        $('#'+id+' div.cell.frequency').hide();
+        $('#'+id+' div.cell.end').show();
+        $('#'+id+' div.cell.schedule_weekday').show();
+        $('#'+id+' div.cell.week_of_month').show();
+        $('#'+id+' div.cell.schedule_month').show();
+        $('#'+id+' div.cell.nextDay').show();
+    }else{
+        alert("invalid schedule type");
+    }
+}
+
+function initScheduleFields(){
+    $('div.row.schedule form').each(function(){
+        var id = $(this).attr('id');
+        if(contains(id,'schedule_'))showScheduleFields(id);
+    });
+}
+
 $(document).ready(
     function(){
     setupLocalization(function(){
@@ -88,6 +119,7 @@ $(document).ready(
         onSelect: function(){updateWeekdays();}
     });
 
+    initScheduleFields();
     setSelectedOptions();
 
     showYearPicker('#show_date', {
@@ -95,6 +127,7 @@ $(document).ready(
             showDates();
         }
     });
+
     showDates();                
 });
 
diff --git a/website/agenda/planung/pot/de/studio-timeslots.po b/website/agenda/planung/pot/de/studio-timeslots.po
index 5a327e1..0f18e75 100644
--- a/website/agenda/planung/pot/de/studio-timeslots.po
+++ b/website/agenda/planung/pot/de/studio-timeslots.po
@@ -64,3 +64,156 @@ msgstr "alle 28 Tage"
 msgid "every_month"
 msgstr "monatlich"
 
+msgid "schedule_start"
+msgstr "Start"
+
+msgid "schedule_end"
+msgstr "wiederholt bis"
+
+msgid "duration"
+msgstr "Dauer"
+
+msgid "duration_in_minutes"
+msgstr "Dauer in Minuten"
+
+msgid "frequency"
+msgstr "wie oft"
+
+msgid "frequency_days"
+msgstr "alle x Tage"
+
+msgid "exception"
+msgstr "Ausnahme"
+
+msgid "week_of_month"
+msgstr "Woche"
+
+msgid "weekday"
+msgstr "Wochentag"
+
+msgid "period_type"
+msgstr "Wiederholung"
+
+msgid "period_type_single"
+msgstr "keine"
+
+msgid "period_type_days"
+msgstr "festes Interval"
+
+msgid "period_type_week_of_month"
+msgstr "Woche im Monat"
+
+msgid "nextDay"
+msgstr "Nacht"
+
+msgid "minutes"
+msgstr "Minuten"
+
+msgid "hour"
+msgstr "Stunde"
+
+msgid "hours"
+msgstr "Stunden"
+
+msgid "day"
+msgstr "Tag"
+
+msgid "days"
+msgstr "Tage"
+
+msgid "daily"
+msgstr "täglich"
+
+msgid "week"
+msgstr "Woche"
+
+msgid "weeks"
+msgstr "Wochen"
+
+msgid "weekly"
+msgstr "wöchentlich"
+
+msgid "month"
+msgstr "Monat"
+
+msgid "months"
+msgstr "Monate"
+
+msgid "from"
+msgstr "von"
+
+msgid "till"
+msgstr "bis"
+
+msgid "modified"
+msgstr "bearbeited"
+
+msgid "added"
+msgstr "hinzugefügt"
+
+msgid "at"
+msgstr "am"
+
+msgid "by"
+msgstr "von"
+
+msgid "unit"
+msgstr "in"
+
+msgid "choose_free"
+msgstr "frei wählbar"
+
+msgid "every"
+msgstr "alle"
+
+msgid "every_month"
+msgstr "wie oft"
+
+msgid "every_time"
+msgstr "jedes Mal"
+
+msgid "every_2nd_time"
+msgstr "jedes 2. Mal"
+
+msgid "every_3rd_time"
+msgstr "jedes 3. Mal"
+
+msgid "every_4th_time"
+msgstr "jedes 4. Mal"
+
+msgid "week_1st"
+msgstr "erster"
+
+msgid "week_2nd"
+msgstr "zweiter"
+
+msgid "week_3rd"
+msgstr "dritter"
+
+msgid "week_4th"
+msgstr "vierter"
+
+msgid "week_5th"
+msgstr "fünter"
+
+msgid "monday"
+msgstr "Montag"
+
+msgid "tuesday"
+msgstr "Dienstag"
+
+msgid "wednesday"
+msgstr "Mittwoch"
+
+msgid "thursday"
+msgstr "Donnerstag"
+
+msgid "friday"
+msgstr "Freitag"
+
+msgid "saturday"
+msgstr "Samstag"
+
+msgid "sunday"
+msgstr "Sonntag"
+
diff --git a/website/agenda/planung/pot/en/studio-timeslots.po b/website/agenda/planung/pot/en/studio-timeslots.po
index b7b414f..30fae44 100644
--- a/website/agenda/planung/pot/en/studio-timeslots.po
+++ b/website/agenda/planung/pot/en/studio-timeslots.po
@@ -64,4 +64,150 @@ msgstr "every four weeks"
 msgid "every_month"
 msgstr "every month"
 
+msgid "schedule_start"
+msgstr "start of schedule"
+
+msgid "schedule_end"
+msgstr "end of schedule"
+
+msgid "duration"
+msgstr "duration"
+
+msgid "duration_in_minutes"
+msgstr "duration in minutes"
+
+msgid "frequency"
+msgstr "how often"
+
+msgid "frequency_days"
+msgstr "every n days"
+
+msgid "week_of_month"
+msgstr "week of month"
+
+msgid "weekday"
+msgstr "weekday"
+
+msgid "period_type"
+msgstr "type of planning"
+
+msgid "period_type_days"
+msgstr "regular recurrence"
+
+msgid "period_type_week_of_month"
+msgstr "week of month"
+
+msgid "nextDay"
+msgstr "night"
+
+msgid "minutes"
+msgstr "minutes"
+
+msgid "hour"
+msgstr "hour"
+
+msgid "hours"
+msgstr "hours"
+
+msgid "day"
+msgstr "day"
+
+msgid "days"
+msgstr "days"
+
+msgid "daily"
+msgstr "daily"
+
+msgid "week"
+msgstr "week"
+
+msgid "weeks"
+msgstr "weeks"
+
+msgid "weekly"
+msgstr "weekly"
+
+msgid "month"
+msgstr "month"
+
+msgid "months"
+msgstr "months"
+
+msgid "from"
+msgstr "from"
+
+msgid "till"
+msgstr "till"
+
+msgid "modified"
+msgstr "modified"
+
+msgid "added"
+msgstr "added"
+
+msgid "at"
+msgstr "at"
+
+msgid "by"
+msgstr "by"
+
+msgid "unit"
+msgstr "in"
+
+msgid "choose_free"
+msgstr "choose freely"
+
+msgid "every"
+msgstr "every"
+
+msgid "every_month"
+msgstr "every nth time"
+
+msgid "every_time"
+msgstr "every time"
+
+msgid "every_2nd_time"
+msgstr "every 2nd time"
+
+msgid "every_3rd_time"
+msgstr "every 3rd time"
+
+msgid "every_4th_time"
+msgstr "every 4th time"
+
+msgid "week_1st"
+msgstr "1st"
+
+msgid "week_2nd"
+msgstr "2nd"
+
+msgid "week_3rd"
+msgstr "3rd"
+
+msgid "week_4th"
+msgstr "4th"
+
+msgid "week_5th"
+msgstr "5th"
+
+msgid "monday"
+msgstr "Monday"
+
+msgid "tuesday"
+msgstr "Tuesday"
+
+msgid "wednesday"
+msgstr "Wednesday"
+
+msgid "thursday"
+msgstr "Thursday"
+
+msgid "friday"
+msgstr "Friday"
+
+msgid "saturday"
+msgstr "Saturday"
+
+msgid "sunday"
+msgstr "Sunday"
 
diff --git a/website/agenda/planung/studio-timeslots.cgi b/website/agenda/planung/studio-timeslots.cgi
index 38981ce..7bad084 100755
--- a/website/agenda/planung/studio-timeslots.cgi
+++ b/website/agenda/planung/studio-timeslots.cgi
@@ -4,9 +4,6 @@ use strict;
 use warnings;
 no warnings 'redefine';
 
-use Data::Dumper;
-use URI::Escape();
-
 use params();
 use config();
 use entry();
@@ -24,11 +21,11 @@ use localization();
 binmode STDOUT, ":utf8";
 
 my $r = shift;
-( my $cgi, my $params, my $error ) = params::get($r);
+(my $cgi, my $params, my $error) = params::get($r);
 
 my $config = config::get('../config/config.cgi');
-my ( $user, $expires ) = auth::get_user( $config, $params, $cgi );
-return if ( ( !defined $user ) || ( $user eq '' ) );
+my ($user, $expires) = auth::get_user($config, $params, $cgi);
+return if ((!defined $user) || ($user eq ''));
 
 my $user_presets = uac::get_user_presets(
     $config,
@@ -39,48 +36,45 @@ my $user_presets = uac::get_user_presets(
     }
 );
 $params->{default_studio_id} = $user_presets->{studio_id};
-$params = uac::setDefaultStudio( $params, $user_presets );
-$params = uac::setDefaultProject( $params, $user_presets );
+$params = uac::setDefaultStudio($params, $user_presets);
+$params = uac::setDefaultProject($params, $user_presets);
 
 my $request = {
     url => $ENV{QUERY_STRING} || '',
     params => {
         original => $params,
-        checked  => check_params( $config, $params ),
+        checked  => check_params($config, $params),
     },
 };
-$request = uac::prepare_request( $request, $user_presets );
+$request = uac::prepare_request($request, $user_presets);
 $params = $request->{params}->{checked};
 
 #process header
-my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
-$headerParams->{loc} = localization::get( $config, { user => $user, file => 'all,menu' } );
+my $headerParams = uac::set_template_permissions($request->{permissions}, $params);
+$headerParams->{loc} = localization::get($config, {user => $user, file => 'all,menu'});
 
 my $action = $params->{action} || '';
-if ( $action eq 'show_dates' ) {
+if ($action eq 'show_dates') {
     #print "Content-type:text/html\n\n";
 } else {
-    template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
+    template::process($config, 'print', template::check($config, 'default.html'), $headerParams);
 }
-return unless uac::check( $config, $params, $user_presets ) == 1;
+return unless uac::check($config, $params, $user_presets) == 1;
 
-if ( $action eq 'show_dates' ) {
+if ($action eq 'show_dates') {
     print "Content-Type:text/html\n\n";
 } else {
-    template::process( $config, 'print', template::check( $config, 'studio-timeslots-header.html' ), $headerParams );
+    template::process($config, 'print', template::check($config, 'studio-timeslots-header.html'), $headerParams);
 }
 
-if ( defined $params->{action} ) {
-    save_schedule( $config, $request ) if ( $params->{action} eq 'save_schedule' );
-    delete_schedule( $config, $request ) if ( $params->{action} eq 'delete_schedule' );
-    if ( $params->{action} eq 'show_dates' ) {
-        showDates( $config, $request );
-        return;
-    }
+if (defined $params->{action}) {
+    save_schedule($config, $request) if $params->{action} eq 'save_schedule';
+    delete_schedule($config, $request) if $params->{action} eq 'delete_schedule';
+    return showDates($config, $request) if $params->{action} eq 'show_dates';
 }
 
 $config->{access}->{write} = 0;
-showTimeslotSchedule( $config, $request );
+showTimeslotSchedule($config, $request);
 return;
 
 #insert or update a schedule and update all schedule dates
@@ -88,44 +82,40 @@ sub save_schedule {
     my ($config, $request) = @_;
 
     my $permissions = $request->{permissions};
-    unless ( $permissions->{update_studio_timeslot_schedule} == 1 ) {
-        uac::permissions_denied('update_studio_timeslot_schedule');
-        return;
-    }
+    return uac::permissions_denied('update_studio_timeslot_schedule')
+        unless $permissions->{update_studio_timeslot_schedule} == 1;
 
     my $params = $request->{params}->{checked};
-
-    for my $attr ( 'project_id', 'studio_id', 'start', 'end', 'end_date', 'schedule_studio_id' ) {
-        unless ( defined $params->{$attr} ) {
-            uac::print_error( $attr . ' not given!' );
-            return;
-        }
-    }
+    for my $attr ('project_id', 'studio_id', 'start', 'end', 'end_date', 'schedule_studio_id') {
+        return uac::print_error($attr . ' not given!') unless defined $params->{$attr};
+   }
 
     my $entry = {};
-    for my $attr ( 'project_id', 'start', 'end', 'end_date', 'frequency' ) {
-        $entry->{$attr} = $params->{$attr} if defined $params->{$attr};
-    }
+    if ($params->{period_type} eq 'days') {
+        entry::set_numbers($entry, $params, ['frequency']);
+        $entry->{period_type} = $params->{period_type};
+   }elsif($params->{period_type} eq 'week_of_month') {
+        entry::set_numbers($entry, $params, ['weekday', 'week_of_month', 'month']);
+        $entry->{period_type} = $params->{period_type};
+   }
+
+    my $entry = {map {$_ => $params->{$_}} ('project_id', 'start', 'end', 'end_date')};
 
     #set schedule's studio to value from schedule_studio_id
     $entry->{studio_id} = $params->{schedule_studio_id} if defined $params->{schedule_studio_id};
 
-    if ( ( $entry->{end} ne '' ) && ( $entry->{end} le $entry->{start} ) ) {
-        uac::print_error('start date should be before end date!');
-        return;
-    }
+    return uac::print_error('start date should be before end date!')
+        if $entry->{end} ne '' && $entry->{end} le $entry->{start};
 
     $config->{access}->{write} = 1;
-    if ( defined $params->{schedule_id} ) {
+    if (defined $params->{schedule_id}) {
         $entry->{schedule_id} = $params->{schedule_id};
-        studio_timeslot_schedule::update( $config, $entry );
-
-        my $updates = studio_timeslot_dates::update( $config, $entry );
+        studio_timeslot_schedule::update($config, $entry);
+        my $updates = studio_timeslot_dates::update($config, $entry);
         uac::print_info("timeslot schedule saved. $updates dates scheduled");
     } else {
-        $entry->{schedule_id} = studio_timeslot_schedule::insert( $config, $entry );
-
-        my $updates = studio_timeslot_dates::update( $config, $entry );
+        $entry->{schedule_id} = studio_timeslot_schedule::insert($config, $entry);
+        my $updates = studio_timeslot_dates::update($config, $entry);
         uac::print_info("timeslot schedule added. $updates dates added");
     }
 
@@ -135,27 +125,20 @@ sub delete_schedule {
     my ($config, $request) = @_;
 
     my $permissions = $request->{permissions};
-    unless ( $permissions->{update_studio_timeslot_schedule} == 1 ) {
-        uac::permissions_denied('update_studio_timeslot_schedule');
-        return;
-    }
-
+    return uac::permissions_denied('update_studio_timeslot_schedule')
+        unless $permissions->{update_studio_timeslot_schedule} == 1;
     my $params = $request->{params}->{checked};
 
     my $entry = {};
-    for my $attr ( 'project_id', 'studio_id', 'schedule_id' ) {
-        if ( defined $params->{$attr} ) {
-            $entry->{$attr} = $params->{$attr};
-        } else {
-            uac::print_error( $attr . ' not given!' );
-            return;
-        }
+    for my $attr ('project_id', 'studio_id', 'schedule_id') {
+        return uac::print_error($attr . ' not given!') unless defined $params->{$attr};
+        $entry->{$attr} = $params->{$attr};
     }
 
     $config->{access}->{write} = 1;
     $entry->{schedule_id} = $params->{schedule_id};
-    studio_timeslot_schedule::delete( $config, $entry );
-    studio_timeslot_dates::update( $config, $entry );
+    studio_timeslot_schedule::delete($config, $entry);
+    studio_timeslot_dates::update($config, $entry);
     uac::print_info("timeslot schedule deleted");
 }
 
@@ -163,49 +146,38 @@ sub showTimeslotSchedule {
     my ($config, $request) = @_;
 
     $config->{access}->{write} = 0;
-
     my $params      = $request->{params}->{checked};
     my $permissions = $request->{permissions};
-    unless ( $permissions->{read_studio_timeslot_schedule} == 1 ) {
-        uac::permissions_denied('read_studio_timeslot_schedule');
-        return;
-    }
+    return uac::permissions_denied('read_studio_timeslot_schedule')
+        unless $permissions->{read_studio_timeslot_schedule} == 1;
 
-    for my $param ( 'project_id', 'studio_id' ) {
-        unless ( defined $params->{$param} ) {
-            uac::print_error("missing $param");
-            return;
-        }
+    for my $param ('project_id', 'studio_id') {
+        return uac::print_error("missing $param") unless defined $params->{$param};
     }
 
     #this will be updated later (especially allow_update_events)
-    for my $permission ( keys %{ $request->{permissions} } ) {
-        $params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
-    }
+    $params->{'allow'}->{$_} = $request->{permissions}->{$_} for (keys %{$request->{permissions}});
 
     $params->{loc} =
-      localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio-timeslots' } );
+      localization::get($config, {user => $params->{presets}->{user}, file => 'all,studio-timeslots'});
 
     my $studio_id  = $params->{studio_id};
     my $project_id = $params->{project_id};
 
     #get project schedule
     my $schedules = studio_timeslot_schedule::get(
-        $config,
-        {
-            project_id => $project_id
-
-              #		    studio_id=>$studio_id
-        }
-    );
+        $config, {project_id => $project_id}
+);
 
     #list of all studios by id
-    my $studios = studios::get( $config, { project_id => $project_id } );
+    my $studios = studios::get($config, {project_id => $project_id});
 
     #remove seconds from dates
     for my $schedule (@$schedules) {
         $schedule->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
         $schedule->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
+        $schedule->{period_type_days} = 1        if $schedule->{period_type} eq 'days';
+        $schedule->{period_type_week_of_month} = 1 if $schedule->{period_type} eq 'week_of_month';
 
         #insert assigned studio
         for my $studio (@$studios) {
@@ -213,8 +185,8 @@ sub showTimeslotSchedule {
                 id   => $studio->{id},
                 name => $studio->{name},
             };
-            $entry->{selected} = 1 if ( $studio->{id} eq $schedule->{studio_id} );
-            push @{ $schedule->{studios} }, $entry;
+            $entry->{selected} = 1 if $studio->{id} eq $schedule->{studio_id};
+            push @{$schedule->{studios}}, $entry;
         }
     }
 
@@ -224,22 +196,17 @@ sub showTimeslotSchedule {
     };
     $result->{schedule}  = $schedules;
     $result->{studios}   = $studios;
-    $result->{start}     = $params->{start};
-    $result->{end}       = $params->{end};
-    $result->{end_date}  = $params->{end_date};
-    $result->{frequency} = $params->{frequency};
-
+    for my $attr ('start', 'end', 'end_date', 'frequency', 'period_type', 'weekday', 'week_of_month', 'month') {
+        $result->{$attr} = $params->{$attr};
+    }
     #remove seconds from datetimes
     $result->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $result->{start};
     $result->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/   if defined $result->{end};
 
     #copy entry values to params
-    for my $key ( keys %$result ) {
-        $params->{$key} = $result->{$key};
-    }
+    $params->{$_} = $result->{$_} for keys %$result;
 
-    #print '
'.Dumper($params).'
'; - template::process( $config, 'print', $params->{template}, $params ); + template::process($config, 'print', $params->{template}, $params); } sub showDates { @@ -249,22 +216,16 @@ sub showDates { my $params = $request->{params}->{checked}; my $permissions = $request->{permissions}; - unless ( $permissions->{read_studio_timeslot_schedule} == 1 ) { - uac::permissions_denied('read_studio_timeslot_schedule'); - return; - } + return uac::permissions_denied('read_studio_timeslot_schedule') + unless $permissions->{read_studio_timeslot_schedule} == 1; - for my $param ( 'project_id', 'studio_id' ) { - unless ( defined $params->{$param} ) { - uac::print_error("missing $param"); - return; - } + for my $param ('project_id', 'studio_id') { + return uac::print_error("missing $param") unless defined $params->{$param}; } #this will be updated later (especially allow_update_events) - for my $permission ( keys %{ $request->{permissions} } ) { - $params->{'allow'}->{$permission} = $request->{permissions}->{$permission}; - } + $params->{'allow'}->{$_} = $request->{permissions}->{$_} + for (keys %{$request->{permissions}}); my $studio_id = $params->{studio_id}; my $project_id = $params->{project_id}; @@ -277,15 +238,13 @@ sub showDates { $config, { project_id => $project_id, - - # studio_id=>$studio_id, from => $fromDate, till => $tillDate } ); $params->{loc} = - localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio-timeslots' } ); + localization::get($config, {user => $params->{presets}->{user}, file => 'all,studio-timeslots'}); my $language = $params->{loc}->{region}; # translate weekday names to selected language @@ -299,11 +258,8 @@ sub showDates { 'Su' => $params->{loc}->{weekday_Su}, }; - my $studios = studios::get( $config, { project_id => $project_id } ); - my $studio_by_id = {}; - for my $studio (@$studios) { - $studio_by_id->{ $studio->{id} } = $studio; - } + my $studios = studios::get($config, {project_id => $project_id}); + my $studio_by_id = {map {$_->{id} => $_} @$studios}; #remove seconds from dates for my $date (@$timeslot_dates) { @@ -313,11 +269,11 @@ sub showDates { $date->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/; # translate weekday - if ( $language ne 'en' ) { - $date->{start_weekday} = $weekday->{ $date->{start_weekday} }; - $date->{end_weekday} = $weekday->{ $date->{end_weekday} }; - } - $date->{studio_name} = $studio_by_id->{ $date->{studio_id} }->{name}; + if ($language ne 'en') { + $date->{start_weekday} = $weekday->{$date->{start_weekday}}; + $date->{end_weekday} = $weekday->{$date->{end_weekday}}; + } + $date->{studio_name} = $studio_by_id->{$date->{studio_id}}->{name}; } my $result = { project_id => $project_id, @@ -326,60 +282,53 @@ sub showDates { }; #copy entry values to params - for my $key ( keys %$result ) { - $params->{$key} = $result->{$key}; - } + $params->{$_} = $result->{$_} for keys %$result; - my $template = template::check( $config, 'studio-timeslot-dates' ); - template::process( $config, 'print', $template, $params ); + my $template = template::check($config, 'studio-timeslot-dates'); + template::process($config, 'print', $template, $params); } sub check_params { - my $config = shift; - my $params = shift; + ($config, $params) = @_; my $checked = {}; + $checked->{template} = template::check($config, $params->{template}, 'studio-timeslots'); #actions and roles - if ( defined $params->{action} ) { - if ( $params->{action} =~ /^(show|save_schedule|delete_schedule|show_dates)$/ ) { - $checked->{action} = $params->{action}; - } - } + $checked->{action} = $params->{action} + if ($params->{action}//'') =~ /^(show|save_schedule|delete_schedule|show_dates)$/; $checked->{exclude} = 0; - entry::set_numbers( $checked, $params, [ + entry::set_numbers($checked, $params, [ 'id', 'project_id', 'studio_id', 'default_studio_id', 'schedule_id', 'schedule_studio_id' ]); + $checked->{default_studio_id} = $checked->{studio_id} // -1; - if ( ( defined $params->{show_date} ) && ( $params->{show_date} =~ /^(\d\d\d\d)/ ) ) { + if (($params->{show_date}//'') =~ /^(\d\d\d\d)/) { $checked->{show_date} = $1; } else { - my $date = time::date_to_array( time::time_to_date() ); + my $date = time::date_to_array(time::time_to_date()); $checked->{show_date} = $date->[0]; } - if ( defined $checked->{studio_id} ) { - $checked->{default_studio_id} = $checked->{studio_id}; - } else { - $checked->{studio_id} = -1; + entry::set_numbers($checked, $params, ['frequency']); + if ($params->{period_type}eq 'days') { + $checked->{period_type} = $params->{period_type}; + }elsif($params->{period_type}eq 'week_of_month') { + entry::set_numbers($checked, $params, ['weekday', 'week_of_month', 'month']); + $checked->{period_type} = $params->{period_type}; } - $checked->{template} = template::check( $config, $params->{template}, 'studio-timeslots' ); - - entry::set_numbers( $checked, $params, ['frequency'] ); - - for my $attr ( 'start', 'end' ) { - if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d[ T]\d\d\:\d\d)/ ) ) { - $checked->{$attr} = $1 . ':00'; + for my $attr ('start', 'end') { + if (($params->{$attr}//'') =~ /(\d\d\d\d\-\d\d\-\d\d[ T]\d\d\:\d\d)/) { + $checked->{$attr} = "$1:00"; } } for my $attr ('end_date') { - if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) ) { + if (($params->{$attr}//'') =~ /(\d\d\d\d\-\d\d\-\d\d)/) { $checked->{$attr} = $1; } } return $checked; } - diff --git a/website/agenda/planung/templates/edit-series.html b/website/agenda/planung/templates/edit-series.html index a00e9e3..ba7bce2 100644 --- a/website/agenda/planung/templates/edit-series.html +++ b/website/agenda/planung/templates/edit-series.html @@ -204,18 +204,18 @@
-
+
-
+
-
+
@@ -238,12 +238,12 @@
-
+
-
+
@@ -268,7 +268,7 @@
-
+
@@ -291,7 +291,7 @@
-
+
@@ -319,18 +319,18 @@
-
+
-
+
-
+
@@ -353,12 +353,12 @@
-
+
-
+
@@ -383,7 +383,7 @@
-
+
@@ -406,7 +406,7 @@
-
+
diff --git a/website/agenda/planung/templates/studio-timeslots.html b/website/agenda/planung/templates/studio-timeslots.html index 2118a8c..cb0ebcb 100644 --- a/website/agenda/planung/templates/studio-timeslots.html +++ b/website/agenda/planung/templates/studio-timeslots.html @@ -21,18 +21,9 @@
- +
-
-
-
-
-
-
-
-
-
@@ -40,11 +31,31 @@ +
-
+
+
+ +
+
-
-
+
+
+ +
+ +
+
+ +
+ +
+
-
-
-
- + +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
-
- + >
@@ -75,15 +129,35 @@ -
-
- - +
+ + + +
-
+
+
+ +
+
-
-
+
+
+ +
+ +
+
+ +
+ +
+
-
-
-
- + +
+
+
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+ +
+ -
+
+ +
@@ -115,12 +231,12 @@
- +
-
+