summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-01-18 14:03:07 -0800
committerIvan Kohler <ivan@freeside.biz>2015-01-18 14:03:07 -0800
commit85c78d955fbc2fd6c3991156b387d37c185b9f64 (patch)
tree682733a1bd4cd3e33434dac083569ca86e75d347 /FS/FS
parent89f9957267f05520fc676c378694383d16eedeb1 (diff)
disable quotations, RT#20688, RT#22232
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/AccessRight.pm1
-rw-r--r--FS/FS/Record.pm48
-rw-r--r--FS/FS/access_right.pm1
-rw-r--r--FS/FS/quotation.pm62
4 files changed, 89 insertions, 23 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 4a1f89a..121f83c 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -97,6 +97,7 @@ tie my %rights, 'Tie::IxHash',
#'New contact',
#'View customer contacts',
'Generate quotation',
+ 'Disable quotation',
],
###
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 25e61d0..4546741 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -743,72 +743,74 @@ sub _from_hashref {
return @return;
}
-## makes this easier to read
-
sub get_real_fields {
my $table = shift;
my $record = shift;
my $real_fields = shift;
- ## this huge map was previously inline, just broke it out to help read the qsearch method, should be optimized for readability
- return (
- map {
+ ## could be optimized more for readability
+ return (
+ map {
my $op = '=';
my $column = $_;
+ my $table_column = "$table.$column";
my $type = dbdef->table($table)->column($column)->type;
my $value = $record->{$column};
$value = $value->{'value'} if ref($value);
- if ( ref($record->{$_}) ) {
- $op = $record->{$_}{'op'} if $record->{$_}{'op'};
+
+ if ( ref($record->{$column}) ) {
+ $op = $record->{$column}{'op'} if $record->{$column}{'op'};
#$op = 'LIKE' if $op =~ /^ILIKE$/i && driver_name ne 'Pg';
if ( uc($op) eq 'ILIKE' ) {
$op = 'LIKE';
- $record->{$_}{'value'} = lc($record->{$_}{'value'});
- $column = "LOWER($_)";
+ $record->{$column}{'value'} = lc($record->{$column}{'value'});
+ $table_column = "LOWER($table_column)";
}
- $record->{$_} = $record->{$_}{'value'}
+ $record->{$column} = $record->{$column}{'value'}
}
- if ( ! defined( $record->{$_} ) || $record->{$_} eq '' ) {
+ if ( ! defined( $record->{$column} ) || $record->{$column} eq '' ) {
if ( $op eq '=' ) {
if ( driver_name eq 'Pg' ) {
if ( $type =~ /(int|numeric|real|float4|(big)?serial)/i ) {
- qq-( $column IS NULL )-;
+ qq-( $table_column IS NULL )-;
} else {
- qq-( $column IS NULL OR $column = '' )-;
+ qq-( $table_column IS NULL OR $table_column = '' )-;
}
} else {
- qq-( $column IS NULL OR $column = "" )-;
+ qq-( $table_column IS NULL OR $table_column = "" )-;
}
} elsif ( $op eq '!=' ) {
if ( driver_name eq 'Pg' ) {
if ( $type =~ /(int|numeric|real|float4|(big)?serial)/i ) {
- qq-( $column IS NOT NULL )-;
+ qq-( $table_column IS NOT NULL )-;
} else {
- qq-( $column IS NOT NULL AND $column != '' )-;
+ qq-( $table_column IS NOT NULL AND $table_column != '' )-;
}
} else {
- qq-( $column IS NOT NULL AND $column != "" )-;
+ qq-( $table_column IS NOT NULL AND $table_column != "" )-;
}
} else {
if ( driver_name eq 'Pg' ) {
- qq-( $column $op '' )-;
+ qq-( $table_column $op '' )-;
} else {
- qq-( $column $op "" )-;
+ qq-( $table_column $op "" )-;
}
}
} elsif ( $op eq '!=' ) {
- qq-( $column IS NULL OR $column != ? )-;
+ qq-( $table_column IS NULL OR $table_column != ? )-;
#if this needs to be re-enabled, it needs to use a custom op like
#"APPROX=" or something (better name?, not '=', to avoid affecting other
# searches
#} elsif ( $op eq 'APPROX=' && _is_fs_float( $type, $value ) ) {
- # ( "$column <= ?", "$column >= ?" );
+ # ( "$table_column <= ?", "$table_column >= ?" );
} else {
- "$column $op ?";
+ "$table_column $op ?";
}
- } @{ $real_fields } );
+
+ } @{ $real_fields }
+ );
}
=item by_key PRIMARY_KEY_VALUE
diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm
index e5a5781..d5e3b8b 100644
--- a/FS/FS/access_right.pm
+++ b/FS/FS/access_right.pm
@@ -250,6 +250,7 @@ sub _upgrade_data { # class method
'List prospects' => 'List contacts',
'List customers' => 'List contacts',
'Backdate payment' => 'Backdate credit',
+ 'Generate quotation' => 'Disable quotation',
);
# foreach my $old_acl ( keys %onetime ) {
diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm
index e72e6cf..5710b38 100644
--- a/FS/FS/quotation.pm
+++ b/FS/FS/quotation.pm
@@ -6,6 +6,7 @@ use strict;
use Tie::RefHash;
use FS::CurrentUser;
use FS::UID qw( dbh );
+use FS::Maketext qw( emt );
use FS::cust_main;
use FS::cust_pkg;
@@ -166,6 +167,38 @@ sub _total {
}
+=item cust_or_prospect_label_link P
+
+HTML links to either the customer or prospect.
+
+Returns a list consisting of two elements. The first is a text label for the
+link, and the second is the URL.
+
+=cut
+
+sub cust_or_prospect_label_link {
+ my( $self, $p ) = @_;
+
+ if ( my $custnum = $self->custnum ) {
+ my $display_custnum = $self->cust_main->display_custnum;
+ my $target = $FS::CurrentUser::CurrentUser->default_customer_view eq 'jumbo'
+ ? '#quotations'
+ : ';show=quotations';
+ (
+ emt("View this customer (#[_1])",$display_custnum) =>
+ "${p}view/cust_main.cgi?custnum=$custnum$target"
+ );
+ } elsif ( my $prospectnum = $self->prospectnum ) {
+ (
+ emt("View this prospect (#[_1])",$prospectnum) =>
+ "${p}view/prospect_main.html?$prospectnum"
+ );
+ } else { #die?
+ ( '', '' );
+ }
+
+}
+
#prevent things from falsely showing up as taxes, at least until we support
# quoting tax amounts..
sub _items_tax {
@@ -271,6 +304,35 @@ sub order {
}
+=item disable
+
+Disables this quotation (sets disabled to Y, which hides the quotation on
+prospects and customers).
+
+If there is an error, returns an error message, otherwise returns false.
+
+=cut
+
+sub disable {
+ my $self = shift;
+ $self->disabled('Y');
+ $self->replace();
+}
+
+=item enable
+
+Enables this quotation.
+
+If there is an error, returns an error message, otherwise returns false.
+
+=cut
+
+sub enable {
+ my $self = shift;
+ $self->disabled('');
+ $self->replace();
+}
+
=back
=head1 CLASS METHODS