svc_phone service and CDR billing from imported CDRs
[freeside.git] / httemplate / view / elements / svc_Common.html
1 <%
2
3   # options example...
4   #
5   # 'table' => 'svc_something'
6   #
7   # 'labels' => {
8   #               'column' => 'Label',
9   #             },
10   #
11   # listref - each item is a literal column name (or method) or (notyet) coderef
12   # if not specified all columns (except for the primary key) will be viewable
13   # 'fields' => [
14   #             ]
15
16   my(%opt) = @_;
17
18   my $table = $opt{'table'};
19
20   my $fields = $opt{'fields'}
21                #|| [ grep { $_ ne 'svcnum' } dbdef->table($table)->columns ];
22                || [ grep { $_ ne 'svcnum' } fields($table) ];
23
24   my($query) = $cgi->keywords;
25   $query =~ /^(\d+)$/;
26   my $svcnum = $1;
27   my $svc_x = qsearchs( $opt{'table'}, { 'svcnum' => $svcnum } )
28     or die "Unknown svcnum $svcnum in ". $opt{'table'}. " table\n";
29
30   my $cust_svc = $svc_x->cust_svc;
31   my($label, $value, $svcdb) = $cust_svc->label;
32
33   my $pkgnum = $cust_svc->pkgnum;
34
35   my($cust_pkg, $custnum);
36   if ($pkgnum) {
37     $cust_pkg = $cust_svc->cust_pkg;
38     $custnum = $cust_pkg->custnum;
39   } else {
40     $cust_pkg = '';
41     $custnum = '';
42   }
43
44 %>
45
46 <% if ( $custnum ) { %>
47
48   <%= include("/elements/header.html","View $label: $value", menubar(
49     "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
50   )) %>
51
52   <%= include( '/elements/small_custview.html', $custnum, '', 1 ) %>
53   <BR>
54
55 <% } else { %>
56
57   <SCRIPT>
58   function areyousure(href) {
59       if (confirm("Permanently delete this <%= $label %>?") == true)
60           window.location.href = href;
61   }
62   </SCRIPT>
63
64   <%= include("/elements/header.html","View $label: $value", menubar(
65       "Cancel this (unaudited) $label" =>
66             "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')"
67   )) %>
68
69 <% } %>
70
71 Service #<B><%= $svcnum %></B>
72 | <A HREF="<%=$p%>edit/<%= $opt{'table'} %>.cgi?<%=$svcnum%>">Edit this <%= $label %></A>
73 <BR>
74
75 <%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %>
76
77 <% foreach my $f ( @$fields ) {
78
79      my( $field, $type);
80      if ( ref($f) ) {
81        $field = $f->{'field'},
82        $type  = $f->{'type'} || 'text',
83      } else {
84        $field = $f;
85        $type = 'text';
86      }
87 %>
88
89   <TR>
90     <TD ALIGN="right">
91       <%= ( $opt{labels} && exists $opt{labels}->{$field} )
92               ? $opt{labels}->{$field}
93               : $field
94       %>
95     </TD>
96
97     <%
98       #eventually more options for <SELECT>, etc. fields
99     %>
100
101     <TD BGCOLOR="#ffffff"><%= $svc_x->$field %><TD>
102
103   </TR>
104
105 <% } %>
106
107 <% foreach (sort { $a cmp $b } $svc_x->virtual_fields) { %>
108   <%= $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %>
109 <% } %>
110
111 </TABLE></TD></TR></TABLE>
112
113 <BR>
114 <%= joblisting({'svcnum'=>$svcnum}, 1) %>
115
116 <%= include('/elements/footer.html') %>