adding export to read mailbox status information, RT#15987
[freeside.git] / httemplate / view / svc_dsl.cgi
1 <% include('elements/svc_Common.html',
2             'table'        => 'svc_dsl',
3             'labels'       => \%labels,
4             'fields'       => \@fields,
5             'svc_callback' => $svc_cb,
6             'html_foot'    => $html_foot,
7           )
8 %>
9 <%init>
10
11 # XXX: AJAX auto-pull
12
13 my $fields = FS::svc_dsl->table_info->{'fields'};
14 my %labels = map { $_ =>  ( ref($fields->{$_})
15                              ? $fields->{$_}{'label'}
16                              : $fields->{$_}
17                          );
18                  } keys %$fields;
19 my @fields = keys %$fields;
20
21 my $footer;
22
23 my $html_foot = sub {
24     return $footer;
25 };
26
27 my $svc_cb = sub {
28     my( $cgi,$svc_dsl, $part_svc,$cust_pkg, $fields1,$opt) = @_;
29
30     my @exports = $part_svc->part_export_dsl_pull;
31     die "more than one DSL-pulling export attached to svcpart ".$part_svc->svcpart
32         if ( scalar(@exports) > 1 );
33     
34     # if no DSL-pulling exports, then just display everything, which is the
35     # default behaviour implemented above
36     if ( scalar(@exports) ) {
37
38       my $export = @exports[0];
39
40       @fields = (
41         'phonenum',
42         { field => 'loop_type', 
43           value => 'FS::part_export::'.$export->exporttype.'::loop_type_long'
44         },
45         { field => 'desired_due_date', type => 'date', },
46         { field => 'due_date', type => 'date', },
47         { field => 'pushed', type => 'datetime', },
48         { field => 'monitored', type => 'checkbox', },
49         { field => 'last_pull', type => 'datetime', },
50         'first',
51         'last',
52         'company',
53       );
54
55       my $status = '';
56       if($export->exporttype eq 'ikano') {
57           push @fields, qw ( username password isp_chg isp_prev staticips );
58           $status = "Ikano " . $svc_dsl->vendor_order_type . " order #"
59                   . $svc_dsl->vendor_order_id . " &nbsp; Status: " 
60                   . $svc_dsl->vendor_order_status;
61       }
62       # else add any other export-specific stuff here
63    
64       $footer = "<B>$status</B>";
65
66     }
67
68     if ( grep $_->can('export_getstatus'), $part_svc->part_export ) {
69
70       $footer .= '<BR><BR>'.
71                  include('/elements/popup_link.html', {
72                    'action'      => $p.'view/svc_Status.html'.
73                                       '?svcnum='. $svc_dsl->svcnum,
74                    'label'       => 'View line status', #link
75                    'actionlabel' => 'View line status', #popup border
76                    'width'       => 763,
77                    'height'      => 300,
78                  });
79
80     }
81
82     $footer .= '<BR><BR>'.
83                include( '/view/elements/svc_devices.html',
84                           'svc_x'   => $svc_dsl,
85                           'table'   => 'dsl_device',
86                           'no_edit' => 1,
87                       );
88
89     my @notes = $svc_dsl->notes;
90     if ( @notes ) {
91
92       my $conf = new FS::Conf;
93       my $date_format = $conf->config('date_format') || '%m/%d/%Y';
94
95       $footer .=
96         "Order Notes<BR>". ntable('#cccccc', 2). #id="dsl_notes"
97         '<TR><TH>Date</TH><TH>By</TH><TH>Priority</TH><TH>Note</TH></TR>';
98
99       foreach my $note ( @notes ) {
100         $footer .= "<TR>
101             <TD>".time2str("$date_format %H:%M",$note->date)."</TD>
102             <TD>".$note->by."</TD>
103             <TD>". ($note->priority eq 'N' ? 'Normal' : 'High') ."</TD>
104             <TD>".$note->note."</TD></TR>";
105       }
106
107       $footer .= '</TABLE>';
108
109     }
110 };
111 </%init>