This commit was manufactured by cvs2svn to create tag 'freeside_2_1_1'.
[freeside.git] / httemplate / edit / cust_main / first_pkg.html
1 % if ( @part_pkg ) {
2
3     <BR><BR>
4     <FONT SIZE="+1"><B>First package</B></FONT>
5     <% ntable("#cccccc") %>
6
7       <TR>
8         <TD COLSPAN=2>
9           <% include('first_pkg/select-part_pkg.html',
10                        'part_pkg' => \@part_pkg,
11                        %opt,
12                        # map { $_ => $opt{$_} } qw( pkgpart_svcpart saved_domsvc )
13                     )
14           %>
15
16 % } 
17 <%init>
18
19 my( $cust_main, %opt ) = @_;
20
21 # pry the wrong place for this logic.  also pretty expensive
22
23 #false laziness, copied from FS::cust_pkg::order
24 my $pkgpart;
25 my $agentnum = '';
26 my @agents = $FS::CurrentUser::CurrentUser->agents;
27 if ( scalar(@agents) == 1 ) {
28   # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART
29   $pkgpart = $agents[0]->pkgpart_hashref;
30   $agentnum = $agents[0]->agentnum;
31 } else {
32   #can't know (agent not chosen), so, allow all
33   $agentnum = 'all';
34   my %typenum;
35   foreach my $agent ( @agents ) {
36     next if $typenum{$agent->typenum}++;
37     $pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref }
38   }
39 }
40 #eslaf
41
42 my @first_svc = ( 'svc_acct', 'svc_phone' );
43
44 my @part_pkg =
45   grep { $_->svcpart(\@first_svc)
46          && ( $pkgpart->{ $_->pkgpart } 
47               || $agentnum eq 'all'
48               || ( $agentnum ne 'all' && $agentnum && $_->agentnum
49                    && $_->agentnum == $agentnum
50                  )
51             )
52        }
53   qsearch( 'part_pkg', { 'disabled' => '' }, '', 'ORDER BY pkg' ); # case?
54
55 </%init>