diff --git a/lib/csc/Controller/callforward.pm b/lib/csc/Controller/callforward.pm index 4886aef..f9533eb 100644 --- a/lib/csc/Controller/callforward.pm +++ b/lib/csc/Controller/callforward.pm @@ -531,30 +531,25 @@ sub time_period_post : Chained('time') PathPart('period') CaptureArgs(0) { sub time_period_edit : Chained('time_period_get') PathPart('edit') Args(0) { my ( $self, $c ) = @_; - # done that's it - # maybe join with time_period_get() ? } sub time_period_save : Chained('time_period_post') PathPart('save') Args(0) { my ( $self, $c ) = @_; + + warn 'from_year: ' . $c->request->params->{from_year}; + warn 'to_year : . ' . $c->request->params->{to_year}; my %period; - $period{year} = $c->request->params->{year}; $period{from_year} = $c->request->params->{from_year}; $period{to_year} = $c->request->params->{to_year}; - $period{month} = $c->request->params->{month}; $period{from_month} = $c->request->params->{from_month}; $period{to_month} = $c->request->params->{to_month}; - $period{mday} = $c->request->params->{mday}; $period{from_mday} = $c->request->params->{from_mday}; $period{to_mday} = $c->request->params->{to_mday}; - $period{wday} = $c->request->params->{wday}; $period{from_wday} = $c->request->params->{from_wday}; $period{to_wday} = $c->request->params->{to_wday}; - $period{hour} = $c->request->params->{hour}; $period{from_hour} = $c->request->params->{from_hour}; $period{to_hour} = $c->request->params->{to_hour}; - $period{minute} = $c->request->params->{minute}; $period{from_minute} = $c->request->params->{from_minute}; $period{to_minute} = $c->request->params->{to_minute}; @@ -566,19 +561,19 @@ sub time_period_save : Chained('time_period_post') PathPart('save') Args(0) { if ($c->stash->{tperiod_id}) { $ret = $c->model('Provisioning')->call_prov( $c, 'voip', 'update_subscriber_cf_time_period', { username => $c->stash->{subscriber}->{username}, - domain => $c->stash->{subscriber}->{domain}, - set_id => $c->stash->{tset_id}, - data => \%period, + domain => $c->stash->{subscriber}->{domain}, + set_id => $c->stash->{tset_id}, + data => \%period, }, undef, ); - } + } else { $ret = $c->model('Provisioning')->call_prov( $c, 'voip', 'create_subscriber_cf_time_period', { username => $c->stash->{subscriber}->{username}, - domain => $c->stash->{subscriber}->{domain}, - set_id => $c->stash->{tset_id}, - data => \%period, + domain => $c->stash->{subscriber}->{domain}, + set_id => $c->stash->{tset_id}, + data => \%period, }, undef, ); @@ -588,9 +583,9 @@ sub time_period_save : Chained('time_period_post') PathPart('save') Args(0) { $c->session->{messages} = { topmsg => 'Server.Voip.SavedSettings' } } else { - $c->session->{messages} = { toperr => 'Client.Voip.InputErrorFound' } + $c->session->{messages} = { toperr => 'Client.Voip.InputErrorFound' } } - + $c->response->redirect($c->uri_for('/callforward/time')); } @@ -706,7 +701,6 @@ sub load_cf_types :Private { ]; } - sub period_expand : Private { my ($self, $period) = @_; @@ -730,43 +724,25 @@ sub period_collapse : Private { my ($self, $period) = @_; foreach my $part ('year', 'month', 'mday', 'wday', 'hour', 'minute') { - my $from = $period->{'from_' . $part}; - my $to = $period->{'to_' . $part}; + my $from = ( $period->{'from_' . $part} >= 0 ) ? $period->{'from_' . $part} : undef; + my $to = ( $period->{'to_' . $part} >= 0 ) ? $period->{'to_' . $part} : undef; my $collapsed; - if ($from) { + if (defined $from) { $collapsed = $from; - if ($to) { - if ($from < $to) { - $collapsed .= '-' . $to; - } - elsif ($from > $to) { - return -1; - } + if (defined $to) { + $collapsed .= '-' . $to; } } + delete $period->{'from_' . $part}; delete $period->{'to_' . $part}; $period->{$part} = $collapsed; + + warn $part . ': ' . $collapsed; } - return 0; + 1; } -sub dbg { - my ($thing, $msg) = @_; - use Data::Dumper; - - my @c = caller (1); - my $subname = $c[3]; - - if (ref $thing eq 'ARRAY' or ref $thing eq 'HASH') { - warn ' ===DBG=== ' . $msg if ($msg); - warn ' ===DBG=== ' . $subname . '(): '. Dumper $thing; - } - else { - warn ' ===DBG=== ' . $msg if ($msg); - warn ' ===DBG=== ' . $subname . '(): '. $thing;; - } -} 1; diff --git a/root/css/sipwise.css b/root/css/sipwise.css index b11e5bd..86c2c69 100644 --- a/root/css/sipwise.css +++ b/root/css/sipwise.css @@ -896,12 +896,18 @@ select.dateform-elem { } div.dateform-elem { - width: 67px; + width: 60px; height: 60px; - margin: 0; + border: 1px solid #c3dae8; + margin: 5px 0px 5px 0px; + padding: 7px; text-align: center; } +a { + font-size: 12px; +} + /* basic grid-layout */ .span-1, .span-2, .span-3, .span-4, .span-5, .span-6, .span-7, .span-8, .span-9, .span-10, .span-11, .span-12, .span-13, .span-14, .span-15, .span-16, .span-17, .span-18, .span-19, .span-20, .span-21, .span-22, .span-23, .span-24 {float:left;margin-right:10px;} .last {margin-right:0;} diff --git a/root/js/csc.js b/root/js/csc.js index a682faa..ba533f0 100644 --- a/root/js/csc.js +++ b/root/js/csc.js @@ -53,6 +53,7 @@ function create_period_part (kind, disabled, selected, name) { var function_name = 'get_' + name + 's'; var steps = window[function_name] (); + var html = ''; if (disabled == 1) { @@ -62,14 +63,18 @@ function create_period_part (kind, disabled, selected, name) { html += ''; @@ -78,40 +83,37 @@ function create_period_part (kind, disabled, selected, name) { } function get_years () { - var years = Array(); + var years = Array(); var d = new Date(); var current_year = d.getFullYear(); for (var i = 0; i < 10 ; i++) { - years.push (current_year + i) + years.push ( {value: current_year+i, label: current_year+i} ); } return years; } -function get_mdays () { - var stuff = Array(31); - - console.log ('length: ' + stuff.length); - - for (var i = 0; i < stuff.length; i++) { - stuff[i] = i+1; +function get_mdays () { + var stuff = Array (); + for (var i = 0; i < 31; i++) { + stuff.push ( {value: i+1, label: i+1 } ); } return stuff; } -function get_hours () { - var stuff = Array(24); - for (var i = 0; i < stuff.length; i++) { - stuff[i] = i; +function get_hours () { + var stuff = Array (); + for (var i = 0; i < 24; i++) { + stuff.push ( {value: i, label: i } ); } return stuff; } -function get_minutes () { - var stuff = Array(60); - for (var i = 0; i < stuff.length; i++) { - stuff[i] = i; +function get_minutes () { + var stuff = Array (); + for (var i = 0; i < 60; i++) { + stuff.push ( {value: i, label: i } ); } return stuff; } @@ -130,7 +132,7 @@ function print_html (target, html, disabled) { function remove_html (target, disabled) { - $("#" + target).empty() + $("#" + target).empty().append('

any

'); if (disabled == 1) { $("#" + target + "-foot").empty(); diff --git a/root/tt/callforward_time.tt b/root/tt/callforward_time.tt index f593727..27f645f 100644 --- a/root/tt/callforward_time.tt +++ b/root/tt/callforward_time.tt @@ -191,32 +191,40 @@ }); function get_months () { - return [ - "[% Catalyst.loc('Jan') %]", - "[% Catalyst.loc('Feb') %]", - "[% Catalyst.loc('Mar') %]", - "[% Catalyst.loc('Apr') %]", - "[% Catalyst.loc('May') %]", - "[% Catalyst.loc('Jun') %]", - "[% Catalyst.loc('Jul') %]", - "[% Catalyst.loc('Aug') %]", - "[% Catalyst.loc('Sep') %]", - "[% Catalyst.loc('Oct') %]", - "[% Catalyst.loc('Nov') %]", - "[% Catalyst.loc('Dec') %]" - ]; + + var stuff = Array (); + var i = 1; + + stuff.push ({ value: i++, label: '[% Catalyst.loc("Jan") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Feb") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Mar") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Apr") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("May") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Jun") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Jul") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Aug") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Sep") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Oct") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Nov") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Dec") %]' }); + + return stuff; } function get_wdays () { - return [ - "[% Catalyst.loc('Mon') %]", - "[% Catalyst.loc('Tue') %]", - "[% Catalyst.loc('Wed') %]", - "[% Catalyst.loc('Thu') %]", - "[% Catalyst.loc('Fri') %]", - "[% Catalyst.loc('Sat') %]", - "[% Catalyst.loc('Sun') %]", - ]; + + var stuff = Array (); + var i = 1; + + stuff.push ({ value: i++, label: '[% Catalyst.loc("Mon") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Tue") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Wed") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Thu") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Fri") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Sat") %]' }); + stuff.push ({ value: i++, label: '[% Catalyst.loc("Sun") %]' }); + + return stuff; } @@ -234,13 +242,12 @@ [% from = 'from_' _ part %] [% to = 'to_' _ part %] - [% selected = (period.$part.defined) ? period.$part : 0 %] - [% selected_from = (period.$from.defined) ? period.$from : 0 %] - [% selected_to = (period.$to.defined) ? period.$to : 0 %] + [% selected_from = (period.$from.defined) ? period.$from : -1 %] + [% selected_to = (period.$to.defined) ? period.$to : -1 %] - [% selected_option = (selected_from) ? selected_from : selected %] + [% selected_option = (selected_from >= 0) ? selected_from : -1 %] - [% IF selected or selected_from %] + [% IF (selected_from >= 0) %] [% f = "create_period_part ('from', $disabled, $selected_option , '$part') " %] [% t = "create_period_part ('to', $disabled, $selected_to, '$part') " %] [% html = html _ "print_html ('$target', $f + ' through
' + $t, $disabled);\n" %]