kivitendo/SL/DB/Manager/Order.pm @ f7fd4311
82515b2d | Sven Schöling | package SL::DB::Manager::Order;
|
||
use strict;
|
||||
fd0a62ab | Moritz Bunkus | use parent qw(SL::DB::Helper::Manager);
|
||
use SL::DB::Helper::Paginated;
|
||||
use SL::DB::Helper::Sorted;
|
||||
23c5a950 | Sven Schöling | use SL::DB::Helper::Filtered;
|
||
82515b2d | Sven Schöling | |||
sub object_class { 'SL::DB::Order' }
|
||||
__PACKAGE__->make_manager_methods;
|
||||
23c5a950 | Sven Schöling | __PACKAGE__->add_filter_specs(
|
||
type => sub {
|
||||
my ($key, $value, $prefix) = @_;
|
||||
return __PACKAGE__->type_filter($value, $prefix);
|
||||
},
|
||||
all => sub {
|
||||
my ($key, $value, $prefix) = @_;
|
||||
return or => [ map { $prefix . $_ => $value } qw(ordnumber quonumber customer.name vendor.name transaction_description) ]
|
||||
}
|
||||
);
|
||||
82515b2d | Sven Schöling | sub type_filter {
|
||
ba0fb69c | Sven Schöling | my $class = shift;
|
||
my $type = lc(shift || '');
|
||||
my $prefix = shift || '';
|
||||
return (and => [ "!${prefix}customer_id" => undef, "${prefix}quotation" => 1 ]) if $type eq 'sales_quotation';
|
||||
return (and => [ "!${prefix}vendor_id" => undef, "${prefix}quotation" => 1 ]) if $type eq 'request_quotation';
|
||||
return (and => [ "!${prefix}customer_id" => undef, or => [ "${prefix}quotation" => 0, "${prefix}quotation" => undef ] ]) if $type eq 'sales_order';
|
||||
return (and => [ "!${prefix}vendor_id" => undef, or => [ "${prefix}quotation" => 0, "${prefix}quotation" => undef ] ]) if $type eq 'purchase_order';
|
||||
82515b2d | Sven Schöling | |||
die "Unknown type $type";
|
||||
}
|
||||
fd0a62ab | Moritz Bunkus | sub _sort_spec {
|
||
return (
|
||||
default => [ 'transdate', 1 ],
|
||||
nulls => {
|
||||
transaction_description => 'FIRST',
|
||||
customer_name => 'FIRST',
|
||||
168836cf | Moritz Bunkus | vendor_name => 'FIRST',
|
||
fd0a62ab | Moritz Bunkus | default => 'LAST',
|
||
},
|
||||
columns => {
|
||||
SIMPLE => 'ALL',
|
||||
284470c1 | Moritz Bunkus | customer => 'lower(customer.name)',
|
||
vendor => 'lower(vendor.name)',
|
||||
fd0a62ab | Moritz Bunkus | globalprojectnumber => 'lower(globalproject.projectnumber)',
|
||
9c7262bf | Sven Schöling | |||
# Bug in Rose::DB::Object: the next should be
|
||||
# "globalproject.project_type.description". This workaround will
|
||||
# only work if no other table with "project_type" is visible in
|
||||
# the current query
|
||||
globalproject_type => 'lower(project_type.description)',
|
||||
fd0a62ab | Moritz Bunkus | map { ( $_ => "lower(oe.$_)" ) } qw(ordnumber quonumber cusordnumber shippingpoint shipvia notes intnotes transaction_description),
|
||
});
|
||||
}
|
||||
sub default_objects_per_page { 40 }
|
||||
82515b2d | Sven Schöling | 1;
|