From 46ef8524cf2e6db7b851967062ce92ffb0773d10 Mon Sep 17 00:00:00 2001 From: levinse Date: Thu, 25 Nov 2010 01:46:34 +0000 Subject: ikano.pm initial commit, svc_dsl UI initial commit, and svc_dsl on-going work, RT7111 --- httemplate/view/elements/svc_Common.html | 10 ++++-- httemplate/view/svc_dsl.cgi | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 httemplate/view/svc_dsl.cgi (limited to 'httemplate/view') diff --git a/httemplate/view/elements/svc_Common.html b/httemplate/view/elements/svc_Common.html index 618d33eed..25845ddc5 100644 --- a/httemplate/view/elements/svc_Common.html +++ b/httemplate/view/elements/svc_Common.html @@ -52,18 +52,22 @@ function areyousure(href) { Service #<% $svcnum %> % my $url = $opt{'edit_url'} || $p. 'edit/'. $opt{'table'}. '.cgi?'; | Edit this <% $label %> + +% unless ( $opt{'disable_unprovision'} ) { | Unprovision this Service
+% } <% ntable("#cccccc") %><% ntable("#cccccc",2) %> % foreach my $f ( @$fields ) { % -% my($field, $type, $value); +% my($field, $type, $value, $hack_strict_refs); % if ( ref($f) ) { % $field = $f->{'field'}, -% $value = $f->{'value'} ? &{ $f->{'value'} }($svc_x) : $svc_x->$field; +% $hack_strict_refs = \&{ $f->{'value'} } if $f->{'value'}; +% $value = $f->{'value'} ? &$hack_strict_refs($svc_x) : $svc_x->$field; % $type = $f->{'type'} || 'text', % } else { % $field = $f; @@ -172,4 +176,6 @@ if ($pkgnum) { $custnum = ''; } +&{ $opt{'svc_callback'} }( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, \%opt ) + if $opt{'svc_callback'}; diff --git a/httemplate/view/svc_dsl.cgi b/httemplate/view/svc_dsl.cgi new file mode 100644 index 000000000..a4b2d4327 --- /dev/null +++ b/httemplate/view/svc_dsl.cgi @@ -0,0 +1,62 @@ +<% include('elements/svc_Common.html', + 'table' => 'svc_dsl', + 'labels' => \%labels, + 'fields' => \@fields, + 'svc_callback' => $svc_cb, + 'html_foot' => $html_foot, + ) +%> +<%init> +my $conf = new FS::Conf; +my $date_format = $conf->config('date_format') || '%m/%d/%Y'; + +my $fields = FS::svc_dsl->table_info->{'fields'}; +my %labels = map { $_ => ( ref($fields->{$_}) + ? $fields->{$_}{'label'} + : $fields->{$_} + ); + } keys %$fields; +my @fields = keys %$fields; + +my $footer; + +my $html_foot = sub { + return $footer; +}; + +my $svc_cb = sub { + my( $cgi,$svc_x, $part_svc,$cust_pkg, $fields1,$opt) = @_; + + my @exports = $part_svc->part_export_dsl_pull; + die "more than one DSL-pulling export attached to svcpart ".$part_svc->svcpart + if ( scalar(@exports) > 1 ); + + # if no DSL-pulling exports, then just display everything, which is the + # default behaviour implemented above + return if ( scalar(@exports) == 0 ); + + $opt->{'disable_unprovision'} = 1; + my $exporttype = @exports[0]->exporttype; + + # XXX: AJAX auto-pull + + @fields = qw( svctn first last company username password ); + + if($exporttype eq 'ikano') { + push @fields, 'isp_chg'; + push @fields, 'isp_prev'; + push @fields, 'staticips'; + } + else { + # XXX + } + + # hack against "can't use string ... as a subroutine ref while 'strict refs' in use" + my $statusSub = \&{'FS::part_export::'.$exporttype.'::status_line'}; + my $statusLine = &$statusSub($svc_x,$date_format,"
"); + + $footer = "$statusLine"; + + # XXX: notes +}; + -- cgit v1.2.1