SL::DB::Contact->detach nicht automatisch speichern lassen
[kivitendo-erp.git] / SL / DB / Contact.pm
1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
3
4 package SL::DB::Contact;
5
6 use strict;
7
8 use SL::DB::MetaSetup::Contact;
9 use SL::DB::Helper::CustomVariables (
10   module      => 'Contacts',
11   cvars_alias => 1,
12 );
13
14 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
15 __PACKAGE__->meta->make_manager_class;
16
17 sub used {
18   my ($self) = @_;
19
20   return unless $self->cp_id;
21
22   require SL::DB::Order;
23   require SL::DB::Invoice;
24   require SL::DB::PurchaseInvoice;
25   require SL::DB::DeliveryOrder;
26
27   return SL::DB::Manager::Order->get_all_count(query => [ cp_id => $self->cp_id ])
28        + SL::DB::Manager::Invoice->get_all_count(query => [ cp_id => $self->cp_id ])
29        + SL::DB::Manager::PurchaseInvoice->get_all_count(query => [ cp_id => $self->cp_id ])
30        + SL::DB::Manager::DeliveryOrder->get_all_count(query => [ cp_id => $self->cp_id ]);
31 }
32
33 sub detach {
34   $_[0]->cp_cv_id(undef);
35   $_[0];
36 }
37
38 sub full_name {
39   my ($self) = @_;
40   die 'not an accessor' if @_ > 1;
41   join ', ', grep $_, $self->cp_name, $self->cp_givenname;
42 }
43
44 sub full_name_dep {
45   my ($self) = @_;
46   die 'not an accessor' if @_ > 1;
47   $self->full_name
48     . join '', map { " ($_)" } grep $_, $self->cp_abteilung;
49 }
50
51 1;