From 67c00bb4c9309c1ae314aa5b8657273f24539270 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Sun, 26 Apr 2015 23:58:08 -0700 Subject: [PATCH] adjustments for 3.x, #33852 --- FS/FS/ClientAPI/MyAccount/quotation.pm | 24 ++++++++++----- ng_selfservice/quotation.php | 56 +++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 29 deletions(-) diff --git a/FS/FS/ClientAPI/MyAccount/quotation.pm b/FS/FS/ClientAPI/MyAccount/quotation.pm index 90c2acebb..f3067f14e 100644 --- a/FS/FS/ClientAPI/MyAccount/quotation.pm +++ b/FS/FS/ClientAPI/MyAccount/quotation.pm @@ -5,7 +5,7 @@ use FS::Record qw(qsearch qsearchs); use FS::quotation; use FS::quotation_pkg; -our $DEBUG = 1; +our $DEBUG = 0; sub _custoragent_session_custnum { FS::ClientAPI::MyAccount::_custoragent_session_custnum(@_); @@ -58,6 +58,7 @@ Returns a hashref describing the current quotation, containing: =cut +use Data::Dumper; sub quotation_info { my $p = shift; @@ -69,13 +70,22 @@ sub quotation_info { warn "quotation_info #".$quotation->quotationnum if $DEBUG; - # code reuse ftw my $null_escape = sub { @_ }; - my ($sections) = $quotation->_items_sections(escape => $null_escape); - foreach my $section (@$sections) { - $section->{'detail_items'} = - [ $quotation->_items_pkg('section' => $section, escape_function => $null_escape) ]; - } + # 3.x only; 4.x quotation redesign uses actual sections for this + # and isn't a weird hack + my @items = + map { $_->{'pkgnum'} = $_->{'preref_html'}; $_ } + $quotation->_items_pkg(escape_function => $null_escape, + preref_callback => sub { shift->quotationpkgnum }); + push @items, $quotation->_items_total(); + + my $sections = [ + { 'description' => 'Estimated Charges', + 'detail_items' => \@items + } + ]; + warn Dumper $sections; + return { 'error' => '', 'sections' => $sections } } diff --git a/ng_selfservice/quotation.php b/ng_selfservice/quotation.php index cf455431b..acccf9cb1 100644 --- a/ng_selfservice/quotation.php +++ b/ng_selfservice/quotation.php @@ -58,34 +58,46 @@ if ( isset($quotation['sections']) and count($quotation['sections']) > 0 ) { ); $row = 0; foreach ( $section['detail_items'] as $detail ) { - print( - ''. - '' - ); - if ( $detail['pkgnum'] ) { + if (isset($detail['description'])) { + print( + ''. + '' + ); + if ( $detail['pkgnum'] ) { + print( + ''. + '' + ); + } + print( + ''. + ''. htmlspecialchars($detail['description']). ''. + ''. $detail['amount']. ''. + ''. "\n" + ); + $row = 1 - $row; + } else { + # total rows; a 3.x-ism print( - ''. - '' + ''. + ''. + ''. htmlspecialchars($detail['total_item']). ''. + ''. $detail['total_amount']. ''. + ''."\n" ); } + } + if (isset($section['subtotal'])) { print( - ''. - ''. htmlspecialchars($detail['description']). ''. - ''. $detail['amount']. ''. - ''. "\n" + ''. + ''. + 'Total'. + ''. $section['subtotal']. ''. + '' ); - $row = 1 - $row; } - print( - ''. - ''. - 'Total'. - ''. $section['subtotal']. ''. - ''. - ''. - "\n" - ); + print "\n"; } # foreach $section } -- 2.11.0