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
22 #at the very bottom (well, as low as you can go from here)
29 function areyousure(href) {
30 if (confirm("Permanently delete this <% $label %>?") == true)
31 window.location.href = href;
37 <% include("/elements/header.html","View $label: $value") %>
39 <% include( '/elements/small_custview.html', $custnum, '', 1,
40 "${p}view/cust_main.cgi") %>
45 <% include("/elements/header.html","View $label: $value", menubar(
46 "Cancel this (unaudited) $label" =>
47 "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')"
52 Service #<B><% $svcnum %></B>
53 % my $url = $opt{'edit_url'} || $p. 'edit/'. $opt{'table'}. '.cgi?';
54 | <A HREF="<%$url%><%$svcnum%>">Edit this <% $label %></A>
55 | <A HREF="javascript:areyousure('<%$p.'misc/unprovision.cgi?'.$svcnum%>')">
56 Unprovision this Service</A>
59 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
61 % foreach my $f ( @$fields ) {
63 % my($field, $type, $value);
65 % $field = $f->{'field'},
66 % $value = $f->{'value'} ? &{ $f->{'value'} }($svc_x) : $svc_x->$field;
67 % $type = $f->{'type'} || 'text',
70 % $value = $svc_x->$field;
74 % my $columndef = $part_svc->part_svc_column($field);
75 % unless ($columndef->columnflag eq 'F' && !length($columndef->columnvalue)) {
79 <% ( $opt{labels} && exists $opt{labels}->{$field} )
80 ? $opt{labels}->{$field}
85 % #eventually more options for <SELECT>, etc. fields
87 <TD BGCOLOR="#ffffff"><% $value %><TD>
95 % foreach (sort { $a cmp $b } $svc_x->virtual_fields) {
96 <% $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %>
100 </TABLE></TD></TR></TABLE>
104 % if ( defined($opt{'html_foot'}) ) {
106 <% ref($opt{'html_foot'})
107 ? &{ $opt{'html_foot'} }($svc_x)
114 <% joblisting({'svcnum'=>$svcnum}, 1) %>
116 <% include('/elements/footer.html') %>
120 unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
124 my $table = $opt{'table'};
126 my $fields = $opt{'fields'}
127 #|| [ grep { $_ ne 'svcnum' } dbdef->table($table)->columns ];
128 || [ grep { $_ ne 'svcnum' } fields($table) ];
131 if ( $cgi->param('svcnum') ) {
132 $cgi->param('svcnum') =~ /^(\d+)$/ or die "unparsable svcnum";
135 my($query) = $cgi->keywords;
136 $query =~ /^(\d+)$/ or die "no svcnum";
139 my $svc_x = qsearchs({
140 'select' => $opt{'table'}.'.*',
141 'table' => $opt{'table'},
142 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
143 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
144 ' LEFT JOIN cust_main USING ( custnum ) ',
145 'hashref' => { 'svcnum' => $svcnum },
146 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql(
147 'null_right' => 'View/link unlinked services'
149 }) or die "Unknown svcnum $svcnum in ". $opt{'table'}. " table\n";
151 my $cust_svc = $svc_x->cust_svc;
152 my($label, $value, $svcdb) = $cust_svc->label;
154 my $part_svc = $cust_svc->part_svc;
156 #false laziness w/edit/svc_Common.html
157 #override default labels with service-definition labels if applicable
158 my $labels = $opt{labels}; #not -> here
159 foreach my $field ( keys %$labels ) {
160 my $col = $part_svc->part_svc_column($field);
161 $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\S*$/;
164 my $pkgnum = $cust_svc->pkgnum;
166 my($cust_pkg, $custnum);
168 $cust_pkg = $cust_svc->cust_pkg;
169 $custnum = $cust_pkg->custnum;