use strict;
-use SL::DB::Helpers::Manager;
-use base qw(SL::DB::Helpers::Manager);
+use parent qw(SL::DB::Helper::Manager);
+
+use SL::DB::Helper::Paginated;
+use SL::DB::Helper::Sorted;
sub object_class { 'SL::DB::Order' }
__PACKAGE__->make_manager_methods;
sub type_filter {
- my $class = shift;
- my $type = lc(shift || '');
+ my $class = shift;
+ my $type = lc(shift || '');
+ my $prefix = shift || '';
- return (and => [ '!customer_id' => undef, quotation => 1 ]) if $type eq 'sales_quotation';
- return (and => [ '!vendor_id' => undef, quotation => 1 ]) if $type eq 'request_quotation';
- return (and => [ '!customer_id' => undef, or => [ quotation => 0, quotation => undef ] ]) if $type eq 'sales_order';
- return (and => [ '!vendor_id' => undef, or => [ quotation => 0, quotation => undef ] ]) if $type eq 'purchase_order';
+ 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';
die "Unknown type $type";
}
+sub _sort_spec {
+ return (
+ default => [ 'transdate', 1 ],
+ nulls => {
+ transaction_description => 'FIRST',
+ customer_name => 'FIRST',
+ vendor_name => 'FIRST',
+ default => 'LAST',
+ },
+ columns => {
+ SIMPLE => 'ALL',
+ customer => 'customer.name',
+ vendor => 'vendor.name',
+ globalprojectnumber => 'lower(globalproject.projectnumber)',
+ map { ( $_ => "lower(oe.$_)" ) } qw(ordnumber quonumber cusordnumber shippingpoint shipvia notes intnotes transaction_description),
+ });
+}
+
+sub default_objects_per_page { 40 }
+
1;