summaryrefslogtreecommitdiff
path: root/FS/FS/Record.pm
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2019-02-19 14:42:25 -0500
committerChristopher Burger <burgerc@freeside.biz>2019-02-22 16:04:04 -0500
commit167a699ce4eaa68a56cd8d38a79696840ef46679 (patch)
tree31a16e45cdb2fe9a9a8dc4b6faed4c41b8402cd1 /FS/FS/Record.pm
parent3e97c5dddd83bd5268c6f54a59d96421b3ca8fbe (diff)
RT# 82092 - custom fields now save and fixed so name label is displayed insted of actual field name
Diffstat (limited to 'FS/FS/Record.pm')
-rw-r--r--FS/FS/Record.pm37
1 files changed, 36 insertions, 1 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index dfe6f18..31cc8a0 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -5,7 +5,7 @@ use strict;
use charnames ':full';
use vars qw( $AUTOLOAD
%virtual_fields_cache %fk_method_cache $fk_table_cache
- $money_char $lat_lower $lon_upper
+ %virtual_fields_hash_cache $money_char $lat_lower $lon_upper
$use_placeholders
);
use Carp qw(carp cluck croak confess);
@@ -1810,6 +1810,41 @@ sub virtual_fields {
}
+=item virtual_fields_hash [ TABLE ]
+
+Returns a list of virtual field records as a hash defined for the table. This should not
+be exported, and should only be called as an instance or class method.
+
+=cut
+
+sub virtual_fields_hash {
+ my $self = shift;
+ my $table;
+ $table = $self->table or confess "virtual_fields called on non-table";
+
+ confess "Unknown table $table" unless dbdef->table($table);
+
+ return () unless dbdef->table('part_virtual_field');
+
+ unless ( $virtual_fields_hash_cache{$table} ) {
+ $virtual_fields_hash_cache{$table} = [];
+ my $concat = [ "'cf_'", "name" ];
+ my $select = concat_sql($concat).' as name, label, length';
+ my @vfields = qsearch({
+ select => $select,
+ table => 'part_virtual_field',
+ hashref => { 'dbtable' => $table, },
+ });
+
+ foreach (@vfields) {
+ push @{ $virtual_fields_hash_cache{$table} }, $_->{Hash};
+ }
+ }
+
+ @{$virtual_fields_hash_cache{$table}};
+
+}
+
=item process_batch_import JOB OPTIONS_HASHREF PARAMS
Processes a batch import as a queued JSRPC job