Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / edit / cust_main / first_pkg.html
index 0de33c0..6845b2c 100644 (file)
@@ -1,17 +1,22 @@
+% if ( $cgi->param('lock_pkgpart') =~ /^([\d, ]+)$/ ) {
+
+    <INPUT TYPE="hidden" NAME="lock_pkgpart" VALUE="<% $1 %>">
+
+% }
+%
 % if ( @part_pkg ) {
 
-    <BR><BR>
-    <FONT SIZE="+1"><B>First package</B></FONT>
-    <% ntable("#cccccc") %>
+    <BR>
+    <FONT CLASS="fsinnerbox-title"><% mt('First package') |h %></FONT>
+    <TABLE BORDER=0 CELLSPACING=0>
 
       <TR>
         <TD COLSPAN=2>
-          <% include('first_pkg/select-part_pkg.html',
-                       'part_pkg' => \@part_pkg,
+          <& first_pkg/select-part_pkg.html,
+                       'part_pkg'  => \@part_pkg,
+                       'first_svc' => \@first_svc,
                        %opt,
-                       # map { $_ => $opt{$_} } qw( pkgpart_svcpart saved_domsvc )
-                    )
-          %>
+          &>
 
 % } 
 <%init>
@@ -28,6 +33,11 @@ if ( scalar(@agents) == 1 ) {
   # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART
   $pkgpart = $agents[0]->pkgpart_hashref;
   $agentnum = $agents[0]->agentnum;
+} elsif ( $cgi->param('lock_agentnum') =~ /^(\d+)$/
+            && $FS::CurrentUser::CurrentUser->agentnum($1) ) {
+  $agentnum = $1;
+  my $agent = (grep { $_->agentnum == $agentnum } @agents)[0];
+  $pkgpart = $agent->pkgpart_hashref;
 } else {
   #can't know (agent not chosen), so, allow all
   $agentnum = 'all';
@@ -39,9 +49,28 @@ if ( scalar(@agents) == 1 ) {
 }
 #eslaf
 
-my @first_svc = ( 'svc_acct', 'svc_phone' );
+my @part_pkg = ();
+if ( $cgi->param('lock_pkgpart') =~ /^([\d, ]+)$/ ) {
+
+  my $lock_pkgpart = $1;
+
+  @part_pkg = qsearch({
+                        'table'     => 'part_pkg',
+                        'hashref'   => { 'disabled' => '' },
+                        'extra_sql' => "AND pkgpart IN ($lock_pkgpart)",
+                        'order_by'  => 'ORDER BY pkg', # case?
+                     });
+
+} else {
+
+  @part_pkg =
+    qsearch( 'part_pkg', { 'disabled' => '' }, '', 'ORDER BY pkg' ); # case?
+
+}
+
+my @first_svc = ( 'svc_acct', 'svc_phone', 'svc_dsl' );
 
-my @part_pkg =
+@part_pkg =
   grep { $_->svcpart(\@first_svc)
          && ( $pkgpart->{ $_->pkgpart } 
               || $agentnum eq 'all'
@@ -50,6 +79,6 @@ my @part_pkg =
                  )
             )
        }
-  qsearch( 'part_pkg', { 'disabled' => '' }, '', 'ORDER BY pkg' ); # case?
+  @part_pkg;
 
 </%init>