From e89dfa5f4a2190e9b1e9c6408636b260d1e15f26 Mon Sep 17 00:00:00 2001 From: Gerhard Jungwirth Date: Fri, 10 May 2013 17:33:51 +0200 Subject: [PATCH] show peaktime dates as datatables table --- lib/NGCP/Panel/Controller/Billing.pm | 28 ++++++++++++++++++++++++++++ lib/NGCP/Panel/Controller/Root.pm | 2 +- share/templates/billing/peaktimes.tt | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/lib/NGCP/Panel/Controller/Billing.pm b/lib/NGCP/Panel/Controller/Billing.pm index 94719066de..2627efc6b6 100644 --- a/lib/NGCP/Panel/Controller/Billing.pm +++ b/lib/NGCP/Panel/Controller/Billing.pm @@ -419,6 +419,26 @@ sub load_weekdays { $c->stash(weekdays => \@weekdays); } +sub peaktime_specials_ajax :Chained('peaktimes_list') :PathPart('ajax') :Args(0) { + my ($self, $c) = @_; + + my $resultset = $c->stash->{'profile_result'}->billing_peaktime_specials; + + $c->forward( "/ajax_process_resultset", [$resultset, + ["id", "start", "end",], + [1,2]]); + + for my $row (@{ $c->stash->{aaData} }) { + my $date = $row->[1]->date; + my $start = $row->[1]->hms; + my $end = $row->[2]->hms; + $row->[1] = $date; + $row->[2] = $start . ' - ' . $end; + } + + $c->detach( $c->view("JSON") ); +} + __PACKAGE__->meta->make_immutable; 1; @@ -537,6 +557,14 @@ Show a modal to edit one weekday. creates a weekdays structure from the stash variable weekdays_result puts the result under weekdays on stash (will be used by template) +=head2 peaktime_specials_ajax + +Returns an ajax representation of billing_peaktime_specials under the current +billing_profile. The rows are modified so that the final form will be +(id, date, startend). + +This depends on inflation being activated in the schema. + =head1 AUTHOR Gerhard Jungwirth C<< >> diff --git a/lib/NGCP/Panel/Controller/Root.pm b/lib/NGCP/Panel/Controller/Root.pm index bfab87b5cf..21ab1158c4 100644 --- a/lib/NGCP/Panel/Controller/Root.pm +++ b/lib/NGCP/Panel/Controller/Root.pm @@ -229,7 +229,7 @@ sub ajax_process_resultset :Private { } for my $row ($rs->all) { - my %tmpRow = $row->get_columns; + my %tmpRow = $row->get_inflated_columns; my @aaRow = @tmpRow{@$columns}; push @$aaData, \@aaRow; } diff --git a/share/templates/billing/peaktimes.tt b/share/templates/billing/peaktimes.tt index 0f51d92c51..c6b35f7545 100644 --- a/share/templates/billing/peaktimes.tt +++ b/share/templates/billing/peaktimes.tt @@ -47,6 +47,20 @@

Dates

+[% + helper.name = 'Billing Profiles'; + helper.column_titles = [ '#', 'Date', 'Start-End' ]; + helper.column_fields = [ 'id', 'date', 'startend' ]; + + helper.create_flag = 0; + helper.edit_flag = 0; + helper.has_edit = 1; + helper.has_preferences = 0; + helper.ajax_uri = c.uri_for_action("/billing/peaktime_specials_ajax", [c.req.captures.0]); + helper.base_uri = ""; + + PROCESS 'helpers/datatables.tt'; +-%] [% IF edit_flag -%] [%