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 % my $delmsg = emt("Permanently delete this [_1]?", $label);
31 if (confirm(<% $delmsg |js_string %>) == true)
32 window.location.href = href;
38 <& /elements/header.html, mt("View [_1]: [_2]",$label,$value) &>
40 <& /elements/small_custview.html, $custnum, '', 1,
41 "${p}view/cust_main.cgi" &>
46 <& /elements/header.html, mt("View [_1]: [_2]",$label,$value), menubar(
47 emt("Cancel this (unaudited) [_1]",$label) =>
48 "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')"
53 <% mt('Service #') |h %><B><% $svcnum %></B>
54 % my $url = $opt{'edit_url'} || $p. 'edit/'. $opt{'table'}. '.cgi?';
55 | <& /view/elements/svc_edit_link.html, 'svc' => $svc_x, 'edit_url' => $url &>
58 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
60 % foreach my $f ( @$fields ) {
62 % my($field, $type, $value, $hack_strict_refs);
64 % $field = $f->{'field'};
65 % $hack_strict_refs = \&{ $f->{'value'} } if $f->{'value'};
66 % $value = $f->{'value'} ? &$hack_strict_refs($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 % $value = time2str($date_format,$value) if ( $type eq 'date' && $value );
86 % $value = time2str("$date_format %H:%M",$value) if ( $type eq 'datetime' && $value );
87 % $value = $value eq 'Y' ? emt('Yes') : emt('No') if ( $type eq 'checkbox' );
88 % #eventually more options for <SELECT>, etc. fields
90 <TD BGCOLOR="#ffffff"><% $value %><TD>
98 % foreach (sort { $a cmp $b } $svc_x->virtual_fields) {
99 <% $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %>
103 </TABLE></TD></TR></TABLE>
107 % if ( defined($opt{'html_foot'}) ) {
109 <% ref($opt{'html_foot'})
110 ? &{ $opt{'html_foot'} }($svc_x)
117 % if ( $conf->config('ticket_system') ) {
118 <& /elements/table-tickets.html, object => $cust_svc &>
121 <% joblisting({'svcnum'=>$svcnum}, 1) %>
123 <% include('/elements/footer.html') %>
127 unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
131 my $conf = new FS::Conf;
132 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
134 my $table = $opt{'table'};
136 my $fields = $opt{'fields'}
137 #|| [ grep { $_ ne 'svcnum' } dbdef->table($table)->columns ];
138 || [ grep { $_ ne 'svcnum' } fields($table) ];
141 if ( $cgi->param('svcnum') ) {
142 $cgi->param('svcnum') =~ /^(\d+)$/ or die "unparsable svcnum";
145 my($query) = $cgi->keywords;
146 $query =~ /^(\d+)$/ or die "no svcnum";
149 my $svc_x = qsearchs({
150 'select' => $opt{'table'}.'.*',
151 'table' => $opt{'table'},
152 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
153 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
154 ' LEFT JOIN cust_main USING ( custnum ) ',
155 'hashref' => { 'svcnum' => $svcnum },
156 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql(
157 'null_right' => 'View/link unlinked services'
159 }) or die "Unknown svcnum $svcnum in ". $opt{'table'}. " table\n";
161 my $cust_svc = $svc_x->cust_svc;
162 my($label, $value, $svcdb) = $cust_svc->label;
164 my $part_svc = $cust_svc->part_svc;
166 #false laziness w/edit/svc_Common.html
167 #override default labels with service-definition labels if applicable
168 my $labels = $opt{labels}; #not -> here
169 foreach my $field ( keys %$labels ) {
170 my $col = $part_svc->part_svc_column($field);
171 $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\s*$/;
174 my $pkgnum = $cust_svc->pkgnum;
176 my($cust_pkg, $custnum);
178 $cust_pkg = $cust_svc->cust_pkg;
179 $custnum = $cust_pkg->custnum;
185 &{ $opt{'svc_callback'} }( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, \%opt )
186 if $opt{'svc_callback'};