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 % if ( $opt{radius_usage} ) {
54 <& svc_radius_usage.html,
56 'part_svc' => $part_svc,
57 'cust_pkg' => $cust_pkg,
61 <% mt('Service #') |h %><B><% $svcnum %></B>
63 % my $url = $opt{'edit_url'} || $p. 'edit/'. $opt{'table'}. '.cgi?';
64 <& /view/elements/svc_edit_link.html, 'svc' => $svc_x, 'edit_url' => $url &>
68 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
70 % my @inventory_items = $svc_x->inventory_item;
71 % foreach my $f ( @$fields ) {
73 % my($field, $type, $value);
75 % $field = $f->{'field'};
76 % $type = $f->{'type'} || 'text';
77 % if ( $f->{'value_callback'} ) {
78 % my $hack_strict_refs = \&{ $f->{'value_callback'} };
79 % $value = &$hack_strict_refs($svc_x);
81 % $value = exists($f->{'value'})
83 % : encode_entities($svc_x->$field);
88 % $value = encode_entities($svc_x->$field);
91 % my $columndef = $part_svc->part_svc_column($field);
92 % if ( $columndef->columnflag =~ /^[MA]$/ && $columndef->columnvalue =~ /,/ )
94 % # inventory-select field with multiple classes
95 % # show the class name to disambiguate
96 % my ($item) = grep { $_->svc_field eq $field } @inventory_items;
97 % my $class = qsearchs('inventory_class', { classnum => $item->classnum });
98 % $value .= ' <i>('. $class->classname . ')</i>' if $class;
100 % unless ($columndef->columnflag eq 'F' && !length($columndef->columnvalue)) {
104 <% ( $opt{labels} && exists $opt{labels}->{$field} )
105 ? $opt{labels}->{$field}
110 % $value = time2str($date_format,$value)
111 % if $type eq 'date' && $value;
112 % $value = time2str("$date_format %H:%M",$value)
113 % if $type eq 'datetime' && $value;
114 % $value = $value eq 'Y' ? emt('Yes') : emt('No')
115 % if $type eq 'checkbox';
116 % $value .= ' ('. (Net::MAC::Vendor::lookup($value))->[0]. ')'
117 % if $type =~ /mac_addr$/ && $value =~ /\w/i;
118 % #eventually more options for <SELECT>, etc. fields
120 <TD BGCOLOR="#ffffff"><% $value %><TD>
128 % foreach (sort { $a cmp $b } $svc_x->virtual_fields) {
129 <% $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %>
133 </TABLE></TD></TR></TABLE>
139 'table' => $svc_x->device_table,
142 % if ( defined($opt{'html_foot'}) ) {
144 <% ref($opt{'html_foot'})
145 ? &{ $opt{'html_foot'} }($svc_x)
153 <& /elements/table-tickets.html, object => $cust_svc &>
156 <% joblisting({'svcnum'=>$svcnum}, 1) %>
158 <% include('/elements/footer.html') %>
162 unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
166 my $conf = new FS::Conf;
167 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
169 my $table = $opt{'table'};
171 my $fields = $opt{'fields'}
172 #|| [ grep { $_ ne 'svcnum' } dbdef->table($table)->columns ];
173 || [ grep { $_ ne 'svcnum' } fields($table) ];
176 if ( $cgi->param('svcnum') ) {
177 $cgi->param('svcnum') =~ /^(\d+)$/ or die "unparseable svcnum";
180 my($query) = $cgi->keywords;
181 $query =~ /^(\d+)$/ or die "no svcnum";
184 my $svc_x = qsearchs({
185 'select' => $opt{'table'}.'.*',
186 'table' => $opt{'table'},
187 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
188 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
189 ' LEFT JOIN cust_main USING ( custnum ) ',
190 'hashref' => { 'svcnum' => $svcnum },
191 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql(
192 'null_right' => 'View/link unlinked services'
194 }) or die "Unknown svcnum $svcnum in ". $opt{'table'}. " table\n";
196 my $cust_svc = $svc_x->cust_svc;
197 my ($label, $value, $svcdb, $part_svc );
198 my $labels = $opt{labels}; #not -> here
201 ($label, $value, $svcdb) = $cust_svc->label;
203 $part_svc = $cust_svc->part_svc;
205 #false laziness w/edit/svc_Common.html
206 #override default labels with service-definition labels if applicable
207 foreach my $field ( keys %$labels ) {
208 my $col = $part_svc->part_svc_column($field);
209 $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\s*$/;
212 $label = "Unlinked $table";
213 $value = $svc_x->label;
215 # just to satisfy callbacks
216 $part_svc = FS::part_svc->new({ svcpart => 0, svcdb => $table });
219 my $pkgnum = $cust_svc->pkgnum if $cust_svc;
221 my($cust_pkg, $custnum);
223 $cust_pkg = $cust_svc->cust_pkg;
224 $custnum = $cust_pkg->custnum;
231 if ( my $router = qsearchs('router', { svcnum => $svc_x->svcnum }) ) {
232 push @$fields, qw(router_routername router_block);
233 $labels->{'router_routername'} = 'Attached router';
234 $labels->{'router_block'} = 'Attached address block';
235 $svc_x->set('router_routername', $router->routername);
236 my $block = qsearchs('addr_block', { routernum => $router->routernum });
238 $svc_x->set('router_block', $block->cidr);
240 $svc_x->set('router_block', '<i>(none)</i>');
244 &{ $opt{'svc_callback'} }( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, \%opt )
245 if $opt{'svc_callback'};