summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/merge-user71
-rwxr-xr-xbin/rt-update-customfield-dates73
2 files changed, 0 insertions, 144 deletions
diff --git a/bin/merge-user b/bin/merge-user
deleted file mode 100755
index e7833595e..000000000
--- a/bin/merge-user
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use FS::UID qw(adminsuidsetup dbh);
-use FS::Schema;
-use FS::Record qw(qsearch qsearchs);
-
-my $DRY_RUN = 1;
-$FS::UID::AutoCommit = 0;
-
-my ($user, $from_usernum, $to_usernum, $go) = @ARGV;
-die usage() if not ($user and $from_usernum and $to_usernum);
-$DRY_RUN = 0 if defined($go) and $go eq 'go';
-
-my $dbh = adminsuidsetup($user);
-
-# Sanity checks.
-die "Can't merge a user to itself." if $from_usernum == $to_usernum;
-my $from_user = FS::access_user->by_key($from_usernum) or
- die "Usernum '$from_usernum' not found.\n";
-my $to_user = FS::access_user->by_key($to_usernum) or
- die "Usernum '$to_usernum' not found.\n";
-
-my $tables = FS::Schema::tables_hashref;
-foreach my $table (keys %$tables) {
- if( grep /^usernum$/, FS::Record::real_fields($table) ) {
- next if $table eq 'access_user';
- foreach ($table, "h_$table") {
- print "$_: ";
- my $sql;
- if( $table =~ /^access_(.*)$/ ) {
- print "deleting ";
- $sql = "DELETE FROM $_ WHERE usernum = $from_usernum";
- }
- else {
- print "updating ";
- $sql = "UPDATE $_ SET usernum = $to_usernum WHERE usernum = $from_usernum";
- }
- #print $sql;
- my $sth = $dbh->prepare($sql);
- $sth->execute;
- if($dbh->err) {
- print $dbh->errstr."\n";
- $dbh->rollback;
- exit(1);
- }
- print $sth->rows, "\n";
- }
- }
-}
-
-if($DRY_RUN) {
- warn "Dry run complete. Reverting all changes.\n";
- $dbh->rollback;
-}
-else {
-# Warning: access_user->delete does not transactionize because of
-# htpasswd issues.
- print "Deleting merged user.\n";
- my $error = $from_user->delete;
- die $error if $error;
-
- warn "Committing changes.\n";
- $dbh->commit;
-}
-exit(0);
-
-sub usage {
- "Usage:\n merge-user admin_user from_usernum to_usernum [ 'go' ]\n
- (Specify 'go' to actually apply changes.)\n\n";
-}
diff --git a/bin/rt-update-customfield-dates b/bin/rt-update-customfield-dates
deleted file mode 100755
index 73fbd09a4..000000000
--- a/bin/rt-update-customfield-dates
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use Date::Parse;
-use Date::Format;
-use FS::UID qw(adminsuidsetup);
-use FS::Record;
-
-my @date_fields = (
- 'Circuit Ordered Date',
- 'Circuit Due Date (s)',
- 'Install Date',
- 'Site Audit Date',
- 'LOCAL PORT COMPLETE',
- 'TF PORTING COMPLETE',
- '411 Submission',
- 'Billed in Freeside',
- 'Billed in Quickbooks',
-);
-#@date_fields = ( 'Custom thingie' );
-
-my $dbh = adminsuidsetup(shift) or die "Usage: rt-update-customfield-dates username\n";
-
-foreach my $date_field ( @date_fields ) {
-
- my $cf_sql = 'SELECT id FROM CustomFields where name = '. $dbh->quote($date_field);
- my $cf_sth = $dbh->prepare($cf_sql) or die $dbh->errstr;
- $cf_sth->execute or die $cf_sth->errstr;
- my $result = $cf_sth->fetchrow_arrayref
- or do { warn "$date_field not found; skipping\n"; next };
- my $customfield_id = $result->[0];
-
- my $ocfv_sql = "SELECT id, content FROM ObjectCustomFieldValues WHERE customfield = $customfield_id and content !~ '^[0-9]+\$' ";
- my $ocfv_sth = $dbh->prepare($ocfv_sql) or die $dbh->errstr;
- $ocfv_sth->execute or die $ocfv_sth->errstr;
-
- while (my $row = $ocfv_sth->fetchrow_arrayref) {
-
- my($id, $content) = @$row;
-
- my $origcontent = $content;
-
- #April 21 KW / April 21 Mont
- $content =~ s/^April (\d\d) [a-zA-Z]+$/April $1/;
-
- #SAL April 29 / other May 3
- $content =~ s/^[a-zA-Z]+ (April|May) (\d\d?)$/$1 $2/;
-
- #things like "July 8/2010 and "JUNE 24/10" are not doing what we want
- $content =~ s/^(June|July) (\d\d?)\/(20)?10$/$1 $2, 2010/i;
-
- #28/04/2010
- $content =~ s{^(2\d|1[3-9])/(0\d)/2010$}{$2/$1/2010};
-
- my $unixdate = str2time($content); #current timezone is what we want here
-
- #things like "DONE"/"ORDERED" are returning a 0 here.. should stay blank
- my $prettynew = $unixdate ? time2str('%Y-%m-%d %T', $unixdate, 'GMT') : '';
-
- print "$id: $origcontent -> $prettynew \n" unless $content =~ qr(^0\d/\d\d/2010$);
-
- my $update_sql =
- "UPDATE ObjectCustomFieldValues SET content = '$prettynew'".
- " WHERE id = $id";
-
- my $update_sth = $dbh->prepare($update_sql) or die $dbh->errstr;
- $update_sth->execute or die $update_sth->errstr;
- $dbh->commit or die $dbh->errstr;
-
- }
-
-}