finish existing customer dsl order, RT#7111
authorivan <ivan>
Mon, 28 Mar 2011 02:00:53 +0000 (02:00 +0000)
committerivan <ivan>
Mon, 28 Mar 2011 02:00:53 +0000 (02:00 +0000)
httemplate/edit/elements/svc_Common.html
httemplate/edit/process/quick-cust_pkg.cgi
httemplate/edit/svc_dsl.cgi
httemplate/elements/popup_link-cust_main.html
httemplate/misc/order_pkg.html
httemplate/view/cust_main/order_pkg_link.html
httemplate/view/qual.cgi

index 2e27f85..aa76995 100644 (file)
                    label_fixup($part_svc, $opt);
 
                    $svc_x->setfield('svcpart', $svcpart);
+
+                   if ( my $cb = $opt{'svc_error_callback'} ) {
+                     my $cust_pkg = $pkgnum
+                                      ? qsearchs('cust_pkg', {pkgnum=>$pkgnum})
+                                      : ''; #?
+                     &{ $cb }( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt);
+                   }
                  },
 
                  'edit_callback' => sub {
                    die "No part_svc entry!" unless $part_svc;
 
                    label_fixup($part_svc, $opt);
-                  
-                  if ( my $cb = $opt{'svc_edit_callback'} ) {
+                   
+                   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);
-                    }
+                     &{ $cb }( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt);
+                   }
                  },
 
                  'new_hashref_callback' => sub {
                  },
 
                  'new_callback' => sub {
-                    my( $cgi, $svc_x, $fields, $opt ) = @_;
+                   my( $cgi, $svc_x, $fields, $opt ) = @_;
 
-                    $part_svc = qsearchs( 'part_svc', { svcpart=>$svcpart });
-                    die "No part_svc entry!" unless $part_svc;
+                   $part_svc = qsearchs( 'part_svc', { svcpart=>$svcpart });
+                   die "No part_svc entry!" unless $part_svc;
 
-                    label_fixup($part_svc, $opt);
+                   label_fixup($part_svc, $opt);
 
-                    #$svcnum='';
+                   #$svcnum='';
 
-                    if ( my $cb = $opt{'svc_new_callback'} ) {
+                   if ( my $cb = $opt{'svc_new_callback'} ) {
                      my $cust_pkg = $pkgnum
-                                      ? qsearchs('cust_pkg', {pkgnum=>$pkgnum})
-                                      : ''; #?
-                      &{ $cb }( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt);
-                    }
+                                     ? qsearchs('cust_pkg', {pkgnum=>$pkgnum})
+                                     : ''; #?
+                     &{ $cb }( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt);
+                   }
 
-                    $svc_x->set_default_and_fixed;
+                   $svc_x->set_default_and_fixed;
 
                  },
 
index 704d256..a6449b8 100644 (file)
 % 
 % # for going right to a provision service after ordering a package
 % if ( $svcpart ) { 
-%    my $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
-%    if ( $part_svc ) {
-%      $redir_url = popurl(3)."edit/".$part_svc->svcdb.".cgi?"
-%                  ."pkgnum=".$cust_pkg->pkgnum.";svcpart=$svcpart";
-%   }
+%   $redir_url = popurl(3)."edit/".$part_svc->svcdb.".cgi?".
+%                  "pkgnum=".$cust_pkg->pkgnum. ";svcpart=$svcpart";
+%   $redir_url .= ";qualnum=$qualnum" if $qualnum;
 % }
 <% header('Package ordered') %>
   <SCRIPT TYPE="text/javascript">
@@ -61,13 +59,22 @@ $cgi->param('discountnum') =~ /^(\-?\d*)$/
 my $discountnum = $1;
 
 # for going right to a provision service after ordering a package
