3 # Copyright (c) 2004 Kristian Hoffmann <khoff@fire2wire.com>
4 # Based on the original RT::URI::base and RT::URI::fsck_com_rt.
6 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
8 # (Except where explictly superceded by other copyright notices)
10 # This work is made available to you under the terms of Version 2 of
11 # the GNU General Public License. A copy of that license should have
12 # been provided with this software, but in any event can be snarfed
15 # This work is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # General Public License for more details.
20 # Unless otherwise specified, all modifications, corrections or
21 # extensions to this work which alter its source code become the
22 # property of Best Practical Solutions, LLC when submitted for
23 # inclusion in the work.
34 use FS::CGI qw(popurl);
35 use FS::UI::Web::small_custview;
37 use FS::Record qw(qsearchs qsearch dbdef);
43 RT::URI::freeside::Internal
47 Overlay for the RT::URI::freeside URI handler implementing the Internal integration type.
49 See L<RT::URI::freeside> for public/private interface documentation.
55 sub _FreesideGetRecord {
58 my ($table, $pkey) = ($self->{'fstable'}, $self->{'fspkey'});
60 $RT::Logger->debug("Called _FreesideGetRecord()");
62 #eval "use FS::$table;";
66 $RT::Logger->error("Using Internal freeside integration type, ".
67 "but it doesn't look like we're running under ".
68 "freeside's Mason handler.");
72 my $pkeyfield = $dbdef->table($table)->primary_key;
74 $RT::Logger->error("No primary key for freeside table '$table'");
78 my $fsrec = qsearchs($table, { $pkeyfield => $pkey });
80 $RT::Logger->error("Record with '$pkeyfield' == '$pkey' does " .
81 "not exist in table $table");
85 return { $fsrec->hash, '_object' => $fsrec };
95 sub FreesideGetConfig {
97 #$conf = new FS::Conf unless ref($conf);
98 my $conf = new FS::Conf;
100 return scalar($conf->config(@_));
104 sub smart_search { #Subroutine
106 return map { { $_->hash } } &FS::cust_main::Search::smart_search(@_);
110 sub email_search { #Subroutine
112 return map { { $_->hash } } &FS::cust_main::Search::email_search(@_);
118 return &FS::UI::Web::small_custview::small_custview(@_);
122 sub _FreesideURILabelLong {
126 my $table = $self->{'fstable'};
128 if ( $table eq 'cust_main' ) {
130 my $rec = $self->_FreesideGetRecord();
131 return small_custview( $rec->{'_object'},
132 scalar(FS::Conf->new->config('countrydefault')),
138 return $self->_FreesideURILabel();
146 my $rec = $self->_FreesideGetRecord() or return;
147 my $agent = $rec->{'_object'}->agent or return;
148 return $agent->agentnum . ': ' . $agent->agent;
153 my $rec = $self->_FreesideGetRecord() or return;
154 my $cust_class = $rec->{'_object'}->cust_class or return;
155 return $cust_class->classname;
160 my $rec = $self->_FreesideGetRecord() or return;
161 my @part_tag = $rec->{'_object'}->part_tag;
163 { 'name' => $_->tagname,
164 'desc' => $_->tagdesc,
165 'color' => $_->tagcolor }