5 include( 'elements/svc_Common.html,
7 'table' => 'svc_something'
13 #listref - each item is a literal column name (or method) or
14 # (notyet) coderef. if not specified all columns (except for the
15 #primary key) will be viewable
19 # defaults to "edit/$table.cgi?", will have svcnum appended
26 <% include("/elements/header.html","View $label: $value") %>
28 <% include( '/elements/small_custview.html', $custnum, '', 1,
29 "${p}view/cust_main.cgi") %>
34 <% include("/elements/header.html","View $label: $value", menubar(
35 "Cancel this (unaudited) $label" =>
36 "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')"
40 function areyousure(href) {
41 if (confirm("Permanently delete this <% $label %>?") == true)
42 window.location.href = href;
48 Service #<B><% $svcnum %></B>
49 % my $url = $opt{'edit_url'} || $p. 'edit/'. $opt{'table'}. '.cgi?';
50 | <A HREF="<%$url%><%$svcnum%>">Edit this <% $label %></A>
53 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
55 % foreach my $f ( @$fields ) {
59 % $field = $f->{'field'},
60 % $type = $f->{'type'} || 'text',
66 % my $columndef = $part_svc->part_svc_column($field);
67 % unless ($columndef->columnflag eq 'F' && !length($columndef->columnvalue)) {
71 <% ( $opt{labels} && exists $opt{labels}->{$field} )
72 ? $opt{labels}->{$field}
77 % #eventually more options for <SELECT>, etc. fields
79 <TD BGCOLOR="#ffffff"><% $svc_x->$field %><TD>
87 % foreach (sort { $a cmp $b } $svc_x->virtual_fields) {
88 <% $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %>
92 </TABLE></TD></TR></TABLE>
96 % if ( defined($opt{'html_foot'}) ) {
98 <% ref($opt{'html_foot'})
99 ? &{ $opt{'html_foot'} }($svc_x)
106 <% joblisting({'svcnum'=>$svcnum}, 1) %>
108 <% include('/elements/footer.html') %>
112 unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
116 my $table = $opt{'table'};
118 my $fields = $opt{'fields'}
119 #|| [ grep { $_ ne 'svcnum' } dbdef->table($table)->columns ];
120 || [ grep { $_ ne 'svcnum' } fields($table) ];
123 if ( $cgi->param('svcnum') ) {
124 $cgi->param('svcnum') =~ /^(\d+)$/ or die "unparsable svcnum";
127 my($query) = $cgi->keywords;
128 $query =~ /^(\d+)$/ or die "no svcnum";
131 my $svc_x = qsearchs({
132 'select' => $opt{'table'}.'.*',
133 'table' => $opt{'table'},
134 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
135 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
136 ' LEFT JOIN cust_main USING ( custnum ) ',
137 'hashref' => { 'svcnum' => $svcnum },
138 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql(
139 'null_right' => 'View/link unlinked services'
141 }) or die "Unknown svcnum $svcnum in ". $opt{'table'}. " table\n";
143 my $cust_svc = $svc_x->cust_svc;
144 my($label, $value, $svcdb) = $cust_svc->label;
146 my $part_svc = $cust_svc->part_svc;
148 #false laziness w/edit/svc_Common.html
149 #override default labels with service-definition labels if applicable
150 my $labels = $opt{labels}; #not -> here
151 foreach my $field ( keys %$labels ) {
152 my $col = $part_svc->part_svc_column($field);
153 $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\S*$/;
156 my $pkgnum = $cust_svc->pkgnum;
158 my($cust_pkg, $custnum);
160 $cust_pkg = $cust_svc->cust_pkg;
161 $custnum = $cust_pkg->custnum;