-my $svcpart;
+my( $svcpart, $part_svc ) = ( '', '' );
 if ( $cgi->param('svcpart') ) {
-    $cgi->param('svcpart') =~ /^(\-?\d*)$/
-       or die 'illegal svcpart '. $cgi->param('svcpart');
-    $svcpart = $1;
+  $cgi->param('svcpart') =~ /^(\-?\d*)$/
+     or die 'illegal svcpart '. $cgi->param('svcpart');
+  $svcpart = $1;
+  $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } )
+    or die "unknown svcpart $svcpart";
 }
 
+my $qualnum = '';
+if ( $cgi->param('qualnum') ) {
+  $cgi->param('qualnum') =~ /^(\d+)$/ or die 'illegal qualnum';
+  $qualnum = $1;
+}
+
+
 my $cust_pkg = new FS::cust_pkg {
   'custnum'              => $custnum,
   'pkgpart'              => $pkgpart,
index 7ecf906..5896f18 100644 (file)
@@ -3,6 +3,7 @@
               'fields'             => \@fields,
               'svc_new_callback'   => $new_cb,
               'svc_edit_callback'  => $edit_cb,
+              'svc_error_callback' => $error_cb,
               'html_foot'          => $html_foot,
           )
 %>
@@ -61,32 +62,58 @@ my $edit_cb = sub {
 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 );
