X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FContact.pm;h=bed7e9cd6f4f0d7090fe2cb237c6b1f6bbadbcdb;hb=0ebb8f829ac2d23b65e8d993c7d03aa0b172b637;hp=aa74bea3dddcee3d50adceee8806802652dfe4cf;hpb=2974447a09f906718f8f2485d62a32c2cbdb56b5;p=kivitendo-erp.git diff --git a/SL/DB/Contact.pm b/SL/DB/Contact.pm index aa74bea3d..bed7e9cd6 100644 --- a/SL/DB/Contact.pm +++ b/SL/DB/Contact.pm @@ -1,18 +1,36 @@ -# This file has been auto-generated only because it didn't exist. -# Feel free to modify it at will; it will not be overwritten automatically. - package SL::DB::Contact; use strict; use SL::DB::MetaSetup::Contact; +use SL::DB::Manager::Contact; use SL::DB::Helper::CustomVariables ( module => 'Contacts', cvars_alias => 1, ); -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->make_manager_class; +__PACKAGE__->meta->initialize; + +sub used { + my ($self) = @_; + + return unless $self->cp_id; + + require SL::DB::Order; + require SL::DB::Invoice; + require SL::DB::PurchaseInvoice; + require SL::DB::DeliveryOrder; + + return SL::DB::Manager::Order->get_all_count(query => [ cp_id => $self->cp_id ]) + + SL::DB::Manager::Invoice->get_all_count(query => [ cp_id => $self->cp_id ]) + + SL::DB::Manager::PurchaseInvoice->get_all_count(query => [ cp_id => $self->cp_id ]) + + SL::DB::Manager::DeliveryOrder->get_all_count(query => [ cp_id => $self->cp_id ]); +} + +sub detach { + $_[0]->cp_cv_id(undef); + $_[0]; +} sub full_name { my ($self) = @_; @@ -27,4 +45,10 @@ sub full_name_dep { . join '', map { " ($_)" } grep $_, $self->cp_abteilung; } +sub formal_greeting { + my ($self) = @_; + die 'not an accessor' if @_ > 1; + join ' ', grep $_, $self->cp_title, $self->cp_givenname, $self->cp_name; +} + 1;