[freeside-commits] freeside/FS/FS Conf.pm, 1.405, 1.406 Schema.pm, 1.254, 1.255 cust_location.pm, 1.8, 1.9
Mark Wells
mark at wavetail.420.am
Mon Dec 13 23:29:14 PST 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv29584/FS/FS
Modified Files:
Conf.pm Schema.pm cust_location.pm
Log Message:
cust_location editing features, RT#10766
Index: cust_location.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_location.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -d -r1.8 -r1.9
--- cust_location.pm 11 Oct 2010 19:00:32 -0000 1.8
+++ cust_location.pm 14 Dec 2010 07:29:12 -0000 1.9
@@ -3,6 +3,7 @@
use strict;
use base qw( FS::geocode_Mixin FS::Record );
use Locale::Country;
+use FS::UID qw( dbh );
use FS::Record qw( qsearch ); #qsearchs );
use FS::prospect_main;
use FS::cust_main;
@@ -74,6 +75,10 @@
Geocode
+=item disabled
+
+Disabled flag; set to 'Y' to disable the location.
+
=back
=head1 METHODS
@@ -192,6 +197,70 @@
=cut
+=item move_to HASHREF
+
+Takes a hashref with one or more cust_location fields. Creates a duplicate
+of the existing location with all fields set to the values in the hashref.
+Moves all packages that use the existing location to the new one, then sets
+the "disabled" flag on the old location. Returns nothing on success, an
+error message on error.
+
+=cut
+
+sub move_to {
+ my $old = shift;
+ my $hashref = shift;
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+ my $error = '';
+
+ my $new = FS::cust_location->new({
+ $old->location_hash,
+ 'custnum' => $old->custnum,
+ 'prospectnum' => $old->prospectnum,
+ %$hashref
+ });
+ $error = $new->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Error creating location: $error";
+ }
+
+ my @pkgs = qsearch('cust_pkg', {
+ 'locationnum' => $old->locationnum,
+ 'cancel' => ''
+ });
+ foreach my $cust_pkg (@pkgs) {
+ $error = $cust_pkg->change(
+ 'locationnum' => $new->locationnum,
+ 'keep_dates' => 1
+ );
+ if ( $error and not ref($error) ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Error moving pkgnum ".$cust_pkg->pkgnum.": $error";
+ }
+ }
+
+ $old->disabled('Y');
+ $error = $old->replace;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Error disabling old location: $error";
+ }
+
+ $dbh->commit if $oldAutoCommit;
+ return;
+}
+
=back
=head1 BUGS
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -w -d -r1.254 -r1.255
--- Schema.pm 10 Dec 2010 22:08:34 -0000 1.254
+++ Schema.pm 14 Dec 2010 07:29:12 -0000 1.255
@@ -909,6 +909,7 @@
'location_type', 'varchar', 'NULL', 20, '', '',
'location_number', 'varchar', 'NULL', 20, '', '',
'location_kind', 'char', 'NULL', 1, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'locationnum',
'unique' => [],
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.405
retrieving revision 1.406
diff -u -w -d -r1.405 -r1.406
--- Conf.pm 10 Dec 2010 22:08:35 -0000 1.405
+++ Conf.pm 14 Dec 2010 07:29:12 -0000 1.406
@@ -2689,6 +2689,13 @@
},
{
+ 'key' => 'cust_pkg-group_by_location',
+ 'section' => 'UI',
+ 'description' => "Group packages by location.",
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'cust_pkg-show_fcc_voice_grade_equivalent',
'section' => 'UI',
'description' => "Show a field on package definitions for assigning a DSO equivalency number suitable for use on FCC form 477.",
More information about the freeside-commits
mailing list