summaryrefslogtreecommitdiff
path: root/httemplate/elements/tr-pkg_svc.html
blob: a9561a11ae64a2efd0749bfdb7e763df52be182c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<TR>
  <TD BGCOLOR="#e8e8e8" COLSPAN=99>

<% itable('', 4, 1) %><TR><TD VALIGN="top">
<% $thead %>

%foreach my $part_svc ( @part_svc ) {
%  my $svcpart = $part_svc->svcpart;
%  my $pkg_svc = $pkg_svc{$svcpart}
%             || new FS::pkg_svc ( {
%                                   'pkgpart'     => $pkgpart,
%                                   'svcpart'     => $svcpart,
%                                   'quantity'    => 0,
%                                   'primary_svc' => '',
%                                } );
%  if ( $cgi->param('error') ) {
%    my $primary_svc = ( $pkg_svc->primary_svc =~ /^Y/i );
%    my $pkg_svc_primary = scalar($cgi->param('pkg_svc_primary'));
%    $pkg_svc->primary_svc('')
%      if $primary_svc && $pkg_svc_primary != $svcpart;
%    $pkg_svc->primary_svc('Y')
%      if ! $primary_svc && $pkg_svc_primary == $svcpart;
%  }
%
%  push @fixups, "pkg_svc$svcpart";
%
%  my $quan = 0;
%  if ( $cgi->param("pkg_svc$svcpart") =~ /^\s*(\d+)\s*$/ ) {
%    $quan = $1;
%  } elsif ( $pkg_svc->quantity ) {
%    $quan = $pkg_svc->quantity;
%  }

  <TR>
    <TD>
      <INPUT TYPE="text" NAME="pkg_svc<% $svcpart %>" SIZE=7 MAXLENGTH=6 VALUE="<% $quan %>">
    </TD>
   
    <TD ALIGN="center">
      <INPUT TYPE="radio" NAME="pkg_svc_primary" VALUE="<% $svcpart %>" <% $pkg_svc->primary_svc =~ /^Y/i ? ' CHECKED' : '' %>>
    </TD>

    <TD>
      <A HREF="part_svc.cgi?<% $part_svc->svcpart %>"><% $part_svc->svc %></A>      <% $part_svc->disabled =~ /^Y/i ? ' (DISABLED' : '' %>
    </TD>
  </TR>
% foreach ( 1 .. $columns-1 ) {
%       if ( $count == int( $_ * scalar(@part_svc) / $columns ) ) { 
%  

         </TABLE></TD><TD VALIGN="top"><% $thead %>
%   }
%     }
%     $count++;
%  
% } 

</TR></TABLE></TD></TR></TABLE>

  </TD>
</TR>

<%init>

my %opt = @_;
my $cgi = $opt{'cgi'};

my $thead =  "\n\n". ntable('#cccccc', 2).
             '<TR><TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Quan.</FONT></TH>'.
             '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-2>Primary</FONT></TH>'.
             '<TH BGCOLOR="#dcdcdc">Service</TH></TR>';

my $part_pkg = $opt{'object'};
my $pkgpart = $part_pkg->pkgpart;

my $where =  "WHERE disabled IS NULL OR disabled = ''";
if ( $pkgpart ) {
  $where .=  "   OR 0 < ( SELECT quantity FROM pkg_svc
                           WHERE pkg_svc.svcpart = part_svc.svcpart
                             AND pkgpart = $pkgpart
                        )";
}
my @part_svc = qsearch('part_svc', {}, '', $where);

#my $q_part_pkg = $clone_part_pkg || $part_pkg;
#my %pkg_svc = map { $_->svcpart => $_ } $q_part_pkg->pkg_svc;
my %pkg_svc = map { $_->svcpart => $_ } $part_pkg->pkg_svc;

my @fixups = ();
my $count = 0;
my $columns = 3;

</%init>