From: Moritz Bunkus Date: Fri, 1 Feb 2013 15:04:36 +0000 (+0100) Subject: Customer-Controller: 'get_hourly_rate'-AJAX-Funktion X-Git-Tag: release-3.2.0beta~467^2~252 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/commitdiff_plain/d157b20fa9377ec48a8b00b7f5ccf8299897f0d2 Customer-Controller: 'get_hourly_rate'-AJAX-Funktion --- diff --git a/SL/Controller/Customer.pm b/SL/Controller/Customer.pm new file mode 100644 index 000000000..d6ba13dc6 --- /dev/null +++ b/SL/Controller/Customer.pm @@ -0,0 +1,29 @@ +package SL::Controller::Customer; + +use strict; +use parent qw(SL::Controller::Base); + +use SL::DB::Customer; +use SL::JSON; + +# safety +__PACKAGE__->run_before(sub { $::auth->assert('customer_vendor_edit') }); + +sub action_get_hourly_rate { + my ($self, %params) = @_; + + my $customer; + $customer = SL::DB::Customer->new(id => $::form->{id})->load if $::form->{id}; + my $data = {}; + + if ($customer) { + $data = { + hourly_rate => $customer->hourly_rate * 1, + hourly_rate_formatted => $::form->format_amount(\%::myconfig, $customer->hourly_rate, 2), + }; + } + + $self->render(\to_json($data), { type => 'json' }); +} + +1;