diff options
Diffstat (limited to 'httemplate/edit')
-rw-r--r-- | httemplate/edit/elements/svc_Common.html | 37 | ||||
-rw-r--r-- | httemplate/edit/process/quick-cust_pkg.cgi | 25 | ||||
-rw-r--r-- | httemplate/edit/svc_dsl.cgi | 140 |
3 files changed, 138 insertions, 64 deletions
diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html index 2e27f851d..aa7699555 100644 --- a/httemplate/edit/elements/svc_Common.html +++ b/httemplate/edit/elements/svc_Common.html @@ -14,6 +14,13 @@ 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 { @@ -29,13 +36,13 @@ 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 { @@ -48,23 +55,23 @@ }, '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; }, diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 704d256e6..a6449b880 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -11,11 +11,9 @@ % % # 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, diff --git a/httemplate/edit/svc_dsl.cgi b/httemplate/edit/svc_dsl.cgi index 7ecf906f0..5896f18ae 100644 --- a/httemplate/edit/svc_dsl.cgi +++ b/httemplate/edit/svc_dsl.cgi @@ -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> |