[freeside-commits] freeside/FS/FS svc_Common.pm,1.55,1.56
Ivan,,,
ivan at wavetail.420.am
Mon Mar 1 11:38:31 PST 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv21471
Modified Files:
svc_Common.pm
Log Message:
enable manual selection from inventory dropdowns for svc_broadband, svc_external & svc_phone, RT#7010
Index: svc_Common.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_Common.pm,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -w -d -r1.55 -r1.56
--- svc_Common.pm 17 Feb 2010 08:30:06 -0000 1.55
+++ svc_Common.pm 1 Mar 2010 19:38:29 -0000 1.56
@@ -685,7 +685,9 @@
=item set_auto_inventory
-Sets any fields which auto-populate from inventory (see L<FS::part_svc>).
+Sets any fields which auto-populate from inventory (see L<FS::part_svc>), and
+also check any manually populated inventory fields.
+
If there is an error, returns the error, otherwise returns false.
=cut
@@ -715,15 +717,26 @@
#set default/fixed/whatever fields from part_svc
my $table = $self->table;
foreach my $field ( grep { $_ ne 'svcnum' } $self->fields ) {
+
my $part_svc_column = $part_svc->part_svc_column($field);
- if ( $part_svc_column->columnflag eq 'A' && $self->$field() eq '' ) {
+ my $columnflag = $part_svc_column->columnflag;
+ next unless $columnflag =~ /^[AM]$/;
+
+ next if $columnflag eq 'A' && $self->$field() ne '';
my $classnum = $part_svc_column->columnvalue;
+ my %hash = ( 'classnum' => $classnum );
+
+ if ( $columnflag eq 'A' && $self->$field() eq '' ) {
+ $hash{'svcnum'} = '';
+ } elsif ( $columnflag eq 'M' ) {
+ return "Select inventory item for $field" unless $self->getfield($field);
+ $hash{'item'} = $self->getfield($field);
+ }
+
my $inventory_item = qsearchs({
'table' => 'inventory_item',
- 'hashref' => { 'classnum' => $classnum,
- 'svcnum' => '',
- },
+ 'hashref' => \%hash,
'extra_sql' => 'LIMIT 1 FOR UPDATE',
});
@@ -737,17 +750,18 @@
#for pluralizing
}
+ next if $columnflag eq 'M' && $inventory_item->svcnum == $self->svcnum;
+
+ $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";
-
}
- $self->setfield( $field, $inventory_item->item );
-
- }
}
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
More information about the freeside-commits
mailing list