summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorlevinse <levinse>2010-11-25 01:46:34 +0000
committerlevinse <levinse>2010-11-25 01:46:34 +0000
commit46ef8524cf2e6db7b851967062ce92ffb0773d10 (patch)
tree5698390a5c5f95b15997264319f1a1303f97271e /httemplate
parent39289cd1e5a06044aa9a8dc3d2e4d8c9ffb02b11 (diff)
ikano.pm initial commit, svc_dsl UI initial commit, and svc_dsl on-going work, RT7111
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/elements/edit.html5
-rw-r--r--httemplate/edit/elements/svc_Common.html7
-rwxr-xr-xhttemplate/edit/part_svc.cgi1
-rw-r--r--httemplate/edit/process/svc_dsl.html10
-rw-r--r--httemplate/edit/svc_dsl.cgi125
-rw-r--r--httemplate/view/elements/svc_Common.html10
-rw-r--r--httemplate/view/svc_dsl.cgi62
7 files changed, 218 insertions, 2 deletions
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 3d828478f..142d0c3ae 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -311,6 +311,11 @@ Example:
% foreach grep exists($f->{$_}),
% qw( hashref agent_virt agent_null agent_null_right );
%
+% # fixed
+% $include_common{$_} = $f->{$_}
+% foreach grep exists($f->{$_}),
+% qw( formatted_value );
+%
% #htmlarea
% $include_common{$_} = $f->{$_}
% foreach grep exists($f->{$_}), qw( width height );
diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html
index e74f44276..2e27f851d 100644
--- a/httemplate/edit/elements/svc_Common.html
+++ b/httemplate/edit/elements/svc_Common.html
@@ -29,6 +29,13 @@
die "No part_svc entry!" unless $part_svc;
label_fixup($part_svc, $opt);
+
+ if ( my $cb = $opt{'svc_edit_callback'} ) {
+ my $cust_pkg = $pkgnum
+ ? qsearchs('cust_pkg', {pkgnum=>$pkgnum})
+ : ''; #?
+ &{ $cb }( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt);
+ }
},
'new_hashref_callback' => sub {
diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi
index 50bc79c02..d156ccd0a 100755
--- a/httemplate/edit/part_svc.cgi
+++ b/httemplate/edit/part_svc.cgi
@@ -16,6 +16,7 @@ Service definitions are the templates for items you offer to your customers.
<UL><LI>svc_acct - Accounts - anything with a username (Mailboxes, PPP accounts, shell accounts, RADIUS entries for broadband, etc.)
<LI>svc_domain - Domains
<LI>svc_cert - Certificates
+ <LI>svc_dsl - DSL
<LI>svc_forward - Mail forwarding
<LI>svc_mailinglist - Mailing list
<LI>svc_www - Virtual domain website
diff --git a/httemplate/edit/process/svc_dsl.html b/httemplate/edit/process/svc_dsl.html
new file mode 100644
index 000000000..627329a00
--- /dev/null
+++ b/httemplate/edit/process/svc_dsl.html
@@ -0,0 +1,10 @@
+<% include( 'elements/svc_Common.html',
+ 'table' => 'svc_dsl',
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+</%init>
diff --git a/httemplate/edit/svc_dsl.cgi b/httemplate/edit/svc_dsl.cgi
new file mode 100644
index 000000000..3568fbd7d
--- /dev/null
+++ b/httemplate/edit/svc_dsl.cgi
@@ -0,0 +1,125 @@
+<% include( 'elements/svc_Common.html',
+ 'table' => 'svc_dsl',
+ 'fields' => \@fields,
+ 'svc_new_callback' => $new_cb,
+ 'svc_edit_callback' => $edit_cb,
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+my $conf = new FS::Conf;
+my $date_format = $conf->config('date_format') || '%m/%d/%Y';
+
+my $ti_fields = FS::svc_dsl->table_info->{'fields'};
+
+my @fields = ();
+my @uneditable = qw( pushed vendor_qual_id isp_chg isp_prev staticips last_pull notes );
+
+my $edit_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 ( scalar(@exports) == 1 ) {
+ my $export = @exports[0];
+ if($export->exporttype eq 'ikano') {
+ @fields = ( 'password', 'monitored', );
+
+ foreach my $hf ( keys %$ti_fields ) {
+ push @fields, {
+ field => $hf,
+ type => 'hidden',
+ value => $svc_x->$hf,
+ } unless ( $hf eq 'password' || $hf eq 'monitored' );
+ }
+ }
+ else {
+ # XXX
+ }
+ }
+ else {
+ # XXX
+ }
+};
+
+my $new_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 ( scalar(@exports) == 1 ) {
+ my $cust_main = $cust_pkg->cust_main;
+ my $defsvctn = $cust_main->ship_daytime ? $cust_main->ship_daytime
+ : $cust_main->daytime;
+ $defsvctn =~ s/[^0-9]//g;
+
+ @fields = (
+ { field => 'first',
+ value => $cust_main->ship_first ? $cust_main->ship_first
+ : $cust_main->first,
+ },
+ { field => 'last',
+ value => $cust_main->ship_last ? $cust_main->ship_last
+ : $cust_main->last,
+ },
+ { field => 'company',
+ value => $cust_pkg->cust_main->ship_company,
+ value => $cust_main->ship_company ? $cust_main->ship_company
+ : $cust_main->company,
+ },
+ { field => 'svctn',
+ value => $defsvctn,
+ },
+ );
+
+ my $loop_type = { field => 'loop_type' };
+
+ my $export = @exports[0];
+ if($export->exporttype eq 'ikano') {
+ $cgi->param('vendor_qual_id') =~ /^(\d+)$/
+ or die 'unparsable vendor_qual_id';
+ my $vendor_qual_id = $1;
+
+ die "no start date set on customer package" if !$cust_pkg->start_date;
+
+ $loop_type = { field => 'loop_type',
+ type => 'select',
+ options => [ '', '0' ],
+ labels => { '' => 'Line-share', '0', => 'Standalone' },
+ # onchange => "document.getElementById('svctn').value = ''",
+ };
+ push @fields, { field => 'isp_chg', type => 'checkbox', };
+ push @fields, 'isp_prev';
+ push @fields, { field => 'vendor_qual_id',
+ type => 'fixed',
+ value => $vendor_qual_id,
+ };
+ }
+ else {
+ push @fields, 'username';
+ }
+
+ push @fields, 'password';
+
+ push @fields, $loop_type;
+
+ push @fields, { field => 'vendor_order_type',
+ type => 'hidden',
+ value => 'N' };
+ push @fields, { field => 'desired_dd',
+ type => 'fixed',
+ formatted_value =>
+ time2str($date_format,$cust_pkg->start_date),
+ value => $cust_pkg->start_date,
+ };
+ }
+ else {
+ # XXX
+ }
+};
+</%init>
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 #<B><% $svcnum %></B>
% my $url = $opt{'edit_url'} || $p. 'edit/'. $opt{'table'}. '.cgi?';
| <A HREF="<%$url%><%$svcnum%>">Edit this <% $label %></A>
+
+% unless ( $opt{'disable_unprovision'} ) {
| <A HREF="javascript:areyousure('<%$p.'misc/unprovision.cgi?'.$svcnum%>')">
Unprovision this Service</A>
<BR>
+% }
<% ntable("#cccccc") %><TR><TD><% 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'};
</%init>
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,"<BR>");
+
+ $footer = "<B>$statusLine</B>";
+
+ # XXX: notes
+};
+</%init>