1 <% encode_json( \@return ) %>\
4 my( $custnum, $prospectnum, $classnum ) = $cgi->param('arg');
9 $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
10 or die 'unknown custnum';
11 $agent = $cust_main->agent;
13 my $prospect_main = qsearchs('prospect_main', {'prospectnum'=>$prospectnum} )
14 or die 'unknown prospectnum';
15 $agent = $prospect_main->agent;
18 my %hash = ( 'disabled' => '' );
19 if ( $classnum > 0 ) {
20 $hash{'classnum'} = $classnum;
21 } elsif ( $classnum eq '' || $classnum == 0 ) {
22 $hash{'classnum'} = '';
23 } #else -1, all classes, so don't set classnum
25 my @part_pkg = qsearch({
26 'table' => 'part_pkg',
29 ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql( 'null'=>1 ).
30 ' AND '. FS::part_pkg->agent_pkgs_sql( $agent ),
31 'order_by' => 'ORDER BY pkg',
34 my $conf = new FS::Conf;
36 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
38 my $default_start_date = $conf->exists('order_pkg-no_start_date')
40 : $cust_main ? $cust_main->next_bill_date
43 #num_billing_pkgs may be slightly better (will allow you to fill in a start
44 # date in the weird edge case where you're using sync_next_bill and
45 # prorate_defer_bill in flat.pm and there's one-time charges hanging around
46 # for this customer but no active ones)
47 #but we don't have an easy method for that, and definitely don't want to pull
49 my $num_ncancelled_pkgs = $cust_main ? $cust_main->num_ncancelled_pkgs : 0;
52 my $start_date = $_->delay_start_date
53 || $default_start_date;
54 $start_date = time2str($date_format, $start_date)
60 num_ncancelled_pkgs => $num_ncancelled_pkgs,
65 #sort { $a->pkg_comment cmp $b->pkg_comment }