Pretty-print period definitions.

agranig/1_0_subfix
Andreas Granig 13 years ago
parent 9fa426139e
commit 076d7a8963

@ -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};
}

@ -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

@ -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 %]<br/>
[% p.as_string %]<br/>
[% jdx = jdx + 1 %]
[% END -%]
[% WHILE jdx < destinations.${idx} -%]
@ -218,7 +218,7 @@
<td>[% set.name %]</td>
<td>
[% FOREACH p IN set.periods -%]
[% p.year %] [% p.month %] [% p.mday %] [% p.wday %] [% p.hour %] [% p.minute %]<br/>
[% p.as_string %]<br/>
[% END -%]
</td>
<td class="ngcp-actions-column">

Loading…
Cancel
Save