diff options
Diffstat (limited to 'httemplate')
23 files changed, 631 insertions, 74 deletions
diff --git a/httemplate/browse/circuit_provider.html b/httemplate/browse/circuit_provider.html new file mode 100644 index 000000000..12f653251 --- /dev/null +++ b/httemplate/browse/circuit_provider.html @@ -0,0 +1,11 @@ +<& elements/browse-simple.html, + 'table' => 'circuit_provider', + 'title' => 'Circuit providers', + 'menubar' => [ 'Circuit types' => 'circuit_type.html', + 'Circuit terminations' => 'circuit_termination.html' + ], + 'name_singular' => 'provider', + 'name_header' => 'Provider name', + 'name_col' => 'provider', + 'acl' => 'Configuration', +&> diff --git a/httemplate/browse/circuit_termination.html b/httemplate/browse/circuit_termination.html new file mode 100644 index 000000000..830ccf7fb --- /dev/null +++ b/httemplate/browse/circuit_termination.html @@ -0,0 +1,11 @@ +<& elements/browse-simple.html, + 'table' => 'circuit_termination', + 'title' => 'Circuit terminations', + 'menubar' => [ 'Circuit types' => 'circuit_type.html', + 'Circuit providers' => 'circuit_provider.html' + ], + 'name_singular' => 'termination type', + 'name_header' => 'Termination type', + 'name_col' => 'termination', + 'acl' => 'Configuration', +&> diff --git a/httemplate/browse/circuit_type.html b/httemplate/browse/circuit_type.html new file mode 100644 index 000000000..a145d54d9 --- /dev/null +++ b/httemplate/browse/circuit_type.html @@ -0,0 +1,11 @@ +<& elements/browse-simple.html, + 'table' => 'circuit_type', + 'title' => 'Circuit types', + 'menubar' => [ 'Circuit providers' => 'circuit_provider.html', + 'Circuit terminations' => 'circuit_termination.html' + ], + 'name_singular' => 'circuit type', + 'name_header' => 'Circuit type', + 'name_col' => 'typename', + 'acl' => 'Configuration', +&> diff --git a/httemplate/browse/elements/browse-simple.html b/httemplate/browse/elements/browse-simple.html new file mode 100644 index 000000000..cfa27e882 --- /dev/null +++ b/httemplate/browse/elements/browse-simple.html @@ -0,0 +1,57 @@ +<& browse.html, + 'query' => { 'table' => $table }, + 'count_query' => "SELECT COUNT(*) FROM $table", + 'header' => [ '#', $opt{name_header} ], + 'fields' => [ $table_key, $opt{name_col} ], + 'links' => [ '', '' ], + 'link_onclicks' => [ '', $sub_edit_popup ], + 'disableable' => 1, + 'disabled_statuspos' => 2, + 'html_init' => $html_init, + %opt, +&> +<%doc> +A simple wrapper around search/elements/search.html for browsing/editing +tables that only have a primary key, a 'disabled' field, and one other column +which is the object's name or description. Usage: + +<& browse-simple.html, + # required + 'table' => 'mytable', + 'title' => 'My Things', + 'name_singular' => 'thing', + 'name_col' => 'thingname', + 'name_header' => 'Thing name' + 'acl' => 'Configure things', +&> + +</%doc> +<%init> +my %opt = @_; + +my $table = delete $opt{table}; +my $name_singular = $opt{name_singular}; + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right($opt{acl}); + +my $table_key = dbdef->table($table)->primary_key; +my $sub_edit_popup = sub { + my $pkey = $_[0]->get($table_key); + include('/elements/popup_link_onclick.html', + 'action' => $p."edit/$table.html?$pkey", + 'actionlabel' => "Edit $name_singular", + 'width' => 350, + 'height' => 220, + ); +}; + +my $html_init = include('/elements/popup_link.html', + 'action' => $p."edit/$table.html?", + 'actionlabel' => "Add $name_singular", + 'width' => 350, + 'height' => 220, + 'label' => "Add a new $name_singular", +) . '<BR>'; + +</%init> diff --git a/httemplate/docs/part_svc-table.html b/httemplate/docs/part_svc-table.html index 8d3711d23..5e8d9e5d1 100644 --- a/httemplate/docs/part_svc-table.html +++ b/httemplate/docs/part_svc-table.html @@ -23,6 +23,7 @@ <LI><B>svc_broadband</B>: Wireless broadband <LI><B>svc_cable</B>: Cable <LI><B>svc_dish</B>: DISH Network + <LI><B>svc_circuit</B>: Phone circuits other than DSL </UL> </TD> <TD VALIGN="top"> diff --git a/httemplate/edit/circuit_provider.html b/httemplate/edit/circuit_provider.html new file mode 100644 index 000000000..6c8dcedac --- /dev/null +++ b/httemplate/edit/circuit_provider.html @@ -0,0 +1,21 @@ +<& elements/edit.html, + 'popup' => 1, + 'table' => 'circuit_provider', + 'name_singular' => 'provider', + 'labels' => \%labels, + 'fields' => \@fields, +&> +<%init> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my @fields = ( + 'provider', + { field => 'disabled', type => 'checkbox', value => 'Y' } +); +my %labels = ( + 'providernum' => '', + 'provider' => 'Provider name', + 'disabled' => 'Disabled' +); +</%init> diff --git a/httemplate/edit/circuit_termination.html b/httemplate/edit/circuit_termination.html new file mode 100644 index 000000000..0317bced5 --- /dev/null +++ b/httemplate/edit/circuit_termination.html @@ -0,0 +1,21 @@ +<& elements/edit.html, + 'popup' => 1, + 'table' => 'circuit_termination', + 'name_singular' => 'termination type', + 'labels' => \%labels, + 'fields' => \@fields, +&> +<%init> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my @fields = ( + 'termination', + { field => 'disabled', type => 'checkbox', value => 'Y' } +); +my %labels = ( + 'termnum' => '', + 'termination' => 'Termination type', + 'disabled' => 'Disabled' +); +</%init> diff --git a/httemplate/edit/circuit_type.html b/httemplate/edit/circuit_type.html new file mode 100644 index 000000000..897758897 --- /dev/null +++ b/httemplate/edit/circuit_type.html @@ -0,0 +1,21 @@ +<& elements/edit.html, + 'popup' => 1, + 'table' => 'circuit_type', + 'name_singular' => 'circuit type', + 'labels' => \%labels, + 'fields' => \@fields, +&> +<%init> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my @fields = ( + 'typename', + { field => 'disabled', type => 'checkbox', value => 'Y' } +); +my %labels = ( + 'typenum' => '', + 'typename' => 'Circuit type', + 'disabled' => 'Disabled' +); +</%init> diff --git a/httemplate/edit/elements/part_svc_column.html b/httemplate/edit/elements/part_svc_column.html index 64901a80f..6dcb602fe 100644 --- a/httemplate/edit/elements/part_svc_column.html +++ b/httemplate/edit/elements/part_svc_column.html @@ -249,7 +249,10 @@ that field. </TR> % } % # special case: services with attached routers (false laziness...) -% if ( $svcdb eq 'svc_acct' or $svcdb eq 'svc_broadband' or $svcdb eq 'svc_dsl' ) { +% if ( $svcdb eq 'svc_acct' +% or $svcdb eq 'svc_broadband' +% or $svcdb eq 'svc_dsl' +% or $svcdb eq 'svc_circuit' ) { % push @fields, 'has_router'; <TR> <TD COLSPAN=3 ALIGN="right"> diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html index fc29327ae..97b630f76 100644 --- a/httemplate/edit/elements/svc_Common.html +++ b/httemplate/edit/elements/svc_Common.html @@ -103,10 +103,42 @@ my $flag = $columndef->columnflag; if ( $flag eq 'F' ) { #fixed - $f->{'type'} = length($columndef->columnvalue) - ? 'fixed' - : 'hidden'; $f->{'value'} = $columndef->columnvalue; + if (length($columndef->columnvalue)) { + + if ( $f->{'type'} =~ /^select-?(.*)/ ) { + # try to display this in a user-friendly manner + if ( $f->{'table'} ) { # find matching records + $f->{'value_col'} ||= + dbdef->table($f->{'table'})->primary_key; + + my @values = split(',', $f->{'value'}); + my @recs; + foreach (@values) { + push @recs, qsearchs( $f->{'table'}, + { $f->{'value_col'} => $_ } + ); + } + if ( @recs ) { + my $method = $f->{'name_col'}; + if ( $f->{'multiple'} ) { + $f->{'formatted_value'} = [ + map { $_->method } @recs + ]; + } else { # there shouldn't be more than one... + $f->{'formatted_value'} = $recs[0]->$method; + } + } # if not, then just let tr-fixed display the + # values as-is + + } # other select types probably don't matter + } # if it's a select + + $f->{'type'} = 'fixed'; + + } else { # fixed, null + $f->{'type'} = 'hidden'; + } } elsif ( $flag eq 'A' ) { #auto assign from inventory $f->{'type'} = 'hidden'; @@ -127,16 +159,14 @@ }; } elsif ( $flag eq 'S' #selectable choice - && $f->{type} !~ /^select-svc(-domain|_pbx)$/ ) { + && $f->{type} !~ /^select-svc/ ) { $f->{type} = 'select'; $f->{options} = [ split( /\s*,\s*/, $columndef->columnvalue) ]; - } + } # shouldn't this be enforced for all 'S' fields? - if ( $f->{'type'} eq 'select-svc_pbx' - || $f->{'type'} eq 'select-svc-domain' - ) + if ( $f->{'type'} =~ /^select-svc/ ) { $f->{'include_opt_callback'} = sub { ( 'pkgnum' => $pkgnum, diff --git a/httemplate/edit/process/circuit_provider.html b/httemplate/edit/process/circuit_provider.html new file mode 100644 index 000000000..0a91a178d --- /dev/null +++ b/httemplate/edit/process/circuit_provider.html @@ -0,0 +1,11 @@ +<& elements/process.html, + 'table' => 'circuit_provider', + 'viewall_dir' => 'browse', + 'popup_reload' => 'Updating', +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/process/circuit_termination.html b/httemplate/edit/process/circuit_termination.html new file mode 100644 index 000000000..94d29c05c --- /dev/null +++ b/httemplate/edit/process/circuit_termination.html @@ -0,0 +1,11 @@ +<& elements/process.html, + 'table' => 'circuit_termination', + 'viewall_dir' => 'browse', + 'popup_reload' => 'Updating', +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/process/circuit_type.html b/httemplate/edit/process/circuit_type.html new file mode 100644 index 000000000..58f461e2c --- /dev/null +++ b/httemplate/edit/process/circuit_type.html @@ -0,0 +1,11 @@ +<& elements/process.html, + 'table' => 'circuit_type', + 'viewall_dir' => 'browse', + 'popup_reload' => 'Updating', +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/process/elements/svc_Common.html b/httemplate/edit/process/elements/svc_Common.html index 55ecc5f79..ca336a126 100644 --- a/httemplate/edit/process/elements/svc_Common.html +++ b/httemplate/edit/process/elements/svc_Common.html @@ -29,7 +29,7 @@ my $args_callback = sub { map { $_ => $cgi->param("router_$_") } qw( routernum routername blocknum ) }); - if (length($router->routername) == 0) { + if ($router->blocknum and length($router->routername) == 0) { #sensible default $router->set('routername', $svc->label); } diff --git a/httemplate/edit/process/svc_circuit.html b/httemplate/edit/process/svc_circuit.html new file mode 100644 index 000000000..d28f91329 --- /dev/null +++ b/httemplate/edit/process/svc_circuit.html @@ -0,0 +1,11 @@ +<& elements/svc_Common.html, + table => 'svc_circuit', + edit_ext => 'html', + redirect => popurl(3)."view/svc_circuit.html?", +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? + +</%init> diff --git a/httemplate/edit/svc_circuit.cgi b/httemplate/edit/svc_circuit.cgi new file mode 100644 index 000000000..3f9bad5b1 --- /dev/null +++ b/httemplate/edit/svc_circuit.cgi @@ -0,0 +1,54 @@ +<& elements/svc_Common.html, + 'table' => 'svc_circuit', + 'fields' => \@fields, +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? + +my $conf = new FS::Conf; +my $date_format = $conf->config('date_format') || '%m/%d/%Y'; + +my @fields = ( + { field => 'providernum', + type => 'select-table', + table => 'circuit_provider', + name_col => 'provider', + disable_empty => 1, + }, + { field => 'typenum', + type => 'select-table', + table => 'circuit_type', + name_col => 'typename', + disable_empty => 1, + }, + { field => 'termnum', + type => 'select-table', + table => 'circuit_termination', + name_col => 'termination', + disable_empty => 1, + }, + { field => 'circuit_id', + size => 40, + }, + { field => 'desired_due_date', + type => 'input-date-field', + }, + { field => 'due_date', + type => 'input-date-field', + }, + 'vendor_order_id', + 'vendor_qual_id', + 'vendor_order_status', + 'endpoint_ip_addr', + { field => 'endpoint_mac_addr', + type => 'input-mac_addr', + }, +); + +# needed: a new_callback to migrate vendor quals over to circuits + +#my ($svc_new_callback, $svc_edit_callback, $svc_error_callback); + +</%init> diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi index f8582057e..f9c0d4005 100644 --- a/httemplate/edit/svc_phone.cgi +++ b/httemplate/edit/svc_phone.cgi @@ -2,17 +2,12 @@ 'table' => 'svc_phone', 'fields' => [], 'begin_callback' => $begin_callback, - 'svc_new_callback' => sub { - my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt ) = @_; - $svc_x->locationnum($cust_pkg->locationnum) if $cust_pkg; - }, - 'svc_edit_callback' => sub { - my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt) = @_; - my $conf = new FS::Conf; - $svc_x->sip_password('*HIDDEN*') unless $conf->exists('showpasswords'); - }, + 'svc_new_callback' => $svc_callback, + 'svc_edit_callback' => $svc_callback, + 'svc_error_callback' => $svc_callback, &> <%init> +my $conf = new FS::Conf; my $begin_callback = sub { my( $cgi, $fields, $opt ) = @_; @@ -25,8 +20,6 @@ my $begin_callback = sub { die "access denied" unless $FS::CurrentUser::CurrentUser->access_right($right); - my $conf = new FS::Conf; - push @$fields, 'countrycode', { field => 'phonenum', @@ -149,7 +142,26 @@ my $begin_callback = sub { } -}; +}; # begin_callback +# svc_edit_callback / svc_new_callback +my $svc_callback = sub { + my ($cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt) = @_; + push @$fields, { + field => 'circuit_svcnum', + type => 'select-svc_circuit', + cust_pkg => $cust_pkg, + part_svc => $part_svc, + }; + + if ( $cust_pkg and not $svc_x->svcnum ) { + # new service, default to package location + $svc_x->set('locationnum', $cust_pkg->locationnum); + } + + if ( not $conf->exists('showpasswords') and $svc_x->svcnum ) { + $svc_x->sip_password('*HIDDEN*'); + } +}; </%init> diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index f26882b1f..b4ecdc490 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -552,6 +552,12 @@ tie my %config_conferencing, 'Tie::IxHash', 'Quality levels' => [ $fsurl.'browse/conferencing_quality.html', '' ], ; +tie my %config_circuit, 'Tie::IxHash', + 'Circuit types' => [ $fsurl.'browse/circuit_type.html', '' ], + 'Circuit providers' => [ $fsurl.'browse/circuit_provider.html', '' ], + 'Termination types' => [ $fsurl.'browse/circuit_termination.html', '' ], +; + tie my %config_export_svc, 'Tie::IxHash', (); if ( $curuser->access_right('Configuration') ) { $config_export_svc{'Service definitions'} = [ $fsurl.'browse/part_svc.cgi', 'Services are items you offer to your customers' ]; @@ -572,6 +578,8 @@ $config_export_svc{'Conferencing'} = [ \%config_conferencing, '' ] if $curuser->access_right('Configuration'); $config_export_svc{'Alarm'} = [ \%config_alarm, '' ] if $curuser->access_right(['Alarm configuration', 'Alarm global configuration']); +$config_export_svc{'Circuits'} = [ \%config_circuit, '' ] + if $curuser->access_right('Configuration'); $config_export_svc{'Hardware types'} = [ $fsurl.'browse/hardware_class.html', 'Set up hardware type catalog' ] if $curuser->access_right('Configuration'); diff --git a/httemplate/elements/tr-select-svc_circuit.html b/httemplate/elements/tr-select-svc_circuit.html new file mode 100644 index 000000000..fb55501c5 --- /dev/null +++ b/httemplate/elements/tr-select-svc_circuit.html @@ -0,0 +1,41 @@ +% if ( $columnflag eq 'F' ) { # no good reason for this, but support it anyway + <INPUT TYPE="hidden" NAME="circuit_svcnum" VALUE="<% $circuit_svcnum %>"> +% } else { + <& tr-select-table.html, + 'table' => 'svc_circuit', + 'name_col' => 'circuit_id', + 'empty_label' => ' ', + %select_hash, + %opt + &> +% } +<%init> + +my %opt = @_; + +my $circuit_svcnum; +if ( $opt{'curr_value'} =~ /^(\d+)$/ ) { + $circuit_svcnum = $1; +} + +# generally not the svcpart of the circuit service (or any circuit service) +my $part_svc = $opt{'part_svc'} + || qsearchs('part_svc', { 'svcpart' => $opt{'svcpart'} }); + +my $columnflag = $part_svc->part_svc_column('circuit_svcnum')->columnflag; + +my $cust_pkg = $opt{'cust_pkg'}; +my $custnum; +$custnum = $cust_pkg->custnum if $cust_pkg; + +my %select_hash; +if ( $custnum =~ /^(\d+)$/ ) { + %select_hash = ( + 'addl_from' => ' LEFT JOIN cust_svc USING (svcnum)' . + ' LEFT JOIN cust_pkg USING (pkgnum)', + 'extra_sql' => " WHERE cust_pkg.custnum = $custnum". + " OR svcnum = $circuit_svcnum", + ); +} + +</%init> diff --git a/httemplate/search/svc_circuit.cgi b/httemplate/search/svc_circuit.cgi new file mode 100755 index 000000000..c14c55fdc --- /dev/null +++ b/httemplate/search/svc_circuit.cgi @@ -0,0 +1,65 @@ +<& elements/svc_Common.html, + 'title' => 'Circuit Search Results', + 'name' => 'circuit services', + 'query' => $query, + 'count_query' => $query->{'count_query'}, + 'redirect' => [ popurl(2). "view/svc_circuit.html?", 'svcnum' ], + 'header' => [ '#', + 'Provider', + 'Type', + 'Termination', + 'Circuit ID', + 'IP Address', + FS::UI::Web::cust_header($cgi->param('cust_fields')), + ], + 'fields' => [ 'svcnum', + 'provider', + 'typename', + 'termination', + 'circuit_id', + 'ip_addr', + \&FS::UI::Web::cust_fields, + ], + 'links' => [ $link, + '', + '', + '', + $link, + $link, + FS::UI::Web::cust_links($cgi->param('cust_fields')), + ], + 'align' => 'rlllll'. FS::UI::Web::cust_aligns(), + 'color' => [ + ('') x 6, + FS::UI::Web::cust_colors(), + ], + 'style' => [ + ('') x 6, + FS::UI::Web::cust_styles(), + ], + +&> +<%init> + +die "access denied" unless + $FS::CurrentUser::CurrentUser->access_right('List services'); + +my $conf = new FS::Conf; + +my %search_hash; +if ( $cgi->param('magic') eq 'unlinked' ) { + %search_hash = ( 'unlinked' => 1 ); +} else { + foreach (qw( custnum agentnum svcpart cust_fields )) { + $search_hash{$_} = $cgi->param($_) if $cgi->param($_); + } + foreach (qw(pkgpart routernum towernum sectornum)) { + $search_hash{$_} = [ $cgi->param($_) ] if $cgi->param($_); + } +} + +my $query = FS::svc_circuit->search(\%search_hash); + +my $link = [ $p.'view/svc_circuit.html?', 'svcnum' ]; + +</%init> diff --git a/httemplate/view/elements/svc_Common.html b/httemplate/view/elements/svc_Common.html index b12d2ddcd..6c5c90201 100644 --- a/httemplate/view/elements/svc_Common.html +++ b/httemplate/view/elements/svc_Common.html @@ -32,6 +32,15 @@ function areyousure(href) { window.location.href = href; } </SCRIPT> +<STYLE> + td.content { + background-color: #ffffff; + } + .error { + color: #ff0000; + font-weight: bold; + } +</STYLE> % if ( $custnum ) { @@ -67,61 +76,20 @@ function areyousure(href) { <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %> -% my @inventory_items = $svc_x->inventory_item; % foreach my $f ( @$fields ) { -% -% my($field, $type, $value); -% if ( ref($f) ) { -% $field = $f->{'field'}; -% $type = $f->{'type'} || 'text'; -% if ( $f->{'value_callback'} ) { -% my $hack_strict_refs = \&{ $f->{'value_callback'} }; -% $value = &$hack_strict_refs($svc_x); -% } else { -% $value = encode_entities($svc_x->$field); -% } -% } else { -% $field = $f; -% $type = 'text'; -% $value = encode_entities($svc_x->$field); -% } -% -% my $columndef = $part_svc->part_svc_column($field); -% if ( $columndef->columnflag =~ /^[MA]$/ && $columndef->columnvalue =~ /,/ ) -% { -% # inventory-select field with multiple classes -% # show the class name to disambiguate -% my ($item) = grep { $_->svc_field eq $field } @inventory_items; -% my $class = qsearchs('inventory_class', { classnum => $item->classnum }); -% $value .= ' <i>('. $class->classname . ')</i>' if $class; -% } -% unless ($columndef->columnflag eq 'F' && !length($columndef->columnvalue)) { - +% my ($field, $label, $value) = &{ $format_field }($f); +% next if !$field; <TR> <TD ALIGN="right"> - <% ( $opt{labels} && exists $opt{labels}->{$field} ) - ? $opt{labels}->{$field} - : $field - %> + <% $label %> </TD> -% $value = time2str($date_format,$value) -% if $type eq 'date' && $value; -% $value = time2str("$date_format %H:%M",$value) -% if $type eq 'datetime' && $value; -% $value = $value eq 'Y' ? emt('Yes') : emt('No') -% if $type eq 'checkbox'; -% $value .= ' ('. (Net::MAC::Vendor::lookup($value))->[0]. ')' -% if $type =~ /mac_addr$/ && $value =~ /\w/i; -% #eventually more options for <SELECT>, etc. fields - - <TD BGCOLOR="#ffffff"><% $value %><TD> - + <TD CLASS="content"> + <% $value %> + </TD> </TR> -% } -% -% } +% } % foreach (sort { $a cmp $b } $svc_x->virtual_fields) { <% $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %> @@ -193,7 +161,7 @@ my $svc_x = qsearchs({ my $cust_svc = $svc_x->cust_svc; my ($label, $value, $svcdb, $part_svc ); -my $labels = $opt{labels}; #not -> here +my $labels = $opt{labels} || {}; if ( $cust_svc ) { ($label, $value, $svcdb) = $cust_svc->label; @@ -227,7 +195,10 @@ if ($pkgnum) { # attached routers if ( my $router = qsearchs('router', { svcnum => $svc_x->svcnum }) ) { - push @$fields, qw(router_routername router_block); + push @$fields, + 'router_routername', + 'router_block'; + $labels->{'router_routername'} = 'Attached router'; $labels->{'router_block'} = 'Attached address block'; $svc_x->set('router_routername', $router->routername); @@ -235,10 +206,100 @@ if ( my $router = qsearchs('router', { svcnum => $svc_x->svcnum }) ) { if ( $block ) { $svc_x->set('router_block', $block->cidr); } else { - $svc_x->set('router_block', '<i>(none)</i>'); + $svc_x->set('router_block', '(none)'); } } +my @inventory_items = $svc_x->inventory_item; + +my $format_field = sub { + my $f = shift; + my($field, $type, $value); + if ( ref($f) ) { + $field = $f->{'field'}; + $type = $f->{'type'} || 'text'; + } else { + $field = $f; + $type = 'text'; + } + + my $columndef = $part_svc->part_svc_column($field); + # skip fields that are fixed and empty + if ( $columndef->columnflag eq 'F' + and length($columndef->columnvalue) == 0 ) { + return; + } + + # things that override the column value: value_callback, select + if ( ref($f) and $f->{'value_callback'} ) { + + my $hack_strict_refs = \&{ $f->{'value_callback'} }; + $value = &$hack_strict_refs($svc_x); + + } elsif ( $type eq 'select-table' ) { + # imitates the /elements/select-table interface + $value = $svc_x->$field; + + my $value_col = $f->{'value_col'} || + dbdef->table($f->{'table'})->primary_key; + my $name_col = $f->{'name_col'} or die 'name_col required'; + # we don't yet support multiple-valued fields here + my $obj = qsearchs($f->{'table'}, { $value_col => $value }); + if ( $obj ) { + $value = $obj->$name_col; # can be any method of the object + } else { + # show the raw value, but mark it as an error + $value = '<SPAN CLASS="error">' . $f->{'table'} . ' ' . + encode_entities($value) . '</SPAN>'; + } + + } else { + $value = encode_entities($svc_x->$field); + } + + # inventory-select field with multiple classes + # show the class name to disambiguate + if ( $columndef->columnflag =~ /^[MA]$/ && $columndef->columnvalue =~ /,/ ) + { + my ($item) = grep { $_->svc_field eq $field } @inventory_items; + my $class = qsearchs('inventory_class', { classnum => $item->classnum }); + $value .= ' <i>('. $class->classname . ')</i>' if $class; + } + + # formatting tweaks + if ( $type eq 'date' and $value ) { + $value = time2str($date_format,$value) + } elsif ( $type eq 'datetime' and $value ) { + $value = time2str("$date_format %H:%M",$value) + } elsif ( $type eq 'checkbox' ) { + $value = $value eq 'Y' ? emt('Yes') : emt('No'); + } elsif ( $type eq 'mac_addr' and $value =~ /\w/) { + $value .= ' ('. (Net::MAC::Vendor::lookup($value))->[0]. ')' + } + + # 'link' option + my $href; + if ( ref($f) and exists $f->{'link'} ) { + my $link = $f->{'link'}; + if ( ref($link) eq 'CODE' ) { + $link = &{$link}($svc_x); + } + if ( ref($link) eq 'ARRAY' ) { + my ($base, $method) = @$link; + $href = $base . $svc_x->$method(); + } elsif ( !ref($link) ) { + $href = $link; + } + + if ( $href ) { + $value = qq!<A HREF="$href">$value</A>!; + } + } + + my $label = $opt{labels}->{$field} || $field; + return ($field, $label, $value); +}; + &{ $opt{'svc_callback'} }( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, \%opt ) if $opt{'svc_callback'}; </%init> diff --git a/httemplate/view/svc_circuit.html b/httemplate/view/svc_circuit.html new file mode 100644 index 000000000..c8d5d23ee --- /dev/null +++ b/httemplate/view/svc_circuit.html @@ -0,0 +1,80 @@ +<& elements/svc_Common.html, + 'table' => 'svc_circuit', + 'labels' => \%labels, + 'fields' => \@fields, + 'html_foot' => sub { $self->call_method('.foot', @_) }, +&> +<%method .foot> +% my $svc_circuit = shift; +% my $link = [ 'svc_phone.cgi?', 'svcnum' ]; +% if ( FS::svc_phone->count('circuit_svcnum = '.$svc_circuit->svcnum) ) { +<& /search/elements/search.html, + + 'title' => 'Provisioned phone services', + 'name_singular' => 'phone number', + 'query' => { 'table' => 'svc_phone', + 'hashref' => { 'circuit_svcnum' => $svc_circuit->svcnum }, + 'addl_from' => ' LEFT JOIN cust_svc USING (svcnum)'. + ' LEFT JOIN part_svc USING (svcpart)', + 'select' => 'svc_phone.*, part_svc.*', + }, + 'count_query' => 'SELECT COUNT(*) FROM svc_phone WHERE circuit_svcnum = '. + $svc_circuit->svcnum, + 'header' => [ '#', 'Service', 'Phone number', ], + 'fields' => [ 'svcnum', 'svc', 'phonenum' ], + 'links' => [ $link, $link, $link ], + 'align' => 'rlr', + + 'html_form' => '<SPAN CLASS="fsinnerbox-title">Phone services</SPAN>', + 'nohtmlheader' => 1, + 'disable_total' => 1, + 'disable_maxselect' => 1, + 'really_disable_download' => 1, +&> + <BR> +% } +</%method> +<%init> + +my @fields = ( + 'circuit_id', + { field => 'providernum', + type => 'select-table', + table => 'circuit_provider', + name_col => 'provider', + }, + { field => 'typenum', + type => 'select-table', + table => 'circuit_type', + name_col => 'typename', + }, + { field => 'termnum', + type => 'select-table', + table => 'circuit_termination', + name_col => 'termination', + }, + qw( vendor_qual_id vendor_order_id vendor_order_type vendor_order_status + desired_due_date due_date + endpoint_ip_addr + ), + { field => 'endpoint_mac_addr', type => 'mac_addr' }, +); + + +my %labels = ( + circuit_id => 'Circuit ID', + providernum => 'Provider', + typenum => 'Circuit type', + termnum => 'Termination', + vendor_qual_id => 'Qualification ID', + vendor_order_id => 'Order ID', + vendor_order_type => 'Order type', + vendor_order_status => 'Order status', + desired_due_date => 'Desired due date', + due_date => 'Due date', + endpoint_ip_addr => 'Endpoint IP address', + endpoint_mac_addr => 'MAC address', +); + +my $self = $m->request_comp; +</%init> diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi index 2a2ef243b..1c0fb39c5 100644 --- a/httemplate/view/svc_phone.cgi +++ b/httemplate/view/svc_phone.cgi @@ -1,7 +1,7 @@ <& elements/svc_Common.html, 'table' => 'svc_phone', 'fields' => \@fields, - 'labels' => \%labels, + 'labels' => \%labels, 'html_foot' => $html_foot, &> <%init> @@ -53,6 +53,11 @@ if ( $conf->exists('svc_phone-lnp') ) { ; } +$labels{circuit_label} = mt('Circuit'); +push @fields, { field => 'circuit_label', + link => [ $p.'view/svc_circuit.html?', 'circuit_svcnum' ] + }; + my $html_foot = sub { my $svc_phone = shift; |