X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FController%2FCustomerVendor.pm;h=c8fd5fd9c2e482a50cf8dfab94a961637bde6328;hb=bc89ebf428c7bde2205b31c5c9abb66879e673e4;hp=3b8f7fc77aabac18256c1b218300a2190fd7151c;hpb=34d35b6a56309c556413ca8e8b810e9e64422367;p=kivitendo-erp.git diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index 3b8f7fc77..c8fd5fd9c 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -10,6 +10,8 @@ use SL::DBUtils; use SL::Helper::Flash; use SL::Locale::String; use SL::Controller::Helper::GetModels; +use SL::Controller::Helper::ReportGenerator; +use SL::Controller::Helper::ParseFilter; use SL::DB::Customer; use SL::DB::Vendor; @@ -25,6 +27,11 @@ use SL::DB::FollowUp; use SL::DB::FollowUpLink; use SL::DB::History; use SL::DB::Currency; +use SL::DB::Invoice; +use SL::DB::PurchaseInvoice; +use SL::DB::Order; + +use Data::Dumper; use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => [ qw(customer_models vendor_models) ], @@ -34,7 +41,8 @@ use Rose::Object::MakeMethods::Generic ( __PACKAGE__->run_before( sub { $::auth->assert('customer_vendor_edit'); - } + }, + except => [ qw(ajaj_autocomplete) ], ); __PACKAGE__->run_before( '_instantiate_args', @@ -274,7 +282,7 @@ sub _transaction { my $db = $self->is_vendor() ? 'vendor' : 'customer'; my $action = 'add'; - if ($::instance_conf->get_feature_experimental && 'oe.pl' eq $script) { + if ($::instance_conf->get_feature_experimental_order && 'oe.pl' eq $script) { $script = 'controller.pl'; $action = 'Order/' . $action; } @@ -466,7 +474,6 @@ sub action_search_contact { print $::form->redirect_header($url); } - sub action_get_delivery { my ($self) = @_; @@ -579,13 +586,17 @@ sub action_ajaj_get_contact { } qw( id gender abteilung title position givenname name email phone1 phone2 fax mobile1 mobile2 - satphone satfax project street zipcode city privatphone privatemail birthday + satphone satfax project street zipcode city privatphone privatemail birthday main ) ) }; $data->{contact_cvars} = $self->_prepare_cvar_configs_for_ajaj($self->{contact}->cvars_by_config); + # avoid two or more main_cp + my $has_main_cp = grep { $_->cp_main == 1 } @{ $self->{cv}->contacts }; + $data->{contact}->{disable_cp_main} = 1 if ($has_main_cp && !$data->{contact}->{cp_main}); + $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 }); } @@ -942,10 +953,42 @@ sub _pre_render { with_objects => ['follow_up'], ); + if ( $self->is_vendor()) { + $self->{open_items} = SL::DB::Manager::PurchaseInvoice->get_all_count( + query => [ + vendor_id => $self->{cv}->id, + paid => {lt_sql => 'amount'}, + ], + ); + } else { + $self->{open_items} = SL::DB::Manager::Invoice->get_all_count( + query => [ + customer_id => $self->{cv}->id, + paid => {lt_sql => 'amount'}, + ], + ); + } + + if ( $self->is_vendor() ) { + $self->{open_orders} = SL::DB::Manager::Order->get_all_count( + query => [ + vendor_id => $self->{cv}->id, + closed => 'F', + ], + ); + } else { + $self->{open_orders} = SL::DB::Manager::Order->get_all_count( + query => [ + customer_id => $self->{cv}->id, + closed => 'F', + ], + ); + } $self->{template_args} ||= {}; $::request->{layout}->add_javascripts('kivi.CustomerVendor.js'); $::request->{layout}->add_javascripts('kivi.File.js'); + $::request->{layout}->add_javascripts('kivi.CustomerVendorTurnover.js'); $self->_setup_form_action_bar; }