diff --git a/lib/NGCP/Panel/Controller/Subscriber.pm b/lib/NGCP/Panel/Controller/Subscriber.pm index f8df5f2a9b..233b842911 100644 --- a/lib/NGCP/Panel/Controller/Subscriber.pm +++ b/lib/NGCP/Panel/Controller/Subscriber.pm @@ -248,6 +248,9 @@ sub preferences :Chained('base') :PathPart('preferences') :Args(0) { my @tset = (); if($map->time_set) { @tset = map { { $_->get_columns } } $map->time_set->voip_cf_periods->all; + foreach my $t(@tset) { + $t->{as_string} = NGCP::Panel::Utils::Subscriber::period_as_string($t); + } } push @{ $cfs->{$type} }, { destinations => \@dset, periods => \@tset }; } @@ -895,10 +898,9 @@ sub preferences_callforward_timeset :Chained('base') :PathPart('preferences/time if($prov_subscriber->voip_cf_time_sets) { foreach my $set($prov_subscriber->voip_cf_time_sets->all) { if($set->voip_cf_periods) { - my @periods = (); - foreach my $period($set->voip_cf_periods->all) { - my %cols = $period->get_columns; - push @periods, \%cols; + my @periods = map { { $_->get_columns } } $set->voip_cf_periods->all; + foreach my $p(@periods) { + $p->{as_string} = NGCP::Panel::Utils::Subscriber::period_as_string($p); } push @sets, { name => $set->name, id => $set->id, periods => \@periods}; } diff --git a/lib/NGCP/Panel/Utils/Subscriber.pm b/lib/NGCP/Panel/Utils/Subscriber.pm index 3e087028b7..fcf80c3018 100644 --- a/lib/NGCP/Panel/Utils/Subscriber.pm +++ b/lib/NGCP/Panel/Utils/Subscriber.pm @@ -20,6 +20,38 @@ sub get_usr_preference_rs { return $preference; } +sub period_as_string { + my $set = shift; + + my @wdays = (qw/ + invalid Sunday Monday Tuesday Wednesday Thursday Friday Saturday + /); + my @months = (qw/ + invalid January February March April May June July August September October November December + /); + + my $string = ""; + foreach my $type(qw/year month mday wday hour minute/) { + my $s = $set->{$type}; + if(defined $s) { + given($type) { + when(/^month$/) { + my ($from, $to) = split /\-/, $s; + $s = $months[$from]; + $s .= '-'.$months[$to] if defined($to); + } + when(/^wday$/) { + my ($from, $to) = split /\-/, $s; + $s = $wdays[$from]; + $s .= '-'.$wdays[$to] if defined($to); + } + } + } + $string .= "$type { $s } " if defined($s); + } + return $string; +} + 1; =head1 NAME diff --git a/share/templates/subscriber/preferences.tt b/share/templates/subscriber/preferences.tt index a6f0a41a8b..1f487ca2fe 100644 --- a/share/templates/subscriber/preferences.tt +++ b/share/templates/subscriber/preferences.tt @@ -93,7 +93,7 @@ [% jdx = jdx + 1 %] [% END -%] [% FOR p IN maps.periods -%] - [% p.year %] [% p.month %] [% p.mday %] [% p.wday %] [% p.hour %] [% p.minute %]
+ [% p.as_string %]
[% jdx = jdx + 1 %] [% END -%] [% WHILE jdx < destinations.${idx} -%] @@ -218,7 +218,7 @@ [% set.name %] [% FOREACH p IN set.periods -%] - [% p.year %] [% p.month %] [% p.mday %] [% p.wday %] [% p.hour %] [% p.minute %]
+ [% p.as_string %]
[% END -%]