X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FContact.pm;h=d891f0781e1e7274cb4a6011dc923c32d7bcecdf;hb=76a2823e654382ba101b4a611dd351a8c87034a1;hp=aa74bea3dddcee3d50adceee8806802652dfe4cf;hpb=9209583a11c108b33ce24ebfc8d26fc1ef1f8268;p=kivitendo-erp.git diff --git a/SL/DB/Contact.pm b/SL/DB/Contact.pm index aa74bea3d..d891f0781 100644 --- a/SL/DB/Contact.pm +++ b/SL/DB/Contact.pm @@ -14,6 +14,27 @@ use SL::DB::Helper::CustomVariables ( # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. __PACKAGE__->meta->make_manager_class; +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) = @_; die 'not an accessor' if @_ > 1;