more sane svc_dsl UI, RT7111
authorlevinse <levinse>
Thu, 25 Nov 2010 20:02:55 +0000 (20:02 +0000)
committerlevinse <levinse>
Thu, 25 Nov 2010 20:02:55 +0000 (20:02 +0000)
FS/FS/part_export/ikano.pm
httemplate/edit/svc_dsl.cgi
httemplate/view/elements/svc_Common.html
httemplate/view/svc_dsl.cgi

index b14f3a4..a5d8ece 100644 (file)
@@ -37,25 +37,19 @@ sub dsl_pull {
 }
 
 sub status_line {
-    my($self,$svc_dsl,$date_format,$separator) = (shift,shift,shift,shift);
+    my($self,$svc_dsl) = (shift,shift,shift,shift);
     my %orderTypes = ( 'N' => 'New', 'X' => 'Cancel', 'C' => 'Change' );
     my %orderStatus = ( 'N' => 'New', 'P' => 'Pending', 'X' => 'Cancelled',
                        'C' => 'Completed', 'E' => 'Error' );
-    my $status = "Ikano ".$orderTypes{$svc_dsl->vendor_order_type}." order #"
+    return "Ikano ".$orderTypes{$svc_dsl->vendor_order_type}." order #"
        . $svc_dsl->vendor_order_id . " (Status: " 
-       . $orderStatus{$svc_dsl->vendor_order_status} . ") $separator ";
-    my $monitored = $svc_dsl->monitored eq 'Y' ? 'Yes' : 'No';
-    my $pushed = $svc_dsl->pushed ? 
-               time2str("$date_format %k:%M",$svc_dsl->pushed) : "never";
-    my $last_pull = $svc_dsl->last_pull ? 
-               time2str("$date_format %k:%M",$svc_dsl->last_pull) : "never";
-    my $ddd = $svc_dsl->desired_dd ? time2str($date_format,$svc_dsl->desired_dd)
-                                  : "";
-    my $dd = $svc_dsl->dd ? time2str($date_format,$svc_dsl->dd) : "";
-    $status .= "$separator Pushed: $pushed   Monitored: $monitored  Last Pull: ";
-    $status .= "$lastpull $separator $separator Desired Due Date: $ddd  ";
-    $status .= "Due Date: $dd";
-    return $status;    
+       . $orderStatus{$svc_dsl->vendor_order_status} . ")";
+}
+
+sub loop_type_long {
+    my($svc_dsl) = shift;
+    return "Standalone" if $svc_dsl->loop_type eq '0';
+    return "Line-share";
 }
 
 sub ikano_command {
index 3568fbd..f086033 100644 (file)
@@ -3,6 +3,7 @@
            'fields'    => \@fields,
            'svc_new_callback' => $new_cb,
            'svc_edit_callback' => $edit_cb,
+           'html_foot' => $html_foot,
          )
 %>
 <%init>
@@ -16,7 +17,21 @@ 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 $html_foot = sub {
+    return "
+<SCRIPT TYPE=\"text/javascript\">
+  function ikano_loop_type_changed() {
+       var loop_type = document.getElementById('loop_type').value;
+       var svctn = document.getElementById('svctn');
+       if(loop_type == '0') {
+           svctn.value = '';
+           svctn.disabled = true;      
+       }
+       else svctn.disabled = false;
+  }
+</SCRIPT>";
+};
 
 my $edit_cb = sub {
     my( $cgi,$svc_x, $part_svc,$cust_pkg, $fields1,$opt) = @_;
@@ -37,12 +52,10 @@ my $edit_cb = sub {
                } unless ( $hf eq 'password' || $hf eq 'monitored' );
            }
        }
-       else {
-           # XXX
-       }
+       # else add any other export-specific stuff here
     }
     else {
-       # XXX
+       # XXX allow editing everything
     }
 };
 
@@ -77,8 +90,6 @@ my $new_cb = sub {
            },
        );
 
