From: ivan Date: Thu, 7 Aug 2003 13:08:00 +0000 (+0000) Subject: - turn on profiling with mason like with Apache::ASP (redirects now working) X-Git-Tag: NET_WHOIS_RAW_0_31~448 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=69ecd0e15d3de36b56ad133d5ae57dcddc53c63e - turn on profiling with mason like with Apache::ASP (redirects now working) - fix mason error with new view/cust_main.cgi UI --- diff --git a/htetc/global.asa b/htetc/global.asa index 21e112e6b..c7056fc03 100644 --- a/htetc/global.asa +++ b/htetc/global.asa @@ -137,8 +137,8 @@ if ( defined(@DBIx::Profile::ISA) ) { my( $self, $location) = @_; my $page = $cgi->header. - qq!Redirect to $location

!. - '
'.
+      qq!Redirect to $location!.
+      '

'.
         ( UNIVERSAL::can(dbh, 'sprintProfile')
             ? encode_entities(dbh->sprintProfile())
             : 'DBIx::Profile missing sprintProfile method;'.
diff --git a/htetc/handler.pl b/htetc/handler.pl
index b28cfe9e2..8f079af33 100644
--- a/htetc/handler.pl
+++ b/htetc/handler.pl
@@ -120,16 +120,24 @@ sub handler
       use FS::export_svc;
       use FS::msgcat;
 
-      *notCGI::redirect = sub {
+      *CGI::redirect = sub {
         my( $self, $location ) = @_;
         use vars qw($m);
 
         if ( defined(@DBIx::Profile::ISA) ) { #profiling redirect
 
-       #   my $page =
-
-
-       #   return $page;
+          my $page =
+            qq!Redirect to $location!.
+            '

'.
+              ( UNIVERSAL::can(dbh, 'sprintProfile')
+                  ? encode_entities(dbh->sprintProfile())
+                  : 'DBIx::Profile missing sprintProfile method;'.
+                    'unpatched or too old?'                        ).
+            #"\n\n". &sprintAutoProfile().  '
'. + "\n\n". '
'. + ''; + dbh->{'private_profile'} = {}; + return $page; } else { #normal redirect diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index c36c9e265..f1afdb570 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -370,7 +370,7 @@ print qq!
Packages !, #get package info -my $packages = get_packages($cust_main); +my $packages = get_packages($cust_main, $conf); if ( @$packages ) { %> @@ -401,27 +401,27 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { <%=$pkg->{pkg}%> - <%=$pkg->{comment}%> ( <%=pkg_details_link($pkg)%> )
<% unless ($pkg->{cancel}) { %> ( <%=pkg_change_link($pkg)%> ) - ( <%=pkg_dates_link($pkg)%> | <%=pkg_customize_link($pkg)%> ) + ( <%=pkg_dates_link($pkg)%> | <%=pkg_customize_link($pkg,$custnum)%> ) <% } %> <% #foreach (qw(setup last_bill next_bill susp expire cancel)) { - # print qq! ! . pkg_datestr($pkg,$_) . qq!\n!; + # print qq! ! . pkg_datestr($pkg,$_,$conf) . qq!\n!; #} print "". &itable(''); - #move - my %freq = ( - 1 => 'monthly', - 2 => 'bi-monthly', - 3 => 'quarterly', - 6 => 'semi-annually', - 12 => 'annually', - 24 => 'bi-annually', - 36 => 'tri-annually', - ); - sub freq { + + my %freq = ( #move this + 1 => 'monthly', + 2 => 'bi-monthly', + 3 => 'quarterly', + 6 => 'semi-annually', + 12 => 'annually', + 24 => 'bi-annually', + 36 => 'tri-annually', + ); + my $freq = shift; exists $freq{$freq} ? $freq{$freq} : "every $freq months"; } @@ -431,17 +431,17 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { if ( $pkg->{cancel} ) { #status: cancelled print 'Cancelled '. - ''. pkg_datestr($pkg,'cancel'). ''; + ''. pkg_datestr($pkg,'cancel',$conf). ''; unless ( $pkg->{setup} ) { print 'Never billed'; } else { print "Setup ". - pkg_datestr($pkg, 'setup'). ''; + pkg_datestr($pkg, 'setup',$conf). ''; print "Last bill ". - pkg_datestr($pkg, 'last_bill'). '' + pkg_datestr($pkg, 'last_bill',$conf). '' if $pkg->{'last_bill'}; print "Suspended ". - pkg_datestr($pkg, 'susp'). '' + pkg_datestr($pkg, 'susp',$conf). '' if $pkg->{'susp'}; } @@ -449,19 +449,19 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { if ( $pkg->{susp} ) { #status: suspended print 'Suspended '. - ''. pkg_datestr($pkg,'susp'). ''; + ''. pkg_datestr($pkg,'susp',$conf). ''; unless ( $pkg->{setup} ) { print 'Never billed'; } else { print "Setup ". - pkg_datestr($pkg, 'setup'). ''; + pkg_datestr($pkg, 'setup',$conf). ''; } print "Last bill ". - pkg_datestr($pkg, 'last_bill'). '' + pkg_datestr($pkg, 'last_bill',$conf). '' if $pkg->{'last_bill'}; # next bill ?? print "Expires ". - pkg_datestr($pkg, 'expire'). '' + pkg_datestr($pkg, 'expire',$conf). '' if $pkg->{'expire'}; print '( '. pkg_unsuspend_link($pkg). ' | '. pkg_cancel_link($pkg). ' )'; @@ -484,24 +484,24 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { unless ( $pkg->{freq} ) { print "One-time charge". 'Billed '. - pkg_datestr($pkg,'setup'). ''; + pkg_datestr($pkg,'setup',$conf). ''; } else { print 'Active'. ', billed '. freq($pkg->{freq}). ''. 'Setup '. - pkg_datestr($pkg, 'setup'). ''; + pkg_datestr($pkg, 'setup',$conf). ''; } } print "Last bill ". - pkg_datestr($pkg, 'last_bill'). '' + pkg_datestr($pkg, 'last_bill',$conf). '' if $pkg->{'last_bill'}; print "Next bill ". - pkg_datestr($pkg, 'next_bill'). '' + pkg_datestr($pkg, 'next_bill',$conf). '' if $pkg->{'next_bill'}; print "Expires ". - pkg_datestr($pkg, 'expire'). '' + pkg_datestr($pkg, 'expire',$conf). '' if $pkg->{'expire'}; if ( $pkg->{freq} ) { print '( '. pkg_suspend_link($pkg). @@ -767,82 +767,92 @@ sub keyfield_numerically { (split(/\t/,$a))[0] <=> (split(/\t/,$b))[0]; } sub get_packages { - -my $cust_main = shift or return undef; - -my @packages = (); - -foreach my $cust_pkg (($conf->exists('hidecancelledpackages') ? ($cust_main->ncancelled_pkgs) - : ($cust_main->all_pkgs))) { - - my $part_pkg = $cust_pkg->part_pkg; - - my %pkg = (); - $pkg{pkgnum} = $cust_pkg->pkgnum; - $pkg{pkg} = $part_pkg->pkg; - $pkg{pkgpart} = $part_pkg->pkgpart; - $pkg{comment} = $part_pkg->getfield('comment'); - $pkg{freq} = $part_pkg->freq; - $pkg{setup} = $cust_pkg->getfield('setup'); - $pkg{last_bill} = $cust_pkg->getfield('last_bill'); - $pkg{next_bill} = $cust_pkg->getfield('bill'); - $pkg{susp} = $cust_pkg->getfield('susp'); - $pkg{expire} = $cust_pkg->getfield('expire'); - $pkg{cancel} = $cust_pkg->getfield('cancel'); - - $pkg{svcparts} = []; - - foreach my $pkg_svc (qsearch('pkg_svc', { 'pkgpart' => $part_pkg->pkgpart })) { - - next if ($pkg_svc->quantity == 0); - - my $part_svc = qsearchs('part_svc', { 'svcpart' => $pkg_svc->svcpart }); - - my $svcpart = {}; - $svcpart->{svcpart} = $part_svc->svcpart; - $svcpart->{svc} = $part_svc->svc; - $svcpart->{svcdb} = $part_svc->svcdb; - $svcpart->{quantity} = $pkg_svc->quantity; - $svcpart->{count} = 0; - - $svcpart->{services} = []; - - foreach my $cust_svc (qsearch('cust_svc', { 'pkgnum' => $cust_pkg->pkgnum, - 'svcpart' => $part_svc->svcpart } )) { - - my $svc = {}; - $svc->{svcnum} = $cust_svc->svcnum; - $svc->{label} = ($cust_svc->label)[1]; - - push @{$svcpart->{services}}, $svc; - - $svcpart->{count}++; - + my $cust_main = shift or return undef; + my $conf = shift; + + my @packages = (); + + foreach my $cust_pkg ( + $conf->exists('hidecancelledpackages') + ? $cust_main->ncancelled_pkgs + : $cust_main->all_pkgs + ) { + + my $part_pkg = $cust_pkg->part_pkg; + + my %pkg = (); + $pkg{pkgnum} = $cust_pkg->pkgnum; + $pkg{pkg} = $part_pkg->pkg; + $pkg{pkgpart} = $part_pkg->pkgpart; + $pkg{comment} = $part_pkg->getfield('comment'); + $pkg{freq} = $part_pkg->freq; + $pkg{setup} = $cust_pkg->getfield('setup'); + $pkg{last_bill} = $cust_pkg->getfield('last_bill'); + $pkg{next_bill} = $cust_pkg->getfield('bill'); + $pkg{susp} = $cust_pkg->getfield('susp'); + $pkg{expire} = $cust_pkg->getfield('expire'); + $pkg{cancel} = $cust_pkg->getfield('cancel'); + + $pkg{svcparts} = []; + + foreach my $pkg_svc ( + qsearch('pkg_svc', { 'pkgpart' => $part_pkg->pkgpart }) + ) { + + next if ($pkg_svc->quantity == 0); + + my $part_svc = qsearchs('part_svc', { 'svcpart' => $pkg_svc->svcpart }); + + my $svcpart = {}; + $svcpart->{svcpart} = $part_svc->svcpart; + $svcpart->{svc} = $part_svc->svc; + $svcpart->{svcdb} = $part_svc->svcdb; + $svcpart->{quantity} = $pkg_svc->quantity; + $svcpart->{count} = 0; + + $svcpart->{services} = []; + + foreach my $cust_svc ( + qsearch( 'cust_svc', { + 'pkgnum' => $cust_pkg->pkgnum, + 'svcpart' => $part_svc->svcpart, + } + ) + ) { + + my $svc = {}; + $svc->{svcnum} = $cust_svc->svcnum; + $svc->{label} = ($cust_svc->label)[1]; + + push @{$svcpart->{services}}, $svc; + + $svcpart->{count}++; + + } + + push @{$pkg{svcparts}}, $svcpart; + } - - push @{$pkg{svcparts}}, $svcpart; - + + push @packages, \%pkg; + } - - push @packages, \%pkg; - -} - -return \@packages; + + return \@packages; } sub svc_link { - my ($svcpart, $svc) = (shift,shift) or return ''; - return qq!$svcpart->{svc}!; + my ($svcpart, $svc) = (shift,shift) or return ''; + return qq!$svcpart->{svc}!; } sub svc_label_link { - my ($svcpart, $svc) = (shift,shift) or return ''; - return qq!$svc->{label}!; + my ($svcpart, $svc) = (shift,shift) or return ''; + return qq!$svc->{label}!; } @@ -875,7 +885,7 @@ sub pkgsort_pkgnum_cancel { } sub pkg_datestr { - my($pkg, $field) = @_ or return ''; + my($pkg, $field, $conf) = @_ or return ''; return ' ' unless $pkg->{$field}; my $format = $conf->exists('pkg_showtimes') ? '%D %l:%M:%S%P %z' @@ -916,6 +926,7 @@ sub pkg_dates_link { sub pkg_customize_link { my $pkg = shift or return ''; + my $custnum = shift; return qq!Customize!; }