optimize CDR rating after timed rate perf regression, RT#15739
[freeside.git] / httemplate / misc / cust-part_pkg.cgi
1 <% objToJson( \@return ) %>
2 <%init>
3
4 my( $custnum, $classnum ) = $cgi->param('arg');
5
6 #XXX i guess i should be agent-virtualized.  cause "packages a customer can
7 #order" is such a huge deal
8 my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
9
10 my %hash = ( 'disabled' => '' );
11 if ( $classnum > 0 ) {
12   $hash{'classnum'} = $classnum;
13 } elsif ( $classnum eq '' || $classnum == 0 ) {
14   $hash{'classnum'} = '';
15 } #else -1, all classes, so don't set classnum
16
17 my @part_pkg = qsearch({
18   'table'     => 'part_pkg',
19   'hashref'   => \%hash,
20   'extra_sql' =>
21     ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql( 'null'=>1 ).
22     ' AND '. FS::part_pkg->agent_pkgs_sql( $cust_main->agent ),
23   'order_by'  => 'ORDER BY pkg',
24 });
25
26 my @return = map  { warn $_->can_start_date;
27                     ( $_->pkgpart,
28                       $_->pkg_comment,
29                       $_->can_discount,
30                       $_->can_start_date,
31                     );
32                   }
33                   #sort { $a->pkg_comment cmp $b->pkg_comment }
34                   @part_pkg;
35
36 </%init>