Reste der Tabellen "rma" und "rmaitems" entfernt
[kivitendo-erp.git] / SL / DB / Manager / Project.pm
1 package SL::DB::Manager::Project;
2
3 use strict;
4
5 use parent qw(SL::DB::Helper::Manager);
6
7 use SL::DB::Helper::Paginated;
8 use SL::DB::Helper::Sorted;
9
10 sub object_class { 'SL::DB::Project' }
11
12 __PACKAGE__->make_manager_methods;
13
14 our %project_id_column_prefixes = (
15   ar              => 'global',
16   ap              => 'global',
17   oe              => 'global',
18   delivery_orders => 'global',
19 );
20
21 our @tables_with_project_id_cols = qw(acc_trans ap ar delivery_order_items delivery_orders invoice oe orderitems);
22
23 sub _sort_spec {
24   return (
25     default    => [ 'projectnumber', 1 ],
26     columns    => {
27       SIMPLE   => 'ALL',
28       customer => 'customer.name',
29     });
30 }
31
32 sub is_not_used_filter {
33   my ($class, $prefix) = @_;
34
35   my $query = join ' UNION ', map {
36     my $column = $project_id_column_prefixes{$_} . 'project_id';
37     qq|SELECT DISTINCT ${column} FROM ${_} WHERE ${column} IS NOT NULL|
38   } @tables_with_project_id_cols;
39
40   return ("!${prefix}id" => [ \"(${query})" ]);
41 }
42
43 1;
44 __END__
45
46 =pod
47
48 =encoding utf8
49
50 =head1 NAME
51
52 SL::DB::Manager::Project - Manager for models for the 'project' table
53
54 =head1 SYNOPSIS
55
56 This is a standard Rose::DB::Manager based model manager and can be
57 used as such.
58
59 =head1 FUNCTIONS
60
61 =over 4
62
63 =item C<is_not_used_filter>
64
65 Returns an array containing a partial filter suitable for the C<query>
66 parameter that limits to projects that are not referenced from any
67 other database table.
68
69 =back
70
71 =head1 BUGS
72
73 Nothing here yet.
74
75 =head1 AUTHOR
76
77 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
78
79 =cut