add playout section
This commit is contained in:
543
website/agenda/planung/studio_timeslots.cgi
Normal file → Executable file
543
website/agenda/planung/studio_timeslots.cgi
Normal file → Executable file
@@ -22,51 +22,57 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($config, {
|
||||
user => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
});
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id}=$params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
user => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$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'){
|
||||
#print "Content-type:text/html\n\n";
|
||||
}else{
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
my $action = $params->{action} || '';
|
||||
if ( $action eq 'show_dates' ) {
|
||||
|
||||
#print "Content-type:text/html\n\n";
|
||||
} else {
|
||||
template::process( 'print', template::check('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'){
|
||||
print "Content-Type:text/html\n\n";
|
||||
}else{
|
||||
print q{
|
||||
if ( $action eq 'show_dates' ) {
|
||||
print "Content-Type:text/html\n\n";
|
||||
} else {
|
||||
print q{
|
||||
<script src="js/jquery-ui-timepicker.js" type="text/javascript"></script>
|
||||
<link href="css/jquery-ui-timepicker.css" type="text/css" rel="stylesheet" />
|
||||
<link href="css/theme.default.css" rel="stylesheet">
|
||||
@@ -76,334 +82,337 @@ if ($action eq 'show_dates'){
|
||||
};
|
||||
}
|
||||
|
||||
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' );
|
||||
if ( $params->{action} eq 'show_dates' ) {
|
||||
showDates( $config, $request );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
showTimeslotSchedule($config, $request);
|
||||
$config->{access}->{write} = 0;
|
||||
showTimeslotSchedule( $config, $request );
|
||||
return;
|
||||
|
||||
#insert or update a schedule and update all schedule dates
|
||||
sub save_schedule{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub save_schedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{update_studio_timeslot_schedule}==1){
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('update_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
#print Dumper($params);
|
||||
my $params=$request->{params}->{checked};
|
||||
#print Dumper($params);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
my $entry={};
|
||||
for my $attr (
|
||||
'project_id', 'start', 'end', 'end_date', 'frequency'
|
||||
){
|
||||
$entry->{$attr}=$params->{$attr} if (defined $params->{$attr});
|
||||
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;
|
||||
}
|
||||
}
|
||||
#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})){
|
||||
my $entry = {};
|
||||
for my $attr ( 'project_id', 'start', 'end', 'end_date', 'frequency' ) {
|
||||
$entry->{$attr} = $params->{$attr} if ( defined $params->{$attr} );
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
#print Dumper($entry);
|
||||
$config->{access}->{write}=1;
|
||||
if(defined $params->{schedule_id}){
|
||||
$entry->{schedule_id}=$params->{schedule_id};
|
||||
#print Dumper($entry);
|
||||
studio_timeslot_schedule::update($config, $entry);
|
||||
#my $updates=0;
|
||||
#print Dumper($entry);
|
||||
my $updates=studio_timeslot_dates::update($config, $entry);
|
||||
#print Dumper($entry);
|
||||
$config->{access}->{write} = 1;
|
||||
if ( defined $params->{schedule_id} ) {
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
|
||||
#print Dumper($entry);
|
||||
studio_timeslot_schedule::update( $config, $entry );
|
||||
|
||||
#my $updates=0;
|
||||
#print Dumper($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=0;
|
||||
my $updates=studio_timeslot_dates::update($config, $entry);
|
||||
} else {
|
||||
$entry->{schedule_id} = studio_timeslot_schedule::insert( $config, $entry );
|
||||
|
||||
#my $updates=0;
|
||||
my $updates = studio_timeslot_dates::update( $config, $entry );
|
||||
uac::print_info("timeslot schedule added. $updates dates added");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub delete_schedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
sub delete_schedule{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{update_studio_timeslot_schedule}==1){
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('update_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
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!');
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
$entry->{schedule_id}=$params->{schedule_id};
|
||||
studio_timeslot_schedule::delete($config, $entry);
|
||||
studio_timeslot_dates::update($config, $entry);
|
||||
$config->{access}->{write} = 1;
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
studio_timeslot_schedule::delete( $config, $entry );
|
||||
studio_timeslot_dates::update( $config, $entry );
|
||||
uac::print_info("timeslot schedule deleted");
|
||||
}
|
||||
|
||||
sub showTimeslotSchedule{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub showTimeslotSchedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{read_studio_timeslot_schedule}==1){
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('read_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $param ('project_id','studio_id'){
|
||||
unless(defined $params->{$param}){
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission (keys %{$request->{permissions}}){
|
||||
$params->{'allow'}->{$permission}=$request->{permissions}->{$permission};
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$params->{loc} = localization::get($config, {user=>$params->{presets}->{user}, file=>'all,studio_timeslots'});
|
||||
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission ( keys %{ $request->{permissions} } ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
|
||||
$params->{loc} = 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
|
||||
}
|
||||
);
|
||||
#get project schedule
|
||||
my $schedules = studio_timeslot_schedule::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id
|
||||
|
||||
#list of all studios by id
|
||||
my $studios=studios::get($config, {project_id=>$project_id});
|
||||
# studio_id=>$studio_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/;
|
||||
#insert assigned studio
|
||||
for my $studio (@$studios){
|
||||
my $entry={
|
||||
id => $studio->{id},
|
||||
name => $studio->{name},
|
||||
};
|
||||
$entry->{selected}=1 if ($studio->{id} eq $schedule->{studio_id});
|
||||
push @{$schedule->{studios}},$entry;
|
||||
}
|
||||
}
|
||||
#list of all studios by id
|
||||
my $studios = studios::get( $config, { project_id => $project_id } );
|
||||
|
||||
my $result={
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
};
|
||||
$result->{schedule} = $schedules;
|
||||
$result->{studios} = $studios;
|
||||
$result->{start} = $params->{start};
|
||||
$result->{end} = $params->{end};
|
||||
$result->{end_date} = $params->{end_date};
|
||||
$result->{frequency} = $params->{frequency};
|
||||
#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/;
|
||||
|
||||
#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};
|
||||
#insert assigned studio
|
||||
for my $studio (@$studios) {
|
||||
my $entry = {
|
||||
id => $studio->{id},
|
||||
name => $studio->{name},
|
||||
};
|
||||
$entry->{selected} = 1 if ( $studio->{id} eq $schedule->{studio_id} );
|
||||
push @{ $schedule->{studios} }, $entry;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $result = {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
};
|
||||
$result->{schedule} = $schedules;
|
||||
$result->{studios} = $studios;
|
||||
$result->{start} = $params->{start};
|
||||
$result->{end} = $params->{end};
|
||||
$result->{end_date} = $params->{end_date};
|
||||
$result->{frequency} = $params->{frequency};
|
||||
|
||||
#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};
|
||||
}
|
||||
|
||||
#print '<pre>'.Dumper($params).'</pre>';
|
||||
template::process('print', $params->{template}, $params);
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub showDates {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
sub showDates{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{read_studio_timeslot_schedule}==1){
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('read_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $param ('project_id','studio_id'){
|
||||
unless(defined $params->{$param}){
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission (keys %{$request->{permissions}}){
|
||||
$params->{'allow'}->{$permission}=$request->{permissions}->{$permission};
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission ( keys %{ $request->{permissions} } ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
|
||||
my $fromDate=$params->{show_date}.'-01-01';
|
||||
my $tillDate=$params->{show_date}.'-12-31';
|
||||
#add timeslot dates
|
||||
my $timeslot_dates=studio_timeslot_dates::get(
|
||||
$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'});
|
||||
my $language=$params->{loc}->{region};
|
||||
my $fromDate = $params->{show_date} . '-01-01';
|
||||
my $tillDate = $params->{show_date} . '-12-31';
|
||||
|
||||
# translate weekday names to selected language
|
||||
my $weekday={
|
||||
'Mo' => $params->{loc}->{weekday_Mo},
|
||||
'Tu' => $params->{loc}->{weekday_Tu},
|
||||
'We' => $params->{loc}->{weekday_We},
|
||||
'Th' => $params->{loc}->{weekday_Th},
|
||||
'Fr' => $params->{loc}->{weekday_Fr},
|
||||
'Sa' => $params->{loc}->{weekday_Sa},
|
||||
'Su' => $params->{loc}->{weekday_Su},
|
||||
};
|
||||
#add timeslot dates
|
||||
my $timeslot_dates = studio_timeslot_dates::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
|
||||
my $studios=studios::get($config, {project_id=>$project_id});
|
||||
my $studio_by_id={};
|
||||
for my $studio (@$studios){
|
||||
$studio_by_id->{$studio->{id}}=$studio;
|
||||
}
|
||||
# studio_id=>$studio_id,
|
||||
from => $fromDate,
|
||||
till => $tillDate
|
||||
}
|
||||
);
|
||||
|
||||
#remove seconds from dates
|
||||
for my $date (@$timeslot_dates){
|
||||
#remove seconds from datetimes
|
||||
$date->{start}=~s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
$date->{end}=~s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio_timeslots' } );
|
||||
my $language = $params->{loc}->{region};
|
||||
|
||||
# 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};
|
||||
}
|
||||
my $result={
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
dates => $timeslot_dates
|
||||
};
|
||||
|
||||
#copy entry values to params
|
||||
for my $key (keys %$result){
|
||||
$params->{$key}=$result->{$key};
|
||||
# translate weekday names to selected language
|
||||
my $weekday = {
|
||||
'Mo' => $params->{loc}->{weekday_Mo},
|
||||
'Tu' => $params->{loc}->{weekday_Tu},
|
||||
'We' => $params->{loc}->{weekday_We},
|
||||
'Th' => $params->{loc}->{weekday_Th},
|
||||
'Fr' => $params->{loc}->{weekday_Fr},
|
||||
'Sa' => $params->{loc}->{weekday_Sa},
|
||||
'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 $template=template::check('studio_timeslot_dates');
|
||||
template::process('print', $template, $params);
|
||||
|
||||
#remove seconds from dates
|
||||
for my $date (@$timeslot_dates) {
|
||||
|
||||
#remove seconds from datetimes
|
||||
$date->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
$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};
|
||||
}
|
||||
my $result = {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
dates => $timeslot_dates
|
||||
};
|
||||
|
||||
#copy entry values to params
|
||||
for my $key ( keys %$result ) {
|
||||
$params->{$key} = $result->{$key};
|
||||
}
|
||||
|
||||
my $template = template::check('studio_timeslot_dates');
|
||||
template::process( 'print', $template, $params );
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#actions and roles
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(show|save_schedule|delete_schedule|show_dates)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(show|save_schedule|delete_schedule|show_dates)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude}=0;
|
||||
for my $param ('id', 'project_id', 'studio_id', 'default_studio_id', 'schedule_id', 'schedule_studio_id'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^\d+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
if ((defined $params->{show_date})&&($params->{show_date}=~/^(\d\d\d\d)/)){
|
||||
$checked->{show_date}=$1;
|
||||
}else{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
$checked->{template}=template::check($params->{template},'studio_timeslots');
|
||||
|
||||
for my $param ('frequency'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/(\d+)/)){
|
||||
$checked->{$param}=$1;
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_id', 'schedule_id', 'schedule_studio_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
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';
|
||||
if ( ( defined $params->{show_date} ) && ( $params->{show_date} =~ /^(\d\d\d\d)/ ) ) {
|
||||
$checked->{show_date} = $1;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
$checked->{template} = template::check( $params->{template}, 'studio_timeslots' );
|
||||
|
||||
for my $param ('frequency') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
for my $attr ('end_date'){
|
||||
if ((defined $params->{$attr}) && ($params->{$attr}=~/(\d\d\d\d\-\d\d\-\d\d)/)){
|
||||
$checked->{$attr}=$1;
|
||||
|
||||
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 ('end_date') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) ) {
|
||||
$checked->{$attr} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user