use strict;
use vars qw( $AUTOLOAD @ISA @EXPORT_OK $DEBUG
$conf $me
- %virtual_fields_cache $nowarn_identical $no_update_diff );
+ %virtual_fields_cache
+ $nowarn_identical $no_update_diff $no_check_foreign
+ );
use Exporter;
use Carp qw(carp cluck croak confess);
use Scalar::Util qw( blessed );
$nowarn_identical = 0;
$no_update_diff = 0;
+$no_check_foreign = 0;
my $rsa_module;
my $rsa_loaded;
my $TYPE = SQL_VARCHAR;
if ( $type =~ /(int|(big)?serial)/i && $value =~ /^\d+(\.\d+)?$/ ) {
$TYPE = SQL_INTEGER;
+
+ #DBD::Pg 1.49: Cannot bind ... unknown sql_type 6 with SQL_FLOAT
} elsif ( ( $type =~ /(numeric)/i && $value =~ /^[+-]?\d+(\.\d+)?$/)
|| ( $type =~ /(real|float4)/i
&& $value =~ /[-+]?\d*\.?\d+([eE][-+]?\d+)?/
)
) {
- $TYPE = SQL_FLOAT;
+ $TYPE = SQL_DECIMAL;
}
if ( $DEBUG > 2 ) {
}
my $table = $self->table;
-
# Encrypt before the database
- if ($conf->exists('encryption') && defined(eval '@FS::'. $table . '::encrypted_fields')) {
+ if ( defined(eval '@FS::'. $table . '::encrypted_fields')
+ && scalar( eval '@FS::'. $table . '::encrypted_fields')
+ && $conf->exists('encryption')
+ ) {
foreach my $field (eval '@FS::'. $table . '::encrypted_fields') {
$self->{'saved'} = $self->getfield($field);
$self->setfield($field, $self->encrypt($self->getfield($field)));
}
}
-
#false laziness w/delete
my @real_fields =
grep { defined($self->getfield($_)) && $self->getfield($_) ne "" }
# If we're encrypting then don't ever store the payinfo or CVV2 in the history....
# You can see if it changed by the paymask...
- if ($conf->exists('encryption') ) {
+ if ($conf && $conf->exists('encryption') ) {
@fields = grep $_ ne 'payinfo' && $_ ne 'cvv2', @fields;
}
my @values = map { _quote( $self->getfield($_), $self->table, $_) } @fields;
$self->setfield($field,'');
} elsif ( $country eq 'US' || $country eq 'CA' ) {
$phonen =~ s/\D//g;
+ $phonen = $conf->config('cust_main-default_areacode').$phonen
+ if length($phonen)==7 && $conf->config('cust_main-default_areacode');
$phonen =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/
or return gettext('illegal_phone'). " $field: ". $self->getfield($field);
$phonen = "$1-$2-$3";
sub ut_foreign_key {
my( $self, $field, $table, $foreign ) = @_;
+ return '' if $no_check_foreign;
qsearchs($table, { $foreign => $self->getfield($field) })
or return "Can't find ". $self->table. ".$field ". $self->getfield($field).
" in $table.$foreign";