Merge branch 'patch-19' of https://github.com/gjones2/Freeside
[freeside.git] / httemplate / browse / part_export.cgi
1 <% include("/elements/header.html", "Export Listing") %>
2
3 Provisioning services to external machines, databases and APIs.<BR><BR>
4
5 <A HREF="<% $p %>edit/part_export.cgi"><I>Add a new export</I></A><BR><BR>
6
7 <SCRIPT>
8 function part_export_areyousure(href) {
9   if (confirm("Are you sure you want to delete this export?") == true)
10     window.location.href = href;
11 }
12 </SCRIPT>
13
14 <% include('/elements/table-grid.html') %>
15 % my $bgcolor1 = '#eeeeee';
16 %   my $bgcolor2 = '#ffffff';
17 %   my $bgcolor = '';
18
19   <TR>
20     <TH COLSPAN=2 CLASS="grid" BGCOLOR="#cccccc">Export</TH>
21     <TH CLASS="grid" BGCOLOR="#cccccc">Options</TH>
22   </TR>
23
24 % foreach my $part_export ( sort { 
25 %     $a->getfield('exportnum') <=> $b->getfield('exportnum')
26 %   } qsearch('part_export',{})
27 % ) {
28 %   if ( $bgcolor eq $bgcolor1 ) {
29 %     $bgcolor = $bgcolor2;
30 %   } else {
31 %     $bgcolor = $bgcolor1;
32 %   }
33
34     <TR>
35
36       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>"><% $part_export->exportnum %></A></TD>
37
38       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
39         <% $part_export->label_html %>
40         (<A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>">edit</A>&nbsp;|&nbsp;<A HREF="javascript:part_export_areyousure('<% $p %>misc/delete-part_export.cgi?<% $part_export->exportnum %>')">delete</A>)
41 %       if ( my @actions = $part_export->actions ) {
42         <P STYLE="position: absolute">
43         Management:
44 %         while (@actions) {
45 %           my $label = shift @actions;
46 %           my $path = shift @actions;
47             <& /elements/popup_link.html,
48               'label'       => $label,
49               'action'      => $fsurl.$path.'?'.$part_export->exportnum,
50               'actionlabel' => $label,
51             &><% @actions ? '&nbsp;|&nbsp;' : '' %>
52 %         }
53         </P>
54 %       } #if @actions
55
56       </TD>
57
58       <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
59         <% itable() %>
60 %         my %opt = $part_export->options;
61 %         my $defs = $part_export->info->{options};
62 %         my %multiples;
63 %         foreach my $opt (keys %$defs) { # is a Tie::IxHash
64 %           my $group = $defs->{$opt}->{multiple};
65 %           if ( $group ) {
66 %             my @values = split("\n", $opt{$opt});
67 %             $multiples{$group} ||= [];
68 %             push @{ $multiples{$group} }, [ $opt, @values ] if @values;
69 %             delete $opt{$opt};
70 %           } elsif (length($opt{$opt})) { # the normal case
71 %#         foreach my $opt ( keys %opt ) { 
72   
73             <TR>
74               <TD ALIGN="right" VALIGN="top" WIDTH="33%"><% $opt %>:&nbsp;</TD>
75               <TD ALIGN="left" WIDTH="67%"><% encode_entities($opt{$opt}) %></TD>
76             </TR>
77 %             delete $opt{$opt};
78 %           }
79 %         }
80 %         # now any that are somehow not in the options list
81 %         foreach my $opt (keys %opt) {
82 %           if ( length($opt{$opt}) ) {
83             <TR>
84               <TD ALIGN="right" VALIGN="top" WIDTH="33%"><% $opt %>:&nbsp;</TD>
85               <TD ALIGN="left" WIDTH="67%"><% encode_entities($opt{$opt}) %></TD>
86             </TR>
87 %           }
88 %         }
89 %         # now show any multiple-option groups
90 %         foreach (sort keys %multiples) {
91 %           my $set = $multiples{$_};
92             <TR><TD ALIGN="center" COLSPAN=2><TABLE CLASS="grid">
93               <TR>
94 %             foreach my $col (@$set) {
95                 <TH><% shift @$col %></TH>
96 %             }
97               </TR>
98 %           while ( 1 ) {
99               <TR>
100 %             my $end = 1;
101 %             foreach my $col (@$set) {
102                 <TD><% shift @$col %></TD>
103 %               $end = 0 if @$col;
104 %             }
105               </TR>
106 %             last if $end;
107 %           }
108             </TABLE></TD></TR>
109 %         } #foreach keys %multiples
110
111         </TABLE>
112       </TD>
113
114     </TR>
115
116 % } 
117
118 </TABLE>
119
120 <% include('/elements/footer.html') %>
121
122 <%init>
123 die "access denied"
124   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
125 </%init>