[freeside-commits] branch FREESIDE_4_BRANCH updated. f21e3fcff8667f90efcb262e4290937212a21e95

Ivan ivan at 420.am
Fri Mar 4 11:35:53 PST 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  f21e3fcff8667f90efcb262e4290937212a21e95 (commit)
      from  e75e33aecdc0a432e57d6dd6278a361e0d3bd950 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f21e3fcff8667f90efcb262e4290937212a21e95
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Mar 4 11:35:52 2016 -0800

    optimize package list on order new package, RT#39822

diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index 3adbc06..45bdc62 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -2332,6 +2332,26 @@ sub _pkgs_sql {
 
 }
 
+=item join_options_sql
+
+Returns an SQL fragment for JOINing the part_pkg_option records for this
+package's setup_fee and recur_fee (as setup_option and recur_option,
+respectively).  Useful for optimization.
+
+=cut
+
+sub join_options_sql {
+  #my $class = shift;
+  "
+    LEFT JOIN part_pkg_option AS setup_option
+      ON (     part_pkg.pkgpart = setup_option.pkgpart
+           AND setup_option.optionname = 'setup_fee' )
+    LEFT JOIN part_pkg_option AS recur_option
+      ON (     part_pkg.pkgpart = recur_option.pkgpart
+           AND recur_option.optionname = 'recur_fee' )
+  ";
+}
+
 =back
 
 =head1 SUBROUTINES
diff --git a/httemplate/elements/select-part_pkg.html b/httemplate/elements/select-part_pkg.html
index 237d7df..22a24be 100644
--- a/httemplate/elements/select-part_pkg.html
+++ b/httemplate/elements/select-part_pkg.html
@@ -43,6 +43,11 @@ if ( exists($opt{'classnum'}) && defined($opt{'classnum'}) ) {
   } #else -1 or not specified, all classes, so don't set classnum
 }
 
+$opt{'select'} = 'part_pkg.*, setup_option.optionvalue AS _setup_fee,
+                              recur_option.optionvalue AS _recur_fee'
+  unless $opt{'select'};
+$opt{'addl_from'} .= FS::part_pkg->join_options_sql;
+
 $opt{'extra_sql'} .= ( keys(%hash) ? ' AND ' : ' WHERE ' ).
                      FS::part_pkg->curuser_pkgs_sql;
 
diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html
index 4b6ddb4..d7ec015 100644
--- a/httemplate/elements/select-table.html
+++ b/httemplate/elements/select-table.html
@@ -182,6 +182,7 @@ if ( $opt{'records'} ) {
     unless $opt{'presorted'};
 } else {
   @records = qsearch( {
+    'select'    => $opt{'select'} || '*',
     'table'     => $opt{'table'},
     'addl_from' => $opt{'addl_from'},
     'hashref'   => $hashref,
diff --git a/httemplate/misc/cust-part_pkg.cgi b/httemplate/misc/cust-part_pkg.cgi
index dc9ba2a..8a46c1d 100644
--- a/httemplate/misc/cust-part_pkg.cgi
+++ b/httemplate/misc/cust-part_pkg.cgi
@@ -23,7 +23,10 @@ if ( $classnum > 0 ) {
 } #else -1, all classes, so don't set classnum
 
 my @part_pkg = qsearch({
+  'select'    => 'part_pkg.*, setup_option.optionvalue AS _setup_fee,
+                              recur_option.optionvalue AS _recur_fee',
   'table'     => 'part_pkg',
+  'addl_from' => FS::part_pkg->join_options_sql,
   'hashref'   => \%hash,
   'extra_sql' =>
     ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql( 'null'=>1 ).

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_pkg.pm                        |   20 ++++++++++++++++++++
 httemplate/elements/select-part_pkg.html |    5 +++++
 httemplate/elements/select-table.html    |    1 +
 httemplate/misc/cust-part_pkg.cgi        |    3 +++
 4 files changed, 29 insertions(+)




More information about the freeside-commits mailing list