residential prospects, RT#7111
[freeside.git] / httemplate / edit / svc_dsl.cgi
index f086033..48464fb 100644 (file)
@@ -23,12 +23,12 @@ my $html_foot = sub {
 <SCRIPT TYPE=\"text/javascript\">
   function ikano_loop_type_changed() {
        var loop_type = document.getElementById('loop_type').value;
-       var svctn = document.getElementById('svctn');
+       var phonenum = document.getElementById('phonenum');
        if(loop_type == '0') {
-           svctn.value = '';
-           svctn.disabled = true;      
+           phonenum.value = '';
+           phonenum.disabled = true;   
        }
-       else svctn.disabled = false;
+       else phonenum.disabled = false;
   }
 </SCRIPT>";
 };
@@ -55,7 +55,7 @@ my $edit_cb = sub {
        # else add any other export-specific stuff here
     }
     else {
-       # XXX allow editing everything
+       push @fields, qw( first last company phonenum circuitnum rate_band vpi vci );
     }
 };
 
@@ -65,7 +65,6 @@ my $new_cb = sub {
     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;
@@ -85,18 +84,26 @@ my $new_cb = sub {
              value => $cust_main->ship_company ? $cust_main->ship_company
                                                : $cust_main->company,
            },
-           { field => 'svctn',
+           { field => 'phonenum',
              value => $defsvctn,
            },
        );
 
+    if ( scalar(@exports) == 1 ) {
        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;
+           my $ddd = $cust_pkg->start_date;
+           $ddd = time unless $ddd;
 
-           die "no start date set on customer package" if !$cust_pkg->start_date;
+           my @quals = $export->quals_by_cust_and_pkg($cust_pkg->cust_main->custnum,$cust_pkg->pkgpart);
+           my @prequalids;
+           my %prequal_labels;
+           foreach my $qual ( @quals ) {
+               my $prequalid = $qual->vendor_qual_id;
+               push @prequalids, $prequalid;
+               $prequal_labels{$prequalid} = "$prequalid - qualification #"
+                                                           .$qual->qualnum;
+           }
 
            my @addl_fields = ( 
                { field => 'loop_type',
@@ -109,24 +116,27 @@ my $new_cb = sub {
                { field => 'isp_chg', type => 'checkbox', },
                'isp_prev',
                { field => 'vendor_qual_id', 
-                 type => 'fixed', 
-                 value => $vendor_qual_id,  },
+                 type => 'select',
+                 options => \@prequalids,
+                 labels => \%prequal_labels,
+                 onchange => 'ikano_vendor_qual_id_changed',
+               },
                { field => 'vendor_order_type', 
                  type => 'hidden', 
-                 value => 'N' },
-               { field => 'desired_dd',
+                 value => 'NEW' },
+               { field => 'desired_due_date',
                  type => 'fixed',
                  formatted_value => 
-                   time2str($date_format,$cust_pkg->start_date),
-                 value => $cust_pkg->start_date
+                   time2str($date_format,$ddd),
+                 value => $ddd
                },
            );
            push @fields, @addl_fields;
        }
        # else add any other export-specific stuff here
     }
-    else {
-       # XXX display everything when no exports attached
+    else { # display non-export and non-Ikano fields
+       push @fields, qw( rate_band circuitnum vpi vci );
     }
 };
 </%init>