invoice_sections_with_taxes per-agent, RT#79636
[freeside.git] / httemplate / edit / elements / export_svc.html
1 <%args>
2 $part_svc
3 $svcdb
4 $clone => undef
5 </%args>
6 <%init>
7
8 my $svcpart = $clone || $part_svc->svcpart; # may be undef
9
10 # get a list of applicable part_exports
11 my @part_export;
12 my $export_info = FS::part_export::export_info($svcdb);
13 foreach ( keys %{ $export_info } ) {
14   push @part_export, qsearch('part_export', { exporttype => $_ });
15 }
16 # and a hash of which ones are already assigned to this part_svc
17 my %export_svc;
18 if ( $svcpart ) {
19   %export_svc = map { $_->exportnum => $_ }
20     qsearch('export_svc', { svcpart => $svcpart });
21 }
22
23 my $count = 0;
24 my $columns = 3;
25
26 </%init>
27 <script type="text/javascript">
28 function toggle_selectrole() {
29   var selectrole = document.getElementById( this.name + '_selectrole' );
30   if ( selectrole ) {
31     selectrole.style.visibility = (this.checked) ? '' : 'hidden';
32   }
33 }
34 <&| /elements/onload.js &>
35   var boxes = document.getElementsByClassName('checkbox_export');
36   for ( var i = 0; i < boxes.length; i++ ) {
37     boxes[i].onchange = toggle_selectrole;
38     toggle_selectrole.apply(boxes[i]);
39   }
40 </&>
41 </script>
42 <FONT CLASS="fsinnerbox-title">Exports</FONT>
43 <TABLE CLASS="fsinnerbox">
44   <TR>
45 % # exports
46 % foreach my $part_export (@part_export) {
47 %   my $exportnum = $part_export->exportnum;
48     <TD>
49       <INPUT CLASS="checkbox_export"
50              TYPE="checkbox" \
51              NAME="exportnum<% $exportnum %>" \
52              VALUE=1 \
53              <% $export_svc{$exportnum} ? 'CHECKED' : '' %>>
54       <% $part_export->label_html %>
55 % if ( $part_export->info->{roles} ) {
56 %   my $role_info = $part_export->info->{roles};
57 %   my @role_names = keys %$role_info;
58 %   my %role_labels = map { %_ => $role_info->{$_}->{label} } @role_names;
59 %   my $curr_role = $export_svc{$exportnum} ? $export_svc{$exportnum}->role
60 %                                           : '';
61       <SPAN CLASS="selectrole" ID="exportnum<%$exportnum%>_selectrole">
62         as: 
63         <& /elements/select.html,
64           'field'       => "exportnum${exportnum}_role",
65           'options'     => \@role_names,
66           'labels'      => \%role_labels,
67           'curr_value'  => $curr_role,
68           'empty_label' => 'select',
69         &>
70       </SPAN>
71 %     # XXX should lock out roles that don't apply to the selected svcdb, 
72 %     # but that's a pain in the ass
73 %   }
74         </SELECT>
75       </SPAN>
76     </TD>
77 %   $count++;
78 %   if ( $count % $columns == 0 ) {
79   </TR>
80   <TR>
81 %   }
82 % }
83   </TR>
84 </TABLE><BR>