-       my $loop_type = { field => 'loop_type' };
-
        my $export = @exports[0];               
        if($export->exporttype eq 'ikano') {
            $cgi->param('vendor_qual_id') =~ /^(\d+)$/ 
@@ -87,39 +98,35 @@ my $new_cb = sub {
 
            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';
+           my @addl_fields = ( 
+               { field => 'loop_type',
+                 type => 'select',
+                 options => [ '', '0' ],
+                 labels => { '' => 'Line-share', '0', => 'Standalone' },
+                 onchange => 'ikano_loop_type_changed',
+               },
+               'password', 
+               { field => 'isp_chg', type => 'checkbox', },
+               'isp_prev',
+               { field => 'vendor_qual_id', 
+                 type => 'fixed', 
+                 value => $vendor_qual_id,  },
+               { field => 'vendor_order_type', 
+                 type => 'hidden', 
+                 value => 'N' },
+               { field => 'desired_dd',
+                 type => 'fixed',
+                 formatted_value => 
+                   time2str($date_format,$cust_pkg->start_date),
+                 value => $cust_pkg->start_date, 
+               },
+           );
+           push @fields, @addl_fields;
        }
-       
-       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 add any other export-specific stuff here
     }
     else {
-       # XXX
+       # XXX display everything when no exports attached
     }
 };
 </%init>
index 25845dd..e3b8da4 100644 (file)
@@ -65,10 +65,10 @@ Unprovision this Service</A>
 %
 %   my($field, $type, $value, $hack_strict_refs);
 %   if ( ref($f) ) {
-%     $field = $f->{'field'},
+%     $field = $f->{'field'};
 %     $hack_strict_refs = \&{ $f->{'value'} } if $f->{'value'};
 %     $value = $f->{'value'} ? &$hack_strict_refs($svc_x) : $svc_x->$field;
-%     $type  = $f->{'type'} || 'text',
+%     $type  = $f->{'type'} || 'text';
 %   } else {
 %     $field = $f;
 %     $value = $svc_x->$field;
@@ -86,6 +86,9 @@ Unprovision this Service</A>
           %>
         </TD>
 
+%      $value = time2str($date_format,$value) if ( $type eq 'date' && $value );
+%      $value = time2str("$date_format %H:%M",$value) if ( $type eq 'datetime' && $value );
+%      $value = $value eq 'Y' ? 'Yes' : 'No' if ( $type eq 'checkbox' );
 %       #eventually more options for <SELECT>, etc. fields
 
         <TD BGCOLOR="#ffffff"><% $value %><TD>
@@ -125,6 +128,9 @@ die "access denied"
 
 my(%opt) = @_;
 
+my $conf = new FS::Conf;
+my $date_format = $conf->config('date_format') || '%m/%d/%Y';
+
 my $table = $opt{'table'};
 
 my $fields = $opt{'fields'}
index b460c01..fd998ae 100644 (file)
@@ -7,8 +7,8 @@
           )
 %>
 <%init>
-my $conf = new FS::Conf;
-my $date_format = $conf->config('date_format') || '%m/%d/%Y';
+
+# XXX: AJAX auto-pull
 
 my $fields = FS::svc_dsl->table_info->{'fields'};
 my %labels = map { $_ =>  ( ref($fields->{$_})
@@ -38,21 +38,25 @@ my $svc_cb = sub {
     my $export = @exports[0];
     $opt->{'disable_unprovision'} = 1;
 
-    # XXX: AJAX auto-pull
-       
-    @fields = qw( svctn first last company username password );
+    @fields = ( 'svctn',
+           { field => 'loop_type', 
+             value => 'FS::part_export::'.$export->exporttype.'::loop_type_long'
+           },
+           { field => 'desired_dd', type => 'date', },
+           { field => 'dd', type => 'date', },
+           { field => 'pushed', type => 'datetime', },
+           { field => 'monitored', type => 'checkbox', },
+           { field => 'last_pull', type => 'datetime', },
+           'first',
+           'last',
+           'company'  );
 
     if($export->exporttype eq 'ikano') {
-       push @fields, 'isp_chg';
-       push @fields, 'isp_prev';
-       push @fields, 'staticips';
-    }
-    else {
-       # XXX
+       push @fields, qw ( username password isp_chg isp_prev staticips );
     }
+    # else add any other export-specific stuff here
    
-    $footer = "<B>".$export->status_line($svc_x,$date_format,"<BR>")."</B>";
-
-    # XXX: notes
+    $footer = "<B>".$export->status_line($svc_x)."</B>";
+    $footer .= "<BR><BR><BR>Order Notes:<BR>".$export->notes_html;
 };
 </%init>