[freeside-commits] freeside/FS/FS AccessRight.pm, 1.44.2.5, 1.44.2.6 cust_main.pm, 1.464.2.35, 1.464.2.36 Record.pm, 1.196.2.6, 1.196.2.7 cust_tag.pm, 1.1.2.2, 1.1.2.3
Ivan,,,
ivan at wavetail.420.am
Fri Jul 16 16:46:41 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv18128/FS/FS
Modified Files:
Tag: FREESIDE_1_9_BRANCH
AccessRight.pm cust_main.pm Record.pm cust_tag.pm
Log Message:
customer tags, RT#9192
Index: cust_tag.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_tag.pm,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -w -d -r1.1.2.2 -r1.1.2.3
--- cust_tag.pm 15 Jul 2010 21:47:03 -0000 1.1.2.2
+++ cust_tag.pm 16 Jul 2010 23:46:39 -0000 1.1.2.3
@@ -2,7 +2,9 @@
use strict;
use base qw( FS::Record );
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearchs );
+use FS::cust_main;
+use FS::part_tag;
=head1 NAME
@@ -112,6 +114,25 @@
$self->SUPER::check;
}
+=item cust_main
+
+=cut
+
+sub cust_main {
+ my $self = shift;
+ qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
+}
+
+=item part_tag
+
+=cut
+
+sub part_tag {
+ my $self = shift;
+ qsearchs( 'part_tag', { 'tagnum' => $self->tagnum } );
+}
+
+
=back
=head1 BUGS
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.44.2.5
retrieving revision 1.44.2.6
diff -u -w -d -r1.44.2.5 -r1.44.2.6
--- AccessRight.pm 12 Jul 2010 13:18:05 -0000 1.44.2.5
+++ AccessRight.pm 16 Jul 2010 23:46:36 -0000 1.44.2.6
@@ -94,6 +94,7 @@
'View customer',
#'View Customer | View tickets',
'Edit customer',
+ 'Edit customer tags',
'Edit referring customer',
'View customer history',
'Cancel customer',
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.464.2.35
retrieving revision 1.464.2.36
diff -u -w -d -r1.464.2.35 -r1.464.2.36
--- cust_main.pm 13 Jul 2010 11:09:55 -0000 1.464.2.35
+++ cust_main.pm 16 Jul 2010 23:46:38 -0000 1.464.2.36
@@ -53,6 +53,7 @@
use FS::part_pkg_taxrate;
use FS::agent;
use FS::cust_main_invoice;
+use FS::cust_tag;
use FS::cust_credit_bill;
use FS::cust_bill_pay;
use FS::prepay_credit;
@@ -471,6 +472,30 @@
$self->invoicing_list( $invoicing_list );
}
+ warn " setting customer tags\n"
+ if $DEBUG > 1;
+
+ foreach my $tagnum ( @{ $self->tagnum || [] } ) {
+ my $cust_tag = new FS::cust_tag { 'tagnum' => $tagnum,
+ 'custnum' => $self->custnum };
+ my $error = $cust_tag->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ if ( $invoicing_list ) {
+ $error = $self->check_invoicing_list( $invoicing_list );
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ #return "checking invoicing_list (transaction rolled back): $error";
+ return $error;
+ }
+ $self->invoicing_list( $invoicing_list );
+ }
+
+
warn " setting cust_main_exemption\n"
if $DEBUG > 1;
@@ -1315,24 +1340,14 @@
}
}
- foreach my $cust_main_invoice ( #(email invoice destinations, not invoices)
- qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } )
- ) {
- my $error = $cust_main_invoice->delete;
+ foreach my $table (qw( cust_main_invoice cust_main_exemption cust_tag )) {
+ foreach my $record ( qsearch( 'table', { 'custnum' => $self->custnum } ) ) {
+ my $error = $record->delete;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
}
}
-
- foreach my $cust_main_exemption (
- qsearch( 'cust_main_exemption', { 'custnum' => $self->custnum } )
- ) {
- my $error = $cust_main_exemption->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
}
my $error = $self->SUPER::delete;
@@ -1420,6 +1435,28 @@
$self->invoicing_list( $invoicing_list );
}
+ if ( $self->exists('tagnum') ) { #so we don't delete these on edit by accident
+
+ #this could be more efficient than deleting and re-inserting, if it matters
+ foreach my $cust_tag (qsearch('cust_tag', {'custnum'=>$self->custnum} )) {
+ my $error = $cust_tag->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+ foreach my $tagnum ( @{ $self->tagnum || [] } ) {
+ my $cust_tag = new FS::cust_tag { 'tagnum' => $tagnum,
+ 'custnum' => $self->custnum };
+ my $error = $cust_tag->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ }
+
my %options = @param;
my $tax_exemption = delete $options{'tax_exemption'};
@@ -2396,6 +2433,30 @@
$self->agent->agent;
}
+=item cust_tag
+
+Returns any tags associated with this customer, as FS::cust_tag objects,
+or an empty list if there are no tags.
+
+=cut
+
+sub cust_tag {
+ my $self = shift;
+ qsearch('cust_tag', { 'custnum' => $self->custnum } );
+}
+
+=item part_tag
+
+Returns any tags associated with this customer, as FS::part_tag objects,
+or an empty list if there are no tags.
+
+=cut
+
+sub part_tag {
+ my $self = shift;
+ map $_->part_tag, $self->cust_tag;
+}
+
=item bill_and_collect
Cancels and suspends any packages due, generates bills, applies payments and
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.196.2.6
retrieving revision 1.196.2.7
diff -u -w -d -r1.196.2.6 -r1.196.2.7
--- Record.pm 20 Feb 2010 22:33:10 -0000 1.196.2.6
+++ Record.pm 16 Jul 2010 23:46:38 -0000 1.196.2.7
@@ -795,6 +795,17 @@
$self->set(@_);
}
+=item exists COLUMN
+
+Returns true if the column/field/key COLUMN exists.
+
+=cut
+
+sub exists {
+ my($self,$field) = @_;
+ exists($self->{Hash}->{$field});
+}
+
=item AUTLOADED METHODS
$record->column is a synonym for $record->get('column');
More information about the freeside-commits
mailing list