freeside/rt/lib/RT/URI freeside.pm,1.1,1.2
ivan
ivan at pouncequick.420.am
Thu Dec 2 01:59:53 PST 2004
Update of /home/cvs/cvsroot/freeside/rt/lib/RT/URI
In directory pouncequick:/tmp/cvs-serv24319/rt/lib/RT/URI
Modified Files:
freeside.pm
Log Message:
second big RT integration checkin, customer linking/delinking interface
Index: freeside.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/URI/freeside.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- freeside.pm 14 Apr 2004 00:48:04 -0000 1.1
+++ freeside.pm 2 Dec 2004 09:59:48 -0000 1.2
@@ -82,10 +82,11 @@
$label = "Freeside service ${svc}: ${tag}";
}
} elsif ($table eq 'cust_main') {
- my ($last, $first, $company) = map { $rec->getfield($_) }
- qw(last first company);
- $label = "Freeside customer ${last}, ${first}";
- $label .= ($company ne '') ? " with ${company}" : '';
+ #my ($last, $first, $company) = map { $rec->getfield($_) }
+ # qw(last first company);
+ #$label = "Freeside customer ${last}, ${first}";
+ #$label .= ($company ne '') ? " with ${company}" : '';
+ $label = "$pkey: ". $rec->name;
} else {
$label = "Freeside ${table}, ${pkeyfield} == ${pkey}";
}
@@ -103,6 +104,61 @@
}
+sub FreesideURILabelLong {
+
+ my $self = shift;
+
+ return(undef) unless (exists($self->{'fstable'}) and
+ exists($self->{'fspkey'}));
+
+ my $label;
+ my ($table, $pkey) = ($self->{'fstable'}, $self->{'fspkey'});
+
+ eval {
+ use FS::UID qw(dbh);
+ use FS::Record qw(qsearchs qsearch dbdef);
+ eval "use FS::$table;";
+ use FS::cust_svc;
+
+ my $dbdef = dbdef or die "No dbdef";
+ my $pkeyfield = $dbdef->table($table)->primary_key
+ or die "No primary key for table $table";
+
+ my $rec = qsearchs($table, { $pkeyfield => $pkey })
+ or die "Record with $pkeyfield == $pkey does not exist in table $table";
+
+ if ($table =~ /^svc_/) {
+ #if ($rec->can('cust_svc')) {
+ # my $cust_svc = $rec->cust_svc or die '$rec->cust_svc failed';
+ # my ($svc, $tag, $svcdb) = $cust_svc->label;
+ # $label = "Freeside service ${svc}: ${tag}";
+ #}
+ $label = '';
+ } elsif ($table eq 'cust_main') {
+ use FS::CGI qw(small_custview);
+ $label = small_custview( $rec,
+ scalar(FS::Conf->new->config('countrydefault')),
+ 1 #nobalance
+ );
+ } else {
+ #$label = "Freeside ${table}, ${pkeyfield} == ${pkey}";
+ $label = '';
+ }
+
+ #... other cases
+
+ };
+
+ if ($label and !$@) {
+ return($label);
+ } else {
+ warn $@;
+ return(undef);
+ }
+
+
+}
+
sub ParseURI {
my $self = shift;
my $uri = shift;
@@ -174,6 +230,22 @@
my $self = shift;
my $prettystring;
if ($prettystring = $self->FreesideURILabel) {
+ return $prettystring;
+ } else {
+ return $self->URI;
+ }
+}
+
+=head2 AsStringLong
+
+Return a longer (HTML) string representing the URI object.
+
+=cut
+
+sub AsStringLong {
+ my $self = shift;
+ my $prettystring;
+ if ($prettystring = $self->FreesideURILabelLong || $self->FreesideURILabel){
return $prettystring;
} else {
return $self->URI;
More information about the freeside-commits
mailing list