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.
29 no warnings qw(redefine);
35 use FS::CGI qw(popurl 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::smart_search(@_);
112 return &FS::CGI::small_custview(@_);
116 sub _FreesideURILabelLong {
120 my $table = $self->{'fstable'};
122 if ( $table eq 'cust_main' ) {
124 my $rec = $self->_FreesideGetRecord();
125 return small_custview( $rec->{'_object'},
126 scalar(FS::Conf->new->config('countrydefault')),
132 return $self->_FreesideURILabel();