+    die "more than one DSL-pulling export for svcpart ".$part_svc->svcpart
+      if ( scalar(@exports) > 1 );
+
+    my $cust_main = $cust_pkg->cust_main;
+
+    @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,
+        },
+    );
+
+    my $vendor_qual_id = '';
+    my $qual = '';
+    if ( $cgi->param('qualnum') ) {
+
+      $qual =
+        qsearchs('qual', { 'qualnum' => scalar($cgi->param('qualnum')) } )
+          or die 'unknown qualnum';
+
+      $vendor_qual_id = $qual->vendor_qual_id;
+
+      push @fields, { 'field' => 'qualnum',
+                      'type'  => 'hidden',
+                      'value' => $qual->qualnum,
+                    },
+                    { 'field' => 'phonenum',
+                      'type'  => 'fixed',
+                      'value' => $qual->phonenum,
+                    };
+    
+    } else {
+
+      my $phonenum = $cust_main->ship_daytime ? $cust_main->ship_daytime
+                                           : $cust_main->daytime;
+      $phonenum =~ s/[^0-9]//g;
+
+      push @fields,
+        { field => 'phonenum',
+          value => $phonenum,
+        };
 
-        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 => 'phonenum',
-              value => $defsvctn,
-            },
-        );
+    }
 
     if ( scalar(@exports) == 1 ) {
         my $export = @exports[0];                
@@ -104,30 +131,52 @@ my $new_cb = sub {
                                                             .$qual->qualnum;
             }
 
-            splice @fields, -1, 0,
-                { field => 'loop_type',
-                  type => 'select',
-                  options => [ '', '0' ],
-                  labels => { '' => 'Line-share', '0', => 'Standalone' },
-                  onchange => 'ikano_loop_type_changed',
-                },
-            ;
+            if ( $vendor_qual_id ) {
+              splice @fields, -1, 0,
+                  { field    => 'loop_type',
+                    type     => 'fixed',
+                    value    => ( $qual->phonenum ? '' : '0' ),
+                    formatted_value => ( $qual->phonenum ? 'Line-share'
+                                                         : 'Standalone' ),
+                  };
+            } else {
+              splice @fields, -1, 0,
+                  { field    => 'loop_type',
+                    type     => 'select',
+                    options  => [ '', '0' ],
+                    labels   => { '' => 'Line-share', '0', => 'Standalone' },
+                    onchange => 'ikano_loop_type_changed',
+                  };
+            }
 
             push @fields,
                 'password', 
                 { field => 'isp_chg', type => 'checkbox', value=>'Y', },
                 'isp_prev',
-                { field => 'vendor_qual_id', 
-                  type => 'select',
-                  options => \@prequalids,
-                  labels => \%prequal_labels,
+            ;
+
+            if ( $vendor_qual_id ) {
+              push @fields,
+                { field => 'vendor_qual_id',
+                  type  => 'fixed',
+                  value => $vendor_qual_id,
+                };
+            } else {
+              push @fields,
+                { field    => 'vendor_qual_id', 
+                  type     => 'select',
+                  options  => \@prequalids,
+                  labels   => \%prequal_labels,
                   onchange => 'ikano_vendor_qual_id_changed',
-                },
+                };
+            }
+
+            push @fields,
                 { field => 'vendor_order_type', 
-                  type => 'hidden', 
+                  type  => 'hidden', 
                   value => 'NEW' },
                 { field => 'desired_due_date',
-                  type => 'fixed',
+                  type  => 'fixed',
                   formatted_value => 
                     time2str($date_format,$ddd),
                   value => $ddd, 
@@ -140,4 +189,15 @@ my $new_cb = sub {
         push @fields, qw( rate_band circuitnum vpi vci );
     }
 };
+
+my $error_cb = sub {
+    my( $cgi ) = @_;
+    #my( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt) = @_;
+    if ( $cgi->param('svcnum') ) {
+      &{ $edit_cb }( @_ );
+    } else {
+      &{ $new_cb }( @_ );
+    }
+};
+
 </%init>
index 78e50e7..db53ad4 100644 (file)
@@ -39,8 +39,8 @@ $params->{'action'} .=
   ( $params->{'action'} =~ /\?/ ? ';' : '?' ).
   'custnum='. $params->{'cust_main'}->custnum;
 
-$params->{'action'} .= ';pkgpart='.$params->{'pkgpart'} if $params->{'pkgpart'};
-$params->{'action'} .= ';locationnum='.$params->{'locationnum'} if $params->{'locationnum'};
-$params->{'action'} .= ';svcpart='.$params->{'svcpart'} if $params->{'svcpart'};
+$params->{'action'} .= ";$_=".$params->{$_}
+  foreach grep $params->{$_},
+    qw( lock_pkgpart lock_locationnum qualnum svcpart );
 
 </%init>
index dcbc016..17c5605 100644 (file)
 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
 
 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">
+<INPUT TYPE="hidden" NAME="qualnum" VALUE="<% scalar($cgi->param('qualnum')) |h %>">
 % if ( $svcpart ) {
     <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
 % }
 
 <% ntable("#cccccc", 2) %>
-<% include('/elements/tr-select-cust-part_pkg.html',
-             'curr_value' => $pkgpart,
-             'classnum'   => -1,
-             'cust_main'  => $cust_main,
-             'onchange'   => 'enable_order_pkg',
-          )
-%>
+% if ( $part_pkg ) {
+    <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>">
+    <TR>
+      <TH ALIGN="right">Package</TH>
+      <TD COLSPAN=6><% $part_pkg->pkg_comment |h %></TD>
+    </TR>
+% } else {
+    <% include('/elements/tr-select-cust-part_pkg.html',
+                 'curr_value' => $pkgpart,
+                 'classnum'   => -1,
+                 'cust_main'  => $cust_main,
+                 'onchange'   => 'enable_order_pkg',
+              )
+    %>
+% }
 
 <TR>
   <TH ALIGN="right">Start date </TD>
   %>
 % }
 
-<% include('/elements/tr-select-cust_location.html',
-             'cgi'       => $cgi,
-             'cust_main' => $cust_main,
-          )
-%>
+% if ( $cgi->param('lock_locationnum') ) {
+
+    <INPUT TYPE  = "hidden"
+           NAME  = "locationnum"
+           VALUE = "<% scalar($cgi->param('lock_locationnum')) |h %>"
+    >
+
+% } else {
+
+    <% include('/elements/tr-select-cust_location.html',
+                 'cgi'       => $cgi,
+                 'cust_main' => $cust_main,
+              )
+    %>
+
+% }
 
 <TR>
   <TH ALIGN="right">Contract end date </TD>
 
 </TABLE>
 
