[freeside-commits] branch FREESIDE_2_3_BRANCH updated. acd68a24195f6e2bd65d58833047256fafba6e13
Ivan
ivan at 420.am
Tue May 8 20:35:00 PDT 2012
The branch, FREESIDE_2_3_BRANCH has been updated
via acd68a24195f6e2bd65d58833047256fafba6e13 (commit)
from faadb1bcccbbdfee91afffded23dfebb89ebafe0 (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 acd68a24195f6e2bd65d58833047256fafba6e13
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue May 8 20:34:56 2012 -0700
fix service definition modifiers (inventory, hardware) w/svc_broadband, RT#17659
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index fded48e..8ed00ad 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -3136,11 +3136,12 @@ sub tables_hashref {
'inventory_item' => {
'columns' => [
- 'itemnum', 'serial', '', '', '', '',
- 'classnum', 'int', '', '', '', '',
- 'agentnum', 'int', 'NULL', '', '', '',
- 'item', 'varchar', '', $char_d, '', '',
- 'svcnum', 'int', 'NULL', '', '', '',
+ 'itemnum', 'serial', '', '', '', '',
+ 'classnum', 'int', '', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+ 'item', 'varchar', '', $char_d, '', '',
+ 'svcnum', 'int', 'NULL', '', '', '',
+ 'svc_field', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'itemnum',
'unique' => [ [ 'classnum', 'item' ] ],
diff --git a/FS/FS/inventory_item.pm b/FS/FS/inventory_item.pm
index 39a0dff..477c934 100644
--- a/FS/FS/inventory_item.pm
+++ b/FS/FS/inventory_item.pm
@@ -111,6 +111,7 @@ sub check {
'Edit global inventory'] )
|| $self->ut_text('item')
|| $self->ut_foreign_keyn('svcnum', 'cust_svc', 'svcnum' )
+ || $self->ut_alphan('svc_field')
;
return $error if $error;
diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm
index ff00ce0..19f5819 100644
--- a/FS/FS/svc_Common.pm
+++ b/FS/FS/svc_Common.pm
@@ -5,6 +5,7 @@ use vars qw( @ISA $noexport_hack $DEBUG $me
$overlimit_missing_cust_svc_nonfatal_kludge );
use Carp qw( cluck carp croak confess ); #specify cluck have to specify them all
use Scalar::Util qw( blessed );
+use Lingua::EN::Inflect qw( PL_N );
use FS::Conf;
use FS::Record qw( qsearch qsearchs fields dbh );
use FS::cust_main_Mixin;
@@ -844,8 +845,7 @@ sub set_auto_inventory {
qsearchs('inventory_class', { 'classnum' => $classnum } );
return "Can't find inventory_class.classnum $classnum"
unless $inventory_class;
- return "Out of ". $inventory_class->classname. "s\n"; #Lingua:: BS
- #for pluralizing
+ return "Out of ". PL_N($inventory_class->classname);
}
next if $columnflag eq 'M' && $inventory_item->svcnum == $self->svcnum;
@@ -853,31 +853,38 @@ sub set_auto_inventory {
$self->setfield( $field, $inventory_item->item );
#if $columnflag eq 'A' && $self->$field() eq '';
- $inventory_item->svcnum( $self->svcnum );
- my $ierror = $inventory_item->replace();
- if ( $ierror ) {
- $dbh->rollback if $oldAutoCommit;
- return "Error provisioning inventory: $ierror";
- }
-
if ( $old && $old->$field() && $old->$field() ne $self->$field() ) {
my $old_inv = qsearchs({
- 'table' => 'inventory_item',
- 'hashref' => { 'classnum' => $classnum,
- 'svcnum' => $old->svcnum,
- 'item' => $old->$field(),
- },
+ 'table' => 'inventory_item',
+ 'hashref' => { 'classnum' => $classnum,
+ 'svcnum' => $old->svcnum,
+ },
+ 'extra_sql' => ' AND '.
+ '( ( svc_field IS NOT NULL AND svc_field = '.$dbh->quote($field).' )'.
+ ' OR ( svc_field IS NULL AND item = '. dbh->quote($old->$field).' )'.
+ ')',
});
if ( $old_inv ) {
$old_inv->svcnum('');
+ $old_inv->svc_field('');
my $oerror = $old_inv->replace;
if ( $oerror ) {
$dbh->rollback if $oldAutoCommit;
return "Error unprovisioning inventory: $oerror";
}
+ } else {
+ warn "old inventory_item not found for $field ". $self->$field;
}
}
+ $inventory_item->svcnum( $self->svcnum );
+ $inventory_item->svc_field( $field );
+ my $ierror = $inventory_item->replace();
+ if ( $ierror ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Error provisioning inventory: $ierror";
+ }
+
}
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
@@ -906,6 +913,7 @@ sub return_inventory {
foreach my $inventory_item ( $self->inventory_item ) {
$inventory_item->svcnum('');
+ $inventory_item->svc_field('');
my $error = $inventory_item->replace();
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 4e896f2..b97f63d 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -293,7 +293,7 @@ Example:
% $include_common{$_} = $f->{$_} foreach grep exists($f->{$_}),
% qw( js_only html_only select_only layers_only cell_style ),#selectlayers,?
% qw( empty_label ), # select-*
-% qw( value_col ), # select-table
+% qw( value_col compare_sub ), # select-table
% qw( table name_col ), #(select,checkboxes)-table
% qw( target_table link_table ), #checkboxes-table
% qw( hashref agent_virt agent_null agent_null_right ),#*-table
diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html
index 38716f0..0d9d36c 100644
--- a/httemplate/edit/elements/svc_Common.html
+++ b/httemplate/edit/elements/svc_Common.html
@@ -103,7 +103,15 @@
$f->{'extra_sql'} .= ' OR svcnum = '. $object->svcnum
if $object->svcnum;
$f->{'extra_sql'} .= ' ) ';
- $f->{'disable_empty'} = $object->svcnum ? 1 : 0,
+ $f->{'disable_empty'} = $object->svcnum ? 1 : 0;
+ if ( $f->{'field'} eq 'mac_addr' ) {
+ $f->{'compare_sub'} = sub {
+ my($a, $b) = @_;
+ $a =~ s/[-: ]//g;
+ $b =~ s/[-: ]//g;
+ lc($a) eq lc($b);
+ };
+ }
} elsif ( $flag eq 'H' ) {
$f->{'type'} = 'select-hardware_type';
$f->{'hashref'} = {
@@ -127,6 +135,10 @@
$object->set('custnum', $cust_pkg->custnum);
}
+ if ( my $cb = $opt{'svc_field_callback'} ) {
+ &{ $cb }( $cgi, $object, $f);
+ }
+
},
'html_init' => sub {
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 071c43a..e33af9d 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -238,8 +238,6 @@ foreach my $value ( @values ) {
}
- $error ||= $new->check;
-
my @args = ();
if ( !$error && $opt{'args_callback'} ) {
@args = &{ $opt{'args_callback'} }( $cgi, $new );
diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi
index b266928..0d4b989 100644
--- a/httemplate/edit/svc_broadband.cgi
+++ b/httemplate/edit/svc_broadband.cgi
@@ -3,7 +3,7 @@
'name' => 'broadband service',
'table' => 'svc_broadband',
'fields' => \@fields,
- 'field_callback' => $field_callback,
+ 'svc_field_callback' => $svc_field_callback,
'svc_new_callback' => $svc_edit_callback,
'svc_edit_callback' => $svc_edit_callback,
'svc_error_callback' => $svc_edit_callback,
@@ -161,20 +161,14 @@ my $svc_edit_callback = sub {
}
};
-my $field_callback = sub {
+my $svc_field_callback = sub {
my ($cgi, $object, $fieldref) = @_;
my $columndef = $part_svc->part_svc_column($fieldref->{'field'});
- if ($columndef->columnflag eq 'F') {
- $fieldref->{'type'} = length($columndef->columnvalue)
- ? 'fixed'
- : 'hidden';
- $fieldref->{'value'} = $columndef->columnvalue;
+ if ($fieldref->{field} eq 'usergroup' && $columndef->columnflag eq 'F') {
- if ( $fieldref->{field} eq 'usergroup' ) {
- $fieldref->{'formatted_value'} =
- [ $object->radius_groups('long_description') ];
- }
+ $fieldref->{'formatted_value'} =
+ [ $object->radius_groups('long_description') ];
}
};
diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html
index c0dde74..127028e 100644
--- a/httemplate/elements/select-table.html
+++ b/httemplate/elements/select-table.html
@@ -93,10 +93,17 @@ Example:
% )
% {
% my $recvalue = $record->$key();
+% my $selected;
+% if ( $opt{'all_selected'} ) {
+% $selected = 1;
+% } elsif ( $opt{'compare_sub'} && !ref($value) ) {
+% $selected = &{ $opt{'compare_sub'} }( $value, $recvalue );
+% } else {
+% $selected = ( ref($value) && $value->{$recvalue} )
+% || ( $value && $value eq $recvalue ); #not == because of value_col
+% }
<OPTION VALUE="<% $recvalue %>"
- <% $opt{'all_selected'} || ref($value) && $value->{$recvalue} || $value && $value eq $recvalue # not == because of value_col
- ? ' SELECTED' : ''
- %>
+ <% $selected ? ' SELECTED' : '' %>
% foreach my $att ( @{ $opt{'extra_option_attributes'} } ) {
data-<% $att %>="<% $record->$att() |h %>"
% }
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Schema.pm | 11 ++++---
FS/FS/inventory_item.pm | 1 +
FS/FS/svc_Common.pm | 36 +++++++++++++++---------
httemplate/edit/elements/edit.html | 2 +-
httemplate/edit/elements/svc_Common.html | 14 +++++++++-
httemplate/edit/process/elements/process.html | 2 -
httemplate/edit/svc_broadband.cgi | 16 +++-------
httemplate/elements/select-table.html | 13 +++++++--
8 files changed, 58 insertions(+), 37 deletions(-)
More information about the freeside-commits
mailing list