X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fcust-part_pkg.cgi;h=43b92297ef061d5ff3f6432f84606d2a34cad669;hb=ded0ab5cac02f099b387de360fb6dd6bd8cbb6b4;hp=dcd033ff24a75f769cce6f50c7ea1c7346f1e77f;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git diff --git a/httemplate/misc/cust-part_pkg.cgi b/httemplate/misc/cust-part_pkg.cgi index dcd033ff2..43b92297e 100644 --- a/httemplate/misc/cust-part_pkg.cgi +++ b/httemplate/misc/cust-part_pkg.cgi @@ -1,11 +1,19 @@ -<% objToJson( \@return ) %> +<% encode_json( \@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,7 +27,7 @@ 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', });