-<% include( '/elements/standardize_locations.html',
-            'form'       => "OrderPkgForm",
-            'onlyship'   => 1,
-            'no_company' => 1,
-            'callback'   => 'document.OrderPkgForm.submit();',
-          )
-%>
+% unless ( $cgi->param('lock_locationnum') ) {
+
+  <% include( '/elements/standardize_locations.html',
+                'form'       => "OrderPkgForm",
+                'onlyship'   => 1,
+                'no_company' => 1,
+                'callback'   => 'document.OrderPkgForm.submit();',
+            )
+  %>
+
+% }
 
 <BR>
-<INPUT NAME="submitButton" TYPE="button" VALUE="Order Package" onClick = "this.disabled=true; standardize_locations();" <% $pkgpart ? '' : 'DISABLED' %>>
+% my $onclick = $cgi->param('lock_locationnum')
+%                 ? 'document.OrderPkgForm.submit()'
+%                 : 'standardize_locations()';
+<INPUT NAME="submitButton"
+       TYPE="button"
+       VALUE="Order Package"
+       onClick = "this.disabled=true; <% $onclick %>;"
+       <% $pkgpart ? '' : 'DISABLED' %>
+>
 
 </FORM>
 </BODY>
@@ -133,7 +165,17 @@ my $cust_main = qsearchs({
   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
 });
 
-my $pkgpart = scalar($cgi->param('pkgpart'));
+my $part_pkg = '';
+if ( $cgi->param('lock_pkgpart') ) {
+  $part_pkg = qsearchs({
+    'table'     => 'part_pkg',
+    'hashref'   => { 'pkgpart' => scalar($cgi->param('lock_pkgpart')) },
+    'extra_sql' => ' AND '. FS::part_pkg->agent_pkgs_sql( $cust_main->agent ),
+  })
+    or die "unknown pkgpart ". $cgi->param('lock_pkgpart');
+}
+
+my $pkgpart = $part_pkg ? $part_pkg->pkgpart : scalar($cgi->param('pkgpart'));
 
 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
 my $start_date = '';
@@ -142,6 +184,6 @@ if( ! $conf->exists('order_pkg-no_start_date') ) {
   $start_date = $start_date ? time2str($format, $start_date) : '';
 }
 
-my $svcpart = $cgi->param('svcpart');
+my $svcpart = scalar($cgi->param('svcpart'));
 
 </%init>
index 2e8b1da..ba731ae 100644 (file)
@@ -6,7 +6,7 @@
               'cust_main'   => $cust_main,
               'closetext'   => 'Close',
               'width'       => 763,
-              'height'      => 538,
+              'height'      => $height,
              %optional,
           )
 %>
 
 my($cust_main, %opt) = @_;
 
-my %optional = ();
-$optional{'pkgpart'} = $opt{'pkgpart'} if $opt{'pkgpart'};
-$optional{'locationnum'} = $opt{'locationnum'} if $opt{'locationnum'};
-$optional{'svcpart'} = $opt{'svcpart'} if $opt{'svcpart'};
+my %optional = map { $_ => $opt{$_} }
+                 grep $opt{$_},
+                   qw( lock_pkgpart lock_locationnum qualnum svcpart );
+
+my $height = $opt{'lock_locationnum'} ? 296 : 538;
 
 </%init>
index 6998b85..5c15ec0 100644 (file)
 
 %           if($cust_or_prospect->custnum) {
 
-%             my %opt = ( 'label'       => $pkglist->{$pkgpart},
-%                         'pkgpart'     => $pkgpart,
-%                         'locationnum' => $location{'locationnum'},
+%             my %opt = ( 'label'            => $pkglist->{$pkgpart},
+%                         'lock_pkgpart'     => $pkgpart,
+%                         'lock_locationnum' => $location{'locationnum'},
+%                         'qualnum'          => $qual->qualnum,                
 %                       );
 %             if ( $export->exporttype eq 'ikano' ) {
 %               my $pkg_svc = qsearchs('pkg_svc', { 'pkgpart'     => $pkgpart,