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
25 function areyousure(href) {
26 if (confirm("Permanently delete this <% $label %>?") == true)
27 window.location.href = href;
33 <% include("/elements/header.html","View $label: $value") %>
35 <% include( '/elements/small_custview.html', $custnum, '', 1,
36 "${p}view/cust_main.cgi") %>
41 <% include("/elements/header.html","View $label: $value", menubar(
42 "Cancel this (unaudited) $label" =>
43 "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')"
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>
51 | <A HREF="javascript:areyousure('<%$p.'misc/unprovision.cgi?'.$svcnum%>')">
52 Unprovision this Service</A>
55 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
57 % foreach my $f ( @$fields ) {
61 % $field = $f->{'field'},
62 % $type = $f->{'type'} || 'text',
68 % my $columndef = $part_svc->part_svc_column($field);
69 % unless ($columndef->columnflag eq 'F' && !length($columndef->columnvalue)) {
73 <% ( $opt{labels} && exists $opt{labels}->{$field} )
74 ? $opt{labels}->{$field}
79 % #eventually more options for <SELECT>, etc. fields
81 <TD BGCOLOR="#ffffff"><% $svc_x->$field %><TD>
89 % foreach (sort { $a cmp $b } $svc_x->virtual_fields) {
90 <% $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %>
94 </TABLE></TD></TR></TABLE>
98 % if ( defined($opt{'html_foot'}) ) {
100 <% ref($opt{'html_foot'})
101 ? &{ $opt{'html_foot'} }($svc_x)
108 <% joblisting({'svcnum'=>$svcnum}, 1) %>
110 <% include('/elements/footer.html') %>
114 unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
118 my $table = $opt{'table'};
120 my $fields = $opt{'fields'}
121 #|| [ grep { $_ ne 'svcnum' } dbdef->table($table)->columns ];
122 || [ grep { $_ ne 'svcnum' } fields($table) ];
125 if ( $cgi->param('svcnum') ) {
126 $cgi->param('svcnum') =~ /^(\d+)$/ or die "unparsable svcnum";
129 my($query) = $cgi->keywords;
130 $query =~ /^(\d+)$/ or die "no svcnum";
133 my $svc_x = qsearchs({
134 'select' => $opt{'table'}.'.*',
135 'table' => $opt{'table'},
136 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
137 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
138 ' LEFT JOIN cust_main USING ( custnum ) ',
139 'hashref' => { 'svcnum' => $svcnum },
140 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql(
141 'null_right' => 'View/link unlinked services'
143 }) or die "Unknown svcnum $svcnum in ". $opt{'table'}. " table\n";
145 my $cust_svc = $svc_x->cust_svc;
146 my($label, $value, $svcdb) = $cust_svc->label;
148 my $part_svc = $cust_svc->part_svc;
150 #false laziness w/edit/svc_Common.html
151 #override default labels with service-definition labels if applicable
152 my $labels = $opt{labels}; #not -> here
153 foreach my $field ( keys %$labels ) {
154 my $col = $part_svc->part_svc_column($field);
155 $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\S*$/;
158 my $pkgnum = $cust_svc->pkgnum;
160 my($cust_pkg, $custnum);
162 $cust_pkg = $cust_svc->cust_pkg;
163 $custnum = $cust_pkg->custnum;