X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fcust-part_pkg.cgi;h=a277ba4070b5aff0839e446ae44fb45f77d60429;hb=578ec27f71498b63102e4cca204575c01c1f8fa9;hp=a249f033f8d8bfe630a705aff5845e23b8712b1d;hpb=e3c3d86b7091d806af42e40475a28ea8afb5865c;p=freeside.git diff --git a/httemplate/misc/cust-part_pkg.cgi b/httemplate/misc/cust-part_pkg.cgi index a249f033f..a277ba407 100644 --- a/httemplate/misc/cust-part_pkg.cgi +++ b/httemplate/misc/cust-part_pkg.cgi @@ -1,11 +1,19 @@ <% objToJson( \@return ) %> <%init> -my( $custnum, $classnum ) = $cgi->param('arg'); +my( $custnum, $prospectnum, $classnum ) = $cgi->param('arg'); -#XXX i guess i should be agent-virtualized. cause "packages a customer can -#order" is such a huge deal -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); + +my $agent; +if ( $custnum ) { + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or die 'unknown custnum'; + $agent = $cust_main->agent; +} else { + my $prospect_main = qsearchs('prospect_main', {'prospectnum'=>$prospectnum} ) + or die 'unknown prospectnum'; + $agent = $prospect_main->agent; +} my %hash = ( 'disabled' => '' ); if ( $classnum > 0 ) { @@ -19,11 +27,18 @@ my @part_pkg = qsearch({ 'hashref' => \%hash, 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql( 'null'=>1 ). - ' AND '. FS::part_pkg->agent_pkgs_sql( $cust_main->agent ), + ' AND '. FS::part_pkg->agent_pkgs_sql( $agent ), + 'order_by' => 'ORDER BY pkg', }); -my @return = map { $_->pkgpart => $_->pkg_comment } - sort { $a->pkg_comment cmp $b->pkg_comment } - @part_pkg; +my @return = map { warn $_->can_start_date; + ( $_->pkgpart, + $_->pkg_comment, + $_->can_discount, + $_->can_start_date, + ); + } + #sort { $a->pkg_comment cmp $b->pkg_comment } + @part_pkg;