[freeside-commits] branch FREESIDE_3_BRANCH updated. c472510ffbe145ae090981bc1b0be9b644de6a37
Ivan
ivan at 420.am
Tue Oct 8 22:55:13 PDT 2013
The branch, FREESIDE_3_BRANCH has been updated
via c472510ffbe145ae090981bc1b0be9b644de6a37 (commit)
from 6c74a126fc01b982bf43403087803512b52f0a2a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c472510ffbe145ae090981bc1b0be9b644de6a37
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue Oct 8 22:55:04 2013 -0700
add provider dropdown to svc_cable, RT#22009
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 7412232..33c2a10 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -4163,6 +4163,8 @@ sub tables_hashref {
'svc_cable' => {
'columns' => [
'svcnum', 'int', '', '', '', '',
+ 'providernum', 'int', 'NULL', '', '', '',
+ # XXX "Circuit ID/Order number"
'modelnum', 'int', 'NULL', '', '', '',
'serialnum', 'varchar', 'NULL', $char_d, '', '',
'mac_addr', 'varchar', 'NULL', 12, '', '',
@@ -4183,6 +4185,17 @@ sub tables_hashref {
'index' => [],
},
+ 'cable_provider' => {
+ 'columns' => [
+ 'providernum', 'serial', '', '', '', '',
+ 'provider', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'providernum',
+ 'unique' => [ [ 'provider' ], ],
+ 'index' => [],
+ },
+
%{ tables_hashref_torrus() },
# tables of ours for doing torrus virtual port combining
diff --git a/FS/FS/cable_provider.pm b/FS/FS/cable_provider.pm
new file mode 100644
index 0000000..e988192
--- /dev/null
+++ b/FS/FS/cable_provider.pm
@@ -0,0 +1,112 @@
+package FS::cable_provider;
+
+use strict;
+use base qw( FS::Record );
+use FS::Record qw( qsearch qsearchs );
+
+=head1 NAME
+
+FS::cable_provider - Object methods for cable_provider records
+
+=head1 SYNOPSIS
+
+ use FS::cable_provider;
+
+ $record = new FS::cable_provider \%hash;
+ $record = new FS::cable_provider { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::cable_provider object represents a cable service provider.
+FS::cable_provider inherits from FS::Record. The following fields are
+currently supported:
+
+=over 4
+
+=item providernum
+
+primary key
+
+=item provider
+
+provider
+
+=item disabled
+
+disabled
+
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new provider. To add the provider to the database, see L<"insert">.
+
+Note that this stores the hash reference, not a distinct copy of the hash it
+points to. You can ask the object for a copy with the I<hash> method.
+
+=cut
+
+# the new method can be inherited from FS::Record, if a table method is defined
+
+sub table { 'cable_provider'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=item delete
+
+Delete this record from the database.
+
+=item replace OLD_RECORD
+
+Replaces the OLD_RECORD with this one in the database. If there is an error,
+returns the error, otherwise returns false.
+
+=item check
+
+Checks all fields to make sure this is a valid provider. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+sub check {
+ my $self = shift;
+
+ my $error =
+ $self->ut_numbern('providernum')
+ || $self->ut_text('provider')
+ || $self->ut_enum('disabled', [ '', 'Y' ] )
+ ;
+ return $error if $error;
+
+ $self->SUPER::check;
+}
+
+=back
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::Record>, schema.html from the base documentation.
+
+=cut
+
+1;
+
diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm
index 1980c0e..596f699 100644
--- a/FS/FS/svc_cable.pm
+++ b/FS/FS/svc_cable.pm
@@ -4,6 +4,7 @@ use base qw( FS::svc_Common ); #qw( FS::device_Common FS::svc_Common );
use strict;
use Tie::IxHash;
use FS::Record qw( qsearchs ); # qw( qsearch qsearchs );
+use FS::cable_provider;
use FS::cable_model;
=head1 NAME
@@ -72,24 +73,35 @@ sub search_sql {
sub table_info {
tie my %fields, 'Tie::IxHash',
- 'svcnum' => 'Service',
- 'modelnum' => { label => 'Model',
- type => 'select-cable_model',
- disable_inventory => 1,
- disable_select => 1,
- value_callback => sub {
- my $svc = shift;
- $svc->cable_model->model_name;
- },
- },
- 'serialnum' => 'Serial number',
- 'mac_addr' => { label => 'MAC address',
- type => 'input-mac_addr',
- value_callback => sub {
- my $svc = shift;
- join(':', $svc->mac_addr =~ /../g);
- },
- },
+ 'svcnum' => 'Service',
+ 'providernum' => { label => 'Provider',
+ type => 'select-cable_provider',
+ disable_inventory => 1,
+ disable_select => 1,
+ value_callback => sub {
+ my $svc = shift;
+ my $p = $svc->cable_provider;
+ $p ? $p->provider : '';
+ },
+ },
+ #XXX "Circuit ID/Order number"
+ 'modelnum' => { label => 'Model',
+ type => 'select-cable_model',
+ disable_inventory => 1,
+ disable_select => 1,
+ value_callback => sub {
+ my $svc = shift;
+ $svc->cable_model->model_name;
+ },
+ },
+ 'serialnum' => 'Serial number',
+ 'mac_addr' => { label => 'MAC address',
+ type => 'input-mac_addr',
+ value_callback => sub {
+ my $svc = shift;
+ join(':', $svc->mac_addr =~ /../g);
+ },
+ },
;
{
@@ -130,6 +142,7 @@ sub check {
my $error =
$self->ut_numbern('svcnum')
+ || $self->ut_foreign_key('providernum', 'cable_provider', 'providernum')
|| $self->ut_foreign_key('modelnum', 'cable_model', 'modelnum')
|| $self->ut_alpha('serialnum')
|| $self->ut_mac_addr('mac_addr')
@@ -139,6 +152,17 @@ sub check {
$self->SUPER::check;
}
+=item cable_provider
+
+Returns the cable_provider object for this record.
+
+=cut
+
+sub cable_provider {
+ my $self = shift;
+ qsearchs('cable_provider', { 'providernum'=>$self->providernum } );
+}
+
=item cable_model
Returns the cable_model object for this record.
diff --git a/FS/t/cable_provider.t b/FS/t/cable_provider.t
new file mode 100644
index 0000000..c794379
--- /dev/null
+++ b/FS/t/cable_provider.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::cable_provider;
+$loaded=1;
+print "ok 1\n";
diff --git a/httemplate/browse/cable_provider.html b/httemplate/browse/cable_provider.html
new file mode 100644
index 0000000..0d34498
--- /dev/null
+++ b/httemplate/browse/cable_provider.html
@@ -0,0 +1,32 @@
+<& elements/browse.html,
+ 'title' => 'Cable providers',
+ 'html_init' => $html_init,
+ 'name' => 'providers',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 1,
+ 'query' => { 'table' => 'cable_provider',
+ 'hashref' => {},
+ 'order_by' => 'ORDER BY provider',
+ },
+ 'count_query' => $count_query,
+ 'header' => $header,
+ 'fields' => $fields,
+ 'links' => $links,
+&>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $html_init =
+ qq!<A HREF="${p}edit/cable_provider.html"><I>Add a provider</I></A><BR><BR>!;
+
+my $count_query = 'SELECT COUNT(*) FROM cable_provider';
+
+my $link = [ $p.'edit/cable_provider.html?', 'providernum' ];
+
+my $header = [ 'Provider' ];
+my $fields = [ 'provider' ];
+my $links = [ $link ];
+
+</%init>
diff --git a/httemplate/edit/cable_provider.html b/httemplate/edit/cable_provider.html
new file mode 100644
index 0000000..9a911cc
--- /dev/null
+++ b/httemplate/edit/cable_provider.html
@@ -0,0 +1,20 @@
+<& elements/edit.html,
+ 'name_singular' => 'Provider',
+ 'table' => 'cable_provider',
+ 'fields' => [
+ 'provider',
+ { field=>'disabled', type=>'checkbox', value=>'Y', },
+ ],
+ 'labels' => {
+ 'providernum' => 'Provider',
+ 'provider' => 'Provider',
+ 'disabled' => 'Disabled',
+ },
+ 'viewall_dir' => 'browse',
+&>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>
diff --git a/httemplate/edit/process/cable_provider.html b/httemplate/edit/process/cable_provider.html
new file mode 100644
index 0000000..ecffaf6
--- /dev/null
+++ b/httemplate/edit/process/cable_provider.html
@@ -0,0 +1,10 @@
+<& elements/process.html,
+ 'table' => 'cable_provider',
+ 'viewall_dir' => 'browse',
+&>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 25c0ef2..70821e9 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -514,6 +514,7 @@ tie my %config_radius, 'Tie::IxHash',
;
tie my %config_cable, 'Tie::IxHash',
+ 'Cable providers' => [ $fsurl.'browse/cable_provider.html', '' ],
'Cable modem models' => [ $fsurl.'browse/cable_model.html', '' ],
;
diff --git a/httemplate/elements/select-cable_provider.html b/httemplate/elements/select-cable_provider.html
new file mode 100644
index 0000000..9530b78
--- /dev/null
+++ b/httemplate/elements/select-cable_provider.html
@@ -0,0 +1,7 @@
+<% include( '/elements/select-table.html',
+ 'table' => 'cable_provider',
+ 'name_col' => 'provider',
+ 'empty_label' => 'Select provider',
+ @_,
+ )
+%>
diff --git a/httemplate/elements/tr-select-cable_provider.html b/httemplate/elements/tr-select-cable_provider.html
new file mode 100644
index 0000000..abb8564
--- /dev/null
+++ b/httemplate/elements/tr-select-cable_provider.html
@@ -0,0 +1,12 @@
+% #if ( scalar(@domains) < 2 ) {
+% #} else {
+ <TR>
+ <TD ALIGN="right"><% $opt{'label'} || 'Provider' %></TD>
+ <TD>
+ <% include( '/elements/select-cable_provider.html', %opt) %>
+ </TD>
+ </TR>
+% #}
+<%init>
+ my %opt = @_;
+</%init>
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Schema.pm | 13 ++++
FS/FS/{cable_model.pm => cable_provider.pm} | 35 ++++++-----
FS/FS/svc_cable.pm | 60 ++++++++++++++------
FS/t/{AccessRight.t => cable_provider.t} | 2 +-
.../{cable_model.html => cable_provider.html} | 19 +++---
.../edit/{cable_model.html => cable_provider.html} | 12 ++--
.../{cable_model.html => cable_provider.html} | 2 +-
httemplate/elements/menu.html | 1 +
httemplate/elements/select-cable_provider.html | 7 ++
httemplate/elements/tr-select-cable_provider.html | 12 ++++
10 files changed, 111 insertions(+), 52 deletions(-)
copy FS/FS/{cable_model.pm => cable_provider.pm} (59%)
copy FS/t/{AccessRight.t => cable_provider.t} (80%)
copy httemplate/browse/{cable_model.html => cable_provider.html} (51%)
copy httemplate/edit/{cable_model.html => cable_provider.html} (55%)
copy httemplate/edit/process/{cable_model.html => cable_provider.html} (81%)
create mode 100644 httemplate/elements/select-cable_provider.html
create mode 100644 httemplate/elements/tr-select-cable_provider.html
More information about the freeside-commits
mailing list